Package org.dmd.dms

Examples of org.dmd.dms.TypeDefinition


     
      boolean shouldAddType = true;
     
      anyAttributes = true;
//      AttributeDefinition ad = may.next();
      TypeDefinition td = ad.getType();
     
      if (ad.getGenericArgs() != null){
        if (ad.getGenericArgs().equals("<DmcObjectName>"))
          needDmwOmni = true;
      }
     
      switch(ad.getValueType()){
      case SINGLE:
        anySVAttributes =  true;
        break;
      case HASHMAPPED:
      case TREEMAPPED:
        anyMVAttributes = true;
        if (ad.getType().getIsRefType())
          anyMVRefs = true;
       
        iterables.put(td.getName(),td);
        break;
      case MULTI:
      case HASHSET:
      case TREESET:
        anyMVAttributes = true;
       
        if (ad.getType().getIsRefType())
          anyMVRefs = true;
       
        iterables.put(td.getName(),td);
       
        break;
      }
     
      if (shouldAddType){
        types.put(td.getName(), td);
        TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
        typeAndAttr.put(ta.name, ta);
      }
     
      appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), ad.getDataType());

      if (ad.getGenericArgsImport() != null)
        genericImports.add(ad.getGenericArgsImport());

      if (ad.getValueType() != ValueTypeEnum.SINGLE){
        if (!ad.getType().getIsExtendedRefType()){
          if ((ad.getIndexSize() != null) && (ad.getType().getIsRefType())){
            // Don't import the schema of indexed, object refs
          }
          else{
            if (useWrappedObjectRefs)
              imports.addImport(ad.getDefinedIn().getDMSASGImport(), "Attribute " + ad.getName() + " from the " + ad.getDefinedIn().getName() + " schema");
            else{
              if ( (ad.getValueType() == ValueTypeEnum.HASHMAPPED) || (ad.getValueType() == ValueTypeEnum.TREEMAPPED))
                imports.addImport(ad.getDefinedIn().getDMSASGImport(), "Attribute " + ad.getName() + " from the " + ad.getDefinedIn().getName() + " schema");
              else if (ad.getType().getIsRefType()){
//                if (ad.getType().getOriginalClass().getIsNamedBy() == null){
//                  if ( (ad.getValueType() != ValueTypeEnum.HASHSET) && (ad.getValueType() != ValueTypeEnum.TREESET)){
//                   
//                    imports.addImport(ad.getDefinedIn().getDMSASGImport(), "Attribute " + ad.getName() + " from the " + ad.getDefinedIn().getName() + " schema");
//                  }
//                }
              }
              else
                imports.addImport(ad.getDefinedIn().getDMSASGImport(), "Attribute " + ad.getName() + " from the " + ad.getDefinedIn().getName() + " schema");
            }
          }
        }
      }

      allAttr.add(ad);
     
    }
   
//    Iterator<AttributeDefinition> may = cd.getMay();
//    if (may != null){
//      while(may.hasNext()){
//        // NOTE: COMPLICATED! We always add the type of the attribute to our global types
//        // map EXCEPT IF the type is a non-referential, MULTI/SET attribute. Gaa!
//        //
//        // This is because WE DON'T want the primitive type any more, just the TYPEIterableDMW.
//        // If the value is a single valued type, we'll want the primitive type.
//       
//        boolean shouldAddType = true;
//       
//        anyAttributes = true;
//        AttributeDefinition ad = may.next();
//        TypeDefinition td = ad.getType();
//       
//        if (ad.getGenericArgs() != null){
//          if (ad.getGenericArgs().equals("<DmcObjectName>"))
//            needDmwOmni = true;
//        }
//       
//        switch(ad.getValueType()){
//        case SINGLE:
//          anySVAttributes =  true;
//          break;
//        case HASHMAPPED:
//        case TREEMAPPED:
//          anyMVAttributes = true;
//          if (ad.getType().getIsRefType())
//            anyMVRefs = true;
//         
//          iterables.put(td.getName(),td);
//          break;
//        case MULTI:
//        case HASHSET:
//        case TREESET:
//          anyMVAttributes = true;
//         
//          if (ad.getType().getIsRefType())
//            anyMVRefs = true;
//         
//          iterables.put(td.getName(),td);
//         
//          break;
//        }
//       
//        if (shouldAddType){
//          types.put(td.getName(), td);
//          TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
//          typeAndAttr.put(ta.name, ta);
//        }
//       
//        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), ad.getDataType());
//
//        if (ad.getGenericArgsImport() != null)
//          genericImports.add(ad.getGenericArgsImport());
//
//        if (ad.getValueType() != ValueTypeEnum.SINGLE){
//          if (!ad.getType().getIsExtendedRefType()){
//            if ((ad.getIndexSize() != null) && (ad.getType().getIsRefType())){
//              // Don't import the schema of indexed, object refs
//            }
//            else
//              imports.addImport(ad.getDefinedIn().getDMSASGImport(), "Attribute " + ad.getName() + " from the " + ad.getDefinedIn().getName() + " schema");
//          }
//        }
//
//        allAttr.add(ad);
//      }
//    }
//   
//    Iterator<AttributeDefinition> must = cd.getMust();
//    if (must != null){
//      while(must.hasNext()){
//        // NOTE: COMPLICATED! We always add the type of the attribute to our global types
//        // map EXCEPT IF the type is a non-referential, MULTI/SET attribute. Gaa!
//        //
//        // This is because WE DON'T want the primitive type any more, just the TYPEIterableDMW.
//        // If the value is a single valued type, we'll want the primitive type.
//       
//        boolean shouldAddType = true;
//        anyAttributes = true;
//        AttributeDefinition ad = must.next();
//        TypeDefinition td = ad.getType();
//       
//        if (ad.getGenericArgs() != null){
//          if (ad.getGenericArgs().equals("<DmcObjectName>"))
//            needDmwOmni = true;
//        }
//       
//        switch(ad.getValueType()){
//        case SINGLE:
//          anySVAttributes =  true;
//          break;
//        case HASHMAPPED:
//        case TREEMAPPED:
//          anyMVAttributes = true;
//          if (ad.getType().getIsRefType())
//            anyMVRefs = true;
//
//          iterables.put(td.getName(),td);
//          break;
//        case MULTI:
//        case HASHSET:
//        case TREESET:
//          anyMVAttributes = true;
//          if (ad.getType().getIsRefType())
//            anyMVRefs = true;
//
//          iterables.put(td.getName(),td);
//          break;
//        }
//
//        if (shouldAddType){
//          types.put(td.getName(), td);
//          TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
//          typeAndAttr.put(ta.name, ta);
//        }
//       
//        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), ad.getDataType());
//
//        if (ad.getGenericArgsImport() != null)
//          genericImports.add(ad.getGenericArgsImport());
//
//        if (ad.getValueType() != ValueTypeEnum.SINGLE){
//          if (!ad.getType().getIsExtendedRefType()){
//            if ((ad.getIndexSize() != null) && (ad.getType().getIsRefType())){
//              // Don't import the schema of indexed, object refs
//            }
//            else
//              imports.addImport(ad.getDefinedIn().getDMSASGImport(), "Attribute " + ad.getName() + " from the " + ad.getDefinedIn().getName() + " schema");
//          }
//        }
//       
//        allAttr.add(ad);
//      }
//    }
   
    if (cd.getIsNamedBy() != null){
      AttributeDefinition isNamedBy = cd.getIsNamedBy();
      String nameAttributeType = isNamedBy.getType().getPrimitiveType();
     
      imports.addImport(nameAttributeType, "Is named by");
    }
     
    if (useWrappedObjectRefs){
//      imports.addImport("org.dmd.dms.*", "Always 2");
      imports.addImport("org.dmd.dms.ClassDefinition", "Passing derived class def up the hierarchy");
    }
   
    if ( (cd.getClassType() != ClassTypeEnum.ABSTRACT) && (cd.getClassType() != ClassTypeEnum.AUXILIARY)){
      imports.addImport("org.dmd.dms.generated.types.DmcTypeModifierMV", "Required for MODREC constructor");
      imports.addImport("org.dmd.dms.generated.dmo.MetaDMSAG", "Required for MODREC constructor");
    }
   
    if (cd.getDmwWrapperType(genContext) == WrapperTypeEnum.EXTENDED){
      imports.addImport(cd.getDmeImport(), "Required for getModificationRecorder()");
    }
     
    if (needDmwOmni)
      imports.addImport("org.dmd.dmw.DmwOmni", "Have DmcObjectName attributes");
   
    if (anyAttributes){
      imports.addImport("org.dmd.dmc.*", "If any attributes");
    }
   
    for(String s: genericImports){
      imports.addImport(s, "Generic args import");
    }

    for(TypeAndAttr ta : typeAndAttr.values()){
      TypeDefinition td = ta.td;
     
      if (td.getIsRefType()){
        if (useWrappedObjectRefs){
          // We have to make some adjustments to handle the fact that we
          // may not be generating this code in the same location as the DMOs
          td.adjustJavaClass();
         
          if (td.getIsExtendedRefType() && ta.valueType == ValueTypeEnum.SINGLE){
            // no need to import the ref type
          }
          else
            imports.addImport(td.getAuxHolderImport(), "Is reference type");
         
          // If this is multi-valued, we don't need the REF because we're returning the Iterable
          if (ta.valueType == ValueTypeEnum.SINGLE){
            if (td.getOriginalClass().getIsNamedBy() == null)
              imports.addImport(td.getOriginalClass().getDmoImport(), "Reference to unnamed object");
            else{
              if (!td.getIsExtendedRefType())
                imports.addImport(td.getOriginalClass().getDmtREFImport(), "Is reference type REF");
            }
          }
         
          if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
            imports.addImport(ta.getImport(), "Reference in an auxiliary class");
          }
         
          if (td.getOriginalClass().getIsNamedBy() != null){
            if ( (ta.valueType == ValueTypeEnum.TREEMAPPED) || (ta.valueType == ValueTypeEnum.HASHMAPPED) || (ta.indexed)){
              if (!ta.td.getIsExtendedRefType())
                imports.addImport(td.getOriginalClass().getDmtREFImport(), "To support getMVCopy() for REFs " + ta.name);
            }
          }
        }
        else{
          // If this is multi-valued, we don't need the REF because we're returning the Iterable
          if (ta.valueType == ValueTypeEnum.SINGLE){
            if (td.getOriginalClass().getIsNamedBy() == null)
              imports.addImport(td.getOriginalClass().getDmoImport(), "Reference to unnamed object");
            else{
              if (!td.getIsExtendedRefType())
                imports.addImport(td.getOriginalClass().getDmtREFImport(), "Is reference type REF");
            }
          }
         
//          if (td.getOriginalClass().getIsNamedBy() != null)
            imports.addImport(td.getPrimitiveType(), "DMO reference");         

          if (td.getHelperClassName() != null){
            imports.addImport(td.getHelperClassName(), "Helper class");
          }
        }
      }
      else if (td.getPrimitiveType() != null){
        imports.addImport(td.getPrimitiveType(), "Primitive type");
      }
      else if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
        imports.addImport(ta.getImport(), "Type in an auxiliary class");
      }
     
      if (td.getAltType() != null){
        if (td.getAltTypeImport() != null)
          imports.addImport(td.getAltTypeImport(), "Alternative type for " + td.getName() + " values");
      }
     
     
     
     
     
     
      if (td.getKeyImport() != null)
        imports.addImport(td.getKeyImport(), "Key class");
     
//      if (ta.valueType != ValueTypeEnum.SINGLE)
//        imports.addImport("java.util.Iterator", "To support getMVCopy()");

      switch(ta.valueType){
      case SINGLE:
        break;
      case MULTI:
        if (!ta.indexed){
          if (td.getIsRefType() && (td.getOriginalClass().getIsNamedBy() == null)){
           
          }
          else if (useWrappedObjectRefs)
            imports.addImport("java.util.ArrayList", "To support getMVCopy()");
        }
        break;
      case HASHMAPPED:
        if (useWrappedObjectRefs)
          imports.addImport("java.util.HashMap", "To support getMVCopy()");
        break;
      case TREEMAPPED:
        if (useWrappedObjectRefs)
          imports.addImport("java.util.TreeMap", "To support getMVCopy()");
        break;
      case HASHSET:
        if (td.getIsRefType()){
          if (td.getOriginalClass().getIsNamedBy() != null){
            if (useWrappedObjectRefs)
              imports.addImport("java.util.HashSet", "To support getMVCopy()");
          }
        }
        else
          imports.addImport("java.util.HashSet", "To support getMVCopy()");
        break;
      case TREESET:
        if (td.getIsRefType()){
          if (td.getOriginalClass().getIsNamedBy() != null){
            if (useWrappedObjectRefs)
              imports.addImport("java.util.TreeSet", "To support getMVCopy()");
          }
        }
        else
View Full Code Here


//    }

    Iterator<TypeDefinition> tdl = sd.getInternalTypeDefList();
    if (tdl != null){
      while(tdl.hasNext()){
        TypeDefinition td = tdl.next();
       
        if (td.getIsEnumType())
          dumpEnumType(td,outdir);
        else if (td.getIsRefType()){
          if (td.getHelperClassName() == null){
            dumpNormalREFType(td, outdir);
          }
          else{
            dumpNamedREF(td, outdir);
            dumpNamedREFHelperType(td,outdir);
          }
        }
      }
    }
   
    tdl = sd.getTypeDefList();
    if (tdl != null){
      while(tdl.hasNext()){
        TypeDefinition td = tdl.next();
       
//        DebugInfo.debug("ITS A USER DEFINED TYPE: " + td.getName());
       

        String tn         = td.getName().getNameString();
        String primitiveImport   = td.getDefinedIn().getSchemaPackage() + ".types.DmcType" + tn;
        String schemaPackage  = td.getDefinedIn().getSchemaPackage();
        String baseTypeImport  = td.getDefinedIn().getSchemaPackage() + ".types." + tn;
        String nameAttrID    = null;
       
        if (td.getIsNameType()){
          nameAttrID = td.getNameAttributeDef().getDmdID().toString();
        }
        if (td.getIsFilterType()){
          nameAttrID = td.getFilterAttributeDef().getDmdID().toString();
        }
       
                  //   dmotypedir     basePackage   baseTypeImport   typeName   primitiveImport   nameAttrImport   nameAttr   nameAttrID  generic  isRef  isNameType      isFilterType      fileHeader   progress
        GenUtility.dumpSVTypeoutdir,     schemaPackage,  baseTypeImport,  tn,      primitiveImport,  null,      null,    nameAttrID,  "",    false,  td.getIsNameType(),  td.getIsFilterType(),  fileHeader,  progress);
        GenUtility.dumpMVTypeoutdir,     schemaPackage,  baseTypeImport,  tn,      primitiveImport,  null,      null,          "",    false,                        fileHeader,  progress);
        GenUtility.dumpSETTypeoutdir,     schemaPackage,  baseTypeImport,  tn,      primitiveImport,  null,      null,          "",    false,                        fileHeader,  progress);

        if (td.getKeyClass() != null){
          String keyClass = td.getKeyClass();
          String keyImport = td.getKeyImport();
                    //   dmotypedir     basePackage   baseTypeImport   typeName   primitiveImport   nameAttrImport   nameAttr   generic  keyClass  keyImport  fileHeader   progress
          GenUtility.dumpMAPTypeoutdir,     schemaPackage,  baseTypeImport,  tn,      primitiveImport,  null,      null,    "",    keyClass,  keyImport,  fileHeader,  progress);
        }
      }
    }
View Full Code Here

    }
     
        Iterator<TypeDefinition> tds = sd.getTypeDefList();
    if (tds != null){
      while(tds.hasNext()){
        TypeDefinition td = tds.next();
        types.put(td.getName().getNameString(), td);
      }
    }
   
    tds = sd.getInternalTypeDefList();
    if (tds != null){
      while(tds.hasNext()){
        TypeDefinition td = tds.next();
        types.put(td.getName().getNameString(), td);
      }
    }
   
     
        out.write("\n");

    out.write("// Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write("public class " + schemaName + " implements DmcCompactSchemaIF {\n\n");

        out.write("\n");
        out.write("    static String schemaName = \"" + sd.getName().getNameString() + "\";\n");
        out.write("\n");

        out.write("\n");
        out.write("    static int schemaBaseID = " + sd.getSchemaBaseID() + ";\n");
        out.write("\n");

        out.write("\n");
        out.write("    static int schemaIDRange = " + sd.getSchemaIDRange() + ";\n");
        out.write("\n");

        int max = sd.getSchemaBaseID() + sd.getSchemaIDRange();
       
        out.write("\n");
        out.write("    static int schemaMaxID = " + max + ";\n");
        out.write("\n");

        for(AttributeDefinition ad: attributes.values()){
      //     public final static DmcAttributeInfo __monitoredBy = new DmcAttributeInfo("monitoredBy",2202,"DashboardPrefs",ValueTypeEnum.MULTI,false);
      out.write("    public final static DmcAttributeInfo __" + ad.getName().getNameString() + " = new DmcAttributeInfo(");
      out.write("\"" + ad.getName().getNameString() + "\"");
      out.write(", " + ad.getDmdID());
      out.write(", \"" + ad.getType().getName().getNameString() + "\"");
      out.write(", ValueTypeEnum." + ad.getValueType());
      out.write(", DataTypeEnum." + ad.getDataType());
     
      if (ad.getIndexSize() == null)
        out.write(");\n");
      else
        out.write(", " + ad.getIndexSize() + ");\n");
    }
       
        if (types.size() > 0){
            out.write("\n");
        out.write("    // Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
        for(TypeDefinition td: types.values()){
           
            if (td.getInternallyGenerated() == false){
              // This is a straightforward type definition
             
              if (td.getIsNameType() == false)
                out.write("    public final static DmcTypeInfo __type_" + td.getName().getNameString() + " = new DmcTypeInfo(\"" + td.getName().getNameString() + "\", OriginalTypeEnum.TYPE);\n");
              else
                out.write("    public final static DmcTypeInfo __type_" + td.getName().getNameString() + " = new DmcTypeInfo(\"" + td.getName().getNameString() + "\", OriginalTypeEnum.NAMETYPE);\n");

            }
            else{
              // Have to check extended ref before ref type since both values are set of extended refs.
             
              if (td.getIsEnumType())
                out.write("    public final static DmcTypeInfo __type_" + td.getName().getNameString() + " = new DmcTypeInfo(\"" + td.getName().getNameString() + "\", OriginalTypeEnum.ENUM);\n");
              else if (td.getIsExtendedRefType())
                out.write("    public final static DmcTypeInfo __type_" + td.getName().getNameString() + " = new DmcTypeInfo(\"" + td.getName().getNameString() + "\", OriginalTypeEnum.EXTREF);\n");
              else if (td.getIsRefType()){
                // We actually want to distinguish between unnamed objects and named objects
                if (td.getOriginalClass().getIsNamedBy() == null)
                  out.write("    public final static DmcTypeInfo __type_" + td.getOriginalClass().getName().getNameString() + " = new DmcTypeInfo(\"" + td.getOriginalClass().getName().getNameString() + "\", OriginalTypeEnum.OBJECT);\n");
                else
                  out.write("    public final static DmcTypeInfo __type_" + td.getOriginalClass().getName().getNameString() + " = new DmcTypeInfo(\"" + td.getOriginalClass().getName().getNameString() + "\", OriginalTypeEnum.REFERENCE);\n");
              }
              else{
                // Fixed 20130121 for references to classes
                if (td.getOriginalClass() == null)
                  out.write("    public final static DmcTypeInfo __type_" + td.getName().getNameString() + " = new DmcTypeInfo(\"" + td.getName().getNameString() + "\", OriginalTypeEnum.COMPLEXTYPE);\n");
                else
                  out.write("    public final static DmcTypeInfo __type_" + td.getOriginalClass().getName().getNameString() + " = new DmcTypeInfo(\"" + td.getOriginalClass().getName().getNameString() + "\", OriginalTypeEnum.COMPLEXTYPE);\n");
              }
            }
           
//            System.out.println("HERE\n\n" + td.toOIF());
        }
View Full Code Here

       
       
        Iterator<TypeDefinition> tds = sd.getTypeDefList();
    if (tds != null){
      while(tds.hasNext()){
        TypeDefinition td = tds.next();
        if (td.getIsNameType()){
          if (td.getNameAttributeDef() == null)
            throw(new IllegalStateException("TypeDefinition " + td.getName() + "  does not have a designated naming attribute."));
         
          String adn = td.getName().getNameString();
          nameBuilders.append("        _NmAp.put(DmcType" + adn + "STATIC.instance.getNameClass(),DmcType" + adn + "STATIC.instance);\n");
        }
        else if (td.getIsFilterType()){
          if (td.getFilterAttributeDef() == null)
            throw(new IllegalStateException("TypeDefinition " + td.getName() + "  does not have a designated filter attribute."));
         
          String adn = td.getName().getNameString();
          nameBuilders.append("        _FmAp.put(DmcType" + adn + "STATIC.instance.getFilterClass(),DmcType" + adn + "STATIC.instance);\n");
        }
      }
    }
   
View Full Code Here

    }
   
    Iterator<TypeDefinition> types = sd.getTypeDefList();
    if (types != null){
      while(types.hasNext()){
        TypeDefinition td = types.next();
       
        if (td.getIsExtendedRefType())
          continue;
       
        String genericArgs = td.getGenericArgs();
        if (genericArgs == null)
          genericArgs = "";
       
        GenUtility.dumpIterable(dmwdir, sd.getDmwPackage(), td.getPrimitiveType(), td.getName().getNameString(), genericArgs, fileHeader, progress);
      }
    }
   
    Iterator<EnumDefinition>  enums = sd.getEnumDefList();
    if (enums != null){
View Full Code Here

    }
   
    Iterator<TypeDefinition> types = sd.getTypeDefList();
    if (types != null){
      while(types.hasNext()){
        TypeDefinition td = types.next();
        String genericArgs = td.getGenericArgs();
        if (genericArgs == null)
          genericArgs = "";
       
        GenUtility.dumpIterable(dmwdir, sd.getDmwPackage(), td.getPrimitiveType(), td.getName().getNameString(), genericArgs, fileHeader, progress);
      }
    }
   
    Iterator<EnumDefinition>  enums = sd.getEnumDefList();
    if (enums != null){
View Full Code Here

    if (may != null){
      while(may.hasNext()){
        AttributeDefinition ad = may.next();
        anyAttributes = true;
       
        TypeDefinition td = ad.getType();
        types.put(td.getName(), td);
       
        TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
        typeAndAttr.put(ta.name, ta);
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes.set(true);;
          break;
        case MULTI:
          if (ad.getIndexSize() == null){
            anyMVAttributes.set(true);
          }
          else{
            if (td.getIsRefType() == false)
              anyMVAttributes.set(true);
          }
          break;
        case HASHMAPPED:
        case TREEMAPPED:
        case HASHSET:
        case TREESET:
          anyMVAttributes.set(true);
          break;
        }
       
        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());
       
        if (attributeInfo != null)
          appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), "true");

        if ((cd != null) && (cd.getClassType() == ClassTypeEnum.AUXILIARY))
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
         
        if ((cd != null) && (ad.getDefinedIn() != cd.getDefinedIn()))
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
         
        if ((act != null) && (ad.getDefinedIn() != act.getDefinedIn()))
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
         
        allAttr.add(ad);
      }
    }
   
    if (must != null){
      while(must.hasNext()){
        AttributeDefinition ad = must.next();
        anyAttributes = true;
       
        TypeDefinition td = ad.getType();
        types.put(td.getName(), td);
       
        TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
        typeAndAttr.put(ta.name, ta);
       
//        if (interested){
//          if (ad.getName().getNameString().equals("wlanConfigProfiles")){
//            DebugInfo.debug("The type is: " + ta.name);
//            theType = ta.name;
//          }
//        }
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes.set(true);
          break;
        case MULTI:
          // We don't need java.util with indexed multi-values
          if (ad.getIndexSize() == null){
            anyMVAttributes.set(true);
          }
          else{
            if (td.getIsRefType() == false)
              anyMVAttributes.set(true);
          }
          break;
        case HASHMAPPED:
        case TREEMAPPED:
        case HASHSET:
        case TREESET:
          anyMVAttributes.set(true);
          break;
        }
               
        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());

        if (attributeInfo != null)
          appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), "true");

        if ((cd != null) && (cd.getClassType() == ClassTypeEnum.AUXILIARY))
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");

        if ((cd != null) && (ad.getDefinedIn() != cd.getDefinedIn()))
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
         
        if ((act != null) && (ad.getDefinedIn() != act.getDefinedIn()))
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
         
        allAttr.add(ad);
      }
    }
   
   
    anyAttributesAtThisLevel = anyAttributes;
   
    if ( (cd != null) && (cd.getFullAttrMap().size() > 0) )
      anyAttributes = true;
   
    if (cd == null){
      if (anyMVAttributes.booleanValue())
        addImport(uniqueImports, longestImport, "java.util.*", "Always required if we have any MV attributes");
    }
    else{
      if (cd.getClassType() != ClassTypeEnum.AUXILIARY){
        if (anyMVAttributes.booleanValue())
          addImport(uniqueImports, longestImport, "java.util.*", "Always required if we have any MV attributes");
      }
    }
     
    if ( (cd != null) && (cd.getClassType() != ClassTypeEnum.AUXILIARY))
      addImport(uniqueImports, longestImport, "java.io.Serializable", "Always required");
     
    if ( (cd != null) && (cd.getClassType() != ClassTypeEnum.ABSTRACT) && (cd.getClassType() != ClassTypeEnum.AUXILIARY)){
      addImport(uniqueImports, longestImport, "org.dmd.dms.generated.types.DmcTypeModifierMV", "Required for MODREC constructor");
      addImport(uniqueImports, longestImport, "org.dmd.dms.generated.dmo.MetaDMSAG", "Required for MODREC constructor");
      addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcSliceInfo", "Required for object slicing");
    }
     
//    if (anyAttributes){
//      addImport(uniqueImports, longestImport, "org.dmd.dms.generated.enums.ValueTypeEnum", "Required if we have any attributes");
//      addImport(uniqueImports, longestImport, "org.dmd.dms.generated.enums.DataTypeEnum", "Required if we have any attributes");
//    }
//
//    addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcAttributeInfo", "Always required");
   
    if (anyAttributesAtThisLevel){
      addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcAttribute", "Any attributes");
      addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcValueException", "Any attributes");
    }
   
    for(String s: genericImports){
      addImport(uniqueImports, longestImport, s, "Generic args import");
    }

//    DebugInfo.debug("For class: " + cd.getName());
   
    for(TypeAndAttr ta: typeAndAttr.values()){
     
      TypeDefinition td = ta.td;
     
//      if (interested && ta.name.startsWith(theType)){
//        DebugInfo.debug("HERE");
//      }

      if ( (td.getPrimitiveType() != null) && (cd != null) && (cd.getClassType() != ClassTypeEnum.AUXILIARY) ){
        if (td.getInternallyGenerated() && td.getIsRefType()){
          // We have an internally generated reference type, only import if
          // the definition is from a different schema, otherwise, we're
          // already in the same package and don't need to import it
          if (cd.getDefinedIn() != td.getDefinedIn()){
            // NOTE: GetRequest has an unneeded ClassDefinitionDMO import because of this
            // need to figure out the right criteria
           
//            addImport(uniqueImports, longestImport, td.getPrimitiveType(), "Primitive type and !auxiliary - internally generated reference type");
          }
        }
        else{
          addImport(uniqueImports, longestImport, td.getPrimitiveType(), "Primitive type and !auxiliary class");
        }
      }
     
      if ( (td.getPrimitiveType() != null) && (act != null) ){
        if (td.getInternallyGenerated() && td.getIsRefType()){
          // We have an internally generated reference type, only import if
          // the definition is from a different schema, otherwise, we're
          // already in the same package and don't need to import it
          if (act.getDefinedIn() != td.getDefinedIn()){
            // NOTE: GetRequest has an unneeded ClassDefinitionDMO import because of this
            // need to figure out the right criteria
           
//            addImport(uniqueImports, longestImport, td.getPrimitiveType(), "Primitive type and !auxiliary - internally generated reference type");
          }
        }
        else{
          addImport(uniqueImports, longestImport, td.getPrimitiveType(), "Primitive type and !auxiliary class");
        }
      }

     
      if (td.getAltType() != null){
        if (td.getAltTypeImport() != null)
          addImport(uniqueImports, longestImport, td.getAltTypeImport(), "Alternative type for " + td.getName() + " values");
      }
     
     
      if (td.getIsRefType() && !td.getIsExtendedRefType()){
        addImport(uniqueImports, longestImport, ta.getImport(), "Reference type");
       
        if (ta.valueType == ValueTypeEnum.TREEMAPPED){
          if (td.getOriginalClass().getIsNamedBy() != null)
            addImport(uniqueImports, longestImport, td.getOriginalClass().getIsNamedBy().getType().getPrimitiveType(),"Name attribute type");
        }
       
        addImport(uniqueImports, longestImport, td.getOriginalClass().getDmoImport(), "Type specific set/add");
       
//        addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcNamedObjectIF", "Named object reference");

        if (td.getOriginalClass().getInternalTypeRef().getHelperClassName() == null){
//          DebugInfo.debug("\n\n*** PROBABLY MISSING isNamedBy FQN on a hierarchic object: " + td.getName() + " ***\n\n");
        }
        else{
         
//          DebugInfo.debug(td.toOIF(20));
          addImport(uniqueImports, longestImport, td.getOriginalClass().getInternalTypeRef().getHelperClassName(), "Reference type helper class");
         
          if ( (cd != null) && (cd.getClassType() != ClassTypeEnum.AUXILIARY))
            addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcOmni", "Lazy resolution");
                   
        }
      }
      else{
        if (td.getIsExtendedRefType())
          addImport(uniqueImports, longestImport, td.getPrimitiveType(), "Extended reference type");

        addImport(uniqueImports, longestImport, ta.getImport(), "Required type");
      }
     
      if (td.getIsExtendedRefType())
        addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcOmni", "Lazy resolution");
     
      if (td.getHelperClassName() != null){
        addImport(uniqueImports, longestImport, td.getHelperClassName(), "Helper class");
      }
     
      if (td.getKeyImport() != null){
        addImport(uniqueImports, longestImport, td.getKeyImport(), "Key class");
      }
    }
   
    if (cd != null){
      if (cd.getDerivedFrom() == null){
View Full Code Here

   
    if (may != null){
      anyAttributes = true;
      while(may.hasNext()){
        AttributeDefinition ad = may.next();
        TypeDefinition td = ad.getType();
        types.put(td.getName(), td);
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes.set(true);
          break;
        case MULTI:
        case HASHMAPPED:
        case TREEMAPPED:
        case HASHSET:
        case TREESET:
          anyMVAttributes.set(true);
          needJavaUtil = true;
          break;
        }

        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), "true");
       
        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());
       
        allAttr.add(ad);
      }
    }
   
    if (must != null){
      anyAttributes = true;
      while(must.hasNext()){
        AttributeDefinition ad = must.next();
        TypeDefinition td = ad.getType();
        types.put(td.getName(), td);
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes.set(true);
          break;
        case MULTI:
        case HASHMAPPED:
        case TREEMAPPED:
        case HASHSET:
        case TREESET:
          anyMVAttributes.set(true);
          needJavaUtil = true;
          break;
        }

        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), "false");

        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());
       
        allAttr.add(ad);
      }
    }
   
    if (needJavaUtil)
      sb.append("import java.util.*;\n\n");
   
    if (anyAttributes){
      sb.append("import org.dmd.dmc.DmcAttribute;\n");
      sb.append("import org.dmd.dmc.DmcValueException;\n");
      sb.append("import org.dmd.dmc.DmcAttributeInfo;\n");
      sb.append("import org.dmd.dms.generated.enums.ValueTypeEnum;\n");
    }
   
    for(String s: genericImports){
      sb.append("import " + s + ";\n");
    }

    // If the class is auxiliary, we need the DmcTypeString to manipulate the ocl attribute
    if (cd != null){
      if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
        types.put(new StringName("String"), MetaSchema._String);
      }
    }

    Iterator<TypeDefinition> t = types.values().iterator();
    while(t.hasNext()){
      TypeDefinition td = t.next();

      if (cd != null){
        if ( (td.getPrimitiveType() != null) && (cd.getClassType() != ClassTypeEnum.AUXILIARY) ){
         
          if (td.getInternallyGenerated() && td.getIsRefType()){
            // We have an internally generated reference type, only import if
            // the definition is from a different schema, otherwise, we're
            // already in the same package and don't need to import it
            if (cd.getDefinedIn() != td.getDefinedIn()){
              sb.append("// import 1\n");
              sb.append("import " + td.getPrimitiveType() + ";\n");
            }
          }
          else{
            sb.append("// import 2\n");
            sb.append("import " + td.getPrimitiveType() + ";\n");
          }
        }
      }
     
      sb.append("// import 3 " + td.getName() + "\n");
     
      if (td.getIsRefType()){
        sb.append("import " + td.getOriginalClass().getDmtImport() + ";\n");
      }
      else{
        sb.append("import " + td.getTypeClassName() + ";\n");
      }
     
      if (td.getHelperClassName() != null){
        sb.append("// import 4\n");
        sb.append("import " + td.getHelperClassName() + ";\n");
      }
    }
   
  }
View Full Code Here

        if (ad.getDmdID() == 1)
          continue;
       
        String       schema   = ad.getDefinedIn().getName().getNameString();
        String       tschema = ad.getType().getDefinedIn().getName().getNameString();
        TypeDefinition   td     = ad.getType();
        String       type   = TypeFormatter.getTypeName(td);
       
        if (first){
          first = false;
          appendSectionLabel(sb, "Must have attributes");
View Full Code Here

        if (ad.getDmdID() == 1)
          continue;

        String       schema   = ad.getDefinedIn().getName().getNameString();
        String       tschema = ad.getType().getDefinedIn().getName().getNameString();
        TypeDefinition   td     = ad.getType();
        String       type   = TypeFormatter.getTypeName(td);

        if (ad.getInternalUse()){
          if (internal.length() == 0){
            appendSectionLabel(internal, "Internal use attributes");
View Full Code Here

TOP

Related Classes of org.dmd.dms.TypeDefinition

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.