Package org.joget.workflow.model.service

Examples of org.joget.workflow.model.service.WorkflowManager


            if (packageId != null || processDefId != null) {
                DataListQueryParam param = dataList.getQueryParam(null, null);

                // get assignments
                WorkflowManager workflowManager = (WorkflowManager) WorkflowUtil.getApplicationContext().getBean("workflowManager");
                PagedList<WorkflowAssignment> assignmentList = workflowManager.getAssignmentPendingAndAcceptedList(packageId, processDefId, null, param.getSort(), param.getDesc(), param.getStart(), param.getSize());

                DirectoryManager directoryManager = (DirectoryManager) AppUtil.getApplicationContext().getBean("directoryManager");
                WorkflowUserManager workflowUserManager = (WorkflowUserManager) AppUtil.getApplicationContext().getBean("workflowUserManager");
                User user = directoryManager.getUserByUsername(workflowUserManager.getCurrentUsername());
                String gmt = "";
                if (user != null) {
                    gmt = user.getTimeZone();
                }
                String format = AppUtil.getAppDateFormat();
                for (WorkflowAssignment assignment : assignmentList) {
                    Map data = new HashMap();
                    data.put("processId", assignment.getProcessId());
                    data.put("processRequesterId", assignment.getProcessRequesterId());
                    data.put("activityId", assignment.getActivityId());
                    data.put("processName", assignment.getProcessName());
                    data.put("activityName", assignment.getActivityName());
                    data.put("processVersion", assignment.getProcessVersion());
                    data.put("dateCreated", TimeZoneUtil.convertToTimeZone(assignment.getDateCreated(), gmt, format));
                    data.put("acceptedStatus", assignment.isAccepted());
                    data.put("dueDate", assignment.getDueDate() != null ? TimeZoneUtil.convertToTimeZone(assignment.getDueDate(), gmt, format) : "-");

                    double serviceLevelMonitor = workflowManager.getServiceLevelMonitorForRunningActivity(assignment.getActivityId());

                    data.put("serviceLevelMonitor", WorkflowUtil.getServiceLevelIndicator(serviceLevelMonitor));

                    // set results
                    resultList.add(data);
View Full Code Here


            return null;
        }
    }

    public int getDataTotalRowCount() {
        WorkflowManager workflowManager = (WorkflowManager) WorkflowUtil.getApplicationContext().getBean("workflowManager");

        String packageId = null;
        String processDefId = null;
        String appFilter = getPropertyString(PROPERTY_FILTER);
        if (PROPERTY_FILTER_ALL.equals(appFilter)) {
            AppDefinition appDef = AppUtil.getCurrentAppDefinition();
            if (appDef != null) {
                PackageDefinition packageDef = appDef.getPackageDefinition();
                if (packageDef != null) {
                    packageId = packageDef.getId();
                }
            }
        } else if (PROPERTY_FILTER_PROCESS.equals(appFilter)) {
            String processId = getPropertyString("processId");
            AppDefinition appDef = AppUtil.getCurrentAppDefinition();
            if (appDef != null && processId != null && !processId.isEmpty()) {
                ApplicationContext ac = AppUtil.getApplicationContext();
                AppService appService = (AppService) ac.getBean("appService");
                WorkflowProcess process = appService.getWorkflowProcessForApp(appDef.getId(), appDef.getVersion().toString(), processId);
                processDefId = process.getId();
            }
        }
        int count = 0;
       
        if (packageId != null || processDefId != null) {
            count = workflowManager.getAssignmentSize(packageId, processDefId, null);
        }
       
        return count;
    }
View Full Code Here

        String activityId = getRequestParameterString("activityId");

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

        Form form = null;
        WorkflowAssignment assignment = null;
        PackageActivityForm activityForm = null;
        FormData formData = new FormData();

        // get assignment by activity ID if available
        if (activityId != null && !activityId.trim().isEmpty()) {
            assignment = workflowManager.getAssignment(activityId);
        }

        if (assignment != null) {
            // load assignment form
            activityForm = retrieveAssignmentForm(formData, assignment);
View Full Code Here

        String activityId = getRequestParameterString("activityId");

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

        Form form = null;
        WorkflowAssignment assignment = null;
        FormData formData = new FormData();

        // get assignment by activity ID if available
        if (activityId != null && !activityId.trim().isEmpty()) {
            assignment = workflowManager.getAssignment(activityId);
        }

        if (assignment != null) {
            // load assignment form
            PackageActivityForm activityForm = retrieveAssignmentForm(formData, assignment);
View Full Code Here

    protected Form submitAssignmentForm(FormData formData, WorkflowAssignment assignment, PackageActivityForm activityForm) {
        Form nextForm = null;
        ApplicationContext ac = AppUtil.getApplicationContext();
        AppService appService = (AppService) ac.getBean("appService");
        FormService formService = (FormService) ac.getBean("formService");
        WorkflowManager workflowManager = (WorkflowManager) ac.getBean("workflowManager");
        String activityId = assignment.getActivityId();
        String processId = assignment.getProcessId();

        // get form
        Form currentForm = activityForm.getForm();

        // submit form
        formData = formService.executeFormActions(currentForm, formData);
       
        setProperty("submitted", Boolean.TRUE);
        setProperty("redirectUrlAfterComplete", getUrl());
        setRedirectUrl(getUrl());

        // check for validation errors
        if (formData.getFormResult(AssignmentWithdrawButton.DEFAULT_ID) != null) {
            // withdraw assignment
            workflowManager.assignmentWithdraw(activityId);
        } else if (formData.getFormResult(AssignmentCompleteButton.DEFAULT_ID) != null) {
            // complete assignment
            Map<String, String> variableMap = AppUtil.retrieveVariableDataFromMap(getRequestParameters());
            formData = appService.completeAssignmentForm(currentForm, assignment, formData, variableMap);
           
            Map<String, String> errors = formData.getFormErrors();
           
            if (errors.isEmpty() && activityForm.isAutoContinue()) {
                // redirect to next activity if available
                WorkflowAssignment nextActivity = workflowManager.getAssignmentByProcess(processId);
                if (nextActivity != null) {
                    String redirectUrl = getUrl() + "?_mode=assignment&activityId=" + nextActivity.getActivityId();
                    setProperty("messageShowAfterComplete", "");
                    setProperty("redirectUrlAfterComplete", redirectUrl);
                    setAlertMessage("");
View Full Code Here

            try {
                JSONArray jsonArray = new JSONArray();

                ApplicationContext ac = AppUtil.getApplicationContext();
                AppService appService = (AppService) ac.getBean("appService");
                WorkflowManager workflowManager = (WorkflowManager) ac.getBean("workflowManager");
                AppDefinition appDef = appService.getAppDefinition(appId, appVersion);
                PackageDefinition packageDefinition = appDef.getPackageDefinition();
                Long packageVersion = (packageDefinition != null) ? packageDefinition.getVersion() : new Long(1);
                Collection<WorkflowProcess> processList = workflowManager.getProcessList(appId, packageVersion.toString());

                Map<String, String> empty = new HashMap<String, String>();
                empty.put("value", "");
                empty.put("label", "");
                jsonArray.put(empty);
View Full Code Here

    public Object execute(Map properties) {
        Object result = null;
        try {
            final AuditTrail auditTrail = (AuditTrail) properties.get("auditTrail");
            final PluginManager pluginManager = (PluginManager) properties.get("pluginManager");
            final WorkflowManager workflowManager = (WorkflowManager) pluginManager.getBean("workflowManager");
            final WorkflowUserManager workflowUserManager = (WorkflowUserManager) pluginManager.getBean("workflowUserManager");
            final DirectoryManager directoryManager = (DirectoryManager) pluginManager.getBean("directoryManager");

            final String base = (String) properties.get("base");
            final String smtpHost = (String) properties.get("host");
            final String smtpPort = (String) properties.get("port");
            final String smtpUsername = (String) properties.get("username");
            final String smtpPassword = (String) properties.get("password");
            final String security = (String) properties.get("security");

            final String from = (String) properties.get("from");
            final String cc = (String) properties.get("cc");

            final String subject = (String) properties.get("subject");
            final String emailMessage = (String) properties.get("emailMessage");
           
            final String url = (String) properties.get("url");
            final String urlName = (String) properties.get("urlName");
            final String parameterName = (String) properties.get("parameterName");
            final String passoverMethod = (String) properties.get("passoverMethod");
            final String exclusion = (String) properties.get("exclusion");
            final String isHtml = (String) properties.get("isHtml");
            Map<String, String> replaceMap = null;
            if ("true".equalsIgnoreCase(isHtml)) {
                replaceMap = new HashMap<String, String>();
                replaceMap.put("\\n", "<br/>");
            }
            final Map<String, String> replace = replaceMap;
                   
            String appId = auditTrail.getAppId();
            String appVersion = auditTrail.getAppVersion();
            AppService appService = (AppService) AppUtil.getApplicationContext().getBean("appService");
            final AppDefinition appDef = appService.getAppDefinition(appId, appVersion);

            if (smtpHost == null || smtpHost.trim().length() == 0) {
                return null;
            }

            if (auditTrail != null && (auditTrail.getMethod().equals("createAssignments") || auditTrail.getMethod().equals("getDefaultAssignments") || auditTrail.getMethod().equals("assignmentReassign") || auditTrail.getMethod().equals("assignmentForceComplete"))) {
                final String profile = DynamicDataSourceManager.getCurrentProfile();
                new Thread(new Runnable() {

                    public void run() {
                        ThreadSessionUtil.initSession();
                        try {
                            HostManager.setCurrentProfile(profile);
                            List<String> userList = new ArrayList<String>();
                            String activityInstanceId = auditTrail.getMessage();
                           
                            int maxAttempt = 5;
                            int numOfAttempt = 0;
                            WorkflowActivity wfActivity = null;
                            while (userList != null && userList.isEmpty() && numOfAttempt < maxAttempt) {
                                //LogUtil.info(getClass().getName(), "Attempting to get resource ids....");
                                Thread.sleep(4000);
                                wfActivity = workflowManager.getActivityById(activityInstanceId);
                                userList = workflowManager.getAssignmentResourceIds(wfActivity.getProcessDefId(), wfActivity.getProcessId(), activityInstanceId);
                                numOfAttempt++;
                            }

                            Collection<String> exclusionIds = new ArrayList<String>();
                            if (exclusion != null && !exclusion.isEmpty()) {
                                exclusionIds.addAll(Arrays.asList(exclusion.split(";")));
                            }
                           
                            if (!exclusionIds.contains(WorkflowUtil.getProcessDefIdWithoutVersion(wfActivity.getProcessDefId()) + "-" + wfActivity.getActivityDefId())) {
                                LogUtil.info(UserNotificationAuditTrail.class.getName(), "Users to notify: " + userList);
                                if (userList != null) {
                                    for (String username : userList) {
                                        workflowUserManager.setCurrentThreadUser(username);
                                        WorkflowAssignment wfAssignment = workflowManager.getAssignment(activityInstanceId);
                                       
                                        Collection<String> addresses = AppUtil.getEmailList(null, username, null, null);
                                       
                                        if (addresses != null && addresses.size() > 0) {
                                            // create the email message
View Full Code Here

        String action = request.getParameter("action");
        String appId = request.getParameter("appId");
        String appVersion = request.getParameter("appVersion");
        ApplicationContext ac = AppUtil.getApplicationContext();
        AppService appService = (AppService) ac.getBean("appService");
        WorkflowManager workflowManager = (WorkflowManager) ac.getBean("workflowManager");
        AppDefinition appDef = appService.getAppDefinition(appId, appVersion);

        if ("getActivities".equals(action)) {
            try {
                JSONArray jsonArray = new JSONArray();
                PackageDefinition packageDefinition = appDef.getPackageDefinition();
                Long packageVersion = (packageDefinition != null) ? packageDefinition.getVersion() : new Long(1);
                Collection<WorkflowProcess> processList = workflowManager.getProcessList(appId, packageVersion.toString());

                if (processList != null && !processList.isEmpty()) {
                    for (WorkflowProcess p : processList) {
                        Collection<WorkflowActivity> activityList = workflowManager.getProcessActivityDefinitionList(p.getId());
                        for (WorkflowActivity a : activityList) {
                            if (!a.getType().equals(WorkflowActivity.TYPE_ROUTE) && !a.getType().equals(WorkflowActivity.TYPE_TOOL)) {
                                Map<String, String> option = new HashMap<String, String>();
                                option.put("value", p.getIdWithoutVersion() + "-" + a.getActivityDefId());
                                option.put("label", p.getName() + " - " + a.getName());
View Full Code Here

    protected void storeToWorkflowVariable(WorkflowAssignment wfAssignment, Map properties, Map object) {
        Object[] wfVariableMapping = (Object[]) properties.get("wfVariableMapping");
        if (wfVariableMapping != null && wfVariableMapping.length > 0) {
            ApplicationContext ac = AppUtil.getApplicationContext();
            WorkflowManager workflowManager = (WorkflowManager) ac.getBean("workflowManager");

            for (Object o : wfVariableMapping) {
                Map mapping = (HashMap) o;
                String variable = mapping.get("variable").toString();
                String jsonObjectName = mapping.get("jsonObjectName").toString();

                String value = (String) getObjectFromMap(jsonObjectName, object);

                if (value != null) {
                    workflowManager.activityVariable(wfAssignment.getActivityId(), variable, value);
                }
            }
        }
    }
View Full Code Here

            }

            // handle workflow variables
            String activityId = formData.getActivityId();
            String processId = formData.getProcessId();
            WorkflowManager workflowManager = (WorkflowManager) WorkflowUtil.getApplicationContext().getBean("workflowManager");
            Collection<WorkflowVariable> variableList = null;
            if (activityId != null && !activityId.isEmpty()) {
                variableList = workflowManager.getActivityVariableList(activityId);
            } else if (processId != null && !processId.isEmpty()) {
                variableList = workflowManager.getProcessVariableList(processId);
            } else {
                variableList = new ArrayList<WorkflowVariable>();
            }
            Map<String, String> variableMap = new HashMap<String, String>();
            for (WorkflowVariable variable : variableList) {
View Full Code Here

TOP

Related Classes of org.joget.workflow.model.service.WorkflowManager

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.