Rebase with master and fix minors errors

This commit is contained in:
Jose Ignacio Recuerda Cambil 2018-10-09 17:39:14 +02:00 committed by Holger Hagen
parent 279589a5df
commit d886aaf00e
10 changed files with 88 additions and 114 deletions

View File

@ -485,10 +485,10 @@ public interface WorkbasketQuery extends BaseQuery<WorkbasketSummary> {
/** /**
* Add to your query if the Workbasket shall be marked for deletion. * Add to your query if the Workbasket shall be marked for deletion.
* *
* @param deletionFlag * @param markedForDeletion
* a simple flag showing if deletion flag is activated * a simple flag showing if the workbasket is marked for deletion
* @return the query * @return the query
*/ */
WorkbasketQuery deletionFlagEquals(Boolean deletionFlag); WorkbasketQuery markedForDeletion(boolean markedForDeletion);
} }

View File

@ -67,7 +67,7 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
private String[] orgLevel3Like; private String[] orgLevel3Like;
private String[] orgLevel4In; private String[] orgLevel4In;
private String[] orgLevel4Like; private String[] orgLevel4Like;
private boolean isDeletionFlagActivated; private boolean markedForDeletion;
private TaskanaEngineImpl taskanaEngine; private TaskanaEngineImpl taskanaEngine;
private List<String> orderBy; private List<String> orderBy;
@ -275,8 +275,8 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
} }
@Override @Override
public WorkbasketQuery deletionFlagEquals(Boolean deletionFlag) { public WorkbasketQuery markedForDeletion(boolean markedForDeletion) {
this.isDeletionFlagActivated = deletionFlag; this.markedForDeletion = markedForDeletion;
return this; return this;
} }
@ -404,7 +404,6 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
this.columnName = columnName; this.columnName = columnName;
handleCallerRolesAndAccessIds(); handleCallerRolesAndAccessIds();
this.orderBy.clear(); this.orderBy.clear();
//this.addOrderCriteria(columnName, sortDirection);
result = taskanaEngine.getSqlSession().selectList(LINK_TO_VALUEMAPPER, this); result = taskanaEngine.getSqlSession().selectList(LINK_TO_VALUEMAPPER, this);
return result; return result;
} finally { } finally {
@ -595,8 +594,8 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
return orgLevel4Like; return orgLevel4Like;
} }
public boolean isDeletionFlagActivated() { public boolean isMarkedForDeletion() {
return isDeletionFlagActivated; return markedForDeletion;
} }
public String[] getOwnerLike() { public String[] getOwnerLike() {
@ -700,8 +699,8 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
builder.append(Arrays.toString(orgLevel4In)); builder.append(Arrays.toString(orgLevel4In));
builder.append(", orgLevel4Like="); builder.append(", orgLevel4Like=");
builder.append(Arrays.toString(orgLevel4Like)); builder.append(Arrays.toString(orgLevel4Like));
builder.append(", deletionFlag="); builder.append(", markedForDeletion=");
builder.append(isDeletionFlagActivated); builder.append(markedForDeletion);
builder.append(", orderBy="); builder.append(", orderBy=");
builder.append(orderBy); builder.append(orderBy);
builder.append(", joinWithAccessList="); builder.append(", joinWithAccessList=");

View File

@ -727,6 +727,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
throws NotAuthorizedException, WorkbasketNotFoundException, WorkbasketInUseException, InvalidArgumentException { throws NotAuthorizedException, WorkbasketNotFoundException, WorkbasketInUseException, InvalidArgumentException {
LOGGER.debug("entry to deleteWorkbasket(workbasketId = {})", workbasketId); LOGGER.debug("entry to deleteWorkbasket(workbasketId = {})", workbasketId);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
if (workbasketId == null || workbasketId.isEmpty()) { if (workbasketId == null || workbasketId.isEmpty()) {
@ -736,25 +737,26 @@ public class WorkbasketServiceImpl implements WorkbasketService {
// check if the workbasket does exist and is empty (Task) // check if the workbasket does exist and is empty (Task)
this.getWorkbasket(workbasketId); this.getWorkbasket(workbasketId);
long numTasksInWorkbasket = taskanaEngine.getTaskService() long numTasksNotCompletedInWorkbasket = taskanaEngine.getTaskService()
.createTaskQuery() .createTaskQuery()
.workbasketIdIn(workbasketId) .workbasketIdIn(workbasketId)
.stateNotIn( .stateNotIn(
TaskState.COMPLETED) TaskState.COMPLETED)
.count(); .count();
if (numTasksInWorkbasket > 0) { if (numTasksNotCompletedInWorkbasket > 0) {
throw new WorkbasketInUseException( throw new WorkbasketInUseException(
"Workbasket " + workbasketId + " contains non-completed tasks and can´t be marked for deletion."); "Workbasket " + workbasketId + " contains non-completed tasks and can´t be marked for deletion.");
} }
numTasksInWorkbasket = taskanaEngine.getTaskService() long numTasksInWorkbasket = taskanaEngine.getTaskService()
.createTaskQuery() .createTaskQuery()
.workbasketIdIn(workbasketId) .workbasketIdIn(workbasketId)
.count(); .count();
if (numTasksInWorkbasket == 0) { if (numTasksInWorkbasket == 0) {
workbasketMapper.delete(workbasketId); workbasketMapper.delete(workbasketId);
deleteReferencesToWorkbasket(workbasketId);
return true; return true;
} else { } else {
markWorkbasketForDeletion(workbasketId); markWorkbasketForDeletion(workbasketId);
@ -780,22 +782,14 @@ public class WorkbasketServiceImpl implements WorkbasketService {
WorkbasketImpl workbasket = workbasketMapper.findById(workbasketId); WorkbasketImpl workbasket = workbasketMapper.findById(workbasketId);
workbasket.setMarkedForDeletion(true); workbasket.setMarkedForDeletion(true);
workbasketMapper.update(workbasket); workbasketMapper.update(workbasket);
deleteWorkbasketTablesReferences(workbasketId);
} finally { } finally {
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from markWorkbasketForDeletion(workbasketId = {}).", workbasketId); LOGGER.debug("exit from markWorkbasketForDeletion(workbasketId = {}).", workbasketId);
} }
} }
private void deleteWorkbasketTablesReferences(String workbasketId) {
// delete workbasket and sub-tables
distributionTargetMapper.deleteAllDistributionTargetsBySourceId(workbasketId);
distributionTargetMapper.deleteAllDistributionTargetsByTargetId(workbasketId);
workbasketAccessMapper.deleteAllAccessItemsForWorkbasketId(workbasketId);
}
public BulkOperationResults<String, TaskanaException> deleteWorkbaskets(List<String> workbasketsIds) public BulkOperationResults<String, TaskanaException> deleteWorkbaskets(List<String> workbasketsIds)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketInUseException, WorkbasketNotFoundException { throws NotAuthorizedException, InvalidArgumentException {
LOGGER.debug("entry to deleteWorkbaskets(workbasketId = {})", LoggerUtils.listToString(workbasketsIds)); LOGGER.debug("entry to deleteWorkbaskets(workbasketId = {})", LoggerUtils.listToString(workbasketsIds));
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
@ -805,16 +799,23 @@ public class WorkbasketServiceImpl implements WorkbasketService {
if (workbasketsIds == null || workbasketsIds.isEmpty()) { if (workbasketsIds == null || workbasketsIds.isEmpty()) {
throw new InvalidArgumentException("List of WorkbasketIds must not be null."); throw new InvalidArgumentException("List of WorkbasketIds must not be null.");
} }
BulkOperationResults<String, TaskanaException> bulkLog = new BulkOperationResults<>();
List<String> existingWorkbasketIds = workbasketMapper.findExistingWorkbaskets(workbasketsIds); if (!workbasketsIds.isEmpty()) {
BulkOperationResults<String, TaskanaException> bulkLog = cleanNonExistingWorkbasketExists( Iterator<String> iterator = workbasketsIds.iterator();
existingWorkbasketIds, String workbasketIdForDeleting = null;
workbasketsIds);
if (!existingWorkbasketIds.isEmpty()) {
Iterator<String> iterator = existingWorkbasketIds.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
deleteWorkbasket(iterator.next()); try {
workbasketIdForDeleting = iterator.next();
deleteWorkbasket(workbasketIdForDeleting);
} catch (WorkbasketInUseException ex) {
bulkLog.addError(workbasketIdForDeleting, new WorkbasketInUseException(
"Workbasket with id " + workbasketIdForDeleting + " is in use and will not be deleted."));
} catch (TaskanaException ex) {
bulkLog.addError(workbasketIdForDeleting, new TaskanaException(
"Workbasket with id " + workbasketIdForDeleting
+ " Throw an exception and couldn't be deleted."));
}
} }
} }
return bulkLog; return bulkLog;
@ -830,30 +831,11 @@ public class WorkbasketServiceImpl implements WorkbasketService {
return new WorkbasketAccessItemQueryImpl(this.taskanaEngine); return new WorkbasketAccessItemQueryImpl(this.taskanaEngine);
} }
private BulkOperationResults<String, TaskanaException> cleanNonExistingWorkbasketExists( private void deleteReferencesToWorkbasket(String workbasketId) {
List<String> existingWorkbasketIds, // deletes sub-tables workbasket references
List<String> workbasketIds) { distributionTargetMapper.deleteAllDistributionTargetsBySourceId(workbasketId);
BulkOperationResults<String, TaskanaException> bulkLog = new BulkOperationResults<>(); distributionTargetMapper.deleteAllDistributionTargetsByTargetId(workbasketId);
Iterator<String> workbasketIdIterator = existingWorkbasketIds.iterator(); workbasketAccessMapper.deleteAllAccessItemsForWorkbasketId(workbasketId);
while (workbasketIdIterator.hasNext()) {
String currentWorkbasketId = workbasketIdIterator.next();
if (currentWorkbasketId == null || currentWorkbasketId.equals("")) {
bulkLog.addError("",
new InvalidArgumentException("IDs with EMPTY or NULL value are not allowed."));
workbasketIdIterator.remove();
} else {
String foundSummary = workbasketIds.stream()
.filter(workbasketId -> currentWorkbasketId.equals(workbasketId))
.findFirst()
.orElse(null);
if (foundSummary == null) {
bulkLog.addError(currentWorkbasketId, new WorkbasketNotFoundException(currentWorkbasketId,
"Workbasket with id " + currentWorkbasketId + " was not found."));
workbasketIdIterator.remove();
}
}
}
return bulkLog;
} }
} }

View File

@ -2,8 +2,6 @@ package pro.taskana.jobs;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -11,14 +9,12 @@ import org.slf4j.LoggerFactory;
import pro.taskana.BaseQuery; import pro.taskana.BaseQuery;
import pro.taskana.BulkOperationResults; import pro.taskana.BulkOperationResults;
import pro.taskana.TaskService;
import pro.taskana.TaskanaEngine; import pro.taskana.TaskanaEngine;
import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskanaException; import pro.taskana.exceptions.TaskanaException;
import pro.taskana.exceptions.WorkbasketInUseException; import pro.taskana.exceptions.WorkbasketInUseException;
import pro.taskana.exceptions.WorkbasketNotFoundException; import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.transaction.TaskanaTransactionProvider; import pro.taskana.transaction.TaskanaTransactionProvider;
/** /**
@ -64,38 +60,15 @@ public class WorkbasketCleanupJob extends AbstractTaskanaJob {
} }
} }
private List<String> getWorkbasketsMarkedForDeletion() throws InvalidArgumentException { private List<String> getWorkbasketsMarkedForDeletion() {
List<String> workbasketList = taskanaEngineImpl.getWorkbasketService() List<String> workbasketList = taskanaEngineImpl.getWorkbasketService()
.createWorkbasketQuery() .createWorkbasketQuery()
.deletionFlagEquals(true) .markedForDeletion(true)
.listValues("ID", BaseQuery.SortDirection.ASCENDING); .listValues("ID", BaseQuery.SortDirection.ASCENDING);
workbasketList = excludeWorkbasketWithPendingTasks(workbasketList);
return workbasketList; return workbasketList;
} }
private List<String> excludeWorkbasketWithPendingTasks(List<String> workbasketList)
throws InvalidArgumentException {
TaskService taskService = taskanaEngineImpl.getTaskService();
ArrayList<String> workbasketDeletionList = new ArrayList<>();
ArrayList<String> workbasketWithNonCompletedTasksList = new ArrayList<>();
if (!workbasketList.isEmpty()) {
Iterator<String> iterator = workbasketList.iterator();
while (iterator.hasNext()) {
String workbasketId = iterator.next();
if (taskService.allTasksCompletedByWorkbasketId(workbasketId)) {
workbasketDeletionList.add(workbasketId);
} else {
workbasketWithNonCompletedTasksList.add(workbasketId);
}
}
}
LOGGER.info("workbasket marked for deletion with non completed tasks {}.",
LoggerUtils.listToString(workbasketWithNonCompletedTasksList));
return workbasketDeletionList;
}
private int deleteWorkbasketsTransactionally(List<String> workbasketsToBeDeleted) { private int deleteWorkbasketsTransactionally(List<String> workbasketsToBeDeleted) {
int deletedWorkbasketsCount = 0; int deletedWorkbasketsCount = 0;
if (txProvider != null) { if (txProvider != null) {

View File

@ -1167,7 +1167,7 @@ public interface QueryMapper {
+ "<if test='orgLevel3Like != null'>AND (<foreach item='item' collection='orgLevel3Like' separator=' OR ' >UPPER(w.ORG_LEVEL_3) LIKE #{item}</foreach>)</if> " + "<if test='orgLevel3Like != null'>AND (<foreach item='item' collection='orgLevel3Like' separator=' OR ' >UPPER(w.ORG_LEVEL_3) LIKE #{item}</foreach>)</if> "
+ "<if test='orgLevel4In != null'>AND w.ORG_LEVEL_4 IN(<foreach item='item' collection='orgLevel4In' separator=',' >#{item}</foreach>)</if> " + "<if test='orgLevel4In != null'>AND w.ORG_LEVEL_4 IN(<foreach item='item' collection='orgLevel4In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='orgLevel4Like != null'>AND (<foreach item='item' collection='orgLevel4Like' separator=' OR ' >UPPER(w.ORG_LEVEL_4) LIKE #{item}</foreach>)</if> " + "<if test='orgLevel4Like != null'>AND (<foreach item='item' collection='orgLevel4Like' separator=' OR ' >UPPER(w.ORG_LEVEL_4) LIKE #{item}</foreach>)</if> "
+ "<if test='isDeletionFlagActivated != null'>AND w.DELETION_FLAG = #{isDeletionFlagActivated}</if> " + "<if test='markedForDeletion != null'>AND w.MARKED_FOR_DELETION = #{markedForDeletion}</if> "
+ "<if test = 'joinWithAccessList'> " + "<if test = 'joinWithAccessList'> "
+ "<if test = 'checkReadPermission'> " + "<if test = 'checkReadPermission'> "
+ "AND (a.MAX_READ = 1 " + "AND (a.MAX_READ = 1 "

View File

@ -231,10 +231,4 @@ public interface TaskMapper {
@Result(property = "taskId", column = "ID")}) @Result(property = "taskId", column = "ID")})
List<String> filterTaskIdsForNotCompleted(@Param("taskIds") List<String> taskIds); List<String> filterTaskIdsForNotCompleted(@Param("taskIds") List<String> taskIds);
@Select("<script>SELECT COUNT(ID) FROM TASK WHERE "
+ "WORKBASKET_ID = #{workbasketId} "
+ "<if test=\"_databaseId == 'db2'\">with UR </if> "
+ "</script>")
Long countTasksInWorkbasket(@Param("workbasketId") String workbasketId);
} }

View File

@ -152,12 +152,6 @@ public interface WorkbasketMapper {
@Result(property = "orgLevel4", column = "ORG_LEVEL_4")}) @Result(property = "orgLevel4", column = "ORG_LEVEL_4")})
List<WorkbasketSummaryImpl> findAll(); List<WorkbasketSummaryImpl> findAll();
@Select("<script>SELECT ID FROM WORKBASKET "
+ "WHERE ID IN( <foreach item='item' collection='workbasketIds' separator=',' >#{item}</foreach> ) "
+ "<if test=\"_databaseId == 'db2'\">with UR </if> "
+ "</script>")
List<String> findExistingWorkbaskets(@Param("workbasketIds") List<String> workbasketIds);
@Insert("<script>INSERT INTO WORKBASKET (ID, KEY, CREATED, MODIFIED, NAME, DOMAIN, TYPE, DESCRIPTION, OWNER, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, ORG_LEVEL_1, ORG_LEVEL_2, ORG_LEVEL_3, ORG_LEVEL_4, MARKED_FOR_DELETION) VALUES (#{workbasket.id}, #{workbasket.key}, #{workbasket.created}, #{workbasket.modified}, #{workbasket.name}, #{workbasket.domain}, #{workbasket.type}, #{workbasket.description}, #{workbasket.owner}, #{workbasket.custom1}, #{workbasket.custom2}, #{workbasket.custom3}, #{workbasket.custom4}, #{workbasket.orgLevel1}, #{workbasket.orgLevel2}, #{workbasket.orgLevel3}, #{workbasket.orgLevel4}, #{workbasket.markedForDeletion}) " @Insert("<script>INSERT INTO WORKBASKET (ID, KEY, CREATED, MODIFIED, NAME, DOMAIN, TYPE, DESCRIPTION, OWNER, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, ORG_LEVEL_1, ORG_LEVEL_2, ORG_LEVEL_3, ORG_LEVEL_4, MARKED_FOR_DELETION) VALUES (#{workbasket.id}, #{workbasket.key}, #{workbasket.created}, #{workbasket.modified}, #{workbasket.name}, #{workbasket.domain}, #{workbasket.type}, #{workbasket.description}, #{workbasket.owner}, #{workbasket.custom1}, #{workbasket.custom2}, #{workbasket.custom3}, #{workbasket.custom4}, #{workbasket.orgLevel1}, #{workbasket.orgLevel2}, #{workbasket.orgLevel3}, #{workbasket.orgLevel4}, #{workbasket.markedForDeletion}) "
+ "</script>") + "</script>")
@Options(keyProperty = "id", keyColumn = "ID") @Options(keyProperty = "id", keyColumn = "ID")

View File

@ -1,6 +1,9 @@
package acceptance.jobs; package acceptance.jobs;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import java.util.List;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
@ -10,14 +13,15 @@ import org.junit.runner.RunWith;
import acceptance.AbstractAccTest; import acceptance.AbstractAccTest;
import pro.taskana.BaseQuery; import pro.taskana.BaseQuery;
import pro.taskana.TaskService; import pro.taskana.TaskService;
import pro.taskana.TaskState;
import pro.taskana.WorkbasketService; import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary; import pro.taskana.WorkbasketSummary;
import pro.taskana.exceptions.TaskanaException;
import pro.taskana.jobs.TaskCleanupJob;
import pro.taskana.jobs.WorkbasketCleanupJob; import pro.taskana.jobs.WorkbasketCleanupJob;
import pro.taskana.security.JAASRunner; import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId; import pro.taskana.security.WithAccessId;
import java.util.List;
/** /**
* Acceptance test for all "jobs workbasket runner" scenarios. * Acceptance test for all "jobs workbasket runner" scenarios.
*/ */
@ -40,19 +44,29 @@ public class WorkbasketCleanupJobAccTest extends AbstractAccTest {
@WithAccessId(userName = "admin") @WithAccessId(userName = "admin")
@Test @Test
public void shouldCleanWorkbasketMarkedForDeletion() throws Exception { public void shouldCleanWorkbasketMarkedForDeletionWithoutTasks() throws TaskanaException {
long totalWorkbasketCount = workbasketService.createWorkbasketQuery().count(); long totalWorkbasketCount = workbasketService.createWorkbasketQuery().count();
assertEquals(25, totalWorkbasketCount); assertEquals(25, totalWorkbasketCount);
List<WorkbasketSummary> workbaskets = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> workbaskets = workbasketService.createWorkbasketQuery()
.keyIn("GPK_KSC", "sort001") .keyIn("TEAMLEAD_1")
.orderByKey( .orderByKey(
BaseQuery.SortDirection.ASCENDING) BaseQuery.SortDirection.ASCENDING)
.list(); .list();
assertEquals(taskService.allTasksCompletedByWorkbasketId(workbaskets.get(1).getId()), true);
workbasketService.markWorkbasketForDeletion(workbaskets.get(1).getId());
WorkbasketCleanupJob job = new WorkbasketCleanupJob(taskanaEngine, null, null); assertEquals(getNumberTaskNotCompleted(workbaskets.get(0).getId()), 0);
job.run(); assertEquals(getNumberTaskCompleted(workbaskets.get(0).getId()), 1);
// Workbasket with completed task will be marked for deletion.
workbasketService.deleteWorkbasket(workbaskets.get(0).getId());
// Run taskCleanupJob for deleting completing tasks before running workbasketCleanupJob
TaskCleanupJob taskCleanupJob = new TaskCleanupJob(taskanaEngine, null, null);
taskCleanupJob.run();
assertEquals(getNumberTaskCompleted(workbaskets.get(0).getId()), 0);
WorkbasketCleanupJob workbasketCleanupJob = new WorkbasketCleanupJob(taskanaEngine, null, null);
workbasketCleanupJob.run();
totalWorkbasketCount = workbasketService.createWorkbasketQuery().count(); totalWorkbasketCount = workbasketService.createWorkbasketQuery().count();
assertEquals(24, totalWorkbasketCount); assertEquals(24, totalWorkbasketCount);
@ -60,23 +74,42 @@ public class WorkbasketCleanupJobAccTest extends AbstractAccTest {
@WithAccessId(userName = "admin") @WithAccessId(userName = "admin")
@Test @Test
public void shouldCleanWorkbasketMarkedForDeletionWithCompletedTasks() throws Exception { public void shouldNotCleanWorkbasketMarkedForDeletionIfWorkbasketHasTasks() throws Exception {
long totalWorkbasketCount = workbasketService.createWorkbasketQuery().count(); long totalWorkbasketCount = workbasketService.createWorkbasketQuery().count();
assertEquals(25, totalWorkbasketCount); assertEquals(25, totalWorkbasketCount);
List<WorkbasketSummary> workbaskets = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> workbaskets = workbasketService.createWorkbasketQuery()
.keyIn("GPK_KSC", "sort001") .keyIn("TEAMLEAD_1")
.orderByKey( .orderByKey(
BaseQuery.SortDirection.ASCENDING) BaseQuery.SortDirection.ASCENDING)
.list(); .list();
assertEquals(taskService.allTasksCompletedByWorkbasketId(workbaskets.get(0).getId()), false);
assertEquals(taskService.allTasksCompletedByWorkbasketId(workbaskets.get(1).getId()), true); assertNotEquals(getNumberTaskCompleted(workbaskets.get(0).getId()), 0);
workbasketService.markWorkbasketForDeletion(workbaskets.get(0).getId());
workbasketService.markWorkbasketForDeletion(workbaskets.get(1).getId()); // Workbasket with completed task will be marked for deletion.
workbasketService.deleteWorkbasket(workbaskets.get(0).getId());
WorkbasketCleanupJob job = new WorkbasketCleanupJob(taskanaEngine, null, null); WorkbasketCleanupJob job = new WorkbasketCleanupJob(taskanaEngine, null, null);
job.run(); job.run();
totalWorkbasketCount = workbasketService.createWorkbasketQuery().count(); totalWorkbasketCount = workbasketService.createWorkbasketQuery().count();
assertEquals(24, totalWorkbasketCount); assertEquals(25, totalWorkbasketCount);
}
private long getNumberTaskNotCompleted(String workbasketId) {
return taskService
.createTaskQuery()
.workbasketIdIn(workbasketId)
.stateNotIn(
TaskState.COMPLETED)
.count();
}
private long getNumberTaskCompleted(String workbasketId) {
return taskService
.createTaskQuery()
.workbasketIdIn(workbasketId)
.stateIn(
TaskState.COMPLETED)
.count();
} }
} }

View File

@ -549,7 +549,6 @@ public class WorkbasketServiceImplTest {
verify(cutSpy, times(1)).getWorkbasket(wb.getId()); verify(cutSpy, times(1)).getWorkbasket(wb.getId());
verify(taskanaEngineImplMock, times(0)).getSqlSession(); verify(taskanaEngineImplMock, times(0)).getSqlSession();
verify(sqlSessionMock, times(0)).getMapper(TaskMapper.class); verify(sqlSessionMock, times(0)).getMapper(TaskMapper.class);
verify(taskMapperMock, times(0)).countTasksInWorkbasket(any());
verify(workbasketMapperMock, times(1)).findById(wb.getId()); verify(workbasketMapperMock, times(1)).findById(wb.getId());
verify(taskanaEngineImplMock, times(2)).returnConnection(); verify(taskanaEngineImplMock, times(2)).returnConnection();

View File

@ -73,5 +73,5 @@ INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000063', '2018-01-29
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000064', '2018-01-29 15:55:23', null , null , '2018-01-29 15:55:23', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'READY' , 'EXTERN' , 'L1060' , 'CLI:200000000000000000000000000000000017', 'WBI:100000000000000000000000000000000015' , 'USER_3_2' , 'DOMAIN_B', 'PI_0000000000020' , 'DOC_0000000000000000021' , null , '00' , 'PASystem' , '00' , 'SDNR' , '11223344' , false , false , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null ); INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000064', '2018-01-29 15:55:23', null , null , '2018-01-29 15:55:23', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'READY' , 'EXTERN' , 'L1060' , 'CLI:200000000000000000000000000000000017', 'WBI:100000000000000000000000000000000015' , 'USER_3_2' , 'DOMAIN_B', 'PI_0000000000020' , 'DOC_0000000000000000021' , null , '00' , 'PASystem' , '00' , 'SDNR' , '11223344' , false , false , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000065', '2018-01-29 15:55:24', null , null , '2018-01-29 15:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'READY' , 'EXTERN' , 'L1060' , 'CLI:200000000000000000000000000000000017', 'WBI:100000000000000000000000000000000015' , 'USER_3_2' , 'DOMAIN_B', 'PI_0000000000024' , 'DOC_0000000000000000024' , null , '00' , 'PASystem' , '00' , 'SDNR' , '11223344' , false , false , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null ); INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000065', '2018-01-29 15:55:24', null , null , '2018-01-29 15:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'READY' , 'EXTERN' , 'L1060' , 'CLI:200000000000000000000000000000000017', 'WBI:100000000000000000000000000000000015' , 'USER_3_2' , 'DOMAIN_B', 'PI_0000000000024' , 'DOC_0000000000000000024' , null , '00' , 'PASystem' , '00' , 'SDNR' , '11223344' , false , false , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
-- Task for TransferAccTest -- Task for TransferAccTest
INSERT INTO TASK VALUES('TKI:100000000000000000000000000000000006', '2018-01-29 15:55:06', '2018-01-30 15:55:06', '2018-01-30 16:55:06', '2018-01-30 16:55:06', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000004' , 'TEAMLEAD_1' , 'DOMAIN_A', 'PI_0000000000006' , 'DOC_0000000000000000006' , null , '00' , 'PASystem' , '00' , 'VNR' , '11223344' , false , false , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null ); INSERT INTO TASK VALUES('TKI:100000000000000000000000000000000006', '2018-01-29 15:55:06', '2018-01-30 15:55:06', '2018-01-30 16:55:06', '2018-01-30 16:55:06', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000004' , 'TEAMLEAD_1' , 'DOMAIN_A', 'PI_0000000000041' , 'DOC_0000000000000000041' , null , '00' , 'PASystem' , '00' , 'VNR' , '11223344' , false , false , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );
INSERT INTO TASK VALUES('TKI:200000000000000000000000000000000006', '2018-03-29 15:55:06', '2018-03-30 15:55:06', null , '2018-03-30 15:55:06', '2018-03-29 15:55:00', '2018-03-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000005' , 'TEAMLEAD_2' , 'DOMAIN_A', 'PI_0000000000006' , 'DOC_0000000000000000006' , null , '00' , 'PASystem' , '00' , 'SDNR' , '98765432' , false , false , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null ); INSERT INTO TASK VALUES('TKI:200000000000000000000000000000000006', '2018-03-29 15:55:06', '2018-03-30 15:55:06', null , '2018-03-30 15:55:06', '2018-03-29 15:55:00', '2018-03-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , 'COMPLETED' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000005' , 'TEAMLEAD_2' , 'DOMAIN_A', 'PI_0000000000006' , 'DOC_0000000000000000006' , null , '00' , 'PASystem' , '00' , 'SDNR' , '98765432' , false , false , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null , 'abc' , null , null );