Search in sources :

Example 81 with ProcessVO

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

the class ProcessWorker method convert_from_designer.

// add hiddlen links for main and embedded subprocesses
public void convert_from_designer(ProcessVO processVO, NodeMetaInfo metainfo) {
    if (processVO.isInRuleSet()) {
        moveStartActivityToFirst(processVO, metainfo);
        List<ProcessVO> subprocs = processVO.getSubProcesses();
        if (subprocs != null) {
            for (ProcessVO subproc : subprocs) {
                moveStartActivityToFirst(subproc, metainfo);
            }
        }
    } else {
        Long startNodeId = findStartActivityId(processVO, metainfo);
        int hiddenLinkLogicalId = 1000;
        String startTransId = processVO.getAttribute(WorkAttributeConstant.START_TRANSITION_ID);
        createHiddenTransition(processVO, startNodeId, EventType.START, null, startTransId, hiddenLinkLogicalId++, processVO.isInRuleSet());
        List<ProcessVO> subprocs = processVO.getSubProcesses();
        if (subprocs != null) {
            for (ProcessVO subproc : subprocs) {
                Integer eventType = subproc.getEventType();
                String entryTransId = subproc.getAttribute(WorkAttributeConstant.ENTRY_TRANSITION_ID);
                String entryCode = subproc.getAttribute(WorkAttributeConstant.ENTRY_CODE);
                createHiddenTransition(processVO, subproc.getProcessId(), eventType, entryCode, entryTransId, hiddenLinkLogicalId++, processVO.isInRuleSet());
                startNodeId = findStartActivityId(subproc, metainfo);
                startTransId = subproc.getAttribute(WorkAttributeConstant.START_TRANSITION_ID);
                createHiddenTransition(subproc, startNodeId, EventType.START, null, startTransId, hiddenLinkLogicalId++, processVO.isInRuleSet());
            }
        }
    }
}
Also used : ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO)

Example 82 with ProcessVO

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

the class ProcessWorker method convert_to_designer.

// remember and then delete hidden links
public void convert_to_designer(ProcessVO processVO) {
    if (processVO.isInRuleSet())
        return;
    WorkTransitionVO startTrans = null;
    List<WorkTransitionVO> hiddenLinks = new ArrayList<WorkTransitionVO>();
    List<WorkTransitionVO> invalidHiddenLinks = new ArrayList<WorkTransitionVO>();
    for (WorkTransitionVO w : processVO.getTransitions()) {
        if (w.getFromWorkId().equals(processVO.getProcessId())) {
            hiddenLinks.add(w);
            if (w.getEventType().equals(EventType.START))
                startTrans = w;
        } else if (w.isHidden()) {
            // somehow in 4.5 invalid hidden transitions are being added
            invalidHiddenLinks.add(w);
        }
    }
    processVO.setAttribute(WorkAttributeConstant.START_TRANSITION_ID, startTrans == null ? null : startTrans.getWorkTransitionId().toString());
    for (WorkTransitionVO w : hiddenLinks) {
        processVO.getTransitions().remove(w);
    }
    for (WorkTransitionVO w : invalidHiddenLinks) {
        processVO.getTransitions().remove(w);
    }
    List<ProcessVO> subProcesses = processVO.getSubProcesses();
    if (subProcesses != null) {
        for (ProcessVO subProcessVO : subProcesses) {
            WorkTransitionVO entryTrans = null;
            for (WorkTransitionVO w : hiddenLinks) {
                if (!w.getEventType().equals(EventType.START) && w.getToWorkId().equals(subProcessVO.getProcessId())) {
                    entryTrans = w;
                    break;
                }
            }
            startTrans = null;
            for (WorkTransitionVO w : subProcessVO.getTransitions()) {
                if (w.getEventType().equals(EventType.START)) {
                    startTrans = w;
                    break;
                }
            }
            if (startTrans != null)
                subProcessVO.getTransitions().remove(startTrans);
            subProcessVO.setAttribute(WorkAttributeConstant.ENTRY_TRANSITION_ID, entryTrans == null ? null : entryTrans.getWorkTransitionId().toString());
            subProcessVO.setAttribute(WorkAttributeConstant.START_TRANSITION_ID, startTrans == null ? null : startTrans.getWorkTransitionId().toString());
        }
    }
}
Also used : WorkTransitionVO(com.centurylink.mdw.model.value.work.WorkTransitionVO) ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO)

Example 83 with ProcessVO

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

the class DesignerDataAccess method getProcessDefinition.

public ProcessVO getProcessDefinition(String procname, int version) throws RemoteException, DataAccessException {
    if (procname.indexOf(RemoteAccess.REMOTE_NAME_DELIMITER) > -1) {
        int k = procname.indexOf(RemoteAccess.REMOTE_NAME_DELIMITER);
        String properProcname = procname.substring(0, k);
        String logicalServerName = procname.substring(k + 1);
        RemoteAccess rao = remoteAccess.get(logicalServerName);
        if (rao == null) {
            rao = createRemoteAccess(logicalServerName);
            remoteAccess.put(logicalServerName, rao);
        }
        ProcessLoader procLoader = rao.getLoader();
        ProcessVO procdef = procLoader.getProcessBase(properProcname, version);
        procdef.setRemoteServer(logicalServerName);
        return procdef;
    } else {
        return loader.getProcessBase(procname, version);
    }
}
Also used : RemoteAccess(com.centurylink.mdw.dataaccess.RemoteAccess) ProcessLoader(com.centurylink.mdw.dataaccess.ProcessLoader) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO)

Example 84 with ProcessVO

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

the class DesignerDataAccess method getTaskInstances.

private List<TaskInstanceVO> getTaskInstances(ProcessVO process, ProcessInstanceVO processInstance, Long activityId, List<TaskInstanceVO> allTaskInstances) throws DataAccessException {
    List<TaskInstanceVO> taskInstances = new ArrayList<>();
    for (TaskInstanceVO taskInstance : allTaskInstances) {
        String secondaryOwner = taskInstance.getSecondaryOwnerType();
        if (OwnerType.DOCUMENT.equals(secondaryOwner) || "EXTERNAL_EVENT_INSTANCE".equals(secondaryOwner)) {
            String formDataString = null;
            if (OwnerType.DOCUMENT.equals(secondaryOwner))
                formDataString = rtinfo.getDocument(taskInstance.getSecondaryOwnerId()).getContent();
            else if ("EXTERNAL_EVENT_INSTANCE".equals(secondaryOwner))
                formDataString = rtinfo.getExternalEventDetails(taskInstance.getSecondaryOwnerId());
            FormDataDocument formDataDoc = new FormDataDocument();
            try {
                formDataDoc.load(formDataString);
                for (ActivityInstanceVO activityInstance : processInstance.getActivityInstances(activityId)) {
                    if (activityInstance.getId().equals(formDataDoc.getActivityInstanceId()))
                        taskInstances.add(taskInstance);
                }
            } catch (MbengException ex) {
                throw new DataAccessException(-1, ex.getMessage(), ex);
            }
        } else {
            // task instance secondary owner is work transition instance
            Long workTransInstId = taskInstance.getSecondaryOwnerId();
            for (WorkTransitionInstanceVO transitionInstance : processInstance.getTransitions()) {
                if (transitionInstance.getTransitionInstanceID().equals(workTransInstId)) {
                    Long transitionId = transitionInstance.getTransitionID();
                    WorkTransitionVO workTrans = process.getWorkTransition(transitionId);
                    if (workTrans == null && process.getSubProcesses() != null) {
                        for (ProcessVO subproc : process.getSubProcesses()) {
                            workTrans = subproc.getWorkTransition(transitionId);
                            if (workTrans != null)
                                break;
                        }
                    }
                    if (workTrans != null && workTrans.getToWorkId().equals(activityId))
                        taskInstances.add(taskInstance);
                }
            }
        }
    }
    return taskInstances;
}
Also used : MbengException(com.qwest.mbeng.MbengException) WorkTransitionInstanceVO(com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO) WorkTransitionVO(com.centurylink.mdw.model.value.work.WorkTransitionVO) ActivityInstanceVO(com.centurylink.mdw.model.value.work.ActivityInstanceVO) TaskInstanceVO(com.centurylink.mdw.model.value.task.TaskInstanceVO) ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) FormDataDocument(com.centurylink.mdw.model.FormDataDocument) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 85 with ProcessVO

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

the class DesignerDataAccess method exportAttributes.

public String exportAttributes(String prefix, Long artifactId, int schemaVersion, ProgressMonitor monitor, String exportArtifactType) throws DataAccessException, ActionCancelledException, XmlException {
    monitor.subTask("Loading attributes...");
    PackageVO packageVO = null;
    ProcessVO processVO = null;
    if (exportArtifactType.equals(OwnerType.PACKAGE)) {
        packageVO = loadPackage(artifactId, true);
        if (isVcsPersist()) {
            try {
                for (ProcessVO process : packageVO.getProcesses()) {
                    Map<String, String> overrideAttrs = workflowAccessRest.getAttributes(OwnerType.PROCESS, process.getId());
                    process.applyOverrideAttributes(overrideAttrs);
                }
            } catch (IOException ex) {
                throw new DataAccessOfflineException("Server does not appear to be running.", ex);
            }
        } else {
            for (ProcessVO process : packageVO.getProcesses()) {
                if (process.isInRuleSet()) {
                    Map<String, String> overrideAttrs = getAttributes(OwnerType.PROCESS, process.getId());
                    process.applyOverrideAttributes(overrideAttrs);
                }
            }
        }
    } else {
        processVO = getProcess(artifactId, null);
        if (isVcsPersist()) {
            try {
                // need to make sure attributes are retrieved
                Map<String, String> overrideAttrs = workflowAccessRest.getAttributes(OwnerType.PROCESS, processVO.getId());
                processVO.applyOverrideAttributes(overrideAttrs);
            } catch (IOException ex) {
                throw new DataAccessOfflineException("Server does not appear to be running.", ex);
            }
        }
    }
    monitor.progress(30);
    if (monitor.isCanceled())
        throw new ActionCancelledException();
    if (packageVO != null) {
        // -- subprocesses must come after their containing parent processes
        Collections.sort(packageVO.getProcesses(), new Comparator<ProcessVO>() {

            public int compare(ProcessVO pVO1, ProcessVO pVO2) {
                boolean pVO1HasSubProcs = pVO1.getSubProcesses() != null && !pVO1.getSubProcesses().isEmpty();
                boolean pVO2HasSubProcs = pVO2.getSubProcesses() != null && !pVO2.getSubProcesses().isEmpty();
                if (pVO1HasSubProcs == pVO2HasSubProcs) {
                    // sort by label
                    return pVO1.getLabel().compareToIgnoreCase(pVO2.getLabel());
                } else if (pVO1HasSubProcs)
                    return -1;
                else
                    return 1;
            }
        });
    }
    if (monitor.isCanceled())
        throw new ActionCancelledException();
    monitor.progress(5);
    monitor.subTask(EXPORTXML);
    ProcessExporter exporter = DataAccess.getProcessExporter(schemaVersion, oldNamespaces ? DesignerCompatibility.getInstance() : null);
    String xml;
    if (packageVO != null)
        xml = exporter.exportOverrideAttributes(prefix, packageVO);
    else
        xml = exporter.exportOverrideAttributes(prefix, processVO, schemaVersion);
    monitor.progress(40);
    return xml;
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) IOException(java.io.IOException) ProcessExporter(com.centurylink.mdw.dataaccess.ProcessExporter)

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