Skip to content

Commit

Permalink
improved logging by @hhund
Browse files Browse the repository at this point in the history
  • Loading branch information
schwzr committed Mar 25, 2024
1 parent f3bacda commit 4e5a6ff
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ca.uhn.fhir.context.FhirContext;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.DataLogger;
import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.activity.AbstractServiceDelegate;
import dev.dsf.bpe.v1.constants.NamingSystems;
Expand All @@ -26,12 +26,14 @@ public class StoreValidationErrorForDts extends AbstractServiceDelegate
private static final Logger logger = LoggerFactory.getLogger(StoreValidationErrorForDts.class);

private final String dtsIdentifierValue;
private final DataLogger dataLogger;

public StoreValidationErrorForDts(ProcessPluginApi api, String dtsIdentifierValue)
public StoreValidationErrorForDts(ProcessPluginApi api, String dtsIdentifierValue, DataLogger dataLogger)
{
super(api);

this.dtsIdentifierValue = dtsIdentifierValue;
this.dataLogger = dataLogger;
}

@Override
Expand All @@ -40,6 +42,7 @@ public void afterPropertiesSet() throws Exception
super.afterPropertiesSet();

Objects.requireNonNull(dtsIdentifierValue, "dtsIdentifierValue");
Objects.requireNonNull(dataLogger, "dataLogger");
}

@Override
Expand Down Expand Up @@ -72,7 +75,7 @@ private IdType createBinaryResource(Binary binary)
}
catch (Exception e)
{
logger.debug("Binary to create {}", FhirContext.forR4().newJsonParser().encodeResourceToString(binary));
dataLogger.logData("Binary to create", binary);
logger.warn("Error while creating Binary resource: " + e.getMessage(), e);

throw new BpmnError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ca.uhn.fhir.context.FhirContext;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.DataLogger;
import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.activity.AbstractServiceDelegate;
import dev.dsf.bpe.v1.constants.NamingSystems;
Expand All @@ -27,12 +27,14 @@ public class StoreDataForDts extends AbstractServiceDelegate
private static final Logger logger = LoggerFactory.getLogger(StoreDataForDts.class);

private final String dtsIdentifierValue;
private final DataLogger dataLogger;

public StoreDataForDts(ProcessPluginApi api, String dtsIdentifierValue)
public StoreDataForDts(ProcessPluginApi api, String dtsIdentifierValue, DataLogger dataLogger)
{
super(api);

this.dtsIdentifierValue = dtsIdentifierValue;
this.dataLogger = dataLogger;
}

@Override
Expand All @@ -41,6 +43,7 @@ public void afterPropertiesSet() throws Exception
super.afterPropertiesSet();

Objects.requireNonNull(dtsIdentifierValue, "dtsIdentifierValue");
Objects.requireNonNull(dataLogger, "dataLogger");
}

@Override
Expand Down Expand Up @@ -72,7 +75,7 @@ private IdType createBinaryResource(Binary binary)
}
catch (Exception e)
{
logger.debug("Binary to create {}", FhirContext.forR4().newJsonParser().encodeResourceToString(binary));
dataLogger.logData("Binary to create", binary);
logger.warn("Error while creating Binary resource: " + e.getMessage(), e);

throw new BpmnError(CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_VALUE_UNABLE_TO_STORE_ECRYPTED_DATA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ca.uhn.fhir.context.FhirContext;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.DataLogger;
import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.activity.AbstractServiceDelegate;
import dev.dsf.bpe.v1.constants.NamingSystems;
Expand All @@ -27,12 +27,14 @@ public class StoreDataForCrr extends AbstractServiceDelegate
private static final Logger logger = LoggerFactory.getLogger(StoreDataForCrr.class);

private final String crrIdentifierValue;
private final DataLogger dataLogger;

public StoreDataForCrr(ProcessPluginApi api, String crrIdentifierValue)
public StoreDataForCrr(ProcessPluginApi api, String crrIdentifierValue, DataLogger dataLogger)
{
super(api);

this.crrIdentifierValue = crrIdentifierValue;
this.dataLogger = dataLogger;
}

@Override
Expand All @@ -41,6 +43,7 @@ public void afterPropertiesSet() throws Exception
super.afterPropertiesSet();

Objects.requireNonNull(crrIdentifierValue, "crrIdentifierValue");
Objects.requireNonNull(dataLogger, "dataLogger");
}

@Override
Expand Down Expand Up @@ -72,7 +75,7 @@ private IdType createBinaryResource(Binary binary)
}
catch (Exception e)
{
logger.debug("Binary to create {}", FhirContext.forR4().newJsonParser().encodeResourceToString(binary));
dataLogger.logData("Binary to create", binary);
logger.warn("Error while creating Binary resource: " + e.getMessage(), e);

throw new BpmnError(CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_VALUE_UNABLE_TO_STORE_ECRYPTED_DATA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_BUNDLE;
import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_VALUE_UNABLE_TO_STORE_ECRYPTED_VALIDATION_ERROR;

import java.util.Objects;

import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.hl7.fhir.r4.model.Binary;
Expand All @@ -12,21 +14,34 @@
import org.hl7.fhir.r4.model.ResourceType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;

import ca.uhn.fhir.context.FhirContext;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.DataLogger;
import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.activity.AbstractServiceDelegate;
import dev.dsf.bpe.v1.constants.NamingSystems;
import dev.dsf.bpe.v1.variables.Variables;
import jakarta.ws.rs.core.MediaType;

public class StoreValidationErrorForDic extends AbstractServiceDelegate
public class StoreValidationErrorForDic extends AbstractServiceDelegate implements InitializingBean
{
private static final Logger logger = LoggerFactory.getLogger(StoreValidationErrorForDic.class);

public StoreValidationErrorForDic(ProcessPluginApi api)
private DataLogger dataLogger;

public StoreValidationErrorForDic(ProcessPluginApi api, DataLogger dataLogger)
{
super(api);

this.dataLogger = dataLogger;
}

@Override
public void afterPropertiesSet() throws Exception
{
super.afterPropertiesSet();

Objects.requireNonNull(dataLogger, "dataLogger");
}

@Override
Expand Down Expand Up @@ -60,7 +75,7 @@ private IdType createBinaryResource(Binary binary)
}
catch (Exception e)
{
logger.debug("Binary to create {}", FhirContext.forR4().newJsonParser().encodeResourceToString(binary));
dataLogger.logData("Binary to create", binary);
logger.warn("Error while creating Binary resource: " + e.getMessage(), e);

throw new BpmnError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public EncryptValidationError encryptValidationError()
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public StoreValidationErrorForDts storeValidationErrorForDts()
{
return new StoreValidationErrorForDts(api, transferDataConfig.dtsIdentifierValue());
return new StoreValidationErrorForDts(api, transferDataConfig.dtsIdentifierValue(),
transferDataConfig.dataLogger());
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public AfterDryRunEndListener afterDryRunEndListener()
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public StoreDataForDts storeDataForDts()
{
return new StoreDataForDts(api, transferDataConfig.dtsIdentifierValue());
return new StoreDataForDts(api, transferDataConfig.dtsIdentifierValue(), transferDataConfig.dataLogger());
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ReplacePseudonym replacePseudonym()
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public StoreDataForCrr storeDataForCodex()
{
return new StoreDataForCrr(api, transferDataConfig.crrIdentifierValue());
return new StoreDataForCrr(api, transferDataConfig.crrIdentifierValue(), transferDataConfig.dataLogger());
}

@Bean
Expand Down Expand Up @@ -108,7 +108,7 @@ public DownloadValidationErrorFromCrr downloadValidationErrorFromCrr()
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public StoreValidationErrorForDic storeValidationErrorForDic()
{
return new StoreValidationErrorForDic(api);
return new StoreValidationErrorForDic(api, transferDataConfig.dataLogger());
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private SnapshotWithValidationMessages generateSnapshotAndWriteToCache(Structure

if (PublicationStatus.DRAFT.equals(snapshot.getSnapshot().getStatus()))
{
logger.info("Not writing StructureDefinition {}|{} with snapshot and status {} to cache",
logger.warn("Not writing StructureDefinition {}|{} with snapshot and status {} to cache",
snapshot.getSnapshot().getUrl(), snapshot.getSnapshot().getVersion(),
snapshot.getSnapshot().getStatus());
return snapshot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.hl7.fhir.common.hapi.validation.support.InMemoryTerminologyServerValidationSupport;
import org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain;
import org.hl7.fhir.r4.model.Enumerations.BindingStrength;
import org.hl7.fhir.r4.model.Enumerations.PublicationStatus;
import org.hl7.fhir.r4.model.StructureDefinition;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent;
Expand Down Expand Up @@ -367,9 +368,22 @@ private void createSnapshot(ValidationPackageWithDepedencies packageWithDependen
definitions.stream()
.filter(sd -> !sd.equals(diff) && !sd.getUrl().equals(diff.getBaseDefinition())
&& !(sd.getUrl() + "|" + sd.getVersion()).equals(diff.getBaseDefinition()))
.map(sd -> sd.getUrl() + "|" + sd.getVersion()).sorted()
.map(sd -> sd.getUrl() + "|" + sd.getVersion()).distinct().sorted()
.collect(Collectors.joining(", ", "[", "]")));

String dependenciesWithDifferentStatus = definitions.stream()
.filter(sd -> !sd.equals(diff) && !sd.getUrl().equals(diff.getBaseDefinition())
&& !(sd.getUrl() + "|" + sd.getVersion()).equals(diff.getBaseDefinition()))
.filter(sd -> !sd.getStatus().equals(diff.getStatus()))
.map(sd -> sd.getUrl() + "|" + sd.getVersion() + ": " + sd.getStatus().toCode()).distinct().sorted()
.collect(Collectors.joining(", "));

if (PublicationStatus.ACTIVE.equals(diff.getStatus()) && !dependenciesWithDifferentStatus.isEmpty())
{
logger.warn("StructureDefinition {}|{}, has dependencies with no active status [{}]", diff.getUrl(),
diff.getVersion(), dependenciesWithDifferentStatus);
}

definitions.stream().filter(sd -> sd.hasDifferential() && !sd.hasSnapshot()
&& !snapshots.containsKey(sd.getUrl() + "|" + sd.getVersion())).forEach(sd ->
{
Expand Down

0 comments on commit 4e5a6ff

Please sign in to comment.