Package org.boco.seamwebappgen.info

Examples of org.boco.seamwebappgen.info.InfoReader


    String deleteDerivateBeans = "";

    String masterDetail1To1Check = "";
    String sons = "";

    InfoReader infoReader = new InfoReader(sourceDir);

    CodeChunk listMethods = new CodeChunk(0);

    Vector<ShowAttribute> attrs = bean.getShowAttributes();

    attrs.add(bean.getKey());

    /** **************************** */
    /** Genera interfaccia Remota * */
    /** **************************** */
    String template = "." + File.separator + "templates" + File.separator + "Seam_ManagerInterfaceRemote.java";
    String sourceFile = sourceDir + ".." + File.separator + "src" + File.separator + basePackage + File.separator + "manager/managerInterface" + File.separator + "remote" + File.separator + bean.getName() + "ManagerRemote.java";
    String targetFile = targetDir + "src" + File.separator + basePackage + File.separator + "manager/managerInterface" + File.separator + "remote" + File.separator + bean.getName() + "ManagerRemote.java";

    LinkedList<String> yourCode = Utils.getYourCode(sourceFile, CustomCodeType.JAVA);

    HashMap<String, String> tags = new HashMap<String, String>();

    tags.put("@basePackage", basePackage);
    tags.put("@Bean", bean.getName());
    tags.put("@bean", Utils.makeFirstLetterLowerCase(bean.getName()));

    Utils.SeamReplaceTagAndSave(tags, yourCode, template, targetFile);

    /** **************************** */
    /** Genera interfaccia Locale * */
    /** **************************** */

    template = "." + File.separator + "templates" + File.separator + "Seam_ManagerInterface.java";
    sourceFile = sourceDir + ".." + File.separator + "src" + File.separator + basePackage + File.separator + "manager/managerInterface" + File.separator + bean.getName() + "Manager.java";
    targetFile = targetDir + "src" + File.separator + basePackage + File.separator + "manager/managerInterface" + File.separator + bean.getName() + "Manager.java";

    yourCode = Utils.getYourCode(sourceFile, CustomCodeType.JAVA);

    /** Metodi per ordinamento **/

    orderingFunctions = generateBeanManagerInterface_OrderingFunctions(attrs);

    /** Metodi per la alimentazione dei listbox * */
    /*************************************************************************
     * Sono interessate le relazioni :1 ed :n verso questo bean, implementate
     * come list box i campi di ricerca implementati come listBox
     *
     ************************************************************************/
    Vector<Relationship> relationships2ThisBean = infoReader.getAllRelationship2ThisBean(bean.getName());

    for (int i = 0; i < relationships2ThisBean.size(); i++)
    {
      Relationship rel = relationships2ThisBean.get(i);

      if (rel.isUsed() || belongs2SearchAttribute(infoReader.getBean(rel.getFromBeanName()), rel))
      {
        if (rel.isListBox() || belongs2SearchAttribute(infoReader.getBean(rel.getFromBeanName()), rel))
        {
          String relatedAttributes = "";
          for (int k = 0; k < rel.getRelatedAttributes().size(); k++)
          {
            relatedAttributes += Utils.makeFirstLetterUpperCase(rel.getRelatedAttributes().get(k).getName());
          }

          CodeChunk tmp = new CodeChunk(0);

          tmp.addJavaCode("\tpublic HashMap<String, " + bean.getName() + "> get" + bean.getName() + "List");
          tmp.addJavaCode(relatedAttributes);
          tmp.addJavaCode("() throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;\r\n\r\n");

          if (!listMethods.getJavaCode().contains(tmp.getJavaCode()))
          {
            // listMethods.addJavaCode(tmp.getJavaCode());
          }
        }

        if (rel.isMasterDetail() && !rel.isFromMaster())
        {
          Vector<ShowList> lists = infoReader.getLists(rel.getFromBeanName());
          for (ShowList list : lists)
          {
            goToDetails += "public String goTo" + list.getName() + "();\r\n";
          }
        }
      }
    }

    /**
     * Inserimento funzione getPath se il bean e' master o detail in almeno una
     * relazione *
     */
    boolean getPath = false;
    String getPathFunction = "";
    for (int i = 0; i < bean.getRelationships().size(); i++)
    {
      Relationship relationship = bean.getRelationships().get(i);
      if (relationship.isUsed() && relationship.isMasterDetail())
        getPath = true;
    }
    if (getPath)
    {
      getPathFunction += "\r\n";
      getPathFunction += "\tpublic String getPath();\r\n";
    }

    /** Gestione della local search * */
    localSearch += "";
    localSearch += "\tpublic boolean isLocalSearch();\r\n";
    localSearch += "\tpublic void setLocalSearch(boolean search);\r\n";
    localSearch += "\tpublic void startLocalSearch();\r\n";
    localSearch += "\tpublic void stopLocalSearch();\r\n\r\n";

    // Getter e Setter per gli attributi di ricerca locale

    for (int i = 0; i < bean.getLocalSearchAttributes().size(); i++)
    {
      SearchAttribute attr = bean.getLocalSearchAttributes().get(i);

      if (attr.getImplementationType() == AttributeImplementationType.TEXT || attr.getImplementationType() == AttributeImplementationType.TEXTAREA)
      {
        localSearch += "\tpublic String getLocalSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + "();\r\n";
        localSearch += "\tpublic void setLocalSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + "(String localSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + ");\r\n";
      }
      else
      {
        if (attr.belongsToRelationship())
        {
          if (attr.getRelationship().isToMany())
          {
            localSearch += "\tpublic List<" + attr.getRelationship().getToBeanName() + "> getLocalSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "();\r\n";
            localSearch += "\tpublic void setLocalSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "(List<" + attr.getRelationship().getToBeanName() + "> localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + ");\r\n";
          }
          else
          {
            localSearch += "\tpublic " + attr.getRelationship().getToBeanName() + " getLocalSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "();\r\n";
            localSearch += "\tpublic void setLocalSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "(" + attr.getRelationship().getToBeanName() + " localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + ");\r\n";
          }
        }
      }
    }

    //    /** Gettere e Setter degli attributi della ricerca locale relativi a listbox e per i quali non funziona la injection **/
    //   
    //    for (int i = 0; i < bean.getLocalSearchAttributes().size(); i++)
    //    {
    //     
    //    }

    tags = new HashMap<String, String>();

    tags.put("@basePackage", basePackage);
    tags.put("@Bean", bean.getName());
    tags.put("@bean", Utils.makeFirstLetterLowerCase(bean.getName()));
    tags.put("@ListMethods", listMethods.getJavaCode());
    tags.put("@OrderingFunctions", orderingFunctions);
    tags.put("@GetPath", getPathFunction);
    tags.put("@GoToDetails", goToDetails);
    tags.put("@LocalSearch", localSearch);

    Utils.SeamReplaceTagAndSave(tags, yourCode, template, targetFile);

    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */
    /** Genera bean * */
    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */

    goToDetails = "";

    template = "." + File.separator + "templates" + File.separator + "Seam_ManagerBean.java";
    sourceFile = sourceDir + ".." + File.separator + "src" + File.separator + basePackage + File.separator + "manager" + File.separator + bean.getName() + "ManagerBean.java";
    targetFile = targetDir + "src" + File.separator + basePackage + File.separator + "manager" + File.separator + bean.getName() + "ManagerBean.java";

    yourCode = Utils.getYourCode(sourceFile, CustomCodeType.JAVA);

    findAll = generateFindAllBody(infoReader, bean, relationships2ThisBean);

    /**
     * Gestione scope del Manager
     */
    scope = bean.getScope();

    /**
     * Gestione Search
     */
    search += "@Factory(\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "SearchList\")\r\n";
    search += "\t@Begin(join = true)\r\n";
    search += "\tpublic void search() throws Exception\r\n";
    search += "\t{\r\n";

    search += "\t\tlog.info(\"search\");\r\n";

    search += "\t\tif(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Search == null)\r\n";
    search += "\t\t\treturn;\r\n\r\n";

    search += "\t\tString customFilter = \"\";\r\n";
    search += "\t\tQueryBuilder qb = new QueryBuilder(entityManager);\r\n\r\n";

    search += "\t\tqb.addSelect(\"o\");\r\n";
    search += "\t\tqb.addFrom(\"" + bean.getName() + " o\");\r\n";

    search += "\r\n";

    search += "\t\tqb.addTextWhere(customFilter,customFilter);\r\n\r\n";

    search += "\t\tswitch (order)\r\n";
    search += "\t\t{\r\n";

    int orderIndex = 1;
    String defaultOrdering = "";
    for (int i = 0; i < attrs.size(); i++)
    {
      ShowAttribute attr = attrs.get(i);

      if (!attr.isKey())
      {
        if (!attr.belongsToRelationship())
        {
          if (!attr.isTrans())
          {
            search += "\t\t\tcase " + orderIndex + ":\r\n";
            search += "\t\t\t\tqb.addOrderBy(\"o." + attr.getName() + " desc\");\r\n";
            search += "\t\t\t\tbreak;\r\n";
            orderIndex++;

            search += "\t\t\tcase " + orderIndex + ":\r\n";
            search += "\t\t\t\tqb.addOrderBy(\"o." + attr.getName() + " asc\");\r\n";
            search += "\t\t\t\tbreak;\r\n\r\n";
            orderIndex++;

            if (attr.getDefaultOrderingAttribute().equals("Asc"))
              defaultOrdering += "qb.addOrderBy(\"o." + attr.getName() + " asc\")";

            if (attr.getDefaultOrderingAttribute().equals("Desc"))
              defaultOrdering += "qb.addOrderBy(\"o." + attr.getName() + " desc\")";
          }
          else
          {
            orderIndex += 2;
          }
        }
        else
        {
          if (!attr.getRelationship().isToMany())
          {
            //            search += "\t\t\tcase " + orderIndex + ":\r\n";
            //            search += "\t\t\t\tqb.addOrderBy(\"o." + Utils.makeMethod2Field(attr.getRelationship().getName()) + "." + attr.getName() + " desc\");\r\n";
            //            search += "\t\t\t\tbreak;\r\n";
            //            orderIndex++;
            //
            //            search += "\t\t\tcase " + orderIndex + ":\r\n";
            //            search += "\t\t\t\tqb.addOrderBy(\"o." + Utils.makeMethod2Field(attr.getRelationship().getName()) + "." + attr.getName() + " asc\");\r\n";
            //            search += "\t\t\t\tbreak;\r\n\r\n";
            //            orderIndex++;
            //
            //            if (attr.getDefaultOrderingAttribute().equals("Asc"))
            //              defaultOrdering += "qb.addOrderBy(\"o." + Utils.makeMethod2Field(attr.getRelationship().getName()) + "." + attr.getName() + " asc\")";
            //
            //            if (attr.getDefaultOrderingAttribute().equals("Desc"))
            //              defaultOrdering += "qb.addOrderBy(\"o." + Utils.makeMethod2Field(attr.getRelationship().getName()) + "." + attr.getName() + " desc\")";

            search += "\t\t\tcase " + orderIndex + ":\r\n";
            search += "\t\t\t\tqb.addOrderBy(\"o.";

            for (int j = 0; j < attr.getRelationships().size(); j++)
            {
              search += Utils.makeMethod2Field(attr.getRelationships().get(j).getName()) + ".";
            }

            search += attr.getNameForOrdering() + " desc\");\r\n";
            search += "\t\t\t\tbreak;\r\n";
            orderIndex++;

            search += "\t\t\tcase " + orderIndex + ":\r\n";
            search += "\t\t\t\tqb.addOrderBy(\"o.";

            for (int j = 0; j < attr.getRelationships().size(); j++)
            {
              search += Utils.makeMethod2Field(attr.getRelationships().get(j).getName()) + ".";
            }

            search += attr.getNameForOrdering() + " asc\");\r\n";

            search += "\t\t\t\tbreak;\r\n\r\n";
            orderIndex++;

            if (attr.getDefaultOrderingAttribute().equals("Asc"))
              defaultOrdering += "qb.addOrderBy(\"o." + Utils.makeMethod2Field(attr.getRelationship().getName()) + "." + attr.getNameForOrdering() + " asc\")";

            if (attr.getDefaultOrderingAttribute().equals("Desc"))
              defaultOrdering += "qb.addOrderBy(\"o." + Utils.makeMethod2Field(attr.getRelationship().getName()) + "." + attr.getNameForOrdering() + " desc\")";
          }
        }
      }
    }

    search += "\t\t\tdefault:\r\n";
    if (defaultOrdering.equals(""))
      search += "\t\t\t\tqb.addOrderBy(\"o.id desc\");\r\n";
    else
      search += "\t\t\t\t" + defaultOrdering + ";\r\n";

    search += "\t\t}\r\n\r\n";

    /** Condizioni della ricerca **/
   
    for (int i = 0; i < bean.getSearchAttributes().size(); i++)
    {
      SearchAttribute attr = bean.getSearchAttributes().get(i);

      if (!attr.belongsToRelationship())
      {
        /** Non appartiene ad una relazione **/
        if (attr.getImplementationType().equals(AttributeImplementationType.TEXT))
        {
          if (attr.getType().equals("java.lang.String"))
          {
            search += "\t\tqb.addTextWhere(\"upper(o." + attr.getName() + ") like upper('%\"+" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Search." + Utils.makeGet(attr.getName()) + "()+\"%')\", " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Search." + Utils.makeGet(attr.getName()) + "());\r\n";
          }
          else
          {
            search += "\t\tqb.addTextWhere(\"o." + attr.getName() + " = ?"+i+"\", " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Search." + Utils.makeGet(attr.getName()) + "());\r\n";           
          }
        }
      }
      else
      {
        /** Non appartiene ad una relazione **/
      }

    }

    search += "\r\n";
    search += "// YOUR CODE GOES HERE\r\n";
    search += "@YourCode";
    search += "// END OF YOUR CODE\r\n\r\n";

   
    /** Parametri Condizioni della ricerca **/
   
    for (int i = 0; i < bean.getSearchAttributes().size(); i++)
    {
      SearchAttribute attr = bean.getSearchAttributes().get(i);

      if (!attr.belongsToRelationship())
      {
        /** Non appartiene ad una relazione **/
        if (attr.getImplementationType().equals(AttributeImplementationType.TEXT))
        {
          if (attr.getType().equals("java.lang.String"))
          {
          }
          else
          {
            search += "\t\tqb.setParameter(\""+i+"\", " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Search." + Utils.makeGet(attr.getName()) + "());\r\n";
          }
        }
      }
      else
      {
        /** Non appartiene ad una relazione **/
      }

    }
   
    search += "\r\n";
    search += "// YOUR CODE GOES HERE\r\n";
    search += "@YourCode";
    search += "// END OF YOUR CODE\r\n\r\n";
   
    search += "\t\tentityManager.clear();\r\n";
    search += "\r\n";
    search += "\t\t" + Utils.makeFirstLetterLowerCase(bean.getName()) + "SearchList = qb.getEjbQuery().getResultList();\r\n";
    search += "\r\n";

    /** Gestione dell'ordinamento dei campi transient **/

    search += "\t\tswitch (order)\r\n";
    search += "\t\t{\r\n";

    orderIndex = 1;

    for (int i = 0; i < attrs.size(); i++)
    {
      ShowAttribute attr = attrs.get(i);

      if (!attr.isKey())
      {
        if (!attr.belongsToRelationship())
        {
          // Attributo del bean

          if (attr.isTrans())
          {
            search += "\t\t\tcase " + orderIndex + ":\r\n";
            search += "\t\t\t\t" + Utils.makeFirstLetterLowerCase(bean.getName()) + "SearchList = SeamUtility.orderBy(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "SearchList, \"" + attr.getNameForOrdering() + "\", GenericFieldComparator.OrderType.DESC);\r\n";
            search += "\t\t\t\tbreak;\r\n";
            orderIndex++;

            search += "\t\t\tcase " + orderIndex + ":\r\n";
            search += "\t\t\t\t" + Utils.makeFirstLetterLowerCase(bean.getName()) + "SearchList = SeamUtility.orderBy(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "SearchList, \"" + attr.getNameForOrdering() + "\", GenericFieldComparator.OrderType.ASC);\r\n";
            search += "\t\t\t\tbreak;\r\n\r\n";
            orderIndex++;
          }
          else
          {
            orderIndex += 2;
          }
        }
        else
        {
          // Attributo di una relazione
          orderIndex += 2;
        }
      }
    }
    search += "\t\t}\r\n\r\n";

    if (bean.getSearchActions().size() > 0 || bean.getSearchImmediateActions().size() > 0)
    {
      search += "\t\tselections.clear();\r\n";
      search += "\t\tfor(" + bean.getName() + " item : " + Utils.makeFirstLetterLowerCase(bean.getName()) + "SearchList)\r\n";
      search += "\t\t{\r\n";
      search += "\t\t\tselections.put(item, true);\r\n";
      search += "\t\t}\r\n";
    }

    search += "\t}\r\n";

    orderingFunctions = "";
    orderIndex = 1;
    for (int i = 0; i < attrs.size(); i++)
    {
      ShowAttribute attr = attrs.get(i);

      if (!attr.isKey())
      {
        if (!attr.belongsToRelationship())
        {
          orderingFunctions += "\tpublic void orderBy" + (i + 1) + "A()\r\n";
          orderingFunctions += "\t{\r\n";
          orderingFunctions += "\t\torder = " + orderIndex + ";\r\n";
          orderingFunctions += "\t\tfindAll();\r\n";
          orderingFunctions += "\t}\r\n";
          orderIndex++;

          orderingFunctions += "\tpublic void orderBy" + (i + 1) + "D()\r\n";
          orderingFunctions += "\t{\r\n";
          orderingFunctions += "\t\torder = " + orderIndex + ";\r\n";
          orderingFunctions += "\t\tfindAll();\r\n";
          orderingFunctions += "\t}\r\n";
          orderIndex++;
        }
        else
        {
          if (!attr.getRelationship().isToMany())
          {
            orderingFunctions += "\tpublic void orderBy" + (i + 1) + "A()\r\n";
            orderingFunctions += "\t{\r\n";
            orderingFunctions += "\t\torder = " + orderIndex + ";\r\n";
            orderingFunctions += "\t\tfindAll();\r\n";
            orderingFunctions += "\t}\r\n";
            orderIndex++;

            orderingFunctions += "\tpublic void orderBy" + (i + 1) + "D()\r\n";
            orderingFunctions += "\t{\r\n";
            orderingFunctions += "\t\torder = " + orderIndex + ";\r\n";
            orderingFunctions += "\t\tfindAll();\r\n";
            orderingFunctions += "\t}\r\n";
            orderIndex++;
          }
        }
      }
    }

    /** Metodi per la alimentazione dei listbox * */
    /**
     * Sono interessate le relazioni :1 ed :n verso questo bean, implementate
     * come list box *
     */

    // listMethods = generateBeanManager_ListBoxFunctions(infoReader, bean, relationships2ThisBean);
    listMethods = new CodeChunk(0);

    /** Riferimenti ai bean che utilizzano questo bean come popup * */
    Vector<Relationship> relationshipToThisBean = infoReader.getAllRelationship2ThisBean(bean.getName());
    for (Relationship rel : relationshipToThisBean)
    {
      if (rel.isUsed() && !rel.isListBox())
      {
        String callingBean = "";

        if (rel.isFromMany())
        {
          callingBean += "\r\n\t@In(required = false, scope=ScopeType.CONVERSATION)\r\n";
          callingBean += "\tprivate " + rel.getFromBeanName() + "\t\t\t\t\t\t\t\t\t\t\t" + Utils.makeFirstLetterLowerCase(rel.getFromBeanName()) + " = null;\r\n";

          if (!callingBeans.contains(callingBean))
            callingBeans += callingBean;

          callingBean = "\r\n\t@In(required=false,create=true,value=\"" + Utils.makeFirstLetterLowerCase(rel.getFromBeanName()) + "Search\")\r\n";
          callingBean += "\tprivate " + rel.getFromBeanName() + "\t\t\t\t\t\t\t\t\t\t\t" + Utils.makeFirstLetterLowerCase(rel.getFromBeanName()) + "Search;\r\n";

          if (!callingBeans.contains(callingBean))
            callingBeans += callingBean;

          // Debbono essere aggiunti anche tutti i bean derivati
          Vector<String> derivedBeans = infoReader.getDerivedBeans(rel.getFromBeanName());

          ;
          for (String derivedBean : derivedBeans)
          {
            callingBean = "\r\n\t@In(required = false)\r\n";
            callingBean += "\tprivate " + derivedBean + "\t\t\t\t\t\t\t\t\t\t\t" + Utils.makeFirstLetterLowerCase(derivedBean) + "        = null;\r\n";

            if (!callingBeans.contains(callingBean))
              callingBeans += callingBean;
          }
        }
        else
        {
          callingBean += "\r\n\t@In(required = false, scope=ScopeType.CONVERSATION)\r\n";
          callingBean += "\tprivate " + rel.getFromBeanName() + "\t\t\t\t\t\t\t\t\t\t\t" + Utils.makeFirstLetterLowerCase(rel.getFromBeanName()) + "        = null;\r\n";

          if (!callingBeans.contains(callingBean))
            callingBeans += callingBean;

          callingBean = "\r\n\t@In(required=false,create=true,value=\"" + Utils.makeFirstLetterLowerCase(rel.getFromBeanName()) + "Search\")\r\n";
          callingBean += "\tprivate " + rel.getFromBeanName() + "\t\t\t\t\t\t\t\t\t\t\t" + Utils.makeFirstLetterLowerCase(rel.getFromBeanName()) + "Search;\r\n";

          if (!callingBeans.contains(callingBean))
            callingBeans += callingBean;
        }
      }
    }

    categorizedRelationshipToMaster = "";

    /** Gestione delle relazioni di cui questo bean non e' owner * */
    for (int i = 0; i < bean.getRelationships().size(); i++)
    {
      Relationship relationship = bean.getRelationships().get(i);
      Relationship inverseRelationship = infoReader.getInverseRelationship(bean, relationship);

      /** Gestione delle relazioni in cui questo bean e' owner e la relazione inversa e' implementata come POPUP
       */
      //      if ( (relationship.getMappedBy()==null || relationship.getMappedBy().equals("")) && inverseRelationship!=null && inverseRelationship.isUsed() && !inverseRelationship.isMasterDetail() && !inverseRelationship.isListBox() && !inverseRelationship.getName().contains("Upload"))
      //      {       
      //        ownedRelationshipCreate += Utils.makeFirstLetterLowerCase(bean.getName())+"."+Utils.switchGet2Set(relationship.getName())+"("+Utils.makeFirstLetterLowerCase(relationship.getToBeanName())+");\r\n";
      //      }
      /** Inizializzazione delle relazioni :1 implementate come listbox **/
      //      if ( !relationship.isToMany() && relationship.isListBox() )
      //      {
      //        // Inizializzazione delle relazioni lazy per la modifica !!!
      //        initilizeLazyRelationshipEdit += "\t\tHibernate.initialize(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + relationship.getName() + "());\r\n";
      //      }
      /**
       * Inizializzazione della relazione al Master nella create e se il
       * Detail è categorizzato *
       */
      if (relationship.isMasterDetail() && !relationship.isFromMaster() && inverseRelationship.isCategorized())
      {
        categorizedRelationshipToMaster = "\tif (SeamUtility.getParameter(facesContext,\"" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + "Id\")!=null)\r\n";
        categorizedRelationshipToMaster += "\t\t" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.switchGet2Set(relationship.getName()) + "(" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + "Manager.find(new Long(SeamUtility.getParameter(facesContext,\"" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + "Id\"))));\r\n";
      }

      if (relationship.isFromMany() || relationship.isToMany())
      {
        /**
         * Gestione relazioni N:M - 1:N - N:1
         *
         */

        if (!relationship.isFromMany())
        {
          // Cancellazione
          notOwnedRelationshipDelete += "\r\n\r\n";
          notOwnedRelationshipDelete += "\t\tList<" + relationship.getToBeanName() + "> " + Utils.makeMethod2Field(relationship.getName()) + " = " + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + relationship.getName() + "();\r\n";
          notOwnedRelationshipDelete += "\r\n";
          notOwnedRelationshipDelete += "\t\tfor (" + relationship.getToBeanName() + " local" + relationship.getToBeanName() + " : " + Utils.makeMethod2Field(relationship.getName()) + ")\r\n";
          notOwnedRelationshipDelete += "\t\t{\r\n";
          notOwnedRelationshipDelete += "\t\t\tlocal" + relationship.getToBeanName() + "." + Utils.makeSet(relationship.getMappedBy()) + "(null);\r\n";
          notOwnedRelationshipDelete += "\t\t\tentityManager.merge(local" + relationship.getToBeanName() + ");\r\n";
          notOwnedRelationshipDelete += "\t\t}";
        }
        else
        {
          if (relationship.getMappedBy() != null && !relationship.getMappedBy().equals(""))
          {
            notOwnedRelationshipDelete += "\r\n\r\n";
            notOwnedRelationshipDelete += "\t\tList<" + relationship.getToBeanName() + "> " + Utils.makeMethod2Field(relationship.getName()) + " = " + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + relationship.getName() + "();\r\n";
            notOwnedRelationshipDelete += "\r\n";
            notOwnedRelationshipDelete += "\t\tfor (" + relationship.getToBeanName() + " local" + relationship.getToBeanName() + " : " + Utils.makeMethod2Field(relationship.getName()) + ")\r\n";
            notOwnedRelationshipDelete += "\t\t{\r\n";
            notOwnedRelationshipDelete += "\t\t\tlocal" + relationship.getToBeanName() + "." + Utils.makeRemove(relationship.getMappedBy()) + "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + ");\r\n";
            notOwnedRelationshipDelete += "\t\t\tentityManager.merge(local" + relationship.getToBeanName() + ");\r\n";
            notOwnedRelationshipDelete += "\t\t}";
          }
        }

        if (relationship.isUsed() && relationship.isToMany())
        {
          if (!relationship.isFromMany())
          {
            /** Relazioni :N **/

            // Creazione
            notOwnedRelationshipCreate += "\r\n";
            notOwnedRelationshipCreate += "\t\tList<" + relationship.getToBeanName() + "> " + Utils.makeMethod2Field(relationship.getName()) + " = " + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + relationship.getName() + "();\r\n";
            notOwnedRelationshipCreate += "\r\n";
            notOwnedRelationshipCreate += "\t\tif (" + Utils.makeMethod2Field(relationship.getName()) + " != null)\r\n";
            notOwnedRelationshipCreate += "\t\t{\r\n";
            notOwnedRelationshipCreate += "\t\t\tfor (" + relationship.getToBeanName() + " " + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + " : " + Utils.makeMethod2Field(relationship.getName()) + ")\r\n";
            notOwnedRelationshipCreate += "\t\t\t{\r\n";

            notOwnedRelationshipCreate += "\t\t\t\t" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + "." + Utils.switchGet2Set(inverseRelationship.getName()) + "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + ");\r\n";
            notOwnedRelationshipCreate += "\t\t\t\tentityManager.merge(" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + ");\r\n";
            notOwnedRelationshipCreate += "\t\t\t}\r\n";
            notOwnedRelationshipCreate += "\t\t}\r\n";

            // Modifica
            notOwnedRelEditRemoveExistingItems += "\r\n";
           
            if (notOwnedRelEditRemoveExistingItems.contains("\t\tList<" + relationship.getToBeanName() + "> old" + relationship.getToBeanName() + "s"))
              notOwnedRelEditRemoveExistingItems += "\t\told" + relationship.getToBeanName() + "s";
            else
              notOwnedRelEditRemoveExistingItems += "\t\tList<" + relationship.getToBeanName() + "> old" + relationship.getToBeanName() + "s";
            //notOwnedRelEditRemoveExistingItems += " = entityManager.find(" + bean.getName() + ".class," + Utils.makeFirstLetterLowerCase(bean.getName()) + ".getId())." + relationship.getName() + "();\r\n";
            notOwnedRelEditRemoveExistingItems += " = " + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + relationship.getName() + "();\r\n";
            notOwnedRelEditRemoveExistingItems += "\r\n";
            notOwnedRelEditRemoveExistingItems += "\t\tfor (" + relationship.getToBeanName() + " " + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + " : old" + relationship.getToBeanName() + "s)\r\n";
            notOwnedRelEditRemoveExistingItems += "\t\t{\r\n";
            notOwnedRelEditRemoveExistingItems += "\t\t\t" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + "." + Utils.makeSet(relationship.getMappedBy()) + "(null);\r\n";
            notOwnedRelEditRemoveExistingItems += "\t\t\tentityManager.merge(" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + ");\r\n";
            notOwnedRelEditRemoveExistingItems += "\t\t}\r\n";

            notOwnedRelationshipEdit += "\r\n";
            notOwnedRelationshipEdit += "\t\tList<" + relationship.getToBeanName() + "> " + Utils.makeMethod2Field(relationship.getName()) + " = " + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + relationship.getName() + "();\r\n";
            notOwnedRelationshipEdit += "\r\n";
            notOwnedRelationshipEdit += "\t\tfor (" + relationship.getToBeanName() + " " + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + " : " + Utils.makeMethod2Field(relationship.getName()) + ")\r\n";
            notOwnedRelationshipEdit += "\t\t{\r\n";
            notOwnedRelationshipEdit += "\t\t\t" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + "." + Utils.makeSet(relationship.getMappedBy()) + "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + ");\r\n";
            notOwnedRelationshipEdit += "\t\t\tentityManager.merge(" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + ");\r\n";
            notOwnedRelationshipEdit += "\t\t}\r\n\r\n";
           
            notOwnedRelationshipEdit += "\t\tList<" + relationship.getToBeanName() + "> list" + relationship.getName() + " = " + Utils.makeFirstLetterLowerCase(bean.getName()) + "."+relationship.getName()+"();\r\n";
            notOwnedRelationshipEdit += "\t\t"+Utils.makeFirstLetterLowerCase(bean.getName())+"."+Utils.switchGet2Set(relationship.getName())+"(new ArrayList<" + relationship.getToBeanName() + ">(list" + relationship.getName() + "));\r\n";
           
           
            // // Inizializzazione delle relazioni lazy per la modifica
            // !!!
            // initilizeLazyRelationshipEdit +=
            // "\t\tHibernate.initialize(" +
            // Utils.makeFirstLetterLowerCase(bean.getName()) + "." +
            // relationship.getName() + "());\r\n";
          }
          else
          {
            /** Relazioni N:M **/

            if (!relationship.getMappedBy().equals(""))
            {
              notOwnedRelationshipCreate += "\r\n";
              notOwnedRelationshipCreate += "\t\tList<" + relationship.getToBeanName() + "> " + Utils.makeMethod2Field(relationship.getName()) + " = " + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + relationship.getName() + "();\r\n";
              notOwnedRelationshipCreate += "\r\n";
              notOwnedRelationshipCreate += "\t\tif (" + Utils.makeMethod2Field(relationship.getName()) + " != null)\r\n";
              notOwnedRelationshipCreate += "\t\t{\r\n";
              notOwnedRelationshipCreate += "\t\tfor (" + relationship.getToBeanName() + " " + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + " : " + Utils.makeMethod2Field(relationship.getName()) + ")\r\n";
              notOwnedRelationshipCreate += "\t\t{\r\n";
              notOwnedRelationshipCreate += "\t\t\t" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + "." + Utils.makeAdd(Utils.makeMethod2Field(inverseRelationship.getName())) + "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + ");\r\n";
              notOwnedRelationshipCreate += "\t\t\tentityManager.merge(" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + ");\r\n";
              notOwnedRelationshipCreate += "\t\t}\r\n";
              notOwnedRelationshipCreate += "\t\t}\r\n";

              notOwnedRelEditRemoveExistingItems += "\r\n";
              if (notOwnedRelEditRemoveExistingItems.contains("\t\tList<" + relationship.getToBeanName() + "> old" + relationship.getToBeanName() + "s"))
                notOwnedRelEditRemoveExistingItems += "\t\told" + relationship.getToBeanName() + "s";
              else
                notOwnedRelEditRemoveExistingItems += "\t\tList<" + relationship.getToBeanName() + "> old" + relationship.getToBeanName() + "s";
              //notOwnedRelEditRemoveExistingItems += " = entityManager.find(" + bean.getName() + ".class," + Utils.makeFirstLetterLowerCase(bean.getName()) + ".getId())." + relationship.getName() + "();\r\n";
              notOwnedRelEditRemoveExistingItems += " = " + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + relationship.getName() + "();\r\n";
              notOwnedRelEditRemoveExistingItems += "\r\n";
              notOwnedRelEditRemoveExistingItems += "\t\tfor (" + relationship.getToBeanName() + " " + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + " : old" + relationship.getToBeanName() + "s)\r\n";
              notOwnedRelEditRemoveExistingItems += "\t\t{\r\n";
              notOwnedRelEditRemoveExistingItems += "\t\t\t" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + "." + Utils.makeRemove(relationship.getMappedBy()) + "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + ");\r\n";
              notOwnedRelEditRemoveExistingItems += "\t\t\tentityManager.merge(" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + ");\r\n";
              notOwnedRelEditRemoveExistingItems += "\t\t}\r\n";

              notOwnedRelationshipEdit += "\r\n";
              notOwnedRelationshipEdit += "\t\tList<" + relationship.getToBeanName() + "> " + Utils.makeMethod2Field(relationship.getName()) + " = " + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + relationship.getName() + "();\r\n";
              notOwnedRelationshipEdit += "\r\n";
              notOwnedRelationshipEdit += "\t\tfor (" + relationship.getToBeanName() + " " + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + " : " + Utils.makeMethod2Field(relationship.getName()) + ")\r\n";
              notOwnedRelationshipEdit += "\t\t{\r\n";

              notOwnedRelationshipEdit += "\t\t\t" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + "." + Utils.makeRemoveAll(relationship.getMappedBy()) + "();\r\n";
              notOwnedRelationshipEdit += "\t\t\t" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + "." + Utils.makeAdd(relationship.getMappedBy()) + "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + ");\r\n";
              notOwnedRelationshipEdit += "\t\t\tentityManager.merge(" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + ");\r\n";
              notOwnedRelationshipEdit += "\t\t}\r\n";
            }
          }

          // Inizializzazione delle relazioni lazy per la modifica !!!
          initilizeLazyRelationshipEdit += "\t\tHibernate.initialize(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + relationship.getName() + "());\r\n";
        }
      }
      else
      {
        /**
         * Gestione delle relazioni 1:1
         *
         */
        if (relationship.isMasterDetail() && !relationship.isFromMaster())
        {
          // Questo e' il detail di una MASTER-DETAIL e viene inserito il
          // check per verificare l'esistenza di un solo detail

          masterDetail1To1Check += "\t\tif (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "List.size()>0)\r\n";
          masterDetail1To1Check += "\t\t{\r\n";
          masterDetail1To1Check += "\t\t\tFacesMessages.instance().clear();\r\n\r\n";
          masterDetail1To1Check += "\t\t\tString msg = MessagesLoader.getMessageResourceString(facesContext.getApplication().getMessageBundle(),\"list_" + relationship.getFromBeanName() + "_" + relationship.getName() + "_OnlyOne" + relationship.getFromBeanName() + "Allowed\", null, facesContext.getViewRoot().getLocale());\r\n\r\n";
          masterDetail1To1Check += "\t\t\tFacesMessage message = new FacesMessage();\r\n";
          masterDetail1To1Check += "\t\t\tmessage.setDetail(msg);\r\n";
          masterDetail1To1Check += "\t\t\tmessage.setSummary(msg);\r\n";
          masterDetail1To1Check += "\t\t\tmessage.setSeverity(FacesMessage.SEVERITY_INFO);\r\n";
          masterDetail1To1Check += "\t\t\tFacesMessages.instance().add(message);\r\n";
          masterDetail1To1Check += "\t\t\treturn returningPage;\r\n";
          masterDetail1To1Check += "\t\t}\r\n";
        }

        if (relationship.getMappedBy().equals(""))
        {
          // Questa bean e' l'owner della relazione
        }
        else
        {
          // Questo bean non e' l'owner della relazione

          // Creazione
          notOwnedRelationshipCreate += "\r\n";
          notOwnedRelationshipCreate += "\t\t" + relationship.getToBeanName() + " local" + Utils.makeFirstLetterUpperCase(Utils.makeMethod2Field(relationship.getName())) + " = " + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + relationship.getName() + "();\r\n";
          notOwnedRelationshipCreate += "\r\n";
          notOwnedRelationshipCreate += "\t\tif (local" + Utils.makeFirstLetterUpperCase(Utils.makeMethod2Field(relationship.getName())) + " != null)\r\n";
          notOwnedRelationshipCreate += "\t\t{\r\n";
          notOwnedRelationshipCreate += "\t\t\tlocal" + Utils.makeFirstLetterUpperCase(Utils.makeMethod2Field(relationship.getName())) + "." + Utils.switchGet2Set(inverseRelationship.getName()) + "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + ");\r\n";
          notOwnedRelationshipCreate += "\t\t\tentityManager.merge(local" + Utils.makeFirstLetterUpperCase(Utils.makeMethod2Field(relationship.getName())) + ");\r\n";
          notOwnedRelationshipCreate += "\t\t}\r\n";

          // Modifica
          notOwnedRelEditRemoveExistingItems += "\r\n";
          if (notOwnedRelEditRemoveExistingItems.contains("\t\t" + relationship.getToBeanName() + " old" + relationship.getToBeanName()))
            notOwnedRelEditRemoveExistingItems += "\t\told" + relationship.getToBeanName();
          else
            notOwnedRelEditRemoveExistingItems += "\t\t" + relationship.getToBeanName() + " old" + relationship.getToBeanName();
          //notOwnedRelEditRemoveExistingItems += " = entityManager.find(" + bean.getName() + ".class," + Utils.makeFirstLetterLowerCase(bean.getName()) + ".getId())." + relationship.getName() + "();\r\n";
          notOwnedRelEditRemoveExistingItems += " = " + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + relationship.getName() + "();\r\n";
          notOwnedRelEditRemoveExistingItems += "\r\n";
          notOwnedRelEditRemoveExistingItems += "\t\tif (old" + relationship.getToBeanName() + " != null)\r\n";
          notOwnedRelEditRemoveExistingItems += "\t\t{\r\n";
          notOwnedRelEditRemoveExistingItems += "\t\t\told" + relationship.getToBeanName() + "." + Utils.makeSet(relationship.getMappedBy()) + "(null);\r\n";
          notOwnedRelEditRemoveExistingItems += "\t\t\tentityManager.merge(old" + relationship.getToBeanName() + ");\r\n";
          notOwnedRelEditRemoveExistingItems += "\t\t}\r\n";

          notOwnedRelationshipEdit += "\r\n";
          notOwnedRelationshipEdit += "\t\t" + relationship.getToBeanName() + " local" + Utils.makeFirstLetterUpperCase(Utils.makeMethod2Field(relationship.getName())) + " = " + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + relationship.getName() + "();\r\n";
          notOwnedRelationshipEdit += "\r\n";
          notOwnedRelationshipEdit += "\t\tif (local" + Utils.makeFirstLetterUpperCase(Utils.makeMethod2Field(relationship.getName())) + " != null)\r\n";
          notOwnedRelationshipEdit += "\t\t{\r\n";
          notOwnedRelationshipEdit += "\t\t\tlocal" + Utils.makeFirstLetterUpperCase(Utils.makeMethod2Field(relationship.getName())) + "." + Utils.makeSet(relationship.getMappedBy()) + "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + ");\r\n";
          notOwnedRelationshipEdit += "\t\t\tentityManager.merge(local" + Utils.makeFirstLetterUpperCase(Utils.makeMethod2Field(relationship.getName())) + ");\r\n";
          notOwnedRelationshipEdit += "\t\t}\r\n";

          // Cancellazione
          notOwnedRelationshipDelete += "\r\n\r\n";
          notOwnedRelationshipDelete += "\t\t" + relationship.getToBeanName() + " local" + Utils.makeFirstLetterUpperCase(Utils.makeMethod2Field(relationship.getName())) + " = " + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + relationship.getName() + "();\r\n";
          notOwnedRelationshipDelete += "\r\n";
          notOwnedRelationshipDelete += "\t\tif (local" + Utils.makeFirstLetterUpperCase(Utils.makeMethod2Field(relationship.getName())) + " != null)\r\n";
          notOwnedRelationshipDelete += "\t\t{\r\n";
          notOwnedRelationshipDelete += "\t\t\tlocal" + Utils.makeFirstLetterUpperCase(Utils.makeMethod2Field(relationship.getName())) + "." + Utils.makeSet(relationship.getMappedBy()) + "(null);\r\n";
          notOwnedRelationshipDelete += "\t\t\tentityManager.merge(local" + Utils.makeFirstLetterUpperCase(Utils.makeMethod2Field(relationship.getName())) + ");\r\n";
          notOwnedRelationshipDelete += "\t\t}\r\n";
        }
      }
    }

    /**
     * Inserimento funzione getPath se il bean e' master o detail in almeno una
     * relazione *
     */
    getPath = false;
    getPathFunction = "";
    for (int i = 0; i < bean.getRelationships().size(); i++)
    {
      Relationship relationship = bean.getRelationships().get(i);
      if (relationship.isUsed() && relationship.isMasterDetail())
        getPath = true;
    }
    if (getPath)
    {
      getPathFunction += "\r\n";
      getPathFunction += "\tpublic String getPath()\r\n";
      getPathFunction += "\t{\r\n";

      getPathFunction += "\t\tif (masterReference)\r\n";
      getPathFunction += "\t\t\treturn SeamUtility.path2String();\r\n";

      getPathFunction += "\t\treturn \"\";\r\n";
      getPathFunction += "\t}\r\n";
    }

    /** Gestione delle relazioni MASTER_DETAIL di cui questo bean e' DETAIL **/
    /** Individuazione dei bean DETAIL di questo **/
    for (int i = 0; i < bean.getRelationships().size(); i++)
    {
      Relationship relationship = bean.getRelationships().get(i);

      if (relationship.isUsed() && relationship.isMasterDetail() && !relationship.isFromMaster())
      {
        if (!referenceToMaster.contains("PathItem pathInfo"))
          referenceToMaster += "PathItem pathInfo = SeamUtility.getReferenceToMaster();\r\n\r\n";

        referenceToMaster += "\t\tif (pathInfo.getId() != null && pathInfo.getBeanName().equals(\"" + relationship.getToBeanName() + "\"))\r\n";
        if (!relationship.isToMany())
          referenceToMaster += "\t\t\t" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeSet(Utils.makeMethod2Field(relationship.getName())) + "(" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + ");\r\n\r\n";
        else
          referenceToMaster += "\t\t\t" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeAdd(Utils.makeMethod2Field(relationship.getName())) + "(" + Utils.makeFirstLetterLowerCase(relationship.getToBeanName()) + ");\r\n\r\n";
      }

      if (relationship.isMasterDetail() && relationship.isFromMaster())
      {
        /** Costruzione dei metodi di chiamata ai dettagli **/
        Vector<ShowList> lists = infoReader.getLists(relationship.getToBeanName());
        for (ShowList list : lists)
        {
          goToDetails += "\r\n";
          goToDetails += "\tpublic String goTo" + list.getName() + "()\r\n";
          goToDetails += "\t{\r\n";
          goToDetails += "\t\tString label=\"\";\r\n\r\n";

          // Gli attributi di riferimento al master sono sulla relazione
          // che va dal detail al master
          // Qui si sta generando il master per cui e' necessario ricercare
          // la relazione che dal detail
          // va al master

          Relationship relk = infoReader.getRelationshipToMaster(relationship.getToBeanName(), bean.getName());

          for (int k = 0; k < relk.getMasterAttributes().size(); k++)
          {
            if (k > 0)
              goToDetails += "\t\tlabel += \" - \";\r\n";

            if (relk.getMasterAttributes().get(k).getType().equals("java.util.Date"))
              // goToDetails += "\t\tlabel += " + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeGet(relk.getMasterAttributes().get(k).getName()) + "()DATA;\r\n";
              goToDetails += "\t\tlabel += SeamUtility.convertDate(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeGet(relk.getMasterAttributes().get(k).getName()) + "(),SeamUtility.getMessage(facesContext,\"Application_DateFormat\"));;\r\n";
            else
              goToDetails += "\t\tlabel += " + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeGet(relk.getMasterAttributes().get(k).getName()) + "();\r\n";
          }

          goToDetails += "\t\tSeamUtility.updateMasterDetailPath(\"" + bean.getName() + "\",label," + Utils.makeFirstLetterLowerCase(bean.getName()) + ".getId());\r\n\r\n";
          goToDetails += "\t\treturn \"/list/" + list.getName() + "List.seam?masterReference=true\";\r\n";
          goToDetails += "\t}\r\n";

        }
      }

    }

    /** Gestione della local search -- variabili **/

    localSearchFields += "";
    localSearchFields += "private boolean\t\t\t\t\t\t\t\t\tlocalSearch\t\t\t\t\t\t= false;\r\n\r\n";
    for (int i = 0; i < bean.getLocalSearchAttributes().size(); i++)
    {
      SearchAttribute attr = bean.getLocalSearchAttributes().get(i);

      if (!attr.belongsToRelationship())
      {
        //        localSearchFields += "\t@In(create = true, required = false)\r\n";
        //        localSearchFields += "\t@Out(required = false)\r\n";
        if (attr.getImplementationType() == AttributeImplementationType.TEXT || attr.getImplementationType() == AttributeImplementationType.TEXTAREA)
        {
          localSearchFields += "\tprivate String\t\t\t\t\t\t\t\t\t\tlocalSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + "\t\t\t\t\t= null;\r\n";
        }
        else
        {
          localSearchFields = "TIPO DI DATO NON SUPPORTATO IN LOCAL SEARCH: " + attr.getImplementationType();
        }
      }
      else
      {
        // Attributo che appartiene ad una relazione
        localSearchFields += "\r\n";
        if (!attr.getRelationship().isToMany())
        {
          //localSearchFields += "\t@In(create = true, required = false)\r\n";
          //localSearchFields += "\t@Out(required = false)\r\n";
          localSearchFields += "\tprivate " + attr.getRelationship().getToBeanName() + "                localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "  = null;\r\n";
        }
        else
        {
          //localSearchFields += "\t@In(create = true, required = false)\r\n";
          //localSearchFields += "\t@Out(required = false)\r\n";
          localSearchFields += "\tprivate List <" + attr.getRelationship().getToBeanName() + ">            localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "  = null;\r\n";
        }
      }
    }

    /** Gestione della local search -- funzioni ausiliarie * */
    localSearch = "";
    localSearch += "public boolean isLocalSearch()\r\n";
    localSearch += "\t{\r\n";
    localSearch += "\t\treturn localSearch;\r\n";
    localSearch += "\t}\r\n\r\n";
    localSearch += "\tpublic void setLocalSearch(boolean search)\r\n";
    localSearch += "\t{\r\n";
    localSearch += "\t\tthis.localSearch = search;\r\n";
    localSearch += "\t}\r\n\r\n";
    localSearch += "\tpublic void startLocalSearch()\r\n";
    localSearch += "\t{\r\n";
    localSearch += "\t\tlocalSearch = true;\r\n";
    localSearch += "\t}\r\n\r\n";
    // localSearch += "\t@Begin(join = true)\r\n";
    localSearch += "\tpublic void stopLocalSearch()\r\n";
    localSearch += "\t{\r\n";

    for (int i = 0; i < bean.getLocalSearchAttributes().size(); i++)
    {
      SearchAttribute attr = bean.getLocalSearchAttributes().get(i);

      if (attr.getImplementationType() == AttributeImplementationType.TEXT || attr.getImplementationType() == AttributeImplementationType.TEXTAREA)
      {
        localSearch += "\t\tlocalSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + " = null;\r\n";
      }
      else
      {
        localSearch += "\t\tlocalSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + " = null;\r\n";
      }
    }

    localSearch += "\t\tlocalSearch = false;\r\n\r\n";
    localSearch += "\t\t" + Utils.makeFirstLetterLowerCase(bean.getName()) + "List = null;\r\n";
    localSearch += "\t}\r\n\r\n";

    // Getter e Setter per gli attributi di ricerca locale

    for (int i = 0; i < bean.getLocalSearchAttributes().size(); i++)
    {
      SearchAttribute attr = bean.getLocalSearchAttributes().get(i);

      if (attr.getImplementationType() == AttributeImplementationType.TEXT || attr.getImplementationType() == AttributeImplementationType.TEXTAREA)
      {
        localSearch += "\tpublic String getLocalSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + "()\r\n";
        localSearch += "\t{\r\n";
        localSearch += "\t\treturn localSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + ";\r\n";
        localSearch += "\t}\r\n\r\n";

        localSearch += "\tpublic void setLocalSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + "(String localSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + ")\r\n";
        localSearch += "\t{\r\n";
        localSearch += "\t\tthis.localSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + " = localSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + ";\r\n";
        localSearch += "\t}\r\n\r\n";
      }
      else
      {
        if (attr.belongsToRelationship())
        {
          if (attr.getRelationship().isToMany())
          {
            localSearch += "\tpublic List<" + attr.getRelationship().getToBeanName() + "> getLocalSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "()\r\n";
            localSearch += "\t{\r\n";
            localSearch += "\t\treturn localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + ";\r\n";
            localSearch += "\t}\r\n\r\n";

            localSearch += "\tpublic void setLocalSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "(List<" + attr.getRelationship().getToBeanName() + "> localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + ")\r\n";
            localSearch += "\t{\r\n";
            localSearch += "\t\tthis.localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + " = localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + ";\r\n";
            localSearch += "\t}\r\n\r\n";
          }
          else
          {
            localSearch += "\tpublic " + attr.getRelationship().getToBeanName() + " getLocalSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "()\r\n";
            localSearch += "\t{\r\n";
            localSearch += "\t\treturn localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + ";\r\n";
            localSearch += "\t}\r\n\r\n";

            localSearch += "\tpublic void setLocalSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "(" + attr.getRelationship().getToBeanName() + " localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + ")\r\n";
            localSearch += "\t{\r\n";
            localSearch += "\t\tthis.localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + " = localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + ";\r\n";
            localSearch += "\t}\r\n\r\n";
          }
        }

      }
    }

    /** Gestione relazioni categorizzate **/
    detailsReference = generateMasterDetailsReference(bean, sourceDir, basePackage);

    /** Gestione della sicurezza sulle azioni **/

    if (bean.getCreateCondition() != null)
      securityCreate = securityCondition(bean.getCreateCondition());
    else
      securityCreate = roleCheck(bean.getRolesEnabledToCreate());

    if (bean.getEditCondition() != null)
      securityEdit = securityCondition(bean.getEditCondition());
    else
      securityEdit = roleCheck(bean.getRolesEnabledToEdit());

    if (bean.getDeleteCondition() != null)
      securityDelete = securityCondition(bean.getDeleteCondition());
    else
      securityDelete = roleCheck(bean.getRolesEnabledToDelete());

    if (bean.getSearchCondition() != null)
      securitySearch = securityCondition(bean.getSearchCondition());
    else
      securitySearch = roleCheck(bean.getRolesEnabledToSearch());

    /** Gestione dei bean derivati **/

    String derivateBeans = InsertDerivateBeansVariables(infoReader, bean);
    displayDerivateBeans = InsertForwardToDerivateBean(infoReader, bean, "DISPLAY");
    editDerivateBeans = InsertForwardToDerivateBean(infoReader, bean, "EDIT");
    deleteDerivateBeans = InsertForwardToDerivateBean(infoReader, bean, "DELETE");

    Vector<String> beans = infoReader.getDerivedBeans(bean.getName());
    for (String derivateBean : beans)
    {
      sons += "|| referrer.contains(\"/" + derivateBean + "\")";
    }

View Full Code Here


        // ret[0].addJavaCode("\tprivate
        // "+relationship.getToBeanName()+"Manager
        // "+Utils.makeFirstLetterLowerCase(relationship.getToBeanName())+"Manager;\r\n");
      }

      InfoReader infoReader = new InfoReader(sourceDir);
      Relationship inverseRelationship = infoReader.getInverseRelationship(bean, relationship);

      if (relationship.isMasterDetail() && !relationship.isFromMaster() && inverseRelationship.isCategorized())
      {
        /** Riferimento al Master */
        ret[0].addJavaCode("@In(create = true, value = \"" + relationship.getToBeanName() + "Manager\")\r\n");
View Full Code Here

TOP

Related Classes of org.boco.seamwebappgen.info.InfoReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.