use of org.hl7.fhir.utilities.npm.NpmPackage in project org.hl7.fhir.core by hapifhir.
the class NpmPackageTests method testNewTgz.
@Test
public void testNewTgz() throws IOException {
NpmPackage npm = NpmPackage.fromPackage(TestingUtilities.loadTestResourceStream("npm", "test.format.new.tgz"));
checkNpm(npm);
}
use of org.hl7.fhir.utilities.npm.NpmPackage in project org.hl7.fhir.core by hapifhir.
the class IgLoader method fetchVersionByPackage.
private String fetchVersionByPackage(String src) throws FHIRException, IOException {
String id = src;
String version = null;
if (src.contains("#")) {
id = src.substring(0, src.indexOf("#"));
version = src.substring(src.indexOf("#") + 1);
}
if (version == null) {
version = getPackageCacheManager().getLatestVersion(id);
}
NpmPackage pi = null;
if (version == null) {
pi = getPackageCacheManager().loadPackageFromCacheOnly(id);
if (pi != null)
System.out.println(" ... Using version " + pi.version());
} else
pi = getPackageCacheManager().loadPackageFromCacheOnly(id, version);
if (pi == null) {
return resolvePackageForVersion(id, version);
} else {
return pi.fhirVersion();
}
}
use of org.hl7.fhir.utilities.npm.NpmPackage in project org.hl7.fhir.core by hapifhir.
the class IgLoader method fetchByPackage.
private Map<String, byte[]> fetchByPackage(String src) throws FHIRException, IOException {
String id = src;
String version = null;
if (src.contains("#")) {
id = src.substring(0, src.indexOf("#"));
version = src.substring(src.indexOf("#") + 1);
}
if (version == null) {
version = getPackageCacheManager().getLatestVersion(id);
}
NpmPackage pi;
if (version == null) {
pi = getPackageCacheManager().loadPackageFromCacheOnly(id);
if (pi != null)
System.out.println(" ... Using version " + pi.version());
} else
pi = getPackageCacheManager().loadPackageFromCacheOnly(id, version);
if (pi == null) {
return resolvePackage(id, version);
} else
return loadPackage(pi);
}
use of org.hl7.fhir.utilities.npm.NpmPackage in project org.hl7.fhir.core by hapifhir.
the class ValidationEngine method loadCoreDefinitions.
/**
* @param src
* @param recursive
* @param terminologyCachePath
* @param userAgent
* @param tt
* @param loggingService
* @throws FHIRException
* @throws IOException
*
* @see IgLoader#loadIgSource(String, boolean, boolean) loadIgSource for detailed description of the src parameter
*/
private void loadCoreDefinitions(String src, boolean recursive, String terminologyCachePath, String userAgent, TimeTracker tt, IWorkerContext.ILoggingService loggingService) throws FHIRException, IOException {
NpmPackage npm = getPcm().loadPackage(src, null);
if (npm != null) {
version = npm.fhirVersion();
SimpleWorkerContext.SimpleWorkerContextBuilder contextBuilder = new SimpleWorkerContext.SimpleWorkerContextBuilder().withLoggingService(loggingService);
if (terminologyCachePath != null)
contextBuilder = contextBuilder.withTerminologyCachePath(terminologyCachePath);
if (userAgent != null) {
contextBuilder.withUserAgent(userAgent);
}
context = contextBuilder.fromPackage(npm, ValidatorUtils.loaderForVersion(version));
} else {
Map<String, byte[]> source = igLoader.loadIgSource(src, recursive, true);
if (version == null) {
version = getVersionFromPack(source);
}
SimpleWorkerContext.SimpleWorkerContextBuilder contextBuilder = new SimpleWorkerContext.SimpleWorkerContextBuilder();
if (terminologyCachePath != null)
contextBuilder = contextBuilder.withTerminologyCachePath(terminologyCachePath);
if (userAgent != null) {
contextBuilder.withUserAgent(userAgent);
}
context = contextBuilder.fromDefinitions(source, ValidatorUtils.loaderForVersion(version), new PackageVersion(src, new Date()));
ValidatorUtils.grabNatives(getBinaries(), source, "http://hl7.org/fhir");
}
// on https://chat.fhir.org/#narrow/stream/179167-hapi
try {
ClassLoader classLoader = ValidationEngine.class.getClassLoader();
InputStream ue = classLoader.getResourceAsStream("ucum-essence.xml");
context.setUcumService(new UcumEssenceService(ue));
} catch (Exception e) {
throw new FHIRException("Error loading UCUM from embedded ucum-essence.xml: " + e.getMessage(), e);
}
initContext(tt);
}
use of org.hl7.fhir.utilities.npm.NpmPackage in project org.hl7.fhir.core by hapifhir.
the class ValidationEngine method initContext.
protected void initContext(TimeTracker tt) throws IOException {
context.setCanNoTS(true);
context.setCacheId(UUID.randomUUID().toString());
// because of Forge
context.setAllowLoadingDuplicates(true);
context.setExpansionProfile(makeExpProfile());
if (tt != null) {
context.setClock(tt);
}
NpmPackage npmX = getPcm().loadPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER);
context.loadFromPackage(npmX, null);
this.fhirPathEngine = new FHIRPathEngine(context);
}
Aggregations