use of org.hl7.fhir.definitions.parsers.spreadsheets.SpreadSheetReloader in project kindling by HL7.
the class SourceParser method loadResource.
private ResourceDefn loadResource(String n, Map<String, ResourceDefn> map, boolean isAbstract, boolean isTemplate, String t, boolean isInterface) throws Exception {
String folder = n;
WorkGroup wg = definitions.getWorkgroups().get(ini.getStringProperty("workgroups", n));
if (wg == null)
throw new Exception("No Workgroup found for resource " + n + ": '" + ini.getStringProperty("workgroups", n) + "'");
File f = new File(Utilities.path(srcDir, folder, n + ".svg"));
if (isTemplate) {
File spreadsheet = new CSFile((srcDir) + folder + File.separatorChar + n + "-spreadsheet.xml");
OldSpreadsheetParser sparser = new OldSpreadsheetParser("core", new CSFileInputStream(spreadsheet), spreadsheet.getName(), spreadsheet.getAbsolutePath(), definitions, srcDir, logger, registry, version, context, genDate, isAbstract, page, false, ini, wg, definitions.getProfileIds(), fpUsages, page.getConceptMaps(), exceptionIfExcelNotNormalised, page.packageInfo(), page.getRc());
ResourceDefn root;
try {
root = sparser.parseResource(isTemplate);
} catch (Exception e) {
throw new Exception("Error Parsing Resource " + n + ": " + e.getMessage(), e);
}
root.setAbstract(isAbstract);
root.setInterface(isInterface);
errors.addAll(sparser.getErrors());
setResourceProps(n, wg, root);
String sc = ini.getStringProperty("security-categorization", root.getName().toLowerCase());
if (sc != null) {
root.setSecurityCategorization(SecurityCategorization.fromCode(sc));
} else if (!Utilities.existsInList(root.getName(), "Resource", "DomainResource", "CanonicalResource", "MetadataResource", "MetadataPattern"))
throw new Exception("Must have an entry in the security-categorization section of fhir.ini for the resource " + root.getName());
for (EventDefn e : sparser.getEvents()) {
processEvent(e, root.getRoot());
}
if (map != null) {
map.put(root.getName(), root);
}
if (!isTemplate) {
definitions.getKnownResources().put(root.getName(), new DefinedCode(root.getName(), root.getRoot().getDefinition(), n));
context.getResourceNames().add(root.getName());
}
if (root.getNormativeVersion() != null || root.getNormativePackage() != null) {
root.setStatus(StandardsStatus.NORMATIVE);
}
if (f.exists()) {
parseSvgFile(f, root.getLayout(), f.getName());
}
if (map != null) {
map.put(root.getName(), root);
}
return root;
} else {
try {
new SpreadSheetReloader(context, srcDir, t, version.toCode()).process();
} catch (Exception e) {
System.out.println("Error loading spreadsheet for resource " + t + ": " + e.getMessage());
}
new SpreadSheetCreator(context, srcDir, t).generateSpreadsheet();
ResourceDefn rootNew = new ResourceParser(srcDir, definitions, context, wg, registry, version.toCode(), page.getConceptMaps()).parse(n, t);
if (f.exists()) {
parseSvgFile(f, rootNew.getLayout(), f.getName());
}
if (!isTemplate) {
definitions.getKnownResources().put(rootNew.getName(), new DefinedCode(rootNew.getName(), rootNew.getRoot().getDefinition(), n));
context.getResourceNames().add(rootNew.getName());
}
setResourceProps(n, wg, rootNew);
if (map != null) {
map.put(rootNew.getName(), rootNew);
}
return rootNew;
}
}
Aggregations