use of org.hl7.fhir.utilities.graphql.Package in project org.hl7.fhir.core by hapifhir.
the class NPMPackageGenerator method loadFiles.
public void loadFiles(String root, File dir, String... noload) throws IOException {
for (File f : dir.listFiles()) {
if (!Utilities.existsInList(f.getName(), noload)) {
if (f.isDirectory()) {
loadFiles(root, f);
} else {
String path = f.getAbsolutePath().substring(root.length() + 1);
byte[] content = TextFile.fileToBytes(f);
if (created.contains(path))
System.out.println("Duplicate package file " + path);
else {
created.add(path);
TarArchiveEntry entry = new TarArchiveEntry(path);
entry.setSize(content.length);
tar.putArchiveEntry(entry);
tar.write(content);
tar.closeArchiveEntry();
}
}
}
}
}
use of org.hl7.fhir.utilities.graphql.Package in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeMedication.
protected void composeMedication(Complex parent, String parentType, String name, Medication element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "Medication", name, element, index);
if (element.hasCode())
composeCodeableConcept(t, "Medication", "code", element.getCode(), -1);
if (element.hasIsBrandElement())
composeBoolean(t, "Medication", "isBrand", element.getIsBrandElement(), -1);
if (element.hasManufacturer())
composeReference(t, "Medication", "manufacturer", element.getManufacturer(), -1);
if (element.hasProduct())
composeMedicationMedicationProductComponent(t, "Medication", "product", element.getProduct(), -1);
if (element.hasPackage())
composeMedicationMedicationPackageComponent(t, "Medication", "package", element.getPackage(), -1);
}
use of org.hl7.fhir.utilities.graphql.Package in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeImplementationGuide.
protected void composeImplementationGuide(Complex parent, String parentType, String name, ImplementationGuide element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "ImplementationGuide", name, element, index);
if (element.hasUrlElement())
composeUri(t, "ImplementationGuide", "url", element.getUrlElement(), -1);
if (element.hasVersionElement())
composeString(t, "ImplementationGuide", "version", element.getVersionElement(), -1);
if (element.hasNameElement())
composeString(t, "ImplementationGuide", "name", element.getNameElement(), -1);
if (element.hasStatusElement())
composeEnum(t, "ImplementationGuide", "status", element.getStatusElement(), -1);
if (element.hasExperimentalElement())
composeBoolean(t, "ImplementationGuide", "experimental", element.getExperimentalElement(), -1);
if (element.hasPublisherElement())
composeString(t, "ImplementationGuide", "publisher", element.getPublisherElement(), -1);
for (int i = 0; i < element.getContact().size(); i++) composeImplementationGuideImplementationGuideContactComponent(t, "ImplementationGuide", "contact", element.getContact().get(i), i);
if (element.hasDateElement())
composeDateTime(t, "ImplementationGuide", "date", element.getDateElement(), -1);
if (element.hasDescriptionElement())
composeString(t, "ImplementationGuide", "description", element.getDescriptionElement(), -1);
for (int i = 0; i < element.getUseContext().size(); i++) composeCodeableConcept(t, "ImplementationGuide", "useContext", element.getUseContext().get(i), i);
if (element.hasCopyrightElement())
composeString(t, "ImplementationGuide", "copyright", element.getCopyrightElement(), -1);
if (element.hasFhirVersionElement())
composeId(t, "ImplementationGuide", "fhirVersion", element.getFhirVersionElement(), -1);
for (int i = 0; i < element.getDependency().size(); i++) composeImplementationGuideImplementationGuideDependencyComponent(t, "ImplementationGuide", "dependency", element.getDependency().get(i), i);
for (int i = 0; i < element.getPackage().size(); i++) composeImplementationGuideImplementationGuidePackageComponent(t, "ImplementationGuide", "package", element.getPackage().get(i), i);
for (int i = 0; i < element.getGlobal().size(); i++) composeImplementationGuideImplementationGuideGlobalComponent(t, "ImplementationGuide", "global", element.getGlobal().get(i), i);
for (int i = 0; i < element.getBinary().size(); i++) composeUri(t, "ImplementationGuide", "binary", element.getBinary().get(i), i);
if (element.hasPage())
composeImplementationGuideImplementationGuidePageComponent(t, "ImplementationGuide", "page", element.getPage(), -1);
}
use of org.hl7.fhir.utilities.graphql.Package in project org.hl7.fhir.core by hapifhir.
the class FilesystemPackageCacheManager method fetchVersionTheOldWay.
// ---------- Current Build SubSystem --------------------------------------------------------------------------------------
private String fetchVersionTheOldWay(String id) throws IOException {
String url = getUrlForPackage(id);
if (url == null) {
try {
url = getPackageUrlFromBuildList(id);
} catch (Exception e) {
url = null;
}
}
if (url == null) {
throw new FHIRException("Unable to resolve package id " + id);
}
String pu = Utilities.pathURL(url, "package-list.json");
JsonObject json = JsonTrackingParser.fetchJson(pu);
if (!id.equals(JSONUtil.str(json, "package-id")))
throw new FHIRException("Package ids do not match in " + pu + ": " + id + " vs " + JSONUtil.str(json, "package-id"));
for (JsonElement e : json.getAsJsonArray("list")) {
JsonObject vo = (JsonObject) e;
if (JSONUtil.bool(vo, "current")) {
return JSONUtil.str(vo, "version");
}
}
return null;
}
use of org.hl7.fhir.utilities.graphql.Package in project org.hl7.fhir.core by hapifhir.
the class FilesystemPackageCacheManager method removePackage.
// ========================= Utilities ============================================================================
/**
* Remove a particular package from the cache
*
* @param id
* @param ver
* @throws IOException
*/
public void removePackage(String id, String ver) throws IOException {
new CacheLock(id + "#" + ver).doWithLock(() -> {
String f = Utilities.path(cacheFolder, id + "#" + ver);
File ff = new File(f);
if (ff.exists()) {
Utilities.clearDirectory(f);
IniFile ini = new IniFile(Utilities.path(cacheFolder, "packages.ini"));
ini.removeProperty("packages", id + "#" + ver);
ini.save();
ff.delete();
}
return null;
});
}
Aggregations