super(dmo);
}
@Override
public void execute(DmcObject obj) throws DmcRuleExceptionSet {
DmcRuleExceptionSet exceptions = null;
// Cycle through the attribute definitions associated with the object
// and verify that any that are NOT optional, exist in the object.
Map<Integer,DmcAttributeInfoRef> mai = obj.getConstructionClassInfo().getIdToAttr();
if (mai != null){
Iterator<DmcAttributeInfoRef> it = mai.values().iterator();
while(it.hasNext()){
DmcAttributeInfoRef air = it.next();
if (air.mandatory){
if (obj.get(air.info.id) == null){
if (exceptions == null)
exceptions = new DmcRuleExceptionSet();
exceptions.add(new DmcRuleException("Mandatory attribute is missing: " + air.info.name, this));
}
}
}
}
// And now, cycle through the attributes of the object and verify that
// they are allowed - if the class isn't extensible
if (obj.getConstructionClassInfo().classType != ClassTypeEnum.EXTENSIBLE){
Iterator<DmcAttribute<?>> attrs = obj.getAttributes().values().iterator();
while(attrs.hasNext()){
DmcAttribute<?> attr = attrs.next();
if (!obj.allowsAttribute(attr.getAttributeInfo())){
if (exceptions == null)
exceptions = new DmcRuleExceptionSet();
exceptions.add(new DmcRuleException("Attribute: " + attr.getName() + " is not valid for an object of class: " + obj.getConstructionClassName(), this));
}
}
}
if (exceptions != null)