Search in sources :

Example 21 with ActivityImplementorVO

use of com.centurylink.mdw.model.value.activity.ActivityImplementorVO in project mdw-designer by CenturyLinkCloud.

the class DesignerDataModel method loadImportedPackage.

public void loadImportedPackage(PackageVO pkg, List<ImportItem> importItems) {
    ImportItem item;
    // PackageListTreeModel pkgTree = getPackageListTree();
    // GroupingNode pkgGrpNode;
    // PackageNode pkgNode;
    boolean loadPackageItself;
    // load package
    item = findImportItem(importItems, ImportItem.TYPE_PACKAGE, pkg.getPackageName());
    loadPackageItself = item.isSelected();
    if (item.isSelected()) {
        // pkg.setPackageId(model.getNewId());
        // pkgGrpNode = pkgTree.findPackageGroupNode(pkg.getPackageName());
        // if (pkgGrpNode==null) pkgGrpNode = pkgTree.addPackageGroup(pkg.getPackageName());
        // pkgNode = pkgTree.addPackage(pkgGrpNode, pkg);
        addPackage(pkg);
    // pkgNode.setObject(pkg);
    // pkgNode.setStatus(BaseTreeNode.STATUS_NEW);
    // pkgNode.clean();
    } else {
        pkg.setVersion(0);
    // pkgNode = pkgTree.getDefaultPackageNode();
    }
    // add implementors
    List<ActivityImplementorVO> pkgImplementors = new ArrayList<ActivityImplementorVO>();
    for (ActivityImplementorVO a : pkg.getImplementors()) {
        item = findImportItem(importItems, ImportItem.TYPE_IMPLEMENTOR, a.getImplementorClassName());
        if (!item.isSelected()) {
            if (loadPackageItself) {
                if (item.getStatus() == ImportItem.STATUS_SAME || item.getStatus() == ImportItem.STATUS_DIFFERENT) {
                    pkgImplementors.add(findActivityImplementorVO(a.getImplementorClassName()));
                // pkgNode.addImplementor(a, BaseTreeNode.STATUS_CLEAN);
                }
            }
        } else if (item.getStatus() == ImportItem.STATUS_DIFFERENT) {
            ActivityImplementorVO impl = findActivityImplementorVO(a.getImplementorClassName());
            impl.setIconName(a.getIconName());
            impl.setBaseClassName(a.getBaseClassName());
            impl.setAttributeDescription(a.getAttributeDescription());
            impl.setLabel(a.getLabel());
            impl.setShowInToolbox(!StringHelper.isEmpty(a.getAttributeDescription()) && !StringHelper.isEmpty(impl.getBaseClassName()) && !StringHelper.isEmpty(impl.getIconName()));
            pkgImplementors.add(impl);
        // if (loadPackageItself) {
        // pkgNode.addImplementor(a, BaseTreeNode.STATUS_CHANGED);
        // }
        } else {
            // staus==STATUS_NEW
            a.setImplementorId(getNewId());
            addImplementor(a);
            a.setShowInToolbox(!StringHelper.isEmpty(a.getAttributeDescription()) && !StringHelper.isEmpty(a.getBaseClassName()) && !StringHelper.isEmpty(a.getIconName()));
            pkgImplementors.add(a);
        // if (loadPackageItself) {
        // pkgNode.addImplementor(a, BaseTreeNode.STATUS_NEW);
        // }
        }
    }
    nodeMetaInfo.init(activityImplementors, databaseSchemaVersion);
    pkg.setImplementors(pkgImplementors);
    // add event handlers
    List<ExternalEventVO> pkgHandlers = new ArrayList<ExternalEventVO>();
    for (ExternalEventVO e : pkg.getExternalEvents()) {
        item = findImportItem(importItems, ImportItem.TYPE_HANDLER, e.getEventName());
        if (!item.isSelected()) {
            if (loadPackageItself) {
                if (item.getStatus() == ImportItem.STATUS_SAME || item.getStatus() == ImportItem.STATUS_DIFFERENT) {
                    pkgHandlers.add(findExternalEvent(e.getEventName()));
                // pkgNode.addHandler(e, BaseTreeNode.STATUS_CLEAN);
                }
            }
        } else if (item.getStatus() == ImportItem.STATUS_DIFFERENT) {
            ExternalEventVO vo = findExternalEvent(e.getEventName());
            vo.setEventHandler(e.getEventHandler());
            pkgHandlers.add(vo);
        // if (loadPackageItself) {
        // pkgNode.addHandler(e, BaseTreeNode.STATUS_CHANGED);
        // }
        } else {
            // staus==STATUS_NEW
            e.setId(getNewId());
            addExternalEvent(e);
            pkgHandlers.add(e);
        // if (loadPackageItself) {
        // pkgNode.addHandler(e, BaseTreeNode.STATUS_NEW);
        // }
        }
    }
    pkg.setExternalEvents(pkgHandlers);
    // add ruleset
    List<RuleSetVO> pkgRuleSets = new ArrayList<RuleSetVO>();
    for (RuleSetVO e : pkg.getRuleSets()) {
        item = findImportItem(importItems, ImportItem.TYPE_RULESET, e.getName());
        if (!item.isSelected()) {
            if (loadPackageItself) {
                if (item.getStatus() == ImportItem.STATUS_SAME_VERSION) {
                    pkgRuleSets.add(findRuleSet(e.getName(), e.getLanguage()));
                }
            }
        } else {
            e.setId(getNewId());
            addRuleSet(e);
            pkgRuleSets.add(e);
        }
    }
    pkg.setRuleSets(pkgRuleSets);
    // TODO import participants
    // load processes
    List<ProcessVO> pkgProcesses = new ArrayList<ProcessVO>();
    for (ProcessVO p : pkg.getProcesses()) {
        item = findImportItem(importItems, ImportItem.TYPE_PROCESS, p.getProcessName());
        if (item.isSelected()) {
            // p.setProcessId(model.getNewId());       // set IDs for all???
            if (p.getVersion() == 0) {
                ProcessVO p1 = findProcessDefinition(p.getProcessName(), 0);
                if (p1 != null)
                    p.setVersion(p1.getVersion() + 1);
                else
                    p.setVersion(1);
            }
            pkgProcesses.add(p);
            addProcess(p);
        // pkgNode.addProcess(p, BaseTreeNode.STATUS_NEW);  done by above
        } else if (item.getStatus() == ImportItem.STATUS_SAME_VERSION || item.getStatus() == ImportItem.STATUS_OLD_VERSION) {
            ProcessVO p1 = findProcessDefinition(p.getProcessName(), p.getVersion());
            if (p1 != null) {
                // indicating to include in package but do not import
                p.setActivities(null);
                p.setProcessId(p1.getProcessId());
                pkgProcesses.add(p);
            }
        // else new process but not import - excluded entirely
        }
    }
    pkg.setProcesses(pkgProcesses);
// return pkgNode;
}
Also used : ImportItem(com.centurylink.mdw.designer.utils.ImportItem) ActivityImplementorVO(com.centurylink.mdw.model.value.activity.ActivityImplementorVO) ExternalEventVO(com.centurylink.mdw.model.value.event.ExternalEventVO) ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) RuleSetVO(com.centurylink.mdw.model.value.attribute.RuleSetVO)

Example 22 with ActivityImplementorVO

use of com.centurylink.mdw.model.value.activity.ActivityImplementorVO in project mdw-designer by CenturyLinkCloud.

the class NodeMetaInfo method init.

public void init(List<ActivityImplementorVO> implementors, boolean sortAtoZ, int dbschema_version) {
    if (dbschema_version < DataAccess.schemaVersion55) {
        DEFAULT_ACTIVITY_IMPLEMENTOR = DEFAULT_ACTIVITY_IMPLEMENTOR_OLD;
        DEFAULT_TASK_ACTIVITY = DEFAULT_TASK_ACTIVITY_OLD;
        DEFAULT_START = DEFAULT_START_OLD;
        DEFAULT_STOP = DEFAULT_STOP_OLD;
    }
    List<ActivityImplementorVO> unsortedList = new ArrayList<ActivityImplementorVO>();
    for (ActivityImplementorVO activityImpl : implementors) {
        if (activityImpl.getLabel() == null) {
            String label = activityImpl.getImplementorClassName();
            int k = label.lastIndexOf('.');
            if (k > 0)
                label = label.substring(k + 1);
            activityImpl.setLabel(label);
        }
        unsortedList.add(activityImpl);
    }
    ActivityImplementorVO defaultActivity = null;
    for (ActivityImplementorVO ai : unsortedList) {
        if (ai.getImplementorClassName().equals(DEFAULT_ACTIVITY_IMPLEMENTOR)) {
            defaultActivity = ai;
            break;
        }
    }
    String attrdesc;
    if (defaultActivity == null) {
        attrdesc = "<PAGELET>\n" + "<NOTE LABEL='ERROR' LX='12' LY='25' VX='120' VY='25' VH='120'>\n" + " The implementor is not configured in database, or not completely configured.\n" + "</NOTE>\n" + "<HYPERLINK URL='/MDWWeb/doc/implementor.html'>\n" + "Click here for documentation on implementing activity implementor.</HYPERLINK>\n" + "</PAGELET>\n";
        defaultActivity = new ActivityImplementorVO("Dummy Activity", DEFAULT_ACTIVITY_IMPLEMENTOR, "shape:activity", attrdesc);
        defaultActivity.setShowInToolbox(true);
        unsortedList.add(defaultActivity);
    }
    // add basic activity implementor if not there. This is for prior version of MDW database
    // and for off-line designer
    // the first three are reserved for embedded process, start and stop meta info
    attrdesc = "<PAGELET>" + "<TEXT NAME='" + WorkAttributeConstant.PROCESS_VISIBILITY + "' LABEL='Process Type' READONLY='TRUE'/>" + "<TEXT NAME='" + WorkAttributeConstant.EMBEDDED_PROCESS_TYPE + "' LABEL='Sub Type' READONLY='TRUE'/>" + "<TEXT NAME='" + WorkAttributeConstant.ENTRY_CODE + "' LABEL='Entry Code' VW='200'/>" + "</PAGELET>";
    ActivityImplementorVO pseudoMainProcess = new ActivityImplementorVO("Embedded Process", PSEUDO_PROCESS_ACTIVITY, "shape:subproc", attrdesc);
    visibleImpls = new ArrayList<ActivityImplementorVO>();
    hiddenImpls = new ArrayList<ActivityImplementorVO>();
    // process itself
    visibleImpls.add(pseudoMainProcess);
    for (ActivityImplementorVO implVO : unsortedList) {
        if (implVO.isShowInToolbox())
            visibleImpls.add(implVO);
        else
            hiddenImpls.add(implVO);
    }
    if (sortAtoZ) {
        // alpha sort by label
        Collections.sort(visibleImpls);
    } else {
        // default sorting -- grouped by icon (with Start and Stop appearing first)
        Collections.sort(visibleImpls, new Comparator<ActivityImplementorVO>() {

            public int compare(ActivityImplementorVO impl1, ActivityImplementorVO impl2) {
                if (PSEUDO_PROCESS_ACTIVITY.equals(impl1.getImplementorClassName())) {
                    return PSEUDO_PROCESS_ACTIVITY.equals(impl2.getImplementorClassName()) ? 0 : -1;
                } else if (PSEUDO_PROCESS_ACTIVITY.equals(impl2.getImplementorClassName())) {
                    return 1;
                } else {
                    if (impl1.isStart()) {
                        return impl2.isStart() ? impl1.getIconName().compareTo(impl2.getIconName()) : -1;
                    } else if (impl2.isStart()) {
                        return 1;
                    } else {
                        if (impl1.isFinish()) {
                            return impl2.isFinish() ? impl1.getIconName().compareTo(impl2.getIconName()) : -1;
                        } else if (impl2.isFinish()) {
                            return 1;
                        } else {
                            if (impl1.getIconName() == null) {
                                return impl2.getIconName() == null ? 0 : -1;
                            } else if (impl2.getIconName() == null) {
                                return 1;
                            }
                            return impl1.getIconName().compareTo(impl2.getIconName());
                        }
                    }
                }
            }
        });
    }
}
Also used : ActivityImplementorVO(com.centurylink.mdw.model.value.activity.ActivityImplementorVO) ArrayList(java.util.ArrayList)

Example 23 with ActivityImplementorVO

use of com.centurylink.mdw.model.value.activity.ActivityImplementorVO in project mdw-designer by CenturyLinkCloud.

the class ProcessValidator method validate.

public void validate(boolean checkImplementors, NodeMetaInfo implInfo) throws ValidationException {
    if (packageVO != null) {
        // check if processes are up to date
        for (ProcessVO proc : packageVO.getProcesses()) {
            if (proc.getNextVersion() != null)
                errors.add("Process " + proc.getProcessName() + " has newer versions");
        }
        // check implementors
        if (checkImplementors) {
            Map<String, ActivityImplementorVO> has = new HashMap<String, ActivityImplementorVO>();
            Map<String, String> hasnot = new HashMap<String, String>();
            for (ActivityImplementorVO ai : packageVO.getImplementors()) {
                has.put(ai.getImplementorClassName(), ai);
            }
            for (ProcessVO proc : packageVO.getProcesses()) {
                for (ActivityVO act : proc.getActivities()) {
                    String v = act.getImplementorClassName();
                    if (!has.containsKey(v))
                        hasnot.put(v, v);
                }
                if (proc.getSubProcesses() != null) {
                    for (ProcessVO subproc : proc.getSubProcesses()) {
                        for (ActivityVO act : subproc.getActivities()) {
                            String v = act.getImplementorClassName();
                            if (!has.containsKey(v))
                                hasnot.put(v, v);
                        }
                    }
                }
            }
            for (String v : hasnot.keySet()) {
                errors.add("Implementor " + v + " is used but not included");
            }
        }
        // validate each process
        for (ProcessVO proc : packageVO.getProcesses()) {
            process = proc;
            validateProcess(implInfo);
        }
    } else {
        validateProcess(implInfo);
    }
    if (errors.size() > 0)
        throw new ValidationException(errors);
}
Also used : ActivityImplementorVO(com.centurylink.mdw.model.value.activity.ActivityImplementorVO) HashMap(java.util.HashMap) ActivityVO(com.centurylink.mdw.model.value.activity.ActivityVO) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO)

Example 24 with ActivityImplementorVO

use of com.centurylink.mdw.model.value.activity.ActivityImplementorVO in project mdw-designer by CenturyLinkCloud.

the class ProcessWorker method moveStartActivityToFirst.

private void moveStartActivityToFirst(ProcessVO processVO, NodeMetaInfo metainfo) {
    for (int i = 0; i < processVO.getActivities().size(); i++) {
        ActivityVO act = processVO.getActivities().get(i);
        ActivityImplementorVO nmi = metainfo.find(act.getImplementorClassName());
        if (nmi == null)
            continue;
        if (nmi.isStart()) {
            if (i > 0) {
                processVO.getActivities().remove(i);
                processVO.getActivities().add(0, act);
            }
            return;
        }
    }
}
Also used : ActivityImplementorVO(com.centurylink.mdw.model.value.activity.ActivityImplementorVO) ActivityVO(com.centurylink.mdw.model.value.activity.ActivityVO)

Aggregations

ActivityImplementorVO (com.centurylink.mdw.model.value.activity.ActivityImplementorVO)24 ArrayList (java.util.ArrayList)12 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)9 RuleSetVO (com.centurylink.mdw.model.value.attribute.RuleSetVO)6 ExternalEventVO (com.centurylink.mdw.model.value.event.ExternalEventVO)6 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)5 Point (java.awt.Point)5 ActivityVO (com.centurylink.mdw.model.value.activity.ActivityVO)4 ActivityImpl (com.centurylink.mdw.plugin.designer.model.ActivityImpl)4 AttributeVO (com.centurylink.mdw.model.value.attribute.AttributeVO)3 ActionCancelledException (com.centurylink.mdw.common.utilities.timer.ActionCancelledException)2 Selectable (com.centurylink.mdw.designer.display.Selectable)2 ImportItem (com.centurylink.mdw.designer.utils.ImportItem)2 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)2 CodeTimer (com.centurylink.mdw.plugin.CodeTimer)2 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)2 Combo (org.eclipse.swt.widgets.Combo)2 ProcessExporter (com.centurylink.mdw.dataaccess.ProcessExporter)1 ProcessPersister (com.centurylink.mdw.dataaccess.ProcessPersister)1 IconFactory (com.centurylink.mdw.designer.icons.IconFactory)1