Package org.dmd.dms

Examples of org.dmd.dms.TypeDefinition


    }
   
   
    Iterator<TypeDefinition>  tdefs = sd.getInternalTypeDefList();
    while(tdefs.hasNext()){
      TypeDefinition td = tdefs.next();
     
      ClassDefinition cd = td.getOriginalClass();
      if (cd != null){
        dumpIterable(config, loc, f, sm, cd, sd);
      }
    }
View Full Code Here


       
        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());

        addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + 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());

        addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");

        allAttr.add(ad);
      }
    }
   
    if (cd.getIsNamedBy() != null){
      AttributeDefinition isNamedBy = cd.getIsNamedBy();
      String nameAttributeType = isNamedBy.getType().getPrimitiveType();
     
      addImport(uniqueImports, longestImport, nameAttributeType, "Is named by");
    }
       
    addImport(uniqueImports, longestImport, "org.dmd.dms.*", "Always 2");
   
    if ( (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");
    }
   
   
    if (cd.getUseWrapperType() == WrapperTypeEnum.EXTENDED){
        addImport(uniqueImports, longestImport, cd.getDmeImport(), "Required for getModificationRecorder()");
    }
     
    if (needDmwOmni)
      addImport(uniqueImports, longestImport, "org.dmd.dmw.DmwOmni", "Have DmcObjectName attributes");
   
    if (anyAttributes)
      addImport(uniqueImports, longestImport, "org.dmd.dmc.*", "If any attributes");
   
    for(String s: genericImports){
      addImport(uniqueImports, longestImport, s, "Generic args import");
    }

    for(TypeAndAttr ta : typeAndAttr.values()){
      TypeDefinition td = ta.td;
     
      if (td.getIsRefType()){
        // 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();
       
        addImport(uniqueImports, longestImport, td.getAuxHolderImport(), "Is reference type aux");
       
        // 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)
            addImport(uniqueImports, longestImport, td.getOriginalClass().getDmoImport(), "Reference to unnamed object");
          else
            addImport(uniqueImports, longestImport, td.getOriginalClass().getDmtREFImport(), "Is reference type REF");
        }
       
        if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
          addImport(uniqueImports, longestImport, ta.getImport(), "Reference in an auxiliary class");
        }
       
        if (td.getOriginalClass().getIsNamedBy() != null)
          addImport(uniqueImports, longestImport, td.getOriginalClass().getDmtREFImport(), "To support getMVCopy() for REFs");
       
      }
      else if (td.getPrimitiveType() != null){
        addImport(uniqueImports, longestImport, td.getPrimitiveType(), "Primitive type");
      }
      else if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
        addImport(uniqueImports, longestImport, ta.getImport(), "Type in an auxiliary class");
      }
     
      if (td.getAltType() != null){
        if (td.getAltTypeImport() != null)
          addImport(uniqueImports, longestImport, td.getAltTypeImport(), "Alternative type for " + td.getName() + " values");
      }
     
      if (td.getKeyImport() != null)
        addImport(uniqueImports, longestImport, td.getKeyImport(), "Key class");
     
      if (ta.valueType != ValueTypeEnum.SINGLE)
        addImport(uniqueImports, longestImport, "java.util.Iterator", "To support getMVCopy()");
       
      switch(ta.valueType){
      case SINGLE:
        break;
      case MULTI:
        addImport(uniqueImports, longestImport, "java.util.ArrayList", "To support getMVCopy()");
        break;
      case HASHMAPPED:
        addImport(uniqueImports, longestImport, "java.util.HashMap", "To support getMVCopy()");
        break;
      case TREEMAPPED:
        addImport(uniqueImports, longestImport, "java.util.TreeMap", "To support getMVCopy()");
        break;
      case HASHSET:
        addImport(uniqueImports, longestImport, "java.util.HashSet", "To support getMVCopy()");
        break;
      case TREESET:
        addImport(uniqueImports, longestImport, "java.util.TreeSet", "To support getMVCopy()");
        break;
      }
       
    }
   
    Iterator<TypeDefinition> t  = iterables.values().iterator();
    while(t.hasNext()){
      TypeDefinition td = t.next();
     
      addImport(uniqueImports, longestImport, td.getDmwIteratorImport(), "For multi-valued " + td.getName().getNameString());
     
      if (td.getPrimitiveType() != null)
        addImport(uniqueImports, longestImport, td.getPrimitiveType(), "For multi-valued contains" + td.getName().getNameString());
     
    }
   
    if (cd.getClassType() == ClassTypeEnum.ABSTRACT){
      addImport(uniqueImports, longestImport, cd.getDmoImport(), "Abstract class");
View Full Code Here

    }
   
    if (useWrappedObjectRefs){
      Iterator<TypeDefinition>  tdefs = sd.getInternalTypeDefList();
      while(tdefs.hasNext()){
        TypeDefinition td = tdefs.next();
       
        ClassDefinition cd = td.getOriginalClass();
        if (cd != null){
          dumpIterable(config, loc, f, sm, cd, sd);
        }
      }
     
View Full Code Here

       
        String CAST = cd.getDmeClass();
//        String REF   = cd.getDmtClass();
        String REF   = ertd.getName().getNameString();
       
        TypeDefinition td = sm.tdef(ertd.getName().getNameString());
       
       
        out.write("package " + cd.getDMWPackage() + ".generated.dmw;\n\n");
       
        out.write("import java.util.Iterator;\n\n");
        out.write("import org.dmd.dmw.DmwContainerIterator;\n");
//        out.write("import " + cd.getDmtREFImport()+ ";\n");
       
        out.write("import " + td.getPrimitiveType() + ";\n");
       
        if (cd.getUseWrapperType() == WrapperTypeEnum.EXTENDED){
            out.write("import " + cd.getDmeImport() + ";\n");
            CAST = cd.getDmeClass();
        }
        else{
            out.write("import " + cd.getDmwImport() + ";\n");
            CAST = cd.getDmwClass();
        }
         
        out.write("\n");
         
        out.write("/**\n");
        out.write(" * The " + ertd.getName().getNameString() + "IteratorDMW will cast from an underlying " + REF + " class to \n");
        out.write(" * the associated wrapper class: " + CAST + " when accessing object references in a wrapper context.\n");
        out.write(" * <P>\n");
        out.write(" * Generated from the " + td.getDefinedIn().getName() + " schema at version " + td.getDefinedIn().getVersion() + "\n");
        out.write(" * <P>\n");
        out.write(" * This code was auto-generated by the dmggenerator utility and shouldn't be altered manually!\n");
        out.write(" * Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write(" */\n");
       
View Full Code Here

       
        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){
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + 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){
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
        }
       
        allAttr.add(ad);
      }
    }
   
    if (cd.getIsNamedBy() != null){
      AttributeDefinition isNamedBy = cd.getIsNamedBy();
      String nameAttributeType = isNamedBy.getType().getPrimitiveType();
     
      addImport(uniqueImports, longestImport, nameAttributeType, "Is named by");
    }
     
    if (useWrappedObjectRefs)
      addImport(uniqueImports, longestImport, "org.dmd.dms.*", "Always 2");
   
    if ( (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");
    }
   
    if (cd.getDmwWrapperType(genContext) == WrapperTypeEnum.EXTENDED){
      addImport(uniqueImports, longestImport, cd.getDmeImport(), "Required for getModificationRecorder()");
    }
     
    if (needDmwOmni)
      addImport(uniqueImports, longestImport, "org.dmd.dmw.DmwOmni", "Have DmcObjectName attributes");
   
    if (anyAttributes)
      addImport(uniqueImports, longestImport, "org.dmd.dmc.*", "If any attributes");
   
    for(String s: genericImports){
      addImport(uniqueImports, longestImport, 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();
         
          addImport(uniqueImports, longestImport, td.getAuxHolderImport(), "Is reference type aux");
         
          // 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)
              addImport(uniqueImports, longestImport, td.getOriginalClass().getDmoImport(), "Reference to unnamed object");
            else
              addImport(uniqueImports, longestImport, td.getOriginalClass().getDmtREFImport(), "Is reference type REF");
          }
         
          if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
            addImport(uniqueImports, longestImport, ta.getImport(), "Reference in an auxiliary class");
          }
         
          if (td.getOriginalClass().getIsNamedBy() != null){
            if ( (ta.valueType == ValueTypeEnum.TREEMAPPED) || (ta.valueType == ValueTypeEnum.HASHMAPPED) || (ta.indexed))
              addImport(uniqueImports, longestImport, td.getOriginalClass().getDmtREFImport(), "To support getMVCopy() for REFs");
          }
        }
        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)
              addImport(uniqueImports, longestImport, td.getOriginalClass().getDmoImport(), "Reference to unnamed object");
            else{
              if (!td.getIsExtendedRefType())
                addImport(uniqueImports, longestImport, td.getOriginalClass().getDmtREFImport(), "Is reference type REF");
            }
          }
         
//          if (td.getOriginalClass().getIsNamedBy() != null)
            addImport(uniqueImports, longestImport, td.getPrimitiveType(), "DMO reference");         

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

      switch(ta.valueType){
      case SINGLE:
        break;
      case MULTI:
        addImport(uniqueImports, longestImport, "java.util.ArrayList", "To support getMVCopy()");
        break;
      case HASHMAPPED:
        if (useWrappedObjectRefs)
          addImport(uniqueImports, longestImport, "java.util.HashMap", "To support getMVCopy()");
        break;
      case TREEMAPPED:
        if (useWrappedObjectRefs)
          addImport(uniqueImports, longestImport, "java.util.TreeMap", "To support getMVCopy()");
        break;
      case HASHSET:
        addImport(uniqueImports, longestImport, "java.util.HashSet", "To support getMVCopy()");
        break;
      case TREESET:
        addImport(uniqueImports, longestImport, "java.util.TreeSet", "To support getMVCopy()");
        break;
      }
       
    }
   
    if (useWrappedObjectRefs){
      Iterator<TypeDefinition> t  = iterables.values().iterator();
      while(t.hasNext()){
        TypeDefinition td = t.next();
       
        addImport(uniqueImports, longestImport, td.getDmwIteratorImport(), "For multi-valued " + td.getName().getNameString());
       
        if (td.getPrimitiveType() != null)
          addImport(uniqueImports, longestImport, td.getPrimitiveType(), "For multi-valued contains" + td.getName().getNameString());
       
      }
    }
   
    if (cd.getClassType() == ClassTypeEnum.ABSTRACT){
View Full Code Here

    }
   
    Iterator<TypeDefinition> types = schema.getTypeDefList();
    if (types != null){
      while(types.hasNext()){
        TypeDefinition td = types.next();
        sb.append("    public static TypeDefinition _" + td.getName() + ";\n");
        allVars.add(new VarToObject("_" + td.getName(), td, "TypeDefinition"));
        typeVars.add(new VarToObject("_" + td.getName(), td, "TypeDefinition"));
      }
      sb.append("\n");
      allVars.add(new VarToObject("", null,null));
    }
   
    Iterator<ComplexTypeDefinition> complextypes = schema.getComplexTypeDefList();
    if (complextypes != null){
      while(complextypes.hasNext()){
        ComplexTypeDefinition td = complextypes.next();
        sb.append("    public static ComplexTypeDefinition _" + td.getName() + ";\n");
        allVars.add(new VarToObject("_" + td.getName(), td, "ComplexTypeDefinition"));
        complexTypeVars.add(new VarToObject("_" + td.getName(), td, "ComplexTypeDefinition"));
      }
      sb.append("\n");
      allVars.add(new VarToObject("", null,null));
    }
   
View Full Code Here

   
    sb.append("import org.dmd.dmc.DmcValueException;\n");
   
    Iterator<TypeDefinition> t = types.values().iterator();
    while(t.hasNext()){
      TypeDefinition td = t.next();
      if (td.getPrimitiveType() != null){
       
//        if (td.getName().equals("AdminGroup")){
//          DebugInfo.debug("type: " + td.getName());
//          DebugInfo.debug("primitive:         " + td.getPrimitiveType());
//          DebugInfo.debug("original.dmoclass: " + td.getOriginalClass().getDmoImport());
//        }
       
//        DebugInfo.debug("TYPE: " + td.getName());
        if (td.getIsRefType()){
//          if (td.getOriginalClass().getInternalTypeRef().getHelperClassName() == null){
//            // This isn't a named object
//            DebugInfo.debug("\n\n*** PROBABLY MISSING isNamedBy FQN on a hierarchic object: " + td.getName() + " ***\n\n");
//          }
          sb.append("import " + td.getOriginalClass().getInternalTypeRef().getHelperClassName() + ";\n");
        }
        else
          sb.append("import " + td.getPrimitiveType() + ";\n");
      }
     
//      sb.append("import " + td.getTypeClassName() + ";\n");
    }
   
View Full Code Here

       
        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){
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + 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){
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
        }
       
        allAttr.add(ad);
      }
    }
   
    if (cd.getIsNamedBy() != null){
      AttributeDefinition isNamedBy = cd.getIsNamedBy();
      String nameAttributeType = isNamedBy.getType().getPrimitiveType();
     
      addImport(uniqueImports, longestImport, nameAttributeType, "Is named by");
    }
       
//    addImport(uniqueImports, longestImport, "org.dmd.dms.*", "Always 2");
   
    if ( (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");
    }
   
    if (cd.getDmwWrapperType(genContext) == WrapperTypeEnum.EXTENDED){
      addImport(uniqueImports, longestImport, cd.getDmeImport(), "Required for getModificationRecorder()");
    }
     
    if (needDmwOmni)
      addImport(uniqueImports, longestImport, "org.dmd.dmw.DmwOmni", "Have DmcObjectName attributes");
   
    if (anyAttributes)
      addImport(uniqueImports, longestImport, "org.dmd.dmc.*", "If any attributes");
   
    for(String s: genericImports){
      addImport(uniqueImports, longestImport, s, "Generic args import");
    }

    for(TypeAndAttr ta : typeAndAttr.values()){
      TypeDefinition td = ta.td;
     
      if (td.getIsRefType()){
        // 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();
       
        addImport(uniqueImports, longestImport, td.getAuxHolderImport(), "Is reference type aux");
       
        // 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)
            addImport(uniqueImports, longestImport, td.getOriginalClass().getDmoImport(), "Reference to unnamed object");
          else
            addImport(uniqueImports, longestImport, td.getOriginalClass().getDmtREFImport(), "Is reference type REF");
        }
       
        if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
          addImport(uniqueImports, longestImport, ta.getImport(), "Reference in an auxiliary class");
        }
       
        if (td.getOriginalClass().getIsNamedBy() != null)
          addImport(uniqueImports, longestImport, td.getOriginalClass().getDmtREFImport(), "To support getMVCopy() for REFs");
       
      }
      else if (td.getPrimitiveType() != null){
        addImport(uniqueImports, longestImport, td.getPrimitiveType(), "Primitive type");
      }
      else if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
        addImport(uniqueImports, longestImport, ta.getImport(), "Type in an auxiliary class");
      }
     
      if (td.getAltType() != null){
        if (td.getAltTypeImport() != null)
          addImport(uniqueImports, longestImport, td.getAltTypeImport(), "Alternative type for " + td.getName() + " values");
      }
     
      if (td.getKeyImport() != null)
        addImport(uniqueImports, longestImport, td.getKeyImport(), "Key class");
     
      if (ta.valueType != ValueTypeEnum.SINGLE)
        addImport(uniqueImports, longestImport, "java.util.Iterator", "To support getMVCopy()");

      switch(ta.valueType){
      case SINGLE:
        break;
      case MULTI:
        addImport(uniqueImports, longestImport, "java.util.ArrayList", "To support getMVCopy()");
        break;
      case HASHMAPPED:
        addImport(uniqueImports, longestImport, "java.util.HashMap", "To support getMVCopy()");
        break;
      case TREEMAPPED:
        addImport(uniqueImports, longestImport, "java.util.TreeMap", "To support getMVCopy()");
        break;
      case HASHSET:
        addImport(uniqueImports, longestImport, "java.util.HashSet", "To support getMVCopy()");
        break;
      case TREESET:
        addImport(uniqueImports, longestImport, "java.util.TreeSet", "To support getMVCopy()");
        break;
      }
       
    }
   
    if (useWrappedObjectRefs){
      Iterator<TypeDefinition> t  = iterables.values().iterator();
      while(t.hasNext()){
        TypeDefinition td = t.next();
       
        addImport(uniqueImports, longestImport, td.getDmwIteratorImport(), "For multi-valued " + td.getName().getNameString());
       
        if (td.getPrimitiveType() != null)
          addImport(uniqueImports, longestImport, td.getPrimitiveType(), "For multi-valued contains" + td.getName().getNameString());
       
      }
    }
   
    if (cd.getClassType() == ClassTypeEnum.ABSTRACT){
View Full Code Here

    }
   
    if (useWrappedObjectRefs){
      Iterator<TypeDefinition>  tdefs = sd.getInternalTypeDefList();
      while(tdefs.hasNext()){
        TypeDefinition td = tdefs.next();
       
        ClassDefinition cd = td.getOriginalClass();
        if (cd != null){
          dumpIterable(config, loc, f, sm, cd, sd);
        }
      }
     
View Full Code Here

          out.write(fileHeader);
       
        String CAST = cd.getDmeClass();
        String REF   = ertd.getName().getNameString();
       
        TypeDefinition td = sm.tdef(ertd.getName().getNameString());
       
       
        out.write("package " + cd.getDMWPackage() + ".generated.dmw;\n\n");
       
        out.write("import java.util.Iterator;\n\n");
        out.write("import org.dmd.dmw.DmwContainerIterator;\n");
       
        out.write("import " + td.getPrimitiveType() + ";\n");
       
        if (cd.getUseWrapperType() == WrapperTypeEnum.EXTENDED){
            out.write("import " + cd.getDmeImport() + ";\n");
            CAST = cd.getDmeClass();
        }
        else{
            out.write("import " + cd.getDmwImport() + ";\n");
            CAST = cd.getDmwClass();
        }
         
        out.write("\n");
         
        out.write("/**\n");
        out.write(" * The " + ertd.getName().getNameString() + "IteratorDMW will cast from an underlying " + REF + " class to \n");
        out.write(" * the associated wrapper class: " + CAST + " when accessing object references in a wrapper context.\n");
        out.write(" * <P>\n");
        out.write(" * Generated from the " + td.getDefinedIn().getName() + " schema at version " + td.getDefinedIn().getVersion() + "\n");
        out.write(" * <P>\n");
        out.write(" * This code was auto-generated by the dmggenerator utility and shouldn't be altered manually!\n");
        out.write(" * Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write(" */\n");
       
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.