Removed BASE directive, sorted value-set rendering and correct imports
This commit is contained in:
parent
a593e9a60d
commit
6ba6a0ae62
|
@ -63,7 +63,7 @@ public class ShExGenerator {
|
||||||
|
|
||||||
public boolean debugMode = false; // Used for Debugging and testing the code
|
public boolean debugMode = false; // Used for Debugging and testing the code
|
||||||
|
|
||||||
public boolean processConstraints = true; // set to false - to skip processing constraints
|
public boolean processConstraints = false; // set to false - to skip processing constraints
|
||||||
|
|
||||||
public ConstraintTranslationPolicy constraintPolicy = ConstraintTranslationPolicy.ALL;
|
public ConstraintTranslationPolicy constraintPolicy = ConstraintTranslationPolicy.ALL;
|
||||||
|
|
||||||
|
@ -79,8 +79,8 @@ public class ShExGenerator {
|
||||||
"PREFIX fhir: <$fhir$> \n" +
|
"PREFIX fhir: <$fhir$> \n" +
|
||||||
"PREFIX fhirvs: <$fhirvs$>\n" +
|
"PREFIX fhirvs: <$fhirvs$>\n" +
|
||||||
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> \n" +
|
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> \n" +
|
||||||
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
|
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n";
|
||||||
"BASE <http://hl7.org/fhir/shape/>\n";
|
//"BASE <http://hl7.org/fhir/shape/>\n";
|
||||||
|
|
||||||
private static String IMPORT_TEMPLATE = "IMPORT <$import$$fileExt$>\n";
|
private static String IMPORT_TEMPLATE = "IMPORT <$import$$fileExt$>\n";
|
||||||
|
|
||||||
|
@ -486,8 +486,27 @@ public class ShExGenerator {
|
||||||
|
|
||||||
if (required_value_sets.size() > 0) {
|
if (required_value_sets.size() > 0) {
|
||||||
shapeDefinitions.append("\n#---------------------- Value Sets ------------------------\n");
|
shapeDefinitions.append("\n#---------------------- Value Sets ------------------------\n");
|
||||||
|
List<String> sortedVS = new ArrayList<String>();
|
||||||
for (ValueSet vs : required_value_sets)
|
for (ValueSet vs : required_value_sets)
|
||||||
shapeDefinitions.append("\n").append(genValueSet(vs));
|
sortedVS.add(genValueSet(vs));
|
||||||
|
|
||||||
|
Collections.sort(sortedVS, new Comparator<String>() {
|
||||||
|
@Override
|
||||||
|
public int compare(String o1, String o2) {
|
||||||
|
try {
|
||||||
|
return StringUtils.substringBetween(o1, "fhirvs:", " ")
|
||||||
|
.compareTo(StringUtils.substringBetween(o2, "fhirvs:", " "));
|
||||||
|
}
|
||||||
|
catch(Exception e){
|
||||||
|
debug("SORT COMPARISON FAILED BETWEEN \n\t\t" + o1 + "\n\t\t and \n\t\t" + o2);
|
||||||
|
debug(e.getMessage());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (String svs : sortedVS)
|
||||||
|
shapeDefinitions.append("\n").append(svs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((unMappedFunctions != null) && (!unMappedFunctions.isEmpty())) {
|
if ((unMappedFunctions != null) && (!unMappedFunctions.isEmpty())) {
|
||||||
|
@ -1426,8 +1445,14 @@ public class ShExGenerator {
|
||||||
while (m.find()) {
|
while (m.find()) {
|
||||||
String tag = m.group(1);
|
String tag = m.group(1);
|
||||||
//System.out.println("FOUND IMPORT: " + tag);
|
//System.out.println("FOUND IMPORT: " + tag);
|
||||||
if ((tag.indexOf(ONE_OR_MORE_PREFIX) == -1) &&
|
if (tag.indexOf(ONE_OR_MORE_PREFIX) != -1) {
|
||||||
(!imports.contains(tag)))
|
tag = tag.substring(ONE_OR_MORE_PREFIX.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((tag.indexOf("_") != -1)||(tag.indexOf("_OR_") != -1))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!imports.contains(tag))
|
||||||
imports.add(tag);
|
imports.add(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,10 +46,10 @@ public class ShexGeneratorTests {
|
||||||
// If you un-comment the following lines, please comment all other lines in this method.
|
// If you un-comment the following lines, please comment all other lines in this method.
|
||||||
// Test with processing constraints flag
|
// Test with processing constraints flag
|
||||||
// ----------------- Uncomment following to testing/Debugging -----
|
// ----------------- Uncomment following to testing/Debugging -----
|
||||||
// boolean processConstraints = true;
|
// boolean processConstraints = false;
|
||||||
// this.doTestSingleSD(name.toLowerCase(), cat, name,
|
// this.doTestSingleSD(name.toLowerCase(), cat, name,
|
||||||
// false, ShExGenerator.ConstraintTranslationPolicy.ALL,
|
// false, ShExGenerator.ConstraintTranslationPolicy.ALL,
|
||||||
// true, true, false, processConstraints);
|
// true, true, false, processConstraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -145,7 +145,7 @@ public class ShexGeneratorTests {
|
||||||
// BatchMode - All Shex Schemas in one single file
|
// BatchMode - All Shex Schemas in one single file
|
||||||
false,
|
false,
|
||||||
// process constraints or not
|
// process constraints or not
|
||||||
true
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue