Skip to content

Commit

Permalink
Bugfix for validate that there are no nested Exposed classes
Browse files Browse the repository at this point in the history
Validate code falsely assumed that all subclasses had been identified at this point in the processing. Algorithm was changed to follow the "component_of" chain.

Resolves #142
Refs CCB-204
  • Loading branch information
jshughes committed Mar 12, 2020
1 parent 8de20d0 commit f7d973f
Showing 1 changed file with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1687,33 +1687,30 @@ private void validateNilRequiredAttributes () {
}

private void validateNoNestedExposedClasses () {
// first find an exposed classe
// first find an exposed class
for (Iterator <DOMClass> i = DOMInfoModel.masterDOMClassArr.iterator(); i.hasNext();) {
DOMClass lClass = (DOMClass) i.next();
if (lClass.isExposed) {
// check all component classes
ArrayList <DOMProp> allAssocArr = new ArrayList <DOMProp> ();
allAssocArr.addAll(lClass.ownedAssocArr);
allAssocArr.addAll(lClass.inheritedAssocArr);
for (Iterator <DOMProp> j = allAssocArr.iterator(); j.hasNext();) {
DOMProp lDOMProp = j.next();
if (lDOMProp.hasDOMObject != null && lDOMProp.hasDOMObject instanceof DOMClass) {
DOMClass lCompClass = (DOMClass) lDOMProp.hasDOMObject;
if (lCompClass.isExposed) {
lddErrorMsg.add(" ERROR Class: <" + lClass.title + "> - <" + lCompClass.title + "> - Exposed classes cannot be nested (component_of).");
}
}
}

// check all super classes
DOMClass lSubClass = lClass;
while (lSubClass.subClassOf != null) {
DOMClass lSuperClass = lSubClass.subClassOf;
if (lSuperClass.isExposed) {
lddErrorMsg.add(" ERROR Class: <" + lClass.title + "> - <" + lSuperClass.title + "> - Exposed classes cannot be nested (parent_of).");
}
lSubClass = lSuperClass;
checkAllSubclasses (lClass);
}
}
return;
}

private void checkAllSubclasses (DOMClass lClass) {
// check all component classes
ArrayList <DOMProp> allAssocArr = new ArrayList <DOMProp> ();
allAssocArr.addAll(lClass.ownedAssocArr);
allAssocArr.addAll(lClass.inheritedAssocArr);
for (Iterator <DOMProp> j = allAssocArr.iterator(); j.hasNext();) {
DOMProp lDOMProp = j.next();
if (lDOMProp.hasDOMObject != null && lDOMProp.hasDOMObject instanceof DOMClass) {
DOMClass lCompClass = (DOMClass) lDOMProp.hasDOMObject;
if (lCompClass.isExposed) {
lddErrorMsg.add(" ERROR Class: <" + lCompClass.title + "> - An exposed class cannot be nested within another exposed class.");
}
checkAllSubclasses (lCompClass);
}
}
return;
Expand Down

0 comments on commit f7d973f

Please sign in to comment.