Package com.volantis.mcs.build.javadoc

Examples of com.volantis.mcs.build.javadoc.ClassInfo


     * Generate a utilities package for the current object if it is needed.
     * @param repInfo
     * @param generatedDir The directory that the utilities are written to.
     */
    public static void generateUtilities(RepositoryObjectInfo repInfo, File generatedDir) {
        ClassInfo objectClassInfo = repInfo.getObjectClassInfo();
        String objectClassName = objectClassInfo.getName();
        PackageInfo objectPackage = objectClassInfo.getPackageInfo();
        String utilitiesPackage = objectPackage.getName();
        String utilitiesName = objectClassName + "Utilities";

        List allObjectFields = repInfo.getAllObjectFields();
        boolean utilitiesNeeded = false;
View Full Code Here


        if (values == null || values.size() == 0) {
            return;
        }

        String fieldName = field.getName();
        ClassInfo objectClassInfo = field.getClassInfo();
        String objectClassName = objectClassInfo.getName();
        String[] objectClassWords
                = GenerateUtilities.getWords(objectClassName);
        String objectNaturalName
                = GenerateUtilities.getNaturalName(objectClassWords);
        if (values != null && values.size() != 0) {
View Full Code Here

     */
    public static void updatePropertyValueLookUp(RepositoryObjectInfo repInfo, File generatedDir) {
        try {
            File propertyValueLookUp = getPropertyValueLookUpFile(generatedDir);

            ClassInfo objectClassInfo = repInfo.getObjectClassInfo();
            String objectClassName = objectClassInfo.getName();
            List allObjectFields = repInfo.getAllObjectFields();
            String utilitiesName = objectClassName + "Utilities";

            // Read the PropertyValueLookUp class into a StringBuffer.
            StringBuffer buffer = new StringBuffer();
            FileReader fr = new FileReader(propertyValueLookUp);
            BufferedReader br = new BufferedReader(fr);

            String line = br.readLine();
            while (line != null) {
                buffer.append(line).append('\n');
                line = br.readLine();
            }
            br.close();

            boolean initializedPropertyToArray = false;
            boolean initializedPropertyToControlType = false;
            boolean initializedPropertyToMap = false;
            boolean initializedPropertyToMaxLength = false;
            boolean initializedPropertyToRequired = false;
            boolean initializedPropertyNametoXMLAttrName = false;
            boolean initializedDependentsList = false;
            boolean initializedIdentityAttributesList = false;

            StringBuffer initialization = new StringBuffer();

            initialization.append("    // " + objectClassName + "\n");

            String qualifiedClassName = objectClassInfo.getQualifiedName();
            String elementName = repInfo.getObjectElementName();
            if(elementName==null) {
                elementName =
                        Character.toLowerCase(objectClassName.charAt(0)) +
                        objectClassName.substring(1);
View Full Code Here

    // Add this immediately to prevent loops.
    String qualifiedClassName = objectClassDoc.qualifiedName ();
    instances.put (qualifiedClassName, this);

    objectClassInfo = new ClassInfo (objectClassDoc);

    ClassDoc identityBaseClassDoc;
    Tag [] tags = objectClassDoc.tags ("mariner-object-base-identity-class");
    // If a base identity class has been specified, try to use it
    // otherwise search for one.
    if(tags.length == 1) {
        String baseIdentityClassName = tags[0].text();
        identityBaseClassDoc = rootDoc.classNamed (baseIdentityClassName);
        if(identityBaseClassDoc == null) {
            throw new IllegalStateException("Cannot find base identity class" +
                baseIdentityClassName);
        }
    } else {
        identityBaseClassDoc = getIdentityBaseClassDoc (rootDoc,
                                                             objectClassDoc);
    }
   
    System.out.println("Using base class " + identityBaseClassDoc.qualifiedName());
    identityBaseClassInfo = new ClassInfo (identityBaseClassDoc);

    // Create a ClassInfo for the identity class.
    String identityClassName = objectClassInfo.getName () + "Identity";
    String identityClassQualifiedName
      = objectClassInfo.getQualifiedName () + "Identity";

    identityClassInfo = new ClassInfo (objectClassInfo.getPackageInfo (),
                                       identityBaseClassInfo,
                                       identityClassName,
                                       identityClassQualifiedName);

    allIdentityFields = new ArrayList ();
    // Find out whether this object has any dependencies.
    tags = objectClassDoc.tags ("mariner-object-guardian");
    if (tags.length == 1) {
      String guardianClass = tags [0].text ();
      ClassDoc guardianClassDoc = rootDoc.classNamed (guardianClass);
      if (guardianClassDoc == null) {
        throw new IllegalStateException ("Cannot find guardian class "
                                         + guardianClass);
      }
      guardianInfo = RepositoryObjectInfo.getInstance (rootDoc,
                                                       guardianClassDoc);
    } else if (tags.length > 1) {
      throw new IllegalStateException ("Class can only have one"
                                       + " mariner-object-guardian");
    }

    // Create an array of the new fields in the class.
    tags = objectClassDoc.tags ("mariner-object-identity-field");
    int identityFieldCount = tags.length;

    for (int i = 0; i < identityFieldCount; i += 1) {

      // Get the field name.
      String fieldName = tags [i].text ();

      FieldInfo identityField;

      // If it is inherited from the base class then ignore it.
      identityField = identityBaseClassInfo.getField (fieldName, true);
     
      if (identityField != null) {
        if (GenerateUtilities.isProjectField(identityField)) {
            projectIdentityField = identityField;
        }
        // Add it to the list of all the identity fields.
        allIdentityFields.add (identityField);
        continue;
      }

      // Get the details of the object's field.
      FieldInfo objectField = objectClassInfo.getField (fieldName, true);

      String comment = objectField.getComment ();
      comment = getConstructorParameterComment (objectClassDoc,
                                                fieldName,
                                                comment);

      // Create a field for the identity class.
      identityField = new FieldInfo (objectField, comment);

      // Add it to the class.
      identityClassInfo.addField (identityField);

      // Add it to the list of all the identity fields.
      allIdentityFields.add (identityField);

      // Get the details of the object's getter method.
      MethodInfo objectGetter = objectClassInfo.getGetterMethod (fieldName,
                                                                 true);
      MethodInfo identityGetter
        = new MethodInfo (objectGetter.getName (),
                          objectGetter.getReturnType (),
                          objectGetter.getComment ());

      // Add it to the class.
      identityClassInfo.addMethod (identityGetter);
    }

      // Create the list of parameters for the constructor.
    List constructorParameters = new ArrayList ();
    for (Iterator i = allIdentityFields.iterator (); i.hasNext ();) {
      FieldInfo field = (FieldInfo) i.next ();

      ParameterInfo parameter = new ParameterInfo (field.getClassInfo (),
                                                   field.getName (),
                                                   field.getType ());
      constructorParameters.add (parameter);
    }
   
    ConstructorInfo constructor = new ConstructorInfo (constructorParameters);
    identityClassInfo.addConstructor (constructor);

    // Get the list of extra identity fields.
    if (guardianInfo == null) {
      extraIdentityFields = new ArrayList (allIdentityFields);
    } else {
      ClassInfo guardianIdentityClassInfo
        = guardianInfo.getIdentityClassInfo ();

      extraIdentityFields = getExtraFields (allIdentityFields,
                                            guardianIdentityClassInfo);
    }
View Full Code Here

   * Generate the Identity class for the specified RepositoryObject.
   * @param info The representation of a RepositoryObject class.
   */
  protected void generateIdentityClass (RepositoryObjectInfo info) {

    ClassInfo objectClassInfo = info.getObjectClassInfo ();
    ClassInfo identityClassInfo = info.getIdentityClassInfo ();

      // Open a file.
      PackageInfo identityPackageInfo = identityClassInfo.getPackageInfo();
      String currentPackageName = identityPackageInfo.getName();

      String identityClassName = identityClassInfo.getName();
      if (identityClassName.endsWith("ImplIdentity")) {
          int end = identityClassName.length() - "ImplIdentity".length();
          identityClassName =
                  identityClassName.substring(0, end) + "Identity";
      }
      String qualifiedClassName = currentPackageName + "." + identityClassName;
      PrintStream out = openFileForClass(qualifiedClassName);

    // Write the header.
    GenerateUtilities.writeHeader (out, this.getClass().getName());

    // Write the package statement. The identity class is added to the same
    // package as the class it identifies.
    out.println ();
    out.println ("package " + currentPackageName + ";");

    // Write the imports.
    SortedSet imports = new TreeSet ();
    ClassInfo identityBaseClassInfo = identityClassInfo.getBaseClassInfo ();
    imports.add (identityBaseClassInfo.getQualifiedName ());

    // Find out if this identity includes a device name and if so add
    // an import for RepositoryObjectDeviceIdentity.
    List identityFields = identityClassInfo.getFields ();

    Iterator fields = identityFields.iterator();
    String anotherFieldName = "";
    while(fields.hasNext() && !anotherFieldName.equals("deviceName")) {
        anotherFieldName = ((FieldInfo) fields.next()).getName();
    }

    if(anotherFieldName.equals("deviceName")) {
      imports.add("com.volantis.mcs.objects.RepositoryObjectDeviceIdentity");
    }
     
    if (currentPackageName.indexOf( "com.volantis.mcs.project" ) == -1 ) {
        imports.add("com.volantis.mcs.project.Project");
    }

    GenerateUtilities.writeImports (out, imports, currentPackageName);

    String comment;
    String separator = null;

    // Write the class comment.
    String objectClassName = objectClassInfo.getName ();
    comment = "Encapsulates those properties of a "
      + objectClassName + " which uniquely identify it.\n";

      // @todo should this condition still apply?
    if (currentPackageName.indexOf("com.volantis.mcs.objects") == -1) {
        comment += getReplicateTagsText(info);

    }

    GenerateUtilities.writeJavaDocComment (out, "", comment);

    // Write the class header.
    out.println ("public class " + identityClassName);
    out.print ("  extends " + identityBaseClassInfo.getName () );

    // If this identity includes a deviceName the add
    // "implements RepositoryObjectDeviceIdentity to the class declaration
    if(anotherFieldName.equals("deviceName")) {
      out.print("\n  implements RepositoryObjectDeviceIdentity");
    }
    out.println(" {");

    // Write the copyright statement.
    GenerateUtilities.writeCopyright (out);

    // Write the fields.
    for (Iterator i = identityFields.iterator (); i.hasNext ();) {
      FieldInfo field = (FieldInfo) i.next ();
      String fieldName = field.getName ();

      GenerateUtilities.writeJavaDocComment (out, "  ", field.getComment ());
      out.println ("  private " + field.getTypeName ()
                   + " " + fieldName + ";");
    }

    // Write the initialisation of the base class.
    List baseConstructors = identityBaseClassInfo.getConstructors();
    System.err.println("base constructors = " + baseConstructors);

    // Based on two constructors in the absolute base class of all assets
    if (baseConstructors.size () != 2) {
      throw new IllegalStateException ("Identity base class has wrong number"
                                       + " of constructors\n" +
              "identityBaseClassInfo = " + identityBaseClassInfo.getName());
    }

    // Iterate over all constructors and replicate them in this class
    for (Iterator i = baseConstructors.iterator(); i.hasNext(); /* No ++ */) {

        ConstructorInfo baseConstructor = (ConstructorInfo)i.next();

        // Write the constructor comment.
        GenerateUtilities.openJavaDocComment(out, "  ");
        GenerateUtilities.addJavaDocComment(out, "  ", "Create a new <code>"
                + identityClassName + "</code>.");
        List constructorParameters = baseConstructor.getParameters();
        for (Iterator innerI = constructorParameters.iterator();
                                            innerI.hasNext(); /* No ++ */) {
            ParameterInfo param = (ParameterInfo)innerI.next();
            String paramName = param.getName();
            comment = "@param " + paramName + " " +
                    identityBaseClassInfo.getField(paramName, true).getComment();

            GenerateUtilities.addJavaDocComment(out, "  ", comment);
        }
        GenerateUtilities.closeJavaDocComment(out, "  ");

View Full Code Here

    return "com.volantis.mcs.accessors.jdbc";
  }

  // Javadoc inherited from super class.
  protected String getAccessorName (RepositoryObjectInfo info) {
    ClassInfo objectClassInfo = info.getObjectClassInfo ();
    return "JDBC" + objectClassInfo.getName () + "Accessor";
  }
View Full Code Here

  protected void writeRetrieveMultipleBody (boolean enumerate,
                                            boolean identities) {

    List selectFields = null;
    List queryFields = null;
    ClassInfo queryClassInfo = null;

    out.println ();
    if (guardianInfo == null) {
        out.println ("    // Parent must be null.");
        out.println ("    if (parent != null) {");
        out.println ("      throw new IllegalArgumentException ("
                     + "\"Parent should be null but is '\"");
        out.println ("                                          "
                     + "+ parent + \"'\");");
        out.println ("    }");

        // The generated method has to select all the objects for a project
        // so the select statement only uses the project field as
        // a query field.
        if (identities) {
          selectFields = allIdentityFields;
        } else {
          selectFields = allObjectFields;
        }

        // Always use the project in the query.
        queryFields = new ArrayList();
        queryFields.add(info.getProjectIdentityField());
        queryClassInfo = info.getIdentityClassInfo();

    } else {

      ClassInfo guardianIdentityClassInfo
        = guardianInfo.getIdentityClassInfo ();
      String guardianIdentityClassName = guardianIdentityClassInfo.getName ();
      List allGuardianIdentityFields = guardianInfo.getAllIdentityFields ();

      // Write the code which casts the RepositoryObjectIdentity to the correct
      // type.
      out.println ("    final " + guardianIdentityClassName + " parentId");
      out.println ("      = (" + guardianIdentityClassName + ") parent;");

      // The generated method has to select only those objects which belong
      // to the specified parent and so the query consists of checking the
      // guardian's fields and the selection is all of those fields of the
      // statement does not have a query and must select the columns associated
      // with all of the object's identity fields.
      if (identities) {
        selectFields = info.getExtraIdentityFields ();
      } else {
        selectFields
          = RepositoryObjectInfo.getExtraFields (allObjectFields,
                                                 guardianIdentityClassInfo);
      }

      queryFields = allGuardianIdentityFields;
      queryClassInfo = guardianIdentityClassInfo;

    }

    ClassInfo classInfo;
    String className;
    String instanceName;
    if (identities) {
      classInfo = identityClassInfo;
      instanceName = "i";
    } else {
      classInfo = objectClassInfo;
      instanceName = "o";
    }
    className = classInfo.getName ();

    // Write the code which gets the SQL Connection from the
    // RepositoryConnection.
    writeGetSQLConnection ();
View Full Code Here

     */
    protected void writeRemoveChildrenImplBody() {

        List selectFields;
        List queryFields;
        ClassInfo queryClassInfo;
        out.println();

        if (guardianInfo == null) {

            return;
        }

        ClassInfo guardianIdentityClassInfo = guardianInfo.getIdentityClassInfo();
        String guardianIdentityClassName = guardianIdentityClassInfo.getName();
        List allGuardianIdentityFields = guardianInfo.getAllIdentityFields();

        // Write the code which casts the RepositoryObjectIdentity to the correct
        // type.
        out.println("    final " + guardianIdentityClassName + " parentId");
        out.println("      = (" + guardianIdentityClassName + ") parent;");

        // The generated method has to select only those objects which belong
        // to the specified parent and so the query consists of checking the
        // guardian's fields and the selection is all of those fields of the
        // statement does not have a query and must select the columns associated
        // with all of the object's identity fields.
        selectFields = info.getExtraIdentityFields();
        queryFields = allGuardianIdentityFields;
        queryClassInfo = guardianIdentityClassInfo;

        ClassInfo classInfo;
        String className;
        String instanceName;
        classInfo = identityClassInfo;
        instanceName = "parentId";
        className = classInfo.getName();

        writeGetJDBCConnection();
        out.println ("    String projectName = jdbcConnection.getProjectName(parentId);");

        // Write the code which gets the SQL Connection from the
View Full Code Here

TOP

Related Classes of com.volantis.mcs.build.javadoc.ClassInfo

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.