Skip to content

Commit 604e262

Browse files
committed
ExecutionVariables enum values are now the enum names
1 parent d28a52e commit 604e262

24 files changed

+73
-92
lines changed

src/main/java/dev/dsf/bpe/ExecutionVariables.java

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,25 @@
22

33
public enum ExecutionVariables
44
{
5-
TIMER_INTERVAL("timerInterval"),
6-
STOP_TIMER("stopTimer"),
7-
DOWNLOAD_RESOURCE_SIZE_BYTES("downloadResourceSizeBytes"),
8-
DOWNLOAD_RESOURCE("downloadResource"),
9-
DOWNLOAD_RESOURCE_REFERENCE("downloadResourceReference"),
10-
STATUS_CODE("statusCode"),
11-
ERROR("error"),
12-
ERROR_LIST("errors"),
13-
DOWNLOADED_BYTES("downloadedBytes"),
14-
DOWNLOADED_DURATION("downloadedDuration"),
15-
PONG_TARGET_ENDPOINT_IDENTIFIER("targetEndpointIdentifier"),
16-
UPLOADED_BYTES("uploadedBytes"),
17-
UPLOADED_DURATION("uploadedDuration"),
18-
RESOURCE_DOWNLOAD_ERROR("resourceDownloadError"),
19-
RESOURCE_UPLOAD_ERROR("resourceUploadError"),
20-
PING_TASK_ID("pingTaskId");
21-
22-
private final String value;
23-
24-
ExecutionVariables(String value)
25-
{
26-
this.value = value;
27-
}
28-
29-
public String getValue()
30-
{
31-
return value;
32-
}
5+
timerInterval,
6+
stopTimer,
7+
downloadResourceSizeBytes,
8+
downloadResource,
9+
downloadResourceReference,
10+
statusCode,
11+
error,
12+
errors,
13+
downloadedBytes,
14+
downloadedDuration,
15+
targetEndpointIdentifier,
16+
uploadedBytes,
17+
uploadedDuration,
18+
resourceDownloadError,
19+
resourceUploadError,
20+
pingTaskId;
3321

3422
public String correlatedValue(String correlationKey)
3523
{
36-
return getValue() + "_" + correlationKey;
24+
return name() + "_" + correlationKey;
3725
}
3826
}

src/main/java/dev/dsf/bpe/message/CleanupPongMessage.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ protected Stream<Task.ParameterComponent> getAdditionalInputParameters(DelegateE
3535
{
3636
Target target = variables.getTarget();
3737
String correlationKey = target.getCorrelationKey();
38-
Long downloadedBytes = variables.getLong(ExecutionVariables.DOWNLOADED_BYTES.correlatedValue(correlationKey));
38+
Long downloadedBytes = variables.getLong(ExecutionVariables.downloadedBytes.correlatedValue(correlationKey));
3939
Duration downloadedDuration = (Duration) variables
40-
.getVariable(ExecutionVariables.DOWNLOADED_DURATION.correlatedValue(correlationKey));
40+
.getVariable(ExecutionVariables.downloadedDuration.correlatedValue(correlationKey));
4141

4242
Stream<Task.ParameterComponent> downloadedBytesParameter = downloadedBytes != null
4343
? Stream.of(DownloadedBytesGenerator.create(downloadedBytes))
@@ -57,8 +57,8 @@ protected void handleSendTaskError(DelegateExecution execution, Variables variab
5757
ProcessError error = SendTaskErrorConverter.convert(exception,
5858
"Sending cleanup message to " + target.getEndpointUrl());
5959

60-
execution.setVariableLocal(ExecutionVariables.ERROR.getValue(), new ProcessErrorValueImpl(error));
61-
execution.setVariableLocal(ExecutionVariables.STATUS_CODE.getValue(), CodeSystem.DsfPing.Code.ERROR.getValue());
60+
execution.setVariableLocal(ExecutionVariables.error.name(), new ProcessErrorValueImpl(error));
61+
execution.setVariableLocal(ExecutionVariables.statusCode.name(), CodeSystem.DsfPing.Code.ERROR.getValue());
6262

6363
logger.info("Request to {} resulted in error: {}", target.getEndpointUrl(), error.message());
6464
}

src/main/java/dev/dsf/bpe/message/SendPingMessage.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ public SendPingMessage(ProcessPluginApi api)
3838
@Override
3939
protected Stream<ParameterComponent> getAdditionalInputParameters(DelegateExecution execution, Variables variables)
4040
{
41-
String downloadResourceReference = variables
42-
.getString(ExecutionVariables.DOWNLOAD_RESOURCE_REFERENCE.getValue());
43-
long downloadResourceSizeBytes = variables.getLong(ExecutionVariables.DOWNLOAD_RESOURCE_SIZE_BYTES.getValue());
41+
String downloadResourceReference = variables.getString(ExecutionVariables.downloadResourceReference.name());
42+
long downloadResourceSizeBytes = variables.getLong(ExecutionVariables.downloadResourceSizeBytes.name());
4443

4544
Stream<ParameterComponent> downloadResourceReferenceStream = downloadResourceReference == null ? Stream.empty()
4645
: Stream.of(DownloadResourceReferenceGenerator.create(downloadResourceReference));
@@ -63,7 +62,7 @@ protected void sendTask(DelegateExecution execution, Variables variables, Target
6362
additionalInputParameters);
6463
if (taskId != null)
6564
{
66-
execution.setVariableLocal(ExecutionVariables.PING_TASK_ID.getValue(), taskId.getIdPart());
65+
execution.setVariableLocal(ExecutionVariables.pingTaskId.name(), taskId.getIdPart());
6766
}
6867
}
6968

@@ -82,8 +81,8 @@ protected void handleSendTaskError(DelegateExecution execution, Variables variab
8281
ProcessError error = SendTaskErrorConverter.convert(exception,
8382
"Sending ping message to " + target.getEndpointUrl());
8483

85-
execution.setVariableLocal(ExecutionVariables.ERROR.getValue(), new ProcessErrorValueImpl(error));
86-
execution.setVariableLocal(ExecutionVariables.STATUS_CODE.getValue(), CodeSystem.DsfPing.Code.ERROR.getValue());
84+
execution.setVariableLocal(ExecutionVariables.error.name(), new ProcessErrorValueImpl(error));
85+
execution.setVariableLocal(ExecutionVariables.statusCode.name(), CodeSystem.DsfPing.Code.ERROR.getValue());
8786

8887
logger.info("Request to {} resulted in error: {}", target.getEndpointUrl(), error.message());
8988
}

src/main/java/dev/dsf/bpe/message/SendPongMessage.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,13 @@ protected Stream<Task.ParameterComponent> getAdditionalInputParameters(DelegateE
5252
Variables variables)
5353
{
5454
ProcessErrors errorList = ErrorListUtils.getErrorList(execution);
55-
long downloadResourceSizeBytes = variables.getLong(ExecutionVariables.DOWNLOAD_RESOURCE_SIZE_BYTES.getValue());
55+
long downloadResourceSizeBytes = variables.getLong(ExecutionVariables.downloadResourceSizeBytes.name());
5656
if (downloadResourceSizeBytes >= 0)
5757
{
58-
Long downloadedBytes = variables.getLong(ExecutionVariables.DOWNLOADED_BYTES.getValue());
58+
Long downloadedBytes = variables.getLong(ExecutionVariables.downloadedBytes.name());
5959
Duration downloadedDuration = (Duration) variables
60-
.getVariable(ExecutionVariables.DOWNLOADED_DURATION.getValue());
61-
String downloadResourceReference = variables
62-
.getString(ExecutionVariables.DOWNLOAD_RESOURCE_REFERENCE.getValue());
60+
.getVariable(ExecutionVariables.downloadedDuration.name());
61+
String downloadResourceReference = variables.getString(ExecutionVariables.downloadResourceReference.name());
6362

6463
Stream<Task.ParameterComponent> downloadedBytesParameter = downloadedBytes != null
6564
? Stream.of(DownloadedBytesGenerator.create(downloadedBytes))
@@ -104,7 +103,7 @@ protected void handleSendTaskError(DelegateExecution execution, Variables variab
104103

105104
ErrorListUtils.add(error, execution);
106105
PingStatusGenerator.updatePongStatusOutput(startTask, CodeSystem.DsfPingStatus.Code.ERROR);
107-
variables.setString(ExecutionVariables.STATUS_CODE.getValue(), CodeSystem.DsfPing.Code.ERROR.getValue());
106+
variables.setString(ExecutionVariables.statusCode.name(), CodeSystem.DsfPing.Code.ERROR.getValue());
108107
variables.updateTask(startTask);
109108

110109
logger.info("Request to {} resulted in error: {}", target.getEndpointUrl(), error.message());

src/main/java/dev/dsf/bpe/service/Cleanup.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public void doExecute(DelegateExecution delegateExecution, Variables variables)
3939
CodeSystem.DsfPingProcesses.Code process = getProcess((String) this.process.getValue(delegateExecution));
4040
Objects.requireNonNull(process);
4141

42-
String downloadResourceId = new IdType(
43-
variables.getString(ExecutionVariables.DOWNLOAD_RESOURCE_REFERENCE.getValue())).getIdPart();
42+
String downloadResourceId = new IdType(variables.getString(ExecutionVariables.downloadResourceReference.name()))
43+
.getIdPart();
4444
if (downloadResourceId != null)
4545
{
4646
try

src/main/java/dev/dsf/bpe/service/GenerateAndStoreResource.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void doExecute(DelegateExecution delegateExecution, Variables variables)
5454
{
5555
resourceContent = new RandomByteInputStream(downloadResourceSizeBytes);
5656
}
57-
variables.setLong(ExecutionVariables.DOWNLOAD_RESOURCE_SIZE_BYTES.getValue(), downloadResourceSizeBytes);
57+
variables.setLong(ExecutionVariables.downloadResourceSizeBytes.name(), downloadResourceSizeBytes);
5858
logger.debug("Generated resource.");
5959
logger.debug("Storing binary resource for download...");
6060

@@ -64,7 +64,7 @@ public void doExecute(DelegateExecution delegateExecution, Variables variables)
6464

6565
String reference = downloadResource.toVersionless().getValueAsString();
6666

67-
variables.setString(ExecutionVariables.DOWNLOAD_RESOURCE_REFERENCE.getValue(), reference);
67+
variables.setString(ExecutionVariables.downloadResourceReference.name(), reference);
6868

6969
logger.debug("Stored binary resource for download");
7070
}
@@ -75,14 +75,13 @@ public void doExecute(DelegateExecution delegateExecution, Variables variables)
7575
CodeSystem.DsfPingProcessSteps.Code.GENERATE_AND_STORE_RESOURCE,
7676
"Storing Binary resource on local DSF FHIR server.", ConstantsPing.POTENTIAL_FIX_URL_ERROR_HTTP,
7777
"Local DSF FHIR server responded with status: " + status);
78-
variables.setVariable(ExecutionVariables.RESOURCE_UPLOAD_ERROR.getValue(),
79-
new ProcessErrorValueImpl(error));
78+
variables.setVariable(ExecutionVariables.resourceUploadError.name(), new ProcessErrorValueImpl(error));
8079
}
8180
}
8281

8382
private long getDownloadResourceSize(Variables variables)
8483
{
85-
return variables.getLong(ExecutionVariables.DOWNLOAD_RESOURCE_SIZE_BYTES.getValue());
84+
return variables.getLong(ExecutionVariables.downloadResourceSizeBytes.name());
8685
}
8786

8887
private IdType storeBinary(RandomByteInputStream downloadResourceContent)

src/main/java/dev/dsf/bpe/service/SetDownloadResourceSize.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected void doExecute(DelegateExecution delegateExecution, Variables variable
3333
logger.debug("Setting download resource size...");
3434

3535
long downloadResourceSizeBytes = getDownloadResourceSizeBytes(variables);
36-
variables.setLong(ExecutionVariables.DOWNLOAD_RESOURCE_SIZE_BYTES.getValue(), downloadResourceSizeBytes);
36+
variables.setLong(ExecutionVariables.downloadResourceSizeBytes.name(), downloadResourceSizeBytes);
3737

3838
logger.debug("Set download resource size to " + downloadResourceSizeBytes);
3939
}

src/main/java/dev/dsf/bpe/service/autostart/SetTargetAndConfigureTimer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public SetTargetAndConfigureTimer(ProcessPluginApi api)
2525
protected void doExecute(DelegateExecution execution, Variables variables) throws BpmnError
2626
{
2727
String timerInterval = getTimerInterval(variables);
28-
logger.debug("Setting variable '{}' to {}", ExecutionVariables.TIMER_INTERVAL.getValue(), timerInterval);
28+
logger.debug("Setting variable '{}' to {}", ExecutionVariables.timerInterval.name(), timerInterval);
2929

30-
variables.setString(ExecutionVariables.TIMER_INTERVAL.getValue(), timerInterval);
30+
variables.setString(ExecutionVariables.timerInterval.name(), timerInterval);
3131
variables.setTarget(
3232
variables.createTarget(api.getOrganizationProvider().getLocalOrganizationIdentifierValue().get(),
3333
api.getEndpointProvider().getLocalEndpointIdentifierValue().get(),

src/main/java/dev/dsf/bpe/service/ping/CheckPingTaskStatus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected void doExecute(DelegateExecution delegateExecution, Variables variable
3737
Target target = variables.getTarget();
3838
String correlationKey = target.getCorrelationKey();
3939

40-
String taskId = (String) delegateExecution.getVariableLocal(ExecutionVariables.PING_TASK_ID.getValue());
40+
String taskId = (String) delegateExecution.getVariableLocal(ExecutionVariables.pingTaskId.name());
4141

4242
Objects.requireNonNull(taskId);
4343
FhirWebserviceClient fhirWebserviceClient = api.getFhirWebserviceClientProvider()

src/main/java/dev/dsf/bpe/service/ping/DownloadResourceAndMeasureSpeedInSubProcess.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ protected void doExecute(DelegateExecution delegateExecution, Variables variable
3939

4040
if (downloadResult.getError() == null)
4141
{
42-
variables.setLong(ExecutionVariables.DOWNLOADED_BYTES.correlatedValue(correlationKey),
42+
variables.setLong(ExecutionVariables.downloadedBytes.correlatedValue(correlationKey),
4343
downloadResult.getDownloadedBytes());
44-
variables.setVariable(ExecutionVariables.DOWNLOADED_DURATION.correlatedValue(correlationKey),
44+
variables.setVariable(ExecutionVariables.downloadedDuration.correlatedValue(correlationKey),
4545
new DurationValueImpl(downloadResult.getDownloadedDuration()));
4646
}
4747
else
4848
{
49-
delegateExecution.setVariableLocal(ExecutionVariables.RESOURCE_DOWNLOAD_ERROR.getValue(),
49+
delegateExecution.setVariableLocal(ExecutionVariables.resourceDownloadError.name(),
5050
downloadResult.getError());
5151
}
5252

0 commit comments

Comments
 (0)