forked from cqframework/cqf-tooling
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update refresh ig 2 (cqframework#524)
* Update Refresh IG Operation - Updated namespace support - Tested locally with NHSN IG (Lantana) - Updated packaging - Added an operation that publishes bundles to a FHIR server (Lantana) * Update Refresh IG Operation - 2 * Build fix * Build fix 2 * Build fix 3 * Fixed package url for StructureMap testing * Build fix 4 * Update on fhir version for npm package manager * Update on fhir version for npm package manager (library refresh) --------- Co-authored-by: c-schuler <[email protected]>
- Loading branch information
Showing
35 changed files
with
1,921 additions
and
133 deletions.
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
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
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
40 changes: 40 additions & 0 deletions
40
tooling/src/main/java/org/opencds/cqf/tooling/npm/NamespaceInfo.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,40 @@ | ||
package org.opencds.cqf.tooling.npm; | ||
|
||
import java.util.Objects; | ||
|
||
public class NamespaceInfo extends org.hl7.cql.model.NamespaceInfo { | ||
private String version; | ||
public NamespaceInfo(String name, String uri, String version) { | ||
super(name, uri); | ||
if (version != null && !version.isEmpty()) { | ||
this.version = version; | ||
} else { | ||
throw new IllegalArgumentException("Version is required"); | ||
} | ||
} | ||
|
||
public String getVersion() { | ||
return version; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(super.hashCode(), version); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object that) { | ||
if (that instanceof NamespaceInfo) { | ||
NamespaceInfo thatInfo = (NamespaceInfo)that; | ||
return this.getName().equals(thatInfo.getName()) && this.getUri().equals(thatInfo.getUri()) | ||
&& this.getVersion().equals(thatInfo.getVersion()); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s: %s|%s", getName(), getUri(), getVersion()); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
tooling/src/main/java/org/opencds/cqf/tooling/npm/NamespaceManager.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,76 @@ | ||
package org.opencds.cqf.tooling.npm; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class NamespaceManager extends org.hl7.cql.model.NamespaceManager { | ||
private final Map<String, List<NamespaceInfo>> namespaces; | ||
|
||
public NamespaceManager() { | ||
this.namespaces = new HashMap<>(); | ||
} | ||
|
||
@Override | ||
public boolean hasNamespaces() { | ||
return !this.namespaces.isEmpty(); | ||
} | ||
|
||
@Override | ||
public void ensureNamespaceRegistered(org.hl7.cql.model.NamespaceInfo namespaceInfo) { | ||
if (namespaceInfo == null) { | ||
throw new IllegalArgumentException("namespaceInfo is required"); | ||
} | ||
|
||
if (!namespaces.containsKey(namespaceInfo.getName())) { | ||
if (namespaceInfo instanceof NamespaceInfo) { | ||
addNamespace(namespaceInfo.getName(), namespaceInfo.getUri(), ((NamespaceInfo) namespaceInfo).getVersion()); | ||
} else { | ||
addNamespace(namespaceInfo.getName(), namespaceInfo.getUri()); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void addNamespace(org.hl7.cql.model.NamespaceInfo namespaceInfo) { | ||
if (namespaceInfo == null) { | ||
throw new IllegalArgumentException("namespaceInfo is required"); | ||
} | ||
|
||
if (namespaceInfo instanceof NamespaceInfo) { | ||
addNamespace(namespaceInfo.getName(), namespaceInfo.getUri(), ((NamespaceInfo) namespaceInfo).getVersion()); | ||
} else { | ||
addNamespace(namespaceInfo.getName(), namespaceInfo.getUri()); | ||
} | ||
} | ||
|
||
public void addNamespace(String name, String uri, String version) { | ||
if (name == null || name.isEmpty()) { | ||
throw new IllegalArgumentException("Namespace name is required"); | ||
} | ||
|
||
if (uri == null || uri.isEmpty()) { | ||
throw new IllegalArgumentException("Namespace uri is required"); | ||
} | ||
|
||
if (version == null || version.isEmpty()) { | ||
throw new IllegalArgumentException("Namespace version is required"); | ||
} | ||
|
||
namespaces.computeIfAbsent(name, s -> new ArrayList<>()).add(new NamespaceInfo(name, uri, version)); | ||
} | ||
|
||
public String resolveNamespaceUri(String name, String version) { | ||
if (namespaces.containsKey(name)) { | ||
return namespaces.get(name).stream().filter(x -> x.getVersion().equals(version)).findFirst().orElseThrow().getUri(); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public org.hl7.cql.model.NamespaceInfo getNamespaceInfoFromUri(String uri, String version) { | ||
return namespaces.values().stream().flatMap(List::stream).filter( | ||
x -> x.getUri().equals(uri) && x.getVersion().equals(version)).findFirst().orElseThrow(); | ||
} | ||
} |
Oops, something went wrong.