code generation clean up
This commit is contained in:
parent
ef085a847e
commit
1e49751242
|
@ -0,0 +1,59 @@
|
|||
package org.hl7.fhir.core.generator.engine;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.model.CapabilityStatement;
|
||||
import org.hl7.fhir.r5.model.CodeSystem;
|
||||
import org.hl7.fhir.r5.model.CompartmentDefinition;
|
||||
import org.hl7.fhir.r5.model.ConceptMap;
|
||||
import org.hl7.fhir.r5.model.OperationDefinition;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.SearchParameter;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.utilities.cache.NpmPackage;
|
||||
import org.hl7.fhir.utilities.cache.PackageCacheManager;
|
||||
import org.hl7.fhir.utilities.cache.ToolsVersion;
|
||||
|
||||
public class DefinitionsLoader {
|
||||
|
||||
public static Definitions load(NpmPackage npm) throws IOException {
|
||||
Definitions res = new Definitions();
|
||||
|
||||
for (String t : npm.listResources("CodeSystem")) {
|
||||
res.getCodeSystems().see((CodeSystem) load(npm, t));
|
||||
}
|
||||
for (String t : npm.listResources("ValueSet")) {
|
||||
res.getValuesets().see((ValueSet) load(npm, t));
|
||||
}
|
||||
for (String t : npm.listResources("ConceptMap")) {
|
||||
res.getConceptMaps().see((ConceptMap) load(npm, t));
|
||||
}
|
||||
for (String t : npm.listResources("CapabilityStatement")) {
|
||||
res.getStatements().see((CapabilityStatement) load(npm, t));
|
||||
}
|
||||
for (String t : npm.listResources("StructureDefinition")) {
|
||||
res.getStructures().see((StructureDefinition) load(npm, t));
|
||||
}
|
||||
for (String t : npm.listResources("OperationDefinition")) {
|
||||
res.getOperations().see((OperationDefinition) load(npm, t));
|
||||
}
|
||||
for (String t : npm.listResources("SearchParameter")) {
|
||||
res.getSearchParams().see((SearchParameter) load(npm, t));
|
||||
}
|
||||
for (String t : npm.listResources("CompartmentDefinition")) {
|
||||
res.getCompartments().see((CompartmentDefinition) load(npm, t));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static Resource load(NpmPackage npm, String t) {
|
||||
try {
|
||||
return new JsonParser().parse(npm.loadResource(t));
|
||||
} catch (Exception e) {
|
||||
throw new Error("Error reading "+t+": "+e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,7 +19,6 @@ import org.hl7.fhir.core.generator.codegen.JavaParserJsonGenerator;
|
|||
import org.hl7.fhir.core.generator.codegen.JavaParserRdfGenerator;
|
||||
import org.hl7.fhir.core.generator.codegen.JavaParserXmlGenerator;
|
||||
import org.hl7.fhir.core.generator.codegen.JavaResourceGenerator;
|
||||
import org.hl7.fhir.core.generator.loader.DefinitionsLoader;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
|
||||
|
@ -43,7 +42,7 @@ public class JavaCoreGenerator {
|
|||
System.out.println("HAPI CORE Code Generator");
|
||||
if (args.length != 3) {
|
||||
System.out.println("Usage: invoke with 3 command line parameters to generate HAPI R5 code");
|
||||
System.out.println("1: fhir version to generate from (e.g. 4.1.0 or 'current'");
|
||||
System.out.println("1: fhir version to generate from (e.g. 4.2.0 or 'current'");
|
||||
System.out.println("2: project directory to read java-adorment from - e.g. C:\\work\\org.hl7.fhir\\org.hl7.fhir.core\\org.hl7.fhir.r5");
|
||||
System.out.println("3: project directory to generate code into - e.g. C:\\work\\org.hl7.fhir\\org.hl7.fhir.core\\org.hl7.fhir.r5.new");
|
||||
} else {
|
||||
|
|
|
@ -11332,6 +11332,15 @@ When pattern[x] is used to constrain a complex object, it means that each proper
|
|||
return b.toString();
|
||||
}
|
||||
|
||||
public String typeSummaryVB() {
|
||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder("|");
|
||||
for (TypeRefComponent tr : getType()) {
|
||||
if (tr.hasCode())
|
||||
b.append(tr.getWorkingCode());
|
||||
}
|
||||
return b.toString().replace(" ", "");
|
||||
}
|
||||
|
||||
|
||||
public TypeRefComponent getType(String code) {
|
||||
for (TypeRefComponent tr : getType())
|
||||
|
|
Loading…
Reference in New Issue