-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added IG operation providers for run time installation of IG's * Refactored conditions for enabling the provider * Refactoring * Disable it by default in config as well * document package install feature --------- Co-authored-by: Jose Costa Teixeira <[email protected]>
- Loading branch information
1 parent
b0ae4f2
commit 1f7d25c
Showing
8 changed files
with
145 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/ca/uhn/fhir/jpa/starter/ig/IImplementationGuideOperationProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package ca.uhn.fhir.jpa.starter.ig; | ||
|
||
import ca.uhn.fhir.jpa.packages.PackageInstallationSpec; | ||
import org.hl7.fhir.utilities.npm.NpmPackage; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
|
||
public interface IImplementationGuideOperationProvider { | ||
static PackageInstallationSpec toPackageInstallationSpec(byte[] npmPackageAsByteArray) throws IOException { | ||
NpmPackage npmPackage = NpmPackage.fromPackage(new ByteArrayInputStream(npmPackageAsByteArray)); | ||
return new PackageInstallationSpec().setName(npmPackage.name()).setPackageContents(npmPackageAsByteArray).setVersion(npmPackage.version()).setInstallMode(PackageInstallationSpec.InstallModeEnum.STORE_AND_INSTALL).setFetchDependencies(false); | ||
} | ||
|
||
//The following declaration is the one that counts but cannot be used across different versions as stating Base64BinaryType would bind to a separate version | ||
//@Operation(name = "$install", typeName = "ImplementationGuide") | ||
//Parameters install(@OperationParam(name = "npmContent",min = 1, max = 1) Base64BinaryType implementationGuide); | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/ca/uhn/fhir/jpa/starter/ig/IgConfigCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package ca.uhn.fhir.jpa.starter.ig; | ||
|
||
import org.springframework.context.annotation.Condition; | ||
import org.springframework.context.annotation.ConditionContext; | ||
import org.springframework.core.type.AnnotatedTypeMetadata; | ||
|
||
public class IgConfigCondition implements Condition { | ||
|
||
@Override | ||
public boolean matches(ConditionContext theConditionContext, AnnotatedTypeMetadata theAnnotatedTypeMetadata) { | ||
String property = theConditionContext.getEnvironment().getProperty("hapi.fhir.ig_runtime_upload_enabled"); | ||
return Boolean.parseBoolean(property); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/ca/uhn/fhir/jpa/starter/ig/ImplementationGuideR4OperationProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package ca.uhn.fhir.jpa.starter.ig; | ||
|
||
import ca.uhn.fhir.jpa.packages.IPackageInstallerSvc; | ||
import ca.uhn.fhir.jpa.starter.annotations.OnR4Condition; | ||
import ca.uhn.fhir.rest.annotation.Operation; | ||
import ca.uhn.fhir.rest.annotation.OperationParam; | ||
import org.hl7.fhir.r4.model.Base64BinaryType; | ||
import org.hl7.fhir.r4.model.Parameters; | ||
import org.springframework.context.annotation.Conditional; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.io.IOException; | ||
|
||
@Conditional({OnR4Condition.class, IgConfigCondition.class}) | ||
@Service | ||
public class ImplementationGuideR4OperationProvider implements IImplementationGuideOperationProvider { | ||
|
||
IPackageInstallerSvc packageInstallerSvc; | ||
|
||
public ImplementationGuideR4OperationProvider(IPackageInstallerSvc packageInstallerSvc) { | ||
this.packageInstallerSvc = packageInstallerSvc; | ||
} | ||
|
||
@Operation(name = "$install", typeName = "ImplementationGuide") | ||
public Parameters install(@OperationParam(name = "npmContent", min = 1, max = 1) Base64BinaryType implementationGuide) { | ||
try { | ||
|
||
packageInstallerSvc.install(IImplementationGuideOperationProvider.toPackageInstallationSpec(implementationGuide.getValue())); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
return new Parameters(); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/ca/uhn/fhir/jpa/starter/ig/ImplementationGuideR5OperationProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package ca.uhn.fhir.jpa.starter.ig; | ||
|
||
import ca.uhn.fhir.jpa.packages.IPackageInstallerSvc; | ||
import ca.uhn.fhir.jpa.starter.annotations.OnR5Condition; | ||
import ca.uhn.fhir.rest.annotation.Operation; | ||
import ca.uhn.fhir.rest.annotation.OperationParam; | ||
import org.hl7.fhir.r5.model.Base64BinaryType; | ||
import org.hl7.fhir.r5.model.Parameters; | ||
import org.springframework.context.annotation.Conditional; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.io.IOException; | ||
|
||
@Conditional({OnR5Condition.class, IgConfigCondition.class}) | ||
@Service | ||
public class ImplementationGuideR5OperationProvider { | ||
|
||
IPackageInstallerSvc packageInstallerSvc; | ||
|
||
public ImplementationGuideR5OperationProvider(IPackageInstallerSvc packageInstallerSvc) { | ||
this.packageInstallerSvc = packageInstallerSvc; | ||
} | ||
|
||
@Operation(name = "$install", typeName = "ImplementationGuide") | ||
public Parameters install(@OperationParam(name = "npmContent", min = 1, max = 1) Base64BinaryType implementationGuide) { | ||
try { | ||
|
||
packageInstallerSvc.install(IImplementationGuideOperationProvider.toPackageInstallationSpec(implementationGuide.getValue())); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
return new Parameters(); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters