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