Search in sources :

Example 71 with ProcessVO

use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.

the class DesignerDataModel method findProcessDefinition.

private ProcessVO findProcessDefinition(List<ProcessVO> proclist, String processName, int version) {
    String remoteServer = null;
    int k = processName.indexOf(RemoteAccess.REMOTE_NAME_DELIMITER);
    if (k > 0) {
        remoteServer = processName.substring(k + 1);
        processName = processName.substring(0, k);
    }
    for (ProcessVO pd1 : proclist) {
        if (pd1.getProcessName().equals(processName) && (remoteServer == null && pd1.getRemoteServer() == null || remoteServer != null && remoteServer.equals(pd1.getRemoteServer()))) {
            if (version == 0 || version == pd1.getVersion()) {
                return pd1;
            }
            ProcessVO prev = pd1.getPrevVersion();
            while (prev != null) {
                if (prev.getVersion() == version)
                    return prev;
                prev = prev.getPrevVersion();
            }
        }
    }
    return null;
}
Also used : ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO)

Example 72 with ProcessVO

use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.

the class DesignerDataModel method getPackagesForProcess.

public List<PackageVO> getPackagesForProcess(String procname) {
    List<PackageVO> ret = new ArrayList<PackageVO>();
    String lastPackageName = "";
    for (PackageVO pkg : packages) {
        if (pkg.getPackageName().equals(lastPackageName))
            continue;
        lastPackageName = pkg.getPackageName();
        // package is shallow-loaded
        if (pkg.getProcesses() == null)
            continue;
        for (ProcessVO proc : pkg.getProcesses()) {
            if (proc.getProcessName().equals(procname)) {
                ret.add(pkg);
                break;
            }
        }
    }
    return ret;
}
Also used : PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO)

Example 73 with ProcessVO

use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.

the class DesignerDataModel method collectImportItems.

public List<ImportItem> collectImportItems(PackageVO pkg) {
    List<ImportItem> importItems = new ArrayList<ImportItem>();
    // check for package
    ImportItem item;
    int status;
    if (pkg.getVersion() != 0 && getDatabaseSchemaVersion() >= DataAccess.schemaVersion4) {
        status = ImportItem.STATUS_NEW_VERSION;
        for (PackageVO one : packages) {
            if (one.getPackageName().equals(pkg.getPackageName())) {
                if (pkg.getVersion() < one.getVersion()) {
                    status = ImportItem.STATUS_OLD_VERSION;
                } else if (pkg.getVersion() == one.getVersion()) {
                    if (status == ImportItem.STATUS_NEW_VERSION)
                        status = ImportItem.STATUS_SAME_VERSION;
                }
            }
        }
    } else
        status = ImportItem.STATUS_NOT_PACKAGE;
    item = new ImportItem(pkg.getPackageName(), ImportItem.TYPE_PACKAGE, status);
    importItems.add(item);
    // check for implementors
    for (ActivityImplementorVO a : pkg.getImplementors()) {
        ActivityImplementorVO a1 = findActivityImplementorVO(a.getImplementorClassName());
        if (a1 == null)
            status = ImportItem.STATUS_NEW;
        else if (same_implementor(a, a1))
            status = ImportItem.STATUS_SAME;
        else
            status = ImportItem.STATUS_DIFFERENT;
        item = new ImportItem(a.getImplementorClassName(), ImportItem.TYPE_IMPLEMENTOR, status);
        importItems.add(item);
    }
    for (ExternalEventVO e : pkg.getExternalEvents()) {
        ExternalEventVO e1 = findExternalEvent(e.getEventName());
        if (e1 == null)
            status = ImportItem.STATUS_NEW;
        else if (same_handler(e, e1))
            status = ImportItem.STATUS_SAME;
        else
            status = ImportItem.STATUS_DIFFERENT;
        item = new ImportItem(e.getEventName(), ImportItem.TYPE_HANDLER, status);
        importItems.add(item);
    }
    for (RuleSetVO e : pkg.getRuleSets()) {
        RuleSetVO e1 = findRuleSet(e.getName(), null);
        if (e1 == null || e.getVersion() > e1.getVersion())
            status = ImportItem.STATUS_NEW_VERSION;
        else if (e.getVersion() == 0) {
            status = ImportItem.STATUS_NEW_VERSION;
            e.setVersion(e1.getVersion() + 1);
        } else if (e.getVersion() == e1.getVersion())
            status = ImportItem.STATUS_SAME_VERSION;
        else
            status = ImportItem.STATUS_OLD_VERSION;
        item = new ImportItem(e.getName(), ImportItem.TYPE_RULESET, status);
        importItems.add(item);
    }
    for (ProcessVO p : pkg.getProcesses()) {
        ProcessVO p1 = findProcessDefinition(p.getProcessName(), 0);
        if (p1 == null || p.getVersion() > p1.getVersion() || p.getVersion() == 0)
            status = ImportItem.STATUS_NEW_VERSION;
        else if (p.getVersion() == p1.getVersion())
            status = ImportItem.STATUS_SAME_VERSION;
        else
            status = ImportItem.STATUS_OLD_VERSION;
        item = new ImportItem(p.getProcessName(), ImportItem.TYPE_PROCESS, status);
        importItems.add(item);
    }
    return importItems;
}
Also used : ImportItem(com.centurylink.mdw.designer.utils.ImportItem) ActivityImplementorVO(com.centurylink.mdw.model.value.activity.ActivityImplementorVO) PackageVO(com.centurylink.mdw.model.value.process.PackageVO) 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 74 with ProcessVO

use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.

the class DesignerDataModel method copyPackage.

public PackageVO copyPackage(PackageVO curPkg, String newname, int newversion) {
    PackageVO newPkg = new PackageVO();
    newPkg.setPackageName(newname != null ? newname : curPkg.getPackageName());
    newPkg.setPackageDescription(curPkg.getPackageDescription());
    newPkg.setExported(false);
    // newPkg.setPools(pools)
    // newPkg.setVariables(variables)
    newPkg.setSchemaVersion(DataAccess.currentSchemaVersion);
    newPkg.setPackageId(getNewId());
    newPkg.setVersion(newversion);
    newPkg.setMetaContent(curPkg.getMetaContent());
    List<ProcessVO> processes = new ArrayList<ProcessVO>();
    newPkg.setProcesses(processes);
    if (curPkg.getProcesses() != null) {
        for (ProcessVO p : curPkg.getProcesses()) {
            processes.add(p);
        }
    }
    if (curPkg.getImplementors() != null) {
        List<ActivityImplementorVO> impls = new ArrayList<ActivityImplementorVO>();
        newPkg.setImplementors(impls);
        for (ActivityImplementorVO a : curPkg.getImplementors()) {
            impls.add(a);
        }
    }
    if (curPkg.getExternalEvents() != null) {
        List<ExternalEventVO> handlers = new ArrayList<ExternalEventVO>();
        newPkg.setExternalEvents(handlers);
        for (ExternalEventVO a : curPkg.getExternalEvents()) {
            handlers.add(a);
        }
    }
    if (curPkg.getParticipants() != null) {
        List<LaneVO> participants = new ArrayList<LaneVO>();
        newPkg.setParticipants(participants);
        for (LaneVO a : curPkg.getParticipants()) {
            participants.add(a);
        }
    }
    if (curPkg.getRuleSets() != null) {
        List<RuleSetVO> rulesets = new ArrayList<RuleSetVO>();
        newPkg.setRuleSets(rulesets);
        for (RuleSetVO a : curPkg.getRuleSets()) {
            rulesets.add(a);
        }
    }
    if (curPkg.getAttributes() != null) {
        List<AttributeVO> attrs = new ArrayList<AttributeVO>();
        newPkg.setAttributes(attrs);
        for (AttributeVO a : curPkg.getAttributes()) {
            attrs.add(a);
        }
    }
    addPackage(newPkg);
    return newPkg;
}
Also used : PackageVO(com.centurylink.mdw.model.value.process.PackageVO) AttributeVO(com.centurylink.mdw.model.value.attribute.AttributeVO) CustomAttributeVO(com.centurylink.mdw.model.value.attribute.CustomAttributeVO) ExternalEventVO(com.centurylink.mdw.model.value.event.ExternalEventVO) ArrayList(java.util.ArrayList) RuleSetVO(com.centurylink.mdw.model.value.attribute.RuleSetVO) ActivityImplementorVO(com.centurylink.mdw.model.value.activity.ActivityImplementorVO) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) LaneVO(com.centurylink.mdw.model.value.process.LaneVO)

Example 75 with ProcessVO

use of com.centurylink.mdw.model.value.process.ProcessVO 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)

Aggregations

ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)92 ArrayList (java.util.ArrayList)29 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)28 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)25 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)17 IOException (java.io.IOException)17 HashMap (java.util.HashMap)15 RemoteException (java.rmi.RemoteException)14 ProcessWorker (com.centurylink.mdw.designer.utils.ProcessWorker)12 ActivityVO (com.centurylink.mdw.model.value.activity.ActivityVO)11 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)11 JSONException (org.json.JSONException)11 RuleSetVO (com.centurylink.mdw.model.value.attribute.RuleSetVO)10 XmlException (org.apache.xmlbeans.XmlException)10 ActivityImplementorVO (com.centurylink.mdw.model.value.activity.ActivityImplementorVO)9 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)9 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)8 ExternalEventVO (com.centurylink.mdw.model.value.event.ExternalEventVO)8 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)7 AuthenticationException (com.centurylink.mdw.auth.AuthenticationException)5