Search in sources :

Example 56 with ProcessVO

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

the class DesignerProxy method findCalledProcesses.

public List<WorkflowProcess> findCalledProcesses(WorkflowProcess mainproc) throws DataAccessException, RemoteException {
    List<WorkflowProcess> called = new ArrayList<>();
    List<ProcessVO> calledProcVos = dataAccess.getDesignerDataAccess().findCalledProcesses(mainproc.getProcessVO());
    for (ProcessVO procVo : calledProcVos) {
        WorkflowProcess processVersion = project.getProcess(procVo.getProcessId());
        if (// might not be loaded in tree
        processVersion == null)
            processVersion = new WorkflowProcess(project, procVo);
        called.add(processVersion);
    }
    return called;
}
Also used : ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 57 with ProcessVO

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

the class DesignerProxy method saveProcessWithProgress.

public void saveProcessWithProgress(final WorkflowProcess process, final FlowchartPage flowchartPage, final PersistType persistType, final int version, final boolean validate, final boolean keepLocked) {
    String progressMsg = SAVING + process.getName() + "'";
    String errorMsg = "Save Process";
    designerRunner = new DesignerRunner(progressMsg, errorMsg, project) {

        public void perform() throws ValidationException, DataAccessException, RemoteException {
            WorkflowProcess oldProcess = null;
            if (persistType == PersistType.NEW_VERSION) {
                RuleSetVO existing = null;
                if (process.isInRuleSet())
                    existing = dataAccess.getDesignerDataAccess().getRuleSet(process.getName(), RuleSetVO.PROCESS, version);
                if (existing != null)
                    throw new DataAccessException("\n" + process.getLabel() + ALREADY_EXISTS);
                process.getProcessVO().setProcessId(-1L);
                // preserve the old version for the process tree
                ProcessVO oldProcessVoStub = new ProcessVO();
                oldProcessVoStub.setProcessId(process.getId());
                oldProcessVoStub.setProcessName(process.getName());
                oldProcessVoStub.setVersion(process.getProcessVO().getVersion());
                oldProcess = new WorkflowProcess(process.getProject(), oldProcessVoStub);
                oldProcess.setPackage(process.getPackage());
                oldProcess.setTopLevelVersion(process.getTopLevelVersion());
                if (// temp attribute to avoid API
                project.isFilePersist())
                    // change
                    process.setAttribute("previousProcessVersion", oldProcess.getVersionString());
            }
            saveProcess(process, flowchartPage, persistType, version, validate, keepLocked);
            if (process.getTopLevelVersion() != null)
                process.getTopLevelVersion().setProcessVO(process.getProcessVO());
            if (persistType == PersistType.NEW_VERSION && process.isInRuleSet()) {
                RuleSetVO procRs = dataAccess.getRuleSet(process.getId());
                if (procRs == null)
                    dataAccess.getAllRuleSets(false).add(process.getProcessVO());
            }
        }
    };
    designerRunner.run();
}
Also used : ValidationException(com.centurylink.mdw.designer.utils.ValidationException) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) RemoteException(java.rmi.RemoteException) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) RuleSetVO(com.centurylink.mdw.model.value.attribute.RuleSetVO)

Example 58 with ProcessVO

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

the class DesignerProxy method getSubProcessInstances.

public List<ProcessInstanceVO> getSubProcessInstances(ProcessInstanceVO parentEmbeddedProcessInstance, Activity activity) {
    try {
        Long parentProcessInstanceId = parentEmbeddedProcessInstance.getId();
        ProcessVO subProcessVO = new ProcessVO();
        String subProcName = activity.getAttribute(WorkAttributeConstant.PROCESS_NAME);
        String subProcVer = activity.getAttribute(WorkAttributeConstant.PROCESS_VERSION);
        WorkflowProcess subProc = new AssetLocator(activity, AssetLocator.Type.PROCESS).getProcessVersion(new AssetVersionSpec(subProcName, subProcVer));
        subProcessVO.setProcessId(subProc == null ? 0L : subProc.getId());
        subProcessVO.setProcessName(subProcName);
        return dataAccess.getDesignerDataAccess().getChildProcessInstance(parentProcessInstanceId, subProcessVO, new ProcessVO());
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Load SubProcess Instances", project);
        return Collections.emptyList();
    }
}
Also used : AssetLocator(com.centurylink.mdw.plugin.designer.properties.editor.AssetLocator) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) AssetVersionSpec(com.centurylink.mdw.model.value.attribute.AssetVersionSpec) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) JSONException(org.json.JSONException) TranslationException(com.centurylink.mdw.common.exception.TranslationException) AuthenticationException(com.centurylink.mdw.auth.AuthenticationException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ZipException(java.util.zip.ZipException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException)

Example 59 with ProcessVO

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

the class DesignerProxy method getSubProcessInstances.

public List<ProcessInstanceVO> getSubProcessInstances(WorkflowProcess parentProcess, Activity activity) {
    try {
        Long parentProcessInstanceId = parentProcess.getProcessInstance().getId();
        if (activity.isHeterogeneousSubProcInvoke()) {
            List<ProcessInstanceVO> insts = new ArrayList<>();
            String procMapStr = activity.getAttribute(WorkAttributeConstant.PROCESS_MAP);
            if (procMapStr != null && !procMapStr.isEmpty()) {
                List<String[]> procMap = StringHelper.parseTable(procMapStr, ',', ';', 3);
                for (String[] row : procMap) {
                    ProcessVO subProcessVO = new ProcessVO();
                    AssetVersionSpec spec = new AssetVersionSpec(row[1], row[2] == null ? "0" : row[2]);
                    AssetLocator locator = new AssetLocator(activity, AssetLocator.Type.PROCESS);
                    WorkflowProcess found = locator.getProcessVersion(spec);
                    if (found != null) {
                        subProcessVO.setProcessId(found.getId());
                        subProcessVO.setProcessName(found.getName());
                        insts.addAll(dataAccess.getDesignerDataAccess().getChildProcessInstance(parentProcessInstanceId, subProcessVO, parentProcess.getProcessVO()));
                    } else {
                        PluginMessages.log(new Exception("SubProcess not found: " + row[1] + " v" + row[2]));
                    }
                }
            }
            return insts;
        } else if (activity.isManualTask()) {
            List<ProcessInstanceVO> insts = new ArrayList<>();
            String procMapStr = activity.getAttribute(TaskAttributeConstant.SERVICE_PROCESSES);
            if (procMapStr != null && !procMapStr.isEmpty()) {
                Map<String, String> pMap = new HashMap<>();
                pMap.put("owner", OwnerType.TASK_INSTANCE);
                StringBuilder sb = new StringBuilder();
                sb.append("(");
                if (activity.getTaskInstances() != null) {
                    for (TaskInstanceVO taskInst : activity.getTaskInstances()) {
                        if (sb.length() > 1)
                            sb.append(",");
                        sb.append(taskInst.getTaskInstanceId().toString());
                    }
                }
                sb.append(")");
                pMap.put("ownerIdList", sb.toString());
                insts = dataAccess.getDesignerDataAccess().getProcessInstanceList(pMap, 0, QueryRequest.ALL_ROWS, parentProcess.getProcessVO(), null).getItems();
            }
            return insts;
        } else {
            ProcessVO subProcessVO = new ProcessVO();
            String subProcName = activity.getAttribute(WorkAttributeConstant.PROCESS_NAME);
            String subProcVer = activity.getAttribute(WorkAttributeConstant.PROCESS_VERSION);
            AssetVersionSpec spec = new AssetVersionSpec(subProcName, subProcVer == null ? "0" : subProcVer);
            AssetLocator locator = new AssetLocator(activity, AssetLocator.Type.PROCESS);
            WorkflowProcess subProc = locator.getProcessVersion(spec);
            subProcessVO.setProcessId((subProc == null || subProc.getId() == null) ? 0L : subProc.getId());
            subProcessVO.setProcessName(activity.getAttribute(WorkAttributeConstant.PROCESS_NAME));
            // handle alias subprocs
            String subprocAliasProcessId = activity.getAttribute(WorkAttributeConstant.ALIAS_PROCESS_ID);
            if (subprocAliasProcessId != null)
                subProcessVO = this.getProcessVO(new Long(subprocAliasProcessId));
            return dataAccess.getDesignerDataAccess().getChildProcessInstance(parentProcessInstanceId, subProcessVO, parentProcess.getProcessVO());
        }
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Load SubProcess Instances (P=" + parentProcess.getId() + ",A=" + activity.getId() + ")", project);
        return Collections.emptyList();
    }
}
Also used : AssetLocator(com.centurylink.mdw.plugin.designer.properties.editor.AssetLocator) ArrayList(java.util.ArrayList) AssetVersionSpec(com.centurylink.mdw.model.value.attribute.AssetVersionSpec) JSONException(org.json.JSONException) TranslationException(com.centurylink.mdw.common.exception.TranslationException) AuthenticationException(com.centurylink.mdw.auth.AuthenticationException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ZipException(java.util.zip.ZipException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) TaskInstanceVO(com.centurylink.mdw.model.value.task.TaskInstanceVO) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) ArrayList(java.util.ArrayList) List(java.util.List) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) Map(java.util.Map) HashMap(java.util.HashMap) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 60 with ProcessVO

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

the class DesignerProxy method upgradeAssets.

/**
 * Replace obsolete implementors, and other assets (see help doc
 * upgradeAssetsDuringImport.html).
 */
public void upgradeAssets(WorkflowPackage packageVersion) throws DataAccessException, IOException {
    boolean packageUpdated = false;
    PackageVO packageVO = packageVersion.getPackageVO();
    List<ProcessVO> processVOs = packageVO.getProcesses();
    // update activity implementors
    List<ProcessVO> newProcs = new ArrayList<>();
    for (ProcessVO processVO : processVOs) {
        boolean processUpdated = false;
        ProcessVO newProc = dataAccess.getDesignerDataAccess().getProcess(processVO.getProcessId(), processVO);
        List<ActivityVO> activities = newProc.getActivities();
        if (activities != null) {
            for (ActivityVO activityVO : activities) {
                if (new ActivityUpgrader(activityVO).doUpgrade())
                    processUpdated = true;
            }
            if (newProc.getSubProcesses() != null) {
                for (ProcessVO subproc : newProc.getSubProcesses()) {
                    if (subproc.getActivities() != null) {
                        for (ActivityVO subprocActivity : subproc.getActivities()) {
                            if (new ActivityUpgrader(subprocActivity).doUpgrade())
                                processUpdated = true;
                        }
                    }
                }
            }
        }
        // update variable types
        List<VariableVO> variables = newProc.getVariables();
        if (variables != null) {
            for (VariableVO variableVO : variables) {
                String variableType = variableVO.getVariableType();
                String updatedVariableType = Compatibility.getVariableType(variableType);
                if (!updatedVariableType.equals(variableType)) {
                    variableVO.setVariableType(updatedVariableType);
                    processUpdated = true;
                }
            }
        }
        if (processUpdated) {
            int processVersion = newProc.getVersion();
            processVersion++;
            newProc.setVersion(processVersion);
            packageUpdated = true;
        }
        newProcs.add(newProc);
    }
    // Set old activity implementors in the package to hidden
    List<ActivityImplementorVO> activityImplementorVOs = packageVO.getImplementors();
    for (ActivityImplementorVO activityImplementorVO : activityImplementorVOs) {
        String activityImplClassName = activityImplementorVO.getImplementorClassName();
        if (Compatibility.isOldImplementor(activityImplClassName)) {
            activityImplementorVO.setHidden(true);
            packageUpdated = true;
        }
    }
    if (packageUpdated) {
        // update with new assets for saving
        packageVO.setProcesses(newProcs);
        List<RuleSetVO> newRuleSets = new ArrayList<>();
        for (RuleSetVO ruleSet : packageVO.getRuleSets()) newRuleSets.add(getDesignerDataAccess().getRuleSet(ruleSet.getId()));
        packageVO.setRuleSets(newRuleSets);
        int version = packageVersion.getVersion();
        version++;
        packageVersion.setVersion(version);
        // avoid forcing version
        packageVersion.setExported(false);
        // increment on save
        packageVersion.syncProcesses();
        getDesignerDataAccess().savePackage(packageVO, ProcessPersister.PersistType.IMPORT);
    }
}
Also used : PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ActivityVO(com.centurylink.mdw.model.value.activity.ActivityVO) 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) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO)

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