Package org.joget.workflow.model

Examples of org.joget.workflow.model.WorkflowAssignment


        FormService formService = (FormService) ac.getBean("formService");
        WorkflowManager workflowManager = (WorkflowManager) ac.getBean("workflowManager");

        if (isAssignmentExist(activityId)) {
            try {
                WorkflowAssignment assignment = workflowManager.getAssignment(activityId);
                // set process instance ID as primary key
                FormData formData = new FormData();

                formData = formService.retrieveFormDataFromRequestMap(formData, getRequestParameters());

                if (getPropertyString("keyName") != null && getPropertyString("keyName").trim().length() > 0 && getKey() != null) {
                    formData.addRequestParameterValues(getPropertyString("keyName"), new String[]{getKey()});
                }

                // get form
                String formUrl = getUrl() + "?_action=assignmentSubmit&activityId=" + activityId;
                PackageActivityForm activityForm = appService.viewAssignmentForm(getRequestParameterString("appId"), getRequestParameterString("appVersion"), activityId, formData, formUrl);
                Form form = activityForm.getForm();
                AppDefinition appDef = appService.getAppDefinition(getRequestParameterString("appId"), getRequestParameterString("appVersion"));

                // generate form HTML
                String formHtml = formService.retrieveFormHtml(form, formData);

                // show form
                setProperty("headerTitle", assignment.getProcessName() + " - " + assignment.getActivityName());
                setProperty("view", "formView");
                setProperty("formHtml", formHtml);
                setProperty("activityForm", activityForm);
                setProperty("appDef", appDef);
                setProperty("assignment", assignment);
View Full Code Here


        FormService formService = (FormService) ac.getBean("formService");
        WorkflowManager workflowManager = (WorkflowManager) ac.getBean("workflowManager");
        String activityId = getRequestParameterString("activityId");
        if (isAssignmentExist(activityId)) {
            try {
                WorkflowAssignment assignment = workflowManager.getAssignment(activityId);
                // set process instance ID as primary key
                FormData formData = new FormData();
                formData = formService.retrieveFormDataFromRequestMap(formData, getRequestParameters());
                String processId = assignment.getProcessId();

                // get form
                String formUrl = getUrl() + "?_action=assignmentSubmit&activityId=" + activityId;
                PackageActivityForm activityForm = appService.viewAssignmentForm(getRequestParameterString("appId"), getRequestParameterString("appVersion"), activityId, formData, formUrl);
                Form form = activityForm.getForm();

                // submit form
                FormData formResult = formService.executeFormActions(form, formData);

                // check for validation errors
                if (formResult.getFormResult(AssignmentWithdrawButton.DEFAULT_ID) != null) {
                    // withdraw assignment
                    workflowManager.assignmentWithdraw(activityId);
                } else if (formResult.getFormResult(AssignmentCompleteButton.DEFAULT_ID) != null) {
                    // complete assignment
                    Map<String, String> variableMap = AppUtil.retrieveVariableDataFromMap(getRequestParameters());
                    formResult = appService.completeAssignmentForm(form, assignment, formData, variableMap);

                    Map<String, String> errors = formResult.getFormErrors();
                    if (!formResult.getStay() && errors.isEmpty() && activityForm.isAutoContinue()) {
                        setAlertMessage(getPropertyString("messageShowAfterComplete"));
                        // redirect to next activity if available
                        WorkflowAssignment nextActivity = workflowManager.getAssignmentByProcess(processId);
                        if (nextActivity != null) {
                            setProperty("view", "redirect");
                            setProperty("messageShowAfterComplete", "");
                            String redirectUrl = getUrl() + "?_action=assignmentView&activityId=" + nextActivity.getActivityId();
                            setAlertMessage("");
                            setRedirectUrl(redirectUrl);
                            return;
                        }
                    }
View Full Code Here

    private boolean isAssignmentExist(String activityId) {
        // check for assignment
        ApplicationContext ac = AppUtil.getApplicationContext();
        WorkflowManager workflowManager = (WorkflowManager) ac.getBean("workflowManager");
        WorkflowAssignment assignment = workflowManager.getAssignment(activityId);
        if (assignment != null) {
            return true;
        } else {
            setProperty("headerTitle", ResourceBundleUtil.getMessage("general.label.assignmentUnavailable"));
            setProperty("view", "assignmentUnavailable");
View Full Code Here

    }

    @RequestMapping("/client/app/(~:appId)/(~:version)/assignment/(*:activityId)")
    public String clientAssignmentView(HttpServletRequest request, ModelMap model, @RequestParam(required = false) String appId, @RequestParam(required = false) String version, @RequestParam("activityId") String activityId) {
        // check assignment
        WorkflowAssignment assignment = workflowManager.getAssignment(activityId);
        if (assignment == null) {
            return "client/app/assignmentUnavailable";
        }

        try {
View Full Code Here

    }

    @RequestMapping(value = "/client/app/(~:appId)/(~:version)/assignment/(*:activityId)/submit", method = RequestMethod.POST)
    public String clientAssignmentSubmit(HttpServletRequest request, ModelMap model, @RequestParam(required = false) String appId, @RequestParam(required = false) String version, @RequestParam("activityId") String activityId) {
        // check assignment
        WorkflowAssignment assignment = workflowManager.getAssignment(activityId);
        if (assignment == null) {
            return "client/app/assignmentUnavailable";
        }

        // get app
        AppDefinition appDef = null;
        if (appId != null && !appId.isEmpty()) {
            appDef = appService.getAppDefinition(appId, version);
        } else {
            appDef = appService.getAppDefinitionForWorkflowActivity(activityId);
        }

        // extract form values from request
        FormData formData = new FormData();
        formData = formService.retrieveFormDataFromRequest(formData, request);

        // set process instance ID as primary key
        String processId = assignment.getProcessId();

        // load form
        Long appVersion = (appDef != null) ? appDef.getVersion() : null;
        String formUrl = AppUtil.getRequestContextPath() + "/web/client/app/" + appId + "/" + appVersion + "/assignment/" + activityId + "/submit";
        PackageActivityForm activityForm = appService.viewAssignmentForm(appDef, assignment, formData, formUrl);
        Form form = activityForm.getForm();

        // submit form
        FormData formResult = formService.executeFormActions(form, formData);

        if (formResult.getFormResult(AssignmentWithdrawButton.DEFAULT_ID) != null) {
            // withdraw assignment
            workflowManager.assignmentWithdraw(activityId);
            return "client/app/dialogClose";

        } else if (formResult.getFormResult(AssignmentCompleteButton.DEFAULT_ID) != null) {
            // complete assignment
            Map<String, String> variableMap = AppUtil.retrieveVariableDataFromRequest(request);
            formResult = appService.completeAssignmentForm(form, assignment, formData, variableMap);

            Map<String, String> errors = formResult.getFormErrors();
            if (!formResult.getStay() && errors.isEmpty() && activityForm.isAutoContinue()) {
                // redirect to next activity if available
                WorkflowAssignment nextActivity = workflowManager.getAssignmentByProcess(processId);
                if (nextActivity != null) {
                    String assignmentUrl = "/web/client/app/" + appId + "/" + appVersion + "/assignment/" + nextActivity.getActivityId();
                    return "redirect:" + assignmentUrl;
                }
            }
        }

View Full Code Here

        writeJson(writer, jsonObject, callback);
    }

    @RequestMapping("/json/workflow/assignment/view/(*:activityId)")
    public void assignmentView(Writer writer, @RequestParam(value = "callback", required = false) String callback, @RequestParam("activityId") String activityId) throws JSONException, IOException {
        WorkflowAssignment assignment = workflowManager.getAssignment(activityId);
        if (assignment == null) {
            return;
        }
        JSONObject jsonObject = new JSONObject();
        jsonObject.accumulate("activityId", assignment.getActivityId());
        jsonObject.accumulate("activityDefId", assignment.getActivityDefId());
        jsonObject.accumulate("processId", assignment.getProcessId());
        jsonObject.accumulate("processDefId", assignment.getProcessDefId());
        jsonObject.accumulate("processVersion", assignment.getProcessVersion());
        jsonObject.accumulate("processName", assignment.getProcessName());
        jsonObject.accumulate("activityName", assignment.getActivityName());
        jsonObject.accumulate("description", assignment.getDescription());
        jsonObject.accumulate("participant", assignment.getParticipant());
        jsonObject.accumulate("assigneeId", assignment.getAssigneeId());
        jsonObject.accumulate("assigneeName", assignment.getAssigneeName());

        User user = directoryManager.getUserByUsername(workflowUserManager.getCurrentUsername());
        String gmt = "";
        if (user != null) {
            gmt = user.getTimeZone();
        }
        String format = AppUtil.getAppDateFormat();
        jsonObject.accumulate("dateCreated", TimeZoneUtil.convertToTimeZone(assignment.getDateCreated(), gmt, format));
        if (assignment.getDueDate() != null) {
            jsonObject.accumulate("dueDate", TimeZoneUtil.convertToTimeZone(assignment.getDueDate(), gmt, format));
        }
        Collection<WorkflowVariable> variableList = workflowManager.getActivityVariableList(activityId);
        for (WorkflowVariable variable : variableList) {
            JSONObject variableObj = new JSONObject();
            variableObj.accumulate(variable.getId(), variable.getVal());
View Full Code Here

        writeJson(writer, jsonObject, callback);
    }

    @RequestMapping("/json/workflow/assignment/process/view/(*:processId)")
    public void assignmentViewByProcess(Writer writer, @RequestParam(value = "callback", required = false) String callback, @RequestParam("processId") String processId) throws JSONException, IOException {
        WorkflowAssignment assignment = workflowManager.getAssignmentByProcess(processId);
        if (assignment == null) {
            return;
        }
        JSONObject jsonObject = new JSONObject();
        jsonObject.accumulate("activityId", assignment.getActivityId());
        jsonObject.accumulate("activityDefId", assignment.getActivityDefId());
        jsonObject.accumulate("processId", assignment.getProcessId());
        jsonObject.accumulate("processDefId", assignment.getProcessDefId());
        jsonObject.accumulate("processVersion", assignment.getProcessVersion());
        jsonObject.accumulate("processName", assignment.getProcessName());
        jsonObject.accumulate("activityName", assignment.getActivityName());
        jsonObject.accumulate("description", assignment.getDescription());
        jsonObject.accumulate("participant", assignment.getParticipant());
        jsonObject.accumulate("assigneeId", assignment.getAssigneeId());
        jsonObject.accumulate("assigneeName", assignment.getAssigneeName());

        User user = directoryManager.getUserByUsername(workflowUserManager.getCurrentUsername());
        String gmt = "";
        if (user != null) {
            gmt = user.getTimeZone();
        }
        String format = AppUtil.getAppDateFormat();
        jsonObject.accumulate("dateCreated", TimeZoneUtil.convertToTimeZone(assignment.getDateCreated(), gmt, format));
        if (assignment.getDueDate() != null) {
            jsonObject.accumulate("dueDate", TimeZoneUtil.convertToTimeZone(assignment.getDueDate(), gmt, format));
        }
        Collection<WorkflowVariable> variableList = workflowManager.getActivityVariableList(assignment.getActivityId());
        for (WorkflowVariable variable : variableList) {
            JSONObject variableObj = new JSONObject();
            variableObj.accumulate(variable.getId(), variable.getVal());
            jsonObject.accumulate("variable", variableObj);
        }
View Full Code Here

    @RequestMapping(value = "/json/workflow/assignment/accept/(*:activityId)", method = RequestMethod.POST)
    public void assignmentAccept(Writer writer, @RequestParam(value = "callback", required = false) String callback, @RequestParam("activityId") String activityId) throws JSONException, IOException {
        appService.getAppDefinitionForWorkflowActivity(activityId);
        workflowManager.assignmentAccept(activityId);
        WorkflowAssignment assignment = workflowManager.getAssignment(activityId);
        LogUtil.info(getClass().getName(), "Assignment " + activityId + " accepted");
        JSONObject jsonObject = new JSONObject();
        jsonObject.accumulate("assignment", assignment.getActivityId());
        jsonObject.accumulate("status", "accepted");

        writeJson(writer, jsonObject, callback);
    }
View Full Code Here

    @RequestMapping(value = "/json/workflow/assignment/withdraw/(*:activityId)", method = RequestMethod.POST)
    public void assignmentWithdraw(Writer writer, @RequestParam(value = "callback", required = false) String callback, @RequestParam("activityId") String activityId) throws JSONException, IOException {
        appService.getAppDefinitionForWorkflowActivity(activityId);
        workflowManager.assignmentWithdraw(activityId);
        WorkflowAssignment assignment = workflowManager.getAssignment(activityId);
        LogUtil.info(getClass().getName(), "Assignment " + activityId + " withdrawn");
        JSONObject jsonObject = new JSONObject();
        jsonObject.accumulate("assignment", assignment.getActivityId());
        jsonObject.accumulate("status", "withdrawn");

        writeJson(writer, jsonObject, callback);
    }
View Full Code Here

    }

    @RequestMapping(value = "/json/workflow/assignment/completeWithVariable/(*:activityId)", method = RequestMethod.POST)
    public void assignmentCompleteWithVariable(HttpServletRequest request, Writer writer, @RequestParam(value = "callback", required = false) String callback, @RequestParam("activityId") String activityId) throws JSONException, IOException {
        appService.getAppDefinitionForWorkflowActivity(activityId);
        WorkflowAssignment assignment = workflowManager.getAssignment(activityId);
        String processId = (assignment != null) ? assignment.getProcessId() : "";
       
        if (assignment != null && !assignment.isAccepted()) {
            workflowManager.assignmentAccept(activityId);
        }

        Map<String, String> workflowVariableMap = AppUtil.retrieveVariableDataFromRequest(request);
        workflowManager.assignmentComplete(activityId, workflowVariableMap);
        LogUtil.info(getClass().getName(), "Assignment " + activityId + " completed");
        JSONObject jsonObject = new JSONObject();
        jsonObject.accumulate("assignment", assignment.getAssigneeId());
        jsonObject.accumulate("status", "completed");
        jsonObject.accumulate("processId", processId);
        jsonObject.accumulate("activityId", activityId);

        // check for automatic continuation
        String processDefId = assignment.getProcessDefId();
        String activityDefId = assignment.getActivityDefId();
        String packageId = WorkflowUtil.getProcessDefPackageId(processDefId);
        String packageVersion = WorkflowUtil.getProcessDefVersion(processDefId);
        boolean continueNextAssignment = appService.isActivityAutoContinue(packageId, packageVersion, processDefId, activityDefId);
        if (continueNextAssignment) {
            WorkflowAssignment nextAssignment = workflowManager.getAssignmentByProcess(processId);
            if (nextAssignment != null) {
                jsonObject.accumulate("nextActivityId", nextAssignment.getActivityId());
            }
        }

        writeJson(writer, jsonObject, callback);
    }
View Full Code Here

TOP

Related Classes of org.joget.workflow.model.WorkflowAssignment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.