use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.
the class DesignerDataAccess method getProcess.
public ProcessVO getProcess(Long procId, ProcessVO procdef) throws DataAccessException {
if (procdef != null && procdef.isRemote()) {
ProcessLoader procLoader = remoteAccess.get(procdef.getRemoteServer()).getLoader();
return procLoader.loadProcess(procId, true);
} else {
ProcessVO process = loader.loadProcess(procId, true);
if (process == null && remoteAssetRetrieve)
process = remoteRetrieveProcess(procId);
if (process != null) {
if (isVcsPersist()) {
if (remoteAssetRetrieve) {
try {
Map<String, String> overrideAttrs = workflowAccessRest.getAttributes(OwnerType.PROCESS, procId);
process.applyOverrideAttributes(overrideAttrs);
} catch (IOException ex) {
System.err.println("Server not running: " + ex);
}
}
} else {
if (process.isInRuleSet())
process.applyOverrideAttributes(getAttributes(OwnerType.PROCESS, procId));
}
}
return process;
}
}
use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.
the class DesignerDataAccess method exportPackage.
public String exportPackage(Long packageId, int schemaVersion, boolean includeTaskTemplates, ProgressMonitor monitor) throws DataAccessException, ActionCancelledException, XmlException {
if (monitor != null)
monitor.subTask("Loading package...");
PackageVO packageVO = loadPackage(packageId, true);
if (monitor != null)
monitor.progress(30);
if (monitor != null) {
if (monitor.isCanceled())
throw new ActionCancelledException();
else
monitor.subTask("Sorting processes and implementors");
}
// adding same logic as in PopupHandler export to get same result
for (ProcessVO processVO : packageVO.getProcesses()) new ProcessWorker().convert_to_designer(processVO);
if (packageVO.getRuleSets() != null) {
Map<String, CustomAttributeVO> customAttrs = new HashMap<>();
for (RuleSetVO ruleSet : packageVO.getRuleSets()) {
if (ruleSet.getLanguage() != null && !customAttrs.containsKey(ruleSet.getLanguage())) {
CustomAttributeVO custAttrVO = getCustomAttribute("RULE_SET", ruleSet.getLanguage());
if (custAttrVO != null)
customAttrs.put(ruleSet.getLanguage(), custAttrVO);
}
}
List<CustomAttributeVO> customAttributes = new ArrayList<>();
for (CustomAttributeVO customAttr : customAttrs.values()) customAttributes.add(customAttr);
packageVO.setCustomAttributes(customAttributes);
}
if (monitor != null && monitor.isCanceled())
throw new ActionCancelledException();
if (monitor != null)
monitor.progress(5);
if (monitor != null)
monitor.subTask(EXPORTXML);
ProcessExporter exporter = DataAccess.getProcessExporter(schemaVersion, oldNamespaces ? DesignerCompatibility.getInstance() : null);
String xml = exporter.exportPackage(packageVO, includeTaskTemplates);
if (monitor != null)
monitor.progress(25);
packageVO.setExported(true);
persister.persistPackage(packageVO, PersistType.UPDATE);
if (monitor != null)
monitor.progress(15);
return xml;
}
use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.
the class Importer method updateSubProcessIdAttributes.
/**
* Update processid attribute for calling processes within this package. Get
* rid of this method, which is only needed for ancient (pre-4.5) runtimes.
*/
private void updateSubProcessIdAttributes(ProcessVO processVO) throws DataAccessException, RemoteException, XmlException {
boolean toUpdate = false;
if (processVO.getActivities() != null) {
for (ActivityVO actVO : processVO.getActivities()) {
String procNameAttr = actVO.getAttribute(PROCESSNAME);
String procVerAttr = actVO.getAttribute(PROCESSVERSION);
if (procNameAttr != null && procVerAttr != null) {
toUpdate = true;
}
}
if (processVO.getSubProcesses() != null) {
for (ProcessVO embedded : processVO.getSubProcesses()) {
for (ActivityVO actVO : embedded.getActivities()) {
String procNameAttr = actVO.getAttribute(PROCESSNAME);
String procVerAttr = actVO.getAttribute(PROCESSVERSION);
if (procNameAttr != null && procVerAttr != null) {
toUpdate = true;
}
}
}
}
}
if (toUpdate) {
ProcessVO procVO = dataAccess.getProcess(processVO.getProcessId(), processVO);
for (ActivityVO actVO : procVO.getActivities()) {
String procNameAttr = actVO.getAttribute(PROCESSNAME);
String procVerAttr = actVO.getAttribute(PROCESSVERSION);
if (procNameAttr != null && procVerAttr != null) {
for (ProcessVO checkVO : importedPackageVO.getProcesses()) {
if (checkVO.getProcessName().equals(procNameAttr) && String.valueOf(checkVO.getVersion()).equals(procVerAttr))
actVO.setAttribute("processid", checkVO.getProcessId().toString());
}
}
}
if (procVO.getSubProcesses() != null) {
for (ProcessVO embedded : procVO.getSubProcesses()) {
for (ActivityVO actVO : embedded.getActivities()) {
String procNameAttr = actVO.getAttribute(PROCESSNAME);
String procVerAttr = actVO.getAttribute(PROCESSVERSION);
if (procNameAttr != null && procVerAttr != null) {
for (ProcessVO checkVO : importedPackageVO.getProcesses()) {
if (checkVO.getProcessName().equals(procNameAttr) && String.valueOf(checkVO.getVersion()).equals(procVerAttr))
actVO.setAttribute("processid", checkVO.getProcessId().toString());
}
}
}
}
}
dataAccess.updateProcess(procVO, 0, false);
}
}
use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.
the class TestCaseRun method performStart.
public void performStart(TestFileLine line) throws TestException {
logCommand(line);
ProcessVO vo = getProcess(line, line.getWord(1));
Map<String, String> params = new HashMap<>();
try {
for (int i = 2; i < line.getWordCount(); i++) {
int k = line.getWord(i).indexOf('=');
params.put(line.getWord(i).substring(0, k), getParameterValue(line.getWord(i).substring(k + 1)));
}
String server = getNextServer();
if (server == null)
dao.launchProcess(vo, masterRequestId, null, params, false, oldNamespaces);
else {
Server restServer = dao.getCurrentServer();
if (restServer.isSchemaVersion61()) {
Map<VariableVO, String> variables = new HashMap<>();
for (Map.Entry<String, String> entry : params.entrySet()) {
VariableVO varVO = vo.getVariable(entry.getKey());
if (varVO != null)
variables.put(varVO, entry.getValue());
}
response = ((RestfulServer) restServer).launchProcess(vo.getProcessId(), masterRequestId, vo.getOwnerType(), vo.getOwnerId(), variables);
} else {
String request = dao.getCurrentServer().buildLaunchProcessRequest(vo, masterRequestId, null, params, false, oldNamespaces);
dao.engineCall(dao.getPeerServerUrl(server), request);
}
}
} catch (Exception e) {
throw new TestException(line, "failed to launch process", e);
}
}
use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.
the class TestCaseRun method loadResults.
protected List<ProcessInstanceVO> loadResults(List<ProcessVO> processes, TestCaseAsset expectedResults, boolean orderById) throws DataAccessException, IOException {
List<ProcessInstanceVO> mainProcessInsts = new ArrayList<>();
Map<String, List<ProcessInstanceVO>> fullProcessInsts = new TreeMap<>();
Map<String, String> fullActivityNameMap = new HashMap<>();
for (ProcessVO proc : processes) {
Map<String, String> criteria = new HashMap<>();
criteria.put("masterRequestId", masterRequestId);
criteria.put("processId", proc.getId().toString());
List<ProcessInstanceVO> procInstList = dao.getProcessInstanceList(criteria, 1, 100, proc, null).getItems();
int n = procInstList.size();
Map<Long, String> activityNameMap = new HashMap<>();
for (ActivityVO act : proc.getActivities()) {
activityNameMap.put(act.getActivityId(), act.getActivityName());
fullActivityNameMap.put(proc.getId() + "-" + act.getActivityId(), act.getActivityName());
}
if (proc.getSubProcesses() != null) {
for (ProcessVO subproc : proc.getSubProcesses()) {
for (ActivityVO act : subproc.getActivities()) {
activityNameMap.put(act.getActivityId(), act.getActivityName());
fullActivityNameMap.put(proc.getId() + "-" + act.getActivityId(), act.getActivityName());
}
}
}
for (ProcessInstanceVO procInst : procInstList) {
procInst = dao.getProcessInstanceAll(procInst.getId(), proc);
mainProcessInsts.add(procInst);
if (getTestCase().isLegacy()) {
translateToLegacyTestFile(proc.getProcessName(), procInst, n, activityNameMap);
} else {
List<ProcessInstanceVO> procInsts = fullProcessInsts.get(proc.getName());
if (procInsts == null)
procInsts = new ArrayList<>();
procInsts.add(procInst);
fullProcessInsts.put(proc.getName(), procInsts);
}
if (proc.getSubProcesses() != null) {
criteria.clear();
if (proc.isInRuleSet()) {
criteria.put("owner", OwnerType.MAIN_PROCESS_INSTANCE);
criteria.put("ownerId", procInst.getId().toString());
criteria.put("processId", proc.getProcessId().toString());
List<ProcessInstanceVO> embeddedProcInstList = dao.getProcessInstanceList(criteria, 0, QueryRequest.ALL_ROWS, proc, null).getItems();
int m = embeddedProcInstList.size();
for (ProcessInstanceVO embeddedProcInst : embeddedProcInstList) {
ProcessInstanceVO fullChildInfo = dao.getProcessInstanceAll(embeddedProcInst.getId(), proc);
String childProcName = "unknown_subproc_name";
for (ProcessVO subproc : proc.getSubProcesses()) {
if (subproc.getProcessId().toString().equals(embeddedProcInst.getComment())) {
childProcName = subproc.getProcessName();
if (!childProcName.startsWith(proc.getProcessName()))
childProcName = proc.getProcessName() + " " + childProcName;
break;
}
}
if (getTestCase().isLegacy()) {
translateToLegacyTestFile(childProcName, fullChildInfo, m, activityNameMap);
} else {
List<ProcessInstanceVO> procInsts = fullProcessInsts.get(childProcName);
if (procInsts == null)
procInsts = new ArrayList<>();
procInsts.add(fullChildInfo);
fullProcessInsts.put(childProcName, procInsts);
}
m--;
}
} else {
StringBuilder sb = new StringBuilder();
sb.append("(");
for (ProcessVO subproc : proc.getSubProcesses()) {
if (sb.length() > 1)
sb.append(",");
sb.append(subproc.getProcessId());
}
sb.append(")");
criteria.put("owner", OwnerType.PROCESS_INSTANCE);
criteria.put("ownerId", procInst.getId().toString());
criteria.put("processIdList", sb.toString());
List<ProcessInstanceVO> embeddedProcInstList = dao.getProcessInstanceList(criteria, 0, QueryRequest.ALL_ROWS, proc, null).getItems();
int m = embeddedProcInstList.size();
for (ProcessInstanceVO embeddedProcInst : embeddedProcInstList) {
ProcessInstanceVO fullChildInfo = dao.getProcessInstanceAll(embeddedProcInst.getId(), proc);
String childProcName = "unknown_subproc_name";
for (ProcessVO subproc : proc.getSubProcesses()) {
if (subproc.getProcessId().equals(embeddedProcInst.getProcessId())) {
childProcName = subproc.getProcessName();
if (!childProcName.startsWith(proc.getProcessName()))
childProcName = proc.getProcessName() + " " + childProcName;
break;
}
}
if (getTestCase().isLegacy()) {
translateToLegacyTestFile(childProcName, fullChildInfo, m, activityNameMap);
}
m--;
}
}
}
n--;
}
}
if (!getTestCase().isLegacy()) {
String newLine = "\n";
if (!createReplace) {
// try to determine newline chars from expectedResultsFile
if (expectedResults.exists() && expectedResults.text().indexOf("\r\n") >= 0)
newLine = "\r\n";
}
String yaml = translateToYaml(fullProcessInsts, fullActivityNameMap, orderById, newLine);
if (createReplace) {
log.println("creating expected results: " + expectedResults);
FileHelper.writeToFile(expectedResults.toString(), yaml, false);
}
String fileName = testcase.getResultDirectory() + "/" + expectedResults.getName();
if (verbose)
log.println("creating actual results file: " + fileName);
FileHelper.writeToFile(fileName, yaml, false);
}
// set friendly statuses
if (mainProcessInsts != null) {
for (ProcessInstanceVO pi : mainProcessInsts) pi.setStatus(WorkStatuses.getWorkStatuses().get(pi.getStatusCode()));
}
return mainProcessInsts;
}
Aggregations