Search in sources :

Example 46 with WorkflowProcess

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

the class WorkflowElementActionHandler method debug.

public void debug(Object element) {
    if (element instanceof WorkflowProcess) {
        WorkflowProcess processVersion = (WorkflowProcess) element;
        IEditorPart editorPart = findOpenEditor(processVersion);
        if (editorPart != null && editorPart.isDirty()) {
            if (MessageDialog.openQuestion(getShell(), "Process Launch", "Save process '" + processVersion.getLabel() + "' before launching?"))
                editorPart.doSave(new NullProgressMonitor());
        }
        if (editorPart == null) {
            // process must be open
            open(processVersion);
        }
        ProcessLaunchShortcut launchShortcut = new ProcessLaunchShortcut();
        launchShortcut.launch(new StructuredSelection(processVersion), ILaunchManager.DEBUG_MODE);
    } else if (element instanceof Activity) {
        Activity activity = (Activity) element;
        WorkflowProcess processVersion = activity.getProcess();
        IEditorPart editorPart = findOpenEditor(processVersion);
        if (editorPart != null && editorPart.isDirty()) {
            if (MessageDialog.openQuestion(getShell(), "Activity Launch", "Save process '" + processVersion.getLabel() + "' before launching?"))
                editorPart.doSave(new NullProgressMonitor());
        }
        ActivityLaunchShortcut launchShortcut = new ActivityLaunchShortcut();
        launchShortcut.launch(new StructuredSelection(activity), ILaunchManager.DEBUG_MODE);
    } else if (element instanceof ExternalEvent) {
        ExternalEvent externalEvent = (ExternalEvent) element;
        ExternalEventLaunchShortcut launchShortcut = new ExternalEventLaunchShortcut();
        launchShortcut.launch(new StructuredSelection(externalEvent), ILaunchManager.DEBUG_MODE);
    } else if (element instanceof WorkflowProject || element instanceof ServerSettings) {
        ServerSettings serverSettings;
        if (element instanceof WorkflowProject) {
            WorkflowProject workflowProject = (WorkflowProject) element;
            serverSettings = workflowProject.getServerSettings();
        } else {
            serverSettings = (ServerSettings) element;
        }
        serverSettings.setDebug(true);
        if (serverSettings.getDebugPort() == 0)
            serverSettings.setDebugPort(8500);
        run(serverSettings);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProcessLaunchShortcut(com.centurylink.mdw.plugin.launch.ProcessLaunchShortcut) ServerSettings(com.centurylink.mdw.plugin.project.model.ServerSettings) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExternalEventLaunchShortcut(com.centurylink.mdw.plugin.launch.ExternalEventLaunchShortcut) AdapterActivity(com.centurylink.mdw.plugin.designer.model.Activity.AdapterActivity) EvaluatorActivity(com.centurylink.mdw.plugin.designer.model.Activity.EvaluatorActivity) StartActivity(com.centurylink.mdw.plugin.designer.model.Activity.StartActivity) Activity(com.centurylink.mdw.plugin.designer.model.Activity) ActivityLaunchShortcut(com.centurylink.mdw.plugin.launch.ActivityLaunchShortcut) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IEditorPart(org.eclipse.ui.IEditorPart) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 47 with WorkflowProcess

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

the class ProcessExplorerActionGroup method runApplies.

// top-level run action
public boolean runApplies(IStructuredSelection selection) {
    if (selection.size() > 1) {
        Boolean legacy = null;
        WorkflowPackage testPkg = null;
        for (Object o : selection.toArray()) {
            if (!(o instanceof AutomatedTestCase))
                return false;
            // make sure they're all in the same package or legacy suite
            AutomatedTestCase testCase = (AutomatedTestCase) o;
            if (legacy == null)
                legacy = testCase.isLegacy();
            if (legacy.booleanValue() != testCase.isLegacy())
                return false;
            if (!testCase.isLegacy()) {
                if (testPkg == null)
                    testPkg = testCase.getPackage();
                if (!testPkg.equals(testCase.getPackage()))
                    return false;
            }
        }
        WorkflowProject workflowProject = ((AutomatedTestCase) selection.getFirstElement()).getProject();
        if (!workflowProject.isRemote())
            return true;
        return workflowProject.isUserAuthorizedInAnyGroup(UserRoleVO.PROCESS_EXECUTION);
    }
    if (selection.size() != 1 || !(selection.getFirstElement() instanceof WorkflowElement))
        return false;
    WorkflowElement workflowElement = (WorkflowElement) selection.getFirstElement();
    if (workflowElement instanceof Report)
        return true;
    if (workflowElement instanceof Page)
        return true;
    if (workflowElement instanceof Template && ((Template) workflowElement).getLanguage().equals(RuleSetVO.VELOCITY))
        return true;
    if (workflowElement instanceof WorkflowProcess || workflowElement instanceof ExternalEvent) {
        if (!workflowElement.getProject().isRemote())
            return true;
        return workflowElement.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION);
    }
    if (workflowElement instanceof AutomatedTestSuite || workflowElement instanceof AutomatedTestCase) {
        if (workflowElement.getProject() == null)
            return false;
        if (workflowElement.getProject().isRemote()) {
            if (!workflowElement.getProject().isUserAuthorizedInAnyGroup(UserRoleVO.PROCESS_EXECUTION))
                return false;
            WorkflowPackage pkg = workflowElement.getPackage();
            if (pkg != null && !pkg.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION))
                return false;
        }
        try {
            AutomatedTestView testView = (AutomatedTestView) MdwPlugin.getActivePage().showView("mdw.views.launch.automatedTest");
            return !testView.isLocked();
        } catch (PartInitException ex) {
            PluginMessages.uiError(ex, "Menu", workflowElement.getProject());
        }
    }
    return false;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) Report(com.centurylink.mdw.plugin.designer.model.Report) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) Page(com.centurylink.mdw.plugin.designer.model.Page) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite) Template(com.centurylink.mdw.plugin.designer.model.Template) TaskTemplate(com.centurylink.mdw.plugin.designer.model.TaskTemplate) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) PartInitException(org.eclipse.ui.PartInitException) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 48 with WorkflowProcess

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

the class ProcessExplorerActionGroup method debugApplies.

public boolean debugApplies(IStructuredSelection selection) {
    if (selection.size() != 1 || !(selection.getFirstElement() instanceof WorkflowElement))
        return false;
    WorkflowElement workflowElement = (WorkflowElement) selection.getFirstElement();
    if (workflowElement instanceof AutomatedTestSuite || workflowElement instanceof AutomatedTestCase) {
        WorkflowProject prj = workflowElement.getProject();
        if (prj == null || !prj.checkRequiredVersion(6, 0) || !prj.isUserAuthorizedInAnyGroup(UserRoleVO.PROCESS_EXECUTION))
            return false;
        WorkflowPackage pkg = workflowElement.getPackage();
        if (pkg != null && !pkg.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION))
            return false;
        try {
            AutomatedTestView testView = (AutomatedTestView) MdwPlugin.getActivePage().showView("mdw.views.launch.automatedTest");
            return !testView.isLocked();
        } catch (PartInitException ex) {
            PluginMessages.uiError(ex, "Menu", workflowElement.getProject());
        }
    }
    if (workflowElement instanceof WorkflowProcess || workflowElement instanceof ExternalEvent)
        return !MdwPlugin.isRcp() && workflowElement.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION);
    else
        return false;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) PartInitException(org.eclipse.ui.PartInitException) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)

Example 49 with WorkflowProcess

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

the class ProcessExplorerActionGroup method createImportActionGroup.

private ActionGroup createImportActionGroup() {
    importMenu = new MenuManager("Import", MdwPlugin.getImageDescriptor("icons/import.gif"), MdwMenuManager.MDW_MENU_PREFIX + "menu.import");
    return new ActionGroup() {

        @Override
        public void fillContextMenu(IMenuManager menu) {
            importMenu.removeAll();
            IStructuredSelection selection = getSelection();
            WorkflowElement element = (WorkflowElement) selection.getFirstElement();
            if (!importMenuApplies(selection))
                return;
            if (importProjectApplies())
                importMenu.add(importProjectAction);
            if (importPackageApplies(selection))
                importMenu.add(importPackageAction);
            if (importVcsApplies(selection))
                importMenu.add(importVcsAction);
            if (importProcessApplies(selection)) {
                if (element instanceof WorkflowProcess) {
                    importProcessAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.new.process.version");
                    importProcessAction.setText("New Process Version...");
                } else {
                    importProcessAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.process");
                    importProcessAction.setText(PROCESS_DOT);
                }
                importMenu.add(importProcessAction);
            }
            if (importWorkflowAssetApplies(selection)) {
                if (element instanceof WorkflowAsset) {
                    WorkflowAsset asset = (WorkflowAsset) element;
                    // menu item text and icon are dynamic
                    importWorkflowAssetAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.new.asset.version");
                    importWorkflowAssetAction.setText("New " + asset.getTitle() + " Version...");
                    importWorkflowAssetAction.setImageDescriptor(MdwPlugin.getImageDescriptor(ICONS + asset.getIcon()));
                } else {
                    importWorkflowAssetAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.asset");
                    importWorkflowAssetAction.setText("Asset...");
                    importWorkflowAssetAction.setImageDescriptor(MdwPlugin.getImageDescriptor(ICON_DOC_GIF));
                }
                importMenu.add(importWorkflowAssetAction);
            }
            if (importAttributesApplies(selection)) {
                List<IAction> importAttrsActions = getImportAttributeActions(selection);
                if (!importAttrsActions.isEmpty()) {
                    MenuManager attributesMenu = new MenuManager("Attributes", MdwPlugin.getImageDescriptor("icons/attribute.gif"), MdwMenuManager.MDW_MENU_PREFIX + "menu.import.attributes");
                    attributesMenu.removeAll();
                    for (IAction action : importAttrsActions) attributesMenu.add(action);
                    importMenu.add(attributesMenu);
                }
            }
            if (importTaskTemplateApplies(selection))
                importMenu.add(importTaskTemplateAction);
            importMenu.add(new Separator(OTHER));
            IWorkbenchAction otherAction = ActionFactory.IMPORT.create(getViewSite().getWorkbenchWindow());
            otherAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.other");
            otherAction.setText(OTHER_DOT);
            importMenu.add(otherAction);
        }
    };
}
Also used : IAction(org.eclipse.jface.action.IAction) ActionGroup(org.eclipse.ui.actions.ActionGroup) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) MdwMenuManager(com.centurylink.mdw.plugin.actions.MdwMenuManager) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) Separator(org.eclipse.jface.action.Separator)

Example 50 with WorkflowProcess

use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess 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

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