use of org.mifos.connector.mpesa.zeebe.ZeebeMessages.OPERATOR_MANUAL_RECOVERY in project ph-ee-connector-mpesa by openMF.
the class OperationsRouteBuilder method configure.
@Override
public void configure() {
from("rest:POST:/channel/transaction/{" + TRANSACTION_ID + "}/resolve").id("transaction-resolve").log(LoggingLevel.INFO, "## operator transaction resolve").process(e -> {
Map<String, Object> variables = new HashMap<>();
JSONObject request = new JSONObject(e.getIn().getBody(String.class));
request.keys().forEachRemaining(k -> {
variables.put(k, request.get(k));
});
zeebeClient.newPublishMessageCommand().messageName(OPERATOR_MANUAL_RECOVERY).correlationKey(e.getIn().getHeader(TRANSACTION_ID, String.class)).timeToLive(Duration.ofMillis(30000)).variables(variables).send().join();
}).setBody(constant((Object) null));
from("rest:POST:/channel/job/resolve").id("job-resolve").log(LoggingLevel.INFO, "## operator job resolve").process(e -> {
JSONObject request = new JSONObject(e.getIn().getBody(String.class));
JSONObject incident = request.getJSONObject("incident");
Map<String, Object> newVariables = new HashMap<>();
JSONObject requestedVariables = request.getJSONObject("variables");
requestedVariables.keys().forEachRemaining(k -> {
newVariables.put(k, requestedVariables.get(k));
});
zeebeClient.newSetVariablesCommand(incident.getLong("elementInstanceKey")).variables(newVariables).send().join();
zeebeClient.newUpdateRetriesCommand(incident.getLong("jobKey")).retries(incident.getInt("newRetries")).send().join();
zeebeClient.newResolveIncidentCommand(incident.getLong("key")).send().join();
}).setBody(constant((Object) null));
from("rest:POST:/channel/workflow/resolve").id("workflow-resolve").log(LoggingLevel.INFO, "## operator workflow resolve").process(e -> {
JSONObject request = new JSONObject(e.getIn().getBody(String.class));
JSONObject incident = request.getJSONObject("incident");
Map<String, Object> newVariables = new HashMap<>();
JSONObject requestedVariables = request.getJSONObject("variables");
requestedVariables.keys().forEachRemaining(k -> {
newVariables.put(k, requestedVariables.get(k));
});
zeebeClient.newSetVariablesCommand(incident.getLong("elementInstanceKey")).variables(newVariables).send().join();
zeebeClient.newResolveIncidentCommand(incident.getLong("key")).send().join();
}).setBody(constant((Object) null));
from("rest:POST:/channel/workflow/{workflowInstanceKey}/cancel").id("workflow-cancel").log(LoggingLevel.INFO, "## operator workflow cancel ${header.workflowInstanceKey}").process(e -> zeebeClient.newCancelInstanceCommand(Long.parseLong(e.getIn().getHeader("workflowInstanceKey", String.class))).send().join()).setBody(constant((Object) null));
}
Aggregations