Search in sources :

Example 6 with WorkflowAsset

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

the class ProcessExplorerActionGroup method createExportActionGroup.

private ActionGroup createExportActionGroup() {
    exportMenu = new MenuManager("Export", MdwPlugin.getImageDescriptor("icons/export.gif"), MdwMenuManager.MDW_MENU_PREFIX + "menu.export");
    return new ActionGroup() {

        @Override
        public void fillContextMenu(IMenuManager menu) {
            exportMenu.removeAll();
            IStructuredSelection selection = getSelection();
            if (exportPackageApplies(selection))
                exportMenu.add(exportPackageAction);
            if (exportProcessApplies(selection))
                exportMenu.add(exportProcessAction);
            if (exportWorkflowAssetApplies(selection)) {
                WorkflowAsset asset = (WorkflowAsset) selection.getFirstElement();
                // menu item text and icon are dynamic
                exportWorkflowAssetAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "export.to.file");
                exportWorkflowAssetAction.setText(asset.getTitle() + " to File...");
                exportWorkflowAssetAction.setImageDescriptor(MdwPlugin.getImageDescriptor(ICONS + asset.getIcon()));
                exportMenu.add(exportWorkflowAssetAction);
            }
            if (exportAttributesApplies(selection)) {
                List<IAction> exportAttrsActions = getExportAttributeActions(selection);
                if (!exportAttrsActions.isEmpty()) {
                    MenuManager attributesMenu = new MenuManager("Attributes", MdwPlugin.getImageDescriptor("icons/attribute.gif"), MdwMenuManager.MDW_MENU_PREFIX + "menu.export.attributes");
                    attributesMenu.removeAll();
                    for (IAction action : exportAttrsActions) attributesMenu.add(action);
                    exportMenu.add(attributesMenu);
                }
            }
            if (exportTaskTemplatesApplies(selection))
                exportMenu.add(exportTaskTemplateAction);
            exportMenu.add(new Separator(OTHER));
            IWorkbenchAction otherAction = ActionFactory.EXPORT.create(getViewSite().getWorkbenchWindow());
            otherAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "export.other");
            otherAction.setText(OTHER_DOT);
            exportMenu.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) Separator(org.eclipse.jface.action.Separator)

Example 7 with WorkflowAsset

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

the class ImportAssetWizard method performImportExport.

void performImportExport(ProgressMonitor progressMonitor) throws IOException, XmlException, DataAccessException, ValidationException, ActionCancelledException {
    DesignerProxy designerProxy = getProject().getDesignerProxy();
    progressMonitor.progress(10);
    progressMonitor.subTask("Reading file");
    byte[] bytes = readFile(getPage().getFilePath());
    progressMonitor.progress(20);
    if (progressMonitor.isCanceled())
        throw new ActionCancelledException();
    progressMonitor.subTask("Performing Import");
    File assetFile = new File(getPage().getFilePath());
    WorkflowAsset existingAsset = getAsset();
    if (// package selected, not asset
    existingAsset == null)
        existingAsset = getPackage().getAsset(assetFile.getName());
    boolean binary;
    RuleSetVO newRuleSet = new RuleSetVO();
    if (existingAsset == null) {
        newRuleSet.setName(assetFile.getName());
        newRuleSet.setLanguage(RuleSetVO.getFormat(assetFile.getName()));
        binary = newRuleSet.isBinary();
    } else {
        newRuleSet.setName(existingAsset.getName());
        newRuleSet.setLanguage(existingAsset.getLanguage());
        binary = existingAsset.isBinary();
        // custom
        newRuleSet.setAttributes(existingAsset.getAttributes());
    // attributes
    }
    newRuleSet.setRaw(getProject().isFilePersist());
    if (getProject().isFilePersist())
        newRuleSet.setRawFile(new File(getProject().getAssetDir() + "/" + getPackage().getName() + "/" + newRuleSet.getName()));
    if (binary) {
        if (newRuleSet.isRaw())
            newRuleSet.setRawContent(bytes);
        else
            newRuleSet.setRuleSet(RuleSetVO.encode(bytes));
    } else
        newRuleSet.setRuleSet(new String(bytes));
    WorkflowAsset newAsset = WorkflowAssetFactory.createAsset(newRuleSet, getPackage());
    // check db in case created in another session
    RuleSetVO existing = getProject().getDesignerDataAccess().getRuleSet(getPackage().getId(), newRuleSet.getName());
    progressMonitor.progress(10);
    newAsset.setVersion(existing == null ? 1 : existing.getVersion() + 1);
    newAsset.setComment(getPage().getComments());
    newAsset.setPackage(getPackage());
    newAsset.setId(Long.valueOf(-1));
    newAsset.setCreateUser(getProject().getUser().getUsername());
    newAsset.setLockingUser(getProject().getUser().getUsername());
    designerProxy.saveWorkflowAsset(newAsset, getPage().isLocked());
    getProject().getDataAccess().getDesignerDataModel().addRuleSet(newAsset.getRuleSetVO());
    // update the tree
    if (existingAsset != null) {
        getPackage().removeAsset(existingAsset);
        newAsset.getRuleSetVO().setPrevVersion(existingAsset.getRuleSetVO());
        getProject().getUnpackagedWorkflowAssets().add(existingAsset);
        existingAsset.setPackage(getProject().getDefaultPackage());
    }
    newAsset.getPackage().addAsset(newAsset);
    designerProxy.savePackage(newAsset.getPackage());
    setElement(newAsset);
    progressMonitor.progress(30);
    if (existingAsset != null)
        WorkflowAssetFactory.deRegisterAsset(existingAsset);
}
Also used : DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) File(java.io.File) RuleSetVO(com.centurylink.mdw.model.value.attribute.RuleSetVO)

Example 8 with WorkflowAsset

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

the class TestResultsFormatter method getXslFile.

private File getXslFile(String filename) throws IOException {
    File stylesheet = null;
    if (project.isFilePersist()) {
        // prefer override (non-MDW testing package); fall back to MDW
        // testing package
        WorkflowPackage mdwTestingPackage = null;
        WorkflowPackage otherTestingPackage = null;
        for (WorkflowPackage pkg : project.getTopLevelPackages()) {
            if (pkg.getName().equals("com.centurylink.mdw.testing"))
                mdwTestingPackage = pkg;
            else if (pkg.getName().endsWith(".testing"))
                otherTestingPackage = pkg;
        }
        if (otherTestingPackage != null) {
            WorkflowAsset asset = otherTestingPackage.getAsset(filename);
            if (asset != null)
                stylesheet = asset.getRawFile();
        }
        if (stylesheet == null && mdwTestingPackage != null) {
            WorkflowAsset asset = mdwTestingPackage.getAsset(filename);
            if (asset != null)
                stylesheet = asset.getRawFile();
        }
    }
    if (stylesheet == null) {
        // fall back to template version in designer
        URL localUrl = PluginUtil.getLocalResourceUrl("templates/xsl/" + filename);
        try {
            stylesheet = new File(new URI(localUrl.toString()));
        } catch (URISyntaxException ex) {
            throw new IOException(ex.getMessage(), ex);
        }
    }
    return stylesheet;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) File(java.io.File) URI(java.net.URI) URL(java.net.URL)

Example 9 with WorkflowAsset

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

the class CopyDialog method nameAlreadyExists.

private boolean nameAlreadyExists(String name) {
    WorkflowProject workflowProject = workflowElement.getProject();
    PluginDataAccess dataAccess = workflowProject.getDataAccess();
    if (workflowElement instanceof WorkflowProcess)
        return dataAccess.processNameExists(targetPackage.getPackageVO(), name);
    else if (workflowElement instanceof ExternalEvent)
        return workflowProject.externalEventNameExists(name);
    else if (workflowElement instanceof WorkflowAsset)
        return targetPackage == null ? workflowProject.workflowAssetNameExists(name) : targetPackage.workflowAssetNameExists(name);
    else
        return false;
}
Also used : WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) PluginDataAccess(com.centurylink.mdw.plugin.designer.PluginDataAccess)

Example 10 with WorkflowAsset

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

the class WorkflowAssetEditor method fillTreeCombo.

private void fillTreeCombo() {
    treeCombo.removeAll();
    Comparator<WorkflowElement> comparator = new Comparator<WorkflowElement>() {

        public int compare(WorkflowElement we1, WorkflowElement we2) {
            return we1.getLabel().compareTo(we2.getLabel());
        }
    };
    if (isProcess()) {
        List<WorkflowPackage> packages = getProject().getTopLevelUserVisiblePackages();
        for (WorkflowPackage pkg : packages) {
            CTreeComboItem packageItem = new CTreeComboItem(treeCombo, SWT.NONE);
            packageItem.setText(pkg.getName());
            packageItem.setImage(pkg.getIconImage());
            for (WorkflowProcess process : pkg.getProcesses()) {
                CTreeComboItem processItem = new CTreeComboItem(packageItem, SWT.NONE);
                processItem.setText(process.getLabel());
                processItem.setImage(process.getIconImage());
            }
        }
    } else if (isTaskTemplate()) {
        List<WorkflowPackage> packages = getProject().getTopLevelUserVisiblePackages();
        for (WorkflowPackage pkg : packages) {
            List<TaskTemplate> templatesForPkg = pkg.getTaskTemplates();
            if (templatesForPkg != null && !templatesForPkg.isEmpty()) {
                CTreeComboItem packageItem = new CTreeComboItem(treeCombo, SWT.NONE);
                packageItem.setText(pkg.getName());
                packageItem.setImage(pkg.getIconImage());
                for (TaskTemplate template : templatesForPkg) {
                    CTreeComboItem templateItem = new CTreeComboItem(packageItem, SWT.NONE);
                    templateItem.setText(template.getLabel());
                    templateItem.setImage(template.getIconImage());
                }
            }
        }
    } else {
        List<WorkflowAsset> assets = getProject().getAssetList(assetTypes);
        Map<WorkflowPackage, List<WorkflowAsset>> packageAssets = new TreeMap<>();
        for (WorkflowAsset asset : assets) {
            List<WorkflowAsset> assetsForPkg = packageAssets.get(asset.getPackage());
            if (assetsForPkg == null) {
                assetsForPkg = new ArrayList<>();
                packageAssets.put(asset.getPackage(), assetsForPkg);
            }
            assetsForPkg.add(asset);
        }
        for (Map.Entry<WorkflowPackage, List<WorkflowAsset>> pkgAssets : packageAssets.entrySet()) {
            CTreeComboItem packageItem = new CTreeComboItem(treeCombo, SWT.NONE);
            packageItem.setText(pkgAssets.getKey().getName());
            packageItem.setImage(pkgAssets.getKey().getIconImage());
            List<WorkflowAsset> assetsForPkg = pkgAssets.getValue();
            Collections.sort(assetsForPkg, comparator);
            for (WorkflowAsset assetForPkg : assetsForPkg) {
                CTreeComboItem assetItem = new CTreeComboItem(packageItem, SWT.NONE);
                assetItem.setText(assetForPkg.getLabel());
                assetItem.setImage(assetForPkg.getIconImage());
            }
        }
    }
}
Also used : TaskTemplate(com.centurylink.mdw.plugin.designer.model.TaskTemplate) WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem) ArrayList(java.util.ArrayList) Comparator(java.util.Comparator) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) ArrayList(java.util.ArrayList) List(java.util.List) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) Map(java.util.Map) TreeMap(java.util.TreeMap) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Aggregations

WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)46 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)17 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)15 ArrayList (java.util.ArrayList)13 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)8 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)8 IFile (org.eclipse.core.resources.IFile)8 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)7 RuleSetVO (com.centurylink.mdw.model.value.attribute.RuleSetVO)6 File (java.io.File)6 IOException (java.io.IOException)6 CoreException (org.eclipse.core.runtime.CoreException)6 IEditorPart (org.eclipse.ui.IEditorPart)5 DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)4 ActivityImpl (com.centurylink.mdw.plugin.designer.model.ActivityImpl)4 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)4 List (java.util.List)4 IFolder (org.eclipse.core.resources.IFolder)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 CodeTimer (com.centurylink.mdw.plugin.CodeTimer)3