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());
}
}
}
}
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());
}
}
}
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);
}
}
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;
}
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;
}
Aggregations