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