diff --git a/model-dmdocument/pom.xml b/model-dmdocument/pom.xml
index d4fe01bb..ecff0e81 100644
--- a/model-dmdocument/pom.xml
+++ b/model-dmdocument/pom.xml
@@ -212,6 +212,11 @@
argparse4j
0.9.0
+
+ commons-io
+ commons-io
+ 2.16.1
+
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/AbstractGenerationPlugin.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/AbstractGenerationPlugin.java
index 26503a4e..81d85b11 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/AbstractGenerationPlugin.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/AbstractGenerationPlugin.java
@@ -1,40 +1,6 @@
-// Copyright 2019, California Institute of Technology ("Caltech").
-// U.S. Government sponsorship acknowledged.
-//
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// * Redistributions must reproduce the above copyright notice, this list of
-// conditions and the following disclaimer in the documentation and/or other
-// materials provided with the distribution.
-// * Neither the name of Caltech nor its operating division, the Jet Propulsion
-// Laboratory, nor the names of its contributors may be used to endorse or
-// promote products derived from this software without specific prior written
-// permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-
package gov.nasa.pds.model.plugin;
import java.io.File;
-import java.lang.reflect.Field;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Parameter;
@@ -67,7 +33,6 @@ public void execute() throws MojoExecutionException {
getLog().info("Writing artifacts from those sources to ‘" + this.target + "’");
File d = new File(this.target);
d.mkdirs();
- DMDocument.outputDirPath = d.toString() + "/";
this.generateArtifacts();
} catch (RuntimeException ex) {
throw ex;
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DMDocument.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DMDocument.java
index a98cb4ea..01914216 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DMDocument.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DMDocument.java
@@ -44,10 +44,9 @@
import java.util.Set;
import java.util.TimeZone;
import java.util.TreeMap;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+import gov.nasa.pds.model.plugin.util.Utility;
import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.helper.HelpScreenException;
import net.sourceforge.argparse4j.impl.Arguments;
@@ -95,7 +94,7 @@ public class DMDocument extends Object {
static String ddDocTeam = "TBD_ddDocTeam";
static String dataDirPath = "TBD_dataDirPath";
- static String outputDirPath = "./";
+ private static String outputDirPath = "./";
static String DMDocVersionId = "0.0.0";
// static String XMLSchemaLabelBuildNum = "6a";
@@ -302,7 +301,7 @@ public class DMDocument extends Object {
// info, warning, and error messages
static int msgOrder = 100000;
- static ArrayList mainMsgArr = new ArrayList<>();
+ public static ArrayList mainMsgArr = new ArrayList<>();
static DOMMsgDefn masterDOMMsgDefn = new DOMMsgDefn();
static TreeMap messageLevelCountMap = new TreeMap<>();
static Integer lMessageWarningCount = 0;
@@ -366,10 +365,10 @@ public static void run(String[] args) throws Throwable {
}
}
} else {
- registerMessage("0>info - Property data.home is null");
+ Utility.registerMessage("0>info - Property data.home is null");
String sysUserDir = System.getProperty("user.dir");
if (sysUserDir == null) {
- registerMessage("3>error Environment variable sysUserDir is null");
+ Utility.registerMessage("3>error Environment variable sysUserDir is null");
printErrorMessages();
System.exit(1);
}
@@ -390,9 +389,9 @@ public static void run(String[] args) throws Throwable {
}
}
}
- registerMessage("0>info - Parent Directory:" + parentDir);
- registerMessage("0>info - IM Directory Path:" + dataDirPath);
- registerMessage("0>info - IM Versions Available:" + alternateIMVersionArr);
+ Utility.registerMessage("0>info - Parent Directory:" + parentDir);
+ Utility.registerMessage("0>info - IM Directory Path:" + dataDirPath);
+ Utility.registerMessage("0>info - IM Versions Available:" + alternateIMVersionArr);
// read the configuration file and initialize key attributes; SchemaFileDefn map is initialized
// below (setupNameSpaceInfoAll)
@@ -466,10 +465,10 @@ public static void run(String[] args) throws Throwable {
}
} catch (FileNotFoundException ex) {
// file does not exist
- registerMessage("3>error Configuration file does not exist. [config.properties]");
+ Utility.registerMessage("3>error Configuration file does not exist. [config.properties]");
} catch (IOException ex) {
// I/O error
- registerMessage("3>error Configuration file IO Exception. [config.properties]");
+ Utility.registerMessage("3>error Configuration file IO Exception. [config.properties]");
} finally {
try {
reader.close();
@@ -501,21 +500,21 @@ public static void run(String[] args) throws Throwable {
// output the context info
if (!LDDToolFlag) {
- registerMessage("1>info DMDoc Version: " + DMDocVersionId);
- registerMessage("1>info IM Version Id: " + DMDocument.masterPDSSchemaFileDefn.versionId);
- registerMessage("1>info IM Namespace Id: " + DMDocument.masterPDSSchemaFileDefn.identifier);
- registerMessage(
+ Utility.registerMessage("1>info DMDoc Version: " + DMDocVersionId);
+ Utility.registerMessage("1>info IM Version Id: " + DMDocument.masterPDSSchemaFileDefn.versionId);
+ Utility.registerMessage("1>info IM Namespace Id: " + DMDocument.masterPDSSchemaFileDefn.identifier);
+ Utility.registerMessage(
"1>info IM Label Version Id: " + DMDocument.masterPDSSchemaFileDefn.labelVersionId);
} else {
- registerMessage("1>info LDDTOOL Version: " + LDDToolVersionId);
- registerMessage("1>info IM Version Id: " + DMDocument.masterPDSSchemaFileDefn.versionId);
- registerMessage("1>info IM Namespace Id: " + DMDocument.masterPDSSchemaFileDefn.identifier);
- registerMessage(
+ Utility.registerMessage("1>info LDDTOOL Version: " + LDDToolVersionId);
+ Utility.registerMessage("1>info IM Version Id: " + DMDocument.masterPDSSchemaFileDefn.versionId);
+ Utility.registerMessage("1>info IM Namespace Id: " + DMDocument.masterPDSSchemaFileDefn.identifier);
+ Utility.registerMessage(
"1>info IM Label Version Id: " + DMDocument.masterPDSSchemaFileDefn.labelVersionId);
}
- registerMessage("1>info Date: " + sTodaysDate);
- registerMessage("1>info PARENT_DIR: " + parentDir);
+ Utility.registerMessage("1>info Date: " + sTodaysDate);
+ Utility.registerMessage("1>info PARENT_DIR: " + parentDir);
// get the 11179 Attribute Dictionary - .pins file
ProtPinsDOM11179DD lProtPinsDOM11179DD = new ProtPinsDOM11179DD();
@@ -544,7 +543,7 @@ public static void run(String[] args) throws Throwable {
ExportModels lExportModels = new ExportModels();
lExportModels.writeAllArtifacts();
}
- registerMessage("0>info Next UID: " + DOMInfoModel.getNextUId());
+ Utility.registerMessage("0>info Next UID: " + DOMInfoModel.getNextUId());
printErrorMessages();
reset();
@@ -552,9 +551,11 @@ public static void run(String[] args) throws Throwable {
/**********************************************************************************************************
* local utilities
+ *
+ * @throws IOException
***********************************************************************************************************/
- static private void cleanupLDDInputFileName(SchemaFileDefn lSchemaFileDefn) {
+ static private void cleanupLDDInputFileName(SchemaFileDefn lSchemaFileDefn) throws IOException {
String lSourceFileSpec = lSchemaFileDefn.sourceFileName;
lSourceFileSpec = replaceString(lSourceFileSpec, "\\", "/");
// String lSourceFileSpecToLower = lSourceFileSpec.toLowerCase();
@@ -563,84 +564,62 @@ static private void cleanupLDDInputFileName(SchemaFileDefn lSchemaFileDefn) {
lSchemaFileDefn.LDDToolOutputFileNameNE = null; // *** deprecate ***
- if (!checkFileName(lSchemaFileDefn.LDDToolInputFileName)) {
+ if (!Utility.checkFileName(lSchemaFileDefn.LDDToolInputFileName)) {
lSchemaFileDefn.LDDToolInputFileName = lSchemaFileDefn.LDDToolInputFileName.toLowerCase();
- if (!checkFileName(lSchemaFileDefn.LDDToolInputFileName)) {
+ if (!Utility.checkFileName(lSchemaFileDefn.LDDToolInputFileName)) {
lSchemaFileDefn.LDDToolInputFileName = lSchemaFileDefn.LDDToolInputFileName.toUpperCase();
- if (!checkFileName(lSchemaFileDefn.LDDToolInputFileName)) {
- registerMessage("3>error " + "Input file not found: " + lSchemaFileDefn.sourceFileName);
+ if (!Utility.checkFileName(lSchemaFileDefn.LDDToolInputFileName)) {
+ String msg = "Input file not found: " + lSchemaFileDefn.sourceFileName;
+ Utility.registerMessage("3>error " + msg);
parser.printHelp();
printErrorMessages();
- System.exit(1);
+ throw new IOException(msg);
}
}
}
}
- static public boolean checkCreateDirectory(String lDirectoryPathName) {
- File file = new File(lDirectoryPathName);
- if (file.exists() && file.isDirectory()) {
- registerMessage("0>info Found directory: " + lDirectoryPathName);
- return true;
- }
- // Create the directory
- boolean bool = file.mkdir();
- if (bool) {
- registerMessage("0>info Created directory: " + lDirectoryPathName);
- return true;
- } else {
- registerMessage("1>error Directory create failed: " + lDirectoryPathName);
- }
- return false;
- }
-
- static public boolean checkFileName(String inputFileName) {
- File file = new File(inputFileName);
- if (file.exists() && (file.isFile())) {
- registerMessage("0>info Found input file: " + inputFileName);
- return true;
- }
- registerMessage("1>error " + "Input file not found: " + inputFileName);
- return false;
- }
-
- static public void checkRequiredFiles() {
+ static public void checkRequiredFiles() throws IOException {
// check that all the required data files exist
File file = new File(dataDirPath + "UpperModel.pont");
boolean isFound = file.exists();
+ String msg = "";
if (!isFound) {
- registerMessage(
- "3>error " + "Required data file was not found: " + dataDirPath + "UpperModel.pont");
+ msg = "Required data file was not found: " + dataDirPath + "UpperModel.pont";
+ Utility.registerMessage("3>error " + msg);
printErrorMessages();
- System.exit(1);
+ throw new IOException(msg);
}
file = new File(dataDirPath + "dd11179.pins");
isFound = file.exists();
if (!isFound) {
- registerMessage(
- "3>error " + "Required data file was not found: " + dataDirPath + "dd11179.pins");
+ msg = "Required data file was not found: " + dataDirPath + "dd11179.pins";
+ Utility.registerMessage(
+ "3>error " + msg);
printErrorMessages();
- System.exit(1);
+ throw new IOException(msg);
}
file = new File(dataDirPath + "Glossary.pins");
isFound = file.exists();
if (!isFound) {
- registerMessage(
- "3>error " + "Required data file was not found: " + dataDirPath + "Glossary.pins");
+ msg = "Required data file was not found: " + dataDirPath + "Glossary.pins";
+ Utility.registerMessage(
+ "3>error " + msg);
printErrorMessages();
- System.exit(1);
+ throw new IOException(msg);
}
file = new File(dataDirPath + "DMDocument.pins");
isFound = file.exists();
if (!isFound) {
- registerMessage(
- "3>error " + "Required data file was not found: " + dataDirPath + "DMDocument.pins");
+ msg = "Required data file was not found: " + dataDirPath + "DMDocument.pins";
+ Utility.registerMessage(
+ "3>error " + msg);
printErrorMessages();
- System.exit(1);
+ throw new IOException(msg);
}
}
@@ -657,7 +636,6 @@ static private void init() {
ddDocTeam = "TBD_ddDocTeam";
dataDirPath = "TBD_dataDirPath";
- outputDirPath = "./";
DMDocVersionId = "0.0.0";
@@ -866,7 +844,7 @@ static void setupNameSpaceInfoAll(Properties prop) {
lSchemaFileDefn.setDictionaryType("Common");
}
} else {
- registerMessage("3>error Missing schema config item: " + isMasterKey);
+ Utility.registerMessage("3>error Missing schema config item: " + isMasterKey);
}
// default to the master values
@@ -901,7 +879,7 @@ static void setupNameSpaceInfoAll(Properties prop) {
lSchemaFileDefn.stewardArr.add(element);
}
} else {
- registerMessage("3>error Missing schema config item: " + stewardArrKey);
+ Utility.registerMessage("3>error Missing schema config item: " + stewardArrKey);
}
String commentKey = SCHEMA_LITERAL + nameSpaceId + ".comment";
@@ -981,7 +959,7 @@ static void setupNameSpaceInfoAll(Properties prop) {
}
if (printNamespaceFlag || debugFlag) {
- registerMessage("1>info Configured NameSpaceIds:" + lNamespaceIdArr);
+ Utility.registerMessage("1>info Configured NameSpaceIds:" + lNamespaceIdArr);
}
}
@@ -1135,20 +1113,7 @@ static void setRegistryAttrFlag() {
registryAttr.add("version_id");
}
- static void registerMessage(String lMessage) {
- DOMMsgDefn lMessageDefn = new DOMMsgDefn(lMessage);
- mainMsgArr.add(lMessageDefn);
- return;
- }
-
- static void registerMessage(String lNameSpaceIdNCLC, String lMessage) {
- DOMMsgDefn lMessageDefn = new DOMMsgDefn(lMessage);
- lMessageDefn.nameSpaceIdNCLC = lNameSpaceIdNCLC;
- mainMsgArr.add(lMessageDefn);
- return;
- }
-
- static Namespace getArgumentParserNamespace(String args[]) {
+ static Namespace getArgumentParserNamespace(String args[]) throws ArgumentParserException {
parser = ArgumentParsers.newFor("LDDTool").build().defaultHelp(true).version(LDDToolVersionId)
.description("LDDTool process control:");
@@ -1159,11 +1124,6 @@ static Namespace getArgumentParserNamespace(String args[]) {
.action(Arguments.storeTrue())
.help("Process one or more local data dictionary input files");
- /*
- * parser.addArgument("-map", "--map") .dest("map") .type(Boolean.class) .nargs(1)
- * .action(Arguments.storeTrue()) .setDefault("false") .help("Map Tool Processing");
- */
-
parser.addArgument("-d", "--discipline").dest("d").type(Boolean.class).nargs(1)
.action(Arguments.storeTrue())
.help("Omit the term \"mission\" from the namespace of a dictionary");
@@ -1238,16 +1198,13 @@ static Namespace getArgumentParserNamespace(String args[]) {
namespace = parser.parseArgs(args);
} catch (HelpScreenException e) {
System.out.println(">> INFO Exit(0)");
- // parser.handleError(e);
- // e.printStackTrace();
- System.exit(0);
+ parser.printHelp();
+ throw e;
} catch (ArgumentParserException e) {
System.out.println(">> ERROR Invalid argument list");
parser.printHelp();
System.out.println(">> INFO Exit(1)");
- // parser.handleError(e);
- // e.printStackTrace();
- System.exit(1);
+ throw e;
}
return namespace;
}
@@ -1293,31 +1250,23 @@ static void processArgumentParserNamespacePhase2(Namespace ns) {
System.out.println("Build Date: " + buildDate);
System.out.println("Configured IM Versions: " + alternateIMVersionArr);
System.out.println(" ");
- System.exit(0);
+ return;
}
// validate the input arguments
if (!PDSOptionalFlag) {
- registerMessage("3>error " + "The -p option must be used for PDS4 processing");
+ String msg = "The -p option must be used for PDS4 processing";
+ Utility.registerMessage("3>error " + msg);
parser.printHelp();
System.out.println(">> INFO Exit(1)");
- System.exit(1);
+ throw new IllegalArgumentException(msg);
}
- /*
- * String mapFlag = ns.getBoolean("map"); if (mapFlag) { registerMessage
- * ("1>info Tool processing"); dmProcessState.setmapToolFlag (); LDDToolFlag = false;
- * mapToolFlag = true; PDSOptionalFlag = true; }
- */
- /*
- * Boolean tFlag = ns.getBoolean("t"); if (tFlag) {
- * dmProcessState.setLDDToolAnnotateDefinitionFlag (); LDDToolAnnotateDefinitionFlag = true; }
- */
Boolean MFlag = ns.getBoolean("M");
if (MFlag) {
dmProcessState.setLDDToolMissionFlag();
LDDToolMissionFlag = true;
- registerMessage("1>warning "
+ Utility.registerMessage("1>warning "
+ "The -M flag has been deprecated as of PDS4 IM Version 1.14.0.0. See the LDDTool User's Manual for more information on how to provide this information.");
}
Boolean mFlag = ns.getBoolean("m");
@@ -1335,11 +1284,6 @@ static void processArgumentParserNamespacePhase2(Namespace ns) {
dmProcessState.setprintNamespaceFlag();
printNamespaceFlag = true;
}
- /*
- * String aFlag = ns.getBoolean("a"); if (aFlag) { dmProcessState.setLDDAttrElementFlag (); //
- * LDDAttrElementFlag = true; LDDAttrElementFlag = false; }
- */
-
Boolean dFlag = ns.getBoolean("d");
if (dFlag) {
@@ -1382,10 +1326,6 @@ static void processArgumentParserNamespacePhase2(Namespace ns) {
exportCustomFileFlag = true;
}
- /*
- * Boolean fFlag = ns.getBoolean("f"); if (fFlag) { dmProcessState.setcheckFileNameFlag (); }
- */
-
// get the LDDIngest file names
for (String fileName : ns.getList("fileNameArr")) {
SchemaFileDefn lLDDSchemaFileDefn = new SchemaFileDefn(fileName);
@@ -1396,7 +1336,6 @@ static void processArgumentParserNamespacePhase2(Namespace ns) {
LDDSchemaFileSortArr.add(lLDDSchemaFileDefn);
masterLDDSchemaFileDefn = lLDDSchemaFileDefn; // the last Ingest_LDD named is the master.
}
- return;
}
static void printErrorMessages() {
@@ -1408,18 +1347,18 @@ static void printErrorMessages() {
DOMMsgDefn lMainMsg = i.next();
// eliminate certain messages
- if (nameSpaceIdExtrnFlagArr.contains(lMainMsg.nameSpaceIdNCLC)) {
+ if (nameSpaceIdExtrnFlagArr.contains(lMainMsg.getNameSpaceIdNCLC())) {
continue;
}
// if debugFlag is false, skip debug messages
// 0>info, 0>warning, 0>error
if (!debugFlag) {
- if ((lMainMsg.msgTypeLevel.substring(0, 2)).compareTo("0>") == 0) {
+ if ((lMainMsg.getMsgTypeLevel().substring(0, 2)).compareTo("0>") == 0) {
continue;
}
}
- String lMapID = lMainMsg.msgTypeLevel + "." + lMainMsg.msgOrder.toString();
+ String lMapID = lMainMsg.getMsgTypeLevel() + "." + lMainMsg.getMsgOrder().toString();
lMainMsgMap.put(lMapID, lMainMsg);
}
@@ -1427,17 +1366,17 @@ static void printErrorMessages() {
ArrayList lMainMsgArr = new ArrayList<>(lMainMsgMap.values());
for (Iterator i = lMainMsgArr.iterator(); i.hasNext();) {
DOMMsgDefn lMainMsg = i.next();
- Integer lMessageCount = messageLevelCountMap.get(lMainMsg.msgTypeLevel);
+ Integer lMessageCount = messageLevelCountMap.get(lMainMsg.getMsgTypeLevel());
if (lMessageCount != null) {
lMessageCount++;
- messageLevelCountMap.put(lMainMsg.msgTypeLevel, lMessageCount);
+ messageLevelCountMap.put(lMainMsg.getMsgTypeLevel(), lMessageCount);
}
- if (lPreviousGroupTitle.compareTo(lMainMsg.msgGroupTitle) != 0) {
- lPreviousGroupTitle = lMainMsg.msgGroupTitle;
+ if (lPreviousGroupTitle.compareTo(lMainMsg.getMsgGroupTitle()) != 0) {
+ lPreviousGroupTitle = lMainMsg.getMsgGroupTitle();
System.out.println("");
}
- System.out.println(lMainMsg.msgPrefix + " " + lMainMsg.msgCleanText);
+ System.out.println(lMainMsg.getMsgPrefix() + " " + lMainMsg.getMsgCleanText());
}
// print out the message counts
@@ -1501,4 +1440,12 @@ static private void printOutputFileNames() {
System.out.println(" - " + writtenFileName);
}
}
+
+ public static String getOutputDirPath() {
+ return outputDirPath;
+ }
+
+ public static void setOutputDirPath(String outputDirPath) {
+ DMDocument.outputDirPath = outputDirPath;
+ }
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DMProcessState.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DMProcessState.java
index 9543a983..adea04fe 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DMProcessState.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DMProcessState.java
@@ -34,6 +34,7 @@
import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;
+import gov.nasa.pds.model.plugin.util.Utility;
public class DMProcessState {
@@ -445,7 +446,7 @@ public void setRelativeFileSpecDDCSV(SchemaFileDefn lSchemaFileDefn) {
public void setRelativeFileSpecCCSDSCSV(SchemaFileDefn lSchemaFileDefn) {
writtenFilesMap.put(lSchemaFileDefn.relativeFileSpecCCSDSCSV, 1120);
if (lSchemaFileDefn.isLDD) {
- DMDocument.checkCreateDirectory(DMDocument.outputDirPath + "export/CSV/");
+ Utility.checkCreateDirectory(DMDocument.getOutputDirPath() + "export/CSV/");
}
return;
}
@@ -465,7 +466,7 @@ public void setRelativeFileSpecReportTXT(SchemaFileDefn lSchemaFileDefn) {
public void setRelativeFileSpecDDDocXML(SchemaFileDefn lSchemaFileDefn) {
writtenFilesMap.put(lSchemaFileDefn.relativeFileSpecDDDocXML, 1150);
if (lSchemaFileDefn.isLDD) {
- DMDocument.checkCreateDirectory(DMDocument.outputDirPath + "export/DD/");
+ Utility.checkCreateDirectory(DMDocument.getOutputDirPath() + "export/DD/");
}
return;
}
@@ -485,7 +486,7 @@ public void setRelativeFileSpecDDProtPinsSN(SchemaFileDefn lSchemaFileDefn) {
public void setRelativeFileSpecModelRDF(SchemaFileDefn lSchemaFileDefn) {
writtenFilesMap.put(lSchemaFileDefn.relativeFileSpecModelRDF, 1190);
if (lSchemaFileDefn.isLDD) {
- DMDocument.checkCreateDirectory(DMDocument.outputDirPath + "export/rdf/");
+ Utility.checkCreateDirectory(DMDocument.getOutputDirPath() + "export/rdf/");
}
return;
}
@@ -493,7 +494,7 @@ public void setRelativeFileSpecModelRDF(SchemaFileDefn lSchemaFileDefn) {
public void setRelativeFileSpecOWLRDF_DOM(SchemaFileDefn lSchemaFileDefn) {
writtenFilesMap.put(lSchemaFileDefn.relativeFileSpecOWLRDF_DOM, 1210);
if (lSchemaFileDefn.isLDD) {
- DMDocument.checkCreateDirectory(DMDocument.outputDirPath + "export/owl/");
+ Utility.checkCreateDirectory(DMDocument.getOutputDirPath() + "export/owl/");
}
return;
}
@@ -501,7 +502,7 @@ public void setRelativeFileSpecOWLRDF_DOM(SchemaFileDefn lSchemaFileDefn) {
public void setRelativeFileSpecSKOSTTL_DOM(SchemaFileDefn lSchemaFileDefn) {
writtenFilesMap.put(lSchemaFileDefn.relativeFileSpecSKOSTTL_DOM, 1230);
if (lSchemaFileDefn.isLDD) {
- DMDocument.checkCreateDirectory(DMDocument.outputDirPath + "export/skos/");
+ Utility.checkCreateDirectory(DMDocument.getOutputDirPath() + "export/skos/");
}
return;
}
@@ -509,7 +510,7 @@ public void setRelativeFileSpecSKOSTTL_DOM(SchemaFileDefn lSchemaFileDefn) {
public void setRelativeFileSpecOWLRDFTTL(SchemaFileDefn lSchemaFileDefn) {
writtenFilesMap.put(lSchemaFileDefn.relativeFileSpecOWLRDF_DOM, 1231);
if (lSchemaFileDefn.isLDD) {
- DMDocument.checkCreateDirectory(DMDocument.outputDirPath + "export/owl/");
+ Utility.checkCreateDirectory(DMDocument.getOutputDirPath() + "export/owl/");
}
return;
}
@@ -517,7 +518,7 @@ public void setRelativeFileSpecOWLRDFTTL(SchemaFileDefn lSchemaFileDefn) {
public void setRelativeFileSpecOWLRDF(SchemaFileDefn lSchemaFileDefn) {
writtenFilesMap.put(lSchemaFileDefn.relativeFileSpecOWLRDF_DOM, 1232);
if (lSchemaFileDefn.isLDD) {
- DMDocument.checkCreateDirectory(DMDocument.outputDirPath + "export/owl/");
+ Utility.checkCreateDirectory(DMDocument.getOutputDirPath() + "export/owl/");
}
return;
}
@@ -525,7 +526,7 @@ public void setRelativeFileSpecOWLRDF(SchemaFileDefn lSchemaFileDefn) {
public void setRelativeFileSpecUMLXMI(SchemaFileDefn lSchemaFileDefn) {
writtenFilesMap.put(lSchemaFileDefn.relativeFileSpecUMLXMI, 1240);
if (lSchemaFileDefn.isLDD) {
- DMDocument.checkCreateDirectory(DMDocument.outputDirPath + "export/xmi/");
+ Utility.checkCreateDirectory(DMDocument.getOutputDirPath() + "export/xmi/");
}
return;
}
@@ -533,7 +534,7 @@ public void setRelativeFileSpecUMLXMI(SchemaFileDefn lSchemaFileDefn) {
public void setRelativeFileSpecUMLXMI2(SchemaFileDefn lSchemaFileDefn) {
writtenFilesMap.put(lSchemaFileDefn.relativeFileSpecUMLXMI2, 1250);
if (lSchemaFileDefn.isLDD) {
- DMDocument.checkCreateDirectory(DMDocument.outputDirPath + "export/xmi/");
+ Utility.checkCreateDirectory(DMDocument.getOutputDirPath() + "export/xmi/");
}
return;
}
@@ -541,7 +542,7 @@ public void setRelativeFileSpecUMLXMI2(SchemaFileDefn lSchemaFileDefn) {
public void setRelativeFileSpecAttrDefn(SchemaFileDefn lSchemaFileDefn) {
writtenFilesMap.put(lSchemaFileDefn.relativeFileSpecAttrDefn, 1300);
if (lSchemaFileDefn.isLDD) {
- DMDocument.checkCreateDirectory(DMDocument.outputDirPath + "export/defnAttr/");
+ Utility.checkCreateDirectory(DMDocument.getOutputDirPath() + "export/defnAttr/");
}
return;
}
@@ -549,7 +550,7 @@ public void setRelativeFileSpecAttrDefn(SchemaFileDefn lSchemaFileDefn) {
public void setRelativeFileSpecClassDefn(SchemaFileDefn lSchemaFileDefn) {
writtenFilesMap.put(lSchemaFileDefn.relativeFileSpecClassDefn, 1310);
if (lSchemaFileDefn.isLDD) {
- DMDocument.checkCreateDirectory(DMDocument.outputDirPath + "export/defnClass/");
+ Utility.checkCreateDirectory(DMDocument.getOutputDirPath() + "export/defnClass/");
}
return;
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMAttr.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMAttr.java
index e39cc5a0..1052dc27 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMAttr.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMAttr.java
@@ -34,6 +34,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.TreeMap;
+import gov.nasa.pds.model.plugin.util.Utility;
public class DOMAttr extends ISOClassOAIS11179 {
String sort_identifier; // lAttr.title + "_" + lAttr.steward + "_" + lAttr.className + "_" +
@@ -256,7 +257,7 @@ public void InitStringArr(ArrayList lDomStrArr, ArrayList lPDSSt
if (lOldStr != null) {
lDomStrArr.add(lOldStr);
} else {
- DMDocument.registerMessage("1>error " + "InitStringArr - Null DomStr");
+ Utility.registerMessage("1>error " + "InitStringArr - Null DomStr");
}
}
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMMsgDefn.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMMsgDefn.java
index 5cbdee0a..fd54bdfd 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMMsgDefn.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMMsgDefn.java
@@ -42,13 +42,13 @@ public class DOMMsgDefn extends Object {
static TreeMap messageLevelTitleMap = new TreeMap<>();
static TreeMap messagePrefixMap = new TreeMap<>();
- Integer msgOrder;
- String msgTypeLevel;
- String msgPrefix;
- String msgOrgText;
- String msgCleanText;
- String msgGroupTitle;
- String nameSpaceIdNCLC;
+ private Integer msgOrder;
+ private String msgTypeLevel;
+ private String msgPrefix;
+ private String msgOrgText;
+ private String msgCleanText;
+ private String msgGroupTitle;
+ private String nameSpaceIdNCLC;
public DOMMsgDefn() {
// messageLevelArr is initialized (init()) when masterDOMMsgDefn is created in DMDocument
@@ -142,4 +142,84 @@ static void init() {
messageLevelArr.add("3>error");
messageLevelArr.add("4>error");
}
+
+ public static ArrayList getMessageLevelArr() {
+ return messageLevelArr;
+ }
+
+ public static void setMessageLevelArr(ArrayList messageLevelArr) {
+ DOMMsgDefn.messageLevelArr = messageLevelArr;
+ }
+
+ public static TreeMap getMessageLevelTitleMap() {
+ return messageLevelTitleMap;
+ }
+
+ public static void setMessageLevelTitleMap(TreeMap messageLevelTitleMap) {
+ DOMMsgDefn.messageLevelTitleMap = messageLevelTitleMap;
+ }
+
+ public static TreeMap getMessagePrefixMap() {
+ return messagePrefixMap;
+ }
+
+ public static void setMessagePrefixMap(TreeMap messagePrefixMap) {
+ DOMMsgDefn.messagePrefixMap = messagePrefixMap;
+ }
+
+ public Integer getMsgOrder() {
+ return msgOrder;
+ }
+
+ public void setMsgOrder(Integer msgOrder) {
+ this.msgOrder = msgOrder;
+ }
+
+ public String getMsgTypeLevel() {
+ return msgTypeLevel;
+ }
+
+ public void setMsgTypeLevel(String msgTypeLevel) {
+ this.msgTypeLevel = msgTypeLevel;
+ }
+
+ public String getMsgPrefix() {
+ return msgPrefix;
+ }
+
+ public void setMsgPrefix(String msgPrefix) {
+ this.msgPrefix = msgPrefix;
+ }
+
+ public String getMsgOrgText() {
+ return msgOrgText;
+ }
+
+ public void setMsgOrgText(String msgOrgText) {
+ this.msgOrgText = msgOrgText;
+ }
+
+ public String getMsgCleanText() {
+ return msgCleanText;
+ }
+
+ public void setMsgCleanText(String msgCleanText) {
+ this.msgCleanText = msgCleanText;
+ }
+
+ public String getMsgGroupTitle() {
+ return msgGroupTitle;
+ }
+
+ public void setMsgGroupTitle(String msgGroupTitle) {
+ this.msgGroupTitle = msgGroupTitle;
+ }
+
+ public String getNameSpaceIdNCLC() {
+ return nameSpaceIdNCLC;
+ }
+
+ public void setNameSpaceIdNCLC(String nameSpaceIdNCLC) {
+ this.nameSpaceIdNCLC = nameSpaceIdNCLC;
+ }
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMProp.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMProp.java
index 53f1f578..834cef37 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMProp.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMProp.java
@@ -31,6 +31,7 @@
package gov.nasa.pds.model.plugin;
import java.util.ArrayList;
+import gov.nasa.pds.model.plugin.util.Utility;
public class DOMProp extends ISOClassOAIS11179 {
@@ -122,7 +123,7 @@ public void setCardMinMax(String lCardMin, String lCardMax) {
} catch (NumberFormatException e) {
cardMinI = 0;
cardMin = "0";
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>error " + "DomProp " + " - Minimum cardinality is invalid: " + lCardMin);
}
}
@@ -138,12 +139,12 @@ public void setCardMinMax(String lCardMin, String lCardMax) {
} catch (NumberFormatException e) {
cardMaxI = 0;
cardMax = "0";
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>error " + "DomProp " + " - Maximum cardinality is invalid: " + lCardMax);
}
}
if (cardMaxI < cardMinI) {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>error " + "DomProp " + " - Maximum cardinality is less than minimum cardinality");
}
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMProtAttr.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMProtAttr.java
index 4deb41b1..7608bbe9 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMProtAttr.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DOMProtAttr.java
@@ -33,6 +33,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
+import gov.nasa.pds.model.plugin.util.Utility;
public class DOMProtAttr extends ISOClassOAIS11179 {
String sort_identifier; // lAttr.title + "_" + lAttr.steward + "_" + lAttr.className + "_" +
@@ -169,7 +170,7 @@ public void InitStringArr(ArrayList lDomStrArr, ArrayList lPDSSt
if (lOldStr != null) {
lDomStrArr.add(lOldStr);
} else {
- DMDocument.registerMessage("1>error " + "InitStringArr - Null DomStr");
+ Utility.registerMessage("1>error " + "InitStringArr - Null DomStr");
}
}
}
@@ -208,10 +209,10 @@ public ArrayList convertToDOMPropCompArr() {
lDomPropComp.domComp = lClassMember;
lDomPropCompArr.add(lDomPropComp);
} else {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>error " + "Could not find the class referenced in an association - identifier:"
+ this.identifier + " Class:" + lClassTitle);
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>error " + "Could not find the class referenced in an association - identifier:"
+ this.identifier + " lClassMemberIdentifier:" + lClassMemberIdentifier);
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ExportModels.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ExportModels.java
index c1a8188c..9c8cad46 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ExportModels.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ExportModels.java
@@ -33,9 +33,9 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.TreeMap;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import gov.nasa.pds.model.plugin.util.Utility;
/**
* Driver for getting document
@@ -54,20 +54,20 @@ public ExportModels() {
public void writeAllArtifacts() throws java.io.IOException {
// check if the export/ directory exists; if not create it
- DMDocument.checkCreateDirectory(DMDocument.outputDirPath + "export/");
+ Utility.checkCreateDirectory(DMDocument.getOutputDirPath() + "export/");
// write the model specification
DMDocument.dmProcessState.setRelativeFileSpecModelSpec_DOM(DMDocument.masterPDSSchemaFileDefn);
WriteDOMSpecification writeDOMSpecification = new WriteDOMSpecification(DMDocument.docInfo);
writeDOMSpecification.printArtifacts();
- DMDocument.registerMessage("0>info " + "writeAllArtifacts - Specification Done");
+ Utility.registerMessage("0>info " + "writeAllArtifacts - Specification Done");
// write the label schema - new version 4
DMDocument.dmProcessState.setRelativeFileSpecXMLSchema(DMDocument.masterPDSSchemaFileDefn);
XML4LabelSchemaDOM xml4LabelSchemaDOM = new XML4LabelSchemaDOM();
xml4LabelSchemaDOM.writeXMLSchemaFiles(DMDocument.masterPDSSchemaFileDefn,
DOMInfoModel.masterDOMClassArr);
- DMDocument
+ Utility
.registerMessage("0>info " + "writeAllArtifacts - XML Schema - lSchemaFileDefn.identifier:"
+ DMDocument.masterPDSSchemaFileDefn.identifier + " - Done");
@@ -76,7 +76,7 @@ public void writeAllArtifacts() throws java.io.IOException {
WriteDOMSchematron writeDOMSchematron = new WriteDOMSchematron();
writeDOMSchematron.writeSchematronFile(DMDocument.masterPDSSchemaFileDefn,
DOMInfoModel.masterDOMClassMap);
- DMDocument
+ Utility
.registerMessage("0>info " + "writeAllArtifacts - Schematron - lSchemaFileDefn.identifier:"
+ DMDocument.masterPDSSchemaFileDefn.identifier + " - Done");
@@ -84,7 +84,7 @@ public void writeAllArtifacts() throws java.io.IOException {
DMDocument.dmProcessState.setRelativeFileSpecXMLLabel(DMDocument.masterPDSSchemaFileDefn);
WriteCoreXMLSchemaLabel writeCoreXMLSchemaLabel = new WriteCoreXMLSchemaLabel();
writeCoreXMLSchemaLabel.writeFile(DMDocument.masterPDSSchemaFileDefn);
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + "writeAllArtifacts - Schema Label - lSchemaFileDefn.identifier:"
+ DMDocument.masterPDSSchemaFileDefn.identifier + " - Done");
@@ -92,7 +92,7 @@ public void writeAllArtifacts() throws java.io.IOException {
DMDocument.dmProcessState.setRelativeFileSpecDDDocXML(DMDocument.masterPDSSchemaFileDefn);
WriteDOMDocBook lWriteDOMDocBook = new WriteDOMDocBook();
lWriteDOMDocBook.writeDocBook(DMDocument.masterPDSSchemaFileDefn);
- DMDocument.registerMessage("0>info " + "writeAllArtifacts - DD DocBook Done");
+ Utility.registerMessage("0>info " + "writeAllArtifacts - DD DocBook Done");
// write the custom files
if (DMDocument.exportCustomFileFlag) {
@@ -104,21 +104,13 @@ public void writeAllArtifacts() throws java.io.IOException {
// write the DOM RDF
WriteDOM11179DDRDFFile writeDOM11179DDRDFFile = new WriteDOM11179DDRDFFile();
writeDOM11179DDRDFFile.printISO11179DDRDF(DMDocument.sTodaysDate);
- DMDocument.registerMessage("0>info " + "writeAllArtifacts - RDF Done");
+ Utility.registerMessage("0>info " + "writeAllArtifacts - RDF Done");
// write the DOM PDS4 DD CSV file
WriteDOMCSVFiles writeDOMCSVFiles = new WriteDOMCSVFiles();
ArrayList domSortClassArr = new ArrayList<>(DOMInfoModel.masterDOMClassMap.values());
writeDOMCSVFiles.writeDOMCSVFile(domSortClassArr, DMDocument.masterPDSSchemaFileDefn, null);
- DMDocument.registerMessage("0>info " + "writeAllArtifacts - DD CSV Done");
-
- // write the 11179 DD pins file
- // WriteDOM11179DDPinsFile lWriteDOM11179DDPinsFile = new WriteDOM11179DDPinsFile ();
- // lWriteDOM11179DDPinsFile.writePINSFile
- // (DMDocument.masterPDSSchemaFileDefn.relativeFileSpecDDProtPins);
- // lWriteDOM11179DDPinsFile.writePINSFile
- // (DMDocument.masterPDSSchemaFileDefn.relativeFileSpecDDProtPinsSN);
- // DMDocument.registerMessage ("0>info " + "writeAllArtifacts - DD Pins File Done");
+ Utility.registerMessage("0>info " + "writeAllArtifacts - DD CSV Done");
// write the 11179 DD pins file - Plus Class Version
WriteDOM11179DDPinsFilePClass lWriteDOM11179DDPinsFilePClass =
@@ -127,25 +119,19 @@ public void writeAllArtifacts() throws java.io.IOException {
.writePINSFile(DMDocument.masterPDSSchemaFileDefn.relativeFileSpecDDProtPins);
lWriteDOM11179DDPinsFilePClass
.writePINSFile(DMDocument.masterPDSSchemaFileDefn.relativeFileSpecDDProtPinsSN);
- DMDocument
+ Utility
.registerMessage("0>info " + "writeAllArtifacts - DD Pins *** plus class *** File Done");
-
- // write the 11179 DOM JSON file - requires DOMInfoModel to be executed
-// DMDocument.dmProcessState.setRelativeFileSpecDOMModelJSON(DMDocument.masterPDSSchemaFileDefn);
-// WriteDOMDDJSONFile writeDOMDDJSONFile = new WriteDOMDDJSONFile();
-// writeDOMDDJSONFile.writeJSONFile();
-// DMDocument.registerMessage("0>info " + "writeAllArtifacts - JSON Done");
// write the 11179 DOM JSON file - requires DOMInfoModel to be executed
DMDocument.dmProcessState.setRelativeFileSpecDOMModelJSON(DMDocument.masterPDSSchemaFileDefn);
WriteDOMDDJSONFileLib writeDOMDDJSONFileLib = new WriteDOMDDJSONFileLib();
writeDOMDDJSONFileLib.writeJSONFile(DMDocument.masterPDSSchemaFileDefn);
- DMDocument.registerMessage("0>info " + "writeAllArtifacts - JSON Done");
+ Utility.registerMessage("0>info " + "writeAllArtifacts - JSON Done");
// write the 11179 DD Data Element Definition XML Files
- DMDocument.registerMessage("0>info " + "writeAllArtifacts - Class Defn Done");
- DMDocument.registerMessage("0>info " + "writeAllArtifacts - Attr Defn Done");
+ Utility.registerMessage("0>info " + "writeAllArtifacts - Class Defn Done");
+ Utility.registerMessage("0>info " + "writeAllArtifacts - Attr Defn Done");
// write the 11179 DOM DD Data Element Definition XML Files
WriteDDProductDOMAttrDefinitions writeDDProductDOMAttrDefinitions =
@@ -158,22 +144,19 @@ public void writeAllArtifacts() throws java.io.IOException {
new WriteDDProductDOMClassDefinitions();
writeDDProductDOMClassDefinitions.writeDDProductDOMClassDefnFiles(
DMDocument.masterPDSSchemaFileDefn, DMDocument.sTodaysDate);
- DMDocument.registerMessage("0>info " + "writeAllDOMArtifacts - DOM Class Defn Done");
- DMDocument.registerMessage("0>info " + "writeAllDOMArtifacts - DOM Attr Defn Done");
+ Utility.registerMessage("0>info " + "writeAllDOMArtifacts - DOM Class Defn Done");
+ Utility.registerMessage("0>info " + "writeAllDOMArtifacts - DOM Attr Defn Done");
// write the OWL/RDF/TTL output in TTL format (IM Classification)
if (DMDocument.exportOWLRDFTTLFileFlag) {
String lClassificationType = "TBD_default"; // default
lClassificationType = ""; // default
lClassificationType = "PDS4.All.Products.Class.Prop"; // works
- // lClassificationType = "EIMEntity"; // works
- // lClassificationType = "PDS4.LDD.All";
- // lClassificationType = "OAISIF";
ClassAttrPropClassification lCAPC = new ClassAttrPropClassification (lClassificationType);
DMDocument.dmProcessState.setRelativeFileSpecOWLRDFTTL (DMDocument.masterPDSSchemaFileDefn);
WriteDOMRDFTTLFile writeDOMRDFTTLFile = new WriteDOMRDFTTLFile ();
writeDOMRDFTTLFile.writeDOMRDFTTLFile (lClassificationType, lCAPC);
- DMDocument.registerMessage ("0>info " + "ExportModels - OWL/RDF/TTL output in TTL format (IM Classification) - Done");
+ Utility.registerMessage ("0>info " + "ExportModels - OWL/RDF/TTL output in TTL format (IM Classification) - Done");
}
// write the OWL/RDF output in RDF format (IM Export)
@@ -181,7 +164,7 @@ public void writeAllArtifacts() throws java.io.IOException {
DMDocument.dmProcessState.setRelativeFileSpecOWLRDFTTL (DMDocument.masterPDSSchemaFileDefn);
WriteDOMRDFOWLFile writeDOMRDFOWLFile = new WriteDOMRDFOWLFile ();
writeDOMRDFOWLFile.writeOWLFile (DMDocument.masterPDSSchemaFileDefn);
- DMDocument.registerMessage ("0>info " + "ExportModels - OWL/RDF output in RDF format (IM Export) - Done");
+ Utility.registerMessage ("0>info " + "ExportModels - OWL/RDF output in RDF format (IM Export) - Done");
}
return;
@@ -189,7 +172,7 @@ public void writeAllArtifacts() throws java.io.IOException {
public void writeLDDArtifacts() throws java.io.IOException {
// check if the export directory exists; if not create it
- DMDocument.checkCreateDirectory(DMDocument.outputDirPath + "export/");
+ Utility.checkCreateDirectory(DMDocument.getOutputDirPath() + "export/");
// DOM
ArrayList lLDDDOMClassArr = new ArrayList<>();
@@ -212,7 +195,7 @@ public void writeLDDArtifacts() throws java.io.IOException {
DMDocument.dmProcessState.setRelativeFileSpecDDDocXML(DMDocument.masterLDDSchemaFileDefn);
WriteDOMDocBook lWriteDOMDocBook = new WriteDOMDocBook();
lWriteDOMDocBook.writeDocBook(DMDocument.masterPDSSchemaFileDefn);
- DMDocument.registerMessage("0>info " + "writeLDDArtifacts - DD DocBook Done");
+ Utility.registerMessage("0>info " + "writeLDDArtifacts - DD DocBook Done");
}
// write the custom files
@@ -226,7 +209,7 @@ public void writeLDDArtifacts() throws java.io.IOException {
DMDocument.dmProcessState.setRelativeFileSpecXMLSchema(DMDocument.masterLDDSchemaFileDefn);
XML4LabelSchemaDOM xml4LabelSchemaDOM = new XML4LabelSchemaDOM();
xml4LabelSchemaDOM.writeXMLSchemaFiles(DMDocument.masterLDDSchemaFileDefn, lLDDDOMClassArr);
- DMDocument
+ Utility
.registerMessage("0>info " + "writeLDDArtifacts - XML Schema - lSchemaFileDefn.identifier:"
+ DMDocument.masterLDDSchemaFileDefn.identifier + " - Done");
@@ -234,7 +217,7 @@ public void writeLDDArtifacts() throws java.io.IOException {
DMDocument.dmProcessState.setRelativeFileSpecSchematron(DMDocument.masterLDDSchemaFileDefn);
WriteDOMSchematron writeDOMSchematron = new WriteDOMSchematron();
writeDOMSchematron.writeSchematronFile(DMDocument.masterLDDSchemaFileDefn, lLDDDOMClassMap);
- DMDocument
+ Utility
.registerMessage("0>info " + "writeLDDArtifacts - Schematron - lSchemaFileDefn.identifier:"
+ DMDocument.masterLDDSchemaFileDefn.identifier + " - Done");
@@ -242,24 +225,16 @@ public void writeLDDArtifacts() throws java.io.IOException {
DMDocument.dmProcessState.setRelativeFileSpecXMLLabel(DMDocument.masterLDDSchemaFileDefn);
WriteCoreXMLSchemaLabel writeCoreXMLSchemaLabel = new WriteCoreXMLSchemaLabel();
writeCoreXMLSchemaLabel.writeFile(DMDocument.masterLDDSchemaFileDefn);
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + "writeAllArtifacts - Schema Label - lSchemaFileDefn.identifier:"
+ DMDocument.masterLDDSchemaFileDefn.identifier + " - Done");
-
- // write the 11179 JSON file
-// if (DMDocument.exportJSONFileFlag || DMDocument.exportJSONFileAllFlag) {
-// DMDocument.dmProcessState.setRelativeFileSpecDOMModelJSON(DMDocument.masterLDDSchemaFileDefn);
-// WriteDOMDDJSONFile writeDOMDDJSONFile = new WriteDOMDDJSONFile();
-// writeDOMDDJSONFile.writeJSONFile();
-// DMDocument.registerMessage("0>info " + "writeAllArtifacts - JSON Done");
-// }
// write the 11179 DOM JSON file
if (DMDocument.exportJSONFileFlag) {
DMDocument.dmProcessState.setRelativeFileSpecDOMModelJSON(DMDocument.masterPDSSchemaFileDefn);
WriteDOMDDJSONFileLib writeDOMDDJSONFileLib = new WriteDOMDDJSONFileLib();
writeDOMDDJSONFileLib.writeJSONFile(DMDocument.masterPDSSchemaFileDefn);
- DMDocument.registerMessage("0>info " + "writeLDDArtifacts - JSON Done");
+ Utility.registerMessage("0>info " + "writeLDDArtifacts - JSON Done");
}
// write the Info Spec file
@@ -268,7 +243,7 @@ public void writeLDDArtifacts() throws java.io.IOException {
.setRelativeFileSpecModelSpec_DOM(DMDocument.masterLDDSchemaFileDefn);
WriteDOMSpecification writeDOMSpecification = new WriteDOMSpecification(DMDocument.docInfo);
writeDOMSpecification.printArtifacts();
- DMDocument.registerMessage("0>info " + "writeLDDArtifacts - Info Model Spec Done");
+ Utility.registerMessage("0>info " + "writeLDDArtifacts - Info Model Spec Done");
}
// write the OWL/RDF/TTL output in TTL format (IM Classification)
@@ -281,7 +256,7 @@ public void writeLDDArtifacts() throws java.io.IOException {
ClassAttrPropClassification lCAPC = new ClassAttrPropClassification (lClassificationType);
WriteDOMRDFTTLFile writeDOMRDFTTLFile = new WriteDOMRDFTTLFile ();
writeDOMRDFTTLFile.writeDOMRDFTTLFile (lClassificationType, lCAPC);
- DMDocument.registerMessage ("0>info " + "ExportModels - OWL/RDF/TTL output in TTL format (IM Classification) - Done");
+ Utility.registerMessage ("0>info " + "ExportModels - OWL/RDF/TTL output in TTL format (IM Classification) - Done");
}
// write the OWL/RDF output in RDF format (IM Export)
@@ -289,7 +264,7 @@ public void writeLDDArtifacts() throws java.io.IOException {
DMDocument.dmProcessState.setRelativeFileSpecOWLRDFTTL (DMDocument.masterLDDSchemaFileDefn);
WriteDOMRDFOWLFile writeDOMRDFOWLFile = new WriteDOMRDFOWLFile ();
writeDOMRDFOWLFile.writeOWLFile (DMDocument.masterLDDSchemaFileDefn);
- DMDocument.registerMessage ("0>info " + "ExportModels - OWL/RDF output in RDF format (IM Export) - Done");
+ Utility.registerMessage ("0>info " + "ExportModels - OWL/RDF output in RDF format (IM Export) - Done");
}
// *** To be deprecated ***
@@ -298,7 +273,7 @@ public void writeLDDArtifacts() throws java.io.IOException {
// write the terminological entry files
WriteDOMTermEntryJSON writeDOMTermEntryJSON = new WriteDOMTermEntryJSON ();
writeDOMTermEntryJSON.WriteDOMTermEntries (DMDocument.masterPDSSchemaFileDefn);
- DMDocument.registerMessage ("0>info " + "WriteDOMTermEntryJSON - Done");
+ Utility.registerMessage ("0>info " + "WriteDOMTermEntryJSON - Done");
}
return;
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ExportModelsCustom.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ExportModelsCustom.java
index 35aeac5f..504f2b6c 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ExportModelsCustom.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ExportModelsCustom.java
@@ -31,6 +31,7 @@
package gov.nasa.pds.model.plugin;
import java.util.*;
+import gov.nasa.pds.model.plugin.util.Utility;
/** Driver for Customized Document Writers
*
@@ -46,7 +47,7 @@ public ExportModelsCustom () {
***********************************************************************************************************/
public void writeArtifacts (boolean lLDDToolFlag, SchemaFileDefn lSchemaFileDefn) throws java.io.IOException {
- DMDocument.registerMessage ("0>info " + "ExportModelsCustom - Specification Done");
+ Utility.registerMessage ("0>info " + "ExportModelsCustom - Specification Done");
// need to pass SchemaFileDefn to get namespace; set static for now.
// SchemaFileDefn lSchemaFileDefn;
@@ -61,7 +62,7 @@ public void writeArtifacts (boolean lLDDToolFlag, SchemaFileDefn lSchemaFileDefn
DMDocument.dmProcessState.setRelativeFileSpecDDDocXML (DMDocument.masterLDDSchemaFileDefn);
WriteDOMDocBookAnon lWriteDOMDocBooks = new WriteDOMDocBookAnon ();
lWriteDOMDocBooks.writeDocBooks(DMDocument.masterPDSSchemaFileDefn);
- DMDocument.registerMessage ("0>info " + "writeLDDArtifacts - DD DocBooks - One Per LDD - Done");
+ Utility.registerMessage ("0>info " + "writeLDDArtifacts - DD DocBooks - One Per LDD - Done");
}
}
@@ -94,7 +95,7 @@ public void writeArtifacts (boolean lLDDToolFlag, SchemaFileDefn lSchemaFileDefn
ArrayList domSortClassArr = new ArrayList<>(DOMInfoModel.masterDOMClassMap.values());
WriteDOMCSVFileClassHier writeDOMCSVFileClassHier = new WriteDOMCSVFileClassHier ();
writeDOMCSVFileClassHier.writeDOMCSVFile (domSortClassArr, DMDocument.masterPDSSchemaFileDefn, null);
- DMDocument.registerMessage ("0>info " + "writeAllArtifacts - WriteDOMCSVFileClassHier Done");
+ Utility.registerMessage ("0>info " + "writeAllArtifacts - WriteDOMCSVFileClassHier Done");
// print out the histogram for the DEC concepts
/*
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/GenDOMRules.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/GenDOMRules.java
index 532fb320..ea4939f5 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/GenDOMRules.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/GenDOMRules.java
@@ -34,6 +34,7 @@
import java.util.Arrays;
import java.util.Iterator;
import java.util.TreeMap;
+import gov.nasa.pds.model.plugin.util.Utility;
class GenDOMRules extends Object {
TreeMap lUnitIdDeprecatedMap = new TreeMap ();
@@ -808,7 +809,7 @@ private void findChildrenOfAssociatedExternalClass() {
parentChildrenRelationMap.put(lDOMClass.identifier, lParentChildrenRelation);
lParentClassIdArr.add(lDOMClass.identifier);
} else {
- DMDocument.registerMessage("1>error "
+ Utility.registerMessage("1>error "
+ "Duplicate Found - Adding Extern Class to parentChildrenRelationMap - lDOMClass.identifier:"
+ lDOMClass.identifier);
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/GetDOMModel.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/GetDOMModel.java
index ab791b35..cc79ab51 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/GetDOMModel.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/GetDOMModel.java
@@ -35,6 +35,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
+import gov.nasa.pds.model.plugin.util.Utility;
public class GetDOMModel extends Object {
@@ -76,7 +77,7 @@ public void getDOMModel(String docFileName) throws Throwable {
if (!DOMInfoModel.masterDOMClassMap.containsKey(lClass.rdfIdentifier)) {
DOMInfoModel.masterDOMClassMap.put(lClass.rdfIdentifier, lClass);
} else {
- DMDocument.registerMessage("1>error "
+ Utility.registerMessage("1>error "
+ "Duplicate Found - ADDING DOM class lClass.rdfIdentifier:" + lClass.rdfIdentifier);
}
}
@@ -117,7 +118,7 @@ public void getDOMModel(String docFileName) throws Throwable {
lClass.ownedAttrArr.add(lDOMProp);
lDOMProp.attrParentClass = lClass;
} else {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>error " + "Duplicate Found - ADDING Attribute Property lDOMProp.rdfIdentifier:"
+ lDOMProp.rdfIdentifier);
}
@@ -132,7 +133,7 @@ public void getDOMModel(String docFileName) throws Throwable {
lDOMProp.isInactive = lClass.isInactive;
lDOMAttr.isInactive = lClass.isInactive;
} else {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>error " + "Duplicate Found - ADDING Attribute lDOMAttr.rdfIdentifier:"
+ lDOMAttr.rdfIdentifier);
}
@@ -153,7 +154,7 @@ public void getDOMModel(String docFileName) throws Throwable {
lClass.ownedAssocArr.add(lDOMProp);
lDOMProp.attrParentClass = lClass;
} else {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>error " + "Duplicate Found - ADDING Class Property lDOMProp.rdfIdentifier:"
+ lDOMProp.rdfIdentifier);
}
@@ -168,7 +169,7 @@ public void getDOMModel(String docFileName) throws Throwable {
lDOMProp.isInactive = lClass.isInactive;
} else {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>error " + "Class not found - ADDING Class lDOMClass.rdfIdentifier:"
+ lDOMClass.rdfIdentifier);
}
@@ -197,7 +198,7 @@ public void getDOMModel(String docFileName) throws Throwable {
// Discipline_Area, and Mission_Area
if (DMDocument.LDDToolSingletonClassTitle.compareTo("USER") == 0) {
DMDocument.LDDToolSingletonDOMClass = DOMInfoModel.masterDOMUserClass;
- DMDocument.registerMessage("0>info "
+ Utility.registerMessage("0>info "
+ "getMasterObjectDict - Set LDDToolSingletonClass - DMDocument.LDDToolSingletonDOMClass.title:"
+ DMDocument.LDDToolSingletonDOMClass.title);
} else {
@@ -206,11 +207,11 @@ public void getDOMModel(String docFileName) throws Throwable {
DOMClass lLDDToolSingletonClass = DOMInfoModel.masterDOMClassIdMap.get(lClassId);
if (lLDDToolSingletonClass != null) {
DMDocument.LDDToolSingletonDOMClass = lLDDToolSingletonClass;
- DMDocument.registerMessage("0>info "
+ Utility.registerMessage("0>info "
+ "getMasterObjectDict - Found LDDToolSingletonClass - DMDocument.LDDToolSingletonDOMClass.title:"
+ DMDocument.LDDToolSingletonDOMClass.title);
} else {
- DMDocument.registerMessage("1>error "
+ Utility.registerMessage("1>error "
+ "getMasterObjectDict - Could not find LDDToolSingletonClass - lClassId:" + lClassId);
}
}
@@ -472,78 +473,78 @@ public void getDOMModel(String docFileName) throws Throwable {
}
if (DMDocument.debugFlag) {
- DMDocument.registerMessage("0>info ");
- DMDocument.registerMessage("0>info " + "Active Namespace Ids:");
+ Utility.registerMessage("0>info ");
+ Utility.registerMessage("0>info " + "Active Namespace Ids:");
for (Iterator i = lNameSpaceHasMemberArr.iterator(); i.hasNext();) {
String lNameSpaceId = i.next();
- DMDocument.registerMessage("0>info " + " - namespace_id:" + lNameSpaceId);
+ Utility.registerMessage("0>info " + " - namespace_id:" + lNameSpaceId);
}
- DMDocument.registerMessage("0>info ");
- DMDocument.registerMessage("0>info " + "Master DOM Structures Initiated");
- DMDocument.registerMessage(
+ Utility.registerMessage("0>info ");
+ Utility.registerMessage("0>info " + "Master DOM Structures Initiated");
+ Utility.registerMessage(
"0>info " + "Master Class Map Sizes - DOMInfoModel.masterDOMClassMap.size():"
+ DOMInfoModel.masterDOMClassMap.size());
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + " - DOMInfoModel.masterDOMClassIdMap.size():"
+ DOMInfoModel.masterDOMClassIdMap.size());
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + " - DOMInfoModel.masterDOMClassArr.size():"
+ DOMInfoModel.masterDOMClassArr.size());
- DMDocument.registerMessage("0>info ");
- DMDocument.registerMessage(
+ Utility.registerMessage("0>info ");
+ Utility.registerMessage(
"0>info " + "Master Property Map Sizes - DOMInfoModel.masterDOMPropMap.size():"
+ DOMInfoModel.masterDOMPropMap.size());
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + " - DOMInfoModel.masterDOMPropIdMap.size():"
+ DOMInfoModel.masterDOMPropIdMap.size());
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + " - DOMInfoModel.masterDOMPropArr.size():"
+ DOMInfoModel.masterDOMPropArr.size());
- DMDocument.registerMessage("0>info ");
- DMDocument.registerMessage(
+ Utility.registerMessage("0>info ");
+ Utility.registerMessage(
"0>info " + "Master Attribute Map Sizes - DOMInfoModel.masterDOMAttrMap.size():"
+ DOMInfoModel.masterDOMAttrMap.size());
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + " - DOMInfoModel.masterDOMAttrIdMap.size():"
+ DOMInfoModel.masterDOMAttrIdMap.size());
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + " - DOMInfoModel.masterDOMAttrArr.size():"
+ DOMInfoModel.masterDOMAttrArr.size());
- DMDocument.registerMessage("0>info ");
- DMDocument.registerMessage(
+ Utility.registerMessage("0>info ");
+ Utility.registerMessage(
"0>info " + "Master Rule Map Sizes - DOMInfoModel.masterDOMRuleMap.size():"
+ DOMInfoModel.masterDOMRuleMap.size());
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + " - DOMInfoModel.masterDOMRuleIdMap.size():"
+ DOMInfoModel.masterDOMRuleIdMap.size());
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + " - DOMInfoModel.masterDOMRuleArr.size():"
+ DOMInfoModel.masterDOMRuleArr.size());
- DMDocument.registerMessage("0>info ");
- DMDocument.registerMessage(
+ Utility.registerMessage("0>info ");
+ Utility.registerMessage(
"0>info " + "Master Data Type Sizes - DOMInfoModel.masterDOMDataTypeMap.size():"
+ DOMInfoModel.masterDOMDataTypeMap.size());
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + " - DOMInfoModel.masterDOMDataTypeTitleMap.size():"
+ DOMInfoModel.masterDOMDataTypeTitleMap.size());
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + " - DOMInfoModel.masterDOMDataTypeArr.size():"
+ DOMInfoModel.masterDOMDataTypeArr.size());
- DMDocument.registerMessage("0>info ");
- DMDocument.registerMessage(
+ Utility.registerMessage("0>info ");
+ Utility.registerMessage(
"0>info " + "Master Unit Sizes - DOMInfoModel.masterDOMUnitMap.size():"
+ DOMInfoModel.masterDOMUnitMap.size());
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + " - DOMInfoModel.masterDOMUnitTitleMap.size():"
+ DOMInfoModel.masterDOMUnitTitleMap.size());
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + " - DOMInfoModel.masterDOMUnitArr.size():"
+ DOMInfoModel.masterDOMUnitArr.size());
- DMDocument.registerMessage("0>info ");
+ Utility.registerMessage("0>info ");
}
- DMDocument.registerMessage("0>info " + "GetDOMModel Done");
+ Utility.registerMessage("0>info " + "GetDOMModel Done");
}
/**********************************************************************************************************
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/GetDOMModelDoc.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/GetDOMModelDoc.java
index b3898bb7..70569110 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/GetDOMModelDoc.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/GetDOMModelDoc.java
@@ -34,6 +34,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
+import gov.nasa.pds.model.plugin.util.Utility;
/**
* Driver for getting document
@@ -86,7 +87,7 @@ public void getModels(String docFileName) throws Throwable {
lobjectid.getProtPinsGlossary(modelId, DMDocument.dataDirPath + lModelInfo.filename);
}
}
- DMDocument.registerMessage("0>info " + "GetDOMModelDoc Done");
+ Utility.registerMessage("0>info " + "GetDOMModelDoc Done");
}
/**********************************************************************************************************
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ISO11179DOMMDR.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ISO11179DOMMDR.java
index 4f5a50da..5e511a28 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ISO11179DOMMDR.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ISO11179DOMMDR.java
@@ -35,6 +35,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.TreeMap;
+import gov.nasa.pds.model.plugin.util.Utility;
class ISO11179DOMMDR extends Object {
TreeMap hashCodedPersmissibleValueMap;
@@ -175,7 +176,7 @@ public void OverwriteFrom11179DataDict() {
} else {
if (lAttr.title.compareTo("%3ANAME") != 0) {
if (! DOMInfoModel.isAttInactive (lAttr.identifier)) {
- DMDocument.registerMessage("1>error " + "11179 data dictionary attribute is missing for overwrite - Identifier:" + lInstId);
+ Utility.registerMessage("1>error " + "11179 data dictionary attribute is missing for overwrite - Identifier:" + lInstId);
}
}
}
@@ -394,7 +395,7 @@ public void OverwriteClassFrom11179DataDict() {
lDOMClass.setIsInactive(true);
if (lDOMClass.title.compareTo("USER") != 0) {
if (! DOMInfoModel.isAttInactive (lDOMClass.identifier)) {
- DMDocument.registerMessage("1>error " + "11179 data dictionary class is missing for overwrite - Identifier:" + lInstId);
+ Utility.registerMessage("1>error " + "11179 data dictionary class is missing for overwrite - Identifier:" + lInstId);
}
}
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/LDDDOMParser.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/LDDDOMParser.java
index 1a621291..ccdb2d2a 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/LDDDOMParser.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/LDDDOMParser.java
@@ -47,6 +47,7 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
+import gov.nasa.pds.model.plugin.util.Utility;
/**
* Parses an XML document - Local_DD
@@ -151,32 +152,32 @@ public LDDDOMParser() {
public void getLocalDD() throws java.io.IOException {
// parse the xml file and get the dom object
parseXmlFile(gSchemaFileDefn);
- DMDocument.registerMessage("0>info getLocalDD.parseXmlFile() Done");
+ Utility.registerMessage("0>info getLocalDD.parseXmlFile() Done");
// process the dom document for classes, attributes, etc
parseDocument(gSchemaFileDefn);
- DMDocument.registerMessage("0>info getLocalDD.parseDocument() Done");
+ Utility.registerMessage("0>info getLocalDD.parseDocument() Done");
}
public void getLocalDDPhase2() {
// resolve component references (cross namespace DD_Association references)
resolveComponentsReferences(gSchemaFileDefn);
- DMDocument.registerMessage("0>info resolveComponentsReferences() Done");
+ Utility.registerMessage("0>info resolveComponentsReferences() Done");
// validate parsed header
validateParsedHeader(gSchemaFileDefn);
- DMDocument.registerMessage("0>info getLocalDD.validateParsedHeader() Done");
+ Utility.registerMessage("0>info getLocalDD.validateParsedHeader() Done");
}
public void getLocalDDPhase3() {
// add the LDD artifacts to the master
addLDDtoMaster();
- DMDocument.registerMessage("0>info getLocalDD.addLDDtoMaster() Done");
+ Utility.registerMessage("0>info getLocalDD.addLDDtoMaster() Done");
validateNoNestedExposedClasses();
- DMDocument.registerMessage("0>info getLocalDD.validateNoNestedExposedClasses() Done");
+ Utility.registerMessage("0>info getLocalDD.validateNoNestedExposedClasses() Done");
- DMDocument.registerMessage("0>info getLocalDD Done");
+ Utility.registerMessage("0>info getLocalDD Done");
}
private void parseXmlFile(SchemaFileDefn lSchemaFileDefn) {
@@ -225,13 +226,13 @@ private void parseDocument(SchemaFileDefn lSchemaFileDefn) {
// default - set settings to the pds configuration setting if the namespace is not found in
// config file
lConfigSchemaFileDefn = DMDocument.masterPDSSchemaFileDefn;
- DMDocument.registerMessage(
+ Utility.registerMessage(
"2>warning Init: " + " - Config.Properties Namespace Id Not Found:" + lNameSpaceIdNC);
} else {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"2>info Init: " + " - Config.Properties Namespace Id Found:" + lNameSpaceIdNC);
}
- DMDocument.registerMessage("2>info Init: " + " - Config.Properties Namespace Id Using:"
+ Utility.registerMessage("2>info Init: " + " - Config.Properties Namespace Id Using:"
+ lConfigSchemaFileDefn.identifier);
// finally set namespace id and add this LDD to LDDSchemaFileSortMap
@@ -257,20 +258,20 @@ private void parseDocument(SchemaFileDefn lSchemaFileDefn) {
if (ldictionaryType.compareTo("Common") == 0) {
lSchemaFileDefn.setDictionaryType("Discipline");
DMDocument.LDDToolSingletonClassTitle = "Discipline_Area";
- DMDocument.registerMessage("2>warning Init: " + " - LDD Dictionary_Type Found:"
+ Utility.registerMessage("2>warning Init: " + " - LDD Dictionary_Type Found:"
+ ldictionaryType + " Defaulting to Discipline");
} else if (ldictionaryType.compareTo("Discipline") == 0) {
lSchemaFileDefn.setDictionaryType("Discipline");
DMDocument.LDDToolSingletonClassTitle = "Discipline_Area";
- DMDocument.registerMessage("2>info Init: " + " - LDD Dictionary_Type is " + ldictionaryType);
+ Utility.registerMessage("2>info Init: " + " - LDD Dictionary_Type is " + ldictionaryType);
} else if (ldictionaryType.compareTo("Mission") == 0) {
lSchemaFileDefn.setDictionaryType("Mission");
DMDocument.LDDToolSingletonClassTitle = "Mission_Area";
- DMDocument.registerMessage("2>info Init: " + " - LDD Dictionary_Type is " + ldictionaryType);
+ Utility.registerMessage("2>info Init: " + " - LDD Dictionary_Type is " + ldictionaryType);
} else {
lSchemaFileDefn.setDictionaryType("Discipline");
DMDocument.LDDToolSingletonClassTitle = "Discipline_Area";
- DMDocument.registerMessage("2>error Init: " + " - LDD Dictionary_Type not Found:"
+ Utility.registerMessage("2>error Init: " + " - LDD Dictionary_Type not Found:"
+ ldictionaryType + " Defaulting to Discipline");
}
@@ -310,57 +311,57 @@ private void parseDocument(SchemaFileDefn lSchemaFileDefn) {
// get the LDD attributes
getAttributes(lSchemaFileDefn, docEle);
- DMDocument.registerMessage("0>info getLocalDD.parseDocument.getAttributes() Done");
+ Utility.registerMessage("0>info getLocalDD.parseDocument.getAttributes() Done");
// get the LDD attributes Extended
getAttributesExtended (lSchemaFileDefn, docEle);
- DMDocument.registerMessage ("0>info getLocalDD.parseDocument.getAttributesExtended() Done");
+ Utility.registerMessage ("0>info getLocalDD.parseDocument.getAttributesExtended() Done");
// get the LDD classes
getClass(lSchemaFileDefn, docEle);
- DMDocument.registerMessage("0>info getLocalDD.parseDocument.getClass() Done");
+ Utility.registerMessage("0>info getLocalDD.parseDocument.getClass() Done");
// get the LDD rules
getRule(lSchemaFileDefn, docEle);
- DMDocument.registerMessage("0>info getLocalDD.parseDocument.getRule() Done");
+ Utility.registerMessage("0>info getLocalDD.parseDocument.getRule() Done");
// get the LDD property map
getPropMap(docEle);
- DMDocument.registerMessage("0>info getLocalDD.parseDocument.getPropMap() Done");
+ Utility.registerMessage("0>info getLocalDD.parseDocument.getPropMap() Done");
}
private void resolveComponentsReferences(SchemaFileDefn lSchemaFileDefn) {
// get the component for the LDD association
resolveComponentsForAssociation(lSchemaFileDefn);
- DMDocument
+ Utility
.registerMessage("0>info getLocalDD.parseDocument.resolveComponentsForAssociation() Done");
// scan DD_Rule to determine if any external namespaces are referenced
scanRulesForExternalNamespaces(lSchemaFileDefn);
- DMDocument
+ Utility
.registerMessage("0>info getLocalDD.parseDocument.scanRulesForExternalNamespaces() Done");
validateReservedNames(lSchemaFileDefn);
- DMDocument.registerMessage("0>info getLocalDD.parseDocument.validateReservedNames() Done");
+ Utility.registerMessage("0>info getLocalDD.parseDocument.validateReservedNames() Done");
validateAttributeUsed();
- DMDocument.registerMessage("0>info getLocalDD.parseDocument.validateAttributeUsed() Done");
+ Utility.registerMessage("0>info getLocalDD.parseDocument.validateAttributeUsed() Done");
validateNoDuplicateNames();
- DMDocument.registerMessage("0>info parseDocument.validateNoDuplicateNames() Done");
+ Utility.registerMessage("0>info parseDocument.validateNoDuplicateNames() Done");
validateTypeAttributes(lSchemaFileDefn.isMission);
- DMDocument.registerMessage("0>info parseDocument.validateTypeAttributes() Done");
+ Utility.registerMessage("0>info parseDocument.validateTypeAttributes() Done");
validateNoUnitsAttributes();
- DMDocument.registerMessage("0>info parseDocument.validateNoUnitsAttributes() Done");
+ Utility.registerMessage("0>info parseDocument.validateNoUnitsAttributes() Done");
validateNilRequiredAttributes();
- DMDocument.registerMessage("0>info parseDocument.validateNilRequiredAttributes() Done");
+ Utility.registerMessage("0>info parseDocument.validateNilRequiredAttributes() Done");
validateEnumeratedFlags();
- DMDocument.registerMessage("0>info parseDocument.validateEnumeratedFlags() Done");
+ Utility.registerMessage("0>info parseDocument.validateEnumeratedFlags() Done");
}
private void printClassDebug(String lLable, String lIdentifier) {
@@ -613,7 +614,7 @@ private void getTermEntry(Object lObject, Element docEle) {
lTermEntry.isPreferred = true;
}
} else {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"2>error Terminological Entry: " + "The attribute is missing.");
}
}
@@ -661,7 +662,7 @@ private TreeMap getTermEntryQueryModel(String lClassN
termEntryQueryModelMap.put(termEntryId, lTermEntryQMObject);
} else {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"2>error Terminological Entry: " + "The attribute is missing.");
}
}
@@ -825,7 +826,7 @@ private void getAssociations(SchemaFileDefn lSchemaFileDefn, DOMClass lDOMClass,
if (lLocalIdentifierArr.size() == 0) {
lLocalIdentifierArr = getXMLValueArr("local_identifier", lAssocElem); // old identifier reference
if (lLocalIdentifierArr.size() == 0) {
- DMDocument.registerMessage("2>error Association - Reference_Type: " + lReferenceType
+ Utility.registerMessage("2>error Association - Reference_Type: " + lReferenceType
+ " - No identifiers were provided for this association.");
continue;
}
@@ -839,12 +840,12 @@ private void getAssociations(SchemaFileDefn lSchemaFileDefn, DOMClass lDOMClass,
} else if ((lReferenceType.compareTo("parent_of") == 0)) {
lIsAttribute = false;
if (lLocalIdentifierArr.size() != 1) {
- DMDocument.registerMessage("2>error Association: " + lLocalIdentifier
+ Utility.registerMessage("2>error Association: " + lLocalIdentifier
+ " - The reference_type 'parent_of' is allowed only one parent");
continue;
}
} else {
- DMDocument.registerMessage("2>error Association: " + lLocalIdentifier
+ Utility.registerMessage("2>error Association: " + lLocalIdentifier
+ " - Invalid reference type: " + lReferenceType);
continue;
}
@@ -1035,13 +1036,13 @@ private void get_Class_Attr_Prop_DD_Associate_External_Class_Query_Model(DOMClas
if (lDOMPropExternal != null) {
finishInitDOMAttr(lDOMAttrExt, lDOMAttrExternal, lDOMPropExternal);
} else {
- DMDocument.registerMessage("2>error Association: " + lDOMAttrExternalId
+ Utility.registerMessage("2>error Association: " + lDOMAttrExternalId
+ " - Could not find referenced property - Query Model 1");
}
} else // *** for qmsre process, when referencing external namespaces, e.g., msn, the attributes
// are not present locally. Need some other solution. ***
if (lSchemaFileDefn.nameSpaceIdNC.compareTo("qmsre") != 0) {
- DMDocument.registerMessage("2>error Association: " + lDOMAttrExternalId
+ Utility.registerMessage("2>error Association: " + lDOMAttrExternalId
+ " - Could not find referenced attribute - Query Model 2");
}
@@ -1630,7 +1631,7 @@ private void resolveComponentsForAssociation(SchemaFileDefn lSchemaFileDefn) {
// *** for qmsre process, when referencing external namespaces, e.g., msn, the attributes
// are not present locally. Need some other solution. ***
if (lSchemaFileDefn.nameSpaceIdNC.compareTo("qmsre") != 0) {
- DMDocument.registerMessage("2>error Association: " + lDOMProp.localIdentifier
+ Utility.registerMessage("2>error Association: " + lDOMProp.localIdentifier
+ " - Could not find referenced attribute - Reference Type: "
+ lDOMProp.referenceType);
}
@@ -1694,7 +1695,7 @@ private void resolveComponentsForAssociation(SchemaFileDefn lSchemaFileDefn) {
lDOMClass.ownedAttrAssocNSTitleArr.add(lDOMProp.nsTitle);
}
} else {
- DMDocument.registerMessage("2>error Association: " + lDOMProp.localIdentifier
+ Utility.registerMessage("2>error Association: " + lDOMProp.localIdentifier
+ " - Missing Component - Reference Type: " + lDOMProp.referenceType);
}
@@ -1708,7 +1709,7 @@ private void resolveComponentsForAssociation(SchemaFileDefn lSchemaFileDefn) {
lDOMClass.subClassOfIdentifier = lDOMParentClass.identifier;
lDOMClass.subClassOf = lDOMParentClass;
} else {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"2>error Association: " + lDOMProp.identifier + " - Missing Class: "
+ lDOMProp.localIdentifier + " - Reference Type: " + lDOMProp.referenceType);
}
@@ -1792,7 +1793,7 @@ private DOMAttr getLocalOrExternAttr(SchemaFileDefn lSchemaFileDefn, DOMClass lD
// *** for qmsre process, when referencing external namespaces, e.g., msn, the attributes
// are not present locally. Need some other solution. ***
if (lSchemaFileDefn.nameSpaceIdNC.compareTo("qmsre") != 0) {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"2>error Class:" + lDOMClass.identifier + " Association:" + lDOMProp.localIdentifier
+ " Attribute: " + lLocalIdentifier + " - Missing Attribute");
}
@@ -1809,13 +1810,16 @@ private DOMAttr getLocalOrExternAttr(SchemaFileDefn lSchemaFileDefn, DOMClass lD
// validate that referenced attribute is exposed
// 555 commented out until DDWG approves impact of the fix
-// if (lDOMAttr.nameSpaceIdNC.compareTo("pds") == 0 && ! lDOMAttr.isExposed) {
-// if (lDOMAttr.isEnumerated) {
-// DMDocument.registerMessage("2>warning Attribute: " + " - The referenced enumerated attribute " + lLocalIdentifier + " is not exposed.");
-// } else {
-// DMDocument.registerMessage("2>warning Attribute: " + " - The referenced attribute " + lLocalIdentifier + " is not exposed.");
-// }
-// }
+ // if (lDOMAttr.nameSpaceIdNC.compareTo("pds") == 0 && ! lDOMAttr.isExposed) {
+ // if (lDOMAttr.isEnumerated) {
+ // DMDocument.registerMessage("2>warning Attribute: " + " - The referenced enumerated attribute
+ // " + lLocalIdentifier + " is not exposed.");
+ // } else {
+ // DMDocument.registerMessage("2>warning Attribute: " + " - The referenced attribute " +
+ // lLocalIdentifier + " is not exposed.");
+ // }
+ // }
+
// clone the USER or LDD attribute for use as a Resolved attribute
// returns rdfIdentifier = "TBD_rdfIdentifier"
@@ -1875,7 +1879,7 @@ private DOMClass getLocalOrExtrnCompClass(SchemaFileDefn lSchemaFileDefn, DOMCla
lLDDValArrExtUpdDefnClassMap.put(lLocalIdentifier, lComponentDOMClass.title);
return lComponentDOMClass;
}
- DMDocument.registerMessage("2>error Class:" + lDOMClass.identifier + " Association:"
+ Utility.registerMessage("2>error Class:" + lDOMClass.identifier + " Association:"
+ lDOMProp.localIdentifier + " Class:" + lLocalIdentifier + " - Missing Component Class");
return null;
}
@@ -1905,7 +1909,7 @@ private DOMClass getLocalOrExtrnParentClass(SchemaFileDefn lSchemaFileDefn, DOMC
}
return lParentDOMClass;
}
- DMDocument.registerMessage("2>error Class:" + lDOMClass.identifier + " Association:"
+ Utility.registerMessage("2>error Class:" + lDOMClass.identifier + " Association:"
+ lDOMProp.localIdentifier + " Class:" + lLocalIdentifier + " - Missing Parent Class");
return null;
}
@@ -1966,12 +1970,12 @@ private void validateReservedNames(SchemaFileDefn lSchemaFileDefn) {
// the value of the attribute local_identifier is irrelevant even if it is a reference to a
// foreign namespace
if (DMDocument.reservedClassNames.contains(lDOMClass.title)) {
- DMDocument.registerMessage("2>error Class: "
+ Utility.registerMessage("2>error Class: "
+ " - No local dictionary may define a class called " + lDOMClass.title + ".");
}
Character lFirstChar = lDOMClass.title.charAt(0);
if (!Character.isUpperCase(lFirstChar)) {
- DMDocument.registerMessage("2>error Class: " + " - The class " + lDOMClass.title
+ Utility.registerMessage("2>error Class: " + " - The class " + lDOMClass.title
+ " must begin with an upper case letter.");
}
@@ -1982,7 +1986,7 @@ private void validateReservedNames(SchemaFileDefn lSchemaFileDefn) {
}
if ((!hasAtLeastOneElementDefined) && numClasses > 0) {
- DMDocument.registerMessage(lSchemaFileDefn.nameSpaceIdNCLC, "2>error NameSpaceId:"
+ Utility.registerMessage(lSchemaFileDefn.nameSpaceIdNCLC, "2>error NameSpaceId:"
+ lSchemaFileDefn.nameSpaceId
+ " - At least one class must be defined as an xs:Element. ( set to \"true\")");
} else {
@@ -1994,13 +1998,13 @@ private void validateReservedNames(SchemaFileDefn lSchemaFileDefn) {
DOMAttr lDOMAttr = i.next();
if (DMDocument.reservedAttrNames.contains(lDOMAttr.title)) {
- DMDocument.registerMessage("2>error Attribute: "
+ Utility.registerMessage("2>error Attribute: "
+ " - No local dictionary may define an attribute called " + lDOMAttr.title + ".");
}
Character lFirstChar = lDOMAttr.title.charAt(0);
if (!Character.isLowerCase(lFirstChar)) {
- DMDocument.registerMessage("2>error Attribute: " + " - The attribute " + lDOMAttr.title
+ Utility.registerMessage("2>error Attribute: " + " - The attribute " + lDOMAttr.title
+ " must begin with a lower case letter.");
}
}
@@ -2027,7 +2031,7 @@ private void validateReservedNames(SchemaFileDefn lSchemaFileDefn) {
}
}
if (!foundReferenceTypeDef) {
- DMDocument.registerMessage("2>error Class: "
+ Utility.registerMessage("2>error Class: "
+ " - At least one value for pds:local_reference_type or pds:reference_type must be defined for "
+ lRuleXPath + ".");
}
@@ -2074,7 +2078,7 @@ private void validateAttributeUsed() {
// DMDocument.registerMessage ("2>warning Attribute: <" +
// (attrMapLocal.get(lAttrLocalIdentifier)).title + "> - This local attribute was not used in
// an Association.");
- DMDocument.registerMessage("2>warning Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>warning Attribute: <" + lDOMAttr.title
+ "> - This local attribute was not used in an Association.");
}
return;
@@ -2088,7 +2092,7 @@ private void validateNoDuplicateNames() {
for (Iterator i = classArr.iterator(); i.hasNext();) {
DOMClass lDOMClass = i.next();
if (lNameArr.contains(lDOMClass.title)) {
- DMDocument.registerMessage("2>warning Class: <" + lDOMClass.title
+ Utility.registerMessage("2>warning Class: <" + lDOMClass.title
+ "> - The class name is duplicated in this local data dictionary.");
} else {
lNameArr.add(lDOMClass.title);
@@ -2099,7 +2103,7 @@ private void validateNoDuplicateNames() {
for (Iterator i = attrArr.iterator(); i.hasNext();) {
DOMAttr lDOMAttr = i.next();
if (lNameArr.contains(lDOMAttr.title)) {
- DMDocument.registerMessage("2>warning Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>warning Attribute: <" + lDOMAttr.title
+ "> - The attribute name is duplicated in this local data dictionary.");
} else {
lNameArr.add(lDOMAttr.title);
@@ -2117,12 +2121,12 @@ private void validateTypeAttributes(boolean isMission) {
|| lDOMAttr.title.compareTo("type") == 0) {
if (lDOMAttr.domPermValueArr.size() < 1) {
if (isMission) {
- DMDocument.registerMessage("2>warning Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>warning Attribute: <" + lDOMAttr.title
+ "> - The 'type' attribute must have at least one permissible value.");
} else {
// DMDocument.registerMessage ("2>error Attribute: <" + lDOMAttr.title + "> - The 'type'
// attribute must have at least one permissible value.");
- DMDocument.registerMessage("2>warning Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>warning Attribute: <" + lDOMAttr.title
+ "> - The 'type' attribute must have at least one permissible value.");
}
}
@@ -2138,7 +2142,7 @@ private void validateEnumeratedFlags() {
DOMAttr lDOMAttr = i.next();
if (lDOMAttr.isEnumerated) {
if (lDOMAttr.domPermValueArr.isEmpty()) {
- DMDocument.registerMessage("2>warning Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>warning Attribute: <" + lDOMAttr.title
+ "> - An attribute with the enumeration_flag = true must have at least one permissible value.");
} else {
// DMDocument.registerMessage ("2>warning Attribute: <" + lDOMAttr.title + "> - An
@@ -2148,7 +2152,7 @@ private void validateEnumeratedFlags() {
// DMDocument.registerMessage ("2>warning Attribute: <" + lDOMAttr.title + "> - An attribute
// with the enumeration_flag = false - NO Problem");
} else {
- DMDocument.registerMessage("2>warning Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>warning Attribute: <" + lDOMAttr.title
+ "> - An attribute with the enumeration_flag = false must not have any permissible values.");
}
}
@@ -2172,7 +2176,7 @@ private void validateNoUnitsAttributes() {
foundFlag = true;
}
if (foundFlag) {
- DMDocument.registerMessage("2>warning Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>warning Attribute: <" + lDOMAttr.title
+ "> - The terms 'unit', 'units', 'unit_of_measure' should not be used as the rightmost part of an attribute's name.");
}
}
@@ -2198,7 +2202,7 @@ private void validateNilRequiredAttributes() {
}
}
if (!foundFlag) {
- DMDocument.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ "> - A 'nillable' attribute was found that is not a required attribute in at least one class.");
}
}
@@ -2227,7 +2231,7 @@ private void checkAllSubclasses(DOMClass lClass) {
if (lDOMProp.hasDOMObject != null && lDOMProp.hasDOMObject instanceof DOMClass) {
DOMClass lCompClass = (DOMClass) lDOMProp.hasDOMObject;
if (lCompClass.isExposed) {
- DMDocument.registerMessage("2>warning Class: <" + lCompClass.title
+ Utility.registerMessage("2>warning Class: <" + lCompClass.title
+ "> - An exposed class was found nested within another exposed class. Nested exposed classes should only be present if there is a specific requirement to expose the additional class.");
}
checkAllSubclasses(lCompClass);
@@ -2301,11 +2305,11 @@ private void addLDDtoMaster() {
DOMClass lDOMClass = i.next();
if (DOMInfoModel.masterDOMClassIdMap.containsKey(lDOMClass.identifier)) {
// an ldd class is a duplicate of a master class; replace the master with the LDD version
- DMDocument.registerMessage(
+ Utility.registerMessage(
"2>warning Found duplicate class - lClass.identifier:" + lDOMClass.identifier);
if (DOMInfoModel.masterDOMClassMap.containsKey(lDOMClass.rdfIdentifier)) {
DOMInfoModel.masterDOMClassMap.remove(lDOMClass.rdfIdentifier);
- DMDocument
+ Utility
.registerMessage("2>warning Found duplicate class - REPLACED - lClass.rdfIdentifier:"
+ lDOMClass.rdfIdentifier);
}
@@ -2338,14 +2342,14 @@ private void addLDDtoMaster() {
if (DOMInfoModel.masterDOMAttrIdMap.containsKey(lDOMAttr.identifier)) {
// an ldd attribute is a duplicate of a master attribute; replace the master with the LDD
// version
- DMDocument.registerMessage(
+ Utility.registerMessage(
"2>warning Found duplicate attribute - lDOMAttr.identifier:" + lDOMAttr.identifier);
if (DOMInfoModel.masterDOMAttrMap.containsKey(lDOMAttr.rdfIdentifier)) {
DOMInfoModel.masterDOMAttrMap.remove(lDOMAttr.rdfIdentifier);
- DMDocument.registerMessage(
+ Utility.registerMessage(
"2>warning Found duplicate attribute - REPLACED - lDOMAttr.rdfIdentifier:"
+ lDOMAttr.rdfIdentifier);
- DMDocument.registerMessage(
+ Utility.registerMessage(
"2>error Found duplicate attribute - REPLACED Failed - lDOMAttr.rdfIdentifier:"
+ lDOMAttr.rdfIdentifier);
}
@@ -2372,11 +2376,11 @@ private void addLDDtoMaster() {
if (DOMInfoModel.masterDOMPropIdMap.containsKey(lDOMProp.identifier)) {
// an ldd association is a duplicate of a master association; replace the master with the
// LDD version
- DMDocument.registerMessage(
+ Utility.registerMessage(
"2>warning Found duplicate attribute - lDOMProp.identifier:" + lDOMProp.identifier);
if (DOMInfoModel.masterDOMPropMap.containsKey(lDOMProp.rdfIdentifier)) {
DOMInfoModel.masterDOMPropMap.remove(lDOMProp.rdfIdentifier);
- DMDocument.registerMessage(
+ Utility.registerMessage(
"2>warning Found duplicate attribute - REPLACED - lDOMProp.rdfIdentifier:"
+ lDOMProp.rdfIdentifier);
}
@@ -2419,7 +2423,7 @@ private void addLDDtoMaster() {
lRule.setRDFIdentifier();
DOMInfoModel.masterDOMRuleMap.put(lRule.rdfIdentifier, lRule);
} else {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"2>warning Found duplicate attribute - lAttr.identifier:" + lRule.identifier);
}
}
@@ -2711,11 +2715,11 @@ public void printClass(DOMClass lDOMClass) {
private void validateParsedHeader(SchemaFileDefn lSchemaFileDefn) {
if (lRegAuthId.compareTo(DMDocument.registrationAuthorityIdentifierValue) != 0) {
- DMDocument
+ Utility
.registerMessage("2>error Header: " + " - Invalid Registration Authority: " + lRegAuthId);
}
if (lSchemaFileDefn.nameSpaceIdNC.compareTo("pds") == 0) {
- DMDocument.registerMessage("2>error Header: "
+ Utility.registerMessage("2>error Header: "
+ " - Master namespace is not allowed as a local data dictionary namespace:"
+ lSchemaFileDefn.nameSpaceIdNC);
}
@@ -2744,26 +2748,26 @@ private void validateAttribute(DOMAttr lDOMAttr) {
int numMatches = 0, maxMatches = 7;
DOMDataType lDOMDataType = DOMInfoModel.masterDOMDataTypeTitleMap.get(lDOMAttr.valueType);
if (lDOMDataType == null) {
- DMDocument.registerMessage("2>error Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>error Attribute: <" + lDOMAttr.title
+ "> - Invalid Data Type. Data Type: " + lDOMAttr.valueType);
} else {
if (lDOMAttr.minimum_value.indexOf("TBD") != 0) {
- DMDocument.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ "> - The default minimum value provided by the attribute's data type is being overridden with "
+ lDOMAttr.minimum_value);
}
if (lDOMAttr.maximum_value.indexOf("TBD") != 0) {
- DMDocument.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ "> - The default maximum value provided by the attribute's data type is being overridden with "
+ lDOMAttr.maximum_value);
}
if (lDOMAttr.minimum_characters.indexOf("TBD") != 0) {
- DMDocument.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ "> - The default minimum characters provided by the attribute's data type is being overridden with "
+ lDOMAttr.minimum_characters);
}
if (lDOMAttr.maximum_characters.indexOf("TBD") != 0) {
- DMDocument.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ "> - The default maximum characters provided by the attribute's data type is being overridden with "
+ lDOMAttr.maximum_characters);
}
@@ -2797,7 +2801,7 @@ private void validateAttribute(DOMAttr lDOMAttr) {
if (!(lDOMAttr.unit_of_measure_type.indexOf("TBD") == 0)) {
DOMUnit lUnit = DOMInfoModel.masterDOMUnitMap.get(lDOMAttr.unit_of_measure_type);
if (lUnit == null) {
- DMDocument.registerMessage("2>warning Attribute2 <: " + lDOMAttr.title
+ Utility.registerMessage("2>warning Attribute2 <: " + lDOMAttr.title
+ " - Invalid Unit of Measure Type: " + lDOMAttr.unit_of_measure_type);
}
}
@@ -2810,7 +2814,7 @@ private void validateAttribute(DOMAttr lDOMAttr) {
DOMAttr lMAttr = i.next();
// if (lMAttr.title.compareTo(lAttr.title) == 0) {
if ((!lMAttr.isFromLDD) && lMAttr.title.compareTo(lDOMAttr.title) == 0) {
- DMDocument.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ "> - This local attribute has a duplicate in the PDS4 data dictionary.");
isExact = true;
numMatches++;
@@ -2830,7 +2834,7 @@ public void validateAssociationCardinalities(String lMinCard, String lMaxCard,
} catch (NumberFormatException e) {
lCardMinI = 0;
lCardMin = "0";
- DMDocument.registerMessage("2>error Association: " + lLocalIdentifier
+ Utility.registerMessage("2>error Association: " + lLocalIdentifier
+ " - Minimum occurrences is invalid: " + lMinCard);
}
}
@@ -2846,12 +2850,12 @@ public void validateAssociationCardinalities(String lMinCard, String lMaxCard,
} catch (NumberFormatException e) {
lCardMaxI = 0;
lCardMax = "0";
- DMDocument.registerMessage("2>error Association: " + lLocalIdentifier
+ Utility.registerMessage("2>error Association: " + lLocalIdentifier
+ " - Maximum occurrences is invalid: " + lMaxCard);
}
}
if (lCardMaxI < lCardMinI) {
- DMDocument.registerMessage("2>error Association: " + lLocalIdentifier
+ Utility.registerMessage("2>error Association: " + lLocalIdentifier
+ " - Maximum occurrences is less than minimum occurrences");
}
}
@@ -2893,7 +2897,7 @@ private void getPartialMatches(DOMAttr lDOMAttr, int numMatches, int maxMatches)
String lTitleUpper = lMAttr.title.toUpperCase();
if (lTitleUpper.indexOf(lClassWord) > -1) {
if (lTitleUpper.indexOf(lDescriptor) > -1) {
- DMDocument.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ "> - PDS4 data dictionary attribute with similar name. - Matched attribute: <"
+ lMAttr.title + ">");
numMatches++;
@@ -2912,7 +2916,7 @@ private void getPartialMatches(DOMAttr lDOMAttr, int numMatches, int maxMatches)
}
String lTitleUpper = lMAttr.title.toUpperCase();
if (lTitleUpper.indexOf(lDescriptor) > -1) {
- DMDocument.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ Utility.registerMessage("2>info Attribute: <" + lDOMAttr.title
+ "> - PDS4 data dictionary attribute with similar name. - Matched attribute: <"
+ lMAttr.title + ">");
numMatches++;
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/MasterDOMInfoModel.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/MasterDOMInfoModel.java
index 11fee5ac..e0c3871e 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/MasterDOMInfoModel.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/MasterDOMInfoModel.java
@@ -36,6 +36,7 @@
import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;
+import gov.nasa.pds.model.plugin.util.Utility;
class MasterDOMInfoModel extends DOMInfoModel {
static String attrNameClassWord;
@@ -99,11 +100,11 @@ public void setAttrParentClass(boolean forLDD) {
if (classNotFound) {
classNotFound = false;
lAttr.attrParentClass = lParentClass;
- DMDocument.registerMessage("1>warning "
+ Utility.registerMessage("1>warning "
+ "set attributes parent class - lAttr.identifier:" + lAttr.identifier
+ " - using first found - lClassMember.identifier:" + lParentClass.identifier);
} else {
- DMDocument.registerMessage("1>warning "
+ Utility.registerMessage("1>warning "
+ "set attributes parent class - lAttr.identifier:" + lAttr.identifier
+ " - also found - lClassMember.identifier:" + lParentClass.identifier);
}
@@ -111,7 +112,7 @@ public void setAttrParentClass(boolean forLDD) {
}
if (classNotFound) {
lAttr.attrParentClass = DOMInfoModel.masterDOMUserClass;
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>warning " + "set attributes parent class - lAttr.identifier:" + lAttr.identifier
+ " - parent class not found, using USER - lClassMember.identifier:"
+ lParentClass.identifier);
@@ -218,7 +219,7 @@ public void getSubClassOf() {
lClass.subClassOfTitle = lSupClass.title;
lClass.subClassOfIdentifier = lSupClass.identifier;
} else {
- DMDocument.registerMessage("1>error "
+ Utility.registerMessage("1>error "
+ "missing superClass in master while trying to set subClassOf - lClass.identifier:"
+ lClass.identifier + " - lClass.subClassOfTitle:" + lClass.subClassOfTitle);
}
@@ -241,7 +242,7 @@ public void getSuperClassHierArr() {
// recurse up the subClassOf chain, getting the super class array
while (lSuperClass != null && !lSuperClass.isUSERClass) {
if (lSuperClassArr.contains(lSuperClass)) {
- DMDocument.registerMessage("1>error "
+ Utility.registerMessage("1>error "
+ "Found cycle in superclass hierarchy - SuperClass.title:" + lSuperClass.title);
break;
}
@@ -296,7 +297,7 @@ public void getSuperClassHierArr() {
// init the class hierarchy levels array (classes higher in in the tree are first)
lClassHierLevelsArr = new ArrayList<>(lClassHierLevelsMap.values());
- DMDocument.registerMessage("0>info " + "getAttrAssocArr Done");
+ Utility.registerMessage("0>info " + "getAttrAssocArr Done");
}
// 012 - remove URI Attribute
@@ -806,78 +807,78 @@ private boolean isRestrictedAttribute(boolean isAttribute, DOMAttr lAttr, DOMAtt
}
if (lAttr.valueType.compareTo(lSuperAttr.valueType) != 0) {
- DMDocument.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.valueType:"
+ Utility.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.valueType:"
+ lSuperAttr.valueType + " lSuperAttr.rdfIdentifier:" + lSuperAttr.rdfIdentifier);
return true;
}
if (lAttr.cardMin.compareTo(lSuperAttr.cardMin) != 0) {
- DMDocument.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.cardMin:"
+ Utility.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.cardMin:"
+ lSuperAttr.cardMin + " lSuperAttr.rdfIdentifier:" + lSuperAttr.rdfIdentifier);
return true;
}
if (lAttr.cardMax.compareTo(lSuperAttr.cardMax) != 0) {
- DMDocument.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.cardMax:"
+ Utility.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.cardMax:"
+ lSuperAttr.cardMax + " lSuperAttr.rdfIdentifier:" + lSuperAttr.rdfIdentifier);
return true;
}
if (lAttr.definition.compareTo(lSuperAttr.definition) != 0) {
- DMDocument.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.description:"
+ Utility.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.description:"
+ lSuperAttr.definition + " lSuperAttr.rdfIdentifier:" + lSuperAttr.rdfIdentifier);
return true;
}
if (lAttr.minimum_characters.compareTo(lSuperAttr.minimum_characters) != 0) {
- DMDocument.registerMessage("1>warning "
+ Utility.registerMessage("1>warning "
+ "isRestrictedAttribute lSuperAttr.minimum_characters:" + lSuperAttr.minimum_characters
+ " lSuperAttr.rdfIdentifier:" + lSuperAttr.rdfIdentifier);
return true;
}
if (lAttr.maximum_characters.compareTo(lSuperAttr.maximum_characters) != 0) {
- DMDocument.registerMessage("1>warning "
+ Utility.registerMessage("1>warning "
+ "isRestrictedAttribute lSuperAttr.maximum_characters:" + lSuperAttr.maximum_characters
+ " lSuperAttr.rdfIdentifier:" + lSuperAttr.rdfIdentifier);
return true;
}
if (lAttr.minimum_value.compareTo(lSuperAttr.minimum_value) != 0) {
- DMDocument.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.minimum_value:"
+ Utility.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.minimum_value:"
+ lSuperAttr.minimum_value + " lSuperAttr.rdfIdentifier:" + lSuperAttr.rdfIdentifier);
return true;
}
if (lAttr.maximum_value.compareTo(lSuperAttr.maximum_value) != 0) {
- DMDocument.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.maximum_value:"
+ Utility.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.maximum_value:"
+ lSuperAttr.maximum_value + " lSuperAttr.rdfIdentifier:" + lSuperAttr.rdfIdentifier);
return true;
}
if (lAttr.nameSpaceIdNC.compareTo(lSuperAttr.nameSpaceIdNC) != 0) {
- DMDocument.registerMessage("1>warning "
+ Utility.registerMessage("1>warning "
+ "isRestrictedAttribute lSuperAttr.attrNameSpaceIdNC:" + lSuperAttr.nameSpaceIdNC
+ " lSuperAttr.rdfIdentifier:" + lSuperAttr.rdfIdentifier);
return true;
}
if (lAttr.pattern.compareTo(lSuperAttr.pattern) != 0) {
- DMDocument.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.pattern:"
+ Utility.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.pattern:"
+ lSuperAttr.pattern + " lSuperAttr.rdfIdentifier:" + lSuperAttr.rdfIdentifier);
return true;
}
if (lAttr.default_unit_id.compareTo(lSuperAttr.default_unit_id) != 0) {
- DMDocument.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.default_unit_id:"
+ Utility.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.default_unit_id:"
+ lSuperAttr.default_unit_id + " lSuperAttr.rdfIdentifier:" + lSuperAttr.rdfIdentifier);
return true;
}
if (lAttr.format.compareTo(lSuperAttr.format) != 0) {
- DMDocument.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.format:"
+ Utility.registerMessage("1>warning " + "isRestrictedAttribute lSuperAttr.format:"
+ lSuperAttr.format + " lSuperAttr.rdfIdentifier:" + lSuperAttr.rdfIdentifier);
return true;
}
if (!isAttribute) { // if association we need to check the standard values.
if (lAttr.valArr.size() != lSuperAttr.valArr.size()) {
- DMDocument.registerMessage("1>warning " + "isRestrictedAttribute lAttr.valArr.size():"
+ Utility.registerMessage("1>warning " + "isRestrictedAttribute lAttr.valArr.size():"
+ lAttr.valArr.size() + " lSuperAttr.rdfIdentifier:" + lSuperAttr.rdfIdentifier);
return true;
}
for (Iterator i = lAttr.valArr.iterator(); i.hasNext();) {
String lVal = i.next();
if (!lSuperAttr.valArr.contains(lVal)) {
- DMDocument.registerMessage("1>warning " + "isRestrictedAttribute lAttr.lVal" + lVal
+ Utility.registerMessage("1>warning " + "isRestrictedAttribute lAttr.lVal" + lVal
+ " lSuperAttr.rdfIdentifier:" + lSuperAttr.rdfIdentifier);
return true;
}
@@ -1333,11 +1334,11 @@ public void GetMasterDECMaps() {
+ "DD_Attribute_Full.pds.attribute_concept");
if (lAttr == null) {
- DMDocument.registerMessage("1>error " + "system attribute - attribute_concept - MISSING");
+ Utility.registerMessage("1>error " + "system attribute - attribute_concept - MISSING");
return;
}
if ((lAttr.valArr == null) || (lAttr.valArr.size() < 1)) {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>error " + "system attribute - attribute_concept - NO PERMISSIBLE VALUES");
return;
}
@@ -1357,11 +1358,11 @@ public void GetMasterCDMaps() {
+ "DD_Value_Domain_Full.pds.conceptual_domain");
if (lAttr == null) {
- DMDocument.registerMessage("1>error " + "system attribute - conceptual_domain - MISSING");
+ Utility.registerMessage("1>error " + "system attribute - conceptual_domain - MISSING");
return;
}
if ((lAttr.valArr == null) || (lAttr.valArr.size() < 1)) {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>error " + "system attribute - conceptual_domain - NO PERMISSIBLE VALUES");
return;
}
@@ -1385,10 +1386,10 @@ public void SetMasterAttrXMLBaseDataTypeFromDataType() {
if (lDataType != null) {
lAttr.xmlBaseDataType = lDataType.xml_schema_base_type;
} else {
- DMDocument.registerMessage("1>error "
+ Utility.registerMessage("1>error "
+ "SetMasterAttrXMLBaseDataTypeFromDataType - Data Type is missing - lAttr.identifier:"
+ lAttr.identifier);
- DMDocument.registerMessage("1>error "
+ Utility.registerMessage("1>error "
+ "SetMasterAttrXMLBaseDataTypeFromDataType - Data Type is missing - lAttr.valueType:"
+ lAttr.valueType);
}
@@ -1404,7 +1405,7 @@ public void sethasAttributeOverride1(ArrayList lMasterDOMAttrArr) {
if (lAttr.isAttribute) {
DOMDataType lValueType = DOMInfoModel.masterDOMDataTypeTitleMap.get(lAttr.valueType);
if (lValueType == null) {
- DMDocument.registerMessage("1>error "
+ Utility.registerMessage("1>error "
+ "Could not find a value type for this attribute while checking for attribute overrides - Name:"
+ lAttr.identifier + " Value Type:" + lAttr.valueType);
} else {
@@ -1514,7 +1515,7 @@ public void sethasAttributeOverride2(ArrayList lMasterDOMAttrArr) {
boolean isEquivalent = true;
if (lAttr1.valueType.compareTo(lAttr2.valueType) != 0) {
isEquivalent = false;
- DMDocument.registerMessage("1>error "
+ Utility.registerMessage("1>error "
+ "hasAttributeOverride2 - valueType is not equivalent - attribute identifier:"
+ lAttr2.identifier);
}
@@ -1541,13 +1542,13 @@ public void sethasAttributeOverride2(ArrayList lMasterDOMAttrArr) {
isEquivalentAll = true;
break;
}
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>warning " + "sethasAttributeOverride - attributes are not equivalent:"
+ lAttr1.identifier + " - " + lAttr2.identifier);
isEquivalentAll = isEquivalentAll && isEquivalent;
}
if (!isEquivalentAll) {
- DMDocument.registerMessage("1>error "
+ Utility.registerMessage("1>error "
+ "sethasAttributeOverride - attribute is not equivalent - Setting unique name - attribute identifier:"
+ lAttr1.identifier);
lAttr1.XMLSchemaName = lAttr1.parentClassTitle + "_" + lAttr1.title;
@@ -1580,11 +1581,11 @@ public void getValClassArr() {
if (lClassMember.title.compareTo(lTitle) == 0) {
if (firstClassFound == null) {
firstClassFound = lClassMember;
- DMDocument.registerMessage("1>warning "
+ Utility.registerMessage("1>warning "
+ "get class using attribute value array - lAttr.identifier:" + lProp.identifier
+ " - using first found - lClassMember.identifier:" + lClassMember.identifier);
} else {
- DMDocument.registerMessage("1>warning "
+ Utility.registerMessage("1>warning "
+ "get class using attribute value array - lAttr.identifier:" + lProp.identifier
+ " - also found - lClassMember.identifier:" + lClassMember.identifier);
}
@@ -1672,7 +1673,7 @@ public String getValueMeaning(DOMRule lRule, String lVal) {
// CheckDataTypes
public void CheckDataTypes() {
- DMDocument.registerMessage("0>info " + "CheckDataTypes");
+ Utility.registerMessage("0>info " + "CheckDataTypes");
TreeMap lTreeMap = new TreeMap<>();
for (Iterator i = DOMInfoModel.masterDOMAttrArr.iterator(); i.hasNext();) {
DOMAttr lAttr = i.next();
@@ -1684,21 +1685,21 @@ public void CheckDataTypes() {
String pTitle = "", pDataType = "", pRDFId = "";
for (Iterator j = lAttrArr.iterator(); j.hasNext();) {
DOMAttr lAttr = j.next();
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + "CheckDataTypes data types not equal - lAttr.title:" + lAttr.title);
if (lAttr.title.compareTo(pTitle) == 0) {
if (lAttr.valueType.compareTo(pDataType) == 0) {
continue;
}
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + "CheckDataTypes data types not equal - lAttr.title:" + lAttr.title);
- DMDocument
+ Utility
.registerMessage("0>info " + "CheckDataTypes data types not equal - pRDFId:" + pRDFId);
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + "CheckDataTypes data types not equal - pDataType:" + pDataType);
- DMDocument.registerMessage("0>info "
+ Utility.registerMessage("0>info "
+ "CheckDataTypes data types not equal - lAttr.rdfIdentifier:" + lAttr.rdfIdentifier);
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + "CheckDataTypes data types not equal - lAttr.valueType:" + lAttr.valueType);
} else {
pTitle = lAttr.title;
@@ -1743,7 +1744,7 @@ public void fixNameSpaces() {
* constraints would cause multiple simpleType definitions ***
*/
static public void checkSameNameOverRide() {
- DMDocument
+ Utility
.registerMessage("0>info " + "Checking for attribute consistency - checkSameNameOverRide");
// sort the attributes
@@ -1813,73 +1814,73 @@ static public void checkForOverRideDetail(DOMAttr lAttr1, DOMAttr lAttr2) {
if (lAttr1.valueType.compareTo(lAttr2.valueType) != 0) {
isFound = true;
- DMDocument.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.valueType:"
+ Utility.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.valueType:"
+ lAttr1.valueType + " lAttr2.valueType:" + lAttr2.valueType);
}
if (lAttr1.minimum_characters.compareTo(lAttr2.minimum_characters) != 0) {
isFound = true;
- DMDocument.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.minimum_characters:"
+ Utility.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.minimum_characters:"
+ lAttr1.minimum_characters + " lAttr2.minimum_characters:"
+ lAttr2.minimum_characters);
}
if (lAttr1.maximum_characters.compareTo(lAttr2.maximum_characters) != 0) {
isFound = true;
- DMDocument.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.maximum_characters:"
+ Utility.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.maximum_characters:"
+ lAttr1.maximum_characters + " lAttr2.maximum_characters:"
+ lAttr2.maximum_characters);
}
if (lAttr1.minimum_value.compareTo(lAttr2.minimum_value) != 0) {
isFound = true;
- DMDocument.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.minimum_value:"
+ Utility.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.minimum_value:"
+ lAttr1.minimum_value + " lAttr2.minimum_value:" + lAttr2.minimum_value);
}
if (lAttr1.maximum_value.compareTo(lAttr2.maximum_value) != 0) {
isFound = true;
- DMDocument.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.maximum_value:"
+ Utility.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.maximum_value:"
+ lAttr1.maximum_value + " lAttr2.maximum_value:" + lAttr2.maximum_value);
}
if (lAttr1.pattern.compareTo(lAttr2.pattern) != 0) {
isFound = true;
- DMDocument.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.pattern:"
+ Utility.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.pattern:"
+ lAttr1.pattern + " lAttr2.pattern:" + lAttr2.pattern);
}
if (lAttr1.default_unit_id.compareTo(lAttr2.default_unit_id) != 0) {
isFound = true;
- DMDocument.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.default_unit_id:"
+ Utility.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.default_unit_id:"
+ lAttr1.default_unit_id + " lAttr2.default_unit_id:" + lAttr2.default_unit_id);
}
if (lAttr1.format.compareTo(lAttr2.format) != 0) {
isFound = true;
- DMDocument.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.format:"
+ Utility.registerMessage("0>warning " + "checkForOverRideDetail lAttr1.format:"
+ lAttr1.format + " lAttr2.format:" + lAttr2.format);
}
if (isFound) {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + "checkForOverRideDetail lAttr1.identifier:" + lAttr1.identifier);
- DMDocument.registerMessage(
+ Utility.registerMessage(
"0>info " + "checkForOverRideDetail lAttr2.identifier:" + lAttr2.identifier);
- DMDocument.registerMessage("0>info ");
+ Utility.registerMessage("0>info ");
}
return;
}
static public void printOwnedAttrAssocArr(DOMClass lClass, String lTitle) {
- DMDocument.registerMessage("0>info " + "ownedAttrAssocArr - " + lTitle + " - "
+ Utility.registerMessage("0>info " + "ownedAttrAssocArr - " + lTitle + " - "
+ "lClass.identifier:" + lClass.identifier);
for (Iterator j = lClass.ownedAttrAssocArr.iterator(); j.hasNext();) {
DOMProp lProp = j.next();
- DMDocument.registerMessage("0>info " + " - lProp.classOrder:" + lProp.classOrder);
+ Utility.registerMessage("0>info " + " - lProp.classOrder:" + lProp.classOrder);
}
}
static public void printAllAttrAssocArr(DOMClass lClass, String lTitle) {
- DMDocument.registerMessage("0>info ");
- DMDocument.registerMessage("0>info " + "allAttrAssocArr - " + lTitle + " - "
+ Utility.registerMessage("0>info ");
+ Utility.registerMessage("0>info " + "allAttrAssocArr - " + lTitle + " - "
+ "lClass.identifier:" + lClass.identifier);
for (Iterator j = lClass.allAttrAssocArr.iterator(); j.hasNext();) {
DOMProp lProp = j.next();
- DMDocument.registerMessage("0>info " + " - lProp.identifier:" + lProp.identifier);
- DMDocument.registerMessage("0>info " + " - lProp.classOrder:" + lProp.classOrder);
+ Utility.registerMessage("0>info " + " - lProp.identifier:" + lProp.identifier);
+ Utility.registerMessage("0>info " + " - lProp.classOrder:" + lProp.classOrder);
}
}
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ProtFramesParser.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ProtFramesParser.java
index f0983294..e6c85476 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ProtFramesParser.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ProtFramesParser.java
@@ -35,6 +35,7 @@
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
+import gov.nasa.pds.model.plugin.util.Utility;
/**
* Parses a Protege Frames file (.pont or .pins) and creates an array of tokens. parse - open file,
@@ -71,9 +72,9 @@ public boolean parse(String fname) throws Throwable {
try {
PBReader = new InputStreamReader(new FileInputStream(new File(fname)), "UTF-8");
- DMDocument.registerMessage("0>info " + "Found required file: " + fname);
+ Utility.registerMessage("0>info " + "Found required file: " + fname);
} catch (Exception e) {
- DMDocument.registerMessage("3>error " + "Could not find required file: " + fname);
+ Utility.registerMessage("3>error " + "Could not find required file: " + fname);
return false;
}
if (!getTokens()) {
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ProtPinsDOMModel.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ProtPinsDOMModel.java
index 942f4451..41b4daed 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ProtPinsDOMModel.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/ProtPinsDOMModel.java
@@ -34,6 +34,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.TreeMap;
+import gov.nasa.pds.model.plugin.util.Utility;
/**
* Creates the in memory protege Upper pins model (e.g. Discipline Facets)
@@ -154,7 +155,7 @@ public void getProtPinsModel(String lRegAuthId, String fname) throws Throwable {
"Discipline_Facets", DMDocument.masterNameSpaceIdNCLC, "discipline_name");
DOMAttr lDOMAttrDiscipline = DOMInfoModel.masterDOMAttrIdMap.get(lAttrId);
if (lDOMAttrDiscipline == null) {
- DMDocument.registerMessage("1>error " + "Missing discipline_name - lAttrId:" + lAttrId);
+ Utility.registerMessage("1>error " + "Missing discipline_name - lAttrId:" + lAttrId);
return;
}
@@ -178,7 +179,7 @@ public void getProtPinsModel(String lRegAuthId, String fname) throws Throwable {
DMDocument.masterNameSpaceIdNCLC, "facet1");
DOMAttr lDOMAttrFacet1 = DOMInfoModel.masterDOMAttrIdMap.get(lAttrId);
if (lDOMAttrFacet1 == null) {
- DMDocument.registerMessage("1>error " + "Missing facet2 - lAttrId:" + lAttrId);
+ Utility.registerMessage("1>error " + "Missing facet2 - lAttrId:" + lAttrId);
continue;
}
lDOMAttrFacet1.isEnumerated = true;
@@ -200,7 +201,7 @@ public void getProtPinsModel(String lRegAuthId, String fname) throws Throwable {
DMDocument.masterNameSpaceIdNCLC, "facet2");
DOMAttr lDOMAttrFacet2 = DOMInfoModel.masterDOMAttrIdMap.get(lAttrId);
if (lDOMAttrFacet2 == null) {
- DMDocument.registerMessage("1>error " + "Missing facet2 - lAttrId:" + lAttrId);
+ Utility.registerMessage("1>error " + "Missing facet2 - lAttrId:" + lAttrId);
continue;
}
lDOMAttrFacet2.isEnumerated = true;
@@ -298,7 +299,7 @@ public void getRulesPins() {
lAssertDefn.testValArr = lValArr;
}
} else {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>error " + "getRulesPins - Assert Statement Not Found - lAssertId:" + lAssertId);
}
}
@@ -339,7 +340,7 @@ private String getValueSingleton(String lKey, HashMap>
return "TBD_" + lKey;
}
if (lValArr.size() > 1) {
- DMDocument.registerMessage("1>error " + "getSingletonValue - ProtPinsModel - lKey:" + lKey);
+ Utility.registerMessage("1>error " + "getSingletonValue - ProtPinsModel - lKey:" + lKey);
}
return lValArr.get(0);
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/SchemaFileDefn.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/SchemaFileDefn.java
index f6b2a045..6d908261 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/SchemaFileDefn.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/SchemaFileDefn.java
@@ -32,7 +32,7 @@
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Iterator;
+import gov.nasa.pds.model.plugin.util.Utility;
public class SchemaFileDefn {
// identifier is the namespace id, without colon, and in caps; it must be unique within the PDS
@@ -281,11 +281,12 @@ public void setVersionIds() {
// set the relative file spec now that we have a version id
relativeFileSpecModelSpec_DOM =
- DMDocument.outputDirPath + "index" + "_" + lab_version_id + ".html";
+ DMDocument.getOutputDirPath() + "index" + "_" + lab_version_id + ".html";
if (!isLDD) {
- relativeFileSpecXMLSchema = DMDocument.outputDirPath + "SchemaXML4/" + DMDocument.mastModelId
+ relativeFileSpecXMLSchema = DMDocument.getOutputDirPath() + "export/" + DMDocument.mastModelId
+ "_" + nameSpaceIdNCUC + "_" + lab_version_id + ".xsd";
- relativeFileSpecSchematron = DMDocument.outputDirPath + "SchemaXML4/" + DMDocument.mastModelId
+ relativeFileSpecSchematron =
+ DMDocument.getOutputDirPath() + "export/" + DMDocument.mastModelId
+ "_" + nameSpaceIdNCUC + "_" + lab_version_id + ".sch";
relativeFileNameXMLSchema =
DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_" + lab_version_id + ".xsd";
@@ -293,20 +294,20 @@ public void setVersionIds() {
+ lFileNameIMVersionId + "_" + lab_version_id + ".xsd";
relativeFileNameSchematron =
DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_" + lab_version_id + ".sch";
- relativeFileSpecXMLLabel = DMDocument.outputDirPath + "SchemaXML4/" + DMDocument.mastModelId
+ relativeFileSpecXMLLabel = DMDocument.getOutputDirPath() + "export/" + DMDocument.mastModelId
+ "_" + nameSpaceIdNCUC + "_" + lab_version_id + ".xml";
- relativeFileSpecDOMModelJSON = DMDocument.outputDirPath + "export/JSON/"
+ relativeFileSpecDOMModelJSON = DMDocument.getOutputDirPath() + "export/"
+ DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_" + lab_version_id + ".JSON";
- relativeFileSpecDDCSV = DMDocument.outputDirPath + "export/csv/" + DMDocument.mastModelId
+ relativeFileSpecDDCSV = DMDocument.getOutputDirPath() + "export/" + DMDocument.mastModelId
+ "_" + nameSpaceIdNCUC + "_" + lab_version_id;
- relativeFileSpecCCSDSCSV = DMDocument.outputDirPath + "export/csv/" + DMDocument.mastModelId
+ relativeFileSpecCCSDSCSV = DMDocument.getOutputDirPath() + "export/" + DMDocument.mastModelId
+ "_" + nameSpaceIdNCUC + "_CCSDS" + "_" + lab_version_id;
} else {
relativeFileSpecXMLSchema =
- DMDocument.outputDirPath + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.getOutputDirPath() + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.masterPDSSchemaFileDefn.lab_version_id + "_" + lab_version_id + ".xsd";
relativeFileSpecSchematron =
- DMDocument.outputDirPath + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.getOutputDirPath() + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.masterPDSSchemaFileDefn.lab_version_id + "_" + lab_version_id + ".sch";
relativeFileNameXMLSchema = DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.masterPDSSchemaFileDefn.lab_version_id + "_" + lab_version_id + ".xsd";
@@ -315,51 +316,54 @@ public void setVersionIds() {
relativeFileNameSchematron = DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.masterPDSSchemaFileDefn.lab_version_id + "_" + lab_version_id + ".sch";
relativeFileSpecXMLLabel =
- DMDocument.outputDirPath + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.getOutputDirPath() + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.masterPDSSchemaFileDefn.lab_version_id + "_" + lab_version_id + ".xml";
relativeFileSpecDOMModelJSON =
- DMDocument.outputDirPath + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.getOutputDirPath() + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.masterPDSSchemaFileDefn.lab_version_id + "_" + lab_version_id + ".JSON";
relativeFileSpecLDDPontMerge =
- DMDocument.outputDirPath + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.getOutputDirPath() + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.masterPDSSchemaFileDefn.lab_version_id + "_" + lab_version_id + ".pont";
relativeFileSpecReportTXT =
- DMDocument.outputDirPath + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.getOutputDirPath() + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.masterPDSSchemaFileDefn.lab_version_id + "_" + lab_version_id + ".txt";
relativeFileSpecDDCSV =
- DMDocument.outputDirPath + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.getOutputDirPath() + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.masterPDSSchemaFileDefn.lab_version_id + "_" + lab_version_id;
relativeFileSpecCCSDSCSV =
- DMDocument.outputDirPath + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.getOutputDirPath() + DMDocument.mastModelId + "_" + nameSpaceIdNCUC + "_"
+ DMDocument.masterPDSSchemaFileDefn.lab_version_id + "_CCSDS" + "_" + lab_version_id;
}
- relativeFileSpecDDDocXML = DMDocument.outputDirPath + "export/DD/" + DMDocument.mastModelId
+ relativeFileSpecDDDocXML = DMDocument.getOutputDirPath() + "export/" + DMDocument.mastModelId
+ "_" + nameSpaceIdNCUC + "_" + "DD" + "_" + lab_version_id + ".xml";
- relativeFileSpecDDProtPins = DMDocument.outputDirPath + "Model_DataDictionary/" + "dd11179_Gen_"
+ relativeFileSpecDDProtPins = DMDocument.getOutputDirPath() + "export/" + "dd11179_Gen_"
+ DMDocument.masterTodaysDateyymmdd + ".pins";
relativeFileSpecDDProtPinsSN =
- DMDocument.outputDirPath + "Model_DataDictionary/" + "dd11179_Gen" + ".pins";
- relativeFileSpecModelRDF = DMDocument.outputDirPath + "export/rdf/" + DMDocument.mastModelId
+ DMDocument.getOutputDirPath() + "export/" + "dd11179_Gen" + ".pins";
+ relativeFileSpecModelRDF = DMDocument.getOutputDirPath() + "export/" + DMDocument.mastModelId
+ "_" + nameSpaceIdNCUC + "_" + "MODEL" + "_" + lab_version_id + ".rdf";
- relativeFileSpecOWLRDF_DOM = DMDocument.outputDirPath + "export/owl/" + DMDocument.mastModelId
+ relativeFileSpecOWLRDF_DOM = DMDocument.getOutputDirPath() + "export/" + DMDocument.mastModelId
+ "_" + nameSpaceIdNCUC + "_" + "OWL" + "_" + lab_version_id + ".rdf";
- relativeFileSpecSKOSTTL_DOM = DMDocument.outputDirPath + "export/skos/" + DMDocument.mastModelId
+ relativeFileSpecSKOSTTL_DOM = DMDocument.getOutputDirPath() + "export/" + DMDocument.mastModelId
+ "_" + nameSpaceIdNCUC + "_" + "SKOS" + "_" + lab_version_id + ".ttl";
- relativeFileSpecUMLXMI = DMDocument.outputDirPath + "export/xmi/" + DMDocument.mastModelId + "_"
+ relativeFileSpecUMLXMI =
+ DMDocument.getOutputDirPath() + "export/" + DMDocument.mastModelId + "_"
+ nameSpaceIdNCUC + "_" + "XMI" + "_clean" + "_" + lab_version_id + ".xmi";
- relativeFileSpecUMLXMI2 = DMDocument.outputDirPath + "export/xmi/" + DMDocument.mastModelId
+ relativeFileSpecUMLXMI2 = DMDocument.getOutputDirPath() + "export/" + DMDocument.mastModelId
+ "_" + nameSpaceIdNCUC + "_" + "XMI" + "_wNames" + "_" + lab_version_id + ".xmi";
- relativeFileSpecModelPVL = DMDocument.outputDirPath + "export/pvl/" + DMDocument.mastModelId
+ relativeFileSpecModelPVL = DMDocument.getOutputDirPath() + "export/" + DMDocument.mastModelId
+ "_" + nameSpaceIdNCUC + "_" + "PVL" + "_" + lab_version_id + "_";
- relativeFileSpecModelRIM1 = DMDocument.outputDirPath + "export/rim/" + DMDocument.mastModelId
+ relativeFileSpecModelRIM1 = DMDocument.getOutputDirPath() + "export/" + DMDocument.mastModelId
+ "_" + nameSpaceIdNCUC + "_" + "RIM1" + "_" + lab_version_id + ".txt";
- relativeFileSpecModelRIM3 = DMDocument.outputDirPath + "export/rim/" + DMDocument.mastModelId
+ relativeFileSpecModelRIM3 = DMDocument.getOutputDirPath() + "export/" + DMDocument.mastModelId
+ "_" + nameSpaceIdNCUC + "_" + "RIM3" + "_" + lab_version_id + ".txt";
- relativeFileSpecModelRIM4 = DMDocument.outputDirPath + "export/rim/" + DMDocument.mastModelId
+ relativeFileSpecModelRIM4 = DMDocument.getOutputDirPath() + "export/" + DMDocument.mastModelId
+ "_" + nameSpaceIdNCUC + "_" + "RIM4" + "_" + lab_version_id + ".txt";
- relativeFileSpecAttrDefn = DMDocument.outputDirPath + "export/defnAttr/";
- relativeFileSpecClassDefn = DMDocument.outputDirPath + "export/defnClass/";
+ relativeFileSpecAttrDefn = DMDocument.getOutputDirPath() + "export/defnAttr/";
+ relativeFileSpecClassDefn = DMDocument.getOutputDirPath() + "export/defnClass/";
+ Utility.checkCreateDirectory(relativeFileSpecAttrDefn);
+ Utility.checkCreateDirectory(relativeFileSpecClassDefn);
return;
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMDDJSONFile.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMDDJSONFile.java
index 4416efd4..160a678e 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMDDJSONFile.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMDDJSONFile.java
@@ -38,6 +38,7 @@
import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;
+import gov.nasa.pds.model.plugin.util.Utility;
/**
* Writes the PDS4 DOM DD content to a JSON file
@@ -307,7 +308,7 @@ public void printAssoc(DOMClass lClass, PrintWriter prDDPins) {
lDOMPropGroup.domObjectArr.add(lDOMObject);
}
} else {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>error " + "WriteDOMDDJSONFile - Failed to find DOMObject - lDOMProp.identifier: "
+ lDOMProp.identifier);
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMDocBook.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMDocBook.java
index 8b24fc52..e4ed5162 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMDocBook.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMDocBook.java
@@ -37,6 +37,7 @@
import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;
+import gov.nasa.pds.model.plugin.util.Utility;
// Write the PDS4 Data Dictionary DocBook file.
@@ -143,14 +144,14 @@ public WriteDOMDocBook() {
}
// print out the class and attribute counts
- DMDocument.registerMessage("0>info " + "DD DocBook Class Counts");
+ Utility.registerMessage("0>info " + "DD DocBook Class Counts");
Set set9 = classClassificationMap.keySet();
Iterator iter9 = set9.iterator();
while (iter9.hasNext()) {
String lId = iter9.next();
ClassClassificationDefnDOM lClassClassificationDefnDOM = classClassificationMap.get(lId);
if (lClassClassificationDefnDOM != null) {
- DMDocument.registerMessage("0>info " + " - namespace: " + lId + " size: "
+ Utility.registerMessage("0>info " + " - namespace: " + lId + " size: "
+ lClassClassificationDefnDOM.classArr.size());
if (lClassClassificationDefnDOM.classArr.size() > 0) {
if (!(lId.compareTo(DMDocument.masterNameSpaceIdNCLC) == 0
@@ -167,14 +168,14 @@ public WriteDOMDocBook() {
}
}
- DMDocument.registerMessage("0>info " + "DD DocBook Attribute Counts");
+ Utility.registerMessage("0>info " + "DD DocBook Attribute Counts");
Set set92 = classClassificationMap.keySet();
Iterator iter92 = set92.iterator();
while (iter92.hasNext()) {
String lId = iter92.next();
AttrClassificationDefnDOM lAttrClassificationDefnDOM = attrClassificationMap.get(lId);
if (lAttrClassificationDefnDOM != null) {
- DMDocument.registerMessage("0>info " + " - namespace: " + lId + " size: "
+ Utility.registerMessage("0>info " + " - namespace: " + lId + " size: "
+ lAttrClassificationDefnDOM.attrArr.size());
}
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMDocBookAnon.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMDocBookAnon.java
index 33c5e261..3b1e034e 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMDocBookAnon.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMDocBookAnon.java
@@ -31,6 +31,7 @@
import java.io.*;
import java.util.*;
+import gov.nasa.pds.model.plugin.util.Utility;
// Write the Data Dictionary DocBook file with PDS mentioned removed
// Writes a DocBook file for each namespace id
@@ -147,14 +148,14 @@ public WriteDOMDocBookAnon () {
}
// print out the class and attribute counts
- DMDocument.registerMessage ("0>info " + "DD DocBook Class Counts");
+ Utility.registerMessage ("0>info " + "DD DocBook Class Counts");
Set set9 = classClassificationMap.keySet();
Iterator iter9 = set9.iterator();
while(iter9.hasNext()) {
String lId = (String) iter9.next();
ClassClassificationDefnDOM lClassClassificationDefnDOM = classClassificationMap.get(lId);
if (lClassClassificationDefnDOM != null ) {
- DMDocument.registerMessage ("0>info " + " - namespace: " + lId + " size: " + lClassClassificationDefnDOM.classArr.size());
+ Utility.registerMessage ("0>info " + " - namespace: " + lId + " size: " + lClassClassificationDefnDOM.classArr.size());
if (lClassClassificationDefnDOM.classArr.size() > 0) {
if (! (lId.compareTo(DMDocument.masterNameSpaceIdNCLC) == 0
|| lId.compareTo("pds.product") == 0
@@ -171,14 +172,14 @@ public WriteDOMDocBookAnon () {
}
}
- DMDocument.registerMessage ("0>info " + "DD DocBook Attribute Counts");
+ Utility.registerMessage ("0>info " + "DD DocBook Attribute Counts");
Set set92 = classClassificationMap.keySet();
Iterator iter92 = set92.iterator();
while(iter92.hasNext()) {
String lId = (String) iter92.next();
AttrClassificationDefnDOM lAttrClassificationDefnDOM = attrClassificationMap.get(lId);
if (lAttrClassificationDefnDOM != null )
- DMDocument.registerMessage ("0>info " + " - namespace: " + lId + " size: " + lAttrClassificationDefnDOM.attrArr.size());
+ Utility.registerMessage ("0>info " + " - namespace: " + lId + " size: " + lAttrClassificationDefnDOM.attrArr.size());
}
return;
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMSchematron.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMSchematron.java
index b59d7296..b138e1d1 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMSchematron.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMSchematron.java
@@ -37,6 +37,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.TreeMap;
+import gov.nasa.pds.model.plugin.util.Utility;
class WriteDOMSchematron extends Object {
PrintWriter prSchematron;
@@ -83,14 +84,14 @@ public void writeSchematronRule(SchemaFileDefn lSchemaFileDefn,
|| lSchemaFileDefn.nameSpaceIdNC.compareTo(lRule.attrNameSpaceNC) == 0))) continue;
} else if (lSchemaFileDefn.isLDD) {
// write an LDD schemtron
- DMDocument.registerMessage(
+ Utility.registerMessage(
"2>info " + "Found LDD - lSchemaFileDefn.isMission:" + lSchemaFileDefn.isMission);
if (!(lRule.isMissionOnly && lSchemaFileDefn.isMission)
|| !((lSchemaFileDefn.nameSpaceIdNC.compareTo(lRule.classNameSpaceNC) == 0
&& lSchemaFileDefn.stewardArr.contains(lRule.classSteward))
|| (lRule.classTitle.compareTo(DMDocument.LDDToolSingletonClassTitle) == 0))) continue;
} else {
- DMDocument.registerMessage("1>warning "
+ Utility.registerMessage("1>warning "
+ "Write Schematron - Invalid governance in SchemaFileDefn - lSchemaFileDefn.identifier:"
+ lSchemaFileDefn.identifier);
}
@@ -270,7 +271,7 @@ public void printSchematronFileHdr(SchemaFileDefn lSchemaFileDefn, PrintWriter p
lVersionNSId = DMDocument.masterPDSSchemaFileDefn.ns_version_id;
lNameSpaceURL = DMDocument.masterPDSSchemaFileDefn.nameSpaceURL;
lNameSpaceIdNCDIR = DMDocument.masterPDSSchemaFileDefn.nameSpaceIdNCDir;
- DMDocument.registerMessage("1>warning "
+ Utility.registerMessage("1>warning "
+ "config.properties file entry is missing for namespace id:" + lNameSpaceIdNC);
}
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMSpecification.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMSpecification.java
index a9233857..e6453ca1 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMSpecification.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMSpecification.java
@@ -42,6 +42,7 @@
import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;
+import gov.nasa.pds.model.plugin.util.Utility;
/**
* Driver for getting document
@@ -584,7 +585,7 @@ private void printTableRow2(ArrayList lPropArr, String relation) {
lAnchorString = lClass.anchorString;
} else {
// error
- DMDocument.registerMessage("1>error "
+ Utility.registerMessage("1>error "
+ "printTableRow2 - Component Class is missing - lClassId:" + lClassId);
}
} else {
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMStandardIdExtract.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMStandardIdExtract.java
index 1abbcfdf..7bba2433 100755
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMStandardIdExtract.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteDOMStandardIdExtract.java
@@ -59,7 +59,7 @@ public void writeExtractFile() throws java.io.IOException {
public void writeExtractFileBegin() throws java.io.IOException {
// Write the files consisting of individual classes
- String lFileName = DMDocument.outputDirPath + "export/" + "StandardId" + "_"
+ String lFileName = DMDocument.getOutputDirPath() + "export/" + "StandardId" + "_"
+ DOMInfoModel.lab_version_id + ".txt";
prPVL =
new PrintWriter(new OutputStreamWriter(new FileOutputStream(new File(lFileName)), "UTF-8"));
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteMappingFile.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteMappingFile.java
index be69bb88..4c75b1c5 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteMappingFile.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/WriteMappingFile.java
@@ -42,6 +42,7 @@
import java.util.Collections;
import java.util.Map;
import java.util.StringTokenizer;
+import gov.nasa.pds.model.plugin.util.Utility;
/**
* Writes terminological map to the ./map directory
@@ -135,10 +136,10 @@ public void writeMappingFile(String registrationAuthority, ArrayList inp
bReader.close();
} catch (FileNotFoundException ex) {
// file does not exist
- DMDocument.registerMessage("1>error " + "csv file does not exist.");
+ Utility.registerMessage("1>error " + "csv file does not exist.");
} catch (IOException ex) {
// I/O error
- DMDocument.registerMessage("1>error " + "input file IO Exception.");
+ Utility.registerMessage("1>error " + "input file IO Exception.");
}
} // end while
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/XML4LabelSchemaDOM.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/XML4LabelSchemaDOM.java
index 8ed11ec4..5bf44572 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/XML4LabelSchemaDOM.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/XML4LabelSchemaDOM.java
@@ -40,7 +40,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+import gov.nasa.pds.model.plugin.util.Utility;
import jdk.internal.org.jline.utils.Log;
// This code writes the information model to XML schema, attempting to replicate the class
@@ -70,7 +70,7 @@ public XML4LabelSchemaDOM() {
public void writeXMLSchemaFiles(SchemaFileDefn lSchemaFileDefn,
ArrayList lInputClassArr) throws java.io.IOException {
- DMDocument.registerMessage("0>info " + "writeXMLSchemaFiles - lSchemaFileDefn.identifier:"
+ Utility.registerMessage("0>info " + "writeXMLSchemaFiles - lSchemaFileDefn.identifier:"
+ lSchemaFileDefn.identifier);
// get the classes
@@ -161,7 +161,7 @@ public void writeXMLSchemaFiles(SchemaFileDefn lSchemaFileDefn,
}
// Write the classes
- DMDocument.registerMessage("0>info "
+ Utility.registerMessage("0>info "
+ "writeXMLSchemaFiles - Write Classes - classHierMap.size():" + classHierMap.size());
ArrayList lClassArr = new ArrayList<>(classHierMap.values());
for (Iterator i = lClassArr.iterator(); i.hasNext();) {
@@ -320,10 +320,10 @@ public void writeXMLSchemaFileHeader(SchemaFileDefn lSchemaFileDefn, PrintWriter
}
prXML.println(" <" + pNS + "schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"");
- DMDocument
+ Utility
.registerMessage("0>info " + "writeXMLSchemaFileHeader - lSchemaFileDefn.nameSpaceIdNC:"
+ lSchemaFileDefn.nameSpaceIdNC);
- DMDocument
+ Utility
.registerMessage("0>info " + "writeXMLSchemaFileHeader - DMDocument.masterNameSpaceIdNCLC:"
+ DMDocument.masterNameSpaceIdNCLC);
@@ -385,7 +385,7 @@ public void writeXMLSchemaFileHeader(SchemaFileDefn lSchemaFileDefn, PrintWriter
lVersionNSId = DMDocument.masterPDSSchemaFileDefn.ns_version_id;
lNameSpaceURL = DMDocument.masterPDSSchemaFileDefn.nameSpaceURL;
lNameSpaceIdNCDIR = DMDocument.masterPDSSchemaFileDefn.nameSpaceIdNCDir;
- DMDocument.registerMessage("1>warning "
+ Utility.registerMessage("1>warning "
+ "config.properties file entry is missing for namespace id:" + lNameSpaceIdNC);
}
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/XMLDocParserDomMDPTNConfig.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/XMLDocParserDomMDPTNConfig.java
index b151f09b..170c2021 100644
--- a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/XMLDocParserDomMDPTNConfig.java
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/XMLDocParserDomMDPTNConfig.java
@@ -40,6 +40,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
+import gov.nasa.pds.model.plugin.util.Utility;
/**
@@ -95,11 +96,11 @@ private void getTable() {
// get the root element
Element lRootElem = dom.getDocumentElement();
if (lRootElem != null) {
- DMDocument.registerMessage("0>info " + "Found required file: " + DMDocument.dataDirPath
+ Utility.registerMessage("0>info " + "Found required file: " + DMDocument.dataDirPath
+ "MDPTNConfigClassDisp.xml");
getRecord(lRootElem);
} else {
- DMDocument.registerMessage("3>error " + "Did not find required file: "
+ Utility.registerMessage("3>error " + "Did not find required file: "
+ DMDocument.dataDirPath + "MDPTNConfigClassDisp.xml");
}
}
@@ -217,7 +218,7 @@ private void getField(Element lElem) {
classDisposition.intSteward = lSteward;
classDispositionMap.put(lNameValue, classDisposition);
} else if (!DMDocument.LDDToolFlag) {
- DMDocument.registerMessage(
+ Utility.registerMessage(
"1>error " + "Duplicate class exists - Class Identifier:" + lNameValue);
}
}
diff --git a/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/util/Utility.java b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/util/Utility.java
new file mode 100644
index 00000000..3fda334a
--- /dev/null
+++ b/model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/util/Utility.java
@@ -0,0 +1,80 @@
+package gov.nasa.pds.model.plugin.util;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+import org.apache.commons.io.filefilter.WildcardFileFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import gov.nasa.pds.model.plugin.DMDocument;
+import gov.nasa.pds.model.plugin.DOMMsgDefn;
+
+public class Utility {
+ private static final Logger LOG = LoggerFactory.getLogger(Utility.class);
+
+ public static boolean checkCreateDirectory(String lDirectoryPathName) {
+ File file = new File(lDirectoryPathName);
+ if (file.exists() && file.isDirectory()) {
+ Utility.registerMessage("0>info Found directory: " + lDirectoryPathName);
+ return true;
+ }
+ // Create the directory
+ boolean bool = file.mkdirs();
+ if (bool) {
+ Utility.registerMessage("0>info Created directory: " + lDirectoryPathName);
+ return true;
+ } else {
+ Utility.registerMessage("1>error Directory create failed: " + lDirectoryPathName);
+ }
+ return false;
+ }
+
+ public static boolean checkFileName(String inputFileName) {
+ File file = new File(inputFileName);
+ if (file.exists() && (file.isFile())) {
+ Utility.registerMessage("0>info Found input file: " + inputFileName);
+ return true;
+ }
+ Utility.registerMessage("1>error " + "Input file not found: " + inputFileName);
+ return false;
+ }
+
+ public static void registerMessage(String lMessage) {
+ DOMMsgDefn lMessageDefn = new DOMMsgDefn(lMessage);
+ DMDocument.mainMsgArr.add(lMessageDefn);
+ return;
+ }
+
+ public static void registerMessage(String lNameSpaceIdNCLC, String lMessage) {
+ DOMMsgDefn lMessageDefn = new DOMMsgDefn(lMessage);
+ lMessageDefn.setNameSpaceIdNCLC(lNameSpaceIdNCLC);
+ DMDocument.mainMsgArr.add(lMessageDefn);
+ return;
+ }
+
+ public static String[] getFilepaths(String basePath, String extension) throws URISyntaxException {
+ if (!extension.startsWith(".")) {
+ extension = "." + extension;
+ }
+
+ Path path = Paths.get(basePath);
+ Iterator fileIter = FileUtils.iterateFiles(path.toFile(),
+ WildcardFileFilter.builder().setWildcards("*" + extension).get(), TrueFileFilter.INSTANCE);
+
+ List fileList = new ArrayList<>();
+ while (fileIter.hasNext()) {
+ fileList.add(fileIter.next().getAbsolutePath());
+ }
+
+ String[] filepaths = new String[fileList.size()];
+ return fileList.toArray(filepaths);
+ }
+
+
+}
diff --git a/model-lddtool/pom.xml b/model-lddtool/pom.xml
index bec1f537..277f027d 100644
--- a/model-lddtool/pom.xml
+++ b/model-lddtool/pom.xml
@@ -194,6 +194,12 @@
7.15.0
test
+
+ gov.nasa.pds
+ validate
+ 3.6.0-SNAPSHOT
+ test
+
diff --git a/model-lddtool/src/test/java/cucumber/LddToolRunner.java b/model-lddtool/src/test/java/cucumber/LddToolRunner.java
index cb26339b..3a08189b 100644
--- a/model-lddtool/src/test/java/cucumber/LddToolRunner.java
+++ b/model-lddtool/src/test/java/cucumber/LddToolRunner.java
@@ -1,12 +1,10 @@
package cucumber;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.PrintStream;
-import java.security.Permission;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import gov.nasa.pds.model.plugin.DMDocument;
/**
@@ -29,15 +27,18 @@ public class LddToolRunner {
* @return the output of lddtool
* @throws Throwable if an error occurs while running lddtool
*/
- public static String runLddTool(String[] args) throws Throwable {
+ public static String runLddTool(String[] args, String outDirectory) throws Throwable {
String output = null; // output of lddtool
try {
- LOG.info("Run LDDTool");
setupStreams(); // Redirect System.out and System.err to capture them
+ File f = new File(outDirectory);
+ f.mkdirs();
+ DMDocument.setOutputDirPath(outDirectory + File.separatorChar);
DMDocument.run(args);
output = outContent.toString();
} catch (Exception e) {
// Throw an exception if an error occurs while setting the SecurityManager
+ e.printStackTrace();
throw new Exception("An error occurred while setting the SecurityManager in runLddTool", e);
} finally {
restoreStreams(); // Restore the original System.out and System.err
diff --git a/model-lddtool/src/test/java/cucumber/StepDefs.java b/model-lddtool/src/test/java/cucumber/StepDefs.java
index bfea3b25..5ee2771a 100644
--- a/model-lddtool/src/test/java/cucumber/StepDefs.java
+++ b/model-lddtool/src/test/java/cucumber/StepDefs.java
@@ -1,16 +1,11 @@
package cucumber;
-import static org.junit.jupiter.api.Assertions.*;
-
-import io.cucumber.java.After;
-import io.cucumber.java.Before;
-import io.cucumber.java.en.Given;
-import io.cucumber.java.en.Then;
-import io.cucumber.java.en.When;
-
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
-import java.io.FilenameFilter;
import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@@ -20,9 +15,13 @@
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import io.cucumber.java.After;
+import io.cucumber.java.Before;
+import io.cucumber.java.en.Given;
+import io.cucumber.java.en.Then;
+import io.cucumber.java.en.When;
/**
* This class connects the feature files with the Cucumber test code
@@ -32,8 +31,8 @@ public class StepDefs {
// The values of these variables should come from a row in the table in the
// feature file.
- private String inputDirectory;
- private String outputDirectory;
+ private static String inputDirectory;
+ private static String outputDirectory;
private String commandArgs;
/**
@@ -41,17 +40,25 @@ public class StepDefs {
* @param args the command arguments
* @return a String array containing the resolved command arguments
*/
- private String[] resolveArgumentStrings(String[] args) {
+ private static String[] resolveArgumentStrings(String[] args) {
String[] resolvedArgs = new String[args.length];
int argIndex = 0;
- // Replace the placeholders with actual values
- for (String temp : args) {
- String resolvedToken = temp.replace("{inputDirectory}", this.inputDirectory)
- .replace("{outputDirectory}", this.outputDirectory)
- .replace("%20", " ");
- resolvedArgs[argIndex++] = resolvedToken;
+
+ LOG.info("inputDirectory: " + inputDirectory);
+ LOG.info("outputDirectory: " + outputDirectory);
+ if (inputDirectory != null && outputDirectory != null) {
+ // Replace the placeholders with actual values
+ for (String temp : args) {
+
+ String resolvedToken = temp.replace("{inputDirectory}", inputDirectory)
+ .replace("{outputDirectory}", outputDirectory)
+ .replace("%20", " ");
+ resolvedArgs[argIndex++] = resolvedToken;
+ }
+ return resolvedArgs;
+ } else {
+ return args;
}
- return resolvedArgs;
}
/**
@@ -62,6 +69,7 @@ private String[] resolveArgumentStrings(String[] args) {
* @throws IOException if an I/O error occurs
*/
private static void moveGeneratedFiles(String sourceDir, String targetDir, String pattern) throws IOException {
+ LOG.info("moveGeneratedFiles");
File source = new File(sourceDir);
File target = new File(targetDir);
@@ -203,8 +211,8 @@ private static List filterLines(List lines, List exclude
*/
@Before
public void setUp() {
- this.inputDirectory = null;
- this.outputDirectory = null;
+ inputDirectory = null;
+ outputDirectory = null;
this.commandArgs = null;
System.setProperty(org.slf4j.simple.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "DEBUG");
}
@@ -216,9 +224,11 @@ public void setUp() {
* @param commandArgs the command arguments
*/
@Given("the directories {string}, {string}, and command arguments {string}")
- public void test_directories_and_command_arguments(String inputDirectory, String outputDirectory, String commandArgs) {
- this.inputDirectory = inputDirectory;
- this.outputDirectory = outputDirectory;
+ public void test_directories_and_command_arguments(String inDir, String outDir, String commandArgs) {
+ inputDirectory = inDir;
+ outputDirectory = outDir;
+ LOG.debug("inputDirectory: " + inputDirectory);
+ LOG.debug("outputDirectory: " + outputDirectory);
this.commandArgs = commandArgs;
}
@@ -227,24 +237,7 @@ public void test_directories_and_command_arguments(String inputDirectory, String
*/
@When("lddtool is run")
public void run_lddtool() {
- String[] args = resolveArgumentStrings(this.commandArgs.split("\\s+")); // resolve the commandArgs into a String array
- String actualResponse;
- try {
- // run lddtool with the commandArgs and capture the output
- actualResponse = LddToolRunner.runLddTool(args);
-
- // create an output file from the lddtool output and save it to target/generated-files directory
- createOutputFile(actualResponse, this.outputDirectory + "/lddtool-output.txt");
-
- // move lddtool-generated files to target/generated-files directory
- moveGeneratedFiles(".", this.outputDirectory + "/", "PDS4_");
- } catch (RuntimeException ex) {
- throw ex;
- } catch (Throwable ex) {
- throw new RuntimeException("DMDocument error", ex);
- }
- args = null;
- actualResponse = null;
+ exec_lddtool(this.commandArgs, this.outputDirectory);
}
/**
@@ -316,8 +309,8 @@ public void output_should_match_expected_file(String actualOutputFile, String ex
// Read the content of the actual and expected output files by line
try {
- actualLines = Files.readAllLines(Paths.get(this.outputDirectory, actualOutputFile));
- expectedLines = Files.readAllLines(Paths.get(this.inputDirectory, expectedOutputFile));
+ actualLines = Files.readAllLines(Paths.get(outputDirectory, actualOutputFile));
+ expectedLines = Files.readAllLines(Paths.get(inputDirectory, expectedOutputFile));
} catch (IOException ex) {
throw new RuntimeException("Failed to read file", ex);
}
@@ -333,14 +326,35 @@ public void output_should_match_expected_file(String actualOutputFile, String ex
expectedLines = null;
excludeList = null;
}
+
+ public static void exec_lddtool(String commandArgs, String outputDir) {
+ String[] args = resolveArgumentStrings(commandArgs.split("\\s+")); // resolve the commandArgs into a String array
+ String actualResponse;
+ try {
+ // run lddtool with the commandArgs and capture the output
+ actualResponse = LddToolRunner.runLddTool(args, outputDir);
+
+ // create an output file from the lddtool output and save it to target/generated-files directory
+ createOutputFile(actualResponse, outputDir + "/lddtool-output.txt");
+
+ // move lddtool-generated files to target/generated-files directory
+ // moveGeneratedFiles(".", outputDir + "/", "PDS4_");
+ } catch (RuntimeException ex) {
+ throw ex;
+ } catch (Throwable ex) {
+ throw new RuntimeException("DMDocument error", ex);
+ }
+ args = null;
+ actualResponse = null;
+ }
/*
* This method is called after each test case to clean up the test environment
*/
@After
public void tearDown() {
- this.inputDirectory = null;
- this.outputDirectory = null;
+ inputDirectory = null;
+ outputDirectory = null;
this.commandArgs = null;
}
}
diff --git a/model-lddtool/src/test/java/cucumber/TestConstants.java b/model-lddtool/src/test/java/cucumber/TestConstants.java
new file mode 100644
index 00000000..bfcc1d2e
--- /dev/null
+++ b/model-lddtool/src/test/java/cucumber/TestConstants.java
@@ -0,0 +1,15 @@
+package cucumber;
+
+import java.io.File;
+
+public final class TestConstants {
+
+ public static final String TEST_DATA_DIR =
+ System.getProperty("user.dir") + File.separator + "src/test/resources";
+ public static final String TEST_OUT_DIR =
+ System.getProperty("user.dir") + File.separator + "target/test";
+ public static final String EXAMPLE_DIR =
+ System.getProperty("user.dir") + File.separator + "src/main/resources/examples";
+ public static final String RESOURCES_DIR =
+ System.getProperty("user.dir") + File.separator + "src/main/resources/util";
+}
\ No newline at end of file
diff --git a/model-lddtool/src/test/java/cucumber/ValidateStepDefs.java b/model-lddtool/src/test/java/cucumber/ValidateStepDefs.java
new file mode 100644
index 00000000..d147b16a
--- /dev/null
+++ b/model-lddtool/src/test/java/cucumber/ValidateStepDefs.java
@@ -0,0 +1,375 @@
+package cucumber;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.apache.commons.io.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import gov.nasa.pds.model.plugin.util.Utility;
+import gov.nasa.pds.tools.validate.CrossLabelFileAreaReferenceChecker;
+import gov.nasa.pds.tools.validate.ProblemType;
+import gov.nasa.pds.validate.ValidateLauncher;
+import io.cucumber.java.en.Given;
+import io.cucumber.java.en.Then;
+import io.cucumber.java.en.When;
+
+public class ValidateStepDefs {
+ // Class used as a glue to connect a feature file to cucumber test code.
+
+ private static final Logger LOG = LoggerFactory.getLogger(ValidateStepDefs.class);
+ private static final String DEFAULT_REPORT_FILENAME = "report_{testDir}.json";
+ private static final String DEFAULT_VALIDATE_ARGS =
+ "--update-context-products --report-style json --skip-content-validation --report-file {reportDir}/"
+ + DEFAULT_REPORT_FILENAME + " ";
+ private static final String DEFAULT_CORE_ARGS = "-p";
+ private static final String DEFAULT_LDDTOOL_ARGS = "-lp";
+
+
+ // For some strange reason, cucumber suppresses the printing of log output
+ // unless the following parameters are added at command line:
+ // Assuming slf4j-simple-1.7.28.jar exist in target/validate-1.25.0-SNAPSHOT/lib
+ // directory.
+ // -Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG
+
+ // "-cp
+ // "target/validate-1.25.0-SNAPSHOT/lib/slf4j-simple-1.7.28.jar:target/test-classes:target/validate-1.25.0-SNAPSHOT/lib/*
+ // For example:
+ //
+ // java -Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG -cp
+ // "target/validate-1.25.0-SNAPSHOT/lib/slf4j-simple-1.7.28.jar:target/test-classes:target/validate-1.25.0-SNAPSHOT/lib/*"
+ // io.cucumber.core.cli.Main target/test-classes/features
+ //
+ // Note that the slf4j-simple-1.7.28.jar has to be explicitly called out first.
+
+ private File outputData = null;
+ // A class to run each test. It must be instantiated for each test in the
+ // setUp() function.
+ private ValidateLauncher launcher = null;
+
+ // The values of these variables should come from a row in the table in the
+ // feature file.
+ private String testName;
+ private String testDir;
+ private int messageCount;
+ private String messageText;
+ private String problemEnum;
+ private String resourceDir;
+ private String reportDir;
+ private String commandArgs;
+ private String refOutputValue;
+
+ private boolean createManifestFileFlag = false;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ void setUp() throws Exception {
+ this.outputData = new File(TestConstants.TEST_OUT_DIR);
+ FileUtils.forceMkdir(this.outputData); // Create directory if one does not already exist.
+ System.setProperty("resources.home", TestConstants.TEST_OUT_DIR);
+ this.launcher = new ValidateLauncher();
+ this.refOutputValue = DEFAULT_REPORT_FILENAME;
+ this.reportDir = TestConstants.TEST_OUT_DIR;
+ this.resourceDir = TestConstants.TEST_DATA_DIR;
+
+
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ void tearDown() throws Exception {
+ // FileUtils.forceDelete(this.outputData);
+ this.launcher.flushValidators();
+ // It seems the launcher does not completely flush any references to schematron
+ // which causes problem for subsequent tests.
+ // get rid of the cross references
+ CrossLabelFileAreaReferenceChecker.reset();
+ }
+
+ private void createManifestFileDo(String testPath) {
+ // Function create a manifest file if the flag createManifestFileFlag it true.
+ // The file is normally used when --target-manifest is used in the command line.
+ // As of 10/13/2020, there is only one test github50 uses the manifest file.
+
+ if (this.createManifestFileFlag) {
+ try {
+ String outFilePath = TestConstants.TEST_OUT_DIR;
+ String manifestFile = outFilePath + File.separator + "target-manifest.xml";
+ String manifestText = testPath + File.separator + "ele_evt_12hr_orbit_2011-2012.xml\n"
+ + testPath + File.separator + "ele_evt_8hr_orbit_2012-2013.xml";
+ BufferedWriter writerManifest = new BufferedWriter(new FileWriter(manifestFile));
+ writerManifest.write(manifestText);
+ writerManifest.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Test Failed Due To Exception: " + e.getMessage());
+ }
+ }
+ }
+
+ private void createCatalogFileDo(String catFile, String testPath, boolean forceFlag) {
+ // Function create a catalog file if the flag createManifestFileFlag it true.
+ // The file is normally used when --target-manifest is used in the command line.
+ // As of 10/13/2020, there is only one test github50 uses the manifest file.
+ if ((this.createManifestFileFlag) || (forceFlag)) {
+ try {
+ // Create catalog file
+ String catText = "\n" + "\n" + "\n"
+ + " \n"
+ + " \n" + "";
+
+ BufferedWriter writer = new BufferedWriter(new FileWriter(catFile));
+ writer.write(catText);
+ writer.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Test Failed Due To Exception: " + e.getMessage());
+ }
+ }
+ }
+
+ private int getMessageCountBasedOnProblemType(String problemEnum, JsonObject reportJson) {
+ // Given an output report, retrieve the 'count' field based on the problemEnum
+ // value.
+ int totalCount = 0;
+ int count = 0; // Individual enum
+ // It is possible that the value is more than one: e.g
+ // CONTEXT_REFERENCE_NOT_FOUND,CONTEXT_REFERENCE_FOUND_MISMATCH
+ // Split using command and loop through each enum to fetch the count.
+ String[] problemTokens = problemEnum.split(",");
+
+ for (String strTemp : problemTokens) {
+ if (strTemp.contains("total")) {
+ count = reportJson.getAsJsonObject("summary").get(strTemp).getAsInt();
+ } else {
+ count = this.getMessageCount(reportJson,
+ ProblemType.valueOf(ProblemType.class, strTemp).getKey());
+ }
+ LOG.debug("getMessageCountBasedOnProblemType: strTemp, count " + strTemp + " "
+ + Integer.toString(count));
+ totalCount += count;
+ }
+
+ LOG.debug("getMessageCountBasedOnProblemType: problemEnum, totalCount " + problemEnum
+ + " " + Integer.toString(totalCount));
+
+ return (totalCount);
+ }
+
+ private String[] resolveArgumentStrings(String commandArgs) throws URISyntaxException {
+ // Given the value of this.commandArgs (just one long string), split using
+ // spaces and replace all {reportDir} and {resourceDir} with actual value.
+ // and return an array of tokens. This returned value can then be used to send
+ // to processMain() function.
+ // Example:
+ //
+ // "-r {reportDir}/report_github50_1.json -s json --no-data-check
+ // --target-manifest {reportDir}/target-manifest.xml
+ // becomes:
+ // "-r target/test/report_github50_1.json -s, json, --no-data-check
+ // --target-manifest target/test/target-manifest.xml
+
+
+ String array1[] = getDefaultValidateArguments(commandArgs);
+ String[] args = new String[array1.length];
+ int argIndex = 0;
+ String resolvedToken = "";
+ for (String temp : array1) {
+ resolvedToken = temp.replace("{reportDir}", this.reportDir);
+ resolvedToken = resolvedToken.replace("{testDir}", this.testDir);
+ resolvedToken = resolvedToken.replace("{outDir}", TestConstants.TEST_OUT_DIR + File.separator + this.testDir);
+ resolvedToken = resolvedToken.replace("{resourceDir}", this.resourceDir);
+ resolvedToken = resolvedToken.replace("%20", " ");
+ args[argIndex++] = resolvedToken;
+ }
+
+ LOG.debug("resolveArgumentStrings() commandArgs = [" + commandArgs + "]");
+ LOG
+ .info("args = [" + Arrays.toString(args) + "]");
+ LOG.debug("resolveArgumentStrings() this.reportDir = [" + this.reportDir + "]");
+ LOG.debug("resolveArgumentStrings() this.resourceDir = [" + this.resourceDir + "]");
+ LOG.debug("resolveArgumentStrings() this.testName = [" + this.testName + "]");
+
+ return (args);
+ }
+
+ @Given("the test {string} at directory {string}")
+ public void a_test_string_with_string(String testName, String testDir) {
+ // throw new io.cucumber.java.PendingException();
+ this.testName = testName;
+ this.testDir = testDir;
+ this.reportDir = this.reportDir + File.separatorChar + testDir;
+ }
+
+ @Given("expected error\\/warning count {int} with expected error\\/warning text of {string} with expected error from ValidateProblems enumeration {string}")
+ public void with_test_property(int messageCount, String messageText, String problemEnum) {
+ this.messageCount = messageCount;
+ this.messageText = messageText;
+ this.problemEnum = problemEnum;
+ LOG.debug("with_test_property:messageCount [" + Integer.toString(messageCount)
+ + "], messageText [" + messageText + "]");
+ }
+
+ @Given("the latest PDS4 schema\\/schematron is generated")
+ public void generate_pds4_schema() throws Exception {
+ StepDefs.exec_lddtool(DEFAULT_CORE_ARGS,
+ TestConstants.TEST_OUT_DIR + File.separator + this.testDir);
+ }
+
+ @Given("a new LDD is generated using the IngestLDDs {string}")
+ public void generate_ldd(String ingestLDDFilename) throws Exception {
+ String ingestLDDPath = TestConstants.TEST_DATA_DIR + File.separator + this.testDir
+ + File.separator + ingestLDDFilename;
+ StepDefs.exec_lddtool(DEFAULT_LDDTOOL_ARGS + " " + ingestLDDPath,
+ TestConstants.TEST_OUT_DIR + File.separator + this.testDir);
+ }
+
+ @When("execute validate command with {string} as arguments")
+ public void execute_a_validate_command(String commandArgs) {
+ // Write code here that turns the phrase above into concrete actions
+ // throw new io.cucumber.java.PendingException();
+ LOG.debug("execute_a_validate_command:testDir " + this.testDir);
+ LOG.debug("execute_a_validate_command:testName " + this.testName);
+
+ this.commandArgs = commandArgs;
+
+ try {
+ this.setUp();
+
+ // Because this.commandArgs is a String but processMain() is expecing a String
+ // [], we have to
+ // convert this.commandArgs into an array of strings.
+ String[] args = this.resolveArgumentStrings(commandArgs);
+
+ this.launcher.processMain(args);
+
+ this.tearDown();
+
+ // Will do the compare of the report in another function.
+ } catch (ExitException e) {
+ assertEquals(0, e.status, "Exit status");
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Test Failed Due To Exception: " + e.getMessage());
+ }
+ }
+
+ @Then("produced output from validate command should be similar to reported {string} JSON report or no error reported.")
+ public void produced_output_from_validate_command_should_be_similar_to_reference_ref_output_value_or_no_error_reported(
+ String testDir) {
+
+ try {
+ Gson gson = new Gson();
+ this.refOutputValue = this.refOutputValue.replace("{testDir}", this.testDir);
+ File report = new File(this.reportDir + File.separator + this.refOutputValue);
+ LOG.debug(
+ "produced_output_from_validate_command_should_be_similar_to_reference_ref_output_value_or_no_error_reported:report = ["
+ + report.getName() + "]");
+ JsonObject reportJson = gson.fromJson(new FileReader(report), JsonObject.class);
+
+ // Get the count for errors based on the value of problemEnum, e.g.
+ // MISSING_REFERENCED_FILE
+ int count = this.getMessageCountBasedOnProblemType(this.problemEnum, reportJson);
+
+ LOG.debug(
+ "produced_output_from_validate_command_should_be_similar_to_reference_ref_output_value_or_no_error_reported:testName,problemEnum,count,refOutputValue: "
+ + this.testName + " " + problemEnum + " " + Integer.toString(count) + " "
+ + this.refOutputValue);
+
+ // Compare the count from this test with the this.messageCount from test table.
+ assertEquals(count, this.messageCount, this.messageText + " " + reportJson.toString());
+
+ } catch (ExitException e) {
+ assertEquals(0, e.status, "Exit status");
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Test Failed Due To Exception: " + e.getMessage());
+ }
+ }
+
+ protected static class ExitException extends SecurityException {
+ private static final long serialVersionUID = -1535371619727142623L;
+
+ public final int status;
+
+ public ExitException(int status) {
+ super("Program exited");
+ this.status = status;
+ }
+ }
+
+ int getMessageCount(JsonObject reportJson, String messageTypeName) {
+ int i = 0;
+ JsonObject message = null;
+ int count = 0;
+ if (messageTypeName.equals("totalErrors")) {
+ return reportJson.getAsJsonObject("summary").get("totalErrors").getAsInt();
+ }
+ while (true) {
+ try {
+ message = reportJson.getAsJsonObject("summary").get("messageTypes").getAsJsonArray().get(i)
+ .getAsJsonObject();
+ if (message.get("messageType").getAsString().equals(messageTypeName)) {
+ count = message.get("total").getAsInt();
+ return count;
+ }
+ } catch (IndexOutOfBoundsException e) {
+ return count;
+ }
+ i++;
+ }
+ }
+
+ private String getAbsolutePath(String path) throws Exception {
+ String finalPath = "";
+ File testFile = new File(path);
+ if (!testFile.isAbsolute()) {
+ finalPath = System.getProperty("user.dir") + "/" + path;
+ } else {
+ finalPath = path;
+ }
+
+ if (!(new File(finalPath)).exists()) {
+ throw new Exception("Path does not exist: " + finalPath);
+ }
+
+ return finalPath;
+ }
+
+ private String[] getDefaultValidateArguments(String commandArgs) throws URISyntaxException {
+ List argsList = new ArrayList();
+ String[] args = DEFAULT_VALIDATE_ARGS.concat(this.commandArgs).split("\\s+");
+
+ // Get schema
+ String[] schemas = Utility
+ .getFilepaths(TestConstants.TEST_OUT_DIR + File.separatorChar + this.testDir, ".xsd");
+
+ // Get schematron
+ String[] schematrons = Utility
+ .getFilepaths(TestConstants.TEST_OUT_DIR + File.separatorChar + this.testDir, ".sch");
+
+
+ Collections.addAll(argsList, args);
+ Collections.addAll(argsList, new String[] {"--schema"});
+ Collections.addAll(argsList, schemas);
+ Collections.addAll(argsList, new String[] {"--schematron"});
+ Collections.addAll(argsList, schematrons);
+ return Arrays.copyOf(argsList.toArray(), argsList.size(), String[].class);
+ }
+}
diff --git a/model-lddtool/src/test/resources/features/integration.feature b/model-lddtool/src/test/resources/features/integration.feature
index c75720cd..138a7652 100644
--- a/model-lddtool/src/test/resources/features/integration.feature
+++ b/model-lddtool/src/test/resources/features/integration.feature
@@ -8,12 +8,25 @@ Feature: Running integration tests for lddtool
When lddtool is run
Then the produced output from lddtool command should