Package boco.ejb3PlugIn.gui

Examples of boco.ejb3PlugIn.gui.RelationshipDialog


      {
        /**
         * Acquisisce le informazioni sulla relazione
         *
         */
        RelationshipDialog relationshipNameDialog = new RelationshipDialog(sourceBeanName, "1", targetBeanName, "N",sourceCompilationUnit,targetCompilationUnit);
        relationshipNameDialog.pack();
        relationshipNameDialog.setLocationRelativeTo(null);
        relationshipNameDialog.setVisible(true);

        if (relationshipNameDialog.isCancelled())
          return;
       
        directRelationshipName = relationshipNameDialog.getDirectRelationshipName();
        reverseRelationshipName = relationshipNameDialog.getReverseRelationshipName();
       
        /**
         * Generazione della relazione nel bean Source
         */
        sourceCompilationUnit.createImport("java.util.List", null, null);
        sourceCompilationUnit.createImport("java.util.Vector", null, null);
        sourceCompilationUnit.createImport("javax.persistence.OneToMany", null, null);
        sourceCompilationUnit.createImport("javax.persistence.FetchType", null, null);
        sourceCompilationUnit.createImport("javax.persistence.CascadeType", null, null);

        IType type = sourceCompilationUnit.getTypes()[0];

        type.createField("private List<" + targetBeanName + "> " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ";", null, true, null);

        String get = "";
        get += "@OneToMany(targetEntity=" + targetBeanName + ".class, cascade = {CascadeType.REFRESH}, fetch=FetchType.LAZY, mappedBy=\"" + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + "\")\r\n";
        get += "public List<" + targetBeanName + "> " + Utils.makeGet(directRelationshipName)+"()\r\n";
        get += "{\r\n";
        get += "\treturn " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ";\r\n";
        get += "}\r\n";
        type.createMethod(get, null, true, null);

        String set = "";
        set += "public void " + Utils.makeSet(directRelationshipName) + "(List<" + targetBeanName + "> " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ")\r\n";
        set += "{\r\n";
        set += "\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName) +" = " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ";\r\n";
        set += "}\r\n";
        type.createMethod(set, null, true, null);

        String add = "";
        add += "public void " + Utils.makeAdd(directRelationshipName) + "(" + targetBeanName + " " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ")\r\n";
        add += "{\r\n";
        add += "\tif (this." + Utils.makeFirstLetterLowerCase(directRelationshipName) + " == null)\r\n";
        add += "\t\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName) + " = new Vector();\r\n\r\n";
        add += "\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName) + ".add(" + Utils.makeFirstLetterLowerCase(directRelationshipName) + ");\r\n";
        add += "}\r\n";
        type.createMethod(add, null, true, null);

        String remove = "";
        remove += "public void " + Utils.makeRemove(directRelationshipName) + "(" + targetBeanName + " " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ")\r\n";
        remove += "{\r\n";
        remove += "\tif (this." + Utils.makeFirstLetterLowerCase(directRelationshipName) + " == null)\r\n";
        remove += "\t\treturn;\r\n\r\n";
        remove += "\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName) +".remove(" + Utils.makeFirstLetterLowerCase(directRelationshipName) + ");\r\n";
        remove += "}\r\n";
        type.createMethod(remove, null, true, null);

        String removeAll = "";
        removeAll += "public void " + Utils.makeRemoveAll(Utils.makeFirstLetterLowerCase(directRelationshipName)) + "()\r\n";
        removeAll += "{\r\n";
        removeAll += "\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName) + " = new Vector<" + targetBeanName + ">();\r\n";
        removeAll += "}\r\n";
        type.createMethod(removeAll, null, true, null);

        sourceCompilationUnit.save(null, true);

        // Inserimento delle annotazioni relative al generatore
       
        IMethod method=null;
        IJavaElement types[] = type.getChildren();
       
        for (IJavaElement element : types)
        {
          if (element instanceof IMethod && element.getElementName().contains(Utils.makeGet(directRelationshipName)))
            method = (IMethod)element;
        }
       
        Utils.addSeamGeneratorAnnotations(method, sourceCompilationUnit, relationshipNameDialog.getSourceRelationshipOption(), relationshipNameDialog.getSourceAttributeSelectionOption(), relationshipNameDialog.getTargetAttributeSelectionOption());
       
        /**
         * Generazione dellla relazione nel bean Target
         */

        targetCompilationUnit.createImport("javax.persistence.ManyToOne", null, null);
        targetCompilationUnit.createImport("javax.persistence.FetchType", null, null);
        targetCompilationUnit.createImport("javax.persistence.CascadeType", null, null);

        type = targetCompilationUnit.getTypes()[0];

        type.createField("private " + sourceBeanName + " " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ";", null, true, null);

        get = "";
        get += "@ManyToOne(targetEntity=" + sourceBeanName + ".class, cascade = {CascadeType.REFRESH}, fetch=FetchType.LAZY)\r\n";
        get += "public " + sourceBeanName + " " + Utils.makeGet(reverseRelationshipName) + "()\r\n";
        get += "{\r\n";
        get += "\treturn " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ";\r\n";
        get += "}\r\n";
        type.createMethod(get, null, true, null);

        set = "";
        set += "public void " + Utils.makeSet(reverseRelationshipName) + "(" + sourceBeanName + " " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ")\r\n";
        set += "{\r\n";
        set += "\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + " = " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ";\r\n";
        set += "}\r\n";
        type.createMethod(set, null, true, null);

        targetCompilationUnit.save(null, true);

        // Inserimento delle annotazioni relative al generatore
       
        types = type.getChildren();
       
        for (IJavaElement element : types)
        {
          if (element instanceof IMethod && element.getElementName().contains(Utils.makeGet(reverseRelationshipName)))
            method = (IMethod)element;
        }
       
        Utils.addSeamGeneratorAnnotations(method, targetCompilationUnit, relationshipNameDialog.getTargetRelationshipOption(), relationshipNameDialog.getTargetAttributeSelectionOption(), relationshipNameDialog.getSourceAttributeSelectionOption());       
      }

    }
    catch (JavaModelException e)
    {
View Full Code Here


      {
        /**
         * Acquisisce le informazioni sulla relazione
         *
         */
        RelationshipDialog relationshipNameDialog = new RelationshipDialog(sourceBeanName, "1", targetBeanName, "1",sourceCompilationUnit,targetCompilationUnit);
        relationshipNameDialog.pack();
        relationshipNameDialog.setLocationRelativeTo(null);
        relationshipNameDialog.setVisible(true);
       
        if (relationshipNameDialog.isCancelled())
          return;
       
        directRelationshipName = relationshipNameDialog.getDirectRelationshipName();
        reverseRelationshipName = relationshipNameDialog.getReverseRelationshipName();
       
        /**
         * Generazione del bean di partenza
         */       
        sourceCompilationUnit.createImport("javax.persistence.OneToOne", null, null);
        sourceCompilationUnit.createImport("javax.persistence.FetchType", null, null);
        sourceCompilationUnit.createImport("javax.persistence.CascadeType", null, null);
       
        IType type = sourceCompilationUnit.getTypes()[0];

        type.createField("private "+ targetBeanName + " " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ";", null, true, null);

        String get = "";
        get += "@OneToOne(targetEntity=" + targetBeanName + ".class, cascade = {CascadeType.REFRESH, CascadeType.MERGE}, fetch=FetchType.LAZY, mappedBy=\"" + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + "\")\r\n";
        get += "public " + targetBeanName + " " + Utils.makeGet(directRelationshipName+ "()\r\n";
        get += "{\r\n";
        get += "\treturn " + Utils.makeFirstLetterLowerCase(directRelationshipName+ ";\r\n";
        get += "}\r\n";
        type.createMethod(get, null, true, null);

        String set = "";
        set += "public void " + Utils.makeSet(directRelationshipName+ "(" + targetBeanName + " " + Utils.makeFirstLetterLowerCase(directRelationshipName+ ")\r\n";
        set += "{\r\n";
        set += "\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName+ " = " + Utils.makeFirstLetterLowerCase(directRelationshipName+ ";\r\n";
        set += "}\r\n";
        type.createMethod(set, null, true, null);
               
        sourceCompilationUnit.save(null, true);
       
        // Inserimento delle annotazioni relative al generatore
       
        IMethod method=null;
        IJavaElement types[] = type.getChildren();
       
        for (IJavaElement element : types)
        {
          if (element instanceof IMethod && element.getElementName().contains(Utils.makeGet(directRelationshipName)))
            method = (IMethod)element;
        }
       
        Utils.addSeamGeneratorAnnotations(method, sourceCompilationUnit, relationshipNameDialog.getSourceRelationshipOption(), relationshipNameDialog.getSourceAttributeSelectionOption(), relationshipNameDialog.getTargetAttributeSelectionOption());
       
       
        /**
         * Generazione del bean Target
         */       
        targetCompilationUnit.createImport("javax.persistence.OneToOne", null, null);
        targetCompilationUnit.createImport("javax.persistence.FetchType", null, null);
        targetCompilationUnit.createImport("javax.persistence.CascadeType", null, null);

        type = targetCompilationUnit.getTypes()[0];

        type.createField("private " + sourceBeanName + " " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ";", null, true, null);

        get = "";
        get += "@OneToOne(targetEntity=" + sourceBeanName + ".class, cascade = {CascadeType.REFRESH}, fetch=FetchType.LAZY)\r\n";
        get += "public " + sourceBeanName + " " + Utils.makeGet(reverseRelationshipName) + "()\r\n";
        get += "{\r\n";
        get += "\treturn " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ";\r\n";
        get += "}\r\n";
        type.createMethod(get, null, true, null);

        set = "";
        set += "public void " + Utils.makeSet(reverseRelationshipName) + "(" + sourceBeanName + " " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ")\r\n";
        set += "{\r\n";
        set += "\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + " = " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ";\r\n";
        set += "}\r\n";
        type.createMethod(set, null, true, null);
     
        targetCompilationUnit.save(null, true);
       
        // Inserimento delle annotazioni relative al generatore
       
        types = type.getChildren();
       
        for (IJavaElement element : types)
        {
          if (element instanceof IMethod && element.getElementName().contains(Utils.makeGet(reverseRelationshipName)))
            method = (IMethod)element;
        }
       
        Utils.addSeamGeneratorAnnotations(method, targetCompilationUnit, relationshipNameDialog.getTargetRelationshipOption(), relationshipNameDialog.getTargetAttributeSelectionOption(), relationshipNameDialog.getSourceAttributeSelectionOption());       
      }

    }
    catch (JavaModelException e)
    {
View Full Code Here

      {
        /**
         * Acquisisce il nome della relazione
         *
         */
        RelationshipDialog relationshipNameDialog = new RelationshipDialog(sourceBeanName, "N", targetBeanName, "N",sourceCompilationUnit,targetCompilationUnit);
        relationshipNameDialog.pack();
        relationshipNameDialog.setLocationRelativeTo(null);
        relationshipNameDialog.setVisible(true);
       
        directRelationshipName = relationshipNameDialog.getDirectRelationshipName();
        reverseRelationshipName = relationshipNameDialog.getReverseRelationshipName();
       
        if (relationshipNameDialog.isCancelled())
          return;
       
        /**
         * Generazione del bean di partenza
         */       
        sourceCompilationUnit.createImport("java.util.List", null, null);
        sourceCompilationUnit.createImport("java.util.Vector", null, null);
        sourceCompilationUnit.createImport("javax.persistence.ManyToMany", null, null);
        sourceCompilationUnit.createImport("javax.persistence.FetchType", null, null);
        sourceCompilationUnit.createImport("javax.persistence.CascadeType", null, null);
        sourceCompilationUnit.createImport("javax.persistence.JoinTable", null, null);

        IType type = sourceCompilationUnit.getTypes()[0];

        type.createField("private List<" + targetBeanName + "> " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ";", null, true, null);

        String get = "";
        get += "@ManyToMany(targetEntity=" + targetBeanName + ".class, cascade = {CascadeType.REFRESH}, fetch=FetchType.LAZY)\r\n";
        get += "@JoinTable(name=\"" + sourceBeanName +"_" + directRelationshipName + "\")";
        get += "public List<" + targetBeanName + "> " + Utils.makeGet(directRelationshipName) + "()\r\n";
        get += "{\r\n";
        get += "\treturn " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ";\r\n";
        get += "}\r\n";
        type.createMethod(get, null, true, null);

        String set = "";
        set += "public void " + Utils.makeSet(directRelationshipName) + "(List<" + targetBeanName + "> " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ")\r\n";
        set += "{\r\n";
        set += "\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName) + " = " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ";\r\n";
        set += "}\r\n";
        type.createMethod(set, null, true, null);

        String add = "";
        add += "public void " + Utils.makeAdd(directRelationshipName) + "(" + targetBeanName + " " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ")\r\n";
        add += "{\r\n";
        add += "\tif (this." + Utils.makeFirstLetterLowerCase(directRelationshipName) + " == null)\r\n";
        add += "\t\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName) + " = new Vector();\r\n\r\n";
        add += "\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName) + ".add(" + Utils.makeFirstLetterLowerCase(directRelationshipName) + ");\r\n";
        add += "}\r\n";
        type.createMethod(add, null, true, null);

        String remove = "";
        remove += "public void " + Utils.makeRemove(directRelationshipName) + "(" + targetBeanName + " " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ")\r\n";
        remove += "{\r\n";
        remove += "\tif (this." + Utils.makeFirstLetterLowerCase(directRelationshipName) + " == null)\r\n";
        remove += "\t\treturn;\r\n\r\n";
        remove += "\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName) + ".remove(" + Utils.makeFirstLetterLowerCase(directRelationshipName) + ");\r\n";
        remove += "}\r\n";
        type.createMethod(remove, null, true, null);

        String removeAll = "";
        removeAll += "public void " + Utils.makeRemoveAll(directRelationshipName) + "()\r\n";
        removeAll += "{\r\n";
        removeAll += "\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName) + " = new Vector<"+targetBeanName+">();\r\n";
        removeAll += "}\r\n";
        type.createMethod(removeAll, null, true, null);
     
        sourceCompilationUnit.save(null, true);

        // Inserimento delle annotazioni relative al generatore
       
        IMethod method=null;
        IJavaElement types[] = type.getChildren();
       
        for (IJavaElement element : types)
        {
          if (element instanceof IMethod && element.getElementName().contains(Utils.makeGet(directRelationshipName)))
            method = (IMethod)element;
        }
       
        Utils.addSeamGeneratorAnnotations(method, sourceCompilationUnit, relationshipNameDialog.getSourceRelationshipOption(), relationshipNameDialog.getSourceAttributeSelectionOption(), relationshipNameDialog.getTargetAttributeSelectionOption());
       
        /**
         * Generazione del bean Target
         */
       
        targetCompilationUnit.createImport("java.util.List", null, null);
        targetCompilationUnit.createImport("java.util.Vector", null, null);
        targetCompilationUnit.createImport("javax.persistence.ManyToMany", null, null);
        targetCompilationUnit.createImport("javax.persistence.FetchType", null, null);
        targetCompilationUnit.createImport("javax.persistence.CascadeType", null, null);
       
        type = targetCompilationUnit.getTypes()[0];

        type.createField("private List<" + sourceBeanName + "> " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ";", null, true, null);

        get = "";
        get += "@ManyToMany(targetEntity=" + sourceBeanName + ".class, cascade = {CascadeType.REFRESH}, fetch=FetchType.LAZY, mappedBy=\"" + Utils.makeFirstLetterLowerCase(directRelationshipName) + "\")\r\n";
        get += "public List<" + sourceBeanName + "> " + Utils.makeGet(reverseRelationshipName+ "()\r\n";
        get += "{\r\n";
        get += "\treturn " + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ ";\r\n";
        get += "}\r\n";
        type.createMethod(get, null, true, null);

        set = "";
        set += "public void " + Utils.makeSet(reverseRelationshipName+ "(List<" + sourceBeanName + "> " + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ ")\r\n";
        set += "{\r\n";
        set += "\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ " = " + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ ";\r\n";
        set += "}\r\n";
        type.createMethod(set, null, true, null);

        add = "";
        add += "public void " + Utils.makeAdd(reverseRelationshipName+ "(" + sourceBeanName + " " + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ ")\r\n";
        add += "{\r\n";
        add += "\tif (this." + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ " == null)\r\n";
        add += "\t\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ " = new Vector();\r\n\r\n";
        add += "\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ ".add(" + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ ");\r\n";
        add += "}\r\n";
        type.createMethod(add, null, true, null);

        remove = "";
        remove += "public void " + Utils.makeRemove(reverseRelationshipName+ "(" + sourceBeanName + " " + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ ")\r\n";
        remove += "{\r\n";
        remove += "\tif (this." + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ " == null)\r\n";
        remove += "\t\treturn;\r\n\r\n";
        remove += "\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ ".remove(" + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ ");\r\n";
        remove += "}\r\n";
        type.createMethod(remove, null, true, null);

        removeAll = "";
        removeAll += "public void " + Utils.makeRemoveAll(reverseRelationshipName+ "()\r\n";
        removeAll += "{\r\n";
        removeAll += "\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ " = new Vector<"+sourceBeanName+">();\r\n";
        removeAll += "}\r\n";
        type.createMethod(removeAll, null, true, null);
               
        targetCompilationUnit.save(null, true);   
       
        // Inserimento delle annotazioni relative al generatore
       
        types = type.getChildren();
       
        for (IJavaElement element : types)
        {
          if (element instanceof IMethod && element.getElementName().contains(Utils.makeGet(reverseRelationshipName)))
            method = (IMethod)element;
        }
       
        Utils.addSeamGeneratorAnnotations(method, targetCompilationUnit, relationshipNameDialog.getTargetRelationshipOption(), relationshipNameDialog.getTargetAttributeSelectionOption(), relationshipNameDialog.getSourceAttributeSelectionOption());               
      }     
    }
    catch (JavaModelException e)
    {
      ErrorMessageDialog errorMessageDialog = new ErrorMessageDialog(e.getMessage());
View Full Code Here

      {
        /**
         * Acquisisce il nome della relazione
         *
         */
        RelationshipDialog relationshipNameDialog = new RelationshipDialog(sourceBeanName, "N", targetBeanName, "1",sourceCompilationUnit,targetCompilationUnit);
        relationshipNameDialog.pack();
        relationshipNameDialog.setLocationRelativeTo(null);
        relationshipNameDialog.setVisible(true);

        directRelationshipName = relationshipNameDialog.getDirectRelationshipName();
        reverseRelationshipName = relationshipNameDialog.getReverseRelationshipName();
       
        if (relationshipNameDialog.isCancelled())
          return;
       
        /**
         * Generazione del bean di partenza
         */
        sourceCompilationUnit.createImport("javax.persistence.ManyToOne", null, null);
        sourceCompilationUnit.createImport("javax.persistence.FetchType", null, null);
        sourceCompilationUnit.createImport("javax.persistence.CascadeType", null, null);

        IType type = sourceCompilationUnit.getTypes()[0];

        type.createField("private " + targetBeanName + " " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ";", null, true, null);

        String get = "";
        get += "@ManyToOne(targetEntity=" + targetBeanName + ".class, cascade = {CascadeType.REFRESH}, fetch=FetchType.LAZY)\r\n";
        get += "public " + targetBeanName + " " + Utils.makeGet(directRelationshipName) + "()\r\n";
        get += "{\r\n";
        get += "\treturn " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ";\r\n";
        get += "}\r\n";
        type.createMethod(get, null, true, null);

        String set = "";
        set += "public void " + Utils.makeSet(directRelationshipName) + "(" + targetBeanName + " " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ")\r\n";
        set += "{\r\n";
        set += "\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName) + " = " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ";\r\n";
        set += "}\r\n";
        type.createMethod(set, null, true, null);

        sourceCompilationUnit.save(null, true);

        // Inserimento delle annotazioni relative al generatore
       
        IMethod method=null;
        IJavaElement types[] = type.getChildren();
       
        for (IJavaElement element : types)
        {
          if (element instanceof IMethod && element.getElementName().contains(Utils.makeGet(directRelationshipName)))
            method = (IMethod)element;
        }
       
        Utils.addSeamGeneratorAnnotations(method, sourceCompilationUnit, relationshipNameDialog.getSourceRelationshipOption(), relationshipNameDialog.getSourceAttributeSelectionOption(), relationshipNameDialog.getTargetAttributeSelectionOption());
       
        /**
         * Generazione del bean Target
         */
       
        targetCompilationUnit.createImport("java.util.List", null, null);
        targetCompilationUnit.createImport("java.util.Vector", null, null);
        targetCompilationUnit.createImport("javax.persistence.OneToMany", null, null);
        targetCompilationUnit.createImport("javax.persistence.FetchType", null, null);
        targetCompilationUnit.createImport("javax.persistence.CascadeType", null, null);

        type = targetCompilationUnit.getTypes()[0];

        type.createField("private List<" + sourceBeanName + "> " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ";", null, true, null);

        get = "";
        get += "@OneToMany(targetEntity=" + sourceBeanName + ".class, cascade = {CascadeType.REFRESH}, fetch=FetchType.LAZY, mappedBy=\"" + Utils.makeFirstLetterLowerCase(directRelationshipName) + "\")\r\n";
        get += "public List<" + sourceBeanName + "> " + Utils.makeGet(reverseRelationshipName) + "()\r\n";
        get += "{\r\n";
        get += "\treturn " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ";\r\n";
        get += "}\r\n";
        type.createMethod(get, null, true, null);

        set = "";
        set += "public void " + Utils.makeSet(reverseRelationshipName) + "(List<" + sourceBeanName + "> " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ")\r\n";
        set += "{\r\n";
        set += "\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + " = " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ";\r\n";
        set += "}\r\n";
        type.createMethod(set, null, true, null);

        String add = "";
        add += "public void " + Utils.makeAdd(reverseRelationshipName) + "(" + sourceBeanName + " " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ")\r\n";
        add += "{\r\n";
        add += "\tif (this." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + " == null)\r\n";
        add += "\t\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + " = new Vector();\r\n\r\n";
        add += "\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ".add(" + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ");\r\n";
        add += "}\r\n";
        type.createMethod(add, null, true, null);

        String remove = "";
        remove += "public void " + Utils.makeRemove(reverseRelationshipName) + "(" + sourceBeanName + " " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ")\r\n";
        remove += "{\r\n";
        remove += "\tif (this." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + " == null)\r\n";
        remove += "\t\treturn;\r\n\r\n";
        remove += "\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ".remove(" + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ");\r\n";
        remove += "}\r\n";
        type.createMethod(remove, null, true, null);

        String removeAll = "";
        removeAll += "public void " + Utils.makeRemoveAll(reverseRelationshipName) + "()\r\n";
        removeAll += "{\r\n";
        removeAll += "\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + " = new Vector<" + sourceBeanName + ">();\r\n";
        removeAll += "}\r\n";
        type.createMethod(removeAll, null, true, null);

        targetCompilationUnit.save(null, true);
       
        // Inserimento delle annotazioni relative al generatore
       
        types = type.getChildren();
       
        for (IJavaElement element : types)
        {
          if (element instanceof IMethod && element.getElementName().contains(Utils.makeGet(reverseRelationshipName)))
            method = (IMethod)element;
        }
       
        Utils.addSeamGeneratorAnnotations(method, targetCompilationUnit, relationshipNameDialog.getTargetRelationshipOption(), relationshipNameDialog.getTargetAttributeSelectionOption(), relationshipNameDialog.getSourceAttributeSelectionOption());               
      }

    }
    catch (JavaModelException e)
    {
View Full Code Here

      {
        /**
         * Acquisisce le informazioni sulla relazione
         *
         */
        RelationshipDialog relationshipNameDialog = new RelationshipDialog(sourceBeanName, "N", targetBeanName, "N",sourceCompilationUnit,targetCompilationUnit);
        relationshipNameDialog.pack();
        relationshipNameDialog.setLocationRelativeTo(null);
        relationshipNameDialog.setVisible(true);
       
        if (relationshipNameDialog.isCancelled())
          return;
       
        directRelationshipName = relationshipNameDialog.getDirectRelationshipName();
        reverseRelationshipName = relationshipNameDialog.getReverseRelationshipName();
       
        /**
         * Generazione del bean di partenza
         */       
        sourceCompilationUnit.createImport("java.util.List", null, null);
        sourceCompilationUnit.createImport("java.util.Vector", null, null);
        sourceCompilationUnit.createImport("javax.persistence.ManyToMany", null, null);
        sourceCompilationUnit.createImport("javax.persistence.FetchType", null, null);
        sourceCompilationUnit.createImport("javax.persistence.CascadeType", null, null);
       
        IType type = sourceCompilationUnit.getTypes()[0];

        type.createField("private List<" + targetBeanName + "> " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ";", null, true, null);

        String get = "";
        get += "@ManyToMany(targetEntity=" + targetBeanName + ".class, cascade = {CascadeType.REFRESH}, fetch=FetchType.LAZY, mappedBy=\"" + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + "\")\r\n";
        get += "public List<" + targetBeanName + "> " + Utils.makeGet(directRelationshipName+ "()\r\n";
        get += "{\r\n";
        get += "\treturn " + Utils.makeFirstLetterLowerCase(directRelationshipName+ ";\r\n";
        get += "}\r\n";
        type.createMethod(get, null, true, null);

        String set = "";
        set += "public void " + Utils.makeSet(directRelationshipName+ "(List<" + targetBeanName + "> " + Utils.makeFirstLetterLowerCase(directRelationshipName+ ")\r\n";
        set += "{\r\n";
        set += "\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName+ " = " + Utils.makeFirstLetterLowerCase(directRelationshipName+ ";\r\n";
        set += "}\r\n";
        type.createMethod(set, null, true, null);

        String add = "";
        add += "public void " + Utils.makeAdd(directRelationshipName+ "(" + targetBeanName + " " + Utils.makeFirstLetterLowerCase(directRelationshipName+ ")\r\n";
        add += "{\r\n";
        add += "\tif (this." + Utils.makeFirstLetterLowerCase(directRelationshipName+ " == null)\r\n";
        add += "\t\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName+ " = new Vector();\r\n\r\n";
        add += "\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName+ ".add(" + Utils.makeFirstLetterLowerCase(directRelationshipName+ ");\r\n";
        add += "}\r\n";
        type.createMethod(add, null, true, null);

        String remove = "";
        remove += "public void " + Utils.makeRemove(directRelationshipName+ "(" + targetBeanName + " " + Utils.makeFirstLetterLowerCase(directRelationshipName+ ")\r\n";
        remove += "{\r\n";
        remove += "\tif (this." + Utils.makeFirstLetterLowerCase(directRelationshipName+ " == null)\r\n";
        remove += "\t\treturn;\r\n\r\n";
        remove += "\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName+ ".remove(" + Utils.makeFirstLetterLowerCase(directRelationshipName+ ");\r\n";
        remove += "}\r\n";
        type.createMethod(remove, null, true, null);

        String removeAll = "";
        removeAll += "public void " + Utils.makeRemoveAll(directRelationshipName+ "()\r\n";
        removeAll += "{\r\n";
        removeAll += "\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName+ " = new Vector<"+targetBeanName+">();\r\n";
        removeAll += "}\r\n";
        type.createMethod(removeAll, null, true, null);
               
        sourceCompilationUnit.save(null, true);
       
        // Inserimento delle annotazioni relative al generatore
       
        IMethod method=null;
        IJavaElement types[] = type.getChildren();
       
        for (IJavaElement element : types)
        {
          if (element instanceof IMethod && element.getElementName().contains(Utils.makeGet(directRelationshipName)))
            method = (IMethod)element;
        }
       
        Utils.addSeamGeneratorAnnotations(method, sourceCompilationUnit, relationshipNameDialog.getSourceRelationshipOption(), relationshipNameDialog.getSourceAttributeSelectionOption(), relationshipNameDialog.getTargetAttributeSelectionOption());
       
       
        /**
         * Generazione del bean Target
         */
       
        targetCompilationUnit.createImport("java.util.List", null, null);
        targetCompilationUnit.createImport("java.util.Vector", null, null);
        targetCompilationUnit.createImport("javax.persistence.ManyToMany", null, null);
        targetCompilationUnit.createImport("javax.persistence.FetchType", null, null);
        targetCompilationUnit.createImport("javax.persistence.CascadeType", null, null);
        sourceCompilationUnit.createImport("javax.persistence.JoinTable", null, null);

        type = targetCompilationUnit.getTypes()[0];

        type.createField("private List<" + sourceBeanName + "> " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ";", null, true, null);

        get = "";
        get += "@ManyToMany(targetEntity=" + sourceBeanName + ".class, cascade = {CascadeType.REFRESH}, fetch=FetchType.LAZY)\r\n";
        get += "@JoinTable(name=\"" + targetBeanName +"_" + reverseRelationshipName + "\")";
        get += "public List<" + sourceBeanName + "> " + Utils.makeGet(reverseRelationshipName) + "()\r\n";
        get += "{\r\n";
        get += "\treturn " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ";\r\n";
        get += "}\r\n";
        type.createMethod(get, null, true, null);

        set = "";
        set += "public void " + Utils.makeSet(reverseRelationshipName) + "(List<" + sourceBeanName + "> " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ")\r\n";
        set += "{\r\n";
        set += "\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + " = " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ";\r\n";
        set += "}\r\n";
        type.createMethod(set, null, true, null);

        add = "";
        add += "public void " + Utils.makeAdd(reverseRelationshipName) + "(" + sourceBeanName + " " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ")\r\n";
        add += "{\r\n";
        add += "\tif (this." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + " == null)\r\n";
        add += "\t\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + " = new Vector();\r\n\r\n";
        add += "\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ".add(" + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ");\r\n";
        add += "}\r\n";
        type.createMethod(add, null, true, null);

        remove = "";
        remove += "public void " + Utils.makeRemove(reverseRelationshipName) + "(" + sourceBeanName + " " + Utils.makeFirstLetterLowerCase(sourceBeanName) + ")\r\n";
        remove += "{\r\n";
        remove += "\tif (this." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + " == null)\r\n";
        remove += "\t\treturn;\r\n\r\n";
        remove += "\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ".remove(" + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ");\r\n";
        remove += "}\r\n";
        type.createMethod(remove, null, true, null);

        removeAll = "";
        removeAll += "public void " + Utils.makeRemoveAll(reverseRelationshipName) + "()\r\n";
        removeAll += "{\r\n";
        removeAll += "\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + " = new Vector<"+sourceBeanName+">();\r\n";
        removeAll += "}\r\n";
        type.createMethod(removeAll, null, true, null);
     
        targetCompilationUnit.save(null, true);
       
        // Inserimento delle annotazioni relative al generatore
       
        types = type.getChildren();
       
        for (IJavaElement element : types)
        {
          if (element instanceof IMethod && element.getElementName().contains(Utils.makeGet(reverseRelationshipName)))
            method = (IMethod)element;
        }
       
        Utils.addSeamGeneratorAnnotations(method, targetCompilationUnit, relationshipNameDialog.getTargetRelationshipOption(), relationshipNameDialog.getTargetAttributeSelectionOption(), relationshipNameDialog.getSourceAttributeSelectionOption());       
      }

    }
    catch (JavaModelException e)
    {
View Full Code Here

      {
        /**
         * Acquisisce il nome della relazione
         *
         */
        RelationshipDialog relationshipNameDialog = new RelationshipDialog(sourceBeanName, "1", targetBeanName, "1",sourceCompilationUnit,targetCompilationUnit);
        relationshipNameDialog.pack();
        relationshipNameDialog.setLocationRelativeTo(null);
        relationshipNameDialog.setVisible(true);
       
        directRelationshipName = relationshipNameDialog.getDirectRelationshipName();
        reverseRelationshipName = relationshipNameDialog.getReverseRelationshipName();
       
        if (relationshipNameDialog.isCancelled())
          return;
       
        /**
         * Generazione del bean di partenza
         */       
        sourceCompilationUnit.createImport("javax.persistence.OneToOne", null, null);
        sourceCompilationUnit.createImport("javax.persistence.FetchType", null, null);
        sourceCompilationUnit.createImport("javax.persistence.CascadeType", null, null);

        IType type = sourceCompilationUnit.getTypes()[0];

        type.createField("private " + targetBeanName + " " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ";", null, true, null);

        String get = "";
        get += "@OneToOne(targetEntity=" + targetBeanName + ".class, cascade = {CascadeType.REFRESH}, fetch=FetchType.LAZY)\r\n";
        get += "public " + targetBeanName + " " + Utils.makeGet(directRelationshipName) + "()\r\n";
        get += "{\r\n";
        get += "\treturn " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ";\r\n";
        get += "}\r\n";
        type.createMethod(get, null, true, null);

        String set = "";
        set += "public void " + Utils.makeSet(directRelationshipName) + "(" + targetBeanName + " " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ")\r\n";
        set += "{\r\n";
        set += "\tthis." + Utils.makeFirstLetterLowerCase(directRelationshipName) + " = " + Utils.makeFirstLetterLowerCase(directRelationshipName) + ";\r\n";
        set += "}\r\n";
        type.createMethod(set, null, true, null);

     
        sourceCompilationUnit.save(null, true);

        // Inserimento delle annotazioni relative al generatore
       
        IMethod method=null;
        IJavaElement types[] = type.getChildren();
       
        for (IJavaElement element : types)
        {
          if (element instanceof IMethod && element.getElementName().contains(Utils.makeGet(directRelationshipName)))
            method = (IMethod)element;
        }
       
        Utils.addSeamGeneratorAnnotations(method, sourceCompilationUnit, relationshipNameDialog.getSourceRelationshipOption(), relationshipNameDialog.getSourceAttributeSelectionOption(), relationshipNameDialog.getTargetAttributeSelectionOption());
       
        /**
         * Generazione del bean Target
         */
       
        targetCompilationUnit.createImport("javax.persistence.OneToOne", null, null);
        targetCompilationUnit.createImport("javax.persistence.FetchType", null, null);
        targetCompilationUnit.createImport("javax.persistence.CascadeType", null, null);
       
        type = targetCompilationUnit.getTypes()[0];

        type.createField("private " + sourceBeanName + " " + Utils.makeFirstLetterLowerCase(reverseRelationshipName) + ";", null, true, null);

        get = "";
        get += "@OneToOne(targetEntity=" + sourceBeanName + ".class, cascade = {CascadeType.REFRESH, CascadeType.MERGE}, fetch=FetchType.LAZY, mappedBy=\"" + Utils.makeFirstLetterLowerCase(directRelationshipName) + "\")\r\n";
        get += "public " + sourceBeanName + " " + Utils.makeGet(reverseRelationshipName+ "()\r\n";
        get += "{\r\n";
        get += "\treturn " + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ ";\r\n";
        get += "}\r\n";
        type.createMethod(get, null, true, null);

        set = "";
        set += "public void " + Utils.makeSet(reverseRelationshipName+ "(" + sourceBeanName + " " + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ ")\r\n";
        set += "{\r\n";
        set += "\tthis." + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ " = " + Utils.makeFirstLetterLowerCase(reverseRelationshipName+ ";\r\n";
        set += "}\r\n";
        type.createMethod(set, null, true, null);

               
        targetCompilationUnit.save(null, true);   
       
        // Inserimento delle annotazioni relative al generatore
       
        types = type.getChildren();
       
        for (IJavaElement element : types)
        {
          if (element instanceof IMethod && element.getElementName().contains(Utils.makeGet(reverseRelationshipName)))
            method = (IMethod)element;
        }
       
        Utils.addSeamGeneratorAnnotations(method, targetCompilationUnit, relationshipNameDialog.getTargetRelationshipOption(), relationshipNameDialog.getTargetAttributeSelectionOption(), relationshipNameDialog.getSourceAttributeSelectionOption());               
      }
     

    }
    catch (JavaModelException e)
View Full Code Here

TOP

Related Classes of boco.ejb3PlugIn.gui.RelationshipDialog

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.