Package org.dmd.dms.util

Examples of org.dmd.dms.util.TypeAndAttr


          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");
View Full Code Here


          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");
View Full Code Here

          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");
View Full Code Here

        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");
View Full Code Here

TOP

Related Classes of org.dmd.dms.util.TypeAndAttr

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.