Search in sources :

Example 61 with WorkflowProject

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

the class ProcessSearchQuery method run.

public IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
    if (getScopedProjects().isEmpty() && getSelectedPackage() != null)
        getScopedProjects().add(getSelectedPackage().getProject());
    if (getScopedProjects().isEmpty()) {
        String msg = "No MDW projects in search scope.";
        showError(msg, "MDW Search", null);
        return new Status(IStatus.WARNING, MdwPlugin.getPluginId(), 0, msg, null);
    }
    for (WorkflowProject project : getScopedProjects()) {
        if (getSearchType().equals(SearchType.ENTITY_BY_NAME)) {
            for (WorkflowProcess process : project.getAllProcessVersions()) {
                String name = isCaseSensitive() ? process.getName() : process.getName().toLowerCase();
                if ((getPattern().equals("*") || name.indexOf(getPattern()) >= 0) && (getSelectedPackage() == null || (process.getPackage() != null && process.getPackage().equals(getSelectedPackage()))))
                    getSearchResults().addMatchingElement(process);
            }
        } else if (getSearchType().equals(SearchType.ENTITY_BY_ID)) {
            WorkflowProcess process = project.getProcess(new Long(getPattern()));
            if (process == null && project.isRemote() && project.isFilePersist()) {
                // could be archived process for remote VCS
                try {
                    ProcessVO procVO = project.getDesignerProxy().getDesignerDataAccess().getProcessDefinition(new Long(getPattern()));
                    process = new WorkflowProcess(project, procVO);
                } catch (Exception ex) {
                    PluginMessages.log(ex);
                }
            }
            if (process != null && (getSelectedPackage() == null || (process.getPackage() != null && process.getPackage().equals(getSelectedPackage()))))
                getSearchResults().addMatchingElement(process);
        } else if (getSearchType().equals(SearchType.CONTAINING_ENTITY)) {
            try {
                for (WorkflowProcess process : project.getDesignerProxy().getProcessesUsingActivityImpl(containedEntityId, containedEntityName)) {
                    String name = isCaseSensitive() ? process.getName() : process.getName().toLowerCase();
                    if (getPattern().equals("*") || name.indexOf(getPattern()) >= 0)
                        getSearchResults().addMatchingElement(process);
                }
            } catch (DataAccessException ex) {
                showError(ex, "Find Processes", project);
            }
        } else if (getSearchType().equals(SearchType.INVOKING_ENTITY)) {
            try {
                WorkflowProcess invoked = project.getProcess(getInvokedEntityId());
                for (WorkflowProcess process : project.getDesignerProxy().findCallingProcesses(invoked)) {
                    String name = isCaseSensitive() ? process.getName() : process.getName().toLowerCase();
                    if (getPattern().equals("*") || name.indexOf(getPattern()) >= 0)
                        getSearchResults().addMatchingElement(process);
                }
            } catch (Exception ex) {
                showError(ex, "Calling Processes", project);
            }
        } else if (getSearchType().equals(SearchType.INSTANCE_BY_ENTITY_ID)) {
            Map<String, String> criteria = new HashMap<String, String>();
            criteria.put("processId", getPattern());
            searchInstances(project, criteria);
        } else if (getSearchType().equals(SearchType.INSTANCE_BY_ID)) {
            Map<String, String> criteria = new HashMap<String, String>();
            criteria.put("id", getPattern());
            searchInstances(project, criteria);
        } else if (getSearchType().equals(SearchType.INSTANCE_BY_MRI)) {
            Map<String, String> criteria = new HashMap<String, String>();
            if (isCaseSensitive())
                criteria.put("masterRequestId", getPattern());
            else
                criteria.put("masterRequestIdIgnoreCase", getPattern());
            searchInstances(project, criteria);
        } else {
            showError("Unsupported search type: " + getSearchType(), "MDW Search", null);
        }
    }
    if (getSearchResults().getMatchingElements().size() == 0)
        return new Status(IStatus.WARNING, MdwPlugin.getPluginId(), 0, "No matching elements found", null);
    else
        return Status.OK_STATUS;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) HashMap(java.util.HashMap) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) HashMap(java.util.HashMap) Map(java.util.Map) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) PartInitException(org.eclipse.ui.PartInitException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 62 with WorkflowProject

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

the class ExternalEventLaunchShortcut method createLaunchConfiguration.

protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(ExternalEvent externalEvent) throws CoreException {
    WorkflowProject workflowProject = externalEvent.getProject();
    String launchConfigName = getUniqueLaunchConfigName(externalEvent);
    ILaunchConfigurationType configType = getLaunchManager().getLaunchConfigurationType(EXTERNAL_EVENT_LAUNCH_CONFIG_TYPE);
    ILaunchConfigurationWorkingCopy wc = configType.newInstance(workflowProject.getSourceProject(), launchConfigName);
    wc.setAttribute(ExternalEventLaunchConfiguration.WORKFLOW_PROJECT, workflowProject.getName());
    wc.setAttribute(ExternalEventLaunchConfiguration.EVENT_NAME, externalEvent.getName());
    return wc;
}
Also used : ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 63 with WorkflowProject

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

the class JavaSourcePathComputer method computeSourceContainers.

@Override
public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
    IRuntimeClasspathEntry[] unresolvedEntries = JavaRuntime.computeUnresolvedSourceLookupPath(configuration);
    List<ISourceContainer> sourcefolderList = new ArrayList<ISourceContainer>();
    IServer server = ServerUtil.getServer(configuration);
    List<IJavaProject> javaProjectList = new ArrayList<IJavaProject>();
    if (server == null) {
        String projectName = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
        if (projectName != null) {
            WorkflowProject workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(projectName);
            if (workflowProject != null)
                javaProjectList.add(workflowProject.getJavaProject());
        }
    } else {
        IModule[] modules = server.getModules();
        addProjectsFromModules(sourcefolderList, modules, javaProjectList, server, monitor);
    }
    IRuntimeClasspathEntry[] projectEntries = new IRuntimeClasspathEntry[javaProjectList.size()];
    for (int i = 0; i < javaProjectList.size(); i++) projectEntries[i] = JavaRuntime.newDefaultProjectClasspathEntry(javaProjectList.get(i));
    IRuntimeClasspathEntry[] entries = new IRuntimeClasspathEntry[projectEntries.length + unresolvedEntries.length];
    System.arraycopy(unresolvedEntries, 0, entries, 0, unresolvedEntries.length);
    System.arraycopy(projectEntries, 0, entries, unresolvedEntries.length, projectEntries.length);
    IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath(entries, configuration);
    ISourceContainer[] javaSourceContainers = JavaRuntime.getSourceContainers(resolved);
    if (!sourcefolderList.isEmpty()) {
        ISourceContainer[] combinedSourceContainers = new ISourceContainer[javaSourceContainers.length + sourcefolderList.size()];
        sourcefolderList.toArray(combinedSourceContainers);
        System.arraycopy(javaSourceContainers, 0, combinedSourceContainers, sourcefolderList.size(), javaSourceContainers.length);
        javaSourceContainers = combinedSourceContainers;
    }
    return javaSourceContainers;
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IModule(org.eclipse.wst.server.core.IModule) ArrayList(java.util.ArrayList) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IRuntimeClasspathEntry(org.eclipse.jdt.launching.IRuntimeClasspathEntry) IJavaProject(org.eclipse.jdt.core.IJavaProject) ISourceContainer(org.eclipse.debug.core.sourcelookup.ISourceContainer)

Example 64 with WorkflowProject

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

the class ImportPackageWizard method performFinish.

@Override
public boolean performFinish() {
    final List<WorkflowPackage> importedPackages = new ArrayList<>();
    final List<java.io.File> includes = new ArrayList<>();
    IRunnableWithProgress op = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            try {
                WorkflowProject wfp = topFolder.getProject();
                DesignerProxy designerProxy = wfp.getDesignerProxy();
                java.io.File assetDir = wfp.getAssetDir();
                java.io.File zipFile = null;
                java.io.File tempDir = wfp.getTempDir();
                monitor.beginTask("Import Packages", 100 * importPackageSelectPage.getSelectedPackages().size());
                monitor.subTask("Importing selected packages...");
                monitor.worked(10);
                StringBuilder sb = new StringBuilder();
                ProgressMonitor progressMonitor = new SwtProgressMonitor(new SubProgressMonitor(monitor, 100));
                for (File pkgFile : importPackageSelectPage.getSelectedPackages()) {
                    if (pkgFile.getContent() == null) {
                        // discovered
                        if (pkgFile.getUrl() != null) {
                            // assets
                            HttpHelper httpHelper = new HttpHelper(pkgFile.getUrl());
                            httpHelper.setConnectTimeout(MdwPlugin.getSettings().getHttpConnectTimeout());
                            httpHelper.setReadTimeout(MdwPlugin.getSettings().getHttpReadTimeout());
                            pkgFile.setContent(httpHelper.get());
                        } else if (mavenDiscovery)
                            importFromMaven(pkgFile.getName(), wfp, includes, monitor);
                        else {
                            getPackageNames(pkgFile.getName(), sb);
                        }
                    }
                    String pkgFileContent = pkgFile.getContent();
                    if (pkgFileContent != null) {
                        Importer importer = new Importer(designerProxy.getPluginDataAccess(), wfp.isFilePersist() && wfp.isRemote() ? null : getShell());
                        WorkflowPackage importedPackage = importer.importPackage(wfp, pkgFileContent, progressMonitor);
                        if (// canceled
                        importedPackage == null) {
                            progressMonitor.done();
                            break;
                        } else {
                            if (upgradeAssets) {
                                progressMonitor.subTask("Upgrading activity implementors and other assets...");
                                designerProxy.upgradeAssets(importedPackage);
                            }
                            if (// file system eclipse
                            wfp.isFilePersist())
                                // sync
                                wfp.getSourceProject().refreshLocal(2, null);
                            // TODO refresh Archive in case existing package
                            // was
                            // moved there
                            importedPackages.add(importedPackage);
                            includes.add(new java.io.File(assetDir + "/" + importedPackage.getName().replace('.', '/')));
                        }
                        progressMonitor.done();
                    }
                }
                if (sb.length() > 0) {
                    String url = wfp.getServiceUrl() + "/Services/Assets";
                    Map<String, String> hdrs = new HashMap<>();
                    hdrs.put("Content-Type", "application/json");
                    hdrs.put("request-query-string", "discoveryUrl=" + discoveryUrl + "&discoveryType=distributed");
                    DesignerHttpHelper httpHelper = new DesignerHttpHelper(new URL(url), wfp.getUser().getJwtToken());
                    httpHelper.setConnectTimeout(MdwPlugin.getSettings().getHttpConnectTimeout());
                    httpHelper.setReadTimeout(MdwPlugin.getSettings().getHttpReadTimeout());
                    httpHelper.setHeaders(hdrs);
                    httpHelper.put("{packages: [" + sb.toString() + "]}");
                }
                if (zipFormat) {
                    zipFile = importFile;
                    if (!wfp.isRemote())
                        unzipToLocal(wfp, zipFile, tempDir, assetDir, importedPackages, progressMonitor);
                }
                if (!includes.isEmpty()) {
                    if (!tempDir.exists() && !tempDir.mkdirs()) {
                        throw new IOException("Unable to create temp directory: " + tempDir);
                    }
                    zipFile = new java.io.File(tempDir + "/packages" + StringHelper.filenameDateToString(new Date()) + ".zip");
                    ZipHelper.zipWith(assetDir, zipFile, includes);
                }
                if (zipFile != null && wfp.isRemote() && wfp.isFilePersist()) {
                    uploadToRemoteServer(wfp, zipFile);
                    if (!zipFile.delete())
                        PluginMessages.log("Unable to delete the file " + zipFile.getPath());
                    progressMonitor.done();
                }
                wfp.getDesignerProxy().getCacheRefresh().doRefresh(true);
            } catch (ActionCancelledException ex) {
                throw new OperationCanceledException();
            } catch (Exception ex) {
                PluginMessages.log(ex);
                throw new InvocationTargetException(ex);
            }
        }
    };
    try {
        boolean confirmed = true;
        if (topFolder.getProject().checkRequiredVersion(6, 0, 13) && topFolder.getProject().isRemote())
            confirmed = MessageDialog.openConfirm(getShell(), "Confirm Import", "This import will impact the remote environment. Are you sure you want to import?");
        if (confirmed) {
            getContainer().run(true, true, op);
            if (!importedPackages.isEmpty())
                DesignerPerspective.promptForShowPerspective(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), importedPackages.get(0));
            IWorkbenchPage page = MdwPlugin.getActivePage();
            ProcessExplorerView processExplorer = (ProcessExplorerView) page.findView(ProcessExplorerView.VIEW_ID);
            if (processExplorer != null) {
                processExplorer.handleRefresh();
                processExplorer.expand(topFolder);
            }
        }
        return true;
    } catch (InterruptedException ex) {
        MessageDialog.openInformation(getShell(), "Import Package", "Import Cancelled");
        return true;
    } catch (Exception ex) {
        PluginMessages.uiError(getShell(), ex, "Import Package", importPackagePage.getProject());
        return false;
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) SwtProgressMonitor(com.centurylink.mdw.plugin.designer.SwtProgressMonitor) HashMap(java.util.HashMap) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ArrayList(java.util.ArrayList) DesignerHttpHelper(com.centurylink.mdw.designer.utils.DesignerHttpHelper) URL(java.net.URL) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Importer(com.centurylink.mdw.plugin.designer.Importer) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) ProcessExplorerView(com.centurylink.mdw.plugin.designer.views.ProcessExplorerView) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IOException(java.io.IOException) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) Date(java.util.Date) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) JSONException(org.json.JSONException) GeneralSecurityException(java.security.GeneralSecurityException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitor(com.centurylink.mdw.common.utilities.timer.ProgressMonitor) SwtProgressMonitor(com.centurylink.mdw.plugin.designer.SwtProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) File(com.centurylink.mdw.plugin.designer.model.File) HttpHelper(com.centurylink.mdw.common.utilities.HttpHelper) DesignerHttpHelper(com.centurylink.mdw.designer.utils.DesignerHttpHelper)

Example 65 with WorkflowProject

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

the class MdwProjectPropertyTester method test.

public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    IAdaptable adaptable = (IAdaptable) receiver;
    if ("mdwWorkflowProject".equals(property)) {
        if (adaptable instanceof IProject) {
            return WorkflowProjectManager.getInstance().getWorkflowProject((IProject) adaptable) != null;
        }
    }
    if ("mdwWorkflowLocalProject".equals(property)) {
        if (adaptable instanceof IProject) {
            WorkflowProject workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject((IProject) adaptable);
            if (workflowProject == null)
                return false;
            else
                return !workflowProject.isRemote();
        }
    }
    if ("mdwWorkflowWebProject".equals(property)) {
        // returns false for Cloud projects
        if (adaptable instanceof IProject) {
            WorkflowProject workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject((IProject) adaptable);
            return workflowProject != null && !workflowProject.isCloudProject() && (adaptable.equals(workflowProject.getWebProject()));
        }
    }
    if ("notMdwWorkflowOsgiProject".equals(property)) {
        if (adaptable instanceof IProject) {
            WorkflowProject workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject((IProject) adaptable);
            if (workflowProject == null)
                return false;
            else
                return !workflowProject.isOsgi();
        }
    }
    if ("mdwProjectVersion".equals(property)) {
        if (adaptable instanceof IProject) {
            IProject project = (IProject) adaptable;
            WorkflowProject workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(project);
            if (workflowProject == null)
                return false;
            if (args == null)
                return false;
            if (args.length < 2)
                return false;
            if (args.length == 2)
                return workflowProject.checkRequiredVersion((Integer) args[0], (Integer) args[1]);
            else
                return workflowProject.checkRequiredVersion((Integer) args[0], (Integer) args[1], (Integer) args[2]);
        } else {
            return false;
        }
    }
    if ("mdwProjectVersionLessThan".equals(property)) {
        if (adaptable instanceof IProject) {
            IProject project = (IProject) adaptable;
            WorkflowProject workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(project);
            if (workflowProject == null)
                return false;
            if (args == null)
                return false;
            if (args.length < 2)
                return false;
            if (args.length == 2)
                return !workflowProject.checkRequiredVersion((Integer) args[0], (Integer) args[1]);
            else
                return !workflowProject.checkRequiredVersion((Integer) args[0], (Integer) args[1], (Integer) args[2]);
        } else {
            return false;
        }
    }
    return false;
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IProject(org.eclipse.core.resources.IProject)

Aggregations

WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)128 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)31 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)25 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)22 ArrayList (java.util.ArrayList)22 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)21 CoreException (org.eclipse.core.runtime.CoreException)19 Action (org.eclipse.jface.action.Action)19 IAction (org.eclipse.jface.action.IAction)18 IProject (org.eclipse.core.resources.IProject)17 IFile (org.eclipse.core.resources.IFile)16 PartInitException (org.eclipse.ui.PartInitException)16 IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)16 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)15 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)12 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)11 InvocationTargetException (java.lang.reflect.InvocationTargetException)11 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)11 IOException (java.io.IOException)10 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)9