Search in sources :

Example 26 with WorkflowElement

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

the class WorkflowProject method findArchivedPackages.

/**
 * Returns all top-level archived (non-latest) packages, populated with
 * their descendants which include the appropriate process versions. Uses
 * 10% of progressMonitor.
 */
private Folder findArchivedPackages(ProgressMonitor progressMonitor, boolean visiblePkgsOnly) {
    CodeTimer timer = new CodeTimer("findAuthorizedArchivedPackages()");
    if (progressMonitor != null)
        progressMonitor.subTask("Organizing packages");
    Folder archivedPkgFolder = new Folder("Archive", this);
    archivedPkgFolder.setIcon("archive.gif");
    List<WorkflowPackage> topLevelArchivedPackageList = new ArrayList<>();
    List<WorkflowPackage> allArchivedPackages = new ArrayList<>();
    for (PackageVO packageVO : getDataAccess().getPackages(false)) {
        if (isShowDefaultPackage() || !packageVO.isDefaultPackage()) {
            WorkflowPackage potentialArchived = new WorkflowPackage(this, packageVO);
            if (!getTopLevelPackages().contains(potentialArchived)) {
                potentialArchived.setArchived(true);
                potentialArchived.setProcesses(findProcesses(potentialArchived));
                potentialArchived.setAssets(findWorkflowAssets(potentialArchived));
                potentialArchived.setActivityImpls(findActivityImplementors(potentialArchived));
                potentialArchived.setExternalEvents(findExternalEvents(potentialArchived));
                potentialArchived.setTaskTemplates(findTaskTemplates(potentialArchived));
                allArchivedPackages.add(potentialArchived);
            }
        }
    }
    // organize the package version hierarchy
    Map<String, WorkflowPackage> topLevelArchivedPackages = new HashMap<>();
    for (WorkflowPackage archivedPackage : allArchivedPackages) {
        WorkflowPackage topLevel = topLevelArchivedPackages.get(archivedPackage.getName());
        if ((!visiblePkgsOnly || (visiblePkgsOnly && archivedPackage.isVisible())) && (topLevel == null || archivedPackage.getPackageVO().getVersion() > topLevel.getPackageVO().getVersion()))
            topLevelArchivedPackages.put(archivedPackage.getName(), archivedPackage);
    }
    for (WorkflowPackage topLevelArchivedPackage : topLevelArchivedPackages.values()) {
        for (WorkflowPackage archivedPackage : allArchivedPackages) {
            if (topLevelArchivedPackage.getName().equals(archivedPackage.getName()) && (!visiblePkgsOnly || (visiblePkgsOnly && archivedPackage.isVisible()))) {
                if (topLevelArchivedPackage.equals(archivedPackage)) {
                    // clone top-level process for first child
                    WorkflowPackage firstChild = new WorkflowPackage(topLevelArchivedPackage);
                    firstChild.setArchived(true);
                    firstChild.setTopLevelVersion(topLevelArchivedPackage);
                    firstChild.setProcesses(topLevelArchivedPackage.getProcesses());
                    firstChild.setAssets(topLevelArchivedPackage.getAssets());
                    firstChild.setActivityImpls(topLevelArchivedPackage.getActivityImpls());
                    firstChild.setExternalEvents(topLevelArchivedPackage.getExternalEvents());
                    firstChild.setTaskTemplates(topLevelArchivedPackage.getTaskTemplates());
                    topLevelArchivedPackage.addDescendantPackageVersion(firstChild);
                } else {
                    archivedPackage.setTopLevelVersion(topLevelArchivedPackage);
                    topLevelArchivedPackage.addDescendantPackageVersion(archivedPackage);
                }
            }
        }
        topLevelArchivedPackageList.add(topLevelArchivedPackage);
        topLevelArchivedPackage.setArchivedFolder(archivedPkgFolder);
    }
    Collections.sort(topLevelArchivedPackageList);
    if (isShowDefaultPackage()) {
        // add unpackaged (default package)
        PackageVO defaultPackageVO = new PackageVO();
        defaultPackageVO.setPackageId(Long.valueOf(0));
        defaultPackageVO.setPackageName(PackageVO.DEFAULT_PACKAGE_NAME);
        archivedDefaultPackage = new WorkflowPackage(this, defaultPackageVO);
        archivedDefaultPackage.setProcesses(findUnpackagedProcesses());
        archivedDefaultPackage.setChildFolders(findUnpackagedAssetFolders());
        archivedDefaultPackage.setArchived(true);
        topLevelArchivedPackageList.add(0, archivedDefaultPackage);
    }
    List<WorkflowElement> children = new ArrayList<>();
    children.addAll(topLevelArchivedPackageList);
    archivedPkgFolder.setChildren(children);
    if (progressMonitor != null)
        progressMonitor.progress(10);
    timer.stopAndLog();
    return archivedPkgFolder;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) PackageVO(com.centurylink.mdw.model.value.process.PackageVO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Folder(com.centurylink.mdw.plugin.designer.model.Folder) IVirtualFolder(org.eclipse.wst.common.componentcore.resources.IVirtualFolder) IFolder(org.eclipse.core.resources.IFolder) CodeTimer(com.centurylink.mdw.plugin.CodeTimer) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 27 with WorkflowElement

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

the class WorkflowProject method newPackageVersion.

public void newPackageVersion(WorkflowPackage newPkg, WorkflowPackage prevPkg) {
    if (isFilePersist()) {
        // refresh prevPkg since it's fast
        try {
            PackageVO pkg = getDesignerDataAccess().loadPackage(prevPkg.getId(), false);
            if (// when incrementing by saving non-process
            pkg == null)
                // pkgs
                return;
            prevPkg.setPackageVO(pkg);
            prevPkg.setProcesses(findProcesses(prevPkg));
            prevPkg.setExternalEvents(findExternalEvents(prevPkg));
            prevPkg.setActivityImpls(findActivityImplementors(prevPkg));
            prevPkg.setAssets(findWorkflowAssets(prevPkg));
            prevPkg.setTaskTemplates(findTaskTemplates(prevPkg));
            // may have been called in response to vcs save new process
            // version
            prevPkg.syncProcesses();
        } catch (Exception ex) {
            PluginMessages.log(ex);
        }
    }
    // contents
    for (WorkflowElement we : getArchivedUserVisiblePackagesFolder().getChildren()) {
        WorkflowPackage pv = (WorkflowPackage) we;
        if (pv.getName().equals(prevPkg.getName())) {
            List<WorkflowPackage> descendants = pv.getDescendantPackageVersions();
            if (descendants == null) {
                descendants = new ArrayList<>();
                pv.setDescendantPackageVersions(descendants);
            }
            descendants.add(prevPkg);
            prevPkg.setTopLevelVersion(pv);
        }
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) PackageVO(com.centurylink.mdw.model.value.process.PackageVO) CoreException(org.eclipse.core.runtime.CoreException) JSONException(org.json.JSONException) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) MdwSecurityException(com.centurylink.mdw.auth.MdwSecurityException) MalformedURLException(java.net.MalformedURLException) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 28 with WorkflowElement

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

the class WorkflowProject method getAllExternalEvents.

/**
 * Returns all external events regardless of packaging and archive status.
 */
/**
 * Returns all event handlers, regardless of packaging.
 */
public List<ExternalEvent> getAllExternalEvents() {
    List<ExternalEvent> allHandlers = new ArrayList<>();
    for (WorkflowPackage pkg : getTopLevelPackages()) {
        for (ExternalEvent handler : pkg.getExternalEvents()) {
            if (!allHandlers.contains(handler))
                allHandlers.add(handler);
        }
    }
    for (WorkflowElement topLevelArchived : getArchivedPackageFolder().getChildren()) {
        if (topLevelArchived instanceof WorkflowPackage) {
            WorkflowPackage topLevelPkg = (WorkflowPackage) topLevelArchived;
            if (topLevelPkg.hasDescendantPackageVersions()) {
                for (WorkflowPackage pkg : topLevelPkg.getDescendantPackageVersions()) {
                    for (ExternalEvent handler : pkg.getExternalEvents()) {
                        if (!allHandlers.contains(handler))
                            allHandlers.add(handler);
                    }
                }
            }
        }
    }
    Collections.sort(allHandlers);
    return allHandlers;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ArrayList(java.util.ArrayList) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 29 with WorkflowElement

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

the class SearchResultsPage method setInput.

public void setInput(ISearchResult result, Object uiState) {
    if (result == null)
        return;
    searchResults = (SearchResults) result;
    List<WorkflowElement> elements = new ArrayList<WorkflowElement>();
    for (WorkflowElement workflowElement : searchResults.getMatchingElements()) elements.add(workflowElement);
    tableEditor.setValue(elements);
    tableEditor.getTable().setSortColumn(tableEditor.getTable().getColumn(0));
    tableEditor.getTable().setSortDirection(SWT.UP);
    tableEditor.getTableViewer().setComparator(getViewerComparator(tableEditor.getColumnSpecs().get(0)));
}
Also used : ArrayList(java.util.ArrayList) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 30 with WorkflowElement

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

the class ImportAssetPage method createControls.

@Override
protected void createControls(Composite composite, int ncol) {
    super.createControls(composite, ncol);
    createCommentsControls(composite, ncol);
    ImportExportWizard wizard = (ImportExportWizard) getWizard();
    WorkflowElement we = wizard.getElement();
    if (we != null && !we.getProject().isFilePersist())
        createLockControls(composite, ncol);
}
Also used : WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Aggregations

WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)65 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)25 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)25 IAction (org.eclipse.jface.action.IAction)22 Action (org.eclipse.jface.action.Action)21 IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)21 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)19 ArrayList (java.util.ArrayList)17 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)14 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)11 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 IFile (org.eclipse.core.resources.IFile)8 AutomatedTestSuite (com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)7 Folder (com.centurylink.mdw.plugin.designer.model.Folder)7 LegacyExpectedResults (com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults)7 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)7 PartInitException (org.eclipse.ui.PartInitException)7 AutomatedTestResults (com.centurylink.mdw.plugin.designer.model.AutomatedTestResults)5 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)5