use of com.centurylink.mdw.model.value.variable.VariableVO in project mdw-designer by CenturyLinkCloud.
the class GroovyTestCaseRun method startProcess.
void startProcess(TestCaseProcess process) throws TestException {
if (verbose)
log.println("starting process " + process.getLabel() + "...");
this.testCaseProcess = process;
try {
if (!getTestCase().isLegacy()) {
// delete the (convention-based) result file if exists
String resFileName = getTestCase().getName() + RuleSetVO.getFileExtension(RuleSetVO.YAML);
File resFile = new File(getTestCase().getResultDirectory() + "/" + resFileName);
if (resFile.isFile())
resFile.delete();
}
ProcessVO vo = process.getProcessVo();
Map<String, String> params = process.getParams();
String server = getNextServer();
String response;
if (server == null) {
response = dao.launchProcess(vo, getMasterRequestId(), 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 = restServer.buildLaunchProcessRequest(vo, getMasterRequestId(), null, params, false, oldNamespaces);
response = dao.engineCall(dao.getPeerServerUrl(server), request);
}
}
validateEngineCallResponse(response);
} catch (Exception ex) {
throw new TestException("Failed to start " + process.getLabel(), ex);
}
}
use of com.centurylink.mdw.model.value.variable.VariableVO in project mdw-designer by CenturyLinkCloud.
the class Server method buildLaunchProcessRequest.
public String buildLaunchProcessRequest(ProcessVO procdef, String masterRequestId, Long activityId, Map<String, String> parameters, boolean isServiceProcess, boolean oldFormat) throws DataAccessException, RemoteException, XmlException {
ActionRequestDocument actionRequestDoc = getLaunchProcessBaseDoc(procdef.getProcessId(), masterRequestId, "Designer", procdef.getId());
Action action = actionRequestDoc.getActionRequest().getAction();
if (activityId != null) {
Parameter parameter = action.addNewParameter();
parameter.setName("mdw.ActivityId");
parameter.setStringValue(activityId.toString());
}
if (isServiceProcess) {
Parameter syncParam = actionRequestDoc.getActionRequest().getAction().addNewParameter();
syncParam.setName("mdw.Synchronous");
syncParam.setStringValue("true");
}
for (String processParam : parameters.keySet()) {
Parameter parameter = action.addNewParameter();
parameter.setName(processParam);
VariableVO varVO = procdef.getVariable(processParam);
if (varVO != null)
parameter.setType(varVO.getVariableType());
parameter.setStringValue(parameters.get(processParam));
}
if (oldFormat)
return DesignerCompatibility.getInstance().getOldActionRequest(actionRequestDoc);
else
return actionRequestDoc.xmlText(getXmlOptions());
}
use of com.centurylink.mdw.model.value.variable.VariableVO in project mdw-designer by CenturyLinkCloud.
the class RestfulServer method launchProcess.
public MDWStatusMessageDocument launchProcess(Long processId, String masterRequestId, String owner, Long ownerId, Map<VariableVO, String> variables, Long activityId, boolean oldFormat) throws DataAccessException, XmlException, JSONException, IOException {
if (isSchemaVersion61()) {
String response = launchProcess(processId, masterRequestId, owner, ownerId, variables);
StatusMessage statusMessage = new StatusMessage(new JSONObject(response));
return statusMessage.getStatusDocument();
} else {
ActionRequestDocument actionRequestDoc = getLaunchProcessBaseDoc(processId, masterRequestId, owner, ownerId);
for (VariableVO variableVO : variables.keySet()) {
Parameter parameter = actionRequestDoc.getActionRequest().getAction().addNewParameter();
parameter.setName(variableVO.getVariableName());
parameter.setType(variableVO.getVariableType());
String stringValue = variables.get(variableVO);
parameter.setStringValue(stringValue);
}
if (activityId != null) {
Parameter parameter = actionRequestDoc.getActionRequest().getAction().addNewParameter();
parameter.setName("mdw.ActivityId");
parameter.setStringValue(activityId.toString());
}
String request;
if (oldFormat)
request = DesignerCompatibility.getInstance().getOldActionRequest(actionRequestDoc);
else
request = actionRequestDoc.xmlText(getXmlOptions());
return invokeService(request);
}
}
use of com.centurylink.mdw.model.value.variable.VariableVO 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);
}
}
Aggregations