Search in sources :

Example 36 with WorkflowProcess

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

the class WorkflowAssetEditor method updateVersionAttribute.

private void updateVersionAttribute(WorkflowElement workflowAsset) {
    AssetVersionSpec versionSpec = AssetVersionSpec.parse(workflowAsset.getLabel());
    String versionAttr = null;
    if (isProcess()) {
        if (getProject().checkRequiredVersion(5, 5) && !(getElement() instanceof Activity && ((Activity) getElement()).isOldMultipleSubProcInvoke())) {
            if (MdwPlugin.getSettings().isInferSmartSubprocVersionSpec())
                versionAttr = AssetVersionSpec.getDefaultSmartVersionSpec(versionSpec.getVersion());
            else
                versionAttr = versionSpec.getVersion();
        } else {
            // pre-5.5
            versionAttr = String.valueOf(((WorkflowProcess) workflowAsset).getVersion());
        // compatibility
        }
        getElement().setAttribute(WorkAttributeConstant.PROCESS_VERSION, versionAttr);
    } else if (// assets only save
    getProject().checkRequiredVersion(5, 5)) // version for 5.5
    {
        if (MdwPlugin.getSettings().isInferSmartSubprocVersionSpec())
            versionAttr = AssetVersionSpec.getDefaultSmartVersionSpec(versionSpec.getVersion());
        else
            versionAttr = versionSpec.getVersion();
        getElement().setAttribute(getAssetVersionAttributeName(), versionAttr);
    }
}
Also used : Activity(com.centurylink.mdw.plugin.designer.model.Activity) AssetVersionSpec(com.centurylink.mdw.model.value.attribute.AssetVersionSpec) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 37 with WorkflowProcess

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

the class AssetLocator method assetFromAttr.

public WorkflowElement assetFromAttr(String attrValue) {
    if (attrValue == null || attrValue.isEmpty() || attrValue.startsWith("$") || attrValue.startsWith("#")) {
        return null;
    }
    if (isProcess()) {
        int slashIdx = attrValue.indexOf('/');
        if (slashIdx <= 0) {
            // prefer process in same package
            WorkflowProcess proc = getElement().getPackage() == null ? null : getProcessVersion(attrValue, getElement().getPackage().getProcesses());
            if (proc != null)
                return proc;
            else
                return getProcessVersion(attrValue, getProject().getAllProcessVersions());
        } else {
            String pkgName = attrValue.substring(0, slashIdx);
            WorkflowPackage pkg = getProject().getPackage(pkgName);
            if (pkg == null)
                return null;
            else
                return getProcessVersion(attrValue.substring(slashIdx + 1), pkg.getProcesses());
        }
    } else if (isTaskTemplate()) {
        // no need to handle unqualified attrs
        int slashIdx = attrValue.indexOf('/');
        String pkgName = slashIdx <= 0 ? null : attrValue.substring(0, slashIdx);
        WorkflowPackage pkg = pkgName == null ? null : getProject().getPackage(pkgName);
        if (pkg == null)
            return null;
        else
            return getTaskTemplateVersion(attrValue.substring(slashIdx + 1), pkg.getTaskTemplates());
    } else {
        int slashIdx = attrValue.indexOf('/');
        if (slashIdx <= 0) {
            // prefer asset in same package
            WorkflowAsset pkgDoc = getElement().getPackage() == null ? null : getWorkflowAssetVersion(attrValue, getElement().getPackage().getAssets());
            if (pkgDoc != null)
                return pkgDoc;
            else
                return getWorkflowAssetVersion(attrValue, getProject().getAllWorkflowAssets());
        } else {
            String pkgName = attrValue.substring(0, slashIdx);
            WorkflowPackage pkg = getProject().getPackage(pkgName);
            if (pkg == null)
                return null;
            else
                return getWorkflowAssetVersion(attrValue.substring(slashIdx + 1), pkg.getAssets());
        }
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 38 with WorkflowProcess

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

the class AssetLocator method getProcessVersion.

private WorkflowProcess getProcessVersion(String versionSpec, List<WorkflowProcess> processes) {
    AssetVersionSpec spec = AssetVersionSpec.parse(versionSpec);
    boolean isDefaultSmart = isDefaultSmartFormat(spec.getVersion());
    WorkflowProcess match = null;
    for (WorkflowProcess process : processes) {
        if (process.getName().equals(spec.getName())) {
            if (process.getVersionString().equals(spec.getVersion())) {
                match = process;
                break;
            } else if ((AssetVersionSpec.VERSION_LATEST.equals(spec.getVersion()) || (isDefaultSmart && process.meetsVersionSpec(spec.getVersion()))) && (match == null || process.getVersion() > match.getVersion())) {
                match = process;
            }
        }
    }
    return match;
}
Also used : AssetVersionSpec(com.centurylink.mdw.model.value.attribute.AssetVersionSpec) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 39 with WorkflowProcess

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

the class ProcessInstanceContentProvider method getElements.

public Object[] getElements(Object inputElement) {
    WorkflowProcess processVersion = (WorkflowProcess) inputElement;
    if (instanceInfo == null) {
        DesignerProxy designerProxy = processVersion.getProject().getDesignerProxy();
        ProcessList instanceList = designerProxy.getProcessInstanceList(processVersion, filter.getProcessCriteria(), filter.getVariableCriteria(processVersion), pageIndex, filter.getPageSize(), sort.getOrderBy());
        instanceCount = instanceList.getTotal();
        instanceInfo = instanceList.getItems();
    }
    return instanceInfo.toArray(new ProcessInstanceVO[0]);
}
Also used : ProcessList(com.centurylink.mdw.model.value.process.ProcessList) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 40 with WorkflowProcess

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

the class WorkflowElementActionHandler method delete.

public void delete(WorkflowElement[] elements) {
    boolean globalConf = false;
    boolean includeInstances = false;
    if (elements.length > 1) {
        boolean globalConfAllowed = true;
        List<WorkflowElement> lockedElems = new ArrayList<WorkflowElement>();
        for (WorkflowElement element : elements) {
            if ((element instanceof WorkflowProject) || (element instanceof WorkflowPackage)) {
                globalConfAllowed = false;
                break;
            } else if (element instanceof WorkflowProcess) {
                WorkflowProcess pv = (WorkflowProcess) element;
                if (pv.getLockingUser() != null && !pv.isLockedToUser())
                    lockedElems.add(pv);
            } else if (element instanceof WorkflowAsset) {
                WorkflowAsset dd = (WorkflowAsset) element;
                if (dd.getLockingUser() != null && !dd.isLockedToUser())
                    lockedElems.add(dd);
            }
        }
        if (!lockedElems.isEmpty()) {
            PluginMessages.uiList(getShell(), "Error: The following elements are locked to other users.\nPlease exclude them from your selection or have them unlocked before proceeding.", "Delete Elements", lockedElems);
            return;
        }
        if (globalConfAllowed) {
            WorkflowElementDeleteDialog multipleDeleteDialog = new WorkflowElementDeleteDialog(getShell(), Arrays.asList(elements));
            int res = multipleDeleteDialog.open();
            if (res == Dialog.CANCEL)
                return;
            else if (res == Dialog.OK) {
                globalConf = true;
                includeInstances = multipleDeleteDialog.isIncludeInstances();
            }
        }
    }
    for (WorkflowElement element : elements) {
        if (element instanceof WorkflowProject) {
            WorkflowProject workflowProject = (WorkflowProject) element;
            if (!workflowProject.isRemote()) {
                MessageDialog.openWarning(getShell(), "Delete Project", "Please delete the underlying Java Project in Package Explorer view.");
                return;
            }
            boolean confirmed = MessageDialog.openConfirm(getShell(), "Confirm Delete", "Delete workflow project: " + workflowProject.getName() + "?");
            if (confirmed) {
                WorkflowProjectManager.getInstance().deleteProject(workflowProject);
                workflowProject.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
            } else {
                return;
            }
        } else if (element instanceof AutomatedTestCase && ((AutomatedTestCase) element).isLegacy()) {
            // still allow deletion of legacy test stuff
            final AutomatedTestCase testCase = (AutomatedTestCase) element;
            if (globalConf || MessageDialog.openConfirm(getShell(), "Delete Legacy Test Case", "Delete " + testCase.getLabel() + "?")) {
                BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                    public void run() {
                        File tcDir = testCase.getTestCaseDirectory();
                        try {
                            PluginUtil.deleteDirectory(tcDir);
                            testCase.getTestSuite().getTestCases().remove(testCase);
                            try {
                                IFolder folder = testCase.getProject().getOldTestCasesFolder();
                                if (folder.exists())
                                    folder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
                            } catch (CoreException ex) {
                                PluginMessages.uiError(ex, "Delete Legacy Test Case", testCase.getProject());
                            }
                            testCase.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
                            testCase.removeElementChangeListener(testCase.getProject());
                        } catch (IOException ex) {
                            PluginMessages.uiError(ex, "Delete Test Case", testCase.getProject());
                        }
                    }
                });
            }
        } else if (element instanceof LegacyExpectedResults) {
            final LegacyExpectedResults expectedResult = (LegacyExpectedResults) element;
            if (globalConf || MessageDialog.openConfirm(getShell(), "Delete Legacy Expected Result", "Delete " + expectedResult.getLabel() + "?")) {
                BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                    public void run() {
                        File file = expectedResult.getExpectedResultFile();
                        if (file.delete()) {
                            expectedResult.getTestCase().getLegacyExpectedResults().remove(expectedResult);
                            try {
                                IFolder folder = expectedResult.getProject().getOldTestCasesFolder();
                                if (folder.exists())
                                    folder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
                            } catch (CoreException ex) {
                                PluginMessages.uiError(ex, "Delete Legacy Expected Result", expectedResult.getProject());
                            }
                            expectedResult.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
                            expectedResult.removeElementChangeListener(expectedResult.getProject());
                        } else {
                            PluginMessages.uiError("Cannot delete expected result " + expectedResult.getName(), "Delete Result", expectedResult.getProject());
                        }
                    }
                });
            }
        } else if (element instanceof com.centurylink.mdw.plugin.designer.model.File) {
            final com.centurylink.mdw.plugin.designer.model.File file = (com.centurylink.mdw.plugin.designer.model.File) element;
            if (globalConf || MessageDialog.openConfirm(getShell(), "Delete File", "Delete " + file.getLabel() + "?")) {
                BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                    public void run() {
                        IFile workspaceFile = file.getWorkspaceFile();
                        try {
                            workspaceFile.delete(true, null);
                            WorkflowElement parent = file.getParent();
                            if (parent instanceof AutomatedTestCase) {
                                AutomatedTestCase testCase = (AutomatedTestCase) parent;
                                testCase.getFiles().remove(file);
                            }
                            file.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
                            file.removeElementChangeListener(file.getProject());
                            refresh(file.getProject().getLegacyTestSuite());
                        } catch (Exception ex) {
                            PluginMessages.uiError("Cannot delete file " + file.getName(), "Delete File", file.getProject());
                        }
                    }
                });
            }
        } else {
            WorkflowProject workflowProject = element.getProject();
            DesignerProxy designerProxy = workflowProject.getDesignerProxy();
            if (element instanceof WorkflowPackage) {
                WorkflowPackage packageToDelete = (WorkflowPackage) element;
                PackageDeleteDialog packageDeleteDialog = new PackageDeleteDialog(getShell(), packageToDelete);
                if (packageDeleteDialog.open() == Dialog.OK) {
                    designerProxy.deletePackage(packageToDelete);
                } else {
                    return;
                }
            } else if (element instanceof WorkflowProcess) {
                WorkflowProcess processVersion = (WorkflowProcess) element;
                if (!processVersion.getProject().isFilePersist() && processVersion.getLockingUser() != null && !processVersion.isLockedToUser()) {
                    MessageDialog.openError(getShell(), "Cannot Delete", "Process '" + processVersion.getLabel() + "' is locked to user '" + processVersion.getLockingUser() + "'.\nPlease have it unlocked before deleting.");
                    return;
                }
                ProcessDeleteDialog deleteDialog = new ProcessDeleteDialog(getShell(), processVersion);
                if (globalConf || deleteDialog.open() == Dialog.OK) {
                    closeOpenEditor(processVersion, false);
                    includeInstances = includeInstances || deleteDialog.isIncludeInstances();
                    designerProxy.deleteProcess(processVersion, includeInstances);
                } else {
                    return;
                }
            } else if (element instanceof TaskTemplate) {
                TaskTemplate taskTemplate = (TaskTemplate) element;
                if (globalConf || MessageDialog.openConfirm(getShell(), "Confirm Delete", "Delete " + taskTemplate.getTitle() + " '" + taskTemplate.getLabel() + "'?")) {
                    designerProxy.deleteTaskTemplate(taskTemplate);
                } else {
                    return;
                }
            } else if (element instanceof WorkflowAsset) {
                WorkflowAsset asset = (WorkflowAsset) element;
                if (!asset.getProject().isFilePersist() && asset.getLockingUser() != null && !asset.isLockedToUser()) {
                    MessageDialog.openError(getShell(), "Cannot Delete", asset.getTitle() + " '" + asset.getLabel() + "' is locked to user '" + asset.getLockingUser() + "'.\nPlease have it unlocked before deleting");
                    return;
                }
                if (globalConf || MessageDialog.openConfirm(getShell(), "Confirm Delete", "Delete " + asset.getTitle() + " '" + asset.getLabel() + "'?")) {
                    if (asset.getFileEditor() != null) {
                        IEditorInput editorInput = asset.getFileEditor().getEditorInput();
                        if (editorInput != null)
                            closeOpenEditor(editorInput, false);
                    }
                    WorkflowAssetFactory.deRegisterAsset(asset);
                    designerProxy.deleteWorkflowAsset(asset);
                } else {
                    return;
                }
            } else if (element instanceof ActivityImpl) {
                ActivityImpl activityImpl = (ActivityImpl) element;
                ActivityImplDeleteDialog deleteDialog = new ActivityImplDeleteDialog(getShell(), activityImpl);
                if (globalConf || deleteDialog.open() == Dialog.OK) {
                    designerProxy.deleteActivityImpl(activityImpl, deleteDialog.isIncludeActivities());
                } else {
                    return;
                }
            } else if (element instanceof ExternalEvent) {
                ExternalEvent externalEvent = (ExternalEvent) element;
                if (globalConf || MessageDialog.openConfirm(getShell(), "Confirm Delete", "Delete Event Handler: " + externalEvent.getLabel() + "?")) {
                    designerProxy.deleteExternalEvent(externalEvent);
                } else {
                    return;
                }
            } else if (element instanceof TaskTemplate) {
                MessageDialog.openWarning(getShell(), "TODO", "Delete task template not yet implemented");
            }
            if (RunnerStatus.SUCCESS.equals(designerProxy.getRunnerStatus())) {
                // notify listeners
                element.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
                element.removeElementChangeListener(workflowProject);
            }
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) WorkflowElementDeleteDialog(com.centurylink.mdw.plugin.designer.dialogs.WorkflowElementDeleteDialog) ProcessDeleteDialog(com.centurylink.mdw.plugin.designer.dialogs.ProcessDeleteDialog) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) PackageDeleteDialog(com.centurylink.mdw.plugin.designer.dialogs.PackageDeleteDialog) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) TaskTemplate(com.centurylink.mdw.plugin.designer.model.TaskTemplate) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException) ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl) LegacyExpectedResults(com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults) ActivityImplDeleteDialog(com.centurylink.mdw.plugin.designer.dialogs.ActivityImplDeleteDialog) IFile(org.eclipse.core.resources.IFile) File(java.io.File) JarFile(com.centurylink.mdw.plugin.designer.model.JarFile) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) IEditorInput(org.eclipse.ui.IEditorInput) IFolder(org.eclipse.core.resources.IFolder)

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