Skip to content

Commit a9b84c1

Browse files
authored
Merge pull request #580 from Imvertor/Development
Development naar 4.3
2 parents 0fb8c9f + 3f9f007 commit a9b84c1

File tree

201 files changed

+9072
-3886
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+9072
-3886
lines changed

src/main/java/nl/imvertor/MIMCompiler/MIMCompiler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ public boolean generateDefault() throws Exception {
119119
}
120120

121121
if (isRDFType) {
122-
transformer.setXslParm("generate-readable-ids", "false");
122+
transformer.setXslParm("generate-readable-ids", "true");
123123
transformer.setXslParm("generate-all-ids", "true");
124-
}
124+
transformer.setXslParm("add-generated-id", "true");
125+
}
125126

126127
succeeds = succeeds && transformer.transformStep("properties/WORK_EMBELLISH_FILE", "properties/WORK_MIMFORMAT_XMLPATH", xslFileParam); //TODO must relocate generation of WORK_LISTS_FILE to a EMBELLISH step.
127128

src/main/java/nl/imvertor/OfficeCompiler/OfficeCompiler.java

Lines changed: 189 additions & 36 deletions
Large diffs are not rendered by default.

src/main/java/nl/imvertor/SchemaValidator/SchemaValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ public boolean validateSchemas() throws Exception {
101101
String msg = "XML schema: " + StringUtils.substringAfter(m.message, m.code + ": ") + " [" + URLDecoder.decode(StringUtils.substringAfter(m.file,"/xsd/"), StandardCharsets.UTF_8.name()) + ":" + m.line + "]";
102102
switch (m.type.toLowerCase()) {
103103
case "error":
104-
runner.error(logger, msg,"","XERCES-" + m.code);
104+
runner.error(logger, msg,"","#XERCES-" + m.code);
105105
break;
106106
case "warning":
107-
runner.warn(logger, msg,"","XERCES-" + m.code);
107+
runner.warn(logger, msg,"","#XERCES-" + m.code);
108108
break;
109109
default:
110110
runner.debug(logger,"CHAIN", msg);

src/main/java/nl/imvertor/YamlCompiler/YamlCompiler.java

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -106,59 +106,18 @@ public boolean generateKING() throws Exception {
106106
transformer.setXslParm("json-version","3.0");
107107
succeeds = succeeds && transformer.transformStep("properties/ROUGH_OPENAPI_ENDPRODUCT_XML_FILE_PATH","properties/RESULT_OPENAPI_ENDPRODUCT_XML_FILE_PATH", "properties/IMVERTOR_METAMODEL_KINGBSM_OPENAPI_ENDPRODUCT_XML_XSLPATH");
108108

109-
succeeds = succeeds && transformer.transformStep("properties/RESULT_OPENAPI_ENDPRODUCT_XML_FILE_PATH","properties/RESULT_YAMLHEADER_FILE_PATH", "properties/IMVERTOR_METAMODEL_KING_YAMLHEADER_XSLPATH");
110-
succeeds = succeeds && transformer.transformStep("properties/RESULT_OPENAPI_ENDPRODUCT_XML_FILE_PATH","properties/RESULT_YAMLBODY_FILE_PATH", "properties/IMVERTOR_METAMODEL_KING_YAMLBODY_XSLPATH");
111-
112-
// Next 2 lines are for generating json and yaml using saxon
109+
// Next 2 lines are for generating json and yaml using a json mapping file
113110
succeeds = succeeds && transformer.transformStep("properties/RESULT_OPENAPI_ENDPRODUCT_XML_FILE_PATH","properties/RESULT_JSONMAPPING_4_BODY_FILE_PATH", "properties/IMVERTOR_METAMODEL_KING_EP4JSONMAPPING_4BODY_XSLPATH");
114111
succeeds = succeeds && transformer.transformStep("properties/RESULT_OPENAPI_ENDPRODUCT_XML_FILE_PATH","properties/RESULT_JSONMAPPING_4_HEADER_FILE_PATH","properties/IMVERTOR_METAMODEL_KING_EP4JSONMAPPING_4HEADER_XSLPATH");
115112

116113
transformer.setXslParm("json-version","2.0");
117-
succeeds = succeeds && transformer.transformStep("properties/RESULT_OPENAPI_ENDPRODUCT_XML_FILE_PATH","properties/RESULT_YAMLBODY_FILE_PATH2", "properties/IMVERTOR_METAMODEL_KING_YAMLBODY_XSLPATH");
118114

119-
// Next line is for generating json using saxon
115+
// Next line is for generating json using a json mapping file
120116
succeeds = succeeds && transformer.transformStep("properties/RESULT_OPENAPI_ENDPRODUCT_XML_FILE_PATH","properties/RESULT_JSONMAPPING_4_BODY_FILE_PATH2", "properties/IMVERTOR_METAMODEL_KING_EP4JSONMAPPING_4BODY_XSLPATH");
121117

122-
if (succeeds) {
123-
// concatenate
124-
YamlFile headerFile = new YamlFile(configurator.getXParm("properties/RESULT_YAMLHEADER_FILE_PATH"));
125-
JsonFile bodyFile = new JsonFile(configurator.getXParm("properties/RESULT_YAMLBODY_FILE_PATH"));
126-
//bodyFile.prettyPrint();
127-
YamlFile yamlFile = new YamlFile(configurator.getXParm("properties/RESULT_YAML_FILE_PATH2"));
128-
JsonFile bodyFile2 = new JsonFile(configurator.getXParm("properties/RESULT_YAMLBODY_FILE_PATH2"));
129-
//bodyFile2.prettyPrint();
130-
131-
// validate
132-
String hc = headerFile.getContent();
133-
succeeds = succeeds && YamlFile.validate(hc);
134-
succeeds = succeeds && bodyFile.toYaml(yamlFile);
135-
String bc = yamlFile.getContent();
136-
137-
// in all cases copy results to app folder
138-
yamlFile.setContent(hc + "\n" + bc);
139-
140-
// convert for debug purposes the Yaml file generated in line 111 to a Json-mapping file.
141-
JsonFile headerJSONFile = new JsonFile(configurator.getXParm("properties/RESULT_YAML_4_HEADER_FILE_PATH2"));
142-
XmlFile jsonXmlMappingFile4header = new XmlFile(configurator.getXParm("properties/RESULT_JSONMAPPING_4_JSONHEADER_FILE_PATH"));
143-
144-
headerFile.toJson(headerJSONFile);
145-
headerJSONFile.toXml(jsonXmlMappingFile4header);
146-
147-
//String schemaName = configurator.getXParm("appinfo/OpenAPI-schema-name");
148-
149-
// copy to the app folder
150-
AnyFile appYamlFile = new AnyFile(yamlFolder,"openapi.yaml");
151-
AnyFile appJsonFile = new AnyFile(yamlFolder,"openapi.json");
152-
AnyFile appJson2File = new AnyFile(yamlFolder,"openapi_draft04.json");
153-
yamlFile.copyFile(appYamlFile);
154-
bodyFile.copyFile(appJsonFile);
155-
bodyFile2.copyFile(appJson2File);
156-
}
157-
// pretty print and store to json folder
118+
// This is the code for generating yaml and json schema's
158119
if (succeeds) {
159120

160-
AnyFolder appFolder = new AnyFolder(configurator.getXParm("system/work-app-folder-path"));
161-
162121
// convert the json xml to Json without schema reference and than to yaml.
163122
XmlFile xmlMappingFileBody = new XmlFile(configurator.getXParm("properties/RESULT_JSONMAPPING_4_BODY_FILE_PATH"));
164123
JsonFile jsonFileBody = new JsonFile(configurator.getXParm("properties/RESULT_JSON_4_BODY_FILE_PATH"));
@@ -182,12 +141,6 @@ public boolean generateKING() throws Exception {
182141
xmlMappingFileHeader.toJson(jsonFileHeader);
183142
jsonFileHeader.toYaml(yamlFileHeader);
184143

185-
// convert for debug purposes the Json file generated in line 112 to a Json-mapping file.
186-
JsonFile jsonbodyFile = new JsonFile(configurator.getXParm("properties/RESULT_YAMLBODY_FILE_PATH"));
187-
XmlFile xmlMappingFileBody3 = new XmlFile(configurator.getXParm("properties/RESULT_JSONMAPPING_4_BODY_FILE_PATH3"));
188-
189-
jsonbodyFile.toXml(xmlMappingFileBody3);
190-
191144
// validate
192145
String hc = yamlFileHeader.getContent();
193146
String bc = yamlFileBody.getContent();
@@ -197,12 +150,10 @@ public boolean generateKING() throws Exception {
197150
// concatenate the yamlbody to the yamlheader
198151
yamlFile.setContent(hc + "\n" + bc);
199152

200-
//String schemaName = configurator.getXParm("appinfo/OpenAPI-schema-name");
201-
202153
// copy to the imvert folder !!! Must be changed to the app folder in future
203-
AnyFile appYamlFile = new AnyFile(appFolder,"openapi-test.yaml");
204-
AnyFile appJsonFile = new AnyFile(appFolder,"openapi-test.json");
205-
AnyFile appJson2File = new AnyFile(appFolder,"openapi_draft04-test.json");
154+
AnyFile appYamlFile = new AnyFile(yamlFolder,"openapi.yaml");
155+
AnyFile appJsonFile = new AnyFile(yamlFolder,"openapi.json");
156+
AnyFile appJson2File = new AnyFile(yamlFolder,"openapi_draft04.json");
206157
yamlFile.copyFile(appYamlFile);
207158
jsonFileBody.copyFile(appJsonFile);
208159
jsonFileBody2.copyFile(appJson2File);

src/main/java/nl/imvertor/common/Configurator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ public AnyFolder getBaseFolder() {
250250
public AnyFolder getWorkFolder() {
251251
return workFolder;
252252
}
253+
254+
public AnyFolder getInputFolder() {
255+
return inputFolder;
256+
}
253257

254258
public AnyFolder getWorkFolder(String subfolderName) {
255259
return new AnyFolder(workFolder,subfolderName);
@@ -1040,7 +1044,7 @@ private void loadFromPropertyFile(String filePath) throws Exception {
10401044
String optionName = e.nextElement().toString();
10411045
String value = properties.getProperty(optionName);
10421046
// process file properties in context of the current file
1043-
if (optionName.equals("umlfile") | optionName.equals("zipfile") | optionName.equals("hisfile")) {
1047+
if (optionName.equals("umlfile") | optionName.equals("zipfile") | optionName.equals("hisfile") | optionName.equals("documentorfile")) {
10441048
File parent = (new File(filePath)).getParentFile();
10451049
if (AnyFile.isAbsolutePath(value))
10461050
value = (new File(value)).getCanonicalPath();

src/main/java/nl/imvertor/common/Messenger.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.regex.Matcher;
2424
import java.util.regex.Pattern;
2525

26+
import org.apache.commons.lang3.StringUtils;
2627
import org.apache.log4j.Logger;
2728

2829
import net.sf.saxon.event.PipelineConfiguration;
@@ -173,7 +174,14 @@ public void writeMsg(String src, String type, String name, String text, String i
173174
cfg.addProperty("messages/message[" + messageIndex + "]/steptext", m.group(3));
174175
}
175176
if (id != null) cfg.addProperty("messages/message[" + messageIndex + "]/id", id);
176-
cfg.addProperty("messages/message[" + messageIndex + "]/wiki", (wiki != null) ? wiki : "NOWIKI");
177+
178+
// bepaal of de wiki message apart moet worden afgehandeld. Dat is bijv. #XERCES-s4s-att-invalid-value
179+
if (wiki == null)
180+
wiki = "NOWIKI";
181+
else if (wiki.startsWith("#")) {
182+
wiki = StringUtils.split(wiki.substring(1),'-')[0];
183+
}
184+
cfg.addProperty("messages/message[" + messageIndex + "]/wiki", wiki);
177185
}
178186
}
179187
}

src/main/java/nl/imvertor/common/file/AnyFolder.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public AnyFolder(File parent, String filename) {
6666
}
6767

6868
/**
69-
* Create a copy of this folder within the target folder.
70-
* Example /a -> /b creates : /b/a/*
69+
* Create a copy of the files in this folder within the target folder.
70+
* Example /a/m -> /b creates : /b/m/*
7171
*
7272
* @param targetFolder
7373
* @throws Exception
@@ -109,6 +109,20 @@ public void copy(String targetFolderPath) throws Exception {
109109
copy(new AnyFolder(targetFolderPath),true);
110110
}
111111

112+
/**
113+
* Copy this folder as a new subfolder within target folder, under the source folder name.
114+
* Overwrite any existing files/folders.
115+
*
116+
* Example /a -> /b creates : /b/a
117+
*
118+
* @param targetFolderPath
119+
* @throws Exception
120+
*/
121+
public void copyFolder(AnyFolder targetFolder) throws Exception {
122+
targetFolder = new AnyFolder(targetFolder.getCanonicalPath() + "/" + getName());
123+
FileUtils.copyDirectory(this, targetFolder);
124+
}
125+
112126
public boolean hasFile(String filename) throws IOException {
113127
if (!this.exists() || this.isFile()) return false;
114128
return (new File(this.getCanonicalPath() + File.separator + filename)).isFile();

src/main/java/nl/imvertor/common/file/HttpFile.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
import java.io.IOException;
66
import java.io.InputStreamReader;
77
import java.net.URI;
8+
import java.nio.charset.StandardCharsets;
89
import java.util.ArrayList;
910
import java.util.HashMap;
1011
import java.util.Iterator;
1112
import java.util.List;
1213
import java.util.Map;
1314
import java.util.Map.Entry;
1415

16+
import org.apache.commons.io.IOUtils;
1517
import org.apache.http.HttpEntity;
1618
import org.apache.http.HttpResponse;
1719
import org.apache.http.NameValuePair;
@@ -220,13 +222,7 @@ public int getStatus() {
220222
return status;
221223
}
222224
public String getResponseBody(HttpResponse response) throws Exception, IOException {
223-
BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
224-
String inputLine;
225-
StringBuffer responseText = new StringBuffer();
226-
while ((inputLine = in.readLine()) != null)
227-
responseText.append(inputLine);
228-
in.close();
229-
return responseText.toString();
225+
return IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
230226
}
231227

232228
}

src/main/java/nl/imvertor/common/file/RdfFile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ public void parse(Configurator configurator) throws Exception {
9090
} else if (ext.equals("yml")) {
9191

9292
// TODO
93-
configurator.getRunner().error(logger,"Not a supported RDF file extension: " + ext,null,"rdf-uns","some-wiki-ref");
93+
configurator.getRunner().error(logger,"Not a supported RDF file extension: \"" + ext + "\"",null,"rdf-uns","RDF-NASRFE1");
9494

9595
} else
96-
configurator.getRunner().fatal(logger,"Not a known RDF file extension: " + ext,null,"rdf-unk","some-wiki-ref");
96+
configurator.getRunner().fatal(logger,"Not a known RDF file extension: \"" + ext + "\"",null,"rdf-unk","RDF-NAKRFE1");
9797

9898
isOpen = true;
9999
} else {

src/main/java/nl/imvertor/common/file/ShaclFile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ public void parse(Configurator configurator, String ttlDataFilePath) throws Exce
113113
} catch (RepositoryException exception) {
114114
Throwable cause = exception.getCause();
115115
if (cause instanceof ValidationException) {
116-
runner.error(logger, "Shacl validator reports RDF error: " + exception.getMessage());
116+
runner.error(logger, "Shacl validator reports RDF error: \"" + exception.getMessage() + "\"","shacl-parse","SHACL-SVRRE1");
117117
} else
118118
throw exception;
119119
}
120120
}
121121

122122
} catch (Exception e) {
123-
runner.warn(logger, "Shacl validator schema file \"" + getName() + "\" invalid, cannot validate RDF. " + e.getMessage(),"rdf-parse","some-wiki-ref");
123+
runner.warn(logger, "Shacl validator schema file \"" + getName() + "\" invalid, cannot validate RDF: \"" + e.getMessage() + "\"","rdf-parse","SHACL-SVSF1ICVR2");
124124
}
125125

126126
}

0 commit comments

Comments
 (0)