/** * @return a {@link TaskService} instance that acts as a client instance to the remote API */ public TaskService getTaskService() { return new TaskServiceClientCommandObject(config); }
@Override public List<TaskSummary> getTasksByGroup(List<String> groupIds) { GetTasksByGroupCommand cmd = new GetTasksByGroupCommand(); cmd.getGroupIds().addAll(groupIds); return executeCommand(cmd); }
@Override public RemoteApiResponse activate( long taskId ) { RemoteApiResponse<Void> response; try { delegate.activate(taskId, delegate.getConfig().getUserName()); response = new RemoteApiResponse<Void>(); } catch( RemoteClientException rce ) { response = createRemoteApiResponse(rce); } catch( Exception e ) { response = new RemoteApiResponse<Void>(RemoteOperationStatus.UNKNOWN_FAILURE, e); } return response; }
@Override public List<TaskSummary> getTasksOwned( String userId, String language ) { GetTasksOwnedCommand cmd = new GetTasksOwnedCommand(); cmd.setUserId(userId); cmd.setFilter(addLanguageFilter(language)); return executeCommand(cmd); }
@Override public void nominate( long taskId, String userId, List<OrganizationalEntity> potentialOwners ) { NominateTaskCommand cmd = new NominateTaskCommand(); cmd.setTaskId(taskId); cmd.setUserId(userId); List<org.kie.remote.jaxb.gen.OrganizationalEntity> genOrgEntList = convertKieOrgEntListToGenOrgEntList(potentialOwners); if( genOrgEntList != null ) { cmd.getPotentialOwners().addAll(genOrgEntList); } 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 RemoteApiResponse<Map<String, Object>> getOutputContentMap( long taskId ) { RemoteApiResponse<Map<String, Object>> response; try { GetContentMapForUserCommand cmd = new GetContentMapForUserCommand(); cmd.setTaskId(taskId); cmd.setUserId(delegate.getConfig().getUserName()); Map<String, Object> outputContentMap = delegate.executeCommand(cmd); response = new RemoteApiResponse<Map<String, Object>>(outputContentMap); } catch( RemoteClientException rce ) { response = createRemoteApiResponse(rce); } catch( Exception e ) { response = new RemoteApiResponse<Map<String, Object>>(RemoteOperationStatus.UNKNOWN_FAILURE, e); } return response; }
private static org.kie.remote.jaxb.gen.Task convertKieTaskToGenTask( Task task ) { org.kie.remote.jaxb.gen.Task genTask = new org.kie.remote.jaxb.gen.Task(); genTask.setDescription(task.getDescription()); List<org.kie.remote.jaxb.gen.I18NText> genTextList = convertKieTextListToGenTextList(task.getDescriptions()); if( genTextList != null ) { genTask.getDescriptions().addAll(genTextList); genTextList = convertKieTextListToGenTextList(task.getNames()); if( genTextList != null ) { genTask.getNames().addAll(genTextList); org.kie.remote.jaxb.gen.PeopleAssignments genPeepAssigns = new org.kie.remote.jaxb.gen.PeopleAssignments(); genTask.setPeopleAssignments(genPeepAssigns); List<org.kie.remote.jaxb.gen.OrganizationalEntity> genOrgEntList = convertKieOrgEntListToGenOrgEntList(kiePeepAssigns .getBusinessAdministrators()); if( genOrgEntList != null ) { genPeepAssigns.getBusinessAdministrators().addAll(genOrgEntList); genOrgEntList = convertKieOrgEntListToGenOrgEntList(kiePeepAssigns.getPotentialOwners()); if( genOrgEntList != null ) { genPeepAssigns.getPotentialOwners().addAll(genOrgEntList); org.kie.remote.jaxb.gen.OrganizationalEntity genOrgEnt = convertKieOrgEntToGenOrgEnt(kiePeepAssigns.getTaskInitiator()); if( genOrgEnt != null ) { genPeepAssigns.setTaskInitiatorId(genOrgEnt.getId()); genTextList = convertKieTextListToGenTextList(task.getSubjects()); if( genTextList != null ) { genTask.getSubjects().addAll(genTextList);
TaskServiceClientCommandObject taskServiceClient = new TaskServiceClientCommandObject(config); TaskServiceClientCommandObject taskServiceClientSpy = spy(taskServiceClient); ArgumentCaptor<Command> cmdCaptor = ArgumentCaptor.forClass(Command.class); doReturn(new Object()).when(taskServiceClientSpy).executeCommand(cmdCaptor.capture());
TaskServiceClientCommandObject taskServiceClient = new TaskServiceClientCommandObject(config); List<Object> objectList = new ArrayList<Object>(); taskServiceClient.addPossiblyNullObject(inputObject, objectList); assertEquals(1, objectList.size()); assertEquals(inputObject, objectList.get(0)); taskServiceClient.addPossiblyNullObject(inputObject, objectList); assertEquals(0, objectList.size()); inputObjectList.add(inputObject); objectList = new ArrayList<Object>(); taskServiceClient.addPossiblyNullObject(inputObjectList, objectList); assertEquals(1, objectList.size()); assertEquals(inputObject, objectList.get(0)); inputObjectArray.getItems().add(inputObjectNullPair); objectList = new ArrayList<Object>(); taskServiceClient.addPossiblyNullObject(inputObjectArray, objectList); assertEquals(1, objectList.size()); assertEquals(inputObject, objectList.get(0)); inputObjectValueMap.put("one", null); objectList = new ArrayList<Object>(); taskServiceClient.addPossiblyNullObject(inputObjectValueMap, objectList); assertEquals(0, objectList.size()); inputObjectList.add(inputObjectList); objectList = new ArrayList<Object>();
@Override public RemoteApiResponse claim( long taskId ) { RemoteApiResponse<Void> response; try { delegate.claim(taskId, delegate.getConfig().getUserName()); response = new RemoteApiResponse<Void>(); } catch( RemoteClientException rce ) { response = createRemoteApiResponse(rce); } catch( Exception e ) { response = new RemoteApiResponse<Void>(RemoteOperationStatus.UNKNOWN_FAILURE, e); } return response; }
@Override public RemoteApiResponse claimNextAvailable() { RemoteApiResponse<Void> response; try { delegate.claimNextAvailable(delegate.getConfig().getUserName()); response = new RemoteApiResponse<Void>(); } catch( RemoteClientException rce ) { response = createRemoteApiResponse(rce); } catch( Exception e ) { response = new RemoteApiResponse<Void>(RemoteOperationStatus.UNKNOWN_FAILURE, e); } return response; }
@Override public RemoteApiResponse complete( long taskId, Map<String, Object> data ) { RemoteApiResponse<Void> response; try { delegate.complete(taskId, delegate.getConfig().getUserName(), data); response = new RemoteApiResponse<Void>(); } catch( RemoteClientException rce ) { response = createRemoteApiResponse(rce); } catch( Exception e ) { response = new RemoteApiResponse<Void>(RemoteOperationStatus.UNKNOWN_FAILURE, e); } return response; }
@Override public void claimNextAvailable( String userId, String language ) { claimNextAvailable(userId); }
private static List<org.kie.remote.jaxb.gen.OrganizationalEntity> convertKieOrgEntListToGenOrgEntList( List<OrganizationalEntity> kieOrgEntList ) { List<org.kie.remote.jaxb.gen.OrganizationalEntity> genOrgEntList = null; if( kieOrgEntList != null ) { genOrgEntList = new ArrayList<org.kie.remote.jaxb.gen.OrganizationalEntity>(kieOrgEntList.size()); for( OrganizationalEntity kieOrgEnt : kieOrgEntList ) { org.kie.remote.jaxb.gen.OrganizationalEntity genOrgEnt = convertKieOrgEntToGenOrgEnt(kieOrgEnt); genOrgEntList.add(genOrgEnt); } } return genOrgEntList; }
@Override public List<TaskSummary> getTasksAssignedAsPotentialOwner( String userId, String language ) { GetTaskAssignedAsPotentialOwnerCommand cmd = new GetTaskAssignedAsPotentialOwnerCommand(); cmd.setUserId(userId); cmd.setFilter(addLanguageFilter(language)); return executeCommand(cmd); }
@Override public RemoteApiResponse nominate( long taskId, String... potentialOwnerUserIds ) { RemoteApiResponse<Void> response; if( potentialOwnerUserIds == null || potentialOwnerUserIds.length == 0 ) { return new RemoteApiResponse<Void>(RemoteOperationStatus.CLIENT_FAILURE, "Null or empty list of potential owner user ids received as argument"); } try { NominateTaskCommand cmd = new NominateTaskCommand(); cmd.setTaskId(taskId); cmd.setUserId(delegate.getConfig().getUserName()); List<org.kie.remote.jaxb.gen.OrganizationalEntity> genOrgEntList = convertStringListToGenOrgEntList(Arrays.asList(potentialOwnerUserIds)); if( genOrgEntList != null ) { cmd.getPotentialOwners().addAll(genOrgEntList); } delegate.executeCommand(cmd); response = new RemoteApiResponse<Void>(); } catch( RemoteClientException rce ) { response = createRemoteApiResponse(rce); } catch( Exception e ) { response = new RemoteApiResponse<Void>(RemoteOperationStatus.UNKNOWN_FAILURE, e); } return response; }
public void claimNextAvailable( String userId ) { ClaimNextAvailableTaskCommand cmd = new ClaimNextAvailableTaskCommand(); cmd.setUserId(userId); executeCommand(cmd); }
@Override public List<TaskSummary> getTasksOwnedByStatus( String userId, List<Status> status, String language ) { GetTasksOwnedCommand cmd = new GetTasksOwnedCommand(); cmd.setUserId(userId); if( status != null ) { cmd.getStatuses().addAll(status); } cmd.setFilter(addLanguageFilter(language)); return executeCommand(cmd); }
@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; }