Search in sources :

Example 71 with WorkflowProcess

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

the class Importer method importAttributes.

public void importAttributes(final WorkflowElement element, final String xml, final ProgressMonitor progressMonitor, String attrPrefix) throws DataAccessException, XmlException {
    progressMonitor.subTask(PARSING_XML);
    int schemaVersion = dataAccess.getSchemaVersion();
    ProcessImporter importer = DataAccess.getProcessImporter(schemaVersion);
    progressMonitor.progress(40);
    progressMonitor.subTask("Saving attributes");
    ProcessDefinitionDocument procdef = ProcessDefinitionDocument.Factory.parse(xml, Compatibility.namespaceOptions());
    if (element instanceof WorkflowPackage && !((WorkflowPackage) element).getName().equals(procdef.getProcessDefinition().getPackageName()))
        throw new DataAccessException("Expected package: " + ((WorkflowPackage) element).getName() + " in attributes XML but found: " + procdef.getProcessDefinition().getPackageName());
    for (MDWProcess process : procdef.getProcessDefinition().getProcessList()) {
        ProcessDefinitionDocument oneProcDef = ProcessDefinitionDocument.Factory.newInstance();
        MDWProcessDefinition oneProc = oneProcDef.addNewProcessDefinition();
        oneProc.getProcessList().add(process);
        ProcessVO importedProc = importer.importProcess(oneProcDef.xmlText());
        if (element instanceof WorkflowProcess && !((WorkflowProcess) element).getName().equals(importedProc.getProcessName()))
            throw new DataAccessException("Expected process: " + ((WorkflowProcess) element).getName() + " in attributes XML but found: " + importedProc.getName());
        ProcessVO proc = dataAccess.getLatestProcess(importedProc.getName());
        if (proc == null)
            throw new DataAccessException("Process not found: " + importedProc.getName());
        Map<String, String> existAttrs = dataAccess.getDesignerDataAccess().getAttributes(OwnerType.PROCESS, proc.getId());
        Map<String, String> importedAttrs = importedProc.getOverrideAttributes();
        Map<String, String> setAttrs = new HashMap<>();
        if (existAttrs != null) {
            // retain existing attrs not related to this prefix
            for (Map.Entry<String, String> attrs : existAttrs.entrySet()) {
                if (!WorkAttributeConstant.isAttrNameFor(attrs.getKey(), attrPrefix))
                    setAttrs.put(attrs.getKey(), attrs.getValue());
            }
        }
        if (importedAttrs != null) {
            for (Map.Entry<String, String> attrs : importedAttrs.entrySet()) {
                if (!WorkAttributeConstant.isAttrNameFor(attrs.getKey(), attrPrefix))
                    throw new DataAccessException("Expected attribute prefix: " + attrPrefix + " in attributes XML but found attribute: " + attrs.getKey());
                else
                    setAttrs.put(attrs.getKey(), attrs.getValue());
            }
        }
        dataAccess.getDesignerDataAccess().setOverrideAttributes(attrPrefix, OwnerType.PROCESS, proc.getId(), setAttrs);
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) HashMap(java.util.HashMap) MDWProcessDefinition(com.centurylink.mdw.bpm.MDWProcessDefinition) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) ProcessImporter(com.centurylink.mdw.dataaccess.ProcessImporter) ProcessDefinitionDocument(com.centurylink.mdw.bpm.ProcessDefinitionDocument) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) Map(java.util.Map) HashMap(java.util.HashMap) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) MDWProcess(com.centurylink.mdw.bpm.MDWProcess)

Example 72 with WorkflowProcess

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

the class TableEditor method createTableViewer.

private TableViewer createTableViewer(Table table) {
    TableViewer lTableViewer = new TableViewer(table);
    lTableViewer.setUseHashlookup(true);
    lTableViewer.setColumnProperties(columnProps);
    if (!isReadOnly()) {
        CellEditor[] cellEditors = new CellEditor[columnSpecs.size()];
        for (int i = 0; i < columnSpecs.size(); i++) {
            ColumnSpec colSpec = columnSpecs.get(i);
            CellEditor cellEditor = null;
            if (!colSpec.hidden) {
                if (colSpec.type.equals(TYPE_TEXT)) {
                    if (colSpec.style != 0)
                        cellEditor = new TextCellEditor(table, colSpec.style);
                    else
                        cellEditor = new TextCellEditor(table);
                } else if (colSpec.type.equals(TYPE_CHECKBOX)) {
                    cellEditor = new CheckboxCellEditor(table);
                } else if (colSpec.type.equals(TYPE_COMBO)) {
                    int style = SWT.None;
                    if (colSpec.readOnly)
                        style = style | SWT.READ_ONLY;
                    cellEditor = new ComboBoxCellEditor(table, colSpec.options, style);
                    if (!colSpec.readOnly)
                        cellEditor.addListener(new EditableComboCellEditorListener((ComboBoxCellEditor) cellEditor, i));
                } else if (colSpec.type.equals(WorkflowAssetEditor.TYPE_ASSET)) {
                    int style = SWT.None;
                    if (colSpec.readOnly)
                        style = style | SWT.READ_ONLY;
                    cellEditor = new TreeComboCellEditor(table, style) {

                        @Override
                        protected void doSetValue(Object value) {
                            Object val = getValue();
                            if (val instanceof CTreeComboItem) {
                                CTreeComboItem selItem = (CTreeComboItem) getValue();
                                if (selItem != null) {
                                    super.doSetValue(selItem.getText());
                                    return;
                                }
                            }
                            if (value instanceof String) {
                                String strVal = (String) value;
                                if (strVal.indexOf('/') > -1) {
                                    super.doSetValue(strVal.substring(strVal.indexOf('/') + 1));
                                    return;
                                }
                            }
                            super.doSetValue(value);
                        }
                    };
                    ((TreeComboCellEditor) cellEditor).setSelectionModifier(new SelectionModifier() {

                        public String modify(CTreeComboItem selection) {
                            if (selection.getParentItem() != null) {
                                WorkflowPackage pkg = getProject().getPackage(selection.getParentItem().getText());
                                if (pkg == null || pkg.isDefaultPackage())
                                    return selection.getText();
                                else
                                    return pkg.getName() + "/" + selection.getText();
                            } else {
                                // ignore packages
                                return null;
                            }
                        }
                    });
                    // populate the treecombo
                    if (colSpec.source.equals(PROCESS)) {
                        List<WorkflowPackage> packages = getProject().getTopLevelUserVisiblePackages();
                        for (WorkflowPackage pkg : packages) {
                            CTreeComboItem packageItem = ((TreeComboCellEditor) cellEditor).addItem(pkg.getName());
                            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 {
                        List<WorkflowAsset> assets = getProject().getAssetList(Arrays.asList(colSpec.assetTypes));
                        Map<String, CTreeComboItem> packageItems = new HashMap<>();
                        for (WorkflowAsset asset : assets) {
                            String pkgName = asset.getPackage().getName();
                            CTreeComboItem packageItem = packageItems.get(pkgName);
                            if (packageItem == null) {
                                packageItem = ((TreeComboCellEditor) cellEditor).addItem(pkgName);
                                packageItem.setImage(asset.getPackage().getIconImage());
                                packageItems.put(pkgName, packageItem);
                            }
                            CTreeComboItem assetItem = new CTreeComboItem(packageItem, SWT.NONE);
                            assetItem.setText(asset.getLabel());
                            assetItem.setImage(asset.getIconImage());
                        }
                    }
                }
                if (colSpec.listener != null && cellEditor != null)
                    cellEditor.addListener(colSpec.listener);
                cellEditors[i] = cellEditor;
            }
        }
        lTableViewer.setCellEditors(cellEditors);
        lTableViewer.setCellModifier(cellModifier);
    }
    return lTableViewer;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) TreeComboCellEditor(com.centurylink.jface.viewers.TreeComboCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) SelectionModifier(com.centurylink.jface.viewers.TreeComboCellEditor.SelectionModifier) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) TreeComboCellEditor(com.centurylink.jface.viewers.TreeComboCellEditor) List(java.util.List) ArrayList(java.util.ArrayList) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) Map(java.util.Map) HashMap(java.util.HashMap)

Example 73 with WorkflowProcess

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

the class ProcessLockSection method elementChanged.

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

Example 74 with WorkflowProcess

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

the class ProcessVersionsSection method createContextMenu.

private Menu createContextMenu(Shell shell) {
    Menu menu = new Menu(shell, SWT.POP_UP);
    final StructuredSelection selection = (StructuredSelection) tableEditor.getTableViewer().getSelection();
    if (selection.size() == 1 && selection.getFirstElement() instanceof WorkflowProcess) {
        final WorkflowProcess processVer = (WorkflowProcess) selection.getFirstElement();
        MenuItem openItem = new MenuItem(menu, SWT.PUSH);
        openItem.setText("Open");
        ImageDescriptor openImageDesc = MdwPlugin.getImageDescriptor("icons/process.gif");
        openItem.setImage(openImageDesc.createImage());
        openItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                openProcess(processVer);
            }
        });
    }
    // delete
    if (!selection.isEmpty() && !process.getProject().isProduction() && process.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION) && (selection.size() == 1 && ((WorkflowProcess) selection.getFirstElement()).isLatest()) || MdwPlugin.getSettings().isAllowDeleteArchivedProcesses()) {
        MenuItem deleteItem = new MenuItem(menu, SWT.PUSH);
        deleteItem.setText("Delete...");
        ImageDescriptor deleteImageDesc = MdwPlugin.getImageDescriptor("icons/delete.gif");
        deleteItem.setImage(deleteImageDesc.createImage());
        deleteItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                if (selection.size() >= 1 && selection.getFirstElement() instanceof WorkflowProcess) {
                    WorkflowProcess[] processVers = new WorkflowProcess[selection.size()];
                    int idx = 0;
                    for (Iterator<?> iter = selection.iterator(); iter.hasNext(); ) {
                        processVers[idx] = (WorkflowProcess) iter.next();
                        idx++;
                    }
                    WorkflowElementActionHandler actionHandler = new WorkflowElementActionHandler();
                    actionHandler.delete(processVers);
                    boolean removedSelected = false;
                    for (WorkflowProcess pv : processVers) {
                        if (pv.equals(process))
                            removedSelected = true;
                        else
                            process.remove(pv);
                    }
                    if (removedSelected) {
                        WorkflowProcess sel = null;
                        for (WorkflowProcess toSel : process.getAllProcessVersions()) {
                            if (!toSel.equals(process)) {
                                sel = toSel;
                                break;
                            }
                        }
                        setSelection(sel);
                    } else {
                        // just force refresh
                        setSelection(process);
                    }
                }
            }
        });
    }
    return menu;
}
Also used : WorkflowElementActionHandler(com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) MenuItem(org.eclipse.swt.widgets.MenuItem) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Menu(org.eclipse.swt.widgets.Menu) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 75 with WorkflowProcess

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

the class WorkflowElementDeleteDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.getShell().setText("Delete Workflow Elements");
    boolean showIncludeInstances = false;
    for (WorkflowElement workflowElement : elements) {
        if (workflowElement instanceof WorkflowProcess) {
            showIncludeInstances = true;
            break;
        }
    }
    if (showIncludeInstances) {
        includeInstancesCheckbox = new Button(composite, SWT.CHECK | SWT.LEFT);
        includeInstancesCheckbox.setText("Include instances if they exist");
    }
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Aggregations

WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)85 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)28 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)21 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)21 PartInitException (org.eclipse.ui.PartInitException)20 ArrayList (java.util.ArrayList)17 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)15 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)12 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)11 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)11 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)10 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)9 IEditorPart (org.eclipse.ui.IEditorPart)9 ProcessEditor (com.centurylink.mdw.plugin.designer.editors.ProcessEditor)8 IFile (org.eclipse.core.resources.IFile)8 CoreException (org.eclipse.core.runtime.CoreException)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)8 IOException (java.io.IOException)7 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)6 Activity (com.centurylink.mdw.plugin.designer.model.Activity)6