Skip to content

Commit

Permalink
add reporting and fix reported code improvements where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
wetret committed Dec 15, 2023
1 parent 049556c commit ef3c66a
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 23 deletions.
45 changes: 45 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,26 @@
</workingPackages>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.5.0</version>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.8.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.21.2</version>
</plugin>
</plugins>
</build>

Expand All @@ -213,6 +233,9 @@
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/medizininformatik-initiative/mii-process-data-transfer</url>
</repository>
<site>
<id>${project.artifactId}-site</id>
</site>
</distributionManagement>

<repositories>
Expand Down Expand Up @@ -388,4 +411,26 @@
</build>
</profile>
</profiles>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<plugins>
<plugin>
<groupId>jp.skypencil.findbugs.slf4j</groupId>
<artifactId>bug-pattern</artifactId>
<version>1.5.0</version>
</plugin>
</plugins>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import de.medizininformatik_initiative.process.data_transfer.ConstantsDataTransfer;
import de.medizininformatik_initiative.processes.common.util.ConstantsBase;
import de.medizininformatik_initiative.processes.common.util.DataSetStatusGenerator;

import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.activity.AbstractTaskMessageSend;
import dev.dsf.bpe.v1.variables.Variables;
Expand Down Expand Up @@ -54,14 +55,15 @@ protected Stream<ParameterComponent> getAdditionalInputParameters(DelegateExecut
.setCode(ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_REFERENCE);
binaryComponent.setValue(new Reference().setType(ResourceType.Binary.name()).setReference(binaryId));

String projectIdentifier = variables
.getString(ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_PROJECT_IDENTIFIER);
String projectIdentifier = variables.getString(
ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_PROJECT_IDENTIFIER);

Task.ParameterComponent projectIdentifierComponent = new Task.ParameterComponent();
projectIdentifierComponent.getType().addCoding().setSystem(ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER)
.setCode(ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_PROJECT_IDENTIFIER);
projectIdentifierComponent.setValue(new Identifier()
.setSystem(ConstantsBase.NAMINGSYSTEM_MII_PROJECT_IDENTIFIER).setValue(projectIdentifier));
projectIdentifierComponent.setValue(
new Identifier().setSystem(ConstantsBase.NAMINGSYSTEM_MII_PROJECT_IDENTIFIER)
.setValue(projectIdentifier));

return Stream.of(binaryComponent, projectIdentifierComponent);
}
Expand All @@ -81,13 +83,11 @@ protected void handleSendTaskError(DelegateExecution execution, Variables variab
Task task = variables.getStartTask();

String statusCode = ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_NOT_REACHABLE;
if (exception instanceof WebApplicationException webApplicationException)
if (exception instanceof WebApplicationException webApplicationException
&& webApplicationException.getResponse() != null
&& webApplicationException.getResponse().getStatus() == Response.Status.FORBIDDEN.getStatusCode())
{
if (webApplicationException.getResponse() != null
&& webApplicationException.getResponse().getStatus() == Response.Status.FORBIDDEN.getStatusCode())
{
statusCode = ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_NOT_ALLOWED;
}
statusCode = ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_NOT_ALLOWED;
}

task.setStatus(Task.TaskStatus.FAILED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import de.medizininformatik_initiative.process.data_transfer.ConstantsDataTransfer;
import de.medizininformatik_initiative.processes.common.util.ConstantsBase;
import de.medizininformatik_initiative.processes.common.util.DataSetStatusGenerator;

import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.activity.AbstractTaskMessageSend;
import dev.dsf.bpe.v1.variables.Variables;
Expand Down Expand Up @@ -55,22 +56,18 @@ protected IdType doSend(FhirWebserviceClient client, Task task)

private Stream<Task.ParameterComponent> createReceiptError(Variables variables)
{
return statusGenerator
.transformOutputToInputComponent(variables.getStartTask(),
ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER,
ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS)
.map(this::receiveToReceiptStatus);
return statusGenerator.transformOutputToInputComponent(variables.getStartTask(),
ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER,
ConstantsDataTransfer.CODESYSTEM_DATA_TRANSFER_VALUE_DATA_SET_STATUS).map(this::receiveToReceiptStatus);
}

private Task.ParameterComponent receiveToReceiptStatus(Task.ParameterComponent parameterComponent)
{
Type value = parameterComponent.getValue();
if (value instanceof Coding coding)
if (value instanceof Coding coding && ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR.equals(
coding.getCode()))
{
if (ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIVE_ERROR.equals(coding.getCode()))
{
coding.setCode(ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_ERROR);
}
coding.setCode(ConstantsBase.CODESYSTEM_DATA_SET_STATUS_VALUE_RECEIPT_ERROR);
}

return parameterComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private DocumentReference getDocumentReference(Bundle bundle)
{
List<DocumentReference> documentReferences = bundle.getEntry().stream()
.map(Bundle.BundleEntryComponent::getResource).filter(r -> r instanceof DocumentReference)
.map(r -> ((DocumentReference) r)).toList();
.map(r -> (DocumentReference) r).toList();

if (documentReferences.size() < 1)
throw new IllegalArgumentException("Could not find any DocumentReference in PublicKey Bundle");
Expand All @@ -132,7 +132,7 @@ private DocumentReference getDocumentReference(Bundle bundle)
private Binary getBinary(Bundle bundle)
{
List<Binary> binaries = bundle.getEntry().stream().map(Bundle.BundleEntryComponent::getResource)
.filter(r -> r instanceof Binary).map(b -> ((Binary) b)).toList();
.filter(r -> r instanceof Binary).map(b -> (Binary) b).toList();

if (binaries.size() < 1)
throw new IllegalArgumentException("Could not find any Binary in PublicKey Bundle");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private DocumentReference readDocumentReference(FhirClient fhirClient, String pr
List<DocumentReference> documentReferences = fhirClient
.searchDocumentReferences(ConstantsBase.NAMINGSYSTEM_MII_PROJECT_IDENTIFIER, projectIdentifier)
.getEntry().stream().map(Bundle.BundleEntryComponent::getResource)
.filter(r -> r instanceof DocumentReference).map(r -> ((DocumentReference) r)).toList();
.filter(r -> r instanceof DocumentReference).map(r -> (DocumentReference) r).toList();

if (documentReferences.size() < 1)
throw new IllegalArgumentException("Could not find any DocumentReference for project-identifier '"
Expand Down

0 comments on commit ef3c66a

Please sign in to comment.