TSK-407: supporting all kind of lists for transferring tasks.
This commit is contained in:
parent
7dc1cd0456
commit
caff822ccd
|
@ -484,9 +484,10 @@ public class TaskServiceImpl implements TaskService {
|
||||||
taskanaEngine.openConnection();
|
taskanaEngine.openConnection();
|
||||||
LOGGER.debug("entry to transferBulk(targetWbId = {}, taskIds = {})", destinationWorkbasketId, taskIds);
|
LOGGER.debug("entry to transferBulk(targetWbId = {}, taskIds = {})", destinationWorkbasketId, taskIds);
|
||||||
// Check pre-conditions with trowing Exceptions
|
// Check pre-conditions with trowing Exceptions
|
||||||
if (destinationWorkbasketId == null || taskIds == null) {
|
if (destinationWorkbasketId == null || destinationWorkbasketId.isEmpty() || taskIds == null
|
||||||
|
|| taskIds.isEmpty()) {
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
"DestinationWorkbasketId or TaskIds can´t be used as NULL-Parameter.");
|
"DestinationWorkbasketId or TaskIds must not be null or empty.");
|
||||||
}
|
}
|
||||||
Workbasket destinationWorkbasket = workbasketService.getWorkbasket(destinationWorkbasketId);
|
Workbasket destinationWorkbasket = workbasketService.getWorkbasket(destinationWorkbasketId);
|
||||||
|
|
||||||
|
@ -521,10 +522,18 @@ public class TaskServiceImpl implements TaskService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BulkOperationResults<String, TaskanaException> transferTasks(List<String> taskIds,
|
private BulkOperationResults<String, TaskanaException> transferTasks(List<String> taskIdsToBeTransferred,
|
||||||
Workbasket destinationWorkbasket) throws InvalidArgumentException {
|
Workbasket destinationWorkbasket) throws InvalidArgumentException {
|
||||||
BulkOperationResults<String, TaskanaException> bulkLog = new BulkOperationResults<>();
|
BulkOperationResults<String, TaskanaException> bulkLog = new BulkOperationResults<>();
|
||||||
|
|
||||||
|
// convert to ArrayList<String> if necessary to prevent a UnsupportedOperationException while removing
|
||||||
|
ArrayList<String> taskIds;
|
||||||
|
if (!(taskIdsToBeTransferred instanceof ArrayList)) {
|
||||||
|
taskIds = new ArrayList<>(taskIdsToBeTransferred);
|
||||||
|
} else {
|
||||||
|
taskIds = (ArrayList<String>) taskIdsToBeTransferred;
|
||||||
|
}
|
||||||
|
|
||||||
// check tasks Ids exist and not empty - log and remove
|
// check tasks Ids exist and not empty - log and remove
|
||||||
Iterator<String> taskIdIterator = taskIds.iterator();
|
Iterator<String> taskIdIterator = taskIds.iterator();
|
||||||
while (taskIdIterator.hasNext()) {
|
while (taskIdIterator.hasNext()) {
|
||||||
|
|
|
@ -12,6 +12,8 @@ import static org.junit.Assert.fail;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -251,4 +253,32 @@ public class TransferTaskAccTest extends AbstractAccTest {
|
||||||
assertEquals("TEAMLEAD_1", transferredTask.getWorkbasketKey());
|
assertEquals("TEAMLEAD_1", transferredTask.getWorkbasketKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@WithAccessId(
|
||||||
|
userName = "teamlead_1",
|
||||||
|
groupNames = {"group_1"})
|
||||||
|
@Test
|
||||||
|
public void testTransferTasksWithListNotSupportingRemove()
|
||||||
|
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||||
|
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||||
|
InvalidStateException, InvalidOwnerException {
|
||||||
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
List<String> taskIds = Collections.singletonList("");
|
||||||
|
taskService.transferTasks("WBI:100000000000000000000000000000000006", taskIds);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@WithAccessId(
|
||||||
|
userName = "teamlead_1",
|
||||||
|
groupNames = {"group_1"})
|
||||||
|
@Test(expected = InvalidArgumentException.class)
|
||||||
|
public void testThrowsExceptionIfEmptyListIsSupplied()
|
||||||
|
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
|
||||||
|
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
|
||||||
|
InvalidStateException, InvalidOwnerException {
|
||||||
|
TaskService taskService = taskanaEngine.getTaskService();
|
||||||
|
List<String> taskIds = new ArrayList<>();
|
||||||
|
taskService.transferTasks("WBI:100000000000000000000000000000000006", taskIds);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue