Package org.joget.report.service

Examples of org.joget.report.service.ReportManager


    protected ReportWorkflowProcessInstance updateProcessData(WorkflowProcess wfProcess, WorkflowProcess wfTrackProcess, String appId, String appVersion) {
        String processInstanceId = wfProcess.getInstanceId();

        WorkflowManager workflowManager = (WorkflowManager) AppUtil.getApplicationContext().getBean("workflowManager");
        ReportManager reportManager = (ReportManager) AppUtil.getApplicationContext().getBean("reportManager");
        AppService appService = (AppService) AppUtil.getApplicationContext().getBean("appService");

        if (wfTrackProcess != null) {
            ReportWorkflowProcessInstance pInstance = reportManager.getReportWorkflowProcessInstance(processInstanceId);
            if (pInstance == null) {
                pInstance = new ReportWorkflowProcessInstance();
                pInstance.setInstanceId(processInstanceId);

                //get app
                AppDefinition appDef = appService.getAppDefinition(appId, appVersion);
                ReportApp reportApp = reportManager.getReportApp(appId, appVersion, appDef.getName());

                //get package
                ReportWorkflowPackage reportPackage = reportManager.getReportWorkflowPackage(reportApp, wfProcess.getPackageId(), wfProcess.getVersion(), wfProcess.getName());

                //get process
                ReportWorkflowProcess reportProcess = reportManager.getReportWorkflowProcess(reportPackage, wfProcess.getIdWithoutVersion(), wfProcess.getName());
                pInstance.setReportWorkflowProcess(reportProcess);
            }

            pInstance.setRequester(wfTrackProcess.getRequesterId());
            pInstance.setState(wfProcess.getState());
            pInstance.setDue(wfTrackProcess.getDue());
            pInstance.setStartedTime(wfTrackProcess.getStartedTime());
            pInstance.setFinishTime(wfTrackProcess.getFinishTime());
            pInstance.setDelay(wfTrackProcess.getDelayInSeconds());
            pInstance.setTimeConsumingFromStartedTime(wfTrackProcess.getTimeConsumingFromDateStartedInSeconds());

            reportManager.saveReportWorkflowProcessInstance(pInstance);

            return reportManager.getReportWorkflowProcessInstance(processInstanceId);
        }
        return null;
    }
View Full Code Here


    protected ReportWorkflowActivityInstance updateActivityData(WorkflowActivity wfActivity, WorkflowActivity wfTrackActivity, WorkflowProcess wfProcess, WorkflowProcess wfTrackProcess, String appId, String appVersion) {
        String activityInstanceId = wfActivity.getId();

        WorkflowManager workflowManager = (WorkflowManager) AppUtil.getApplicationContext().getBean("workflowManager");
        ReportManager reportManager = (ReportManager) AppUtil.getApplicationContext().getBean("reportManager");
       
        if (wfActivity != null) {
            ReportWorkflowActivityInstance aInstance = reportManager.getReportWorkflowActivityInstance(activityInstanceId);
            List<String> userList = new ArrayList<String>();
            if (aInstance == null) {
                aInstance = new ReportWorkflowActivityInstance();
                aInstance.setInstanceId(activityInstanceId);

                //set process Instance
                String processInstanceId = wfActivity.getProcessId();

                ReportWorkflowProcessInstance processInstance = reportManager.getReportWorkflowProcessInstance(processInstanceId);
                if (processInstance == null) {
                    processInstance = updateProcessData(wfProcess, wfTrackProcess, appId, appVersion);
                }
                aInstance.setReportWorkflowProcessInstance(processInstance);

                //set activity
                ReportWorkflowActivity reportActivtiy = reportManager.getReportWorkflowActivity(processInstance.getReportWorkflowProcess(), wfActivity.getActivityDefId(), wfActivity.getName());
                aInstance.setReportWorkflowActivity(reportActivtiy);

                //get assignment users
                try {
                    Thread.sleep(2000);
                    int maxAttempt = 5;
                    int numOfAttempt = 0;
                    while ((userList == null || userList.isEmpty()) && numOfAttempt < maxAttempt) {
                        LogUtil.debug(getClass().getName(), "Attempting to get resource ids....");
                        userList = workflowManager.getAssignmentResourceIds(wfActivity.getProcessDefId(), wfActivity.getProcessId(), activityInstanceId);
                        Thread.sleep(2000);
                        numOfAttempt++;
                    }

                    LogUtil.debug(getClass().getName(), "Resource ids=" + userList);
                } catch (Exception e) {
                    LogUtil.error(getClass().getName(), e, "Error executing report plugin");
                }
            } else {
                userList = workflowManager.getAssignmentResourceIds(wfActivity.getProcessDefId(), wfActivity.getProcessId(), activityInstanceId);
            }

            String assignmentUsers = "";
            if (userList != null) {
                for (String username : userList) {
                    assignmentUsers += username + ",";
                }
            }
            if (assignmentUsers.endsWith(",")) {
                assignmentUsers = assignmentUsers.substring(0, assignmentUsers.length() - 1);
            }
            aInstance.setAssignmentUsers(assignmentUsers);

            aInstance.setPerformer(wfTrackActivity.getPerformer());
            aInstance.setNameOfAcceptedUser(wfTrackActivity.getNameOfAcceptedUser());
            aInstance.setState(wfActivity.getState());
            aInstance.setStatus(wfTrackActivity.getStatus());
            aInstance.setDue(wfTrackActivity.getDue());
            aInstance.setCreatedTime(wfTrackActivity.getCreatedTime());
            aInstance.setStartedTime(wfTrackActivity.getStartedTime());
            aInstance.setFinishTime(wfTrackActivity.getFinishTime());
            aInstance.setDelay(wfTrackActivity.getDelayInSeconds());
            aInstance.setTimeConsumingFromCreatedTime(wfTrackActivity.getTimeConsumingFromDateCreatedInSeconds());
            aInstance.setTimeConsumingFromStartedTime(wfTrackActivity.getTimeConsumingFromDateStartedInSeconds());

            reportManager.saveReportWorkflowActivityInstance(aInstance);

            return null;
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.joget.report.service.ReportManager

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.