Skip to content

Commit

Permalink
Merge pull request #198 from samply/release/7.8.0
Browse files Browse the repository at this point in the history
Release/7.8.0
  • Loading branch information
TasDeniz authored Sep 9, 2022
2 parents 0c1cfc2 + 6a86ade commit a117409
Show file tree
Hide file tree
Showing 18 changed files with 276 additions and 124 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [7.8.0 - 2022-08-08]
### Added
- create sublist for cql results
- changed NumberDisguiser to LaplaceMechanism
- init resources for directory sync

## [7.7.2 - 2022-07-27]
### Fixed
- Translate German remaining sentences for English version of main site
Expand Down
9 changes: 4 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>

<artifactId>share-client</artifactId>
<version>7.7.2</version>
<version>7.8.0</version>
<packaging>war</packaging>

<name>Connector</name>
Expand Down Expand Up @@ -64,10 +64,10 @@
<jsf-renderer.version>2.0.0</jsf-renderer.version>
<common-mailing.version>3.0.0</common-mailing.version>
<common-http.version>7.4.4</common-http.version>
<common-ldmclient.centraxx.version>6.2.0</common-ldmclient.centraxx.version>
<common-ldmclient.centraxx.version>6.2.1</common-ldmclient.centraxx.version>
<common-ldmclient.samplystore.biobank.version>3.0.0
</common-ldmclient.samplystore.biobank.version>
<common-ldmclient.cql.version>2.0.0</common-ldmclient.cql.version>
<common-ldmclient.cql.version>2.1.1</common-ldmclient.cql.version>
<converter.dktk.patient.version>2.4.0</converter.dktk.patient.version>
<project-directory-client.version>1.3.0</project-directory-client.version>

Expand Down Expand Up @@ -98,7 +98,7 @@
<twbs-pagination.version>1.4.1</twbs-pagination.version>
<jqplot.version>1.0.9.d96a669-1</jqplot.version>
<hapi.version>5.7.2</hapi.version>
<directory-sync.version>0.1.1</directory-sync.version>
<directory-sync.version>0.2.0</directory-sync.version>
<togglz.version>2.8.0</togglz.version>
<swagger-ui.version>4.1.3</swagger-ui.version>
<microprofile-openapi-api.version>3.0</microprofile-openapi-api.version>
Expand All @@ -119,7 +119,6 @@
<commons-io.version>2.11.0</commons-io.version>
<log4j.version>2.17.2</log4j.version>
<slf4j.version>1.7.36</slf4j.version>

<protobuf-java.version>3.19.4</protobuf-java.version>
<maven-resources-plugin.version>3.2.0</maven-resources-plugin.version>
<json-smart.version>1.3.3</json-smart.version>
Expand Down
51 changes: 46 additions & 5 deletions src/main/java/de/samply/share/client/control/ApplicationBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import static org.omnifaces.util.Faces.getServletContext;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import com.google.common.base.Splitter;
import de.dth.mdr.validator.MdrConnection;
import de.dth.mdr.validator.MdrValidator;
Expand All @@ -14,6 +17,10 @@
import de.samply.common.mdrclient.MdrInvalidResponseException;
import de.samply.config.util.FileFinderUtil;
import de.samply.config.util.JaxbUtil;
import de.samply.directory_sync.Sync;
import de.samply.directory_sync.directory.DirectoryApi;
import de.samply.directory_sync.fhir.FhirApi;
import de.samply.directory_sync.fhir.FhirReporting;
import de.samply.project.directory.client.DktkProjectDirectory;
import de.samply.project.directory.client.DktkProjectDirectoryParameters;
import de.samply.project.directory.client.ProjectDirectory;
Expand Down Expand Up @@ -83,6 +90,7 @@
import de.samply.share.common.utils.Constants;
import de.samply.share.common.utils.ProjectInfo;
import de.samply.web.mdrfaces.MdrContext;
import io.vavr.control.Either;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand All @@ -103,6 +111,7 @@
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.faces.validator.ValidatorException;
import javax.security.auth.login.CredentialNotFoundException;
import javax.servlet.ServletContext;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
Expand All @@ -111,7 +120,9 @@
import org.apache.commons.configuration.ConfigurationException;
import org.apache.http.HttpHeaders;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.HttpClients;
import org.flywaydb.core.api.FlywayException;
import org.hl7.fhir.r4.model.OperationOutcome;
import org.quartz.CronExpression;
import org.quartz.CronScheduleBuilder;
import org.quartz.CronTrigger;
Expand Down Expand Up @@ -179,6 +190,7 @@ public class ApplicationBean implements Serializable {
private ConnectCheckResult patientListAvailability = new ConnectCheckResult();
private ConnectCheckResult projectPseudonAvailability = new ConnectCheckResult();
private static Crypt crypt;
private FhirContext ctx = FhirContext.forR4();


public static Locale getLocale() {
Expand Down Expand Up @@ -278,7 +290,7 @@ private static void loadCommonConfig() {
} catch (UnmarshalException ue) {
throw new RuntimeException("Unable to unmarshal config file");
} catch (SAXException | JAXBException | ParserConfigurationException e) {
logger.error(e.getMessage(),e);
logger.error(e.getMessage(), e);
}
}

Expand All @@ -301,7 +313,7 @@ private static void loadUrls() {
} catch (UnmarshalException ue) {
throw new RuntimeException("Unable to unmarshal common_urls file", ue);
} catch (SAXException | JAXBException | ParserConfigurationException e) {
logger.error(e.getMessage(),e);
logger.error(e.getMessage(), e);
}
}

Expand All @@ -324,7 +336,7 @@ private static void loadOperator() {
} catch (UnmarshalException ue) {
throw new RuntimeException("Unable to unmarshal common_operator file");
} catch (SAXException | JAXBException | ParserConfigurationException e) {
logger.error(e.getMessage(),e);
logger.error(e.getMessage(), e);
}
}

Expand All @@ -347,7 +359,7 @@ private static void loadBridgeheadInfo() {
} catch (UnmarshalException ue) {
throw new RuntimeException("Unable to unmarshal bridgehead_info file", ue);
} catch (SAXException | JAXBException | ParserConfigurationException e) {
logger.error(e.getMessage(),e);
logger.error(e.getMessage(), e);
}
}

Expand All @@ -370,7 +382,7 @@ private static void loadCtsInfo() {
} catch (UnmarshalException ue) {
throw new RuntimeException("Unable to unmarshal CTS file", ue);
} catch (SAXException | JAXBException | ParserConfigurationException e) {
logger.error(e.getMessage(),e);
logger.error(e.getMessage(), e);
}
}

Expand Down Expand Up @@ -927,6 +939,15 @@ public void init() {
logger.info("initializing crypt...");
initCrypt();
}
if (featureManager.getFeatureState(ClientFeature.BBMRI_DIRECTORY_SYNC).isEnabled()) {
IGenericClient client = ctx
.newRestfulGenericClient(ApplicationBean.getUrlsForDirectory().getLdmUrl());
client.registerInterceptor(new LoggingInterceptor(true));
FhirApi fhirApi = new FhirApi(client);
FhirReporting fhirReporting = new FhirReporting(ctx, fhirApi);
Sync sync = new Sync(fhirApi, fhirReporting, null, null);
sync.initResources();
}
logger.info("Application Bean initialized");

}
Expand Down Expand Up @@ -1068,6 +1089,26 @@ public void updateLocalComponentInfo() {
}
}

private Either<OperationOutcome, DirectoryApi> createDirectoryApi()
throws CredentialNotFoundException {
List<Credentials> credentialsList = CredentialsUtil
.getCredentialsByTarget(TargetType.TT_DIRECTORY);
if (credentialsList.size() < 1) {
throw new CredentialNotFoundException("No directory credentials found");
}
Credentials credentials = credentialsList.get(0);
return DirectoryApi.createWithLogin(HttpClients.createDefault(),
ApplicationBean.getUrlsForDirectory().getDirectoryUrl(), credentials.getUsername(),
credentials.getPasscode());
}

private FhirApi createFhirApi() {
IGenericClient client = ctx
.newRestfulGenericClient(ApplicationBean.getUrlsForDirectory().getLdmUrl());
client.registerInterceptor(new LoggingInterceptor(true));
return new FhirApi(client);
}

private void setComponentInfoViewModel(IcomponentBasicInfoConnector basicInfoConnector,
ConnectCheckResult connectCheckResult) {
try {
Expand Down
26 changes: 19 additions & 7 deletions src/main/java/de/samply/share/client/control/InquiryBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private static TreeModel<Container> resultPageToTree(Result queryResultPage) {
try {
containerTmp = Converter.convertCcpContainerToCommonContainer(patientContainer);
} catch (JAXBException e) {
logger.error(e.getMessage(),e);
logger.error(e.getMessage(), e);
}
containerTree = visitContainerNode(containerTree, containerTmp);

Expand All @@ -173,7 +173,7 @@ private static TreeModel<Container> resultPageToTree(Result queryResultPage) {
try {
containerTmp = Converter.convertOsseContainerToCommonContainer(patientContainer);
} catch (JAXBException e) {
logger.error(e.getMessage(),e);
logger.error(e.getMessage(), e);
}

containerTree = visitContainerNode(containerTree, containerTmp);
Expand Down Expand Up @@ -598,7 +598,6 @@ public void loadSelectedInquiry() {
}



/**
* Generate the query criteria tree from the criteria string in common namespace.
*
Expand Down Expand Up @@ -785,6 +784,19 @@ private void buildPatientPageTree(Result queryResultPage) {
patientPageTree = resultPageToTree(queryResultPage);
}

/**
* Load the sublist results.
* @return sublist results
*/
public List<String> loadSubListUrls() {
List<InquiryResult> inquiryResultList = InquiryResultUtil.fetchLastTwoInquiryResult(
latestInquiryDetails.getId(), false);
List<String> locations = new ArrayList<>();
locations.add(inquiryResultList.get(0).getLocation());
locations.add(inquiryResultList.get(1).getLocation());
return locations;
}

/**
* Send a reply back to the broker. Currently only supports the size. TODO: Add support for other
* reply types TODO: Add success/error message
Expand All @@ -808,7 +820,7 @@ public String reply() {
.getLocation());
brokerConnector.reply(latestInquiryDetails, queryResult);
} catch (LdmConnectorException e) {
logger.error(e.getMessage(),e);
logger.error(e.getMessage(), e);
}
} else if (ApplicationUtils.isLanguageCql()) {
CqlResult queryResult = new CqlResultFactory(latestInquiryDetails).createCqlResult();
Expand Down Expand Up @@ -885,7 +897,7 @@ public void handleDocumentUpload(AjaxBehaviorEvent event) {
newDocument = null;
Ajax.oncomplete(RESET_FILEINPUT, CREATE_EVENTHANDLERS);
} catch (IOException e) {
logger.error(e.getMessage(),e);
logger.error(e.getMessage(), e);
logger.error("Document upload failed.");
}
}
Expand Down Expand Up @@ -955,7 +967,7 @@ private void reloadPage() {
try {
reloadPageWithoutExceptionManagement();
} catch (IOException e) {
logger.error(e.getMessage(),e);
logger.error(e.getMessage(), e);
}
}

Expand Down Expand Up @@ -1003,7 +1015,7 @@ private void generateExportFileWithoutManagementException(
Integer timeout = ConfigurationUtil
.getConfigurationElementValueAsInteger(EnumConfiguration.EXPORT_TIMEOUT_IN_MINUTES);
ExportFileGenerator exportFileGenerator =
new ExportFileGenerator(latestInquiryResult, ldmConnector, inquiry,selectedInquiryContact,
new ExportFileGenerator(latestInquiryResult, ldmConnector, inquiry, selectedInquiryContact,
validationHandling, timeout);

ByteArrayOutputStream bos = exportFileGenerator.generateExport();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package de.samply.share.client.job;

import de.samply.common.ldmclient.LdmClientException;
import de.samply.share.client.job.util.CqlResultFactory;
import de.samply.share.client.model.db.enums.InquiryStatusType;
import de.samply.share.client.model.db.enums.QueryLanguageType;
import de.samply.share.client.model.db.tables.pojos.InquiryCriteria;
import de.samply.share.client.model.db.tables.pojos.InquiryResult;
import de.samply.share.client.util.connector.BrokerConnector;
import de.samply.share.client.util.connector.LdmConnectorCql;
import de.samply.share.client.util.connector.exception.BrokerConnectorException;
import de.samply.share.client.util.db.InquiryCriteriaUtil;
import de.samply.share.client.util.db.InquiryResultUtil;
import de.samply.share.model.cql.CqlResult;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.function.Consumer;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
Expand Down Expand Up @@ -45,18 +50,37 @@ InquiryCriteria getInquiryCriteria() {

void handleInquiryStatusReady() {
inquiryDetails.setStatus(InquiryStatusType.IS_PARTIALLY_READY);

createSublist();
CheckInquiryStatusReadyForMultipleCriteriaJobCql.spawnNewJob(inquiryDetails);
}

private void createSublist() {
try {
String location = ldmConnector.createSubjectList(new URI(inquiryResult.getLocation()));
InquiryResult inquiryResultSubList = new InquiryResult();
inquiryResultSubList.setInquiryCriteriaId(inquiryResult.getInquiryCriteriaId());
inquiryResultSubList.setInquiryDetailsId(inquiryResult.getInquiryDetailsId());
inquiryResultSubList.setSize(inquiryResult.getSize());
inquiryResultSubList.setStatisticsOnly(false);
inquiryResultSubList.setIsError(false);
inquiryResultSubList.setNotificationSent(false);
inquiryResultSubList.setLocation(location);
InquiryResultUtil.insertInquiryResult(inquiryResultSubList);
} catch (LdmClientException | URISyntaxException e) {
logger.error(e.getMessage());
}

}


@Override
Consumer<BrokerConnector> getProcessReplyRuleMethod() {
return brokerConnector -> {
try {
CqlResult queryResult = new CqlResultFactory(inquiryDetails).createCqlResult();
brokerConnector.reply(inquiryDetails, queryResult);
} catch (BrokerConnectorException e) {
logger.error(e.getMessage(),e);
logger.error(e.getMessage(), e);
handleBrokerConnectorException(e);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public CqlResult createCqlResult() {

for (InquiryCriteria inquiryCriteria : inquiryCriteriaList) {
InquiryResult inquiryResult = InquiryResultUtil
.fetchLatestInquiryResultForInquiryCriteriaById(inquiryCriteria.getId());
.fetchLatestInquiryResultForInquiryCriteriaById(inquiryCriteria.getId(), true);
if (InquiryCriteriaEntityType.PATIENT.getName().equals(inquiryCriteria.getEntityType())) {
queryResult.setNumberOfPatients(inquiryResult.getSize());
List<Stratification> stratifications = readStratifications(inquiryResult);
Expand All @@ -61,7 +61,7 @@ private List<Stratification> readStratifications(InquiryResult inquiryResult) {
.readValue(inquiryResult.getStratifications(), new TypeReference<List<Stratification>>() {
});
} catch (IOException e) {
logger.error(e.getMessage(),e);
logger.error(e.getMessage(), e);
return new ArrayList<>();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ si_subject=Ihre Anfrage
si_institution=Institution
si_criteria=Suchkriterien
si_executeInquiry=Anfrage erneut ausf\u00FChren
si_matchingResults=Passende Datens\u00E4tze ({0})
si_matchingResults=Passende Datens\u00E4tze
si_exportResults=Exportieren
si_details=Details der Anfrage
si_events=Verlauf
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/de/samply/share/client/rest/Connector.java
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ private InquiryLine fetchLatestInquiryResultForInquiryDetailsById_WithoutManagem
InquiryLine inquiryLine, InquiryDetails inquiryDetails) {
List<InquiryResult> inquiryResultList = new ArrayList<>();
if (ApplicationUtils.isLanguageCql()) {
inquiryResultList = InquiryResultUtil.fetchLastTwoInquiryResult(inquiryDetails.getId());
inquiryResultList = InquiryResultUtil.fetchLastTwoInquiryResult(inquiryDetails.getId(), true);
} else if (ApplicationUtils.isLanguageQuery()) {
inquiryResultList.add(
InquiryResultUtil.fetchLatestInquiryResultForInquiryDetailsById(inquiryDetails.getId()));
Expand Down Expand Up @@ -501,7 +501,7 @@ private String getSizeOfInquiryResult(InquiryResult inquiryResult, String defaul
return inquiryResult.getSize().toString();

} catch (Exception e) {
logger.error(e.getMessage(),e);
logger.error(e.getMessage(), e);
return Messages.getString(defaultErrorMessage);
}

Expand Down Expand Up @@ -544,7 +544,7 @@ private String getBrokerName(Inquiry inquiry) {
return brokerName;

} catch (Exception e) {
logger.error(e.getMessage(),e);
logger.error(e.getMessage(), e);
return UNKNOWN;
}

Expand Down
Loading

0 comments on commit a117409

Please sign in to comment.