Search in sources :

Example 21 with WorkflowProcess

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

the class ProcessExplorerContentProvider method getChildren.

public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof WorkflowProject) {
        final WorkflowProject workflowProject = (WorkflowProject) parentElement;
        if (!workflowProject.isLoaded()) {
            try {
                IRunnableWithProgress loader = new IRunnableWithProgress() {

                    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                        ProgressMonitor progressMonitor = new SwtProgressMonitor(monitor);
                        progressMonitor.start("Loading " + workflowProject.getLabel());
                        progressMonitor.progress(5);
                        try {
                            workflowProject.initialize(progressMonitor);
                            if (workflowProject.getDataAccess() != null) {
                                workflowProject.getTopLevelUserVisiblePackages(progressMonitor);
                                workflowProject.getArchivedUserVisiblePackagesFolder(progressMonitor);
                                progressMonitor.done();
                            }
                        } catch (Exception ex) {
                            throw new InvocationTargetException(ex);
                        }
                    }
                };
                ProgressMonitorDialog progMonDlg = new MdwProgressMonitorDialog(MdwPlugin.getShell());
                progMonDlg.run(true, false, loader);
            } catch (InvocationTargetException itx) {
                if (itx.getCause() instanceof DataUnavailableException) {
                    PluginMessages.log(itx);
                    MessageDialog.openWarning(MdwPlugin.getShell(), LOAD_WF_PROJECT, itx.getCause().getMessage());
                } else if (itx.getCause() instanceof DataAccessOfflineException) {
                    PluginMessages.log(itx);
                    MessageDialog.openError(MdwPlugin.getShell(), LOAD_WF_PROJECT, itx.getCause().getMessage());
                    return new WorkflowPackage[0];
                } else {
                    PluginMessages.uiError(itx, LOAD_WF_PROJECT, workflowProject);
                    return new WorkflowPackage[0];
                }
            } catch (Exception ex) {
                PluginMessages.uiError(ex, LOAD_WF_PROJECT, workflowProject);
                return new WorkflowPackage[0];
            }
        }
        if (workflowProject.getDataAccess() == null)
            return new WorkflowPackage[0];
        List<WorkflowPackage> topLevelPackages = workflowProject.getTopLevelUserVisiblePackages();
        Folder archivedPackageFolder = workflowProject.getArchivedUserVisiblePackagesFolder();
        int size = topLevelPackages.size();
        boolean showArchived = isShowArchivedItems(workflowProject);
        if (showArchived)
            size++;
        AutomatedTestSuite testSuite = workflowProject.getLegacyTestSuite();
        if (testSuite != null && !testSuite.isEmpty())
            size++;
        Object[] objects = new Object[size];
        for (int i = 0; i < topLevelPackages.size(); i++) objects[i] = topLevelPackages.get(i);
        int cur = topLevelPackages.size();
        if (showArchived) {
            objects[cur] = archivedPackageFolder;
            cur++;
        }
        if (testSuite != null && !testSuite.isEmpty())
            objects[cur] = testSuite;
        return objects;
    } else if (parentElement instanceof WorkflowPackage) {
        WorkflowPackage packageVersion = (WorkflowPackage) parentElement;
        if (packageVersion.isArchived() && packageVersion.hasDescendantPackageVersions()) {
            return packageVersion.getDescendantPackageVersions().toArray(new WorkflowPackage[0]);
        } else {
            List<WorkflowElement> elements = new ArrayList<>();
            IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
            if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_PROCESSES_IN_PEX))
                elements.addAll(packageVersion.getProcesses());
            if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_WORKFLOW_ASSETS_IN_PEX))
                elements.addAll(packageVersion.getAssets());
            if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_EVENT_HANDLERS_IN_PEX))
                elements.addAll(packageVersion.getExternalEvents());
            if (prefsStore.getBoolean(PreferenceConstants.PREFS_SHOW_ACTIVITY_IMPLEMENTORS_IN_PEX))
                elements.addAll(packageVersion.getActivityImpls());
            if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_TASK_TEMPLATES_IN_PEX))
                elements.addAll(packageVersion.getTaskTemplates());
            elements.addAll(packageVersion.getChildFolders());
            if (isSortPackageContentsAtoZ()) {
                Collections.sort(elements, new Comparator<WorkflowElement>() {

                    public int compare(WorkflowElement e1, WorkflowElement e2) {
                        return e1.getLabel().compareToIgnoreCase(e2.getLabel());
                    }
                });
            }
            return elements.toArray(new Object[0]);
        }
    } else if (parentElement instanceof WorkflowProcess) {
        WorkflowProcess processVersion = (WorkflowProcess) parentElement;
        if (processVersion.hasDescendantProcessVersions()) {
            return processVersion.getDescendantProcessVersions().toArray(new WorkflowProcess[0]);
        } else {
            return emptyARRAY;
        }
    } else if (parentElement instanceof Folder) {
        Folder folder = (Folder) parentElement;
        return folder.getChildren().toArray(new WorkflowElement[0]);
    } else if (parentElement instanceof AutomatedTestSuite) {
        AutomatedTestSuite testSuite = (AutomatedTestSuite) parentElement;
        return testSuite.getTestCases().toArray(new AutomatedTestCase[0]);
    } else if (parentElement instanceof AutomatedTestCase) {
        AutomatedTestCase testCase = (AutomatedTestCase) parentElement;
        if (!testCase.isLegacy())
            return emptyARRAY;
        List<LegacyExpectedResults> expectedResults = testCase.getLegacyExpectedResults();
        List<File> files = testCase.getFiles();
        Object[] objects = new Object[expectedResults.size() + files.size()];
        for (int i = 0; i < expectedResults.size(); i++) objects[i] = expectedResults.get(i);
        for (int i = expectedResults.size(); i < objects.length; i++) objects[i] = files.get(i - expectedResults.size());
        return objects;
    } else {
        return emptyARRAY;
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) SwtProgressMonitor(com.centurylink.mdw.plugin.designer.SwtProgressMonitor) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) Folder(com.centurylink.mdw.plugin.designer.model.Folder) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Comparator(java.util.Comparator) ArrayList(java.util.ArrayList) List(java.util.List) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) InvocationTargetException(java.lang.reflect.InvocationTargetException) DataUnavailableException(com.centurylink.mdw.designer.DataUnavailableException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProgressMonitor(com.centurylink.mdw.common.utilities.timer.ProgressMonitor) SwtProgressMonitor(com.centurylink.mdw.plugin.designer.SwtProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DataUnavailableException(com.centurylink.mdw.designer.DataUnavailableException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 22 with WorkflowProcess

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

the class ProcessExplorerDropTarget method checkForDuplicates.

/**
 * Returns true if duplicates found.
 */
private boolean checkForDuplicates(WorkflowPackage targetPackage, String[] elements) {
    for (String element : elements) {
        if (element.startsWith("Process~")) {
            String processName = element.substring(8);
            for (WorkflowProcess process : targetPackage.getProcesses()) {
                if (process.getName().equals(processName)) {
                    String msg = PACAKGE + targetPackage.getName() + "' already contains version " + process.getVersionLabel() + " of process '" + process.getName() + "'";
                    MessageDialog.openError(getViewer().getControl().getShell(), "Duplicate Process", msg);
                    return true;
                }
            }
        } else if (element.startsWith("ExternalEvent~")) {
            String externalEventName = element.substring(14);
            for (ExternalEvent externalEvent : targetPackage.getExternalEvents()) {
                if (externalEvent.getName().equals(externalEventName)) {
                    String msg = PACAKGE + targetPackage.getName() + "' already contains " + " an external event named '" + externalEvent.getName() + "'";
                    MessageDialog.openError(getViewer().getControl().getShell(), "Duplicate External Event", msg);
                    return true;
                }
            }
        } else if (element.startsWith("ActivityImpl~")) {
        // TODO: dups okay?
        } else if (element.startsWith("WorkflowAsset~")) {
            String assetName = element.substring(14);
            for (WorkflowAsset asset : targetPackage.getAssets()) {
                if (asset.getName().equals(assetName)) {
                    String msg = PACAKGE + targetPackage.getName() + "' already contains " + " an definition document named '" + asset.getName() + "'";
                    MessageDialog.openError(getViewer().getControl().getShell(), "Duplicate Definition Doc", msg);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 23 with WorkflowProcess

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

the class ProcessExplorerDropTarget method handleDropProcess.

/**
 * @param processInfo
 * @param targetPackage
 * @param operation
 * @return
 */
private boolean handleDropProcess(String processInfo, WorkflowPackage targetPackage, int operation) {
    String processName = getProcessName(processInfo);
    String version = getProcessVersion(processInfo);
    WorkflowProject targetProject = targetPackage.getProject();
    WorkflowPackage sourcePackage = targetProject.getPackage(getPackageName(processInfo));
    DesignerProxy designerProxy = targetProject.getDesignerProxy();
    if (operation == DND.DROP_COPY) {
        String workflowProjectName = getWorkflowProjectName(processInfo);
        WorkflowProcess existing = targetProject.getProcess(processName, version);
        if (!targetPackage.getProject().getName().equals(workflowProjectName)) {
            // copying from remote project
            if (existing != null) {
                MessageDialog.openError(getViewer().getControl().getShell(), "Copy Foreign Process", "' " + processName + " v" + version + "' already exists in workflow project '" + targetPackage.getProject().getLabel() + "'.");
                return false;
            }
            WorkflowProject sourceProject = WorkflowProjectManager.getInstance().getWorkflowProject(workflowProjectName);
            designerProxy.copyForeignProcess(processName, version, sourceProject, targetPackage);
            WorkflowProcess newCopy = targetProject.getProcess(processName, "0.1");
            if (newCopy != null) {
                newCopy.addElementChangeListener(targetProject);
                newCopy.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, newCopy);
            }
            ((TreeViewer) getViewer()).refresh(targetPackage, true);
            return true;
        } else {
            // is there a dirty editor open?
            if (existing != null) {
                IEditorPart editor = findOpenEditor(existing);
                if (editor != null && editor.isDirty()) {
                    MessageDialog.openWarning(getViewer().getControl().getShell(), "Copy Process", "' " + processName + " v" + version + "' is currently open in an editor.\nPlease save or close before copying.");
                    return false;
                }
            }
            CopyDialog copyDialog = new CopyDialog(getViewer().getControl().getShell(), existing, processName, version, targetPackage);
            if (copyDialog.open() == Dialog.OK) {
                String newName = copyDialog.getNewName();
                designerProxy.copyProcess(processName, version, newName, targetPackage);
                WorkflowProcess newCopy = targetProject.getProcess(newName, "0.1");
                if (newCopy != null) {
                    newCopy.addElementChangeListener(targetProject);
                    newCopy.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, newCopy);
                }
                ((TreeViewer) getViewer()).refresh(targetPackage, true);
                return true;
            }
        }
        return false;
    } else if (operation == DND.DROP_MOVE) {
        // don't allow multiple versions of the same process in a package
        if (!targetPackage.isDefaultPackage() && targetPackage.getProcess(processName) != null) {
            MessageDialog.openError(MdwPlugin.getShell(), "Process Exists", "Process '" + processName + "' already exists in package '" + targetPackage.getName() + "'.");
            return false;
        }
        if (targetPackage.isDefaultPackage()) {
            designerProxy.removeProcessFromPackage(processName, version, sourcePackage);
        } else {
            designerProxy.moveProcessToPackage(processName, version, targetPackage);
        }
        ((TreeViewer) getViewer()).refresh(targetPackage.getProject(), true);
        if (sourcePackage != null)
            ((TreeViewer) getViewer()).refresh(sourcePackage.getProject(), true);
        return true;
    } else {
        return false;
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) CopyDialog(com.centurylink.mdw.plugin.designer.dialogs.CopyDialog) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IEditorPart(org.eclipse.ui.IEditorPart) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 24 with WorkflowProcess

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

the class ProcessHierarchyContentProvider method addCalledHierarchy.

private void addCalledHierarchy(LinkedProcess caller) throws DataAccessException, RemoteException {
    WorkflowProcess callerProcess = caller.getProcess();
    for (WorkflowProcess calledProcess : callerProcess.getProject().getDesignerProxy().findCalledProcesses(callerProcess).toArray(new WorkflowProcess[0])) {
        LinkedProcess child = new LinkedProcess(calledProcess);
        child.setParent(caller);
        caller.getChildren().add(child);
        addCalledHierarchy(child);
    }
}
Also used : WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 25 with WorkflowProcess

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

the class ProcessHierarchyView method createPartControl.

public void createPartControl(Composite parent) {
    treeViewer = new TreeViewer(parent);
    treeViewer.setLabelProvider(new ProcessHierarchyLabelProvider());
    // action group
    actionGroup = new ProcessHierarchyActionGroup(this);
    actionGroup.fillActionBars(getViewSite().getActionBars());
    treeViewer.addOpenListener(new IOpenListener() {

        public void open(OpenEvent event) {
            for (Object item : getSelection().toList()) {
                if (item instanceof LinkedProcess)
                    actionGroup.getActionHandler().open(((LinkedProcess) item).getProcess());
                if (item instanceof LinkedProcessInstance) {
                    ProcessInstanceVO procInst = ((LinkedProcessInstance) item).getProcessInstance();
                    WorkflowProcess pv = processVersion.getProject().getProcess(procInst.getProcessId());
                    if (pv != null) {
                        WorkflowProcess toOpen = new WorkflowProcess(pv);
                        toOpen.setProcessInstance(procInst);
                        actionGroup.getActionHandler().open(toOpen);
                    }
                }
            }
        }
    });
}
Also used : IOpenListener(org.eclipse.jface.viewers.IOpenListener) LinkedProcess(com.centurylink.mdw.plugin.designer.views.ProcessHierarchyContentProvider.LinkedProcess) TreeViewer(org.eclipse.jface.viewers.TreeViewer) LinkedProcessInstance(com.centurylink.mdw.model.value.process.LinkedProcessInstance) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

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