Search in sources :

Example 1 with Report

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

Aggregations

AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)1 AutomatedTestSuite (com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)1 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)1 Page (com.centurylink.mdw.plugin.designer.model.Page)1 Report (com.centurylink.mdw.plugin.designer.model.Report)1 TaskTemplate (com.centurylink.mdw.plugin.designer.model.TaskTemplate)1 Template (com.centurylink.mdw.plugin.designer.model.Template)1 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)1 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)1 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)1 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)1 PartInitException (org.eclipse.ui.PartInitException)1