// Again, some trickiness, we have to resolve the rule so that we can access and use the must/may
// attributes that are defined for it and add them to the class definition we create
try {
rd.resolveReferences(this);
} catch (DmcValueExceptionSet e) {
ResultException ex = new ResultException();
ex.addError("Unresolved references in RuleDefinition: " + rd.getName());
for(DmcValueException dve : e.getExceptions()){
ex.moreMessages(dve.getMessage());
}
throw(ex);
}
StringName ruleClassName = new StringName(rd.getName().getNameString() + "Data");
if (checkAndAdd(rd.getObjectName(),rd,ruleDefs) == false){
ResultException ex = new ResultException();
ex.addError(clashMsg(rd.getObjectName(),rd,ruleDefs,"rule definitions"));
throw(ex);
}
if (checkAndAdd(rd.getObjectName(),rd,allDefs) == false){
ResultException ex = new ResultException();
ex.addError(clashMsg(rd.getObjectName(),rd,allDefs,"definition names"));
throw(ex);
}
if (performIDChecks){
// Bump up the DMD ID by the amount of schemaBaseID
int base = rd.getDefinedIn().getSchemaBaseID();
int range = rd.getDefinedIn().getSchemaIDRange();
int current = rd.getDmdID();
if (current >= range){
ResultException ex = new ResultException("Number of rules exceeds schema ID range: " + rd.getName());
throw(ex);
}
rd.setDmdID(base + current);
}
ClassDefinition existing = classDefs.get(ruleClassName);
if (existing != null){
// We have the class for this rule, just check that it's auto generated
if (existing.getInternallyGenerated()){
return;
}
else{
// We have some kind of clash
}
}
// We check that the ID of the rule doesn't clash with the class definitions, since we're
// going to create a class for this rule with the rule's ID.
if (classesByID.get(rd.getDmdID()) != null){
ResultException ex = new ResultException();
ex.addError(clashMsg(rd.getDmdID(),rd,classesByID,"dmdID"));
throw(ex);
}
///////////////////////////////////////////////////////////////////////