Search in sources :

Example 56 with WorkflowProcess

use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.

the class ProcessInstanceListView method createContextMenu.

private Menu createContextMenu(Shell shell) {
    Menu menu = new Menu(shell, SWT.POP_UP);
    final StructuredSelection selection = (StructuredSelection) getTableViewer().getSelection();
    if (selection.size() == 1 && selection.getFirstElement() instanceof ProcessInstanceVO) {
        final ProcessInstanceVO processInstanceInfo = (ProcessInstanceVO) selection.getFirstElement();
        // open instance
        MenuItem openItem = new MenuItem(menu, SWT.PUSH);
        openItem.setText("Open");
        ImageDescriptor openImageDesc = MdwPlugin.getImageDescriptor("icons/process.gif");
        openItem.setImage(openImageDesc.createImage());
        openItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                handleOpen(processInstanceInfo);
            }
        });
        // owning document
        if (OwnerType.DOCUMENT.equals(processInstanceInfo.getOwner()) || OwnerType.TESTER.equals(processInstanceInfo.getOwner())) {
            MenuItem docItem = new MenuItem(menu, SWT.PUSH);
            docItem.setText("View Owning Document");
            ImageDescriptor docImageDesc = MdwPlugin.getImageDescriptor("icons/doc.gif");
            docItem.setImage(docImageDesc.createImage());
            docItem.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    IStorage storage = new DocumentStorage(workflowProject, new DocumentReference(processInstanceInfo.getOwnerId(), null));
                    final IStorageEditorInput input = new StorageEditorInput(storage);
                    final IWorkbenchPage page = MdwPlugin.getActivePage();
                    if (page != null) {
                        BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() {

                            public void run() {
                                try {
                                    page.openEditor(input, "org.eclipse.ui.DefaultTextEditor");
                                } catch (PartInitException ex) {
                                    PluginMessages.uiError(ex, "View Document", workflowProject);
                                }
                            }
                        });
                    }
                }
            });
        }
        // instance hierarchy
        MenuItem hierarchyItem = new MenuItem(menu, SWT.PUSH);
        hierarchyItem.setText("Instance Hierarchy");
        ImageDescriptor hierarchyImageDesc = MdwPlugin.getImageDescriptor("icons/hierarchy.gif");
        hierarchyItem.setImage(hierarchyImageDesc.createImage());
        hierarchyItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                WorkflowProcess pv = new WorkflowProcess(processVersion);
                pv.setProcessVO(processVersion.getProcessVO());
                pv.setProcessInstance(processInstanceInfo);
                new WorkflowElementActionHandler().showHierarchy(pv);
            }
        });
    }
    // delete
    if (!selection.isEmpty() && !processVersion.getProject().isProduction() && processVersion.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION)) {
        MenuItem deleteItem = new MenuItem(menu, SWT.PUSH);
        deleteItem.setText("Delete...");
        ImageDescriptor deleteImageDesc = MdwPlugin.getImageDescriptor("icons/delete.gif");
        deleteItem.setImage(deleteImageDesc.createImage());
        deleteItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (selection.size() == 1 && selection.getFirstElement() instanceof ProcessInstanceVO) {
                    ProcessInstanceVO pii = (ProcessInstanceVO) selection.getFirstElement();
                    if (MessageDialog.openConfirm(getSite().getShell(), "Confirm Delete", "Delete process instance ID: " + pii.getId() + " for workflow project '" + processVersion.getProject().getName() + "'?")) {
                        List<ProcessInstanceVO> instances = new ArrayList<>();
                        instances.add((ProcessInstanceVO) selection.getFirstElement());
                        handleDelete(instances);
                    }
                } else {
                    if (MessageDialog.openConfirm(getSite().getShell(), "Confirm Delete", "Delete selected process instances for workflow project '" + processVersion.getProject().getName() + "'?")) {
                        List<ProcessInstanceVO> instances = new ArrayList<>();
                        for (Object instance : selection.toArray()) {
                            if (instance instanceof ProcessInstanceVO)
                                instances.add((ProcessInstanceVO) instance);
                        }
                        handleDelete(instances);
                    }
                }
            }
        });
    }
    return menu;
}
Also used : DocumentStorage(com.centurylink.mdw.plugin.designer.storage.DocumentStorage) IStorageEditorInput(org.eclipse.ui.IStorageEditorInput) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) MenuItem(org.eclipse.swt.widgets.MenuItem) IStorage(org.eclipse.core.resources.IStorage) WorkflowElementActionHandler(com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler) StorageEditorInput(com.centurylink.mdw.plugin.designer.storage.StorageEditorInput) IStorageEditorInput(org.eclipse.ui.IStorageEditorInput) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) List(java.util.List) ArrayList(java.util.ArrayList) Menu(org.eclipse.swt.widgets.Menu) PartInitException(org.eclipse.ui.PartInitException) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) DocumentReference(com.centurylink.mdw.model.value.variable.DocumentReference)

Example 57 with WorkflowProcess

use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.

the class WorkflowProject method getUnpackagedDescendantProcesses.

/**
 * Returns the descendant process versions for a top-level process version
 * (includes the top-level version itself as a descendant).
 */
private List<WorkflowProcess> getUnpackagedDescendantProcesses(WorkflowProcess topLevelProcessVersion) {
    List<WorkflowProcess> processVersions = new ArrayList<>();
    // clone top-level process for first child
    WorkflowProcess processVersion = new WorkflowProcess(topLevelProcessVersion);
    // walk down the chain
    while (processVersion != null) {
        if (processVersion.getPackage() == null) {
            processVersion.setTopLevelVersion(topLevelProcessVersion);
            processVersions.add(processVersion);
        }
        processVersion = processVersion.getPreviousVersion();
    }
    // no need to sort
    return processVersions;
}
Also used : ArrayList(java.util.ArrayList) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 58 with WorkflowProcess

use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.

the class WorkflowProject method findUnpackagedProcesses.

/**
 * Gets the top-level unpackaged version for all processes. Side effect: if
 * a version is later than than in any package, it's added to the default
 * package. The results are populated with their unpackaged descendant
 * process versions.
 */
private List<WorkflowProcess> findUnpackagedProcesses() {
    List<WorkflowProcess> unpackagedProcesses = new ArrayList<>();
    for (ProcessVO processVO : getDataAccess().getProcesses(false)) {
        ProcessVO topUnpackaged = null;
        ProcessVO toCheck = processVO;
        // if process version is later than that in any package,
        // it belongs in the top-level default package
        boolean toCheckIsLatest = true;
        for (WorkflowPackage pkg : getTopLevelPackages()) {
            if (pkg.isDefaultPackage())
                continue;
            WorkflowProcess packaged = pkg.getProcess(processVO.getProcessName());
            if (packaged != null && packaged.getVersion() >= toCheck.getVersion()) {
                toCheckIsLatest = false;
                break;
            }
        }
        if (toCheckIsLatest) {
            WorkflowProcess pv = new WorkflowProcess(this, toCheck);
            getDefaultPackage().addProcess(pv);
            pv.addElementChangeListener(this);
            toCheck = toCheck.getPrevVersion();
        }
        // add the hierarchy of old unpackaged processes
        while (toCheck != null) {
            if (!isPackaged(toCheck)) {
                topUnpackaged = toCheck;
                break;
            }
            toCheck = toCheck.getPrevVersion();
        }
        if (topUnpackaged != null) {
            WorkflowProcess processVersion = new WorkflowProcess(this, topUnpackaged);
            processVersion.setDescendantProcessVersions(getUnpackagedDescendantProcesses(processVersion));
            unpackagedProcesses.add(processVersion);
        }
    }
    Collections.sort(unpackagedProcesses);
    return unpackagedProcesses;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 59 with WorkflowProcess

use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.

the class WorkflowProject method findTopLevelPackages.

/**
 * Finds the list of top level packages (including the default if
 * supported), populated with the appropriate processes, etc.
 */
private void findTopLevelPackages(ProgressMonitor progressMonitor) {
    CodeTimer timer = new CodeTimer("findTopLevelPackages()");
    topLevelPackages = new ArrayList<>();
    topLevelUserVisiblePackages = new ArrayList<>();
    activityImpls.clear();
    for (PackageVO packageVO : getTopLevelPackageVOs(progressMonitor)) {
        WorkflowPackage topLevelPackage = new WorkflowPackage(this, packageVO);
        topLevelPackage.setProcesses(findProcesses(topLevelPackage));
        topLevelPackage.setExternalEvents(findExternalEvents(topLevelPackage));
        topLevelPackage.setActivityImpls(findActivityImplementors(topLevelPackage));
        topLevelPackage.setAssets(findWorkflowAssets(topLevelPackage));
        topLevelPackage.setTaskTemplates(findTaskTemplates(topLevelPackage));
        topLevelPackages.add(topLevelPackage);
        if (topLevelPackage.isVisible())
            topLevelUserVisiblePackages.add(topLevelPackage);
        // register as a listener so that i can pass on element change
        // events
        topLevelPackage.addElementChangeListener(this);
        for (WorkflowProcess process : topLevelPackage.getProcesses()) process.addElementChangeListener(this);
    }
    Collections.sort(topLevelPackages);
    Collections.sort(topLevelUserVisiblePackages);
    File resultsFile = getFunctionTestResultsFile();
    if (resultsFile.exists()) {
        // update test case statuses
        List<TestCase> testCases = new ArrayList<>();
        for (WorkflowPackage pkg : topLevelPackages) {
            for (WorkflowAsset asset : pkg.getAssets()) {
                if (asset instanceof AutomatedTestCase)
                    testCases.add(((AutomatedTestCase) asset).getTestCase());
            }
        }
        if (!testCases.isEmpty()) {
            try {
                TestResultsParser parser = new TestResultsParser(resultsFile, testCases);
                if (resultsFile.getName().endsWith(".xml"))
                    parser.parseXml();
                else
                    parser.parseJson(getAssetDir());
            } catch (Exception ex) {
                PluginMessages.uiError(ex, "Parse Test Results", this);
            }
        }
    }
    timer.stopAndLog();
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) JSONException(org.json.JSONException) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) MdwSecurityException(com.centurylink.mdw.auth.MdwSecurityException) MalformedURLException(java.net.MalformedURLException) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) TestCase(com.centurylink.mdw.designer.testing.TestCase) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) TestResultsParser(com.centurylink.mdw.designer.testing.TestResultsParser) CodeTimer(com.centurylink.mdw.plugin.CodeTimer) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 60 with WorkflowProcess

use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.

the class WorkflowProject method findProcesses.

/**
 * Returns the process versions belonging to a package version.
 */
private List<WorkflowProcess> findProcesses(WorkflowPackage aPackage) {
    List<WorkflowProcess> processVersions = new ArrayList<>();
    for (ProcessVO processVO : getDataAccess().getAllProcesses(false)) {
        if (aPackage.getPackageVO().containsProcess(processVO.getProcessId())) {
            WorkflowProcess processVersion = new WorkflowProcess(this, processVO);
            if (// vcs assets
            !processVersions.contains(processVersion)) // would add
            // same-versioned
            // archived
            // processes
            {
                processVersion.setPackage(aPackage);
                processVersions.add(processVersion);
            }
        }
    }
    Collections.sort(processVersions);
    return processVersions;
}
Also used : ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Aggregations

WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)85 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)28 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)21 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)21 PartInitException (org.eclipse.ui.PartInitException)20 ArrayList (java.util.ArrayList)17 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)15 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)12 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)11 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)11 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)10 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)9 IEditorPart (org.eclipse.ui.IEditorPart)9 ProcessEditor (com.centurylink.mdw.plugin.designer.editors.ProcessEditor)8 IFile (org.eclipse.core.resources.IFile)8 CoreException (org.eclipse.core.runtime.CoreException)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)8 IOException (java.io.IOException)7 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)6 Activity (com.centurylink.mdw.plugin.designer.model.Activity)6