class WorkflowActionBBTasks {

    public void updateRequestStatusToComplete(DelegateExecution execution) {
        try {
            final String requestId = (String) execution.getVariable(G_REQUEST_ID);
            InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
            final String action = (String) execution.getVariable(G_ACTION);
            final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE);
            final String resourceName = (String) execution.getVariable("resourceName");
            String statusMessage = (String) execution.getVariable("StatusMessage");
            String macroAction;
            if (statusMessage == null) {
                if (aLaCarte) {
                    macroAction = "ALaCarte-" + resourceName + "-" + action + " request was executed correctly.";
                } else {
                    macroAction = "Macro-" + resourceName + "-" + action + " request was executed correctly.";
                }
            } else {
                macroAction = statusMessage;
            }
            execution.setVariable("finalStatusMessage", macroAction);
            Timestamp endTime = new Timestamp(System.currentTimeMillis());
            request.setEndTime(endTime);
            request.setFlowStatus("Successfully completed all Building Blocks");
            request.setStatusMessage(macroAction);
            request.setProgress(100L);
            request.setRequestStatus("COMPLETE");
            request.setLastModifiedBy("CamundaBPMN");
            requestsDbListener.post(request, new DelegateExecutionImpl(execution));
            requestDbclient.updateInfraActiveRequests(request);
        } catch (Exception ex) {
            workflowAction.buildAndThrowException(execution, "Error Updating Request Database", ex);
        }
    }

}