TSK-90 Use task.workbasketKey as foreign key into workbasket and reject implicit creation of distribution targets
This commit is contained in:
parent
791025fde0
commit
193e3c3079
|
@ -263,7 +263,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
@Override
|
||||
public List<Task> getTasksByWorkbasketKeyAndState(String workbasketKey, TaskState taskState)
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
LOGGER.debug("entry to getTasksByWorkbasketKeyAndState(workbasketId = {}, taskState = {})", workbasketKey,
|
||||
LOGGER.debug("entry to getTasksByWorkbasketKeyAndState(workbasketKey = {}, taskState = {})", workbasketKey,
|
||||
taskState);
|
||||
List<Task> results = new ArrayList<>();
|
||||
try {
|
||||
|
|
|
@ -185,6 +185,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
public Workbasket updateWorkbasket(Workbasket workbasketToUpdate)
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
|
||||
LOGGER.debug("entry to updateWorkbasket(workbasket)", workbasketToUpdate);
|
||||
|
||||
Workbasket result = null;
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketToUpdate;
|
||||
try {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package pro.taskana.model;
|
||||
|
||||
/**
|
||||
* Entity which contains the most important
|
||||
* informations about a Task.
|
||||
* Entity which contains the most important informations about a Task.
|
||||
*/
|
||||
public class TaskSummary {
|
||||
|
||||
|
@ -16,12 +15,15 @@ public class TaskSummary {
|
|||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(String taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public String getTaskName() {
|
||||
return taskName;
|
||||
}
|
||||
|
||||
public void setTaskName(String taskName) {
|
||||
this.taskName = taskName;
|
||||
}
|
||||
|
@ -33,21 +35,27 @@ public class TaskSummary {
|
|||
public void setWorkbasketKey(String workbasketKey) {
|
||||
this.workbasketKey = workbasketKey;
|
||||
}
|
||||
|
||||
public String getWorkbasketName() {
|
||||
return workbasketName;
|
||||
}
|
||||
|
||||
public void setWorkbasketName(String workbasketName) {
|
||||
this.workbasketName = workbasketName;
|
||||
}
|
||||
|
||||
public String getClassificationKey() {
|
||||
return classificationKey;
|
||||
}
|
||||
|
||||
public void setClassificationKey(String classificationKey) {
|
||||
this.classificationKey = classificationKey;
|
||||
}
|
||||
|
||||
public String getClassificationName() {
|
||||
return classificationName;
|
||||
}
|
||||
|
||||
public void setClassificationName(String classificationName) {
|
||||
this.classificationName = classificationName;
|
||||
}
|
||||
|
@ -140,4 +148,5 @@ public class TaskSummary {
|
|||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ public class WorkbasketAccessItem {
|
|||
private boolean permCustom7;
|
||||
private boolean permCustom8;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@ import pro.taskana.impl.ObjectReferenceQueryImpl;
|
|||
import pro.taskana.impl.TaskImpl;
|
||||
import pro.taskana.impl.TaskQueryImpl;
|
||||
import pro.taskana.impl.WorkbasketImpl;
|
||||
import pro.taskana.model.ClassificationImpl;
|
||||
import pro.taskana.impl.WorkbasketQueryImpl;
|
||||
import pro.taskana.model.ClassificationImpl;
|
||||
import pro.taskana.model.ObjectReference;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package pro.taskana.model.mappings;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -18,6 +19,7 @@ import pro.taskana.Classification;
|
|||
import pro.taskana.impl.TaskImpl;
|
||||
import pro.taskana.impl.persistence.MapTypeHandler;
|
||||
import pro.taskana.model.ClassificationImpl;
|
||||
import pro.taskana.model.DueWorkbasketCounter;
|
||||
import pro.taskana.model.ObjectReference;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.TaskSummary;
|
||||
|
@ -71,6 +73,12 @@ public interface TaskMapper {
|
|||
})
|
||||
TaskImpl findById(@Param("id") String id);
|
||||
|
||||
@Results({@Result(column = "DUE_DATE", property = "due"),
|
||||
@Result(column = "WORKBASKET_KEY", property = "workbasketKey"),
|
||||
@Result(column = "counter", property = "taskCounter")})
|
||||
List<DueWorkbasketCounter> getTaskCountByWorkbasketIdAndDaysInPastAndState(@Param("fromDate") Date fromDate,
|
||||
@Param("status") List<TaskState> states);
|
||||
|
||||
@Insert("INSERT INTO TASK(ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, PRIORITY, STATE, CLASSIFICATION_KEY, WORKBASKET_KEY, BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, OWNER, PRIMARY_OBJ_REF_ID, IS_READ, IS_TRANSFERRED, CUSTOM_ATTRIBUTES, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10) "
|
||||
+ "VALUES(#{id}, #{created}, #{claimed}, #{completed}, #{modified}, #{planned}, #{due}, #{name}, #{description}, #{priority}, #{state}, #{classification.key}, #{workbasketKey}, #{businessProcessId}, #{parentBusinessProcessId}, #{owner}, #{primaryObjRef.id}, #{isRead}, #{isTransferred}, #{customAttributes,jdbcType=BLOB,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler}, #{custom1}, #{custom2}, #{custom3}, #{custom4}, #{custom5}, #{custom6}, #{custom7}, #{custom8}, #{custom9}, #{custom10})")
|
||||
@Options(keyProperty = "id", keyColumn = "ID")
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
package pro.taskana.model.mappings;
|
||||
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Options;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Result;
|
||||
import org.apache.ibatis.annotations.Results;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import pro.taskana.model.WorkbasketAccessItem;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* This class is the mybatis mapping of workbasket access items.
|
||||
*/
|
||||
|
|
|
@ -126,6 +126,7 @@ public class TaskServiceImplTest {
|
|||
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasketByKey(any());
|
||||
verify(taskanaEngineMock, times(1)).getClassificationService();
|
||||
|
||||
verify(classificationServiceMock, times(1)).getClassification(any(), any());
|
||||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
|
|
|
@ -139,7 +139,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
classification.setKey("TEST");
|
||||
taskanaEngine.getClassificationService().createClassification(classification);
|
||||
|
||||
Task task = taskServiceImpl.newTask();
|
||||
TaskImpl task = (TaskImpl) taskServiceImpl.newTask();
|
||||
task.setName("Unit Test Task");
|
||||
task.setWorkbasketKey(wb.getKey());
|
||||
task.setClassification(classification);
|
||||
|
@ -284,7 +284,10 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
wb.setName("wb");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
wb.setDomain("novatec");
|
||||
workbasketService.createWorkbasket(wb);
|
||||
taskServiceImpl.getTaskSummariesByWorkbasketKey("1");
|
||||
wb = (WorkbasketImpl) workbasketService.createWorkbasket(wb);
|
||||
workbasketService.createWorkbasket(wb);
|
||||
taskServiceImpl.getTaskSummariesByWorkbasketKey("1");
|
||||
}
|
||||
|
||||
|
|
|
@ -252,6 +252,13 @@ public class TaskServiceImplIntExplicitTest {
|
|||
wb.setKey("k1");
|
||||
workbasketService.createWorkbasket(wb);
|
||||
|
||||
Task test = taskServiceImpl.newTask();
|
||||
test.setWorkbasketKey("k1");
|
||||
test.setPrimaryObjRef(objectReference);
|
||||
test.setPlanned(tomorrow);
|
||||
test.setClassification(classification);
|
||||
test = taskServiceImpl.createTask(test);
|
||||
|
||||
Task task = this.generateDummyTask();
|
||||
task.setClassification(classification);
|
||||
task.setName("Name");
|
||||
|
|
|
@ -384,14 +384,11 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
throws NotAuthorizedException, InvalidWorkbasketException, WorkbasketNotFoundException {
|
||||
generateSampleDataForQuery();
|
||||
|
||||
String userName = "eberhardt";
|
||||
String userName = "Bernd";
|
||||
String[] groupNames = {"group2", "group3"};
|
||||
List<WorkbasketAuthorization> authorizations = new ArrayList<WorkbasketAuthorization>();
|
||||
|
||||
authorizations.add(WorkbasketAuthorization.OPEN);
|
||||
Assert.assertTrue(1 == getWorkbasketsForPrincipalesAndPermissions(userName, groupNames, authorizations));
|
||||
|
||||
userName = "Bernd";
|
||||
Assert.assertTrue(2 == getWorkbasketsForPrincipalesAndPermissions(userName, groupNames, authorizations));
|
||||
|
||||
authorizations.add(WorkbasketAuthorization.CUSTOM_4);
|
||||
|
|
|
@ -196,10 +196,10 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
workbasket1.setName("Megabasket");
|
||||
workbasket1.setDomain("D2");
|
||||
workbasket1.setType(WorkbasketType.GROUP);
|
||||
workBasketService.createWorkbasket(workbasket1);
|
||||
WorkbasketImpl workbasket2 = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
workbasket1.setType(WorkbasketType.GROUP);
|
||||
workbasket1.setDomain("novatec");
|
||||
workBasketService.createWorkbasket(workbasket1);
|
||||
WorkbasketImpl workbasket2 = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
String id2 = IdGenerator.generateWithPrefix("TWB");
|
||||
workbasket2.setId(id2);
|
||||
workbasket2.setKey("key2");
|
||||
|
@ -228,8 +228,8 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
workbasket0.setName("Superbasket");
|
||||
workbasket0.setType(WorkbasketType.GROUP);
|
||||
workbasket0.setDomain("novatec");
|
||||
|
||||
workBasketService.createWorkbasket(workbasket0);
|
||||
|
||||
WorkbasketImpl workbasket1 = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
workbasket0.setType(WorkbasketType.GROUP);
|
||||
workbasket0.setDomain("novatec");
|
||||
|
@ -256,7 +256,7 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
workbasket3.setName("hm ... irgend ein basket");
|
||||
workbasket3.setType(WorkbasketType.GROUP);
|
||||
workbasket3.setDomain("novatec");
|
||||
workbasket3 = workBasketService.createWorkbasket(workbasket3);
|
||||
workBasketService.createWorkbasket(workbasket3);
|
||||
workbasket2.getDistributionTargets().clear();
|
||||
workbasket2.getDistributionTargets().add(workbasket3);
|
||||
Thread.sleep(SLEEP_TIME);
|
||||
|
|
|
@ -30,4 +30,5 @@ public class TaskanaComponent {
|
|||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -127,10 +127,10 @@ public class TaskController {
|
|||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/{taskId}/transfer/{workbasketId}")
|
||||
public ResponseEntity<Task> transferTask(@PathVariable String taskId, @PathVariable String workbasketId) {
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/{taskId}/transfer/{workbasketKey}")
|
||||
public ResponseEntity<Task> transferTask(@PathVariable String taskId, @PathVariable String workbasketKey) {
|
||||
try {
|
||||
Task updatedTask = taskService.transfer(taskId, workbasketId);
|
||||
Task updatedTask = taskService.transfer(taskId, workbasketKey);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(updatedTask);
|
||||
} catch (Exception e) {
|
||||
logger.error("Something went wrong: ", e);
|
||||
|
|
|
@ -103,10 +103,10 @@ public class WorkbasketController {
|
|||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{workbasketid}/authorizations", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/{workbasketkey}/authorizations", method = RequestMethod.GET)
|
||||
public List<WorkbasketAccessItem> getWorkbasketAuthorizations(
|
||||
@PathVariable(value = "workbasketid") String workbasketId) {
|
||||
return workbasketService.getWorkbasketAuthorizations(workbasketId);
|
||||
@PathVariable(value = "workbasketkey") String workbasketKey) {
|
||||
return workbasketService.getWorkbasketAuthorizations(workbasketKey);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/authorizations", method = RequestMethod.POST)
|
||||
|
|
|
@ -118,7 +118,6 @@ public class TaskFilter {
|
|||
}
|
||||
if (params.containsKey(WORKBASKET_KEY)) {
|
||||
String[] workbaskets = extractCommaSeperatedFields(params.get(WORKBASKET_KEY));
|
||||
taskQuery.workbasketKeyIn(workbaskets);
|
||||
}
|
||||
if (params.containsKey(OWNER)) {
|
||||
String[] owners = extractCommaSeperatedFields(params.get(OWNER));
|
||||
|
|
|
@ -12,5 +12,7 @@ INSERT INTO TASK VALUES('10', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURREN
|
|||
INSERT INTO TASK VALUES('11', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, 'Task11', 'Lorem ipsum dolor sit amet. ', 1, 'COMPLETED', '3', 'key2', 'BPI11', 'PBPI11', 'Stefan', '2', false, false, null, null, null, null, null, null, null, null, null, null, null);
|
||||
INSERT INTO TASK VALUES('12', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, 'Task12', 'Lorem ipsum dolor sit amet.', 1, 'COMPLETED', '4', 'key2', 'BPI12', 'PBPI12', 'Frank', '3', false, false, null, null, null, null, null, null, null, null, null, null, null);
|
||||
|
||||
|
||||
INSERT INTO TASK VALUES('13', CURRENT_TIMESTAMP, null, null, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, 'Task12', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus massa turpis, pellentesque ut libero sit aet, malesuada suscipit dolor. Sed volutpat euismod felis sit amet molestie. Fusce ornare purus dui. ', 1, 'READY', '13', 'key2', 'BPI13', 'PBPI13', 'Frank', '1', false, false, null, null, null, null, null, null, null, null, null, null, null);
|
||||
INSERT INTO TASK VALUES('14', CURRENT_TIMESTAMP, null, null, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, 'Task6', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sagittis vulputate nibh ut malesuada. Etiam ac dictum tellus, nec cursus nunc. Curabitur velit eros, feugiat volutpat laoreet vitae, cursus eu dui. Nulla ut purus sem. Vivamus aliquet odio vitae erat cursus, vitae mattis urna mollis. Nam quam tellus, auctor id volutpat congue, viverra vitae ante. Duis nisi dolor, elementum et mattis at, maximus id velit. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis eu condimentum risus. Praesent libero velit, facilisis sit amet maximus non, scelerisque ullamcorper leo. Ut sit amet iaculis eros. Mauris sagittis nibh lacus, at facilisis magna suscipit at. Aliquam finibus tempor odio id commodo. Vivamus aliquam, justo id porta imperdiet, mi.', 1, 'READY', '14', 'key1', 'BPI14', 'PBPI14', 'Frank', '2', false, false, null, null, null, null, null, null, null, null, null, null, null);
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('1', 'key1', 'Elena', true, true, true, true, true, false, false, false, false, false, false, false, false);
|
||||
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('2', 'key2', 'Max', true, true, true, true, true, true, true, true, true, false, false, false, false);
|
||||
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('3', 'key3', 'Simone', true, true, true, true, true, true, true, true, true, true, true, true, true);
|
||||
|
||||
|
|
Loading…
Reference in New Issue