// Value: comment
TreeMap<String,String> uniqueImports = new TreeMap<String, String>();
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){
if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcObject", "Auxiliary class");
addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcAttributeInfo", "Auxiliary class");
}
else{
// addImport(uniqueImports, longestImport, "org.dmd.dms.generated.dmo.DmwWrapperDMO", "Structural class");
addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcObject", "Structural class");
}
}
else{
addImport(uniqueImports, longestImport, cd.getDerivedFrom().getDmoImport(), "Base class");
}
if (cd.getIsNamedBy() != null){
AttributeDefinition isNamedBy = cd.getIsNamedBy();
String nameAttributeType = isNamedBy.getType().getPrimitiveType();
if (nameAttributeType == null){
ResultException ex = new ResultException("Naming attribute for class " + cd.getName() + " must be a complex type.");
ex.result.lastResult().moreMessages("Check the type of attribute " + isNamedBy.getName().getNameString());
ex.result.lastResult().fileName(isNamedBy.getFile());
ex.result.lastResult().lineNumber(isNamedBy.getLineNumber());
throw(ex);
}
addImport(uniqueImports, longestImport, nameAttributeType, "Naming attribute type");
if (isNamedBy.getType().getIsHierarchicName())
addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcHierarchicNamedObjectIF", "Named object");
addImport(uniqueImports, longestImport, "org.dmd.dmc.DmcNamedObjectIF", "Named object");
}
}