dumpHeaderDMSAG(out, sm, sd.getSchemaPackage(), sd, nameBuilders, filterBuilders);
Iterator<ClassDefinition> cds = sd.getClassDefList();
if (cds != null){
while(cds.hasNext()){
ClassDefinition cd = cds.next();
classes.put(cd.getName().getNameString(), cd);
}
}
Iterator<AttributeDefinition> ads = sd.getAttributeDefList();
if (ads != null){
while(ads.hasNext()){
AttributeDefinition ad = ads.next();
attributes.put(ad.getName().getNameString(), ad);
}
}
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());
}
}
if (classes.size() > 0){
out.write("\n");
out.write(" // Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
TreeMap<String,ClassNode> hierarchy = getHierarchy(classes.values().iterator());
for(ClassNode cn: hierarchy.values()){
cn.writeClassInfo(out);
}
}
///////////////////////////////////////////////////////////////////////
if (sd.getSliceDefListSize() > 0){
out.write("\n");
out.write(" // Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
for(SliceDefinition slice: sd.getSliceDefList()){
out.write(" public final static DmcSliceInfo __" + slice.getName() + " = new DmcSliceInfo(\"" + slice.getName() + "\");\n");
for(AttributeDefinition ad: slice.getSelectAttribute()){
out.write(" // " + ad.getName() + "\n");
}
out.write("\n");
}
}
// DmoObjectFactoryNew factory = new DmoObjectFactoryNew(sm);
///////////////////////////////////////////////////////////////////////
Iterator<DmcUncheckedObject> rules = sd.getParsedRules();
if (rules != null){
out.write("\n");
out.write(" // Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
while(rules.hasNext()){
DmcUncheckedObject ruleData = rules.next();
// try {
// RuleDataDMO rdd = (RuleDataDMO) factory.createObject(ruleData);
// DebugInfo.debugWithTrace(rdd.toOIF());
// } catch (DmcValueException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
String dataName = ruleData.getConstructionClass();
int dataPos = dataName.indexOf("Data");
String ruleClass = dataName.substring(0, dataPos);
String ruleName = ruleData.getSV("ruleName");
out.write(" public final static " + ruleClass + " __" + ruleName + ";\n");
}
}
///////////////////////////////////////////////////////////////////////
// Static initializer
writeCommonPart1(out);
// Inside the static initializer
for(AttributeDefinition ad: attributes.values()){
// _SmAp.put(__jobName.name,__jobName);
out.write(" _SmAp.put(__" + ad.getName().getNameString() + ".id,__" + ad.getName().getNameString() + ");\n");
}
for(ClassDefinition cd: classes.values()){
// _SmAp.put(__jobName.name,__jobName);
out.write(" _CmAp.put(__" + cd.getName().getNameString() + ".id,__" + cd.getName().getNameString() + ");\n");
}
out.write(nameBuilders.toString());
for(SliceDefinition slice: sd.getSliceDefList()){
out.write("\n");
// _SmAp.put(__jobName.name,__jobName);
for(AttributeDefinition ad: slice.getSelectAttribute()){
out.write(" __" + slice.getName().getNameString() + ".addAttributeID(" + ad.getDmdID() + ");\n");
}
out.write(" _SImAp.put(\"" + slice.getName() + "\",__" + slice.getName().getNameString() + ");\n");
}
cds = sd.getClassDefList();
if (cds != null){
while(cds.hasNext()){
out.write("\n");
ClassDefinition cd = cds.next();
String attr = null;
for (AttributeDefinition ad: cd.getMust()){
if (ad.getDefinedIn() == cd.getDefinedIn())
attr = "__" + ad.getName();
else
attr = ad.getDefinedIn().getDMSASGName() + ".__" + ad.getName();
out.write(" __" + cd.getName() + ".addMust(" + attr + ");\n");
}
for (AttributeDefinition ad: cd.getMay()){
if (ad.getDefinedIn() == cd.getDefinedIn())
attr = "__" + ad.getName();
else
attr = ad.getDefinedIn().getDMSASGName() + ".__" + ad.getName();
out.write(" __" + cd.getName() + ".addMay(" + attr + ");\n");
}
}
out.write("\n");