Skip to content

Commit

Permalink
additional logging
Browse files Browse the repository at this point in the history
  • Loading branch information
hhund committed Jun 20, 2022
1 parent 3d10fac commit 103b2c0
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,35 @@
public class ErrorLogger
{
private static final Logger validationLogger = LoggerFactory.getLogger("validation-error-logger");
private static final Logger errorLogger = LoggerFactory.getLogger("error-logger");

public void logValidationFailed(IdType taskId)
{
validationLogger.debug(
"Validation of FHIR resources faild during execution of data-send process started by Task {}",
taskId.getValue());
validationLogger.debug("Validation of FHIR resources failed, started by Task {}", taskId.getValue());
}

public void logValidationFailedLocal(IdType taskId)
{
validationLogger.debug("Local validation of FHIR resources failed, started by Task {}", taskId.getValue());
}

public void logValidationFailedRemote(IdType taskId)
{
validationLogger.debug("Remote validation of FHIR resources failed, started by Task {}", taskId.getValue());
}

public void logDataSendFailed(IdType taskId)
{
errorLogger.debug("Send process failed, started by Task {}", taskId.getValue());
}

public void logDataTranslateFailed(IdType taskId)
{
errorLogger.debug("Translate process failed, started by Task {}", taskId.getValue());
}

public void logDataReceiveFailed(IdType taskId)
{
errorLogger.debug("Receive process failed, started by Task {}", taskId.getValue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,31 @@
import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper;
import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider;
import org.highmed.dsf.fhir.task.TaskHelper;
import org.hl7.fhir.r4.model.ResourceType;
import org.hl7.fhir.r4.model.Task;
import org.hl7.fhir.r4.model.Task.TaskOutputComponent;
import org.hl7.fhir.r4.model.Task.TaskStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.error.ErrorOutputParameterGenerator;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.ErrorLogger;

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

private final ErrorOutputParameterGenerator errorOutputParameterGenerator;
private final ErrorLogger errorLogger;

public LogError(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper,
ReadAccessHelper readAccessHelper, ErrorOutputParameterGenerator errorOutputParameterGenerator)
ReadAccessHelper readAccessHelper, ErrorOutputParameterGenerator errorOutputParameterGenerator,
ErrorLogger errorLogger)
{
super(clientProvider, taskHelper, readAccessHelper);

this.errorOutputParameterGenerator = errorOutputParameterGenerator;
this.errorLogger = errorLogger;
}

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

Objects.requireNonNull(errorOutputParameterGenerator, "errorOutputParameterGenerator");
Objects.requireNonNull(errorLogger, "errorLogger");
}

@Override
Expand All @@ -63,6 +69,11 @@ protected void doExecute(DelegateExecution execution) throws BpmnError, Exceptio
errorCode, errorMessage);

task.addOutput(output);

logger.warn("Error while transfering data to CRR: {} - {}", errorCode, errorMessage);

errorLogger.logDataReceiveFailed(getLeadingTaskFromExecutionVariables().getIdElement()
.withServerBase(getFhirWebserviceClientProvider().getLocalBaseUrl(), ResourceType.Task.name()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,30 @@
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.OperationOutcome;
import org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity;
import org.hl7.fhir.r4.model.ResourceType;
import org.hl7.fhir.r4.model.Task;
import org.hl7.fhir.r4.model.Task.TaskStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.error.ErrorOutputParameterGenerator;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.ErrorLogger;

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

private final ErrorOutputParameterGenerator errorOutputParameterGenerator;
private final ErrorLogger errorLogger;

public LogValidationError(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper,
ReadAccessHelper readAccessHelper, ErrorOutputParameterGenerator errorOutputParameterGenerator)
ReadAccessHelper readAccessHelper, ErrorOutputParameterGenerator errorOutputParameterGenerator,
ErrorLogger errorLogger)
{
super(clientProvider, taskHelper, readAccessHelper);

this.errorOutputParameterGenerator = errorOutputParameterGenerator;
this.errorLogger = errorLogger;
}

@Override
Expand All @@ -40,11 +45,16 @@ public void afterPropertiesSet() throws Exception
super.afterPropertiesSet();

Objects.requireNonNull(errorOutputParameterGenerator, "errorOutputParameterGenerator");
Objects.requireNonNull(errorLogger, "errorLogger");
}

@Override
protected void doExecute(DelegateExecution execution) throws BpmnError, Exception
{
logger.info("Validation error while adding resources to CRR FHIR repository");
errorLogger.logValidationFailed(getLeadingTaskFromExecutionVariables().getIdElement()
.withServerBase(getFhirWebserviceClientProvider().getLocalBaseUrl(), ResourceType.Task.name()));

logger.debug("Setting Task.status failed, adding validation errors");

Task task = getLeadingTaskFromExecutionVariables();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,31 @@
import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper;
import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider;
import org.highmed.dsf.fhir.task.TaskHelper;
import org.hl7.fhir.r4.model.ResourceType;
import org.hl7.fhir.r4.model.Task;
import org.hl7.fhir.r4.model.Task.TaskOutputComponent;
import org.hl7.fhir.r4.model.Task.TaskStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.error.ErrorOutputParameterGenerator;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.ErrorLogger;

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

private final ErrorOutputParameterGenerator errorOutputParameterGenerator;
private final ErrorLogger errorLogger;

public LogError(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper,
ReadAccessHelper readAccessHelper, ErrorOutputParameterGenerator errorOutputParameterGenerator)
ReadAccessHelper readAccessHelper, ErrorOutputParameterGenerator errorOutputParameterGenerator,
ErrorLogger errorLogger)
{
super(clientProvider, taskHelper, readAccessHelper);

this.errorOutputParameterGenerator = errorOutputParameterGenerator;
this.errorLogger = errorLogger;
}

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

Objects.requireNonNull(errorOutputParameterGenerator, "errorOutputParameterGenerator");
Objects.requireNonNull(errorLogger, "errorLogger");
}

@Override
Expand All @@ -63,6 +69,11 @@ protected void doExecute(DelegateExecution execution) throws BpmnError, Exceptio
errorCode, errorMessage);

task.addOutput(output);

logger.warn("Error while transfering data to CRR: {} - {}", errorCode, errorMessage);

errorLogger.logDataReceiveFailed(getLeadingTaskFromExecutionVariables().getIdElement()
.withServerBase(getFhirWebserviceClientProvider().getLocalBaseUrl(), ResourceType.Task.name()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public LogSuccess(FhirWebserviceClientProvider clientProvider, TaskHelper taskHe
@Override
protected void doExecute(DelegateExecution execution) throws BpmnError, Exception
{
// TODO log success
logger.debug("TODO log success");
logger.info("All resources successfully added to CRR FHIR repository");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,31 @@
import org.hl7.fhir.r4.model.OperationOutcome;
import org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity;
import org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent;
import org.hl7.fhir.r4.model.ResourceType;
import org.hl7.fhir.r4.model.StringType;
import org.hl7.fhir.r4.model.Task;
import org.hl7.fhir.r4.model.Task.TaskStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.error.ErrorOutputParameterGenerator;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.ErrorLogger;

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

private final ErrorOutputParameterGenerator errorOutputParameterGenerator;
private final ErrorLogger errorLogger;

public LogValidationError(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper,
ReadAccessHelper readAccessHelper, ErrorOutputParameterGenerator errorOutputParameterGenerator)
ReadAccessHelper readAccessHelper, ErrorOutputParameterGenerator errorOutputParameterGenerator,
ErrorLogger errorLogger)
{
super(clientProvider, taskHelper, readAccessHelper);

this.errorOutputParameterGenerator = errorOutputParameterGenerator;
this.errorLogger = errorLogger;
}

@Override
Expand All @@ -46,17 +51,22 @@ public void afterPropertiesSet() throws Exception
super.afterPropertiesSet();

Objects.requireNonNull(errorOutputParameterGenerator, "errorOutputParameterGenerator");
Objects.requireNonNull(errorLogger, "errorLogger");
}

@Override
protected void doExecute(DelegateExecution execution) throws BpmnError, Exception
{
logger.info("Validation error while adding resources to CRR FHIR repository");

Bundle bundle = (Bundle) execution.getVariable(BPMN_EXECUTION_VARIABLE_BUNDLE);

@SuppressWarnings("unchecked")
Map<String, String> sourceIdsByBundleUuid = (Map<String, String>) execution
.getVariable(BPMN_EXECUTION_VARIABLE_SOURCE_IDS_BY_BUNDLE_UUID);

errorLogger.logValidationFailedRemote(getLeadingTaskFromExecutionVariables().getIdElement()
.withServerBase(getFhirWebserviceClientProvider().getLocalBaseUrl(), ResourceType.Task.name()));
logValidationDetails(bundle, sourceIdsByBundleUuid);
addErrorsToTask(bundle, sourceIdsByBundleUuid);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.hl7.fhir.r4.model.OperationOutcome;
import org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity;
import org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent;
import org.hl7.fhir.r4.model.ResourceType;
import org.hl7.fhir.r4.model.StringType;
import org.hl7.fhir.r4.model.Task;
import org.slf4j.Logger;
Expand Down Expand Up @@ -112,9 +113,9 @@ protected void doExecute(DelegateExecution execution) throws BpmnError, Exceptio
resourcesWithErrorCount, resourcesWithErrorCount != 1 ? "s" : "");

addErrorsToTask(bundle);
errorLogger.logValidationFailed(getLeadingTaskFromExecutionVariables().getIdElement()
.withServerBase(getFhirWebserviceClientProvider().getLocalBaseUrl(),
getLeadingTaskFromExecutionVariables().getIdElement().getResourceType()));
errorLogger.logValidationFailedLocal(
getLeadingTaskFromExecutionVariables().getIdElement().withServerBase(
getFhirWebserviceClientProvider().getLocalBaseUrl(), ResourceType.Task.name()));

throw new BpmnError(CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_VALUE_VALIDATION_FAILED,
"Validation of transfer bundle failed, " + resourcesWithErrorCount + " resource"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,31 @@
import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper;
import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider;
import org.highmed.dsf.fhir.task.TaskHelper;
import org.hl7.fhir.r4.model.ResourceType;
import org.hl7.fhir.r4.model.Task;
import org.hl7.fhir.r4.model.Task.TaskOutputComponent;
import org.hl7.fhir.r4.model.Task.TaskStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.error.ErrorOutputParameterGenerator;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.ErrorLogger;

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

private final ErrorOutputParameterGenerator errorOutputParameterGenerator;
private final ErrorLogger errorLogger;

public LogError(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper,
ReadAccessHelper readAccessHelper, ErrorOutputParameterGenerator errorOutputParameterGenerator)
ReadAccessHelper readAccessHelper, ErrorOutputParameterGenerator errorOutputParameterGenerator,
ErrorLogger errorLogger)
{
super(clientProvider, taskHelper, readAccessHelper);

this.errorOutputParameterGenerator = errorOutputParameterGenerator;
this.errorLogger = errorLogger;
}

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

Objects.requireNonNull(errorOutputParameterGenerator, "errorOutputParameterGenerator");
Objects.requireNonNull(errorLogger, "errorLogger");
}

@Override
Expand All @@ -63,6 +69,11 @@ protected void doExecute(DelegateExecution execution) throws BpmnError, Exceptio
errorCode, errorMessage);

task.addOutput(output);

logger.warn("Error while transfering data to CRR: {} - {}", errorCode, errorMessage);

errorLogger.logDataReceiveFailed(getLeadingTaskFromExecutionVariables().getIdElement()
.withServerBase(getFhirWebserviceClientProvider().getLocalBaseUrl(), ResourceType.Task.name()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,30 @@
import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper;
import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider;
import org.highmed.dsf.fhir.task.TaskHelper;
import org.hl7.fhir.r4.model.ResourceType;
import org.hl7.fhir.r4.model.Task;
import org.hl7.fhir.r4.model.Task.TaskOutputComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.error.ErrorOutputParameterGenerator;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.ErrorLogger;

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

private final ErrorOutputParameterGenerator errorOutputParameterGenerator;
private final ErrorLogger errorLogger;

public LogValidationError(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper,
ReadAccessHelper readAccessHelper, ErrorOutputParameterGenerator errorOutputParameterGenerator)
ReadAccessHelper readAccessHelper, ErrorOutputParameterGenerator errorOutputParameterGenerator,
ErrorLogger errorLogger)
{
super(clientProvider, taskHelper, readAccessHelper);

this.errorOutputParameterGenerator = errorOutputParameterGenerator;
this.errorLogger = errorLogger;
}

@Override
Expand All @@ -38,12 +43,15 @@ public void afterPropertiesSet() throws Exception
super.afterPropertiesSet();

Objects.requireNonNull(errorOutputParameterGenerator, "errorOutputParameterGenerator");
Objects.requireNonNull(errorLogger, "errorLogger");
}

@Override
protected void doExecute(DelegateExecution execution) throws BpmnError, Exception
{
logger.info("Validation error while adding resources to CRR FHIR repository");
errorLogger.logValidationFailedRemote(getLeadingTaskFromExecutionVariables().getIdElement()
.withServerBase(getFhirWebserviceClientProvider().getLocalBaseUrl(), ResourceType.Task.name()));

Task task = getLeadingTaskFromExecutionVariables();
TaskOutputComponent output = errorOutputParameterGenerator.createError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public LogSuccess logSuccess()
public LogValidationError logValidationError()
{
return new LogValidationError(transferDataConfig.fhirClientProvider(), transferDataConfig.taskHelper(),
transferDataConfig.readAccessHelper(), transferDataConfig.errorOutputParameterGenerator());
transferDataConfig.readAccessHelper(), transferDataConfig.errorOutputParameterGenerator(),
transferDataConfig.errorLogger());
}

@Bean
Expand Down Expand Up @@ -112,6 +113,7 @@ public ContinueTranslateProcessWithError continueTranslateProcessWithError()
public LogError logError()
{
return new LogError(transferDataConfig.fhirClientProvider(), transferDataConfig.taskHelper(),
transferDataConfig.readAccessHelper(), transferDataConfig.errorOutputParameterGenerator());
transferDataConfig.readAccessHelper(), transferDataConfig.errorOutputParameterGenerator(),
transferDataConfig.errorLogger());
}
}
Loading

0 comments on commit 103b2c0

Please sign in to comment.