Search in sources :

Example 21 with ProcessInstanceVO

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

the class LogWatcher method startup.

public void startup(boolean watchProcess) {
    this.watchProcess = watchProcess;
    if (logListener != null)
        // already started
        return;
    pattern = Pattern.compile(MESSAGE_REG_EX, Pattern.DOTALL);
    processInstancePages = new HashMap<Long, ProcessInstancePage>();
    processInstances = new HashMap<Long, ProcessInstanceVO>();
    accumulated = new LinkedList<ProcessInstanceUpdater>();
    scheduleShutdown = false;
    MessageConsole console = MessageConsole.findConsole("Live View Log", icon, display);
    console.setRunnableEntity(this);
    console.setDefaultShowPref(true);
    console.setStatus(MessageConsole.STATUS_RUNNING);
    console.clearConsole();
    outputStream = console.newMessageStream();
    try {
        dataAccess = new DesignerDataAccess(process.getProject().getDesignerProxy().getDesignerDataAccess());
        logListener = new LogSubscriberSocket(dataAccess, serverSettings.getLogWatcherPort(), process.getProject().isOldNamespaces()) {

            protected void handleMessage(String message) {
                handleLogMessage(message);
            }
        };
        logListener.start(true);
        new Thread(new Runnable() {

            public void run() {
                processQueue();
            }
        }).start();
    } catch (Exception ex) {
        if (outputStream != null)
            ex.printStackTrace(new PrintStream(outputStream));
        if (logListener != null && !logListener.isClosed()) {
            logListener.shutdown();
            logListener = null;
        }
        PluginMessages.uiError(ex, "Monitor Logs", process.getProject());
    }
}
Also used : PrintStream(java.io.PrintStream) MessageConsole(com.centurylink.mdw.plugin.MessageConsole) IOException(java.io.IOException) LogSubscriberSocket(com.centurylink.mdw.designer.runtime.LogSubscriberSocket) ProcessInstancePage(com.centurylink.mdw.designer.runtime.ProcessInstancePage) DesignerDataAccess(com.centurylink.mdw.designer.DesignerDataAccess) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 22 with ProcessInstanceVO

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

the class ImageServletHelper method generateImageForTaskInstance.

/**
 * Generate a process image from the designer server.
 */
public BufferedImage generateImageForTaskInstance(Long pTaskInstId) throws ServletException {
    try {
        DesignerDataAccess dao = new DesignerDataAccess(new Server(), null, onServer);
        ProcessInstanceVO pi = dao.getCauseForTaskInstance(pTaskInstId);
        if (pi == null) {
            throw new ServletException("Failed to locate the ProcessInstance for TaskInstanceId:" + pTaskInstId);
        }
        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 23 with ProcessInstanceVO

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

the class WorkflowImageHelper method generateImage.

/**
 * Generate a process instance image.
 */
private BufferedImage generateImage(DesignerDataAccess dao) throws Exception {
    NodeMetaInfo metainfo = new NodeMetaInfo();
    metainfo.init(dao.getActivityImplementors(), DataAccess.currentSchemaVersion);
    new ProcessWorker().convert_to_designer(process);
    IconFactory iconFactory = new IconFactory();
    iconFactory.setDesignerDataAccess(dao);
    Graph graph = null;
    Node selectedNode = null;
    if (processInstance != null) {
        processInstance.setProcessName(process.getProcessName());
        graph = new Graph(process, processInstance, metainfo, iconFactory);
        graph.setStatus(new StringBuffer());
        if (embeddedInstances != null) {
            for (ProcessInstanceVO embeddedInstance : embeddedInstances) {
                if (embeddedInstance.getStatusCode() == null && embeddedInstance.getStatus() != null)
                    embeddedInstance.setStatusCode(WorkStatuses.getCode(embeddedInstance.getStatus()));
                Long embeddedProcId = new Long(embeddedInstance.getComment());
                SubGraph subgraph = graph.getSubGraph(embeddedProcId);
                if (subgraph != null) {
                    List<ProcessInstanceVO> insts = subgraph.getInstances();
                    if (insts == null) {
                        insts = new ArrayList<ProcessInstanceVO>();
                        subgraph.setInstances(insts);
                    }
                    insts.add(embeddedInstance);
                }
            }
            for (SubGraph subgraph : graph.subgraphs) subgraph.setStatus(new StringBuffer());
        }
        if (selectedActivityInstanceId != null) {
            ActivityInstanceVO selectedInstance = processInstance.getActivity(selectedActivityInstanceId);
            if (selectedInstance == null) {
                for (SubGraph subgraph : graph.subgraphs) {
                    if (subgraph.getInstances() != null) {
                        for (ProcessInstanceVO subinst : subgraph.getInstances()) {
                            selectedInstance = subinst.getActivity(selectedActivityInstanceId);
                            if (selectedInstance != null)
                                break;
                        }
                    }
                    if (selectedInstance != null)
                        break;
                }
            }
            if (selectedInstance != null)
                selectedNode = graph.getNode("A" + selectedInstance.getDefinitionId());
        }
    } else {
        graph = new Graph(process, metainfo, iconFactory);
        if (selectedActivity != null)
            selectedNode = graph.getNode(selectedActivity);
    }
    Dimension graphsize = graph.getGraphSize();
    WorkflowImage canvas = new WorkflowImage(graph, dao);
    if (selectedNode != null)
        canvas.setSelectedObject(selectedNode);
    int h_margin = 72, v_margin = 72;
    BufferedImage image = new BufferedImage(graphsize.width + h_margin, graphsize.height + v_margin, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = image.createGraphics();
    canvas.paintComponent(g2);
    g2.dispose();
    return image;
}
Also used : NodeMetaInfo(com.centurylink.mdw.designer.utils.NodeMetaInfo) ActivityInstanceVO(com.centurylink.mdw.model.value.work.ActivityInstanceVO) Dimension(java.awt.Dimension) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) ProcessWorker(com.centurylink.mdw.designer.utils.ProcessWorker) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) IconFactory(com.centurylink.mdw.designer.icons.IconFactory)

Example 24 with ProcessInstanceVO

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

the class ProcessInstanceSection method setSelection.

@Override
public void setSelection(WorkflowElement selection) {
    process = (WorkflowProcess) selection;
    ProcessInstanceVO instanceInfo = process.getProcessInstance();
    idPropertyEditor.setElement(process);
    idPropertyEditor.setValue(instanceInfo.getId());
    masterRequestIdPropertyEditor.setElement(process);
    masterRequestIdPropertyEditor.setValue(instanceInfo.getMasterRequestId());
    statusPropertyEditor.setElement(process);
    statusPropertyEditor.setValue(WorkStatuses.getWorkStatuses().get(instanceInfo.getStatusCode()));
    ownerPropertyEditor.setElement(process);
    ownerPropertyEditor.setValue(instanceInfo.getOwner());
    ownerIdPropertyEditor.setElement(process);
    ownerIdPropertyEditor.setValue(instanceInfo.getOwnerId());
    startDatePropertyEditor.setElement(process);
    if (instanceInfo.getStartDate() != null)
        startDatePropertyEditor.setValue(instanceInfo.getStartDate());
    endDatePropertyEditor.setElement(process);
    if (instanceInfo.getEndDate() != null)
        endDatePropertyEditor.setValue(instanceInfo.getEndDate());
    processLabelPropertyEditor.setElement(process);
    if (instanceInfo.getComment() != null)
        processLabelPropertyEditor.setValue(instanceInfo.getComment());
}
Also used : ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 25 with ProcessInstanceVO

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

the class ProcessExplorerActionGroup method createOpenInstanceAction.

private IAction createOpenInstanceAction() {
    IAction action = new Action() {

        @Override
        public void run() {
            if (openInstanceApplies(getSelection())) {
                WorkflowProject project = ((WorkflowElement) getSelection().getFirstElement()).getProject();
                try {
                    Long procInstId = null;
                    if (getSelection().getFirstElement() instanceof AutomatedTestResults) {
                        AutomatedTestResults expectedResults = (AutomatedTestResults) getSelection().getFirstElement();
                        procInstId = expectedResults.getActualProcessInstanceId();
                    } else if (getSelection().getFirstElement() instanceof LegacyExpectedResults) {
                        LegacyExpectedResults expectedResult = (LegacyExpectedResults) getSelection().getFirstElement();
                        java.io.File resultsFile = expectedResult.getActualResultFile();
                        TestFile testFile = new TestFile(null, resultsFile.getPath());
                        testFile.load();
                        TestFileLine line1 = testFile.getLines().get(0);
                        procInstId = new Long(line1.getWord(3));
                    }
                    if (procInstId == null) {
                        MessageDialog.openWarning(view.getSite().getShell(), "No Results", "Unable to locate results file.");
                        return;
                    }
                    ProcessInstanceVO procInst = project.getDataAccess().getProcessInstance(procInstId);
                    Long processId = procInst.getProcessId();
                    ProcessVO procVO = project.getProcess(processId).getProcessVO();
                    if (procVO == null)
                        PluginMessages.uiError("Unable to locate process: " + processId, OPEN_PROCESS_INSTANCE, project);
                    WorkflowProcess instance = new WorkflowProcess(project, procVO);
                    instance.setProcessInstance(procInst);
                    actionHandler.open(instance);
                } catch (Exception ex) {
                    PluginMessages.uiError(ex, OPEN_PROCESS_INSTANCE, project);
                }
            }
        }
    };
    action.setText(OPEN_PROCESS_INSTANCE);
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + OPEN_PROCESS_INSTANCE);
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor(ICON_PROCESS_GIF);
    action.setImageDescriptor(imageDesc);
    return action;
}
Also used : WebLaunchAction(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction) IAction(org.eclipse.jface.action.IAction) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) TestFileLine(com.centurylink.mdw.designer.testing.TestFileLine) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) AutomatedTestResults(com.centurylink.mdw.plugin.designer.model.AutomatedTestResults) PartInitException(org.eclipse.ui.PartInitException) ConnectException(java.net.ConnectException) NamingException(javax.naming.NamingException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) RemoteException(java.rmi.RemoteException) TestFile(com.centurylink.mdw.designer.testing.TestFile) LegacyExpectedResults(com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IFile(org.eclipse.core.resources.IFile) TestFile(com.centurylink.mdw.designer.testing.TestFile) File(com.centurylink.mdw.plugin.designer.model.File) JarFile(com.centurylink.mdw.plugin.designer.model.JarFile) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Aggregations

ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)40 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)10 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)9 IOException (java.io.IOException)9 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)7 HashMap (java.util.HashMap)7 DesignerDataAccess (com.centurylink.mdw.designer.DesignerDataAccess)6 ActivityInstanceVO (com.centurylink.mdw.model.value.work.ActivityInstanceVO)6 ArrayList (java.util.ArrayList)6 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)5 ProcessList (com.centurylink.mdw.model.value.process.ProcessList)5 XmlException (org.apache.xmlbeans.XmlException)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 JSONException (org.json.JSONException)5 Graph (com.centurylink.mdw.designer.display.Graph)4 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)4 Menu (org.eclipse.swt.widgets.Menu)4 MenuItem (org.eclipse.swt.widgets.MenuItem)4 PartInitException (org.eclipse.ui.PartInitException)4