Search in sources :

Example 1 with DesignerDataAccess

use of com.centurylink.mdw.designer.DesignerDataAccess in project mdw-designer by CenturyLinkCloud.

the class ImageServletHelper method generateImageForProcessInstance.

/**
 * Generate a process image from the designer server.
 */
public BufferedImage generateImageForProcessInstance(Long pProcInstId) throws ServletException {
    try {
        DesignerDataAccess dao = new DesignerDataAccess(new Server(), null, onServer);
        ProcessInstanceVO pi = dao.getProcessInstanceBase(pProcInstId, null);
        if (pi == null) {
            throw new ServletException("Failed to locate the ProcessInstance for ProcessInstanceId:" + pProcInstId);
        }
        return generateImage(pi, dao);
    } catch (Exception ex) {
        log(ex);
        throw new ServletException(ex);
    }
}
Also used : ServletException(javax.servlet.ServletException) Server(com.centurylink.mdw.designer.utils.Server) DesignerDataAccess(com.centurylink.mdw.designer.DesignerDataAccess) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) ServletException(javax.servlet.ServletException)

Example 2 with DesignerDataAccess

use of com.centurylink.mdw.designer.DesignerDataAccess in project mdw-designer by CenturyLinkCloud.

the class ImageServletHelper method generateImageForSecondaryOwner.

/**
 * Generate a process image from the designer server.
 */
public BufferedImage generateImageForSecondaryOwner(String pSecOwner, Long pSecOwnerId) throws ServletException {
    try {
        DesignerDataAccess dao = new DesignerDataAccess(new Server(), null, onServer);
        ProcessInstanceVO pi = dao.getProcessInstanceForSecondary(pSecOwner, pSecOwnerId);
        if (pi == null) {
            throw new ServletException("Failed to locate the ProcessInstance for Secondary Owner and OwnerId");
        }
        return generateImage(pi, dao);
    } catch (Exception ex) {
        log(ex);
        throw new ServletException(ex);
    }
}
Also used : ServletException(javax.servlet.ServletException) Server(com.centurylink.mdw.designer.utils.Server) DesignerDataAccess(com.centurylink.mdw.designer.DesignerDataAccess) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) ServletException(javax.servlet.ServletException)

Example 3 with DesignerDataAccess

use of com.centurylink.mdw.designer.DesignerDataAccess in project mdw-designer by CenturyLinkCloud.

the class WorkflowImageHelper method getProcessImage.

/**
 * Generate a process instance image.
 */
public BufferedImage getProcessImage() throws Exception {
    VersionControl vc = DataAccess.getAssetVersionControl(ApplicationContext.getAssetRoot());
    String serviceUrl = ApplicationContext.getServicesUrl();
    RestfulServer restfulServer = new RestfulServer("jdbc://dummy", "mdwapp", serviceUrl);
    restfulServer.setVersionControl(vc);
    restfulServer.setRootDirectory(ApplicationContext.getAssetRoot());
    DesignerDataAccess dao = new DesignerDataAccess(restfulServer, null, "mdwapp");
    // clone the process since it'll be converted to Designer
    Long processId = process.getId();
    process = new ProcessVO(process);
    process.setId(processId);
    return generateImage(dao);
}
Also used : ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) RestfulServer(com.centurylink.mdw.designer.utils.RestfulServer) DesignerDataAccess(com.centurylink.mdw.designer.DesignerDataAccess) VersionControl(com.centurylink.mdw.dataaccess.VersionControl)

Example 4 with DesignerDataAccess

use of com.centurylink.mdw.designer.DesignerDataAccess 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 5 with DesignerDataAccess

use of com.centurylink.mdw.designer.DesignerDataAccess 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

DesignerDataAccess (com.centurylink.mdw.designer.DesignerDataAccess)15 IOException (java.io.IOException)10 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)6 Server (com.centurylink.mdw.designer.utils.Server)5 JSONException (org.json.JSONException)5 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)4 HashMap (java.util.HashMap)4 AuthenticationException (com.centurylink.mdw.auth.AuthenticationException)3 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)3 TranslationException (com.centurylink.mdw.common.exception.TranslationException)3 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)3 RestfulServer (com.centurylink.mdw.designer.utils.RestfulServer)3 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)3 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 VersionControl (com.centurylink.mdw.dataaccess.VersionControl)2 ProcessInstancePage (com.centurylink.mdw.designer.runtime.ProcessInstancePage)2 RuleSetVO (com.centurylink.mdw.model.value.attribute.RuleSetVO)2 ProcessList (com.centurylink.mdw.model.value.process.ProcessList)2 RemoteException (java.rmi.RemoteException)2