Skip to content

Commit

Permalink
Issue #97 CCB-204 Validate that LDD attributes named "type" or with n…
Browse files Browse the repository at this point in the history
…ames ending in "_type" have permissible value lists.

Validate that LDD attributes named "type" or with names ending in "_type" have permissible value lists. Part 1 of CCB-204.

Use command line argument "D" for writing the Data Dictionary DocBook file.
  • Loading branch information
jshughes committed Dec 4, 2019
1 parent a3dac0e commit f4df3ab
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public class DMDocument extends Object {
static boolean LDDNuanceFlag = false; //

// import export file flags
static boolean exportProdDefnFlag = true;
static boolean exportJSONFileFlag = false; // LDDTool, set by -J option
static boolean exportSpecFileFlag = false;
static boolean exportDDFileFlag = false;
Expand Down Expand Up @@ -590,17 +589,14 @@ static private void getCommandArgs (String args[]) {
System.exit(0);
}
if (lArg.indexOf('D') > -1) {
exportProdDefnFlag = false;
exportDDFileFlag = true;
}
if (lArg.indexOf('J') > -1) {
exportJSONFileFlag = true;
}
if (lArg.indexOf('1') > -1) {
exportSpecFileFlag = true;
}
if (lArg.indexOf('2') > -1) {
exportDDFileFlag = true;
}
if (lArg.indexOf('3') > -1) {
exportJSONAttrFlag = true;
}
Expand Down Expand Up @@ -734,7 +730,7 @@ static public void printHelp () {
System.out.println(" -p, --PDS4 Set the context to PDS4");
System.out.println(" -l, --LDD Process a local data dictionary input file");
System.out.println(" -a, --attribute Write definitions for attribute elements.");
// System.out.println(" -c, --class Write definitions for class elements.");
System.out.println(" -D, --DataDict Write the Data Dictionary DocBook file.");
System.out.println(" -J, --JSON Write the master data dictionary to a JSON formatted file.");
System.out.println(" -m, --merge Generate file to merge the local dictionary into the master dictionary");
System.out.println(" -M, --Mission Indicates mission level governance (includes msn directory specification)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ private void parseDocument(SchemaFileDefn lSchemaFileDefn){

validateNoDuplicateNames ();
if (DMDocument.debugFlag) System.out.println("debug parseDocument.validateNoDuplicateNames() Done");

validateTypeAttributes ();
if (DMDocument.debugFlag) System.out.println("debug parseDocument.validateTypeAttributes() Done");
}

private void printClassDebug (String lLable, String lIdentifier) {
Expand Down Expand Up @@ -1530,8 +1533,6 @@ private void validateAttributeUsed () {
}

private void validateNoDuplicateNames () {
// System.out.println("\ndebug validateNoDuplicateNames");

// get a list for names
ArrayList <String> lNameArr = new ArrayList <String> ();

Expand All @@ -1556,7 +1557,25 @@ private void validateNoDuplicateNames () {
}
return;
}


private void validateTypeAttributes () {
// scan for attribute names containing "type"
for (Iterator <DOMAttr> i = attrArr.iterator(); i.hasNext();) {
DOMAttr lDOMAttr = (DOMAttr) i.next();
int lTypeOffset = lDOMAttr.title.length();
lTypeOffset = lTypeOffset - 4;
if (lDOMAttr.title.indexOf("type") == lTypeOffset) {
if (lDOMAttr.domPermValueArr.size() < 1) {
if (DMDocument.LDDToolMissionGovernanceFlag)
lddErrorMsg.add(" WARNING Attribute: <" + lDOMAttr.title + "> - The 'type' attribute must have at least one permissible value.");
else
lddErrorMsg.add(" ERROR Attribute: <" + lDOMAttr.title + "> - The 'type' attribute must have at least one permissible value.");
}
}
}
return;
}

private ArrayList <Element> getAssocElemFromClassDefn (Element elem) {
ArrayList <Element> lAssocElemArr = new ArrayList <Element> ();
Node assocElement = elem.getFirstChild();
Expand Down Expand Up @@ -1751,34 +1770,6 @@ public void OverwriteFrom11179DataDict () {
}
}

public void OverwriteFrom11179DataDictxxx () {
// iterate through the LDD attribute array
for (Iterator<DOMAttr> i = attrArr.iterator(); i.hasNext();) {
DOMAttr lDOMAttr = (DOMAttr) i.next();

System.out.println("\ndebug LDDDOMParser.OverwriteFrom11179DataDict - Before - lDOMAttr.identifier:" + lDOMAttr.identifier);
System.out.println(" LDDDOMParser.OverwriteFrom11179DataDict - Before - lDOMAttr.valueType:" + lDOMAttr.valueType);


DOMAttr lLDDUserAttribute = lDOMAttr.lddUserAttribute;
if (lLDDUserAttribute == null) continue;
lDOMAttr.isNilable = lLDDUserAttribute.isNilable;
lDOMAttr.valueType = lLDDUserAttribute.valueType;
lDOMAttr.minimum_value = lLDDUserAttribute.minimum_value;
lDOMAttr.maximum_value = lLDDUserAttribute.maximum_value;
lDOMAttr.minimum_characters = lLDDUserAttribute.minimum_characters;
lDOMAttr.maximum_characters = lLDDUserAttribute.maximum_characters;
lDOMAttr.pattern = lLDDUserAttribute.pattern;
lDOMAttr.unit_of_measure_type = lLDDUserAttribute.unit_of_measure_type;
lDOMAttr.default_unit_id = lLDDUserAttribute.default_unit_id;
lDOMAttr.valArr = lLDDUserAttribute.valArr;
lDOMAttr.permValueArr = lLDDUserAttribute.permValueArr;
System.out.println(" LDDDOMParser.OverwriteFrom11179DataDict - After - lDOMAttr.identifier:" + lDOMAttr.identifier);
System.out.println(" LDDDOMParser.OverwriteFrom11179DataDict - After - lDOMAttr.valueType:" + lDOMAttr.valueType);
}
}


private int getIntValue(Element ele, String tagName) {
//in production application you would catch the exception
return Integer.parseInt(getTextValue(ele,tagName));
Expand Down

0 comments on commit f4df3ab

Please sign in to comment.