@Override public ProcessInstance startProcess( String processId, Map<String, Object> parameters ) { StartProcessCommand cmd = new StartProcessCommand(); cmd.setProcessId(processId); JaxbStringObjectPairArray arrayMap = convertMapToJaxbStringObjectPairArray(parameters); cmd.setParameter(arrayMap); return (ProcessInstance) executeCommand(cmd); }
@Override public void completeWorkItem( long id, Map<String, Object> results ) { CompleteWorkItemCommand cmd = new CompleteWorkItemCommand(); cmd.setId(id); JaxbStringObjectPairArray arrayMap = convertMapToJaxbStringObjectPairArray(results); cmd.setResult(arrayMap); executeCommand(cmd); }
@Override public void fail( long taskId, String userId, Map<String, Object> faultData ) { FailTaskCommand cmd = new FailTaskCommand(); cmd.setTaskId(taskId); cmd.setUserId(userId); JaxbStringObjectPairArray values = convertMapToJaxbStringObjectPairArray(faultData); cmd.setData(values); executeCommand(cmd); }
@Override public long addTask( Task task, Map<String, Object> params ) { AddTaskCommand cmd = new AddTaskCommand(); org.kie.remote.jaxb.gen.Task genTask = convertKieTaskToGenTask(task); cmd.setJaxbTask(genTask); JaxbStringObjectPairArray values = convertMapToJaxbStringObjectPairArray(params); cmd.setParameter(values); return (Long) executeCommand(cmd); }
@Override public void complete( long taskId, String userId, Map<String, Object> data ) { CompleteTaskCommand cmd = new CompleteTaskCommand(); cmd.setTaskId(taskId); cmd.setUserId(userId); cmd.setData(convertMapToJaxbStringObjectPairArray(data)); executeCommand(cmd); }
@Override public ProcessInstance startProcess( String processId, CorrelationKey correlationKey, Map<String, Object> parameters ) { StartCorrelatedProcessCommand cmd = new StartCorrelatedProcessCommand(); cmd.setProcessId(processId); JaxbStringObjectPairArray arrayMap = convertMapToJaxbStringObjectPairArray(parameters); cmd.setParameter(arrayMap); String strCorrKey = convertCorrelationKeyToString(correlationKey); cmd.setCorrelationKey(strCorrKey); return executeCommand(cmd); }
@Test public void serializingPrimitiveArraysTest() throws Exception { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("url", "http://soaptest.parasoft.com/calculator.wsdl"); parameters.put("namespace", "http://www.parasoft.com/wsdl/calculator/"); parameters.put("interface", "Calculator"); parameters.put("operation", "add"); Float [] arrayParam = new Float[] { 9.0f, 12.0f }; parameters.put("parameters", arrayParam); addClassesToSerializationProvider(arrayParam.getClass()); org.kie.remote.jaxb.gen.StartProcessCommand cmd = new org.kie.remote.jaxb.gen.StartProcessCommand(); cmd.setProcessId("proc.with.array.params"); cmd.setParameter(ConversionUtil.convertMapToJaxbStringObjectPairArray(parameters)); org.kie.remote.client.jaxb.JaxbCommandsRequest clientReq = new org.kie.remote.client.jaxb.JaxbCommandsRequest("test", cmd); JaxbCommandsRequest serviceReq = (JaxbCommandsRequest) clientServicesRoundTrip(clientReq); StartProcessCommand newCmd = (StartProcessCommand) serviceReq.getCommands().get(0); assertNotNull(newCmd); Float [] arrayParamCopy = (Float[]) newCmd.getParameters().get("parameters"); assertArrayEquals(arrayParam, arrayParamCopy); }
@Override public RemoteApiResponse<Long> addOutputContent( long taskId, Map<String, Object> params ) { RemoteApiResponse<Long> response; if( params == null ) { return new RemoteApiResponse<Long>(RemoteOperationStatus.CLIENT_FAILURE, "Null Map<String, Object> received as argument"); } try { AddContentFromUserCommand cmd = new AddContentFromUserCommand(); cmd.setTaskId(taskId); cmd.setUserId(delegate.getConfig().getUserName()); cmd.setOutputContentMap(convertMapToJaxbStringObjectPairArray(params)); Long contentId = delegate.executeCommand(cmd); response = new RemoteApiResponse<Long>(contentId); } catch( RemoteClientException rce ) { response = createRemoteApiResponse(rce); } catch( Exception e ) { response = new RemoteApiResponse<Long>(RemoteOperationStatus.UNKNOWN_FAILURE, e); } return response; }