From 836ebf077d862c5c22d59695697a6e1bdcc3a2f2 Mon Sep 17 00:00:00 2001 From: Hauke Hund Date: Sun, 23 Apr 2023 21:57:33 +0200 Subject: [PATCH 1/9] upgrades implementation to the new process plugins api, closes #1 --- pom.xml | 10 +- src/main/java/dev/dsf/bpe/ConstantsPing.java | 29 +-- .../dsf/bpe/PingProcessPluginDefinition.java | 72 +++--- .../dev/dsf/bpe/mail/ErrorMailService.java | 61 ++--- .../java/dev/dsf/bpe/message/SendPing.java | 64 ++--- .../java/dev/dsf/bpe/message/SendPong.java | 54 ++--- .../dev/dsf/bpe/message/SendStartPing.java | 20 +- .../dev/dsf/bpe/service/LogNoResponse.java | 38 ++- .../java/dev/dsf/bpe/service/LogPing.java | 19 +- .../java/dev/dsf/bpe/service/LogPong.java | 39 ++-- .../dsf/bpe/service/SelectPingTargets.java | 112 +++------ .../dev/dsf/bpe/service/SelectPongTarget.java | 48 ++-- .../service/SetTargetAndConfigureTimer.java | 59 ++--- .../dev/dsf/bpe/spring/config/PingConfig.java | 65 ++---- .../dev/dsf/bpe/util/PingStatusGenerator.java | 12 +- ...=> dev.dsf.bpe.v1.ProcessPluginDefinition} | 0 src/main/resources/bpe/ping-autostart.bpmn | 220 +++++++++--------- src/main/resources/bpe/ping.bpmn | 160 +++++++------ src/main/resources/bpe/pong.bpmn | 100 ++++---- .../StructureDefinition/dsf-task-ping.xml | 6 +- .../StructureDefinition/dsf-task-pong.xml | 6 +- .../dsf-task-start-ping-autostart.xml | 6 +- .../dsf-task-start-ping.xml | 6 +- .../dsf-task-stop-ping-autostart.xml | 6 +- .../fhir/Task/dsf-task-start-ping.xml | 38 +++ .../bpe/PingProcessPluginDefinitionTest.java | 31 +-- .../Ping3MedicFromTtpExampleStarter.java | 24 +- .../PingTtpsFromMedic1ExampleStarter.java | 24 +- ...ostartPing3MedicFromTtpExampleStarter.java | 25 +- ...ostartPing3MedicFromTtpExampleStarter.java | 25 +- .../dsf/fhir/profiles/TaskProfileTest.java | 191 +++++++++------ 31 files changed, 739 insertions(+), 831 deletions(-) rename src/main/resources/META-INF/services/{dev.dsf.bpe.ProcessPluginDefinition => dev.dsf.bpe.v1.ProcessPluginDefinition} (100%) create mode 100644 src/main/resources/fhir/Task/dsf-task-start-ping.xml diff --git a/pom.xml b/pom.xml index e76581f..aa05eb9 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ dev.dsf dsf-process-ping-pong - 1.0.0-SNAPSHOT + 1.0.0.0-SNAPSHOT jar @@ -39,10 +39,16 @@ dev.dsf - dsf-bpe-process-base + dsf-bpe-process-api-v1 ${dsf.version} provided + + org.springframework + spring-web + 6.0.8 + provided + org.slf4j diff --git a/src/main/java/dev/dsf/bpe/ConstantsPing.java b/src/main/java/dev/dsf/bpe/ConstantsPing.java index 5769b59..0f8c12f 100644 --- a/src/main/java/dev/dsf/bpe/ConstantsPing.java +++ b/src/main/java/dev/dsf/bpe/ConstantsPing.java @@ -11,42 +11,25 @@ public interface ConstantsPing String PROCESS_NAME_FULL_PING = "dsfdev_" + PROCESS_NAME_PING; String PROCESS_NAME_FULL_PONG = "dsfdev_" + PROCESS_NAME_PONG; + String PROCESS_DSF_URI_BASE = "http://dsf.dev/bpe/Process/"; + String PROFILE_DSF_TASK_START_PING_AUTOSTART = "http://dsf.dev/fhir/StructureDefinition/task-start-ping-autostart"; - String PROFILE_DSF_TASK_START_PING_AUTOSTART_AND_LATEST_VERSION = PROFILE_DSF_TASK_START_PING_AUTOSTART + "|" - + PingProcessPluginDefinition.VERSION; - String PROFILE_DSF_TASK_START_PING_AUTOSTART_PROCESS_URI = ConstantsBase.PROCESS_DSF_URI_BASE - + PROCESS_NAME_PING_AUTOSTART + "/"; - String PROFILE_DSF_TASK_START_PING_AUTOSTART_PROCESS_URI_AND_LATEST_VERSION = PROFILE_DSF_TASK_START_PING_AUTOSTART_PROCESS_URI - + PingProcessPluginDefinition.VERSION; + String PROFILE_DSF_TASK_START_PING_AUTOSTART_PROCESS_URI = PROCESS_DSF_URI_BASE + PROCESS_NAME_PING_AUTOSTART; String PROFILE_DSF_TASK_START_PING_AUTOSTART_MESSAGE_NAME = "startPingAutostart"; String PROFILE_DSF_TASK_STOP_PING_AUTOSTART = "http://dsf.dev/fhir/StructureDefinition/task-stop-ping-autostart"; - String PROFILE_DSF_TASK_STOP_PING_AUTOSTART_AND_LATEST_VERSION = PROFILE_DSF_TASK_STOP_PING_AUTOSTART + "|" - + PingProcessPluginDefinition.VERSION; - String PROFILE_DSF_TASK_STOP_PING_AUTOSTART_PROCESS_URI = ConstantsBase.PROCESS_DSF_URI_BASE - + PROCESS_NAME_PING_AUTOSTART + "/"; - String PROFILE_DSF_TASK_STOP_PING_AUTOSTART_PROCESS_URI_AND_LATEST_VERSION = PROFILE_DSF_TASK_STOP_PING_AUTOSTART_PROCESS_URI - + PingProcessPluginDefinition.VERSION; + String PROFILE_DSF_TASK_STOP_PING_AUTOSTART_PROCESS_URI = PROCESS_DSF_URI_BASE + PROCESS_NAME_PING_AUTOSTART; String PROFILE_DSF_TASK_STOP_PING_AUTOSTART_MESSAGE_NAME = "stopPingAutostart"; String PROFILE_DSF_TASK_START_PING = "http://dsf.dev/fhir/StructureDefinition/task-start-ping"; - String PROFILE_DSF_TASK_START_PING_AND_LATEST_VERSION = PROFILE_DSF_TASK_START_PING + "|" - + PingProcessPluginDefinition.VERSION; String PROFILE_DSF_TASK_START_PING_MESSAGE_NAME = "startPing"; String PROFILE_DSF_TASK_PING = "http://dsf.dev/fhir/StructureDefinition/task-ping"; - String PROFILE_DSF_TASK_PING_AND_LATEST_VERSION = PROFILE_DSF_TASK_PING + "|" + PingProcessPluginDefinition.VERSION; - String PROFILE_DSF_TASK_PING_PROCESS_URI = ConstantsBase.PROCESS_DSF_URI_BASE + PROCESS_NAME_PING + "/"; - String PROFILE_DSF_TASK_PING_PROCESS_URI_AND_LATEST_VERSION = PROFILE_DSF_TASK_PING_PROCESS_URI - + PingProcessPluginDefinition.VERSION; + String PROFILE_DSF_TASK_PING_PROCESS_URI = PROCESS_DSF_URI_BASE + PROCESS_NAME_PING; String PROFILE_DSF_TASK_PING_MESSAGE_NAME = "ping"; String PROFILE_DSF_TASK_PONG_TASK = "http://dsf.dev/fhir/StructureDefinition/task-pong"; - String PROFILE_DSF_TASK_PONG_TASK_AND_LATEST_VERSION = PROFILE_DSF_TASK_PONG_TASK + "|" - + PingProcessPluginDefinition.VERSION; - String PROFILE_DSF_TASK_PONG_PROCESS_URI = ConstantsBase.PROCESS_DSF_URI_BASE + PROCESS_NAME_PONG + "/"; - String PROFILE_DSF_TASK_PONG_PROCESS_URI_AND_LATEST_VERSION = PROFILE_DSF_TASK_PONG_PROCESS_URI - + PingProcessPluginDefinition.VERSION; + String PROFILE_DSF_TASK_PONG_PROCESS_URI = PROCESS_DSF_URI_BASE + PROCESS_NAME_PONG; String PROFILE_DSF_TASK_PONG_MESSAGE_NAME = "pong"; String CODESYSTEM_DSF_PING = "http://dsf.dev/fhir/CodeSystem/ping"; diff --git a/src/main/java/dev/dsf/bpe/PingProcessPluginDefinition.java b/src/main/java/dev/dsf/bpe/PingProcessPluginDefinition.java index 09c3b61..de682fc 100644 --- a/src/main/java/dev/dsf/bpe/PingProcessPluginDefinition.java +++ b/src/main/java/dev/dsf/bpe/PingProcessPluginDefinition.java @@ -4,23 +4,14 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.stream.Stream; -import org.springframework.core.env.PropertyResolver; - -import ca.uhn.fhir.context.FhirContext; import dev.dsf.bpe.spring.config.PingConfig; -import dev.dsf.fhir.resources.AbstractResource; -import dev.dsf.fhir.resources.ActivityDefinitionResource; -import dev.dsf.fhir.resources.CodeSystemResource; -import dev.dsf.fhir.resources.ResourceProvider; -import dev.dsf.fhir.resources.StructureDefinitionResource; -import dev.dsf.fhir.resources.ValueSetResource; +import dev.dsf.bpe.v1.ProcessPluginDefinition; public class PingProcessPluginDefinition implements ProcessPluginDefinition { - public static final String VERSION = "0.7.0"; - public static final LocalDate RELEASE_DATE = LocalDate.of(2022, 10, 18); + public static final String VERSION = "1.0.0.0"; + public static final LocalDate RELEASE_DATE = LocalDate.of(2023, 4, 22); @Override public String getName() @@ -41,51 +32,46 @@ public LocalDate getReleaseDate() } @Override - public Stream getBpmnFiles() + public List getProcessModels() { - return Stream.of("bpe/ping-autostart.bpmn", "bpe/ping.bpmn", "bpe/pong.bpmn"); + return List.of("bpe/ping-autostart.bpmn", "bpe/ping.bpmn", "bpe/pong.bpmn"); } @Override - public Stream> getSpringConfigClasses() + public List> getSpringConfigurations() { - return Stream.of(PingConfig.class); + return List.of(PingConfig.class); } @Override - public ResourceProvider getResourceProvider(FhirContext fhirContext, ClassLoader classLoader, - PropertyResolver resolver) + public Map> getFhirResourcesByProcessId() { - var aPing = ActivityDefinitionResource.file("fhir/ActivityDefinition/dsf-ping.xml"); - var aPingAutostart = ActivityDefinitionResource.file("fhir/ActivityDefinition/dsf-ping-autostart.xml"); - var aPong = ActivityDefinitionResource.file("fhir/ActivityDefinition/dsf-pong.xml"); + var aPing = "fhir/ActivityDefinition/dsf-ping.xml"; + var aPingAutostart = "fhir/ActivityDefinition/dsf-ping-autostart.xml"; + var aPong = "fhir/ActivityDefinition/dsf-pong.xml"; + + var cPing = "fhir/CodeSystem/dsf-ping.xml"; + var cPingStatus = "fhir/CodeSystem/dsf-ping-status.xml"; - var cPing = CodeSystemResource.file("fhir/CodeSystem/dsf-ping.xml"); - var cPingStatus = CodeSystemResource.file("fhir/CodeSystem/dsf-ping-status.xml"); + var sPingStatus = "fhir/StructureDefinition/dsf-extension-ping-status.xml"; + var sPing = "fhir/StructureDefinition/dsf-task-ping.xml"; + var sPong = "fhir/StructureDefinition/dsf-task-pong.xml"; + var sStartPing = "fhir/StructureDefinition/dsf-task-start-ping.xml"; + var sStartPingAutostart = "fhir/StructureDefinition/dsf-task-start-ping-autostart.xml"; + var sStopPingAutostart = "fhir/StructureDefinition/dsf-task-stop-ping-autostart.xml"; - var sPingStatus = StructureDefinitionResource.file("fhir/StructureDefinition/dsf-extension-ping-status.xml"); - var sPing = StructureDefinitionResource.file("fhir/StructureDefinition/dsf-task-ping.xml"); - var sPong = StructureDefinitionResource.file("fhir/StructureDefinition/dsf-task-pong.xml"); - var sStartPing = StructureDefinitionResource.file("fhir/StructureDefinition/dsf-task-start-ping.xml"); - var sStartPingAutostart = StructureDefinitionResource - .file("fhir/StructureDefinition/dsf-task-start-ping-autostart.xml"); - var sStopPingAutostart = StructureDefinitionResource - .file("fhir/StructureDefinition/dsf-task-stop-ping-autostart.xml"); + var tStartPing = "fhir/Task/dsf-task-start-ping.xml"; - var vPing = ValueSetResource.file("fhir/ValueSet/dsf-ping.xml"); - var vPingStatus = ValueSetResource.file("fhir/ValueSet/dsf-ping-status.xml"); - var vPongStatus = ValueSetResource.file("fhir/ValueSet/dsf-pong-status.xml"); + var vPing = "fhir/ValueSet/dsf-ping.xml"; + var vPingStatus = "fhir/ValueSet/dsf-ping-status.xml"; + var vPongStatus = "fhir/ValueSet/dsf-pong-status.xml"; - Map> resourcesByProcessKeyAndVersion = Map.of( - ConstantsPing.PROCESS_NAME_FULL_PING + "/" + VERSION, - Arrays.asList(aPing, cPing, cPingStatus, sPingStatus, sStartPing, sPong, vPing, vPingStatus), - ConstantsPing.PROCESS_NAME_FULL_PING_AUTOSTART + "/" + VERSION, + return Map.of(ConstantsPing.PROCESS_NAME_FULL_PING, + Arrays.asList(aPing, cPing, cPingStatus, sPingStatus, sStartPing, sPong, tStartPing, vPing, + vPingStatus), + ConstantsPing.PROCESS_NAME_FULL_PING_AUTOSTART, Arrays.asList(aPingAutostart, cPing, sStartPingAutostart, sStopPingAutostart, vPing), - ConstantsPing.PROCESS_NAME_FULL_PONG + "/" + VERSION, + ConstantsPing.PROCESS_NAME_FULL_PONG, Arrays.asList(aPong, cPing, cPingStatus, sPingStatus, sPing, vPing, vPongStatus)); - - return ResourceProvider.read(VERSION, RELEASE_DATE, - () -> fhirContext.newXmlParser().setStripVersionsFromReferences(false), classLoader, resolver, - resourcesByProcessKeyAndVersion); } } diff --git a/src/main/java/dev/dsf/bpe/mail/ErrorMailService.java b/src/main/java/dev/dsf/bpe/mail/ErrorMailService.java index 895f3b4..4e4c2aa 100644 --- a/src/main/java/dev/dsf/bpe/mail/ErrorMailService.java +++ b/src/main/java/dev/dsf/bpe/mail/ErrorMailService.java @@ -1,22 +1,14 @@ package dev.dsf.bpe.mail; -import java.util.Collections; -import java.util.Map; import java.util.Objects; -import org.hl7.fhir.r4.model.Bundle; -import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; -import org.hl7.fhir.r4.model.Endpoint; import org.hl7.fhir.r4.model.IdType; -import org.hl7.fhir.r4.model.Identifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; -import dev.dsf.bpe.ConstantsBase; -import dev.dsf.bpe.service.MailService; -import dev.dsf.fhir.client.FhirWebserviceClientProvider; -import dev.dsf.fhir.variables.Target; +import dev.dsf.bpe.v1.ProcessPluginApi; +import dev.dsf.bpe.v1.variables.Target; public class ErrorMailService implements InitializingBean { @@ -26,21 +18,14 @@ public class ErrorMailService implements InitializingBean private static final String SUBJECT_PING_PROCESS_FAILED = "Ping Process Failed"; private static final String SUBJECT_PONG_PROCESS_FAILED = "Pong Process Failed"; - private final String localOrganizationIdentifierValue; - - private final MailService mailService; - private final FhirWebserviceClientProvider clientProvider; + private final ProcessPluginApi api; private final boolean sendPingProcessFailedMail; private final boolean sendPongProcessFailedMail; - public ErrorMailService(MailService mailService, FhirWebserviceClientProvider clientProvider, - String localOrganizationIdentifierValue, boolean sendPingProcessFailedMail, - boolean sendPongProcessFailedMail) + public ErrorMailService(ProcessPluginApi api, boolean sendPingProcessFailedMail, boolean sendPongProcessFailedMail) { - this.mailService = mailService; - this.clientProvider = clientProvider; - this.localOrganizationIdentifierValue = localOrganizationIdentifierValue; + this.api = api; this.sendPingProcessFailedMail = sendPingProcessFailedMail; this.sendPongProcessFailedMail = sendPongProcessFailedMail; @@ -49,33 +34,16 @@ public ErrorMailService(MailService mailService, FhirWebserviceClientProvider cl @Override public void afterPropertiesSet() throws Exception { - Objects.requireNonNull(mailService, "mailService"); - Objects.requireNonNull(clientProvider, "clientProvider"); - Objects.requireNonNull(localOrganizationIdentifierValue, "localOrganizationIdentifierValue"); - } - - private String localEndpointIdentifierValue() - { - Bundle result = clientProvider.getLocalWebserviceClient().searchWithStrictHandling(Endpoint.class, - Map.of("address", Collections.singletonList(clientProvider.getLocalBaseUrl()))); - - if (result.getTotal() != 1) - return "?"; - - return result.getEntry().stream().filter(BundleEntryComponent::hasResource) - .map(BundleEntryComponent::getResource).filter(r -> r instanceof Endpoint).map(r -> (Endpoint) r) - .findFirst().stream().flatMap(e -> e.getIdentifier().stream()) - .filter(i -> ConstantsBase.NAMINGSYSTEM_DSF_ENDPOINT_IDENTIFIER.equals(i.getSystem())).findFirst() - .map(Identifier::getValue).orElse("?"); + Objects.requireNonNull(api, "api"); } private String createMessage(Target target, String message, String messageDetails, IdType taskId) { StringBuilder b = new StringBuilder(); - b.append(localOrganizationIdentifierValue); + b.append(api.getOrganizationProvider().getLocalOrganizationIdentifierValue()); b.append('/'); - b.append(localEndpointIdentifierValue()); + b.append(api.getEndpointProvider().getLocalEndpointIdentifierValue().orElse("?")); b.append(" -> "); @@ -93,7 +61,8 @@ private String createMessage(Target target, String message, String messageDetail } b.append("\n\nProcess started by: "); - b.append(taskId.toVersionless().withServerBase(clientProvider.getLocalBaseUrl(), "Task").getValue()); + b.append(taskId.toVersionless().withServerBase(api.getEndpointProvider().getLocalEndpointAddress(), "Task") + .getValue()); return b.toString(); } @@ -105,7 +74,7 @@ public void pongMessageNotReceived(IdType taskId, Target target) if (sendPingProcessFailedMail) { - mailService.send(SUBJECT_PING_PROCESS_FAILED, + api.getMailService().send(SUBJECT_PING_PROCESS_FAILED, createMessage(target, "No pong message received", null, taskId)); } } @@ -117,7 +86,7 @@ public void endpointNotReachableForPing(IdType taskId, Target target, String err if (sendPingProcessFailedMail) { - mailService.send(SUBJECT_PING_PROCESS_FAILED, + api.getMailService().send(SUBJECT_PING_PROCESS_FAILED, createMessage(target, "Not reachable with ping", errorMessage, taskId)); } } @@ -129,7 +98,7 @@ public void endpointReachablePingForbidden(IdType taskId, Target target, String if (sendPongProcessFailedMail) { - mailService.send(SUBJECT_PING_PROCESS_FAILED, + api.getMailService().send(SUBJECT_PING_PROCESS_FAILED, createMessage(target, "Ping forbidden", errorMessage, taskId)); } } @@ -141,7 +110,7 @@ public void endpointNotReachableForPong(IdType taskId, Target target, String err if (sendPongProcessFailedMail) { - mailService.send(SUBJECT_PONG_PROCESS_FAILED, + api.getMailService().send(SUBJECT_PONG_PROCESS_FAILED, createMessage(target, "Not reachable with pong", errorMessage, taskId)); } } @@ -153,7 +122,7 @@ public void endpointReachablePongForbidden(IdType taskId, Target target, String if (sendPongProcessFailedMail) { - mailService.send(SUBJECT_PONG_PROCESS_FAILED, + api.getMailService().send(SUBJECT_PONG_PROCESS_FAILED, createMessage(target, "Pong forbidden", errorMessage, taskId)); } } diff --git a/src/main/java/dev/dsf/bpe/message/SendPing.java b/src/main/java/dev/dsf/bpe/message/SendPing.java index 184fe2c..f581455 100644 --- a/src/main/java/dev/dsf/bpe/message/SendPing.java +++ b/src/main/java/dev/dsf/bpe/message/SendPing.java @@ -1,47 +1,36 @@ package dev.dsf.bpe.message; -import java.util.Collections; -import java.util.Map; import java.util.Objects; import java.util.stream.Stream; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.hl7.fhir.r4.model.Bundle; -import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; -import org.hl7.fhir.r4.model.Endpoint; import org.hl7.fhir.r4.model.Identifier; import org.hl7.fhir.r4.model.Reference; import org.hl7.fhir.r4.model.ResourceType; import org.hl7.fhir.r4.model.Task; import org.hl7.fhir.r4.model.Task.ParameterComponent; -import ca.uhn.fhir.context.FhirContext; -import dev.dsf.bpe.ConstantsBase; import dev.dsf.bpe.ConstantsPing; import dev.dsf.bpe.mail.ErrorMailService; import dev.dsf.bpe.util.PingStatusGenerator; -import dev.dsf.fhir.authorization.read.ReadAccessHelper; -import dev.dsf.fhir.client.FhirWebserviceClientProvider; -import dev.dsf.fhir.organization.OrganizationProvider; -import dev.dsf.fhir.task.AbstractTaskMessageSend; -import dev.dsf.fhir.task.TaskHelper; -import dev.dsf.fhir.variables.Target; +import dev.dsf.bpe.v1.ProcessPluginApi; +import dev.dsf.bpe.v1.activity.AbstractTaskMessageSend; +import dev.dsf.bpe.v1.variables.Target; +import dev.dsf.bpe.v1.variables.Variables; import jakarta.ws.rs.WebApplicationException; import jakarta.ws.rs.core.Response; public class SendPing extends AbstractTaskMessageSend { private final PingStatusGenerator statusGenerator; - private final ErrorMailService errorLogger; + private final ErrorMailService errorMailService; - public SendPing(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider, FhirContext fhirContext, - PingStatusGenerator statusGenerator, ErrorMailService errorLogger) + public SendPing(ProcessPluginApi api, PingStatusGenerator statusGenerator, ErrorMailService errorMailService) { - super(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); + super(api); this.statusGenerator = statusGenerator; - this.errorLogger = errorLogger; + this.errorMailService = errorMailService; } @Override @@ -50,24 +39,25 @@ public void afterPropertiesSet() throws Exception super.afterPropertiesSet(); Objects.requireNonNull(statusGenerator, "statusGenerator"); - Objects.requireNonNull(errorLogger, "errorLogger"); + Objects.requireNonNull(errorMailService, "errorMailService"); } @Override - protected Stream getAdditionalInputParameters(DelegateExecution execution) + protected Stream getAdditionalInputParameters(DelegateExecution execution, Variables variables) { - return Stream.of(getTaskHelper().createInput(ConstantsPing.CODESYSTEM_DSF_PING, + return Stream.of(api.getTaskHelper().createInput(ConstantsPing.CODESYSTEM_DSF_PING, ConstantsPing.CODESYSTEM_DSF_PING_VALUE_ENDPOINT_IDENTIFIER, new Reference().setIdentifier(getLocalEndpointIdentifier()).setType(ResourceType.Endpoint.name()))); } @Override - protected void handleSendTaskError(DelegateExecution execution, Exception exception, String errorMessage) + protected void handleSendTaskError(DelegateExecution execution, Variables variables, Exception exception, + String errorMessage) { - Target target = getTarget(execution); - Task task = getLeadingTaskFromExecutionVariables(execution); + Target target = variables.getTarget(); + Task mainTask = variables.getMainTask(); - if (task != null) + if (mainTask != null) { String statusCode = ConstantsPing.CODESYSTEM_DSF_PING_STATUS_VALUE_NOT_REACHABLE; if (exception instanceof WebApplicationException webApplicationException) @@ -81,16 +71,16 @@ protected void handleSendTaskError(DelegateExecution execution, Exception except String specialErrorMessage = createErrorMessage(exception); - task.addOutput(statusGenerator.createPingStatusOutput(target, statusCode, specialErrorMessage)); - updateLeadingTaskInExecutionVariables(execution, task); + mainTask.addOutput(statusGenerator.createPingStatusOutput(target, statusCode, specialErrorMessage)); + variables.updateTask(mainTask); if (ConstantsPing.CODESYSTEM_DSF_PING_STATUS_VALUE_NOT_REACHABLE.equals(statusCode)) - errorLogger.endpointNotReachableForPing(task.getIdElement(), target, specialErrorMessage); + errorMailService.endpointNotReachableForPing(mainTask.getIdElement(), target, specialErrorMessage); else if (ConstantsPing.CODESYSTEM_DSF_PING_STATUS_VALUE_NOT_ALLOWED.equals(statusCode)) - errorLogger.endpointReachablePingForbidden(task.getIdElement(), target, specialErrorMessage); + errorMailService.endpointReachablePingForbidden(mainTask.getIdElement(), target, specialErrorMessage); } - super.handleSendTaskError(execution, exception, errorMessage); + super.handleSendTaskError(execution, variables, exception, errorMessage); } @Override @@ -109,15 +99,7 @@ private String createErrorMessage(Exception exception) private Identifier getLocalEndpointIdentifier() { - Bundle bundle = getFhirWebserviceClientProvider().getLocalWebserviceClient().search(Endpoint.class, - Map.of("address", Collections.singletonList(getFhirWebserviceClientProvider().getLocalBaseUrl()))); - return bundle.getEntry().stream().filter(BundleEntryComponent::hasResource) - .filter(e -> e.getResource() instanceof Endpoint).map(e -> (Endpoint) e.getResource()).findFirst() - .filter(e -> e.hasIdentifier()) - .flatMap(e -> e.getIdentifier().stream() - .filter(i -> ConstantsBase.NAMINGSYSTEM_DSF_ENDPOINT_IDENTIFIER.equals(i.getSystem())) - .findFirst()) - .orElseThrow(() -> new IllegalStateException("No Identifier for Endpoint or Endpoint with address " - + getFhirWebserviceClientProvider().getLocalBaseUrl() + " found")); + return api.getEndpointProvider().getLocalEndpointIdentifier() + .orElseThrow(() -> new IllegalStateException("Local endpoint identifier unknown")); } } diff --git a/src/main/java/dev/dsf/bpe/message/SendPong.java b/src/main/java/dev/dsf/bpe/message/SendPong.java index 2b3fed7..a56717c 100644 --- a/src/main/java/dev/dsf/bpe/message/SendPong.java +++ b/src/main/java/dev/dsf/bpe/message/SendPong.java @@ -5,32 +5,27 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.hl7.fhir.r4.model.Task; -import ca.uhn.fhir.context.FhirContext; import dev.dsf.bpe.ConstantsPing; import dev.dsf.bpe.mail.ErrorMailService; import dev.dsf.bpe.util.PingStatusGenerator; -import dev.dsf.fhir.authorization.read.ReadAccessHelper; -import dev.dsf.fhir.client.FhirWebserviceClientProvider; -import dev.dsf.fhir.organization.OrganizationProvider; -import dev.dsf.fhir.task.AbstractTaskMessageSend; -import dev.dsf.fhir.task.TaskHelper; -import dev.dsf.fhir.variables.Target; +import dev.dsf.bpe.v1.ProcessPluginApi; +import dev.dsf.bpe.v1.activity.AbstractTaskMessageSend; +import dev.dsf.bpe.v1.variables.Target; +import dev.dsf.bpe.v1.variables.Variables; import jakarta.ws.rs.WebApplicationException; import jakarta.ws.rs.core.Response; public class SendPong extends AbstractTaskMessageSend { private final PingStatusGenerator statusGenerator; - private final ErrorMailService errorLogger; + private final ErrorMailService errorMailService; - public SendPong(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider, FhirContext fhirContext, - PingStatusGenerator statusGenerator, ErrorMailService errorLogger) + public SendPong(ProcessPluginApi api, PingStatusGenerator statusGenerator, ErrorMailService errorMailService) { - super(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); + super(api); this.statusGenerator = statusGenerator; - this.errorLogger = errorLogger; + this.errorMailService = errorMailService; } @Override @@ -39,28 +34,29 @@ public void afterPropertiesSet() throws Exception super.afterPropertiesSet(); Objects.requireNonNull(statusGenerator, "statusGenerator"); - Objects.requireNonNull(errorLogger, "errorLogger"); + Objects.requireNonNull(errorMailService, "errorMailService"); } @Override - public void doExecute(DelegateExecution execution) throws Exception + protected void doExecute(DelegateExecution execution, Variables variables) throws Exception { - super.doExecute(execution); + super.doExecute(execution, variables); - Target target = getTarget(execution); - Task task = getLeadingTaskFromExecutionVariables(execution); - task.addOutput(statusGenerator.createPongStatusOutput(target, + Target target = variables.getTarget(); + Task mainTask = variables.getMainTask(); + mainTask.addOutput(statusGenerator.createPongStatusOutput(target, ConstantsPing.CODESYSTEM_DSF_PING_STATUS_VALUE_PONG_SEND)); - updateLeadingTaskInExecutionVariables(execution, task); + variables.updateTask(mainTask); } @Override - protected void handleEndEventError(DelegateExecution execution, Exception exception, String errorMessage) + protected void handleEndEventError(DelegateExecution execution, Variables variables, Exception exception, + String errorMessage) { - Target target = getTarget(execution); - Task task = getLeadingTaskFromExecutionVariables(execution); + Target target = variables.getTarget(); + Task mainTask = variables.getMainTask(); - if (task != null) + if (mainTask != null) { String statusCode = ConstantsPing.CODESYSTEM_DSF_PING_STATUS_VALUE_NOT_REACHABLE; if (exception instanceof WebApplicationException) @@ -75,16 +71,16 @@ protected void handleEndEventError(DelegateExecution execution, Exception except String specialErrorMessage = createErrorMessage(exception); - task.addOutput(statusGenerator.createPongStatusOutput(target, statusCode, specialErrorMessage)); - updateLeadingTaskInExecutionVariables(execution, task); + mainTask.addOutput(statusGenerator.createPongStatusOutput(target, statusCode, specialErrorMessage)); + variables.updateTask(mainTask); if (ConstantsPing.CODESYSTEM_DSF_PING_STATUS_VALUE_NOT_REACHABLE.equals(statusCode)) - errorLogger.endpointNotReachableForPong(task.getIdElement(), target, specialErrorMessage); + errorMailService.endpointNotReachableForPong(mainTask.getIdElement(), target, specialErrorMessage); else if (ConstantsPing.CODESYSTEM_DSF_PING_STATUS_VALUE_NOT_ALLOWED.equals(statusCode)) - errorLogger.endpointReachablePongForbidden(task.getIdElement(), target, specialErrorMessage); + errorMailService.endpointReachablePongForbidden(mainTask.getIdElement(), target, specialErrorMessage); } - super.handleEndEventError(execution, exception, errorMessage); + super.handleEndEventError(execution, variables, exception, errorMessage); } private String createErrorMessage(Exception exception) diff --git a/src/main/java/dev/dsf/bpe/message/SendStartPing.java b/src/main/java/dev/dsf/bpe/message/SendStartPing.java index b2dd4ee..52ae765 100644 --- a/src/main/java/dev/dsf/bpe/message/SendStartPing.java +++ b/src/main/java/dev/dsf/bpe/message/SendStartPing.java @@ -4,28 +4,24 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.hl7.fhir.r4.model.Task; +import org.hl7.fhir.r4.model.Task.ParameterComponent; -import ca.uhn.fhir.context.FhirContext; import dev.dsf.bpe.ConstantsPing; -import dev.dsf.fhir.authorization.read.ReadAccessHelper; -import dev.dsf.fhir.client.FhirWebserviceClientProvider; -import dev.dsf.fhir.organization.OrganizationProvider; -import dev.dsf.fhir.task.AbstractTaskMessageSend; -import dev.dsf.fhir.task.TaskHelper; +import dev.dsf.bpe.v1.ProcessPluginApi; +import dev.dsf.bpe.v1.activity.AbstractTaskMessageSend; +import dev.dsf.bpe.v1.variables.Variables; public class SendStartPing extends AbstractTaskMessageSend { - public SendStartPing(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider, FhirContext fhirContext) + public SendStartPing(ProcessPluginApi api) { - super(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); + super(api); } @Override - protected Stream getAdditionalInputParameters(DelegateExecution execution) + protected Stream getAdditionalInputParameters(DelegateExecution execution, Variables variables) { - return getLeadingTaskFromExecutionVariables(execution).getInput().stream() - .filter(Task.ParameterComponent::hasType) + return variables.getMainTask().getInput().stream().filter(Task.ParameterComponent::hasType) .filter(i -> i.getType().getCoding().stream() .anyMatch(c -> ConstantsPing.CODESYSTEM_DSF_PING.equals(c.getSystem()) && ConstantsPing.CODESYSTEM_DSF_PING_VALUE_TARGET_ENDPOINTS.equals(c.getCode()))); diff --git a/src/main/java/dev/dsf/bpe/service/LogNoResponse.java b/src/main/java/dev/dsf/bpe/service/LogNoResponse.java index 29c2472..68b7305 100644 --- a/src/main/java/dev/dsf/bpe/service/LogNoResponse.java +++ b/src/main/java/dev/dsf/bpe/service/LogNoResponse.java @@ -2,37 +2,34 @@ import java.util.Objects; +import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.hl7.fhir.r4.model.Task; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import dev.dsf.bpe.ConstantsBase; import dev.dsf.bpe.ConstantsPing; -import dev.dsf.bpe.delegate.AbstractServiceDelegate; import dev.dsf.bpe.mail.ErrorMailService; import dev.dsf.bpe.util.PingStatusGenerator; -import dev.dsf.fhir.authorization.read.ReadAccessHelper; -import dev.dsf.fhir.client.FhirWebserviceClientProvider; -import dev.dsf.fhir.task.TaskHelper; -import dev.dsf.fhir.variables.FhirResourceValues; -import dev.dsf.fhir.variables.Target; -import dev.dsf.fhir.variables.Targets; +import dev.dsf.bpe.v1.ProcessPluginApi; +import dev.dsf.bpe.v1.activity.AbstractServiceDelegate; +import dev.dsf.bpe.v1.variables.Target; +import dev.dsf.bpe.v1.variables.Targets; +import dev.dsf.bpe.v1.variables.Variables; public class LogNoResponse extends AbstractServiceDelegate { private static final Logger logger = LoggerFactory.getLogger(LogNoResponse.class); private final PingStatusGenerator responseGenerator; - private final ErrorMailService errorLogger; + private final ErrorMailService errorMailService; - public LogNoResponse(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - ReadAccessHelper readAccessHelper, PingStatusGenerator responseGenerator, ErrorMailService errorLogger) + public LogNoResponse(ProcessPluginApi api, PingStatusGenerator responseGenerator, ErrorMailService errorMailService) { - super(clientProvider, taskHelper, readAccessHelper); + super(api); this.responseGenerator = responseGenerator; - this.errorLogger = errorLogger; + this.errorMailService = errorMailService; } @Override @@ -41,18 +38,19 @@ public void afterPropertiesSet() throws Exception super.afterPropertiesSet(); Objects.requireNonNull(responseGenerator, "responseGenerator"); - Objects.requireNonNull(errorLogger, "errorLogger"); + Objects.requireNonNull(errorMailService, "errorLogger"); } + @Override - public void doExecute(DelegateExecution execution) throws Exception + protected void doExecute(DelegateExecution execution, Variables variables) throws BpmnError, Exception { - Task task = getLeadingTaskFromExecutionVariables(execution); + Task mainTask = variables.getMainTask(); - Targets targets = (Targets) execution.getVariable(ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGETS); - targets.getEntries().forEach(t -> logAndAddResponseToTask(task, t)); + Targets targets = variables.getTargets(); + targets.getEntries().forEach(t -> logAndAddResponseToTask(mainTask, t)); - execution.setVariable(ConstantsBase.BPMN_EXECUTION_VARIABLE_LEADING_TASK, FhirResourceValues.create(task)); + variables.updateTask(mainTask); } private void logAndAddResponseToTask(Task task, Target target) @@ -62,6 +60,6 @@ private void logAndAddResponseToTask(Task task, Target target) task.addOutput(responseGenerator.createPingStatusOutput(target, ConstantsPing.CODESYSTEM_DSF_PING_STATUS_VALUE_PONG_MISSING)); - errorLogger.pongMessageNotReceived(task.getIdElement(), target); + errorMailService.pongMessageNotReceived(task.getIdElement(), target); } } diff --git a/src/main/java/dev/dsf/bpe/service/LogPing.java b/src/main/java/dev/dsf/bpe/service/LogPing.java index 66cf4c6..86be63f 100644 --- a/src/main/java/dev/dsf/bpe/service/LogPing.java +++ b/src/main/java/dev/dsf/bpe/service/LogPing.java @@ -1,5 +1,6 @@ package dev.dsf.bpe.service; +import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.hl7.fhir.r4.model.Identifier; import org.hl7.fhir.r4.model.Reference; @@ -8,25 +9,23 @@ import org.slf4j.LoggerFactory; import dev.dsf.bpe.ConstantsPing; -import dev.dsf.bpe.delegate.AbstractServiceDelegate; -import dev.dsf.fhir.authorization.read.ReadAccessHelper; -import dev.dsf.fhir.client.FhirWebserviceClientProvider; -import dev.dsf.fhir.task.TaskHelper; +import dev.dsf.bpe.v1.ProcessPluginApi; +import dev.dsf.bpe.v1.activity.AbstractServiceDelegate; +import dev.dsf.bpe.v1.variables.Variables; public class LogPing extends AbstractServiceDelegate { private static final Logger logger = LoggerFactory.getLogger(LogPing.class); - public LogPing(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - ReadAccessHelper readAccessHelper) + public LogPing(ProcessPluginApi api) { - super(clientProvider, taskHelper, readAccessHelper); + super(api); } @Override - public void doExecute(DelegateExecution execution) throws Exception + protected void doExecute(DelegateExecution execution, Variables variables) throws BpmnError, Exception { - Task task = getCurrentTaskFromExecutionVariables(execution); + Task task = variables.getLatestTask(); logger.info("PING from {} (endpoint: {})", task.getRequester().getIdentifier().getValue(), getEndpointIdentifierValue(task)); @@ -34,7 +33,7 @@ public void doExecute(DelegateExecution execution) throws Exception private String getEndpointIdentifierValue(Task task) { - return getTaskHelper() + return api.getTaskHelper() .getFirstInputParameterReferenceValue(task, ConstantsPing.CODESYSTEM_DSF_PING, ConstantsPing.CODESYSTEM_DSF_PING_VALUE_ENDPOINT_IDENTIFIER) .map(Reference::getIdentifier).map(Identifier::getValue).get(); diff --git a/src/main/java/dev/dsf/bpe/service/LogPong.java b/src/main/java/dev/dsf/bpe/service/LogPong.java index 9ab3da3..e1381e8 100644 --- a/src/main/java/dev/dsf/bpe/service/LogPong.java +++ b/src/main/java/dev/dsf/bpe/service/LogPong.java @@ -2,21 +2,19 @@ import java.util.Objects; +import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.hl7.fhir.r4.model.Task; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import dev.dsf.bpe.ConstantsBase; import dev.dsf.bpe.ConstantsPing; -import dev.dsf.bpe.delegate.AbstractServiceDelegate; import dev.dsf.bpe.util.PingStatusGenerator; -import dev.dsf.fhir.authorization.read.ReadAccessHelper; -import dev.dsf.fhir.client.FhirWebserviceClientProvider; -import dev.dsf.fhir.task.TaskHelper; -import dev.dsf.fhir.variables.Target; -import dev.dsf.fhir.variables.Targets; -import dev.dsf.fhir.variables.TargetsValues; +import dev.dsf.bpe.v1.ProcessPluginApi; +import dev.dsf.bpe.v1.activity.AbstractServiceDelegate; +import dev.dsf.bpe.v1.variables.Target; +import dev.dsf.bpe.v1.variables.Targets; +import dev.dsf.bpe.v1.variables.Variables; public class LogPong extends AbstractServiceDelegate { @@ -24,10 +22,9 @@ public class LogPong extends AbstractServiceDelegate private final PingStatusGenerator responseGenerator; - public LogPong(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - ReadAccessHelper readAccessHelper, PingStatusGenerator responseGenerator) + public LogPong(ProcessPluginApi api, PingStatusGenerator responseGenerator) { - super(clientProvider, taskHelper, readAccessHelper); + super(api); this.responseGenerator = responseGenerator; } @@ -40,26 +37,22 @@ public void afterPropertiesSet() throws Exception Objects.requireNonNull(responseGenerator, "responseGenerator"); } + @Override - public void doExecute(DelegateExecution execution) + protected void doExecute(DelegateExecution execution, Variables variables) throws BpmnError, Exception { - Target target = getTarget(execution); + Target target = variables.getTarget(); logger.info("PONG from {} (endpoint: {})", target.getOrganizationIdentifierValue(), target.getEndpointIdentifierValue()); - Task leading = getLeadingTaskFromExecutionVariables(execution); - leading.addOutput(responseGenerator.createPingStatusOutput(target, + Task mainTask = variables.getMainTask(); + mainTask.addOutput(responseGenerator.createPingStatusOutput(target, ConstantsPing.CODESYSTEM_DSF_PING_STATUS_VALUE_PONG_RECEIVED)); - updateLeadingTaskInExecutionVariables(execution, leading); + variables.updateTask(mainTask); - Targets targets = (Targets) execution.getVariable(ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGETS); + Targets targets = variables.getTargets(); targets = targets.removeByEndpointIdentifierValue(target.getEndpointIdentifierValue()); - execution.setVariable(ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGETS, TargetsValues.create(targets)); - } - - private Target getTarget(DelegateExecution execution) - { - return (Target) execution.getVariable(ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGET); + variables.setTargets(targets); } } diff --git a/src/main/java/dev/dsf/bpe/service/SelectPingTargets.java b/src/main/java/dev/dsf/bpe/service/SelectPingTargets.java index d3561a5..732358e 100644 --- a/src/main/java/dev/dsf/bpe/service/SelectPingTargets.java +++ b/src/main/java/dev/dsf/bpe/service/SelectPingTargets.java @@ -12,6 +12,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; @@ -27,16 +28,13 @@ import org.springframework.web.util.UriComponents; import org.springframework.web.util.UriComponentsBuilder; -import dev.dsf.bpe.ConstantsBase; import dev.dsf.bpe.ConstantsPing; -import dev.dsf.bpe.delegate.AbstractServiceDelegate; -import dev.dsf.fhir.authorization.read.ReadAccessHelper; -import dev.dsf.fhir.client.FhirWebserviceClientProvider; -import dev.dsf.fhir.organization.OrganizationProvider; -import dev.dsf.fhir.task.TaskHelper; -import dev.dsf.fhir.variables.Target; -import dev.dsf.fhir.variables.Targets; -import dev.dsf.fhir.variables.TargetsValues; +import dev.dsf.bpe.v1.ProcessPluginApi; +import dev.dsf.bpe.v1.activity.AbstractServiceDelegate; +import dev.dsf.bpe.v1.constants.NamingSystems.EndpointIdentifier; +import dev.dsf.bpe.v1.constants.NamingSystems.OrganizationIdentifier; +import dev.dsf.bpe.v1.variables.Target; +import dev.dsf.bpe.v1.variables.Variables; public class SelectPingTargets extends AbstractServiceDelegate implements InitializingBean { @@ -45,34 +43,20 @@ public class SelectPingTargets extends AbstractServiceDelegate implements Initia private static final Pattern endpointResouceTypes = Pattern.compile( "Endpoint|HealthcareService|ImagingStudy|InsurancePlan|Location|Organization|OrganizationAffiliation|PractitionerRole"); - private final OrganizationProvider organizationProvider; - - public SelectPingTargets(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider) + public SelectPingTargets(ProcessPluginApi api) { - super(clientProvider, taskHelper, readAccessHelper); - - this.organizationProvider = organizationProvider; + super(api); } @Override - public void afterPropertiesSet() throws Exception + protected void doExecute(DelegateExecution execution, Variables variables) throws BpmnError, Exception { - super.afterPropertiesSet(); - - Objects.requireNonNull(organizationProvider, "organizationProvider"); - } - - @Override - public void doExecute(DelegateExecution execution) throws Exception - { - Stream targetEndpoints = getTargetEndpointsSearchParameter(execution).map(this::searchForEndpoints) + Stream targetEndpoints = getTargetEndpointsSearchParameter(variables).map(this::searchForEndpoints) .orElse(allEndpointsNotLocal()); - Map organizationIdentifierByOrganizationId = getAllActiveOrganizations() - .collect(Collectors.toMap(o -> o.getIdElement().getIdPart(), o -> o.getIdentifier().stream() - .filter(i -> ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER.equals(i.getSystem())) - .findFirst().get())); + List remoteOrganizations = api.getOrganizationProvider().getRemoteOrganizations(); + Map organizationIdentifierByOrganizationId = remoteOrganizations.stream().collect( + Collectors.toMap(o -> o.getIdElement().getIdPart(), o -> OrganizationIdentifier.findFirst(o).get())); Stream remoteTargetEndpointsWithActiveOrganization = targetEndpoints .filter(e -> getOrganizationIdentifier(e, organizationIdentifierByOrganizationId).isPresent()); @@ -80,21 +64,21 @@ public void doExecute(DelegateExecution execution) throws Exception List targets = remoteTargetEndpointsWithActiveOrganization.map(e -> { String organizationIdentifier = getOrganizationIdentifier(e, organizationIdentifierByOrganizationId).get(); - String endpointIdentifier = getEndpointIdentifier(e).get(); - String endpointAddress = getEndpointAddress(e).get(); - return Target.createBiDirectionalTarget(organizationIdentifier, endpointIdentifier, endpointAddress, + String endpointIdentifier = EndpointIdentifier.findFirst(e).map(Identifier::getValue).get(); + String endpointAddress = e.getAddress(); + + return variables.createBiDirectionalTarget(organizationIdentifier, endpointIdentifier, endpointAddress, UUID.randomUUID().toString()); }).collect(Collectors.toList()); - execution.setVariable(ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGETS, - TargetsValues.create(new Targets(targets))); + variables.setTargets(variables.createTargets(targets)); } - private Optional getTargetEndpointsSearchParameter(DelegateExecution execution) + private Optional getTargetEndpointsSearchParameter(Variables variables) { - Task task = getLeadingTaskFromExecutionVariables(execution); - return getTaskHelper() - .getFirstInputParameterStringValue(task, ConstantsPing.CODESYSTEM_DSF_PING, + Task mainTask = variables.getMainTask(); + return api.getTaskHelper() + .getFirstInputParameterStringValue(mainTask, ConstantsPing.CODESYSTEM_DSF_PING, ConstantsPing.CODESYSTEM_DSF_PING_VALUE_TARGET_ENDPOINTS) .map(requestUrl -> UriComponentsBuilder.fromUriString(requestUrl).build()); } @@ -117,7 +101,7 @@ private Stream searchForEndpoints(UriComponents searchParameters, int queryParameters.putAll(searchParameters.getQueryParams()); queryParameters.put("_page", Collections.singletonList(String.valueOf(page))); - Bundle searchResult = getFhirWebserviceClientProvider().getLocalWebserviceClient() + Bundle searchResult = api.getFhirWebserviceClientProvider().getLocalWebserviceClient() .searchWithStrictHandling(resourceType.get(), queryParameters); if (searchResult.getTotal() > currentTotal + searchResult.getEntry().size()) @@ -155,12 +139,12 @@ private Stream allEndpointsNotLocal() private Predicate isLocalEndpoint() { - return e -> Objects.equals(getFhirWebserviceClientProvider().getLocalBaseUrl(), e.getAddress()); + return e -> Objects.equals(api.getEndpointProvider().getLocalEndpointAddress(), e.getAddress()); } private Stream allEndpoints(int page, int currentTotal) { - Bundle searchResult = getFhirWebserviceClientProvider().getLocalWebserviceClient() + Bundle searchResult = api.getFhirWebserviceClientProvider().getLocalWebserviceClient() .searchWithStrictHandling(Endpoint.class, Map.of("status", Collections.singletonList("active"), "_page", Collections.singletonList(String.valueOf(page)))); @@ -191,46 +175,4 @@ private Optional getOrganizationIdentifier(Endpoint endpoint, .get(endpoint.getManagingOrganization().getReferenceElement().getIdPart())) .map(Identifier::getValue); } - - private Optional getEndpointIdentifier(Endpoint endpoint) - { - return endpoint.getIdentifier().stream() - .filter(i -> ConstantsBase.NAMINGSYSTEM_DSF_ENDPOINT_IDENTIFIER.equals(i.getSystem())).findFirst() - .map(Identifier::getValue); - } - - private Optional getEndpointAddress(Endpoint endpoint) - { - return endpoint.hasAddress() ? Optional.of(endpoint.getAddress()) : Optional.empty(); - } - - private Stream getAllActiveOrganizations() - { - return getActiveOrganizations(1, 0); - } - - private Stream getActiveOrganizations(int page, int currentTotal) - { - Map> queryParameters = new HashMap>(); - queryParameters.put("active", Collections.singletonList("true")); - queryParameters.put("_page", Collections.singletonList(String.valueOf(page))); - - Bundle searchResult = getFhirWebserviceClientProvider().getLocalWebserviceClient() - .searchWithStrictHandling(Organization.class, queryParameters); - - if (searchResult.getTotal() > currentTotal + searchResult.getEntry().size()) - return Stream.concat(toOrganization(searchResult), - getActiveOrganizations(page + 1, currentTotal + searchResult.getEntry().size())); - else - return toOrganization(searchResult); - } - - private Stream toOrganization(Bundle searchResult) - { - Objects.requireNonNull(searchResult, "searchResult"); - - return searchResult.getEntry().stream().filter(BundleEntryComponent::hasResource) - .filter(e -> e.getResource() instanceof Organization).map(e -> (Organization) e.getResource()) - .filter(e -> e.getActive()); - } -} +} \ No newline at end of file diff --git a/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java b/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java index 0465b69..c9c411e 100644 --- a/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java +++ b/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java @@ -1,7 +1,5 @@ package dev.dsf.bpe.service; -import java.util.Objects; - import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.hl7.fhir.r4.model.Identifier; @@ -11,49 +9,32 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; -import dev.dsf.bpe.ConstantsBase; import dev.dsf.bpe.ConstantsPing; -import dev.dsf.bpe.delegate.AbstractServiceDelegate; -import dev.dsf.fhir.authorization.read.ReadAccessHelper; -import dev.dsf.fhir.client.FhirWebserviceClientProvider; -import dev.dsf.fhir.organization.EndpointProvider; -import dev.dsf.fhir.task.TaskHelper; -import dev.dsf.fhir.variables.Target; -import dev.dsf.fhir.variables.TargetValues; +import dev.dsf.bpe.v1.ProcessPluginApi; +import dev.dsf.bpe.v1.activity.AbstractServiceDelegate; +import dev.dsf.bpe.v1.constants.CodeSystems.BpmnMessage; +import dev.dsf.bpe.v1.variables.Variables; public class SelectPongTarget extends AbstractServiceDelegate implements InitializingBean { private static final Logger logger = LoggerFactory.getLogger(SelectPongTarget.class); - private final EndpointProvider endpointProvider; - - public SelectPongTarget(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - ReadAccessHelper readAccessHelper, EndpointProvider endpointProvider) - { - super(clientProvider, taskHelper, readAccessHelper); - - this.endpointProvider = endpointProvider; - } - - @Override - public void afterPropertiesSet() throws Exception + public SelectPongTarget(ProcessPluginApi api) { - super.afterPropertiesSet(); - - Objects.requireNonNull(endpointProvider, "endpointProvider"); + super(api); } @Override - public void doExecute(DelegateExecution execution) throws Exception + protected void doExecute(DelegateExecution execution, Variables variables) throws BpmnError, Exception { - Task task = getCurrentTaskFromExecutionVariables(execution); + Task task = variables.getMainTask(); - String correlationKey = getTaskHelper().getFirstInputParameterStringValue(task, - ConstantsBase.CODESYSTEM_DSF_BPMN, ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_CORRELATION_KEY).get(); + String correlationKey = api.getTaskHelper() + .getFirstInputParameterStringValue(task, BpmnMessage.URL, BpmnMessage.Codes.CORRELATION_KEY).get(); String targetOrganizationIdentifierValue = task.getRequester().getIdentifier().getValue(); String targetEndpointIdentifierValue = getEndpointIdentifierValue(task); - String targetEndpointAddress = endpointProvider.getEndpointAddress(targetEndpointIdentifierValue) + String targetEndpointAddress = api.getEndpointProvider().getEndpointAddress(targetEndpointIdentifierValue) .orElseThrow(() -> { logger.warn( @@ -62,14 +43,13 @@ public void doExecute(DelegateExecution execution) throws Exception return new BpmnError("target_not_allowed"); }); - execution.setVariable(ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGET, - TargetValues.create(Target.createBiDirectionalTarget(targetOrganizationIdentifierValue, - targetEndpointIdentifierValue, targetEndpointAddress, correlationKey))); + variables.setTarget(variables.createBiDirectionalTarget(targetOrganizationIdentifierValue, + targetEndpointIdentifierValue, targetEndpointAddress, correlationKey)); } private String getEndpointIdentifierValue(Task task) { - return getTaskHelper() + return api.getTaskHelper() .getFirstInputParameterReferenceValue(task, ConstantsPing.CODESYSTEM_DSF_PING, ConstantsPing.CODESYSTEM_DSF_PING_VALUE_ENDPOINT_IDENTIFIER) .map(Reference::getIdentifier).map(Identifier::getValue).get(); diff --git a/src/main/java/dev/dsf/bpe/service/SetTargetAndConfigureTimer.java b/src/main/java/dev/dsf/bpe/service/SetTargetAndConfigureTimer.java index e4f50d0..2b67358 100644 --- a/src/main/java/dev/dsf/bpe/service/SetTargetAndConfigureTimer.java +++ b/src/main/java/dev/dsf/bpe/service/SetTargetAndConfigureTimer.java @@ -1,70 +1,43 @@ package dev.dsf.bpe.service; -import java.util.Objects; - import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.variable.Variables; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import dev.dsf.bpe.ConstantsBase; import dev.dsf.bpe.ConstantsPing; -import dev.dsf.bpe.delegate.AbstractServiceDelegate; -import dev.dsf.fhir.authorization.read.ReadAccessHelper; -import dev.dsf.fhir.client.FhirWebserviceClientProvider; -import dev.dsf.fhir.organization.EndpointProvider; -import dev.dsf.fhir.organization.OrganizationProvider; -import dev.dsf.fhir.task.TaskHelper; -import dev.dsf.fhir.variables.Target; -import dev.dsf.fhir.variables.TargetValues; +import dev.dsf.bpe.v1.ProcessPluginApi; +import dev.dsf.bpe.v1.activity.AbstractServiceDelegate; +import dev.dsf.bpe.v1.variables.Variables; public class SetTargetAndConfigureTimer extends AbstractServiceDelegate { private static final Logger logger = LoggerFactory.getLogger(SetTargetAndConfigureTimer.class); - private final OrganizationProvider organizationProvider; - private final EndpointProvider endpointProvider; - - public SetTargetAndConfigureTimer(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper, - ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider, - EndpointProvider endpointProvider) - { - super(clientProvider, taskHelper, readAccessHelper); - - this.organizationProvider = organizationProvider; - this.endpointProvider = endpointProvider; - } - - @Override - public void afterPropertiesSet() throws Exception + public SetTargetAndConfigureTimer(ProcessPluginApi api) { - super.afterPropertiesSet(); - - Objects.requireNonNull(organizationProvider, "organizationProvider"); - Objects.requireNonNull(endpointProvider, "endpointProvider"); + super(api); } @Override - protected void doExecute(DelegateExecution execution) throws BpmnError, Exception + protected void doExecute(DelegateExecution execution, Variables variables) throws BpmnError, Exception { - String timerInterval = getTimerInterval(execution); + String timerInterval = getTimerInterval(variables); logger.debug("Setting variable '{}' to {}", ConstantsPing.BPMN_EXECUTION_VARIABLE_TIMER_INTERVAL, timerInterval); - execution.setVariable(ConstantsPing.BPMN_EXECUTION_VARIABLE_TIMER_INTERVAL, - Variables.stringValue(timerInterval)); - execution.setVariable(ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGET, - TargetValues.create(Target.createUniDirectionalTarget(organizationProvider.getLocalIdentifierValue(), - endpointProvider.getLocalEndpointIdentifier().getValue(), - getFhirWebserviceClientProvider().getLocalBaseUrl()))); + variables.setString(ConstantsPing.BPMN_EXECUTION_VARIABLE_TIMER_INTERVAL, timerInterval); + variables.setTarget(variables.createUniDirectionalTarget( + api.getOrganizationProvider().getLocalOrganizationIdentifierValue().get(), + api.getEndpointProvider().getLocalEndpointIdentifierValue().get(), + api.getEndpointProvider().getLocalEndpointAddress())); } - private String getTimerInterval(DelegateExecution execution) + private String getTimerInterval(Variables variables) { - return getTaskHelper() - .getFirstInputParameterStringValue(getLeadingTaskFromExecutionVariables(execution), - ConstantsPing.CODESYSTEM_DSF_PING, ConstantsPing.CODESYSTEM_DSF_PING_VALUE_TIMER_INTERVAL) + return api.getTaskHelper() + .getFirstInputParameterStringValue(variables.getMainTask(), ConstantsPing.CODESYSTEM_DSF_PING, + ConstantsPing.CODESYSTEM_DSF_PING_VALUE_TIMER_INTERVAL) .orElse(ConstantsPing.TIMER_INTERVAL_DEFAULT_VALUE); } } diff --git a/src/main/java/dev/dsf/bpe/spring/config/PingConfig.java b/src/main/java/dev/dsf/bpe/spring/config/PingConfig.java index 33981f4..5dc096e 100644 --- a/src/main/java/dev/dsf/bpe/spring/config/PingConfig.java +++ b/src/main/java/dev/dsf/bpe/spring/config/PingConfig.java @@ -2,11 +2,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; -import ca.uhn.fhir.context.FhirContext; -import dev.dsf.bpe.documentation.ProcessDocumentation; import dev.dsf.bpe.mail.ErrorMailService; import dev.dsf.bpe.message.SendPing; import dev.dsf.bpe.message.SendPong; @@ -14,40 +14,18 @@ import dev.dsf.bpe.service.LogNoResponse; import dev.dsf.bpe.service.LogPing; import dev.dsf.bpe.service.LogPong; -import dev.dsf.bpe.service.MailService; import dev.dsf.bpe.service.SelectPingTargets; import dev.dsf.bpe.service.SelectPongTarget; import dev.dsf.bpe.service.SetTargetAndConfigureTimer; import dev.dsf.bpe.util.PingStatusGenerator; -import dev.dsf.fhir.authorization.read.ReadAccessHelper; -import dev.dsf.fhir.client.FhirWebserviceClientProvider; -import dev.dsf.fhir.organization.EndpointProvider; -import dev.dsf.fhir.organization.OrganizationProvider; -import dev.dsf.fhir.task.TaskHelper; +import dev.dsf.bpe.v1.ProcessPluginApi; +import dev.dsf.bpe.v1.documentation.ProcessDocumentation; @Configuration public class PingConfig { @Autowired - private FhirWebserviceClientProvider clientProvider; - - @Autowired - private TaskHelper taskHelper; - - @Autowired - private ReadAccessHelper readAccessHelper; - - @Autowired - private OrganizationProvider organizationProvider; - - @Autowired - private EndpointProvider endpointProvider; - - @Autowired - private FhirContext fhirContext; - - @Autowired - private MailService mailService; + private ProcessPluginApi api; @ProcessDocumentation(description = "To enable a mail being send if the ping process fails, set to 'true'. This requires the SMPT mail service client to be configured in the DSF", processNames = "dsfdev_ping") @Value("${dev.dsf.dsf.bpe.ping.mail.onPingProcessFailed:false}") @@ -58,16 +36,17 @@ public class PingConfig boolean sendPongProcessFailedMail; @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public SetTargetAndConfigureTimer setTargetAndConfigureTimer() { - return new SetTargetAndConfigureTimer(clientProvider, taskHelper, readAccessHelper, organizationProvider, - endpointProvider); + return new SetTargetAndConfigureTimer(api); } @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public SendStartPing sendStartPing() { - return new SendStartPing(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext); + return new SendStartPing(api); } @Bean @@ -79,51 +58,55 @@ public PingStatusGenerator responseGenerator() @Bean public ErrorMailService errorLogger() { - return new ErrorMailService(mailService, clientProvider, organizationProvider.getLocalIdentifierValue(), - sendPingProcessFailedMail, sendPongProcessFailedMail); + return new ErrorMailService(api, sendPingProcessFailedMail, sendPongProcessFailedMail); } @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public SendPing sendPing() { - return new SendPing(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext, - responseGenerator(), errorLogger()); + return new SendPing(api, responseGenerator(), errorLogger()); } @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public SendPong sendPong() { - return new SendPong(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext, - responseGenerator(), errorLogger()); + return new SendPong(api, responseGenerator(), errorLogger()); } @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public LogPing logPing() { - return new LogPing(clientProvider, taskHelper, readAccessHelper); + return new LogPing(api); } @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public LogPong logPong() { - return new LogPong(clientProvider, taskHelper, readAccessHelper, responseGenerator()); + return new LogPong(api, responseGenerator()); } @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public LogNoResponse logNoResponse() { - return new LogNoResponse(clientProvider, taskHelper, readAccessHelper, responseGenerator(), errorLogger()); + return new LogNoResponse(api, responseGenerator(), errorLogger()); } @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public SelectPingTargets selectPingTargets() { - return new SelectPingTargets(clientProvider, taskHelper, readAccessHelper, organizationProvider); + return new SelectPingTargets(api); } @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public SelectPongTarget selectPongTarget() { - return new SelectPongTarget(clientProvider, taskHelper, readAccessHelper, endpointProvider); + return new SelectPongTarget(api); } } diff --git a/src/main/java/dev/dsf/bpe/util/PingStatusGenerator.java b/src/main/java/dev/dsf/bpe/util/PingStatusGenerator.java index 6e22f9e..142ded7 100644 --- a/src/main/java/dev/dsf/bpe/util/PingStatusGenerator.java +++ b/src/main/java/dev/dsf/bpe/util/PingStatusGenerator.java @@ -2,13 +2,13 @@ import org.hl7.fhir.r4.model.Coding; import org.hl7.fhir.r4.model.Extension; -import org.hl7.fhir.r4.model.Identifier; import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.Task.TaskOutputComponent; -import dev.dsf.bpe.ConstantsBase; import dev.dsf.bpe.ConstantsPing; -import dev.dsf.fhir.variables.Target; +import dev.dsf.bpe.v1.constants.NamingSystems.EndpointIdentifier; +import dev.dsf.bpe.v1.constants.NamingSystems.OrganizationIdentifier; +import dev.dsf.bpe.v1.variables.Target; public class PingStatusGenerator { @@ -45,11 +45,9 @@ private TaskOutputComponent createStatusOutput(Target target, String outputParam extension.setUrl(ConstantsPing.EXTENSION_URL_PING_STATUS); extension.addExtension(ConstantsPing.EXTENSION_URL_CORRELATION_KEY, new StringType(target.getCorrelationKey())); extension.addExtension().setUrl(ConstantsPing.EXTENSION_URL_ORGANIZATION_IDENTIFIER) - .setValue(new Identifier().setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER) - .setValue(target.getOrganizationIdentifierValue())); + .setValue(OrganizationIdentifier.withValue(target.getOrganizationIdentifierValue())); extension.addExtension().setUrl(ConstantsPing.EXTENSION_URL_ENDPOINT_IDENTIFIER) - .setValue(new Identifier().setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ENDPOINT_IDENTIFIER) - .setValue(target.getEndpointIdentifierValue())); + .setValue(EndpointIdentifier.withValue(target.getEndpointIdentifierValue())); if (errorMessage != null) extension.addExtension().setUrl(ConstantsPing.EXTENSION_URL_ERROR_MESSAGE) .setValue(new StringType(errorMessage)); diff --git a/src/main/resources/META-INF/services/dev.dsf.bpe.ProcessPluginDefinition b/src/main/resources/META-INF/services/dev.dsf.bpe.v1.ProcessPluginDefinition similarity index 100% rename from src/main/resources/META-INF/services/dev.dsf.bpe.ProcessPluginDefinition rename to src/main/resources/META-INF/services/dev.dsf.bpe.v1.ProcessPluginDefinition diff --git a/src/main/resources/bpe/ping-autostart.bpmn b/src/main/resources/bpe/ping-autostart.bpmn index 2c4c13b..c77a2c4 100644 --- a/src/main/resources/bpe/ping-autostart.bpmn +++ b/src/main/resources/bpe/ping-autostart.bpmn @@ -1,7 +1,7 @@ - + - + Flow_1h835ja @@ -11,11 +11,11 @@ Flow_0g1txh0 Flow_0jy9ipp - + Flow_1m61xqv - + no @@ -27,8 +27,8 @@ ${timerInterval} - - + + ${stop == 'yes'} @@ -38,36 +38,42 @@ Flow_1h835ja Flow_19zyiou - + ${stop == 'yes'} - + ${stop == 'no'} - - - - - http://dsf.dev/fhir/StructureDefinition/task-start-ping|#{version} - startPing - http://dsf.dev/bpe/Process/ping/#{version} - - + + + Flow_0jy9ipp Flow_1yj8623 - + + + + http://dsf.dev/fhir/StructureDefinition/task-start-ping|#{version} + + + startPing + + + http://dsf.dev/bpe/Process/ping|#{version} + + + - + Flow_0y7niuq - - + + Flow_0y7niuq - - + + Flow_1m61xqv Flow_09o8bb5 @@ -80,8 +86,8 @@ Flow_18lkrxy Flow_10ocr9f - - + + yes @@ -91,10 +97,10 @@ Flow_096pj3d - - - - + + + + no @@ -107,24 +113,77 @@ + - - - - - - - + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + - + @@ -136,17 +195,23 @@ - - - - + + + - + - - - + + + + + + + + + + @@ -184,63 +249,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/bpe/ping.bpmn b/src/main/resources/bpe/ping.bpmn index 74561f7..ec72bce 100644 --- a/src/main/resources/bpe/ping.bpmn +++ b/src/main/resources/bpe/ping.bpmn @@ -1,36 +1,40 @@ - + - - - + + + SequenceFlow_0k1j79c SequenceFlow_05ia6lz - + - - http://dsf.dev/bpe/Process/pong/#{version} - ping - http://dsf.dev/fhir/StructureDefinition/task-ping|#{version} - + + http://dsf.dev/fhir/StructureDefinition/task-ping|#{version} + + + ping + + + http://dsf.dev/bpe/Process/pong|#{version} + SequenceFlow_05ia6lz SequenceFlow_1vng5zz - + SequenceFlow_1vng5zz SequenceFlow_10d3jfk - + SequenceFlow_1jv4kfm - - + + Flow_0brn8vt - + ${target.correlationKey} @@ -39,110 +43,118 @@ SequenceFlow_1jv4kfm SequenceFlow_0r89tc0 - - - + + + SequenceFlow_0r89tc0 Flow_0brn8vt - + Flow_0d1hhpd - - - + + + SequenceFlow_0k1j79c - - + + SequenceFlow_10d3jfk Flow_1mpgmm5 Flow_0d1hhpd - + Flow_1mpgmm5 PT5M - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + - + - - - - - - - - - - - - - + - + - + + - + + - + + + + + + + + + + + + + - + + + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/bpe/pong.bpmn b/src/main/resources/bpe/pong.bpmn index d67be4b..39fdb0b 100644 --- a/src/main/resources/bpe/pong.bpmn +++ b/src/main/resources/bpe/pong.bpmn @@ -1,84 +1,98 @@ - + - + SequenceFlow_07w11cw - - - - - http://dsf.dev/bpe/Process/ping/#{version} - pong - http://dsf.dev/fhir/StructureDefinition/task-pong|#{version} - - + + + SequenceFlow_1ism9wt - + + + + http://dsf.dev/fhir/StructureDefinition/task-pong|#{version} + + + pong + + + http://dsf.dev/bpe/Process/ping|#{version} + + + - - + + SequenceFlow_07w11cw SequenceFlow_09i9zb8 - + SequenceFlow_09i9zb8 SequenceFlow_1ism9wt - - + + Flow_0yr2pmf - + Flow_0yr2pmf - + - - - - - - - - - - - - - - - - - - + + + + - + + + + - + + - + + - + - + - + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/fhir/StructureDefinition/dsf-task-ping.xml b/src/main/resources/fhir/StructureDefinition/dsf-task-ping.xml index 0847c82..8934616 100644 --- a/src/main/resources/fhir/StructureDefinition/dsf-task-ping.xml +++ b/src/main/resources/fhir/StructureDefinition/dsf-task-ping.xml @@ -21,9 +21,9 @@ - - - + + + diff --git a/src/main/resources/fhir/StructureDefinition/dsf-task-pong.xml b/src/main/resources/fhir/StructureDefinition/dsf-task-pong.xml index a0c9a6d..225c13b 100644 --- a/src/main/resources/fhir/StructureDefinition/dsf-task-pong.xml +++ b/src/main/resources/fhir/StructureDefinition/dsf-task-pong.xml @@ -21,9 +21,9 @@ - - - + + + diff --git a/src/main/resources/fhir/StructureDefinition/dsf-task-start-ping-autostart.xml b/src/main/resources/fhir/StructureDefinition/dsf-task-start-ping-autostart.xml index 3e59e73..0683d5a 100644 --- a/src/main/resources/fhir/StructureDefinition/dsf-task-start-ping-autostart.xml +++ b/src/main/resources/fhir/StructureDefinition/dsf-task-start-ping-autostart.xml @@ -21,9 +21,9 @@ - - - + + + diff --git a/src/main/resources/fhir/StructureDefinition/dsf-task-start-ping.xml b/src/main/resources/fhir/StructureDefinition/dsf-task-start-ping.xml index ebc7801..cf4363e 100644 --- a/src/main/resources/fhir/StructureDefinition/dsf-task-start-ping.xml +++ b/src/main/resources/fhir/StructureDefinition/dsf-task-start-ping.xml @@ -21,9 +21,9 @@ - - - + + + diff --git a/src/main/resources/fhir/StructureDefinition/dsf-task-stop-ping-autostart.xml b/src/main/resources/fhir/StructureDefinition/dsf-task-stop-ping-autostart.xml index c35d583..bc6a7b1 100644 --- a/src/main/resources/fhir/StructureDefinition/dsf-task-stop-ping-autostart.xml +++ b/src/main/resources/fhir/StructureDefinition/dsf-task-stop-ping-autostart.xml @@ -21,9 +21,9 @@ - - - + + + diff --git a/src/main/resources/fhir/Task/dsf-task-start-ping.xml b/src/main/resources/fhir/Task/dsf-task-start-ping.xml new file mode 100644 index 0000000..637ced2 --- /dev/null +++ b/src/main/resources/fhir/Task/dsf-task-start-ping.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/dev/dsf/bpe/PingProcessPluginDefinitionTest.java b/src/test/java/dev/dsf/bpe/PingProcessPluginDefinitionTest.java index bec7b6c..d27e5de 100644 --- a/src/test/java/dev/dsf/bpe/PingProcessPluginDefinitionTest.java +++ b/src/test/java/dev/dsf/bpe/PingProcessPluginDefinitionTest.java @@ -3,11 +3,12 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import java.util.List; +import java.util.Map; + import org.junit.Test; -import org.springframework.core.env.StandardEnvironment; -import ca.uhn.fhir.context.FhirContext; -import dev.dsf.fhir.resources.ResourceProvider; +import dev.dsf.bpe.v1.ProcessPluginDefinition; public class PingProcessPluginDefinitionTest { @@ -15,23 +16,23 @@ public class PingProcessPluginDefinitionTest public void testResourceLoading() throws Exception { ProcessPluginDefinition definition = new PingProcessPluginDefinition(); - ResourceProvider provider = definition.getResourceProvider(FhirContext.forR4(), getClass().getClassLoader(), - new StandardEnvironment()); - assertNotNull(provider); + Map> resourcesByProcessId = definition.getFhirResourcesByProcessId(); - var ping = provider - .getResources(ConstantsPing.PROCESS_NAME_FULL_PING + "/" + PingProcessPluginDefinition.VERSION); + var ping = resourcesByProcessId.get(ConstantsPing.PROCESS_NAME_FULL_PING); assertNotNull(ping); - assertEquals(8, ping.count()); + assertEquals(9, ping.stream().filter(this::exists).count()); - var pingAutostart = provider.getResources( - ConstantsPing.PROCESS_NAME_FULL_PING_AUTOSTART + "/" + PingProcessPluginDefinition.VERSION); + var pingAutostart = resourcesByProcessId.get(ConstantsPing.PROCESS_NAME_FULL_PING_AUTOSTART); assertNotNull(pingAutostart); - assertEquals(5, pingAutostart.count()); + assertEquals(5, pingAutostart.stream().filter(this::exists).count()); - var pong = provider - .getResources(ConstantsPing.PROCESS_NAME_FULL_PONG + "/" + PingProcessPluginDefinition.VERSION); + var pong = resourcesByProcessId.get(ConstantsPing.PROCESS_NAME_FULL_PONG); assertNotNull(pong); - assertEquals(7, pong.count()); + assertEquals(7, pong.stream().filter(this::exists).count()); + } + + private boolean exists(String file) + { + return getClass().getClassLoader().getResourceAsStream(file) != null; } } diff --git a/src/test/java/dev/dsf/bpe/start/Ping3MedicFromTtpExampleStarter.java b/src/test/java/dev/dsf/bpe/start/Ping3MedicFromTtpExampleStarter.java index 26c6e3f..2b6cdde 100644 --- a/src/test/java/dev/dsf/bpe/start/Ping3MedicFromTtpExampleStarter.java +++ b/src/test/java/dev/dsf/bpe/start/Ping3MedicFromTtpExampleStarter.java @@ -6,8 +6,10 @@ import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.Task; -import dev.dsf.bpe.ConstantsBase; import dev.dsf.bpe.ConstantsPing; +import dev.dsf.bpe.PingProcessPluginDefinition; +import dev.dsf.bpe.v1.constants.CodeSystems.BpmnMessage; +import dev.dsf.bpe.v1.constants.NamingSystems.OrganizationIdentifier; public class Ping3MedicFromTtpExampleStarter { @@ -22,22 +24,22 @@ public static void main(String[] args) throws Exception private static Task task() { + var def = new PingProcessPluginDefinition(); + Task task = new Task(); - task.getMeta().addProfile(ConstantsPing.PROFILE_DSF_TASK_START_PING_AND_LATEST_VERSION); - task.setInstantiatesUri(ConstantsPing.PROFILE_DSF_TASK_PING_PROCESS_URI_AND_LATEST_VERSION); + task.getMeta().addProfile(ConstantsPing.PROFILE_DSF_TASK_START_PING + "|" + def.getResourceVersion()); + task.setInstantiatesCanonical(ConstantsPing.PROFILE_DSF_TASK_PING_PROCESS_URI + "|" + def.getResourceVersion()); task.setStatus(Task.TaskStatus.REQUESTED); task.setIntent(Task.TaskIntent.ORDER); task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER) - .setValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_TTP); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER) - .setValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_TTP); + task.getRequester().setType(ResourceType.Organization.name()).setIdentifier(OrganizationIdentifier + .withValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_TTP)); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()) + .setIdentifier(OrganizationIdentifier + .withValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_TTP)); task.addInput().setValue(new StringType(ConstantsPing.PROFILE_DSF_TASK_START_PING_MESSAGE_NAME)).getType() - .addCoding().setSystem(ConstantsBase.CODESYSTEM_DSF_BPMN) - .setCode(ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_MESSAGE_NAME); + .addCoding(BpmnMessage.messageName()); return task; } diff --git a/src/test/java/dev/dsf/bpe/start/PingTtpsFromMedic1ExampleStarter.java b/src/test/java/dev/dsf/bpe/start/PingTtpsFromMedic1ExampleStarter.java index bf7885d..7bc70f0 100644 --- a/src/test/java/dev/dsf/bpe/start/PingTtpsFromMedic1ExampleStarter.java +++ b/src/test/java/dev/dsf/bpe/start/PingTtpsFromMedic1ExampleStarter.java @@ -6,8 +6,10 @@ import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.Task; -import dev.dsf.bpe.ConstantsBase; import dev.dsf.bpe.ConstantsPing; +import dev.dsf.bpe.PingProcessPluginDefinition; +import dev.dsf.bpe.v1.constants.CodeSystems.BpmnMessage; +import dev.dsf.bpe.v1.constants.NamingSystems.OrganizationIdentifier; public class PingTtpsFromMedic1ExampleStarter { @@ -22,22 +24,22 @@ public static void main(String[] args) throws Exception private static Task task() { + var def = new PingProcessPluginDefinition(); + Task task = new Task(); - task.getMeta().addProfile(ConstantsPing.PROFILE_DSF_TASK_START_PING_AND_LATEST_VERSION); - task.setInstantiatesUri(ConstantsPing.PROFILE_DSF_TASK_PING_PROCESS_URI_AND_LATEST_VERSION); + task.getMeta().addProfile(ConstantsPing.PROFILE_DSF_TASK_START_PING + "|" + def.getResourceVersion()); + task.setInstantiatesCanonical(ConstantsPing.PROFILE_DSF_TASK_PING_PROCESS_URI + "|" + def.getResourceVersion()); task.setStatus(Task.TaskStatus.REQUESTED); task.setIntent(Task.TaskIntent.ORDER); task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER) - .setValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER) - .setValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1); + task.getRequester().setType(ResourceType.Organization.name()).setIdentifier(OrganizationIdentifier + .withValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1)); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()) + .setIdentifier(OrganizationIdentifier + .withValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_MEDIC_1)); task.addInput().setValue(new StringType(ConstantsPing.PROFILE_DSF_TASK_START_PING_MESSAGE_NAME)).getType() - .addCoding().setSystem(ConstantsBase.CODESYSTEM_DSF_BPMN) - .setCode(ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_MESSAGE_NAME); + .addCoding(BpmnMessage.messageName()); task.addInput().setValue(new StringType( "OrganizationAffiliation?primary-organization:identifier=http://dsf.dev/sid/organization-identifier|highmed.org" diff --git a/src/test/java/dev/dsf/bpe/start/StartAutostartPing3MedicFromTtpExampleStarter.java b/src/test/java/dev/dsf/bpe/start/StartAutostartPing3MedicFromTtpExampleStarter.java index 3fd1378..39d5a86 100644 --- a/src/test/java/dev/dsf/bpe/start/StartAutostartPing3MedicFromTtpExampleStarter.java +++ b/src/test/java/dev/dsf/bpe/start/StartAutostartPing3MedicFromTtpExampleStarter.java @@ -6,8 +6,10 @@ import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.Task; -import dev.dsf.bpe.ConstantsBase; import dev.dsf.bpe.ConstantsPing; +import dev.dsf.bpe.PingProcessPluginDefinition; +import dev.dsf.bpe.v1.constants.CodeSystems.BpmnMessage; +import dev.dsf.bpe.v1.constants.NamingSystems.OrganizationIdentifier; public class StartAutostartPing3MedicFromTtpExampleStarter { @@ -22,22 +24,23 @@ public static void main(String[] args) throws Exception private static Task task() { + var def = new PingProcessPluginDefinition(); + Task task = new Task(); - task.getMeta().addProfile(ConstantsPing.PROFILE_DSF_TASK_START_PING_AUTOSTART_AND_LATEST_VERSION); - task.setInstantiatesUri(ConstantsPing.PROFILE_DSF_TASK_START_PING_AUTOSTART_PROCESS_URI_AND_LATEST_VERSION); + task.getMeta().addProfile(ConstantsPing.PROFILE_DSF_TASK_START_PING_AUTOSTART + "|" + def.getResourceVersion()); + task.setInstantiatesCanonical( + ConstantsPing.PROFILE_DSF_TASK_START_PING_AUTOSTART_PROCESS_URI + "|" + def.getResourceVersion()); task.setStatus(Task.TaskStatus.REQUESTED); task.setIntent(Task.TaskIntent.ORDER); task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER) - .setValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_TTP); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER) - .setValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_TTP); + task.getRequester().setType(ResourceType.Organization.name()).setIdentifier(OrganizationIdentifier + .withValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_TTP)); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()) + .setIdentifier(OrganizationIdentifier + .withValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_TTP)); task.addInput().setValue(new StringType(ConstantsPing.PROFILE_DSF_TASK_START_PING_AUTOSTART_MESSAGE_NAME)) - .getType().addCoding().setSystem(ConstantsBase.CODESYSTEM_DSF_BPMN) - .setCode(ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_MESSAGE_NAME); + .getType().addCoding(BpmnMessage.messageName()); task.addInput().setValue(new StringType("Endpoint?identifier=http://dsf.dev/sid/endpoint-identifier|")) .getType().addCoding().setSystem(ConstantsPing.CODESYSTEM_DSF_PING) .setCode(ConstantsPing.CODESYSTEM_DSF_PING_VALUE_TARGET_ENDPOINTS); diff --git a/src/test/java/dev/dsf/bpe/start/StopAutostartPing3MedicFromTtpExampleStarter.java b/src/test/java/dev/dsf/bpe/start/StopAutostartPing3MedicFromTtpExampleStarter.java index 4dac7d6..f476438 100644 --- a/src/test/java/dev/dsf/bpe/start/StopAutostartPing3MedicFromTtpExampleStarter.java +++ b/src/test/java/dev/dsf/bpe/start/StopAutostartPing3MedicFromTtpExampleStarter.java @@ -6,8 +6,10 @@ import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.Task; -import dev.dsf.bpe.ConstantsBase; import dev.dsf.bpe.ConstantsPing; +import dev.dsf.bpe.PingProcessPluginDefinition; +import dev.dsf.bpe.v1.constants.CodeSystems.BpmnMessage; +import dev.dsf.bpe.v1.constants.NamingSystems.OrganizationIdentifier; public class StopAutostartPing3MedicFromTtpExampleStarter { @@ -22,22 +24,23 @@ public static void main(String[] args) throws Exception private static Task task() { + var def = new PingProcessPluginDefinition(); + Task task = new Task(); - task.getMeta().addProfile(ConstantsPing.PROFILE_DSF_TASK_STOP_PING_AUTOSTART_AND_LATEST_VERSION); - task.setInstantiatesUri(ConstantsPing.PROFILE_DSF_TASK_STOP_PING_AUTOSTART_PROCESS_URI_AND_LATEST_VERSION); + task.getMeta().addProfile(ConstantsPing.PROFILE_DSF_TASK_STOP_PING_AUTOSTART + "|" + def.getResourceVersion()); + task.setInstantiatesCanonical( + ConstantsPing.PROFILE_DSF_TASK_STOP_PING_AUTOSTART_PROCESS_URI + "|" + def.getResourceVersion()); task.setStatus(Task.TaskStatus.REQUESTED); task.setIntent(Task.TaskIntent.ORDER); task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER) - .setValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_TTP); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER) - .setValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_TTP); + task.getRequester().setType(ResourceType.Organization.name()).setIdentifier(OrganizationIdentifier + .withValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_TTP)); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()) + .setIdentifier(OrganizationIdentifier + .withValue(ConstantsExampleStarters.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER_VALUE_TTP)); task.addInput().setValue(new StringType(ConstantsPing.PROFILE_DSF_TASK_STOP_PING_AUTOSTART_MESSAGE_NAME)) - .getType().addCoding().setSystem(ConstantsBase.CODESYSTEM_DSF_BPMN) - .setCode(ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_MESSAGE_NAME); + .getType().addCoding(BpmnMessage.messageName()); return task; } diff --git a/src/test/java/dev/dsf/fhir/profiles/TaskProfileTest.java b/src/test/java/dev/dsf/fhir/profiles/TaskProfileTest.java index dbefce5..7fefe36 100644 --- a/src/test/java/dev/dsf/fhir/profiles/TaskProfileTest.java +++ b/src/test/java/dev/dsf/fhir/profiles/TaskProfileTest.java @@ -6,7 +6,6 @@ import java.util.Date; import java.util.UUID; -import org.hl7.fhir.r4.model.Identifier; import org.hl7.fhir.r4.model.Reference; import org.hl7.fhir.r4.model.ResourceType; import org.hl7.fhir.r4.model.StringType; @@ -20,28 +19,32 @@ import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhir.validation.ValidationResult; -import dev.dsf.bpe.ConstantsBase; import dev.dsf.bpe.ConstantsPing; import dev.dsf.bpe.PingProcessPluginDefinition; import dev.dsf.bpe.util.PingStatusGenerator; +import dev.dsf.bpe.v1.constants.CodeSystems.BpmnMessage; +import dev.dsf.bpe.v1.constants.NamingSystems.EndpointIdentifier; +import dev.dsf.bpe.v1.constants.NamingSystems.OrganizationIdentifier; +import dev.dsf.bpe.v1.variables.Target; import dev.dsf.fhir.validation.ResourceValidator; import dev.dsf.fhir.validation.ResourceValidatorImpl; import dev.dsf.fhir.validation.ValidationSupportRule; -import dev.dsf.fhir.variables.Target; public class TaskProfileTest { private static final Logger logger = LoggerFactory.getLogger(TaskProfileTest.class); + private static final PingProcessPluginDefinition def = new PingProcessPluginDefinition(); + @ClassRule - public static final ValidationSupportRule validationRule = new ValidationSupportRule( - PingProcessPluginDefinition.VERSION, PingProcessPluginDefinition.RELEASE_DATE, - Arrays.asList("dsf-task-base-0.5.0.xml", "dsf-extension-ping-status.xml", "dsf-task-ping.xml", + public static final ValidationSupportRule validationRule = new ValidationSupportRule(def.getResourceVersion(), + def.getResourceReleaseDate(), + Arrays.asList("dsf-task-base-1.0.0.xml", "dsf-extension-ping-status.xml", "dsf-task-ping.xml", "dsf-task-pong.xml", "dsf-task-start-ping.xml", "dsf-task-start-ping-autostart.xml", "dsf-task-stop-ping-autostart.xml"), - Arrays.asList("dsf-read-access-tag-0.5.0.xml", "dsf-bpmn-message-0.5.0.xml", "dsf-ping.xml", + Arrays.asList("dsf-read-access-tag-0.5.0.xml", "dsf-bpmn-message-1.0.0.xml", "dsf-ping.xml", "dsf-ping-status.xml"), - Arrays.asList("dsf-read-access-tag-0.5.0.xml", "dsf-bpmn-message-0.5.0.xml", "dsf-ping.xml", + Arrays.asList("dsf-read-access-tag-0.5.0.xml", "dsf-bpmn-message-1.0.0.xml", "dsf-ping.xml", "dsf-ping-status.xml", "dsf-pong-status.xml")); private ResourceValidator resourceValidator = new ResourceValidatorImpl(validationRule.getFhirContext(), @@ -110,18 +113,18 @@ private Task createValidTaskStartAutostartProcess() { Task task = new Task(); task.getMeta().addProfile(ConstantsPing.PROFILE_DSF_TASK_START_PING_AUTOSTART); - task.setInstantiatesUri(ConstantsPing.PROFILE_DSF_TASK_START_PING_AUTOSTART_PROCESS_URI_AND_LATEST_VERSION); + task.setInstantiatesCanonical( + ConstantsPing.PROFILE_DSF_TASK_START_PING_AUTOSTART_PROCESS_URI + "|" + def.getResourceVersion()); task.setStatus(TaskStatus.REQUESTED); task.setIntent(TaskIntent.ORDER); task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER).setValue("TTP"); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER).setValue("TTP"); + task.getRequester().setType(ResourceType.Organization.name()) + .setIdentifier(OrganizationIdentifier.withValue("TTP")); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()) + .setIdentifier(OrganizationIdentifier.withValue("TTP")); task.addInput().setValue(new StringType(ConstantsPing.PROFILE_DSF_TASK_START_PING_AUTOSTART_MESSAGE_NAME)) - .getType().addCoding().setSystem(ConstantsBase.CODESYSTEM_DSF_BPMN) - .setCode(ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_MESSAGE_NAME); + .getType().addCoding(BpmnMessage.messageName()); return task; } @@ -142,18 +145,18 @@ private Task createValidTaskStopAutostartProcess() { Task task = new Task(); task.getMeta().addProfile(ConstantsPing.PROFILE_DSF_TASK_STOP_PING_AUTOSTART); - task.setInstantiatesUri(ConstantsPing.PROFILE_DSF_TASK_STOP_PING_AUTOSTART_PROCESS_URI_AND_LATEST_VERSION); + task.setInstantiatesCanonical( + ConstantsPing.PROFILE_DSF_TASK_STOP_PING_AUTOSTART_PROCESS_URI + "|" + def.getResourceVersion()); task.setStatus(TaskStatus.REQUESTED); task.setIntent(TaskIntent.ORDER); task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER).setValue("TTP"); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER).setValue("TTP"); + task.getRequester().setType(ResourceType.Organization.name()) + .setIdentifier(OrganizationIdentifier.withValue("TTP")); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()) + .setIdentifier(OrganizationIdentifier.withValue("TTP")); task.addInput().setValue(new StringType(ConstantsPing.PROFILE_DSF_TASK_STOP_PING_AUTOSTART_MESSAGE_NAME)) - .getType().addCoding().setSystem(ConstantsBase.CODESYSTEM_DSF_BPMN) - .setCode(ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_MESSAGE_NAME); + .getType().addCoding(BpmnMessage.messageName()); return task; } @@ -191,9 +194,8 @@ public void testTaskStartPingProcessProfileValidWithTargetEndpoints() throws Exc public void testTaskStartPingProcessProfileValidWithBuisnessKeyOutput() throws Exception { Task task = createValidTaskStartPingProcess(); - task.addOutput().setValue(new StringType(UUID.randomUUID().toString())).getType().addCoding() - .setSystem(ConstantsBase.CODESYSTEM_DSF_BPMN) - .setCode(ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_BUSINESS_KEY); + task.addOutput().setValue(new StringType(UUID.randomUUID().toString())).getType() + .addCoding(BpmnMessage.businessKey()); ValidationResult result = resourceValidator.validate(task); ValidationSupportRule.logValidationMessages(logger, result); @@ -205,13 +207,36 @@ public void testTaskStartPingProcessProfileValidWithBuisnessKeyOutput() throws E @Test public void testTaskStartPingProcessProfileValidWithBusinessKeyAndPingStatusOutput() throws Exception { - Task task = createValidTaskStartPingProcess(); - task.addOutput().setValue(new StringType(UUID.randomUUID().toString())).getType().addCoding() - .setSystem(ConstantsBase.CODESYSTEM_DSF_BPMN) - .setCode(ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_BUSINESS_KEY); + Target target = new Target() + { + @Override + public String getOrganizationIdentifierValue() + { + return "target.org"; + } + + @Override + public String getEndpointUrl() + { + return "https://endpoint.target.org/fhir"; + } + + @Override + public String getEndpointIdentifierValue() + { + return "endpoint.target.org"; + } + + @Override + public String getCorrelationKey() + { + return UUID.randomUUID().toString(); + } + }; - Target target = Target.createBiDirectionalTarget("target.org", "endpoint.target.org", - "https://endpoint.target.org/fhir", UUID.randomUUID().toString()); + Task task = createValidTaskStartPingProcess(); + task.addOutput().setValue(new StringType(UUID.randomUUID().toString())).getType() + .addCoding(BpmnMessage.businessKey()); task.addOutput(new PingStatusGenerator().createPingStatusOutput(target, ConstantsPing.CODESYSTEM_DSF_PING_STATUS_VALUE_NOT_REACHABLE, "some error message")); @@ -226,7 +251,7 @@ public void testTaskStartPingProcessProfileValidWithBusinessKeyAndPingStatusOutp public void testTaskStartPingProcessProfileNotValid1() throws Exception { Task task = createValidTaskStartPingProcess(); - task.setInstantiatesUri("http://dsf.dev/bpe/Process/ping/0.1.0"); // not valid + task.setInstantiatesCanonical("http://dsf.dev/bpe/Process/ping/0.1.0"); // not valid ValidationResult result = resourceValidator.validate(task); ValidationSupportRule.logValidationMessages(logger, result); @@ -265,18 +290,17 @@ private Task createValidTaskStartPingProcess() { Task task = new Task(); task.getMeta().addProfile(ConstantsPing.PROFILE_DSF_TASK_START_PING); - task.setInstantiatesUri(ConstantsPing.PROFILE_DSF_TASK_PING_PROCESS_URI_AND_LATEST_VERSION); + task.setInstantiatesCanonical(ConstantsPing.PROFILE_DSF_TASK_PING_PROCESS_URI + "|" + def.getResourceVersion()); task.setStatus(TaskStatus.REQUESTED); task.setIntent(TaskIntent.ORDER); task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER).setValue("TTP"); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER).setValue("TTP"); + task.getRequester().setType(ResourceType.Organization.name()) + .setIdentifier(OrganizationIdentifier.withValue("TTP")); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()) + .setIdentifier(OrganizationIdentifier.withValue("TTP")); task.addInput().setValue(new StringType(ConstantsPing.PROFILE_DSF_TASK_START_PING_MESSAGE_NAME)).getType() - .addCoding().setSystem(ConstantsBase.CODESYSTEM_DSF_BPMN) - .setCode(ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_MESSAGE_NAME); + .addCoding(BpmnMessage.messageName()); return task; } @@ -296,10 +320,34 @@ public void testTaskPingValid() throws Exception @Test public void testTaskPingValidWithPingStatusOutput() throws Exception { + Target target = new Target() + { + @Override + public String getOrganizationIdentifierValue() + { + return "target.org"; + } + + @Override + public String getEndpointUrl() + { + return "https://endpoint.target.org/fhir"; + } + + @Override + public String getEndpointIdentifierValue() + { + return "endpoint.target.org"; + } + + @Override + public String getCorrelationKey() + { + return UUID.randomUUID().toString(); + } + }; Task task = createValidTaskPing(); - task.addOutput(new PingStatusGenerator().createPongStatusOutput( - Target.createBiDirectionalTarget("target.org", "endpoint.target.org", - "https://endpoint.target.org/fhir", UUID.randomUUID().toString()), + task.addOutput(new PingStatusGenerator().createPongStatusOutput(target, ConstantsPing.CODESYSTEM_DSF_PING_STATUS_VALUE_PONG_SEND)); ValidationResult result = resourceValidator.validate(task); @@ -313,28 +361,24 @@ private Task createValidTaskPing() { Task task = new Task(); task.getMeta().addProfile(ConstantsPing.PROFILE_DSF_TASK_PING); - task.setInstantiatesUri(ConstantsPing.PROFILE_DSF_TASK_PONG_PROCESS_URI_AND_LATEST_VERSION); + task.setInstantiatesCanonical(ConstantsPing.PROFILE_DSF_TASK_PONG_PROCESS_URI + "|" + def.getResourceVersion()); task.setStatus(TaskStatus.REQUESTED); task.setIntent(TaskIntent.ORDER); task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER).setValue("TTP"); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER).setValue("MeDIC 1"); - - task.addInput().setValue(new StringType(ConstantsPing.PROFILE_DSF_TASK_PING_MESSAGE_NAME)).getType().addCoding() - .setSystem(ConstantsBase.CODESYSTEM_DSF_BPMN) - .setCode(ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_MESSAGE_NAME); - task.addInput().setValue(new StringType(UUID.randomUUID().toString())).getType().addCoding() - .setSystem(ConstantsBase.CODESYSTEM_DSF_BPMN) - .setCode(ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_BUSINESS_KEY); - task.addInput().setValue(new StringType(UUID.randomUUID().toString())).getType().addCoding() - .setSystem(ConstantsBase.CODESYSTEM_DSF_BPMN) - .setCode(ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_CORRELATION_KEY); + task.getRequester().setType(ResourceType.Organization.name()) + .setIdentifier(OrganizationIdentifier.withValue("TTP")); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()) + .setIdentifier(OrganizationIdentifier.withValue("MeDIC 1")); + + task.addInput().setValue(new StringType(ConstantsPing.PROFILE_DSF_TASK_PING_MESSAGE_NAME)).getType() + .addCoding(BpmnMessage.messageName()); + task.addInput().setValue(new StringType(UUID.randomUUID().toString())).getType() + .addCoding(BpmnMessage.businessKey()); + task.addInput().setValue(new StringType(UUID.randomUUID().toString())).getType() + .addCoding(BpmnMessage.correlationKey()); task.addInput() - .setValue(new Reference().setIdentifier(new Identifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ENDPOINT_IDENTIFIER).setValue("endpoint.target.org")) - .setType(ResourceType.Endpoint.name())) + .setValue(new Reference().setType(ResourceType.Endpoint.name()) + .setIdentifier(EndpointIdentifier.withValue("endpoint.target.org"))) .getType().addCoding().setSystem(ConstantsPing.CODESYSTEM_DSF_PING) .setCode(ConstantsPing.CODESYSTEM_DSF_PING_VALUE_ENDPOINT_IDENTIFIER); @@ -357,24 +401,21 @@ private Task createValidTaskPong() { Task task = new Task(); task.getMeta().addProfile(ConstantsPing.PROFILE_DSF_TASK_PONG_TASK); - task.setInstantiatesUri(ConstantsPing.PROFILE_DSF_TASK_PING_PROCESS_URI_AND_LATEST_VERSION); + task.setInstantiatesCanonical(ConstantsPing.PROFILE_DSF_TASK_PING_PROCESS_URI + "|" + def.getResourceVersion()); task.setStatus(TaskStatus.REQUESTED); task.setIntent(TaskIntent.ORDER); task.setAuthoredOn(new Date()); - task.getRequester().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER).setValue("MeDIC 1"); - task.getRestriction().addRecipient().setType(ResourceType.Organization.name()).getIdentifier() - .setSystem(ConstantsBase.NAMINGSYSTEM_DSF_ORGANIZATION_IDENTIFIER).setValue("TTP"); - - task.addInput().setValue(new StringType(ConstantsPing.PROFILE_DSF_TASK_PONG_MESSAGE_NAME)).getType().addCoding() - .setSystem(ConstantsBase.CODESYSTEM_DSF_BPMN) - .setCode(ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_MESSAGE_NAME); - task.addInput().setValue(new StringType(UUID.randomUUID().toString())).getType().addCoding() - .setSystem(ConstantsBase.CODESYSTEM_DSF_BPMN) - .setCode(ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_BUSINESS_KEY); - task.addInput().setValue(new StringType(UUID.randomUUID().toString())).getType().addCoding() - .setSystem(ConstantsBase.CODESYSTEM_DSF_BPMN) - .setCode(ConstantsBase.CODESYSTEM_DSF_BPMN_VALUE_CORRELATION_KEY); + task.getRequester().setType(ResourceType.Organization.name()) + .setIdentifier(OrganizationIdentifier.withValue("MeDIC 1")); + task.getRestriction().addRecipient().setType(ResourceType.Organization.name()) + .setIdentifier(OrganizationIdentifier.withValue("TTP")); + + task.addInput().setValue(new StringType(ConstantsPing.PROFILE_DSF_TASK_PONG_MESSAGE_NAME)).getType() + .addCoding(BpmnMessage.messageName()); + task.addInput().setValue(new StringType(UUID.randomUUID().toString())).getType() + .addCoding(BpmnMessage.businessKey()); + task.addInput().setValue(new StringType(UUID.randomUUID().toString())).getType() + .addCoding(BpmnMessage.correlationKey()); return task; } From deddd3986ae5e1e031eb3fab94402f632d757f26 Mon Sep 17 00:00:00 2001 From: Hauke Hund Date: Mon, 24 Apr 2023 14:20:07 +0200 Subject: [PATCH 2/9] changed documentation-generator goal to reflect modifications in dsf --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index aa05eb9..d4a1b42 100644 --- a/pom.xml +++ b/pom.xml @@ -169,7 +169,7 @@ - documentation-generation + generate From 761e91ae93dd5555cd05fbe5d6e56abc5cfc7290 Mon Sep 17 00:00:00 2001 From: Hauke Hund Date: Tue, 25 Apr 2023 02:27:13 +0200 Subject: [PATCH 3/9] changes to reflect modifications to the process api --- src/main/java/dev/dsf/bpe/service/SelectPingTargets.java | 2 +- src/main/java/dev/dsf/bpe/service/SelectPongTarget.java | 4 ++-- .../dev/dsf/bpe/service/SetTargetAndConfigureTimer.java | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/dev/dsf/bpe/service/SelectPingTargets.java b/src/main/java/dev/dsf/bpe/service/SelectPingTargets.java index 732358e..92f2368 100644 --- a/src/main/java/dev/dsf/bpe/service/SelectPingTargets.java +++ b/src/main/java/dev/dsf/bpe/service/SelectPingTargets.java @@ -67,7 +67,7 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw String endpointIdentifier = EndpointIdentifier.findFirst(e).map(Identifier::getValue).get(); String endpointAddress = e.getAddress(); - return variables.createBiDirectionalTarget(organizationIdentifier, endpointIdentifier, endpointAddress, + return variables.createTarget(organizationIdentifier, endpointIdentifier, endpointAddress, UUID.randomUUID().toString()); }).collect(Collectors.toList()); diff --git a/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java b/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java index c9c411e..42d24ec 100644 --- a/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java +++ b/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java @@ -43,8 +43,8 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw return new BpmnError("target_not_allowed"); }); - variables.setTarget(variables.createBiDirectionalTarget(targetOrganizationIdentifierValue, - targetEndpointIdentifierValue, targetEndpointAddress, correlationKey)); + variables.setTarget(variables.createTarget(targetOrganizationIdentifierValue, targetEndpointIdentifierValue, + targetEndpointAddress, correlationKey)); } private String getEndpointIdentifierValue(Task task) diff --git a/src/main/java/dev/dsf/bpe/service/SetTargetAndConfigureTimer.java b/src/main/java/dev/dsf/bpe/service/SetTargetAndConfigureTimer.java index 2b67358..0392723 100644 --- a/src/main/java/dev/dsf/bpe/service/SetTargetAndConfigureTimer.java +++ b/src/main/java/dev/dsf/bpe/service/SetTargetAndConfigureTimer.java @@ -27,10 +27,10 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw timerInterval); variables.setString(ConstantsPing.BPMN_EXECUTION_VARIABLE_TIMER_INTERVAL, timerInterval); - variables.setTarget(variables.createUniDirectionalTarget( - api.getOrganizationProvider().getLocalOrganizationIdentifierValue().get(), - api.getEndpointProvider().getLocalEndpointIdentifierValue().get(), - api.getEndpointProvider().getLocalEndpointAddress())); + variables.setTarget( + variables.createTarget(api.getOrganizationProvider().getLocalOrganizationIdentifierValue().get(), + api.getEndpointProvider().getLocalEndpointIdentifierValue().get(), + api.getEndpointProvider().getLocalEndpointAddress())); } private String getTimerInterval(Variables variables) From 695b15bbf4cbdb39891be7d1fa5eb65567ed19a8 Mon Sep 17 00:00:00 2001 From: Hauke Hund Date: Wed, 26 Apr 2023 00:30:05 +0200 Subject: [PATCH 4/9] config fields now private, Optional fix, removed optional xml preamble --- pom.xml | 1 - src/main/java/dev/dsf/bpe/mail/ErrorMailService.java | 2 +- src/main/java/dev/dsf/bpe/spring/config/PingConfig.java | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index d4a1b42..48e5dec 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,3 @@ - diff --git a/src/main/java/dev/dsf/bpe/mail/ErrorMailService.java b/src/main/java/dev/dsf/bpe/mail/ErrorMailService.java index 4e4c2aa..b3366e0 100644 --- a/src/main/java/dev/dsf/bpe/mail/ErrorMailService.java +++ b/src/main/java/dev/dsf/bpe/mail/ErrorMailService.java @@ -41,7 +41,7 @@ private String createMessage(Target target, String message, String messageDetail { StringBuilder b = new StringBuilder(); - b.append(api.getOrganizationProvider().getLocalOrganizationIdentifierValue()); + b.append(api.getOrganizationProvider().getLocalOrganizationIdentifierValue().orElse("?")); b.append('/'); b.append(api.getEndpointProvider().getLocalEndpointIdentifierValue().orElse("?")); diff --git a/src/main/java/dev/dsf/bpe/spring/config/PingConfig.java b/src/main/java/dev/dsf/bpe/spring/config/PingConfig.java index 5dc096e..5ffd8a4 100644 --- a/src/main/java/dev/dsf/bpe/spring/config/PingConfig.java +++ b/src/main/java/dev/dsf/bpe/spring/config/PingConfig.java @@ -29,11 +29,11 @@ public class PingConfig @ProcessDocumentation(description = "To enable a mail being send if the ping process fails, set to 'true'. This requires the SMPT mail service client to be configured in the DSF", processNames = "dsfdev_ping") @Value("${dev.dsf.dsf.bpe.ping.mail.onPingProcessFailed:false}") - boolean sendPingProcessFailedMail; + private boolean sendPingProcessFailedMail; @ProcessDocumentation(description = "To enable a mail being send if the pong process fails, set to 'true'. This requires the SMPT mail service client to be configured in the DSF", processNames = "dsfdev_pong") @Value("${dev.dsf.dsf.bpe.ping.mail.onPongProcessFailed:false}") - boolean sendPongProcessFailedMail; + private boolean sendPongProcessFailedMail; @Bean @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) From 2dad1b0363a77cd843e8e6af24a9c28eb83b4035 Mon Sep 17 00:00:00 2001 From: Hauke Hund Date: Fri, 28 Apr 2023 01:31:53 +0200 Subject: [PATCH 5/9] changes to reflect modifications to the process api --- src/main/java/dev/dsf/bpe/message/SendPing.java | 2 +- src/main/java/dev/dsf/bpe/message/SendPong.java | 4 ++-- src/main/java/dev/dsf/bpe/message/SendStartPing.java | 2 +- src/main/java/dev/dsf/bpe/service/LogNoResponse.java | 2 +- src/main/java/dev/dsf/bpe/service/LogPong.java | 2 +- src/main/java/dev/dsf/bpe/service/SelectPingTargets.java | 2 +- src/main/java/dev/dsf/bpe/service/SelectPongTarget.java | 2 +- .../java/dev/dsf/bpe/service/SetTargetAndConfigureTimer.java | 2 +- src/main/resources/fhir/Task/dsf-task-start-ping.xml | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/dev/dsf/bpe/message/SendPing.java b/src/main/java/dev/dsf/bpe/message/SendPing.java index f581455..c5a63bd 100644 --- a/src/main/java/dev/dsf/bpe/message/SendPing.java +++ b/src/main/java/dev/dsf/bpe/message/SendPing.java @@ -55,7 +55,7 @@ protected void handleSendTaskError(DelegateExecution execution, Variables variab String errorMessage) { Target target = variables.getTarget(); - Task mainTask = variables.getMainTask(); + Task mainTask = variables.getStartTask(); if (mainTask != null) { diff --git a/src/main/java/dev/dsf/bpe/message/SendPong.java b/src/main/java/dev/dsf/bpe/message/SendPong.java index a56717c..f423aa4 100644 --- a/src/main/java/dev/dsf/bpe/message/SendPong.java +++ b/src/main/java/dev/dsf/bpe/message/SendPong.java @@ -43,7 +43,7 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw super.doExecute(execution, variables); Target target = variables.getTarget(); - Task mainTask = variables.getMainTask(); + Task mainTask = variables.getStartTask(); mainTask.addOutput(statusGenerator.createPongStatusOutput(target, ConstantsPing.CODESYSTEM_DSF_PING_STATUS_VALUE_PONG_SEND)); variables.updateTask(mainTask); @@ -54,7 +54,7 @@ protected void handleEndEventError(DelegateExecution execution, Variables variab String errorMessage) { Target target = variables.getTarget(); - Task mainTask = variables.getMainTask(); + Task mainTask = variables.getStartTask(); if (mainTask != null) { diff --git a/src/main/java/dev/dsf/bpe/message/SendStartPing.java b/src/main/java/dev/dsf/bpe/message/SendStartPing.java index 52ae765..196d828 100644 --- a/src/main/java/dev/dsf/bpe/message/SendStartPing.java +++ b/src/main/java/dev/dsf/bpe/message/SendStartPing.java @@ -21,7 +21,7 @@ public SendStartPing(ProcessPluginApi api) @Override protected Stream getAdditionalInputParameters(DelegateExecution execution, Variables variables) { - return variables.getMainTask().getInput().stream().filter(Task.ParameterComponent::hasType) + return variables.getStartTask().getInput().stream().filter(Task.ParameterComponent::hasType) .filter(i -> i.getType().getCoding().stream() .anyMatch(c -> ConstantsPing.CODESYSTEM_DSF_PING.equals(c.getSystem()) && ConstantsPing.CODESYSTEM_DSF_PING_VALUE_TARGET_ENDPOINTS.equals(c.getCode()))); diff --git a/src/main/java/dev/dsf/bpe/service/LogNoResponse.java b/src/main/java/dev/dsf/bpe/service/LogNoResponse.java index 68b7305..ae07189 100644 --- a/src/main/java/dev/dsf/bpe/service/LogNoResponse.java +++ b/src/main/java/dev/dsf/bpe/service/LogNoResponse.java @@ -45,7 +45,7 @@ public void afterPropertiesSet() throws Exception @Override protected void doExecute(DelegateExecution execution, Variables variables) throws BpmnError, Exception { - Task mainTask = variables.getMainTask(); + Task mainTask = variables.getStartTask(); Targets targets = variables.getTargets(); targets.getEntries().forEach(t -> logAndAddResponseToTask(mainTask, t)); diff --git a/src/main/java/dev/dsf/bpe/service/LogPong.java b/src/main/java/dev/dsf/bpe/service/LogPong.java index e1381e8..e5ce0be 100644 --- a/src/main/java/dev/dsf/bpe/service/LogPong.java +++ b/src/main/java/dev/dsf/bpe/service/LogPong.java @@ -46,7 +46,7 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw logger.info("PONG from {} (endpoint: {})", target.getOrganizationIdentifierValue(), target.getEndpointIdentifierValue()); - Task mainTask = variables.getMainTask(); + Task mainTask = variables.getStartTask(); mainTask.addOutput(responseGenerator.createPingStatusOutput(target, ConstantsPing.CODESYSTEM_DSF_PING_STATUS_VALUE_PONG_RECEIVED)); variables.updateTask(mainTask); diff --git a/src/main/java/dev/dsf/bpe/service/SelectPingTargets.java b/src/main/java/dev/dsf/bpe/service/SelectPingTargets.java index 92f2368..3eaa0ab 100644 --- a/src/main/java/dev/dsf/bpe/service/SelectPingTargets.java +++ b/src/main/java/dev/dsf/bpe/service/SelectPingTargets.java @@ -76,7 +76,7 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw private Optional getTargetEndpointsSearchParameter(Variables variables) { - Task mainTask = variables.getMainTask(); + Task mainTask = variables.getStartTask(); return api.getTaskHelper() .getFirstInputParameterStringValue(mainTask, ConstantsPing.CODESYSTEM_DSF_PING, ConstantsPing.CODESYSTEM_DSF_PING_VALUE_TARGET_ENDPOINTS) diff --git a/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java b/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java index 42d24ec..3299de8 100644 --- a/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java +++ b/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java @@ -27,7 +27,7 @@ public SelectPongTarget(ProcessPluginApi api) @Override protected void doExecute(DelegateExecution execution, Variables variables) throws BpmnError, Exception { - Task task = variables.getMainTask(); + Task task = variables.getStartTask(); String correlationKey = api.getTaskHelper() .getFirstInputParameterStringValue(task, BpmnMessage.URL, BpmnMessage.Codes.CORRELATION_KEY).get(); diff --git a/src/main/java/dev/dsf/bpe/service/SetTargetAndConfigureTimer.java b/src/main/java/dev/dsf/bpe/service/SetTargetAndConfigureTimer.java index 0392723..4df0f1a 100644 --- a/src/main/java/dev/dsf/bpe/service/SetTargetAndConfigureTimer.java +++ b/src/main/java/dev/dsf/bpe/service/SetTargetAndConfigureTimer.java @@ -36,7 +36,7 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw private String getTimerInterval(Variables variables) { return api.getTaskHelper() - .getFirstInputParameterStringValue(variables.getMainTask(), ConstantsPing.CODESYSTEM_DSF_PING, + .getFirstInputParameterStringValue(variables.getStartTask(), ConstantsPing.CODESYSTEM_DSF_PING, ConstantsPing.CODESYSTEM_DSF_PING_VALUE_TIMER_INTERVAL) .orElse(ConstantsPing.TIMER_INTERVAL_DEFAULT_VALUE); } diff --git a/src/main/resources/fhir/Task/dsf-task-start-ping.xml b/src/main/resources/fhir/Task/dsf-task-start-ping.xml index 637ced2..4e7ff94 100644 --- a/src/main/resources/fhir/Task/dsf-task-start-ping.xml +++ b/src/main/resources/fhir/Task/dsf-task-start-ping.xml @@ -4,7 +4,7 @@ - + From 7812cd552971ad7ae129cf9df5d00d7358713f03 Mon Sep 17 00:00:00 2001 From: Hauke Hund Date: Fri, 28 Apr 2023 23:26:25 +0200 Subject: [PATCH 6/9] fixed test dependency --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 48e5dec..3e45df5 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ dev.dsf - dsf-bpe-process-base + dsf-bpe-process-api-v1 ${dsf.version} test test-jar From 76de793a69841105bdf406ab96e54e49f7eae12c Mon Sep 17 00:00:00 2001 From: Hauke Hund Date: Tue, 16 May 2023 23:27:07 +0200 Subject: [PATCH 7/9] changes to align with datasharingframework/dsf#39 --- src/main/java/dev/dsf/bpe/message/SendPing.java | 6 +++--- src/main/java/dev/dsf/bpe/service/LogPing.java | 4 ++-- src/main/java/dev/dsf/bpe/service/SelectPongTarget.java | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/dev/dsf/bpe/message/SendPing.java b/src/main/java/dev/dsf/bpe/message/SendPing.java index c5a63bd..0e87717 100644 --- a/src/main/java/dev/dsf/bpe/message/SendPing.java +++ b/src/main/java/dev/dsf/bpe/message/SendPing.java @@ -45,9 +45,9 @@ public void afterPropertiesSet() throws Exception @Override protected Stream getAdditionalInputParameters(DelegateExecution execution, Variables variables) { - return Stream.of(api.getTaskHelper().createInput(ConstantsPing.CODESYSTEM_DSF_PING, - ConstantsPing.CODESYSTEM_DSF_PING_VALUE_ENDPOINT_IDENTIFIER, - new Reference().setIdentifier(getLocalEndpointIdentifier()).setType(ResourceType.Endpoint.name()))); + return Stream.of(api.getTaskHelper().createInput( + new Reference().setIdentifier(getLocalEndpointIdentifier()).setType(ResourceType.Endpoint.name()), + ConstantsPing.CODESYSTEM_DSF_PING, ConstantsPing.CODESYSTEM_DSF_PING_VALUE_ENDPOINT_IDENTIFIER)); } @Override diff --git a/src/main/java/dev/dsf/bpe/service/LogPing.java b/src/main/java/dev/dsf/bpe/service/LogPing.java index 86be63f..cbfc286 100644 --- a/src/main/java/dev/dsf/bpe/service/LogPing.java +++ b/src/main/java/dev/dsf/bpe/service/LogPing.java @@ -34,8 +34,8 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw private String getEndpointIdentifierValue(Task task) { return api.getTaskHelper() - .getFirstInputParameterReferenceValue(task, ConstantsPing.CODESYSTEM_DSF_PING, - ConstantsPing.CODESYSTEM_DSF_PING_VALUE_ENDPOINT_IDENTIFIER) + .getFirstInputParameterValue(task, ConstantsPing.CODESYSTEM_DSF_PING, + ConstantsPing.CODESYSTEM_DSF_PING_VALUE_ENDPOINT_IDENTIFIER, Reference.class) .map(Reference::getIdentifier).map(Identifier::getValue).get(); } } diff --git a/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java b/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java index 3299de8..7e3f0d3 100644 --- a/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java +++ b/src/main/java/dev/dsf/bpe/service/SelectPongTarget.java @@ -50,8 +50,8 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw private String getEndpointIdentifierValue(Task task) { return api.getTaskHelper() - .getFirstInputParameterReferenceValue(task, ConstantsPing.CODESYSTEM_DSF_PING, - ConstantsPing.CODESYSTEM_DSF_PING_VALUE_ENDPOINT_IDENTIFIER) + .getFirstInputParameterValue(task, ConstantsPing.CODESYSTEM_DSF_PING, + ConstantsPing.CODESYSTEM_DSF_PING_VALUE_ENDPOINT_IDENTIFIER, Reference.class) .map(Reference::getIdentifier).map(Identifier::getValue).get(); } } From b33ec8995637a36003e389b5d1851ded89290be7 Mon Sep 17 00:00:00 2001 From: Hauke Hund Date: Sat, 20 May 2023 02:55:07 +0200 Subject: [PATCH 8/9] DSF 1.0.0-M1 --- pom.xml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 3e45df5..5dcb44d 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ 17 17 - 1.0.0-SNAPSHOT + 1.0.0-M1 ../dsf @@ -197,9 +197,6 @@ github GitHub DSF Apache Maven Packages https://maven.pkg.github.com/datasharingframework/dsf - - true - true From 93868106d8d5a404ffc505346ed9153b852398eb Mon Sep 17 00:00:00 2001 From: Hauke Hund Date: Sat, 20 May 2023 03:03:54 +0200 Subject: [PATCH 9/9] plugin name, release date --- src/main/java/dev/dsf/bpe/PingProcessPluginDefinition.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/dsf/bpe/PingProcessPluginDefinition.java b/src/main/java/dev/dsf/bpe/PingProcessPluginDefinition.java index de682fc..6538d43 100644 --- a/src/main/java/dev/dsf/bpe/PingProcessPluginDefinition.java +++ b/src/main/java/dev/dsf/bpe/PingProcessPluginDefinition.java @@ -11,12 +11,12 @@ public class PingProcessPluginDefinition implements ProcessPluginDefinition { public static final String VERSION = "1.0.0.0"; - public static final LocalDate RELEASE_DATE = LocalDate.of(2023, 4, 22); + public static final LocalDate RELEASE_DATE = LocalDate.of(2023, 5, 20); @Override public String getName() { - return "dsf-bpe-process-ping"; + return "dsf-process-ping-pong"; } @Override