Search in sources :

Example 31 with VariableVO

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);
    }
}
Also used : Server(com.centurylink.mdw.designer.utils.Server) RestfulServer(com.centurylink.mdw.designer.utils.RestfulServer) HashMap(java.util.HashMap) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) AssetFile(com.centurylink.mdw.dataaccess.file.AssetFile) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map) JSONException(org.json.JSONException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException)

Example 32 with VariableVO

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());
}
Also used : Action(com.centurylink.mdw.service.Action) Parameter(com.centurylink.mdw.service.Parameter) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) ActionRequestDocument(com.centurylink.mdw.service.ActionRequestDocument)

Example 33 with VariableVO

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);
    }
}
Also used : JSONObject(org.json.JSONObject) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) Parameter(com.centurylink.mdw.service.Parameter) MDWStatusMessage(com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage) StatusMessage(com.centurylink.mdw.common.service.types.StatusMessage) ActionRequestDocument(com.centurylink.mdw.service.ActionRequestDocument)

Example 34 with VariableVO

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);
    }
}
Also used : Server(com.centurylink.mdw.designer.utils.Server) RestfulServer(com.centurylink.mdw.designer.utils.RestfulServer) HashMap(java.util.HashMap) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) JSONException(org.json.JSONException) ParseException(java.text.ParseException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) MbengException(com.qwest.mbeng.MbengException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException)

Aggregations

VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)34 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)9 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)7 VariableValue (com.centurylink.mdw.plugin.designer.model.VariableValue)5 IOException (java.io.IOException)4 Map (java.util.Map)4 TreeMap (java.util.TreeMap)4 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)3 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)3 ActivityVO (com.centurylink.mdw.model.value.activity.ActivityVO)3 VariableTypeVO (com.centurylink.mdw.model.value.variable.VariableTypeVO)3 VariableBinding (com.centurylink.mdw.plugin.designer.model.VariableBinding)3 ActionRequestDocument (com.centurylink.mdw.service.ActionRequestDocument)3 Parameter (com.centurylink.mdw.service.Parameter)3 XmlException (org.apache.xmlbeans.XmlException)3 JSONException (org.json.JSONException)3 MDWStatusMessage (com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage)2 SubGraph (com.centurylink.mdw.designer.display.SubGraph)2 RestfulServer (com.centurylink.mdw.designer.utils.RestfulServer)2