diff --git a/jsonld-utility/pom.xml b/jsonld-utility/pom.xml index fcfcdd4..3af5800 100644 --- a/jsonld-utility/pom.xml +++ b/jsonld-utility/pom.xml @@ -6,7 +6,7 @@ org.unece.uncefact vocab-jsonld-utility - 1.5.2 + 1.5.3 diff --git a/jsonld-utility/src/main/java/org/unece/uncefact/vocab/Runner.java b/jsonld-utility/src/main/java/org/unece/uncefact/vocab/Runner.java index 5e6b8cc..137110d 100644 --- a/jsonld-utility/src/main/java/org/unece/uncefact/vocab/Runner.java +++ b/jsonld-utility/src/main/java/org/unece/uncefact/vocab/Runner.java @@ -27,7 +27,7 @@ public static void main(String[] args) throws ParseException, IOException { Option prettyPrintOption = new Option("p", "pretty-print",false, "an output file to be created as a result of transformation. Default value: output.jsonld."); Option workindDirOption = new Option("d", "directory",true, "Working directory for files to be merged or for md generation. Default value for merge - \"vocab/\", for md - \"\""); Option inputFilesOption = new Option("i", "input-file",true, "Input file name to be merged or for md generation. Default value for md generation - \"merged.jsonld/\""); - Option outputFileNameOption = new Option("o", "input-file",true, "Input file name to be merged or for md generation. Default value for md generation - \"merged.jsonld/\""); + Option outputFileNameOption = new Option("o", "output-file",true, "Input file name to be merged or for md generation. Default value for md generation - \"merged.jsonld/\""); Option versionOption = new Option("?", "version", false, "display this help."); options.addOption(runningModeOption); @@ -73,6 +73,8 @@ public static void main(String[] args) throws ParseException, IOException { case "merge": workingDir = "vocab/"; break; + case "md-locode": + workingDir = "."; case "md": case "minify": case "pretty-print": @@ -113,6 +115,12 @@ public static void main(String[] args) throws ParseException, IOException { DomainsToMD.generate(workingDir, inputFileNames); break; + case "md-locode": + UNLCDToMD.generate(workingDir); + UNLCDCountriesToMD.generate(workingDir); + UNLCDFunctionsToMD.generate(workingDir); + UNLCDSubdivisionsToMD.generate(workingDir); + break; case "minify": JsonLDMerge.format(workingDir, inputFileNames, false, outputFileName); break; diff --git a/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/DomainsToMD.java b/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/DomainsToMD.java index 71b6456..4d09dca 100644 --- a/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/DomainsToMD.java +++ b/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/DomainsToMD.java @@ -697,7 +697,11 @@ else if (comment instanceof JsonArray){ for (JsonObject jsonObject:codeProperties.get(codeListId).values()) { JsonObjectBuilder mdCodeListValue = Json.createObjectBuilder(); mdCodeListValue.add("uri",jsonObject.getString(Constants.ID)); - mdCodeListValue.add("comment",jsonObject.getString(Constants.RDFS_COMMENT)); + if(jsonObject.containsKey(Constants.RDFS_COMMENT)){ + mdCodeListValue.add("comment",jsonObject.getString(Constants.RDFS_COMMENT)); + } else{ + mdCodeListValue.add("comment",""); + } mdCodeListValue.add("value",jsonObject.getString(Constants.RDF_VALUE)); valuesMap.put(jsonObject.getString(Constants.RDF_VALUE), mdCodeListValue.build()); @@ -706,7 +710,11 @@ else if (comment instanceof JsonArray){ batchObject.add("id", dataSet.concat("_").concat(jsonObject.getString(Constants.ID))); batchFieldsObject = Json.createObjectBuilder(); batchFieldsObject.add("label", StringUtils.substringAfter(jsonObject.getString(Constants.ID), ":")); - batchFieldsObject.add("comment", jsonObject.getString(Constants.RDFS_COMMENT)); + if(jsonObject.containsKey(Constants.RDFS_COMMENT)){ + batchFieldsObject.add("comment", jsonObject.getString(Constants.RDFS_COMMENT)); + } else{ + batchFieldsObject.add("comment", ""); + } batchFieldsObject.add("type", "Code List Value"); batchFieldsObject.add("dataset", dataSet); batchObject.add("fields", batchFieldsObject.build()); diff --git a/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDCountriesToMD.java b/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDCountriesToMD.java index f7dcf09..48e6c84 100644 --- a/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDCountriesToMD.java +++ b/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDCountriesToMD.java @@ -50,7 +50,7 @@ public static void generate(String workingDir) throws IOException { mdContent = mdContent.concat(String.format("permalink: %s", "unlocode-countries")).concat("\n"); mdContent = mdContent.concat(String.format("jsonid: %s", "unlocode-countries")).concat("\n"); mdContent = mdContent.concat(String.format("label: %s", "UN/LOCODE Countries")).concat("\n"); - mdContent = mdContent.concat(String.format("comment: %s", "desc")).concat("\n"); +// mdContent = mdContent.concat(String.format("comment: %s", "desc")).concat("\n"); mdContent = mdContent.concat("columns:\n"); mdContent = mdContent.concat(" - \n"); mdContent = mdContent.concat(" title: Label\n"); @@ -62,7 +62,7 @@ public static void generate(String workingDir) throws IOException { mdContent = mdContent.concat(" title: UN/LOCODEs\n"); mdContent = mdContent.concat(String.format(" type: %s\n", "unlocode-link")); mdContent = mdContent.concat("---\n"); - new FileGenerator().generateTextFile(mdContent,workingDir+"/_code-lists/unlocode-countries.md"); + new FileGenerator().generateTextFile(mdContent,workingDir+"/_unlocode-lists/unlocode-countries.md"); fis.close(); } } diff --git a/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDFunctionsToMD.java b/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDFunctionsToMD.java index bb570e1..5f42411 100644 --- a/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDFunctionsToMD.java +++ b/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDFunctionsToMD.java @@ -42,7 +42,7 @@ public static void generate(String workingDir) throws IOException { JsonObject jsonObject = iterator.next().asJsonObject(); csvContent = csvContent.concat(String.format("\"%s\",", jsonObject.getString(Constants.ID))); csvContent = csvContent.concat(String.format("\"%s\",", jsonObject.getString(Constants.RDFS_LABEL))); - csvContent = csvContent.concat(String.format("\"%s\",", jsonObject.getString(Constants.RDFS_COMMENT))); + csvContent = csvContent.concat(String.format("\"%s\",", jsonObject.getString(Constants.RDFS_COMMENT).replaceAll("\"", "'"))); csvContent = csvContent.concat(String.format("\"%s\"\n", jsonObject.getString(Constants.RDF_VALUE))); } new FileGenerator().generateTextFile(csvContent,workingDir+"/_data/unlocode-functions.csv"); @@ -52,7 +52,7 @@ public static void generate(String workingDir) throws IOException { mdContent = mdContent.concat(String.format("permalink: %s", "unlocode-functions")).concat("\n"); mdContent = mdContent.concat(String.format("jsonid: %s", "unlocode-functions")).concat("\n"); mdContent = mdContent.concat(String.format("label: %s", "UN/LOCODE Functions")).concat("\n"); - mdContent = mdContent.concat(String.format("comment: %s", "desc")).concat("\n"); +// mdContent = mdContent.concat(String.format("comment: %s", "desc")).concat("\n"); mdContent = mdContent.concat("columns:\n"); mdContent = mdContent.concat(" - \n"); mdContent = mdContent.concat(" title: Label\n"); @@ -64,7 +64,7 @@ public static void generate(String workingDir) throws IOException { mdContent = mdContent.concat(" title: Value\n"); mdContent = mdContent.concat(String.format(" code: %s\n", "value")); mdContent = mdContent.concat("---\n"); - new FileGenerator().generateTextFile(mdContent,workingDir+"/_code-lists/unlocode-functions.md"); + new FileGenerator().generateTextFile(mdContent,workingDir+"/_unlocode-lists/unlocode-functions.md"); fis.close(); } } diff --git a/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDSubdivisionsToMD.java b/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDSubdivisionsToMD.java index 60934e5..b2f1172 100644 --- a/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDSubdivisionsToMD.java +++ b/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDSubdivisionsToMD.java @@ -55,7 +55,7 @@ public static void generate(String workingDir) throws IOException { mdContent = mdContent.concat(String.format("permalink: %s", "unlocode-subdivisions")).concat("\n"); mdContent = mdContent.concat(String.format("jsonid: %s", "unlocode-subdivisions")).concat("\n"); mdContent = mdContent.concat(String.format("label: %s", "UN/LOCODE Country Subdivisions")).concat("\n"); - mdContent = mdContent.concat(String.format("comment: %s", "desc")).concat("\n"); +// mdContent = mdContent.concat(String.format("comment: %s", "desc")).concat("\n"); mdContent = mdContent.concat("columns:\n"); mdContent = mdContent.concat(" - \n"); mdContent = mdContent.concat(" title: Label\n"); @@ -71,7 +71,7 @@ public static void generate(String workingDir) throws IOException { mdContent = mdContent.concat(" title: Value\n"); mdContent = mdContent.concat(String.format(" code: %s\n", "value")); mdContent = mdContent.concat("---\n"); - new FileGenerator().generateTextFile(mdContent,workingDir+"/_code-lists/unlocode-subdivisions.md"); + new FileGenerator().generateTextFile(mdContent,workingDir+"/_unlocode-lists/unlocode-subdivisions.md"); fis.close(); } } diff --git a/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDToMD.java b/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDToMD.java index a9e41cd..b822f67 100644 --- a/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDToMD.java +++ b/jsonld-utility/src/main/java/org/unece/uncefact/vocab/md/UNLCDToMD.java @@ -78,7 +78,7 @@ public static void generate(String workingDir) throws IOException { mdContent += String.format("permalink: %s%s\n", "unlocode", countryCode); mdContent += String.format("jsonid: %s%s\n", "unlocode", countryCode); mdContent += String.format("label: %s\n", "UN/LOCODE"); - mdContent += String.format("comment: %s\n", "desc"); +// mdContent += String.format("comment: %s\n", "desc"); mdContent += "excludeFromList: true\n"; mdContent += "columns:\n"; mdContent += " - \n"; @@ -106,7 +106,7 @@ public static void generate(String workingDir) throws IOException { mdContent += " title: Longitude\n"; mdContent += String.format(" code: %s\n", UNLOCODEConstants.GEO_NS+":long"); mdContent += "---\n"; - new FileGenerator().generateTextFile(mdContent, String.format(workingDir+"/_code-lists/unlocode%s.md", countryCode)); + new FileGenerator().generateTextFile(mdContent, String.format(workingDir+"/_unlocode-lists/unlocode%s.md", countryCode)); } countryCode = currentCountryCode; csvContent += String.format("\"%s\",", jsonObject.getString(Constants.ID)); @@ -174,7 +174,7 @@ public static void generate(String workingDir) throws IOException { mdContent += String.format("permalink: %s%s\n", "unlocode", countryCode); mdContent += String.format("jsonid: %s%s\n", "unlocode", countryCode); mdContent += String.format("label: %s\n", "UN/LOCODE"); - mdContent += String.format("comment: %s\n", "desc"); +// mdContent += String.format("comment: %s\n", "desc"); mdContent += "excludeFromList: true\n"; mdContent += "columns:\n"; mdContent += " - \n"; @@ -202,7 +202,7 @@ public static void generate(String workingDir) throws IOException { mdContent += " title: Longitude\n"; mdContent += String.format(" code: %s\n", UNLOCODEConstants.GEO_NS+":long"); mdContent += "---\n"; - new FileGenerator().generateTextFile(mdContent, String.format(workingDir+"/_code-lists/unlocode%s.md", countryCode)); + new FileGenerator().generateTextFile(mdContent, String.format(workingDir+"/_unlocode-lists/unlocode%s.md", countryCode)); fis.close(); } }