use of org.hl7.fhir.utilities.IniFile in project kindling by HL7.
the class Publisher method execute.
/**
* Entry point to the publisher. This classes Java Main() calls this function
* to actually produce the specification
*
* @param folder
* @throws IOException
*/
public void execute(String folder) throws IOException {
tester = new PublisherTestSuites();
page.log("Publish FHIR in folder " + folder + " @ " + Config.DATE_FORMAT().format(page.getGenDate().getTime()), LogMessageType.Process);
if (web)
page.log("Build final copy for HL7 web site", LogMessageType.Process);
else
page.log("Build local copy", LogMessageType.Process);
if (outputdir != null) {
page.log("Create output in " + outputdir, LogMessageType.Process);
}
page.log("Detected Java version: " + System.getProperty("java.version") + " from " + System.getProperty("java.home") + " on " + System.getProperty("os.arch"), LogMessageType.Process);
try {
tester.initialTests();
page.setFolders(new FolderManager(folder, outputdir));
if (!initialize(folder))
throw new Exception("Unable to publish as preconditions aren't met");
cache = new IniFile(page.getFolders().rootDir + "temp" + File.separator + "build.cache");
loadSuppressedMessages(page.getFolders().rootDir);
boolean doAny = false;
for (String n : dates.keySet()) {
Long d = cache.getLongProperty("dates", n);
boolean b = d == null || (dates.get(n) > d);
cache.setLongProperty("dates", n, dates.get(n).longValue(), null);
buildFlags.put(n.toLowerCase(), b);
doAny = doAny || b;
}
cache.save();
if (noPartialBuild || !doAny || !(new File(page.getFolders().dstDir + "qa.html").exists()))
// nothing - build all
buildFlags.put("all", true);
if (singlePage != null) {
for (String n : buildFlags.keySet()) buildFlags.put(n, false);
buildFlags.put("page-" + singlePage.toLowerCase(), true);
} else if (singleResource != null) {
for (String n : buildFlags.keySet()) buildFlags.put(n, false);
buildFlags.put(singleResource.toLowerCase(), true);
}
if (!buildFlags.get("all")) {
if (!noSound) {
AudioUtilities.tone(1000, 10);
AudioUtilities.tone(1400, 10);
AudioUtilities.tone(1800, 10);
AudioUtilities.tone(1000, 10);
AudioUtilities.tone(1400, 10);
AudioUtilities.tone(1800, 10);
}
page.log("Partial Build (if you want a full build, just run the build again)", LogMessageType.Process);
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
for (String n : buildFlags.keySet()) if (buildFlags.get(n))
b.append(n);
page.log(" Build: " + b.toString(), LogMessageType.Process);
} else {
if (!noSound)
AudioUtilities.tone(1200, 30);
page.log("Full Build", LogMessageType.Process);
}
if (isGenerate && page.getBuildId() == null)
page.setBuildId(getGitBuildId());
page.log("Version " + page.getVersion() + "-" + page.getBuildId(), LogMessageType.Hint);
Utilities.createDirectory(page.getFolders().dstDir);
Utilities.deleteTempFiles();
page.getBreadCrumbManager().parse(page.getFolders().srcDir + "hierarchy.xml");
page.loadSnomed();
page.loadLoinc();
page.loadUcum();
buildFeedsAndMaps();
prsr.setExternals(externals);
prsr.parse(page.getGenDate(), page.getValidationErrors());
for (String n : page.getDefinitions().sortedResourceNames()) if (!page.getBreadCrumbManager().knowsResource(n))
page.getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.INVALID, -1, -1, "hierarchy.xml", "Resource not found: " + n, IssueSeverity.ERROR));
for (String n : prsr.getErrors()) page.getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.INVALID, -1, -1, "source spreadsheets", n, IssueSeverity.ERROR));
if (web) {
page.log("Clear Directory", LogMessageType.Process);
Utilities.clearDirectory(page.getFolders().dstDir);
}
if (web || (isGenerate && buildFlags.get("all"))) {
Utilities.createDirectory(page.getFolders().dstDir + "html");
Utilities.createDirectory(page.getFolders().dstDir + "examples");
}
for (ImplementationGuideDefn ig : page.getDefinitions().getSortedIgs()) if (!ig.isCore())
Utilities.createDirectory(page.getFolders().dstDir + ig.getCode());
if (buildFlags.get("all")) {
copyStaticContent();
}
page.makeRenderingContext();
loadValueSets1();
prsr.getRegistry().commit();
generateSCMaps();
validate();
processProfiles();
checkAllOk();
if (isGenerate) {
produceSpecification();
checkAllOk();
}
if (doValidate)
validationProcess();
page.saveSnomed();
page.getWorkerContext().saveCache();
processWarnings(false);
if (isGenerate && buildFlags.get("all"))
produceQA();
if (!buildFlags.get("all")) {
page.log("This was a Partial Build", LogMessageType.Process);
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
for (String n : buildFlags.keySet()) if (buildFlags.get(n))
b.append(n);
page.log(" Build: " + b.toString(), LogMessageType.Process);
} else
page.log("This was a Full Build", LogMessageType.Process);
if (!noSound) {
AudioUtilities.tone(800, 10);
AudioUtilities.tone(1000, 10);
AudioUtilities.tone(1200, 10);
AudioUtilities.tone(1000, 10);
AudioUtilities.tone(800, 10);
}
page.log("Finished publishing FHIR @ " + Config.DATE_FORMAT().format(Calendar.getInstance().getTime()), LogMessageType.Process);
} catch (Exception e) {
if (!(e instanceof NullPointerException)) {
// because NullPointerException is unexpected...
try {
processWarnings(e instanceof EValidationFailed);
} catch (Exception e2) {
page.log(" ERROR: Unable to process warnings: " + e2.getMessage(), LogMessageType.Error);
e2.printStackTrace();
}
}
if (buildFlags.containsKey("all") && !buildFlags.get("all")) {
page.log("This was a Partial Build", LogMessageType.Process);
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
for (String n : buildFlags.keySet()) if (buildFlags.get(n))
b.append(n);
page.log(" Build: " + b.toString(), LogMessageType.Process);
} else
page.log("This was a Full Build", LogMessageType.Process);
if (!noSound) {
AudioUtilities.tone(800, 20);
AudioUtilities.tone(1000, 20);
AudioUtilities.tone(1200, 20);
}
try {
Thread.sleep(50);
} catch (InterruptedException e1) {
}
if (!noSound) {
AudioUtilities.tone(800, 20);
AudioUtilities.tone(1000, 20);
AudioUtilities.tone(1200, 20);
}
try {
Thread.sleep(50);
} catch (InterruptedException e1) {
}
if (!noSound) {
AudioUtilities.tone(800, 20);
AudioUtilities.tone(1000, 20);
AudioUtilities.tone(1200, 20);
}
page.log("FHIR build failure @ " + Config.DATE_FORMAT().format(Calendar.getInstance().getTime()), LogMessageType.Process);
System.out.println("Error: " + e.getMessage());
e.printStackTrace();
TextFile.stringToFile(StringUtils.defaultString(e.getMessage()), Utilities.path(folder, "publish", "simple-error.txt"));
System.exit(1);
}
}
use of org.hl7.fhir.utilities.IniFile in project kindling by HL7.
the class PageProcessor method makeArchives.
private String makeArchives() throws Exception {
IniFile ini = new IniFile(folders.rootDir + "publish.ini");
StringBuilder s = new StringBuilder();
s.append("<h2>Archived Versions of FHIR</h2>");
s.append("<p>These archives only keep the more significant past versions of FHIR, and only the book form, and are provided for purposes of supporting html diff tools. A full archive history of everything is available <a href=\"http://wiki.hl7.org/index.php?title=FHIR\">through the HL7 gForge archives</a>.</p>");
s.append("<ul>");
if (ini.getPropertyNames("Archives") != null) {
for (String v : ini.getPropertyNames("Archives")) {
s.append("<li><a href=\"http://www.hl7.org/implement/standards/FHIR/v").append(v).append("/index.htm\">Version ").append(v).append("</a>, ").append(ini.getStringProperty("Archives", v)).append("</li>");
if (!definitions.getPastVersions().contains(v))
definitions.getPastVersions().add(v);
}
}
s.append("</ul>");
return s.toString();
}
use of org.hl7.fhir.utilities.IniFile in project kindling by HL7.
the class PageProcessor method expandVS.
public String expandVS(ValueSet vs, String prefix, String base) {
try {
ValueSetExpansionOutcome result = workerContext.expandVS(vs, true, true);
if (result.getError() != null)
return "<hr/>\r\n" + VS_INC_START + "<!--3-->" + processExpansionError(result.getError()) + VS_INC_END;
if (result.getValueset() == null)
return "<hr/>\r\n" + VS_INC_START + "<!--4-->" + processExpansionError("(no error returned)") + VS_INC_END;
ValueSet exp = result.getValueset();
if (exp == vs)
throw new Exception("Expansion cannot be the same instance");
exp.setCompose(null);
exp.setText(null);
exp.setDescription("Value Set Contents (Expansion) for " + vs.present() + " at " + Config.DATE_FORMAT().format(new Date()));
int i = countContains(exp.getExpansion().getContains());
IniFile sini = new IniFile(Utilities.path(folders.rootDir, "temp", "stats.ini"));
sini.setIntegerProperty("valuesets", vs.getId(), i, null);
sini.save();
RenderingContext lrc = rc.copy().setLocalPrefix(prefix).setTooCostlyNoteEmpty(TOO_MANY_CODES_TEXT_EMPTY).setTooCostlyNoteNotEmpty(TOO_MANY_CODES_TEXT_NOT_EMPTY);
RendererFactory.factory(exp, lrc).render(exp);
return "<hr/>\r\n" + VS_INC_START + "" + new XhtmlComposer(XhtmlComposer.HTML).compose(exp.getText().getDiv()) + VS_INC_END;
} catch (Exception e) {
e.printStackTrace();
return "<hr/>\r\n" + VS_INC_START + "<!--5-->" + processExpansionError(e instanceof NullPointerException ? "NullPointerException" : e.getMessage()) + " " + Utilities.escapeXml(stack(e)) + VS_INC_END;
}
}
use of org.hl7.fhir.utilities.IniFile in project kindling by HL7.
the class SpecNPMPackageGenerator method determineVersion.
private FHIRVersion determineVersion(Map<String, byte[]> files) throws FHIRException {
byte[] b = files.get("version.info");
if (b == null)
return FHIRVersion.NULL;
String s = new String(b);
s = Utilities.stripBOM(s).trim();
while (s.charAt(0) != '[') s = s.substring(1);
byte[] bytes = {};
try {
bytes = s.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
}
ByteArrayInputStream bs = new ByteArrayInputStream(bytes);
IniFile ini = new IniFile(bs);
String v = ini.getStringProperty("FHIR", "version");
if (v == null)
throw new Error("unable to determine version from " + new String(bytes));
if ("3.0.0".equals(v))
v = "3.0.1";
return FHIRVersion.fromCode(v);
}
use of org.hl7.fhir.utilities.IniFile in project kindling by HL7.
the class SourceParser method loadW5s.
private void loadW5s() throws IOException {
if (new File(Utilities.path(srcDir, "w5.ini")).exists()) {
IniFile w5 = new IniFile(Utilities.path(srcDir, "w5.ini"));
for (String n : w5.getPropertyNames("names")) {
W5Entry w5o = new W5Entry(n, w5.getStringProperty("names", n), w5.getBooleanProperty("display", n), w5.getStringProperty("subclasses", n), w5.getStringProperty("fivews", n));
definitions.getW5list().add(w5o);
definitions.getW5s().put(n, w5o);
}
}
}
Aggregations