Skip to content

Commit

Permalink
Merge branch 'master' into engine-fhir-tests-improvements-7
Browse files Browse the repository at this point in the history
  • Loading branch information
antvaset authored Oct 30, 2024
2 parents 5c1b221 + 35668e9 commit b25912e
Show file tree
Hide file tree
Showing 79 changed files with 1,959 additions and 4,103 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,23 @@ jobs:
with:
distribution: 'temurin'
java-version: '21'
cache: gradle
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Run Gradle Build
working-directory: ./Src/java
run: ./gradlew check publish
run: ./gradlew check publish sonar
env:
OSSRH_USERNAME: ${{ vars.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure() # always run even if the previous step fails
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@ jobs:
distribution: 'temurin'
java-version: '21'
cache: gradle
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Run Gradle Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
working-directory: ./Src/java
run: ./gradlew check -x spotlessCheck
run: ./gradlew check sonar -x spotlessCheck
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: (success() || failure()) && matrix.os == 'ubuntu-latest'
Expand Down
4 changes: 4 additions & 0 deletions Src/java/.sonarlint/connectedMode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"sonarCloudOrganization": "cqframework",
"projectKey": "cqframework_clinical_quality_language"
}
6 changes: 5 additions & 1 deletion Src/java/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,9 @@
".git",
"**/*.gradle",
"**/test/resources/**"
]
],
"sonarlint.connectedMode.project": {
"connectionId": "cqframework",
"projectKey": "cqframework_clinical_quality_language"
}
}
9 changes: 9 additions & 0 deletions Src/java/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
plugins {
id 'idea'
id 'eclipse'
id "org.sonarqube" version "4.4.1.3373"
}

sonar {
properties {
property "sonar.projectKey", "cqframework_clinical_quality_language"
property "sonar.organization", "cqframework"
property "sonar.host.url", "https://sonarcloud.io"
}
}

idea {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.List;
import org.cqframework.cql.cql2elm.LibrarySourceProvider;
import org.hl7.elm.r1.VersionedIdentifier;
import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.ILoggingService;
import org.hl7.fhir.r5.model.Library;
import org.hl7.fhir.utilities.npm.NpmPackage;

Expand All @@ -15,16 +15,15 @@
*/
public class NpmLibrarySourceProvider implements LibrarySourceProvider {

public NpmLibrarySourceProvider(
List<NpmPackage> packages, ILibraryReader reader, IWorkerContext.ILoggingService logger) {
public NpmLibrarySourceProvider(List<NpmPackage> packages, ILibraryReader reader, ILoggingService logger) {
this.packages = packages;
this.reader = reader;
this.logger = logger;
}

private List<NpmPackage> packages;
private ILibraryReader reader;
private IWorkerContext.ILoggingService logger;
private ILoggingService logger;

@Override
public InputStream getLibrarySource(VersionedIdentifier identifier) {
Expand Down Expand Up @@ -59,7 +58,7 @@ public InputStream getLibrarySource(VersionedIdentifier identifier) {
}
} catch (IOException e) {
logger.logDebugMessage(
IWorkerContext.ILoggingService.LogCategory.PROGRESS,
ILoggingService.LogCategory.PROGRESS,
String.format(
"Exceptions occurred attempting to load npm library source for %s",
identifier.toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.hl7.cql.model.ModelIdentifier;
import org.hl7.cql.model.ModelInfoProvider;
import org.hl7.elm_modelinfo.r1.ModelInfo;
import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.ILoggingService;
import org.hl7.fhir.r5.model.Library;
import org.hl7.fhir.utilities.npm.NpmPackage;

Expand All @@ -17,16 +17,15 @@
*/
public class NpmModelInfoProvider implements ModelInfoProvider {

public NpmModelInfoProvider(
List<NpmPackage> packages, ILibraryReader reader, IWorkerContext.ILoggingService logger) {
public NpmModelInfoProvider(List<NpmPackage> packages, ILibraryReader reader, ILoggingService logger) {
this.packages = packages;
this.reader = reader;
this.logger = logger;
}

private List<NpmPackage> packages;
private ILibraryReader reader;
private IWorkerContext.ILoggingService logger;
private ILoggingService logger;

public ModelInfo load(ModelIdentifier modelIdentifier) {
// VersionedIdentifier.id: Name of the model
Expand Down Expand Up @@ -60,7 +59,7 @@ public ModelInfo load(ModelIdentifier modelIdentifier) {
}
} catch (IOException e) {
logger.logDebugMessage(
IWorkerContext.ILoggingService.LogCategory.PROGRESS,
ILoggingService.LogCategory.PROGRESS,
String.format(
"Exceptions occurred attempting to load npm library for model %s",
modelIdentifier.toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.ILoggingService;
import org.hl7.fhir.r5.model.ImplementationGuide;
import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class NpmPackageManager implements IWorkerContext.ILoggingService {
public class NpmPackageManager implements ILoggingService {
private static final Logger logger = LoggerFactory.getLogger(NpmPackageManager.class);
private final ImplementationGuide sourceIg;
private final FilesystemPackageCacheManager fspcm;
Expand All @@ -29,23 +29,10 @@ public NpmPackageManager(ImplementationGuide sourceIg, FilesystemPackageCacheMan
public NpmPackageManager(
ImplementationGuide sourceIg, FilesystemPackageCacheManager fspcm, List<NpmPackage> npmList) {
this.sourceIg = sourceIg;

if (fspcm == null) {
try {
// userMode indicates whether the packageCache is within the working directory or in the user home
this.fspcm = new FilesystemPackageCacheManager(true);
} catch (IOException e) {
String message = "Error creating the FilesystemPackageCacheManager: " + e.getMessage();
logErrorMessage(message);
throw new NpmPackageManagerException(message, e);
}
} else {
this.fspcm = fspcm;
}

this.npmList = npmList == null ? new ArrayList<>() : npmList;

try {
this.fspcm = fspcm != null ? fspcm : new FilesystemPackageCacheManager.Builder().build();
loadDependencies();
} catch (Exception e) {
logErrorMessage(e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50;
import org.hl7.fhir.convertors.conv40_50.VersionConvertor_40_50;
import org.hl7.fhir.r4.model.Resource;
import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.ILoggingService;
import org.hl7.fhir.r5.model.ImplementationGuide;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class NpmPackageManagerTests implements IWorkerContext.ILoggingService {
public class NpmPackageManagerTests implements ILoggingService {

private final Logger logger = LoggerFactory.getLogger(NpmPackageManagerTests.class);
private final VersionConvertor_40_50 convertor = new VersionConvertor_40_50(new BaseAdvisor_40_50());
Expand Down Expand Up @@ -134,7 +134,7 @@ public void logMessage(String msg) {
}

@Override
public void logDebugMessage(IWorkerContext.ILoggingService.LogCategory category, String msg) {
public void logDebugMessage(ILoggingService.LogCategory category, String msg) {
logMessage(msg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50;
import org.hl7.fhir.convertors.conv40_50.VersionConvertor_40_50;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.ILoggingService;
import org.hl7.fhir.r5.elementmodel.Manager;
import org.hl7.fhir.r5.model.ImplementationGuide;
import org.hl7.fhir.utilities.IniFile;
Expand All @@ -19,9 +19,9 @@

public class IGContext {

private IWorkerContext.ILoggingService logger;
private ILoggingService logger;

public IWorkerContext.ILoggingService getLogger() {
public ILoggingService getLogger() {
return logger;
}

Expand Down Expand Up @@ -65,7 +65,7 @@ protected void setBinaryPaths(List<String> binaryPaths) {
this.binaryPaths = binaryPaths;
}

public IGContext(IWorkerContext.ILoggingService logger) {
public IGContext(ILoggingService logger) {
this.logger = logger;
}

Expand Down Expand Up @@ -113,16 +113,17 @@ public void initializeFromIg(String rootDir, String igPath, String fhirVersion)
* Initializes from an ig.ini file in the root directory
*/
public void initializeFromIni(String iniFile) {
IniFile ini = new IniFile(new File(iniFile).getAbsolutePath());
String rootDir = Utilities.getDirectoryForFile(ini.getFileName());
String igPath = ini.getStringProperty("IG", "ig");
String specifiedFhirVersion = ini.getStringProperty("IG", "fhir-version");
if (specifiedFhirVersion == null || specifiedFhirVersion == "") {
logMessage("fhir-version was not specified in the ini file. Trying FHIR version 4.0.1");
specifiedFhirVersion = "4.0.1";
}
try {
initializeFromIg(rootDir, igPath, specifiedFhirVersion);
IniFile ini = new IniFile(new File(iniFile).getAbsolutePath());
String iniDir = Utilities.getDirectoryForFile(ini.getFileName());
String igPath = ini.getStringProperty("IG", "ig");
String specifiedFhirVersion = ini.getStringProperty("IG", "fhir-version");
if (specifiedFhirVersion == null || specifiedFhirVersion == "") {
logMessage("fhir-version was not specified in the ini file. Trying FHIR version 4.0.1");
specifiedFhirVersion = "4.0.1";
}

initializeFromIg(iniDir, igPath, specifiedFhirVersion);
} catch (Exception e) {
String message = String.format(
"Exceptions occurred initializing refresh from ini file '%s':%s", iniFile, e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.cqframework.fhir.utilities;

import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.ILoggingService;
import org.slf4j.Logger;

public class LoggerAdapter implements IWorkerContext.ILoggingService {
public class LoggerAdapter implements ILoggingService {
private Logger innerLogger;

public LoggerAdapter(Logger innerLogger) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.ILoggingService;
import org.junit.jupiter.api.Test;

public class TestIGContext implements IWorkerContext.ILoggingService {
public class TestIGContext implements ILoggingService {

@Test
void typesAndValuesIG() throws URISyntaxException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.antlr.v4.runtime.tree.ParseTree;
import org.cqframework.cql.cql2elm.elm.ElmEdit;
import org.cqframework.cql.cql2elm.elm.ElmEditor;
import org.cqframework.cql.cql2elm.elm.IElmEdit;
import org.cqframework.cql.cql2elm.model.CompiledLibrary;
import org.cqframework.cql.cql2elm.preprocessor.CqlPreprocessor;
import org.cqframework.cql.elm.IdObjectFactory;
Expand Down Expand Up @@ -234,7 +235,8 @@ public Library run(CharStream is) {
var edits = allNonNull(
!options.contains(EnableAnnotations) ? ElmEdit.REMOVE_ANNOTATION : null,
!options.contains(EnableResultTypes) ? ElmEdit.REMOVE_RESULT_TYPE : null,
!options.contains(EnableLocators) ? ElmEdit.REMOVE_LOCATOR : null);
!options.contains(EnableLocators) ? ElmEdit.REMOVE_LOCATOR : null,
ElmEdit.REMOVE_CHOICE_TYPE_SPECIFIER_TYPE_IF_EMPTY);

new ElmEditor(edits).edit(library);

Expand All @@ -248,7 +250,7 @@ public Library run(CharStream is) {
return library;
}

private List<ElmEdit> allNonNull(ElmEdit... ts) {
private List<IElmEdit> allNonNull(IElmEdit... ts) {
return Arrays.stream(ts).filter(x -> x != null).collect(Collectors.toList());
}
}
Loading

0 comments on commit b25912e

Please sign in to comment.