}
void dumpHeaderDMSAG(BufferedWriter out, SchemaManager sm, String schemaPackage, SchemaDefinition sd, StringBuffer nameBuilders, StringBuffer filterBuilders) throws IOException, ResultException {
out.write("package " + schemaPackage + ".generated.dmo;\n\n");
ImportManager manager = new ImportManager();
manager.addImport("java.util.HashMap","For storage of schema info");
manager.addImport("java.util.ArrayList","For storage of schema info");
manager.addImport("java.util.Iterator","For access of schema info");
manager.addImport("org.dmd.dmc.*","Basic DMC stuff");
manager.addImport("org.dmd.dmc.rules.RuleIF","For rule info");
DmcAttribute<?> cdef = sd.getDMO().get(MetaDMSAG.__classDefList);
if (cdef != null){
manager.addImport("org.dmd.dms.generated.enums.ClassTypeEnum", "Have class definitions");
manager.addImport("org.dmd.dms.generated.enums.DataTypeEnum", "Have class/attribute definitions");
// out.write("import org.dmd.dms.generated.enums.ClassTypeEnum;\n");
}
if ( (sd.getTypeDefListSize() > 0) || (sd.getInternalTypeDefListSize() > 0)){
manager.addImport("org.dmd.dms.generated.enums.OriginalTypeEnum", "Have type/internal type definitions");
}
for(ClassDefinition cd: sd.getClassDefList()){
for(AttributeDefinition ad: cd.getMust()){
if (ad.getDefinedIn() != sd)
manager.addImport(ad.getDefinedIn().getDMSASGImport(), "Required attribute from " + ad.getDefinedIn().getDMSASGName());
}
for(AttributeDefinition ad: cd.getMay()){
if (ad.getDefinedIn() != sd)
manager.addImport(ad.getDefinedIn().getDMSASGImport(), "Optional attribute from " + ad.getDefinedIn().getDMSASGName());
}
if (cd.getDerivedFrom() != null){
if (cd.getDerivedFrom().getDefinedIn() != sd)
manager.addImport(cd.getDerivedFrom().getDefinedIn().getDMSASGImport(), "Base class from " + cd.getDerivedFrom().getDefinedIn().getDMSASGName());
}
}
DmcAttribute<?> adef = sd.getDMO().get(MetaDMSAG.__attributeDefList);
if (adef != null){
manager.addImport("org.dmd.dms.generated.enums.DataTypeEnum", "Have class/attribute definitions");
manager.addImport("org.dmd.dms.generated.enums.ValueTypeEnum", "Have attribute definitions");
// out.write("import org.dmd.dms.generated.enums.ValueTypeEnum;\n");
// out.write("import org.dmd.dms.generated.enums.DataTypeEnum;\n");
}
///////////////////////////////////////////////////////////////////////
// Rule definitions
for(RuleDefinition rd: sd.getRuleDefinitionList()){
manager.addImport(rd.getRuleDefinitionImport(), "To support instantiations of " + rd.getName());
}
///////////////////////////////////////////////////////////////////////
// Rule instances
Iterator<DmcUncheckedObject> rules = sd.getParsedRules();
if (rules != null){
while(rules.hasNext()){
DmcUncheckedObject rule = rules.next();
ClassDefinition ruleDataCD = sm.isClass(rule.getConstructionClass());
if (ruleDataCD == null){
ResultException ex = new ResultException();
ex.addError("Unknown rule data class. For Rule instance: \n" + rule.toOIF());
throw(ex);
}
manager.addImport(ruleDataCD.getDmoImport(), "To instantiate " + rule.getConstructionClass() + " rule data");
manager.addImport(ruleDataCD.getRuleDefinition().getRuleDefinitionImport(), "To instantiate rules of this type");
ruleDataCD.addImportsForAdditionalAttributes(sm,manager, rule);
}
}
out.write(manager.getFormattedImports());
out.write("\n");
Iterator<TypeDefinition> tds = sd.getTypeDefList();
if (tds != null){