Merge remote-tracking branch 'origin/master'

This commit is contained in:
Grahame Grieve 2022-07-22 15:26:37 +10:00
commit b12ef761bc
21 changed files with 118 additions and 87 deletions

View File

@ -9,7 +9,7 @@
* Fix NPE rendering bundles
* R5 Changes to ConceptMap
* Fix bug accessing polymorphic fields when rendering
* Fix bug rendering extensions
* Fix bug accessing polymorphic fields when rendering
* Fix bug around lazy loading packages when validating references
* Add ability to suppress serialising ids when serialising element models
* Add ability to suppress serialising ids when serialising element models

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.51-SNAPSHOT</version>
<version>5.6.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.51-SNAPSHOT</version>
<version>5.6.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -55,19 +55,19 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.0.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>

View File

@ -1,33 +1,33 @@
package org.hl7.fhir.dstu2.formats;
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
@ -122,7 +122,7 @@ public abstract class JsonParserBase extends ParserBase implements IParser {
}
/**
* parse xml that is known to be a resource, and that has already been read into a JSON object
* Parse JSON that is known to be a resource, and that has already been read into a JSON object
* @throws IOException
* @throws FHIRFormatError
*/

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.51-SNAPSHOT</version>
<version>5.6.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -69,19 +69,19 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.0.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.51-SNAPSHOT</version>
<version>5.6.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -63,19 +63,19 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.0.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.51-SNAPSHOT</version>
<version>5.6.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -75,19 +75,19 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.0.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>

View File

@ -55,6 +55,7 @@ import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.ToolsVersion;
import org.hl7.fhir.utilities.tests.BaseTestingUtilities;
import org.hl7.fhir.utilities.tests.ResourceLoaderTests;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -444,8 +445,7 @@ public class TestingUtilities {
}
public static String resourceNameToFile(String name) throws IOException {
//return Utilities.path(System.getProperty("user.dir"), "src", "test", "resources", name);
return resourceNameToFile(null, name);
return resourceNameToFile(null, name);
}
private static boolean fileForPathExists(String path) {
@ -454,7 +454,7 @@ public class TestingUtilities {
public static String generateResourcePath(String subFolder, String name) throws IOException {
String path = Utilities.path(System.getProperty("user.dir"), "src", "test", "resources", subFolder, name);
createParentDirectoryPathIfNotExists(Paths.get(path));
BaseTestingUtilities.createParentDirIfNotExists(Paths.get(path));
return path;
}
public static String resourceNameToFile(String subFolder, String name) throws IOException {
@ -472,15 +472,10 @@ public class TestingUtilities {
}
private static void copyResourceToNewFile(String resourcePath, Path newFilePath) throws IOException {
createParentDirectoryPathIfNotExists(newFilePath);
BaseTestingUtilities.createParentDirIfNotExists(newFilePath);
ResourceLoaderTests.copyResourceToFile(TestingUtilities.class, newFilePath, resourcePath);
}
private static void createParentDirectoryPathIfNotExists(Path newFilePath) {
Path parent = newFilePath.getParent();
if (!parent.toFile().exists()) {
parent.toFile().mkdirs();
}
}
}

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.51-SNAPSHOT</version>
<version>5.6.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -82,19 +82,19 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.0.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.51-SNAPSHOT</version>
<version>5.6.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -61,19 +61,19 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.0.1</version>
<version>${apache_poi_version}</version>
<optional>true</optional>
</dependency>
<dependency>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.51-SNAPSHOT</version>
<version>5.6.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.51-SNAPSHOT</version>
<version>5.6.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -7,6 +7,7 @@ import org.hl7.fhir.utilities.ToolGlobalSettings;
import org.hl7.fhir.utilities.Utilities;
import java.io.*;
import java.nio.file.Path;
public class BaseTestingUtilities {
@ -114,4 +115,11 @@ public class BaseTestingUtilities {
public static void setFhirTestCasesDirectory(String s) {
}
public static void createParentDirIfNotExists(Path target) {
Path parent = target.getParent();
if (!parent.toFile().exists()) {
parent.toFile().mkdirs();
}
}
}

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.utilities.tests;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
@ -23,7 +22,7 @@ public interface ResourceLoaderTests {
public static void copyResourceToFile(Class<?> clazz, Path target, String ... resourcePath) throws IOException {
InputStream initialStream = getResourceAsInputStream(clazz, resourcePath);
BaseTestingUtilities.createParentDirIfNotExists(target);
java.nio.file.Files.copy(
initialStream,
target,
@ -31,4 +30,5 @@ public interface ResourceLoaderTests {
initialStream.close();
}
}

View File

@ -128,7 +128,7 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
case ERROR: return "error";
case WARNING: return "warning";
case INFORMATION: return "information";
case NULL: return null;
case NULL: return null;
default: return "?";
}
}
@ -138,7 +138,7 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
case ERROR: return "http://hl7.org/fhir/issue-severity";
case WARNING: return "http://hl7.org/fhir/issue-severity";
case INFORMATION: return "http://hl7.org/fhir/issue-severity";
case NULL: return null;
case NULL: return null;
default: return "?";
}
}
@ -148,7 +148,7 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
case ERROR: return "The issue is sufficiently important to cause the action to fail.";
case WARNING: return "The issue is not important enough to cause the action to fail, but may cause it to be performed suboptimally or in a way that is not as desired.";
case INFORMATION: return "The issue has no relation to the degree of success of the action.";
case NULL: return null;
case NULL: return null;
default: return "?";
}
}
@ -158,7 +158,7 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
case ERROR: return "Error";
case WARNING: return "Warning";
case INFORMATION: return "Information";
case NULL: return null;
case NULL: return null;
default: return "?";
}
}
@ -388,7 +388,7 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
case TIMEOUT: return "timeout";
case THROTTLED: return "throttled";
case INFORMATIONAL: return "informational";
case NULL: return null;
case NULL: return null;
default: return "?";
}
}
@ -423,7 +423,7 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
case TIMEOUT: return "http://hl7.org/fhir/issue-type";
case THROTTLED: return "http://hl7.org/fhir/issue-type";
case INFORMATIONAL: return "http://hl7.org/fhir/issue-type";
case NULL: return null;
case NULL: return null;
default: return "?";
}
}
@ -458,7 +458,7 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
case TIMEOUT: return "An internal timeout has occurred.";
case THROTTLED: return "The system is not prepared to handle this request due to load management.";
case INFORMATIONAL: return "A message unrelated to the processing success of the completed operation (examples of the latter include things like reminders of password expiry, system maintenance times, etc.).";
case NULL: return null;
case NULL: return null;
default: return "?";
}
}
@ -493,7 +493,7 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
case TIMEOUT: return "Timeout";
case THROTTLED: return "Throttled";
case INFORMATIONAL: return "Informational Note";
case NULL: return null;
case NULL: return null;
default: return "?";
}
}
@ -526,7 +526,7 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
}
public ValidationMessage(Source source, IssueType type, String path, String message, IssueSeverity level) {
super();
this();
this.line = -1;
this.col = -1;
this.location = path;
@ -544,7 +544,7 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
}
public ValidationMessage(Source source, IssueType type, int line, int col, String path, String message, IssueSeverity level) {
super();
this();
this.line = line;
this.col = col;
this.location = path;
@ -560,7 +560,7 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
}
public ValidationMessage(Source source, IssueType type, String path, String message, String html, IssueSeverity level) {
super();
this();
this.line = -1;
this.col = -1;
this.location = path;
@ -578,7 +578,7 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
}
public ValidationMessage(Source source, IssueType type, int line, int col, String path, String message, String html, IssueSeverity level) {
super();
this();
this.line = line;
this.col = col;
this.location = path;

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.51-SNAPSHOT</version>
<version>5.6.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -202,7 +202,7 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.1</version>
<version>${apache_poi_version}</version>
<optional>false</optional>
<scope>compile</scope>
</dependency>
@ -210,7 +210,7 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
<version>${apache_poi_version}</version>
<optional>false</optional>
<scope>compile</scope>
</dependency>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.51-SNAPSHOT</version>
<version>5.6.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -59,6 +59,19 @@ public class SessionCache {
return sessionId;
}
/**
* When called, this actively checks the cache for expired entries and removes
* them.
*/
public void removeExpiredSessions() {
/*
The PassiveExpiringMap will remove entries when accessing the mapped value
for a key, OR when invoking methods that involve accessing the entire map
contents. So, we call keySet below to force removal of all expired entries.
* */
cachedSessions.keySet();
}
/**
* Checks if the passed in {@link String} id exists in the set of stored session id.
* @param sessionId The {@link String} id to search for.

View File

@ -328,6 +328,7 @@ public class ValidationService {
public String initializeValidator(CliContext cliContext, String definitions, TimeTracker tt, String sessionId) throws Exception {
tt.milestone();
sessionCache.removeExpiredSessions();
if (!sessionCache.sessionExists(sessionId)) {
if (sessionId != null) {
System.out.println("No such cached session exists for session id " + sessionId + ", re-instantiating validator.");

View File

@ -48,4 +48,17 @@ class SessionCacheTest {
SessionCache cache = new SessionCache();
Assertions.assertFalse(cache.sessionExists(null));
}
@Test
@DisplayName("test that explicit removeExiredSessions works")
void testRemoveExpiredSessions() throws InterruptedException, IOException {
final long EXPIRE_TIME = 5L;
SessionCache cache = new SessionCache(EXPIRE_TIME, TimeUnit.SECONDS);
ValidationEngine testEngine = new ValidationEngine.ValidationEngineBuilder().fromNothing();
String sessionId = cache.cacheSession(testEngine);
Assertions.assertTrue(cache.sessionExists(sessionId));
TimeUnit.SECONDS.sleep(EXPIRE_TIME + 1L);
cache.removeExpiredSessions();
Assertions.assertTrue(cache.getSessionIds().isEmpty());
}
}

View File

@ -14,7 +14,7 @@
HAPI FHIR
-->
<artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.51-SNAPSHOT</version>
<version>5.6.52-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
@ -28,6 +28,7 @@
<info_cqframework_version>1.5.1</info_cqframework_version>
<lombok_version>1.18.22</lombok_version>
<byte_buddy_version>1.10.21</byte_buddy_version>
<apache_poi_version>4.1.1</apache_poi_version>
</properties>
<name>HL7 Core Artifacts</name>