Search in sources :

Example 21 with ProcessVO

use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.

the class DesignerPage method saveProcess.

/**
 * Saves and then reload the process graph
 */
public Graph saveProcess(Graph process, MainFrame frame, PersistType persistType, int version, boolean lock) throws ValidationException, DataAccessException, RemoteException {
    String processId = saveProcess(process, persistType, version, lock);
    if (processId == null)
        throw new ValidationException("Error in saving process");
    // load process again
    ProcessVO procdef = process.getProcessVO();
    if (persistType == PersistType.CREATE) {
        procdef.setProcessId(new Long(processId));
        procdef = loadProcess(procdef);
    } else if (persistType == PersistType.NEW_VERSION) {
        procdef = frame.dao.getProcess(new Long(processId), procdef);
        // procdef is overridden with the new version here
        new ProcessWorker().convert_to_designer(procdef);
        model.addProcess(procdef);
    } else {
        procdef = loadProcess(procdef);
    }
    process.reinit(procdef);
    return process;
}
Also used : ValidationException(com.centurylink.mdw.designer.utils.ValidationException) ProcessWorker(com.centurylink.mdw.designer.utils.ProcessWorker) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO)

Example 22 with ProcessVO

use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.

the class DesignerPage method saveProcess.

/**
 * @param graph
 * @return process ID if saving is successful; null o/w
 */
private String saveProcess(Graph graph, PersistType persistType, int version, boolean lock) throws ValidationException {
    String processId = null;
    ProcessVO process = graph.getProcessVO();
    int currentVersion = process.getVersion();
    try {
        frame.log("Saving process " + process.getProcessName() + " ...");
        new ProcessWorker().convert_from_designer(process, model.getNodeMetaInfo());
        if (persistType == PersistType.CREATE) {
            processId = frame.dao.createProcess(process);
        } else {
            processId = frame.dao.updateProcess(process, version, lock);
            process.setVersion(currentVersion);
        // keep the version number
        }
        graph.setDirtyLevel(Graph.CLEAN);
        graph.setReadonly(true);
        graph.getProcessVO().clearDeletedTransitions();
    } catch (Exception e) {
        // TODO better not to convert back - keep the original
        new ProcessWorker().convert_to_designer(process);
        process.setVersion(currentVersion);
        e.printStackTrace();
        throw new ValidationException(e.getCause() == null ? e.getMessage() : e.getCause().getMessage());
    }
    return processId;
}
Also used : ValidationException(com.centurylink.mdw.designer.utils.ValidationException) ProcessWorker(com.centurylink.mdw.designer.utils.ProcessWorker) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) RemoteException(java.rmi.RemoteException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException)

Example 23 with ProcessVO

use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.

the class DesignerPage method setProcessVersion.

private void setProcessVersion(Node node, boolean includeId) {
    String procname = node.getAttribute(WorkAttributeConstant.PROCESS_NAME);
    if (procname != null) {
        ProcessVO procdef = findProcessDefinition(procname, 0);
        if (procdef != null) {
            node.setAttribute(WorkAttributeConstant.PROCESS_VERSION, Integer.toString(procdef.getVersion()));
            if (includeId)
                node.setAttribute("process_id", procdef.getProcessId().toString());
            node.setAttribute(WorkAttributeConstant.ALIAS_PROCESS_ID, null);
        }
    }
}
Also used : ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO)

Example 24 with ProcessVO

use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method loadProcessInstance.

public RunTimeDesignerCanvas loadProcessInstance(WorkflowProcess processVersion, ProcessInstancePage processInstancePage) {
    CodeTimer timer = new CodeTimer("loadProcessInstance()");
    ProcessInstanceVO processInstanceInfo = processVersion.getProcessInstance();
    ProcessInstanceLoader instanceLoadThread = new ProcessInstanceLoader(processInstanceInfo, processInstancePage);
    String errorMessage = null;
    try {
        Graph processGraph = dataAccess.getDesignerDataModel().findProcessGraph(processVersion.getId(), null);
        if (processGraph == null)
            processGraph = processInstancePage.loadProcess(processInstanceInfo.getProcessId(), null);
        processVersion.setProcessVO(processGraph.getProcessVO());
        DesignerDataAccess dao = processVersion.getDesignerDataAccess() == null ? processInstancePage.frame.dao : processVersion.getDesignerDataAccess();
        Graph procInstGraph = instanceLoadThread.loadCompletionMap(processGraph.getProcessVO(), processInstanceInfo, dao);
        ProcessInstanceTreeModel model = instanceLoadThread.createOrUpdateModel(null);
        model.getCurrentProcess().setGraph(procInstGraph);
        processInstancePage.setData(model, processInstancePage);
        Map<Long, List<TaskInstanceVO>> taskInstances = new HashMap<>();
        // embedded subprocesses
        List<ProcessInstanceVO> embeddedSubs = new ArrayList<>();
        if (procInstGraph.subgraphs != null) {
            for (SubGraph instSubGraph : procInstGraph.subgraphs) {
                if (instSubGraph.getInstances() != null) {
                    if (instSubGraph.nodes != null) {
                        List<Long> taskActivityIds = new ArrayList<>();
                        for (Node node : instSubGraph.nodes) {
                            if (node.isTaskActivity()) {
                                for (ProcessInstanceVO embeddedProcInst : instSubGraph.getInstances()) {
                                    if (!embeddedProcInst.getActivityInstances(node.getActivityId()).isEmpty())
                                        taskActivityIds.add(node.getActivityId());
                                }
                            }
                        }
                        if (!taskActivityIds.isEmpty()) {
                            for (ProcessInstanceVO embeddedProcInst : instSubGraph.getInstances()) {
                                ProcessVO embeddedProc = instSubGraph.getGraph().getProcessVO();
                                Map<Long, List<TaskInstanceVO>> embeddedTaskInsts = dao.getTaskInstances(embeddedProc, embeddedProcInst, taskActivityIds);
                                for (Map.Entry<Long, List<TaskInstanceVO>> embeddedTaskInst : embeddedTaskInsts.entrySet()) {
                                    if (taskInstances.get(embeddedTaskInst.getKey()) == null)
                                        taskInstances.put(embeddedTaskInst.getKey(), new ArrayList<TaskInstanceVO>());
                                    taskInstances.get(embeddedTaskInst.getKey()).addAll(embeddedTaskInst.getValue());
                                }
                            }
                        }
                    }
                    embeddedSubs.addAll(instSubGraph.getInstances());
                }
            }
        }
        processVersion.setEmbeddedSubProcessInstances(embeddedSubs);
        // manual task instances
        if (processGraph.nodes != null) {
            List<Long> taskActivityIds = new ArrayList<>();
            for (Node node : processGraph.nodes) {
                if (node.isTaskActivity() && !processInstanceInfo.getActivityInstances(node.getActivityId()).isEmpty())
                    taskActivityIds.add(node.getActivityId());
            }
            if (!taskActivityIds.isEmpty()) {
                Map<Long, List<TaskInstanceVO>> taskInsts = dao.getTaskInstances(processVersion.getProcessVO(), processInstanceInfo, taskActivityIds);
                for (Map.Entry<Long, List<TaskInstanceVO>> taskInst : taskInsts.entrySet()) {
                    if (taskInstances.get(taskInst.getKey()) == null)
                        taskInstances.put(taskInst.getKey(), new ArrayList<TaskInstanceVO>());
                    taskInstances.get(taskInst.getKey()).addAll(taskInst.getValue());
                }
            }
        }
        processVersion.setTaskInstances(taskInstances);
    } catch (Exception ex) {
        PluginMessages.log(ex);
        errorMessage = PluginMessages.getUserMessage(ex);
    }
    if (errorMessage == null)
        errorMessage = instanceLoadThread.getErrorMessage();
    if (errorMessage != null) {
        PluginMessages.uiError(errorMessage, "Load Process Instance");
    }
    timer.stopAndLog();
    return processInstancePage.canvas;
}
Also used : HashMap(java.util.HashMap) Node(com.centurylink.mdw.designer.display.Node) ProcessInstanceTreeModel(com.centurylink.mdw.designer.runtime.ProcessInstanceTreeModel) ArrayList(java.util.ArrayList) ProcessInstanceLoader(com.centurylink.mdw.designer.runtime.ProcessInstanceLoader) JSONException(org.json.JSONException) TranslationException(com.centurylink.mdw.common.exception.TranslationException) AuthenticationException(com.centurylink.mdw.auth.AuthenticationException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ZipException(java.util.zip.ZipException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) ArrayList(java.util.ArrayList) List(java.util.List) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) DesignerDataAccess(com.centurylink.mdw.designer.DesignerDataAccess) CodeTimer(com.centurylink.mdw.plugin.CodeTimer) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Map(java.util.Map) HashMap(java.util.HashMap) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 25 with ProcessVO

use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method prepareTestCase.

public TestCaseRun prepareTestCase(AutomatedTestCase testCase, int runNum, File resultDir, boolean createReplace, boolean verbose, PrintStream log, LogMessageMonitor monitor, boolean singleServer, boolean stubbing, boolean debug) throws RemoteException {
    if ((testCase.isGroovy() || testCase.isGherkin()) && !MdwPlugin.workspaceHasGroovySupport()) {
        String msg = "Please install Groovy support to execute test case: " + testCase.getName();
        throw new IllegalStateException(msg);
    }
    SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd-HHmmssSSS");
    try {
        if (!testCase.isLegacy() && !testCase.getProject().isFilePersist()) {
            // non-VCS asset-based -- load ruleSet content
            testCase.load();
            testCase.getRuleSetVO().setPackageName(testCase.getPackage().getName());
        }
        testCase.getTestCase().prepare();
        Map<String, ProcessVO> procCache = new HashMap<>();
        String masterRequestId = testCase.getMasterRequestId();
        if (masterRequestId == null)
            masterRequestId = project.getUser().getUsername() + "-" + sdf.format(new Date());
        else if (!testCase.isGroovy() && !testCase.isGherkin() && masterRequestId.equals(TestDataFilter.AnyNumberToken))
            masterRequestId = Long.toString(System.currentTimeMillis());
        if (testCase.isGherkin() && masterRequestId.indexOf("${masterRequestId}") != -1)
            masterRequestId = masterRequestId.replace("${masterRequestId}", project.getUser().getUsername() + "-" + sdf.format(new Date()));
        testCase.setMasterRequestId(masterRequestId);
        TestCaseRun run;
        if (testCase.isGherkin()) {
            run = new GherkinTestCaseLaunch(testCase.getTestCase(), runNum, masterRequestId, new DesignerDataAccess(dataAccess.getDesignerDataAccess()), monitor, procCache, testCase.isLoadTest(), true, testCase.getProject().isOldNamespaces(), project);
        } else if (testCase.isGroovy()) {
            if (debug) {
                run = new AutoTestCaseRun(testCase, runNum, masterRequestId, new DesignerDataAccess(dataAccess.getDesignerDataAccess()), monitor, procCache, debug);
            } else {
                List<String> classpathList = null;
                IJavaProject javaProject = project.getJavaProject();
                if (javaProject != null && javaProject.exists()) {
                    classpathList = Arrays.asList(JavaRuntime.computeDefaultRuntimeClassPath(javaProject));
                }
                run = new GroovyTestCaseRun(testCase.getTestCase(), runNum, masterRequestId, new DesignerDataAccess(dataAccess.getDesignerDataAccess()), monitor, procCache, testCase.isLoadTest(), true, testCase.getProject().isOldNamespaces(), classpathList);
            }
        } else {
            run = new TestCaseRun(testCase.getTestCase(), runNum, masterRequestId, new DesignerDataAccess(dataAccess.getDesignerDataAccess()), monitor, procCache, testCase.isLoadTest(), true, testCase.getProject().isOldNamespaces());
        }
        run.prepareTest(createReplace, resultDir, verbose, singleServer, stubbing, log);
        return run;
    } catch (Exception ex) {
        throw new RemoteException(ex.getMessage(), ex);
    }
}
Also used : HashMap(java.util.HashMap) GherkinTestCaseLaunch(com.centurylink.mdw.plugin.launch.GherkinTestCaseLaunch) GroovyTestCaseRun(com.centurylink.mdw.designer.testing.GroovyTestCaseRun) Date(java.util.Date) JSONException(org.json.JSONException) TranslationException(com.centurylink.mdw.common.exception.TranslationException) AuthenticationException(com.centurylink.mdw.auth.AuthenticationException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ZipException(java.util.zip.ZipException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) IJavaProject(org.eclipse.jdt.core.IJavaProject) AutoTestCaseRun(com.centurylink.mdw.plugin.launch.AutoTestCaseRun) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) ArrayList(java.util.ArrayList) List(java.util.List) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) DesignerDataAccess(com.centurylink.mdw.designer.DesignerDataAccess) TestCaseRun(com.centurylink.mdw.designer.testing.TestCaseRun) AutoTestCaseRun(com.centurylink.mdw.plugin.launch.AutoTestCaseRun) GroovyTestCaseRun(com.centurylink.mdw.designer.testing.GroovyTestCaseRun) RemoteException(java.rmi.RemoteException) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)92 ArrayList (java.util.ArrayList)29 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)28 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)25 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)17 IOException (java.io.IOException)17 HashMap (java.util.HashMap)15 RemoteException (java.rmi.RemoteException)14 ProcessWorker (com.centurylink.mdw.designer.utils.ProcessWorker)12 ActivityVO (com.centurylink.mdw.model.value.activity.ActivityVO)11 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)11 JSONException (org.json.JSONException)11 RuleSetVO (com.centurylink.mdw.model.value.attribute.RuleSetVO)10 XmlException (org.apache.xmlbeans.XmlException)10 ActivityImplementorVO (com.centurylink.mdw.model.value.activity.ActivityImplementorVO)9 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)9 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)8 ExternalEventVO (com.centurylink.mdw.model.value.event.ExternalEventVO)8 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)7 AuthenticationException (com.centurylink.mdw.auth.AuthenticationException)5