use of org.hl7.fhir.utilities.IniFile in project kindling by HL7.
the class SpreadSheetCreator method generateSpreadsheet.
public void generateSpreadsheet() throws FHIRFormatError, FileNotFoundException, IOException {
String tgt = fnSpreadsheet();
File t = new File(tgt);
if (t.exists()) {
t.delete();
}
if (t.exists()) {
System.out.println(tgt + " not updated - open in excel");
} else {
XSSFWorkbook excel = new XSSFWorkbook();
makeStyles(excel);
XSSFSheet bindings = addResourceSheets(excel);
addSearchParams(excel);
addOperations(excel, bindings);
addExamples(excel);
addPacks(excel);
try (FileOutputStream outputStream = new FileOutputStream(tgt)) {
excel.write(outputStream);
} catch (Exception e) {
System.out.println("Error writing to " + tgt + " " + e.getMessage());
}
new File(tgt).setLastModified(date);
IniFile ini = new IniFile(Utilities.changeFileExt(tgt, ".datestamp"));
ini.setLongProperty("spreadsheet", "date", date, "Never change this date manually");
ini.save();
}
}
use of org.hl7.fhir.utilities.IniFile in project kindling by HL7.
the class SpreadSheetReloader method process.
public void process() throws Exception {
xlsx = fnSpreadsheet();
IniFile ini = new IniFile(Utilities.changeFileExt(xlsx, ".datestamp"));
File t = new File(xlsx);
File cfg = new File(Utilities.changeFileExt(xlsx, ".datestamp"));
if (t.exists() && cfg.exists() && ini.hasProperty("spreadsheet", "date") && t.lastModified() > ini.getLongProperty("spreadsheet", "date")) {
date = t.lastModified();
// ok, we read the spreadsheet
XSSFWorkbook excel = new XSSFWorkbook(new FileInputStream(xlsx));
processResource(excel);
processSearchParams(excel);
processExamples(excel);
processOperations(excel);
processPacks(excel);
}
}
use of org.hl7.fhir.utilities.IniFile in project kindling by HL7.
the class SourceParser method isRuledOutLocally.
private boolean isRuledOutLocally(String code) throws IOException {
String inifile = Utilities.path(rootDir, "local.ini");
if (!new File(inifile).exists())
return false;
IniFile ini = new IniFile(inifile);
boolean ok = "false".equals(ini.getStringProperty("igs", code));
return ok;
}
use of org.hl7.fhir.utilities.IniFile in project kindling by HL7.
the class JsonLDDefinitionsGenerator method generate.
// private String genDate;
// private String version;
// private BuildWorkerContext workerContext;
public void generate(Definitions definitions, IniFile ini, String tmpResDir, String dstDir, String srcDir, FHIRVersion version, String genDate, BuildWorkerContext workerContext) throws Exception {
// this.genDate = genDate;
// this.version = version;
// this.workerContext = workerContext;
JsonObject defn = new JsonObject();
JsonObject context = new JsonObject();
defn.add("@context", context);
defn.addProperty("@id", "http://hl7.org/fhir/");
context.addProperty("fhir", "http://hl7.org/fhir/");
context.addProperty("xsd", "http://www.w3.org/2001/XMLSchema#");
// properties for primitives, helpers, format features
addProperty(context, "value", "fhir:value", "xsd:string");
addProperty(context, "decimal", "fhir:value", "xsd:decimal");
addProperty(context, "integer", "fhir:value", "xsd:integer");
if (!version.isR4B()) {
addProperty(context, "integer64", "fhir:value", "xsd:string");
}
addProperty(context, "boolean", "fhir:value", "xsd:boolean");
addProperty(context, "binary", "fhir:value", "xsd:base64Binary");
addProperty(context, "date", "fhir:value", "xsd:date");
addProperty(context, "dateTime", "fhir:value", "xsd:dateTime");
addProperty(context, "gYearMonth", "fhir:value", "xsd:gYearMonth");
addProperty(context, "gYear", "fhir:value", "xsd:gYear");
addProperty(context, "link", "fhir:link", "@id");
addProperty(context, "concept", "fhir:concept", "@id");
addProperty(context, "index", "fhir:index", "xsd:integer");
addProperty(context, "role", "fhir:nodeRole", "@id");
// elements defined in FHIR:
for (TypeRef tr : definitions.getKnownTypes()) {
if (!definitions.hasPrimitiveType(tr.getName()) && !tr.getName().equals("SimpleQuantity") && !tr.getName().equals("MoneyQuantity")) {
TypeDefn root = definitions.getElementDefn(tr.getName());
new JsonLDGenerator(definitions, workerContext, definitions.getKnownTypes()).generate(context, root, version, genDate);
}
}
List<String> names = new ArrayList<String>();
names.addAll(definitions.getResources().keySet());
names.addAll(definitions.getBaseResources().keySet());
names.add("Parameters");
Collections.sort(names);
for (String name : names) {
ResourceDefn root = definitions.getResourceByName(name);
new JsonLDGenerator(definitions, workerContext, definitions.getKnownTypes()).generate(context, root.getRoot(), version, genDate);
}
save(defn, dstDir + "fhir.jsonld");
}
use of org.hl7.fhir.utilities.IniFile in project kindling by HL7.
the class Publisher method initialize.
private boolean initialize(String folder) throws Exception {
HierarchicalTableGenerator.ACTIVE_TABLES = true;
page.setDefinitions(new Definitions());
page.getWorkerContext().setCanRunWithoutTerminology(!web);
page.log("Checking Source for " + folder, LogMessageType.Process);
List<String> errors = new ArrayList<String>();
Utilities.checkFolder(page.getFolders().rootDir, errors);
if (checkFile("required", page.getFolders().rootDir, "publish.ini", errors, "all")) {
checkFile("required", page.getFolders().srcDir, "navigation.xml", errors, "all");
page.setIni(new IniFile(page.getFolders().rootDir + "publish.ini"));
page.setVersion(FHIRVersion.fromCode(page.getIni().getStringProperty("FHIR", "version")));
prsr = new SourceParser(page, folder, page.getDefinitions(), web, page.getVersion(), page.getWorkerContext(), page.getGenDate(), page, fpUsages, isCIBuild);
prsr.checkConditions(errors, dates);
page.setRegistry(prsr.getRegistry());
page.getDiffEngine().loadFromIni(prsr.getIni());
for (String s : page.getIni().getPropertyNames("special-pages")) page.getDefinitions().getStructuralPages().add(s);
Utilities.checkFolder(page.getFolders().xsdDir, errors);
checkFile("required", page.getFolders().srcDir, "hierarchy.xml", errors, "all");
checkFile("required", page.getFolders().srcDir, "fhir-all.xsd", errors, "all");
checkFile("required", page.getFolders().templateDir, "template.html", errors, "all");
checkFile("required", page.getFolders().templateDir, "template-book.html", errors, "all");
checkFile("required", page.getFolders().srcDir, "mappingSpaces.xml", errors, "all");
if (page.getIni().getPropertyNames("support") != null)
for (String n : page.getIni().getPropertyNames("support")) checkFile("support", page.getFolders().srcDir, n, errors, "all");
for (String n : page.getIni().getPropertyNames("images")) checkFile("image", page.getFolders().imgDir, n, errors, "all");
for (String n : page.getIni().getPropertyNames("schema")) checkFile("schema", page.getFolders().srcDir, n, errors, "all");
for (String n : page.getIni().getPropertyNames("pages")) checkFile("page", page.getFolders().srcDir, n, errors, "page-" + n);
for (String n : page.getIni().getPropertyNames("files")) checkFile("file", page.getFolders().rootDir, n, errors, "page-" + n);
}
if (checkFile("translations", page.getFolders().rootDir + "implementations" + File.separator, "translations.xml", errors, null)) {
// schema check
XmlValidator xv = new XmlValidator(page.getValidationErrors(), page.getFolders().rootDir + "implementations", Utilities.path(page.getFolders().rootDir, "tools", "schematron"), new String[] { "translations.xsd" });
xv.checkBySchema(Utilities.path(page.getFolders().rootDir, "implementations", "translations.xml"), true);
Utilities.copyFile(page.getFolders().rootDir + "implementations" + File.separator + "translations.xml", page.getFolders().dstDir + "translations.xml");
page.getTranslations().setLang("en");
page.getTranslations().load(page.getFolders().rootDir + "implementations" + File.separator + "translations.xml");
}
if (errors.size() > 0)
page.log("Unable to publish FHIR specification:", LogMessageType.Error);
for (String e : errors) {
page.log(e, LogMessageType.Error);
}
return errors.size() == 0;
}
Aggregations