use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.
the class DesignerPage method saveProcess.
/**
* Saves and then reload the process graph
*/
public Graph saveProcess(Graph process, MainFrame frame, PersistType persistType, int version, boolean lock) throws ValidationException, DataAccessException, RemoteException {
String processId = saveProcess(process, persistType, version, lock);
if (processId == null)
throw new ValidationException("Error in saving process");
// load process again
ProcessVO procdef = process.getProcessVO();
if (persistType == PersistType.CREATE) {
procdef.setProcessId(new Long(processId));
procdef = loadProcess(procdef);
} else if (persistType == PersistType.NEW_VERSION) {
procdef = frame.dao.getProcess(new Long(processId), procdef);
// procdef is overridden with the new version here
new ProcessWorker().convert_to_designer(procdef);
model.addProcess(procdef);
} else {
procdef = loadProcess(procdef);
}
process.reinit(procdef);
return process;
}
use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.
the class DesignerPage method saveProcess.
/**
* @param graph
* @return process ID if saving is successful; null o/w
*/
private String saveProcess(Graph graph, PersistType persistType, int version, boolean lock) throws ValidationException {
String processId = null;
ProcessVO process = graph.getProcessVO();
int currentVersion = process.getVersion();
try {
frame.log("Saving process " + process.getProcessName() + " ...");
new ProcessWorker().convert_from_designer(process, model.getNodeMetaInfo());
if (persistType == PersistType.CREATE) {
processId = frame.dao.createProcess(process);
} else {
processId = frame.dao.updateProcess(process, version, lock);
process.setVersion(currentVersion);
// keep the version number
}
graph.setDirtyLevel(Graph.CLEAN);
graph.setReadonly(true);
graph.getProcessVO().clearDeletedTransitions();
} catch (Exception e) {
// TODO better not to convert back - keep the original
new ProcessWorker().convert_to_designer(process);
process.setVersion(currentVersion);
e.printStackTrace();
throw new ValidationException(e.getCause() == null ? e.getMessage() : e.getCause().getMessage());
}
return processId;
}
use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.
the class DesignerPage method setProcessVersion.
private void setProcessVersion(Node node, boolean includeId) {
String procname = node.getAttribute(WorkAttributeConstant.PROCESS_NAME);
if (procname != null) {
ProcessVO procdef = findProcessDefinition(procname, 0);
if (procdef != null) {
node.setAttribute(WorkAttributeConstant.PROCESS_VERSION, Integer.toString(procdef.getVersion()));
if (includeId)
node.setAttribute("process_id", procdef.getProcessId().toString());
node.setAttribute(WorkAttributeConstant.ALIAS_PROCESS_ID, null);
}
}
}
use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method loadProcessInstance.
public RunTimeDesignerCanvas loadProcessInstance(WorkflowProcess processVersion, ProcessInstancePage processInstancePage) {
CodeTimer timer = new CodeTimer("loadProcessInstance()");
ProcessInstanceVO processInstanceInfo = processVersion.getProcessInstance();
ProcessInstanceLoader instanceLoadThread = new ProcessInstanceLoader(processInstanceInfo, processInstancePage);
String errorMessage = null;
try {
Graph processGraph = dataAccess.getDesignerDataModel().findProcessGraph(processVersion.getId(), null);
if (processGraph == null)
processGraph = processInstancePage.loadProcess(processInstanceInfo.getProcessId(), null);
processVersion.setProcessVO(processGraph.getProcessVO());
DesignerDataAccess dao = processVersion.getDesignerDataAccess() == null ? processInstancePage.frame.dao : processVersion.getDesignerDataAccess();
Graph procInstGraph = instanceLoadThread.loadCompletionMap(processGraph.getProcessVO(), processInstanceInfo, dao);
ProcessInstanceTreeModel model = instanceLoadThread.createOrUpdateModel(null);
model.getCurrentProcess().setGraph(procInstGraph);
processInstancePage.setData(model, processInstancePage);
Map<Long, List<TaskInstanceVO>> taskInstances = new HashMap<>();
// embedded subprocesses
List<ProcessInstanceVO> embeddedSubs = new ArrayList<>();
if (procInstGraph.subgraphs != null) {
for (SubGraph instSubGraph : procInstGraph.subgraphs) {
if (instSubGraph.getInstances() != null) {
if (instSubGraph.nodes != null) {
List<Long> taskActivityIds = new ArrayList<>();
for (Node node : instSubGraph.nodes) {
if (node.isTaskActivity()) {
for (ProcessInstanceVO embeddedProcInst : instSubGraph.getInstances()) {
if (!embeddedProcInst.getActivityInstances(node.getActivityId()).isEmpty())
taskActivityIds.add(node.getActivityId());
}
}
}
if (!taskActivityIds.isEmpty()) {
for (ProcessInstanceVO embeddedProcInst : instSubGraph.getInstances()) {
ProcessVO embeddedProc = instSubGraph.getGraph().getProcessVO();
Map<Long, List<TaskInstanceVO>> embeddedTaskInsts = dao.getTaskInstances(embeddedProc, embeddedProcInst, taskActivityIds);
for (Map.Entry<Long, List<TaskInstanceVO>> embeddedTaskInst : embeddedTaskInsts.entrySet()) {
if (taskInstances.get(embeddedTaskInst.getKey()) == null)
taskInstances.put(embeddedTaskInst.getKey(), new ArrayList<TaskInstanceVO>());
taskInstances.get(embeddedTaskInst.getKey()).addAll(embeddedTaskInst.getValue());
}
}
}
}
embeddedSubs.addAll(instSubGraph.getInstances());
}
}
}
processVersion.setEmbeddedSubProcessInstances(embeddedSubs);
// manual task instances
if (processGraph.nodes != null) {
List<Long> taskActivityIds = new ArrayList<>();
for (Node node : processGraph.nodes) {
if (node.isTaskActivity() && !processInstanceInfo.getActivityInstances(node.getActivityId()).isEmpty())
taskActivityIds.add(node.getActivityId());
}
if (!taskActivityIds.isEmpty()) {
Map<Long, List<TaskInstanceVO>> taskInsts = dao.getTaskInstances(processVersion.getProcessVO(), processInstanceInfo, taskActivityIds);
for (Map.Entry<Long, List<TaskInstanceVO>> taskInst : taskInsts.entrySet()) {
if (taskInstances.get(taskInst.getKey()) == null)
taskInstances.put(taskInst.getKey(), new ArrayList<TaskInstanceVO>());
taskInstances.get(taskInst.getKey()).addAll(taskInst.getValue());
}
}
}
processVersion.setTaskInstances(taskInstances);
} catch (Exception ex) {
PluginMessages.log(ex);
errorMessage = PluginMessages.getUserMessage(ex);
}
if (errorMessage == null)
errorMessage = instanceLoadThread.getErrorMessage();
if (errorMessage != null) {
PluginMessages.uiError(errorMessage, "Load Process Instance");
}
timer.stopAndLog();
return processInstancePage.canvas;
}
use of com.centurylink.mdw.model.value.process.ProcessVO in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method prepareTestCase.
public TestCaseRun prepareTestCase(AutomatedTestCase testCase, int runNum, File resultDir, boolean createReplace, boolean verbose, PrintStream log, LogMessageMonitor monitor, boolean singleServer, boolean stubbing, boolean debug) throws RemoteException {
if ((testCase.isGroovy() || testCase.isGherkin()) && !MdwPlugin.workspaceHasGroovySupport()) {
String msg = "Please install Groovy support to execute test case: " + testCase.getName();
throw new IllegalStateException(msg);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd-HHmmssSSS");
try {
if (!testCase.isLegacy() && !testCase.getProject().isFilePersist()) {
// non-VCS asset-based -- load ruleSet content
testCase.load();
testCase.getRuleSetVO().setPackageName(testCase.getPackage().getName());
}
testCase.getTestCase().prepare();
Map<String, ProcessVO> procCache = new HashMap<>();
String masterRequestId = testCase.getMasterRequestId();
if (masterRequestId == null)
masterRequestId = project.getUser().getUsername() + "-" + sdf.format(new Date());
else if (!testCase.isGroovy() && !testCase.isGherkin() && masterRequestId.equals(TestDataFilter.AnyNumberToken))
masterRequestId = Long.toString(System.currentTimeMillis());
if (testCase.isGherkin() && masterRequestId.indexOf("${masterRequestId}") != -1)
masterRequestId = masterRequestId.replace("${masterRequestId}", project.getUser().getUsername() + "-" + sdf.format(new Date()));
testCase.setMasterRequestId(masterRequestId);
TestCaseRun run;
if (testCase.isGherkin()) {
run = new GherkinTestCaseLaunch(testCase.getTestCase(), runNum, masterRequestId, new DesignerDataAccess(dataAccess.getDesignerDataAccess()), monitor, procCache, testCase.isLoadTest(), true, testCase.getProject().isOldNamespaces(), project);
} else if (testCase.isGroovy()) {
if (debug) {
run = new AutoTestCaseRun(testCase, runNum, masterRequestId, new DesignerDataAccess(dataAccess.getDesignerDataAccess()), monitor, procCache, debug);
} else {
List<String> classpathList = null;
IJavaProject javaProject = project.getJavaProject();
if (javaProject != null && javaProject.exists()) {
classpathList = Arrays.asList(JavaRuntime.computeDefaultRuntimeClassPath(javaProject));
}
run = new GroovyTestCaseRun(testCase.getTestCase(), runNum, masterRequestId, new DesignerDataAccess(dataAccess.getDesignerDataAccess()), monitor, procCache, testCase.isLoadTest(), true, testCase.getProject().isOldNamespaces(), classpathList);
}
} else {
run = new TestCaseRun(testCase.getTestCase(), runNum, masterRequestId, new DesignerDataAccess(dataAccess.getDesignerDataAccess()), monitor, procCache, testCase.isLoadTest(), true, testCase.getProject().isOldNamespaces());
}
run.prepareTest(createReplace, resultDir, verbose, singleServer, stubbing, log);
return run;
} catch (Exception ex) {
throw new RemoteException(ex.getMessage(), ex);
}
}
Aggregations