Search in sources :

Example 11 with WorkflowAsset

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

the class ProcessExplorerDropTarget method checkForDuplicates.

/**
 * Returns true if duplicates found.
 */
private boolean checkForDuplicates(WorkflowPackage targetPackage, String[] elements) {
    for (String element : elements) {
        if (element.startsWith("Process~")) {
            String processName = element.substring(8);
            for (WorkflowProcess process : targetPackage.getProcesses()) {
                if (process.getName().equals(processName)) {
                    String msg = PACAKGE + targetPackage.getName() + "' already contains version " + process.getVersionLabel() + " of process '" + process.getName() + "'";
                    MessageDialog.openError(getViewer().getControl().getShell(), "Duplicate Process", msg);
                    return true;
                }
            }
        } else if (element.startsWith("ExternalEvent~")) {
            String externalEventName = element.substring(14);
            for (ExternalEvent externalEvent : targetPackage.getExternalEvents()) {
                if (externalEvent.getName().equals(externalEventName)) {
                    String msg = PACAKGE + targetPackage.getName() + "' already contains " + " an external event named '" + externalEvent.getName() + "'";
                    MessageDialog.openError(getViewer().getControl().getShell(), "Duplicate External Event", msg);
                    return true;
                }
            }
        } else if (element.startsWith("ActivityImpl~")) {
        // TODO: dups okay?
        } else if (element.startsWith("WorkflowAsset~")) {
            String assetName = element.substring(14);
            for (WorkflowAsset asset : targetPackage.getAssets()) {
                if (asset.getName().equals(assetName)) {
                    String msg = PACAKGE + targetPackage.getName() + "' already contains " + " an definition document named '" + asset.getName() + "'";
                    MessageDialog.openError(getViewer().getControl().getShell(), "Duplicate Definition Doc", msg);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 12 with WorkflowAsset

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

the class ProcessExplorerDropTarget method handleDropWorkflowAsset.

private boolean handleDropWorkflowAsset(String assetInfo, WorkflowPackage targetPackage, int operation) {
    if (!targetPackage.getProject().checkRequiredVersion(5, 0)) {
        String msg = "Packaging of Definition Documents (such as scripts and pages) is only supported for MDWFramework 5.0 and later.";
        MessageDialog.openError(getViewer().getControl().getShell(), "Package Def Doc", msg);
        return false;
    }
    Long assetId = getWorkflowAssetId(assetInfo);
    WorkflowProject workflowProject = targetPackage.getProject();
    WorkflowPackage sourcePackage = workflowProject.getPackage(getPackageName(assetInfo));
    DesignerProxy designerProxy = workflowProject.getDesignerProxy();
    if (operation == DND.DROP_COPY) {
        WorkflowAsset existing = workflowProject.getAsset(assetId);
        CopyDialog copyDialog = new CopyDialog(getViewer().getControl().getShell(), existing, existing.getName(), String.valueOf(existing.getVersion()), targetPackage);
        if (copyDialog.open() == Dialog.OK) {
            String newName = copyDialog.getNewName();
            if (!existing.isLoaded())
                existing.load();
            WorkflowAsset newCopy;
            try {
                // try and use reflection to make it the correct type
                Constructor<? extends WorkflowAsset> ctor = existing.getClass().getConstructor(existing.getClass());
                newCopy = ctor.newInstance(existing);
            } catch (Exception ex) {
                PluginMessages.log(ex);
                newCopy = new WorkflowAsset(existing);
            }
            newCopy.setName(newName);
            newCopy.setVersion(1);
            newCopy.setPackage(targetPackage);
            try {
                designerProxy.createNewWorkflowAsset(newCopy, true);
            } catch (Exception ex) {
                PluginMessages.uiError(ex, "Copy " + existing.getTitle(), existing.getProject());
            }
            newCopy.addElementChangeListener(workflowProject);
            newCopy.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, newCopy);
            WorkflowAssetFactory.registerAsset(newCopy);
            ((TreeViewer) getViewer()).refresh(targetPackage, true);
            return true;
        }
        return false;
    } else if (operation == DND.DROP_MOVE) {
        // don't allow multiple versions of the same asset in a package
        if (!targetPackage.isDefaultPackage()) {
            WorkflowAsset asset = workflowProject.getAsset(assetId);
            if (targetPackage.getAsset(asset.getName()) != null) {
                MessageDialog.openError(MdwPlugin.getShell(), "Asset Exists", "Asset '" + asset.getName() + "' already exists in package '" + targetPackage.getName() + "'.");
                return false;
            }
        }
        if (targetPackage.isDefaultPackage()) {
            designerProxy.removeWorkflowAssetFromPackage(assetId, sourcePackage);
        } else {
            assetId = designerProxy.moveWorkflowAssetToPackage(assetId, targetPackage);
        }
        ((TreeViewer) getViewer()).refresh(targetPackage.getProject(), true);
        WorkflowAssetFactory.registerAsset(workflowProject.getAsset(assetId));
        return true;
    } else {
        return false;
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) CopyDialog(com.centurylink.mdw.plugin.designer.dialogs.CopyDialog) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) SWTException(org.eclipse.swt.SWTException)

Example 13 with WorkflowAsset

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

the class WorkflowAssetAttributesSection method select.

public boolean select(Object toTest) {
    // currently only definition docs supported
    if (!(toTest instanceof WorkflowAsset))
        return false;
    WorkflowAsset asset = (WorkflowAsset) toTest;
    if (!asset.getProject().isMdw5())
        return false;
    CustomAttributeVO customAttribute = asset.getCustomAttribute();
    if (customAttribute == null || !customAttribute.hasDefinition())
        return false;
    if (customAttribute.hasRoles()) {
        // check authorization
        for (String role : customAttribute.getRoles()) {
            if (asset.isUserAuthorized(role))
                return true;
        }
        return false;
    }
    return true;
}
Also used : CustomAttributeVO(com.centurylink.mdw.model.value.attribute.CustomAttributeVO) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset)

Example 14 with WorkflowAsset

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

the class WorkflowAssetLockSection method elementChanged.

public void elementChanged(ElementChangeEvent ece) {
    if (ece.getElement().equals(workflowAsset)) {
        if (ece.getChangeType().equals(ChangeType.PROPERTIES_CHANGE)) {
            WorkflowAsset changedVersion = (WorkflowAsset) ece.getElement();
            if (!lockUserPropertyEditor.getValue().equals(changedVersion.getLockingUser())) {
                lockUserPropertyEditor.setValue(changedVersion.getLockingUser());
                modDatePropertyEditor.setValue(changedVersion.getModifyDate());
                lockButtonPropertyEditor.setLabel(changedVersion.isLockedToUser() ? "Unlock" : "Lock");
            }
            notifyLabelChange();
        }
    }
}
Also used : WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset)

Example 15 with WorkflowAsset

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

the class ParameterizedCombo method fillParamCombo.

private void fillParamCombo(String[] types) {
    paramCombo.removeAll();
    Comparator<WorkflowElement> comparator = new Comparator<WorkflowElement>() {

        public int compare(WorkflowElement we1, WorkflowElement we2) {
            return we1.getName().compareTo(we2.getName());
        }
    };
    List<WorkflowAsset> assets = workflowProject.getAssetList(Arrays.asList(types));
    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 (WorkflowPackage pkg : packageAssets.keySet()) {
        CTreeComboItem packageItem = new CTreeComboItem(paramCombo, SWT.NONE);
        packageItem.setText(pkg.getName());
        packageItem.setImage(pkg.getIconImage());
        List<WorkflowAsset> assetsForPkg = packageAssets.get(pkg);
        Collections.sort(assetsForPkg, comparator);
        for (WorkflowAsset assetForPkg : assetsForPkg) {
            CTreeComboItem assetItem = new CTreeComboItem(packageItem, SWT.NONE);
            assetItem.setText(assetForPkg.getName());
            assetItem.setImage(assetForPkg.getIconImage());
        }
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) ArrayList(java.util.ArrayList) List(java.util.List) TreeMap(java.util.TreeMap) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) Comparator(java.util.Comparator)

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