Search in sources :

Example 66 with WorkflowProcess

use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess 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 67 with WorkflowProcess

use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess 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 68 with WorkflowProcess

use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess 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 69 with WorkflowProcess

use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess 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 70 with WorkflowProcess

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

the class Importer method importProcess.

public WorkflowProcess importProcess(final WorkflowPackage targetPackage, final WorkflowProcess targetProcess, final String xml) throws DataAccessException, RemoteException, XmlException, ValidationException {
    CodeTimer timer = new CodeTimer("importProcess()");
    ProcessVO importedProcessVO = null;
    int schemaVersion = dataAccess.getSchemaVersion();
    ProcessImporter importer = DataAccess.getProcessImporter(schemaVersion);
    importedProcessVO = importer.importProcess(xml);
    if (targetProcess != null && !importedProcessVO.getName().equals(targetProcess.getName()))
        throw new ValidationException("Process in XML (" + importedProcessVO.getName() + ") is not " + targetProcess.getName());
    for (WorkflowProcess existing : targetPackage.getProject().getAllProcesses()) {
        if (existing.getName().equals(importedProcessVO.getName())) {
            if (existing.getVersion() == importedProcessVO.getVersion())
                throw new ValidationException(existing.getLabel() + " already exists in " + targetPackage.getProject().getLabel() + ".");
            if (existing.getVersion() > importedProcessVO.getVersion())
                throw new ValidationException(existing.getLabel() + " already exists in " + targetPackage.getProject().getLabel() + " with a version greater than the imported process (v" + importedProcessVO.getVersionString() + ").");
        }
    }
    // designer fix for backward compatibility
    ProcessWorker worker = new ProcessWorker();
    worker.convert_to_designer(importedProcessVO);
    worker.convert_from_designer(importedProcessVO, syncNodeMetaInfo(dataAccess.getDesignerDataModel().getNodeMetaInfo(), importedProcessVO));
    if (!importedProcessVO.isInRuleSet()) {
        // fix pseudo variables
        for (VariableVO varVO : importedProcessVO.getVariables()) varVO.setVariableId(null);
    }
    importedProcessVO.setPackageName(targetPackage.getName());
    WorkflowProcess alreadyInPackage = null;
    if (targetPackage.getProject().getProcess(importedProcessVO.getName()) == null)
        dataAccess.getDesignerDataAccess().createProcess(importedProcessVO);
    else {
        alreadyInPackage = targetPackage.getProcess(importedProcessVO.getName());
        dataAccess.getDesignerDataAccess().updateProcess(importedProcessVO, importedProcessVO.getVersion(), false);
    }
    ProcessVO reloaded = dataAccess.getDesignerDataAccess().getProcessDefinition(importedProcessVO.getProcessName(), importedProcessVO.getVersion());
    importedProcessVO.setProcessId(reloaded.getProcessId());
    if (targetPackage.getProject().getDataAccess().getSupportedSchemaVersion() < DataAccess.schemaVersion52)
        updateSubProcessIdAttributes(importedProcessVO);
    WorkflowProcess importedProcess = new WorkflowProcess(targetPackage.getProject(), importedProcessVO);
    dataAccess.getProcesses(false).add(importedProcess.getProcessVO());
    if (alreadyInPackage != null)
        targetPackage.removeProcess(alreadyInPackage);
    targetPackage.addProcess(importedProcess);
    importedProcess.setPackage(targetPackage);
    dataAccess.auditLog(Action.Import, importedProcess);
    timer.stopAndLog();
    return importedProcess;
}
Also used : ValidationException(com.centurylink.mdw.designer.utils.ValidationException) ProcessWorker(com.centurylink.mdw.designer.utils.ProcessWorker) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) ProcessImporter(com.centurylink.mdw.dataaccess.ProcessImporter) CodeTimer(com.centurylink.mdw.plugin.CodeTimer) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

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