TSK-680 - Mark workbasket for deletion

This commit is contained in:
Jose Ignacio Recuerda Cambil 2018-09-06 16:56:37 +02:00 committed by Holger Hagen
parent eab4d54acd
commit f74a70e0d5
52 changed files with 747 additions and 457 deletions

View File

@ -219,7 +219,8 @@ public interface TaskService {
* @throws NotAuthorizedException
* if the current user has no read permission for the workbasket the task is in
*/
Task setTaskRead(String taskId, boolean isRead) throws TaskNotFoundException, NotAuthorizedException;
Task setTaskRead(String taskId, boolean isRead)
throws TaskNotFoundException, NotAuthorizedException;
/**
* This method provides a query builder for quering the database.
@ -330,7 +331,8 @@ public interface TaskService {
* @throws NotAuthorizedException
* if the current user is not member of role ADMIN
*/
void deleteTask(String taskId) throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
void deleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
/**
* Deletes the task with the given Id even if it is not completed.

View File

@ -222,6 +222,21 @@ public interface Workbasket {
*/
void setOrgLevel4(String orgLevel4);
/**
* Return the value for the markedForDeletion attribute.
*
* @return markedForDeletion
*/
boolean isMarkedForDeletion();
/**
* Sets the value for markedForDeletion attribute.
*
* @param markedForDeletion
* the markedForDeletion property of the workbasket
*/
void setMarkedForDeletion(boolean markedForDeletion);
/**
* Return a summary of the current workbasket.
*

View File

@ -326,6 +326,7 @@ public interface WorkbasketService {
*
* @param workbasketId
* Id of the workbasket which should be deleted.
* @return true if the workbasket is marked for deletion. False in another case.
* @throws NotAuthorizedException
* if the current user got no permissions for this interaction.
* @throws WorkbasketNotFoundException
@ -335,7 +336,7 @@ public interface WorkbasketService {
* @throws InvalidArgumentException
* if the workbasketId is NULL or EMPTY
*/
void deleteWorkbasket(String workbasketId)
boolean deleteWorkbasket(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException, WorkbasketInUseException, InvalidArgumentException;
/**

View File

@ -111,4 +111,11 @@ public interface WorkbasketSummary {
*/
String getOrgLevel4();
/**
* Gets the markedForDeletion property of the workbasket.
*
* @return the workbasket's markedForDeletion property
*/
boolean isMarkedForDeletion();
}

View File

@ -56,7 +56,7 @@ public class TaskanaEngineConfiguration {
private static final String TASKANA_DOMAINS_PROPERTY = "taskana.domains";
private static final String TASKANA_CLASSIFICATION_TYPES_PROPERTY = "taskana.classification.types";
private static final String TASKANA_CLASSIFICATION_CATEGORIES_PROPERTY = "taskana.classification.categories";
protected static final String TASKANA_SCHEMA_VERSION = "1.0.2"; // must match the VERSION value in table
protected static final String TASKANA_SCHEMA_VERSION = "1.0.4"; // must match the VERSION value in table
// TASKANA_SCHEMA_VERSION
private static final String DEFAULT_SCHEMA_NAME = "TASKANA";
@ -204,13 +204,17 @@ public class TaskanaEngineConfiguration {
}
}
String taskCleanupJobAllCompletedSameParentBusinessProperty = props.getProperty(TASKANA_JOB_TASK_CLEANUP_ALL_COMPLETED_SAME_PARENTE_BUSINESS);
if (taskCleanupJobAllCompletedSameParentBusinessProperty != null && !taskCleanupJobAllCompletedSameParentBusinessProperty.isEmpty()) {
String taskCleanupJobAllCompletedSameParentBusinessProperty = props.getProperty(
TASKANA_JOB_TASK_CLEANUP_ALL_COMPLETED_SAME_PARENTE_BUSINESS);
if (taskCleanupJobAllCompletedSameParentBusinessProperty != null
&& !taskCleanupJobAllCompletedSameParentBusinessProperty.isEmpty()) {
try {
taskCleanupJobAllCompletedSameParentBusiness = Boolean.parseBoolean(taskCleanupJobAllCompletedSameParentBusinessProperty);
taskCleanupJobAllCompletedSameParentBusiness = Boolean.parseBoolean(
taskCleanupJobAllCompletedSameParentBusinessProperty);
} catch (Exception e) {
LOGGER.warn("Could not parse taskCleanupJobAllCompletedSameParentBusinessProperty ({}). Using default. Exception: {} ",
taskCleanupJobAllCompletedSameParentBusinessProperty, e.getMessage());
LOGGER.warn(
"Could not parse taskCleanupJobAllCompletedSameParentBusinessProperty ({}). Using default. Exception: {} ",
taskCleanupJobAllCompletedSameParentBusinessProperty, e.getMessage());
}
}
@ -219,9 +223,9 @@ public class TaskanaEngineConfiguration {
LOGGER.debug("TaskCleanupJob configuration: first run at {}", taskCleanupJobFirstRun);
LOGGER.debug("TaskCleanupJob configuration: runs every {}", taskCleanupJobRunEvery);
LOGGER.debug("TaskCleanupJob configuration: minimum age of tasks to be cleanup up is {}",
taskCleanupJobMinimumAge);
taskCleanupJobMinimumAge);
LOGGER.debug("TaskCleanupJob configuration: all completed task with the same parent business property id {}",
taskCleanupJobAllCompletedSameParentBusiness);
taskCleanupJobAllCompletedSameParentBusiness);
}
private void initDomains(Properties props) {
@ -253,7 +257,8 @@ public class TaskanaEngineConfiguration {
List<String> classificationCategoriesAux;
for (String type : classificationTypes) {
classificationCategoriesAux = new ArrayList<>();
classificationCategoryNames = props.getProperty(TASKANA_CLASSIFICATION_CATEGORIES_PROPERTY + "." + type.toLowerCase());
classificationCategoryNames = props.getProperty(
TASKANA_CLASSIFICATION_CATEGORIES_PROPERTY + "." + type.toLowerCase());
if (classificationCategoryNames != null && !classificationCategoryNames.isEmpty()) {
st = new StringTokenizer(classificationCategoryNames, ",");
while (st.hasMoreTokens()) {
@ -465,6 +470,7 @@ public class TaskanaEngineConfiguration {
public List<String> getClassificationCategoriesByType(String type) {
return classificationCategoriesByTypeMap.get(type);
}
public void setClassificationCategoriesByType(Map<String, List<String>> classificationCategoriesByType) {
this.classificationCategoriesByTypeMap = classificationCategoriesByType;
}

View File

@ -2,6 +2,7 @@ package pro.taskana.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.apache.ibatis.exceptions.PersistenceException;
@ -420,7 +421,7 @@ public class TaskQueryImpl implements TaskQuery {
@Override
public TaskQuery stateNotIn(TaskState... states) {
// No benefit in introducing a new variable
List<TaskState> stateIn = Arrays.asList(TaskState.values());
List<TaskState> stateIn = new LinkedList<TaskState>(Arrays.asList(TaskState.values()));
for (TaskState state : states) {
stateIn.remove(state);
}

View File

@ -315,7 +315,13 @@ public class TaskServiceImpl implements TaskService {
throw new InvalidArgumentException("Cannot create a task outside a workbasket");
}
task.setWorkbasketSummary(workbasket.asSummary());
if (!workbasket.isMarkedForDeletion()) {
task.setWorkbasketSummary(workbasket.asSummary());
} else {
throw new WorkbasketNotFoundException(workbasket.getId(),
"The workbasket " + workbasket.getId() + " was marked for deletion");
}
task.setDomain(workbasket.getDomain());
workbasketService.checkAuthorization(task.getWorkbasketSummary().getId(),
@ -424,7 +430,13 @@ public class TaskServiceImpl implements TaskService {
task.setTransferred(true);
// transfer task from source to destination workbasket
task.setWorkbasketSummary(destinationWorkbasket.asSummary());
if (!destinationWorkbasket.isMarkedForDeletion()) {
task.setWorkbasketSummary(destinationWorkbasket.asSummary());
} else {
throw new WorkbasketNotFoundException(destinationWorkbasket.getId(),
"The workbasket " + destinationWorkbasket.getId() + " was marked for deletion");
}
task.setModified(Instant.now());
task.setState(TaskState.READY);
task.setOwner(null);
@ -464,7 +476,13 @@ public class TaskServiceImpl implements TaskService {
task.setTransferred(true);
// transfer task from source to destination workbasket
task.setWorkbasketSummary(destinationWorkbasket.asSummary());
if (!destinationWorkbasket.isMarkedForDeletion()) {
task.setWorkbasketSummary(destinationWorkbasket.asSummary());
} else {
throw new WorkbasketNotFoundException(destinationWorkbasket.getId(),
"The workbasket " + destinationWorkbasket.getId() + " was marked for deletion");
}
task.setModified(Instant.now());
task.setState(TaskState.READY);
task.setOwner(null);
@ -951,7 +969,8 @@ public class TaskServiceImpl implements TaskService {
}
@Override
public void deleteTask(String taskId) throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
public void deleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
deleteTask(taskId, false);
}

View File

@ -1,7 +1,6 @@
package pro.taskana.impl;
import java.time.Instant;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketSummary;
import pro.taskana.WorkbasketType;
@ -28,6 +27,7 @@ public class WorkbasketImpl implements Workbasket {
private String orgLevel2;
private String orgLevel3;
private String orgLevel4;
private boolean markedForDeletion;
WorkbasketImpl() {
}
@ -193,6 +193,16 @@ public class WorkbasketImpl implements Workbasket {
this.orgLevel4 = orgLevel4;
}
@Override
public boolean isMarkedForDeletion() {
return markedForDeletion;
}
@Override
public void setMarkedForDeletion(boolean markedForDeletion) {
this.markedForDeletion = markedForDeletion;
}
public void setDomain(String domain) {
this.domain = domain;
}
@ -211,6 +221,7 @@ public class WorkbasketImpl implements Workbasket {
result.setOrgLevel2(this.getOrgLevel2());
result.setOrgLevel3(this.getOrgLevel3());
result.setOrgLevel4(this.getOrgLevel4());
result.setMarkedForDeletion(this.isMarkedForDeletion());
return result;
}

View File

@ -3,11 +3,13 @@ package pro.taskana.impl;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.TaskState;
import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaRole;
import pro.taskana.Workbasket;
@ -28,7 +30,6 @@ import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.util.IdGenerator;
import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.mappings.DistributionTargetMapper;
import pro.taskana.mappings.TaskMapper;
import pro.taskana.mappings.WorkbasketAccessMapper;
import pro.taskana.mappings.WorkbasketMapper;
import pro.taskana.security.CurrentUserContext;
@ -729,10 +730,11 @@ public class WorkbasketServiceImpl implements WorkbasketService {
}
@Override
public void deleteWorkbasket(String workbasketId)
public boolean deleteWorkbasket(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException, WorkbasketInUseException, InvalidArgumentException {
LOGGER.debug("entry to deleteWorkbasket(workbasketId = {})", workbasketId);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
HashMap response = new HashMap();
try {
taskanaEngine.openConnection();
if (workbasketId == null || workbasketId.isEmpty()) {
@ -740,29 +742,61 @@ public class WorkbasketServiceImpl implements WorkbasketService {
}
// check if the workbasket does exist and is empty (Task)
Workbasket wb = this.getWorkbasket(workbasketId);
this.getWorkbasket(workbasketId);
long numTasksInWorkbasket = taskanaEngine.getSqlSession()
.getMapper(TaskMapper.class)
.countTasksInWorkbasket(workbasketId);
long numTasksInWorkbasket = taskanaEngine.getTaskService()
.createTaskQuery()
.workbasketIdIn(workbasketId)
.stateNotIn(
TaskState.COMPLETED)
.count();
if (numTasksInWorkbasket > 0) {
throw new WorkbasketInUseException(
"Workbasket is used on tasks and can´t be deleted. WorkbasketId = \"" + workbasketId
+ "\" and WorkbasketKey = \"" + wb.getKey() + "\" in domain = \"" + wb.getDomain() + "\"");
"Workbasket " + workbasketId + " contains non-completed tasks and can´t be marked for deletion.");
}
// delete workbasket and sub-tables
distributionTargetMapper.deleteAllDistributionTargetsBySourceId(wb.getId());
distributionTargetMapper.deleteAllDistributionTargetsByTargetId(wb.getId());
workbasketAccessMapper.deleteAllAccessItemsForWorkbasketId(wb.getId());
workbasketMapper.delete(workbasketId);
numTasksInWorkbasket = taskanaEngine.getTaskService()
.createTaskQuery()
.workbasketIdIn(workbasketId)
.count();
if (numTasksInWorkbasket == 0) {
workbasketMapper.delete(workbasketId);
return false;
} else {
markWorkbasketForDeletion(workbasketId);
return true;
}
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from deleteWorkbasket(workbasketId = {})", workbasketId);
}
}
private void markWorkbasketForDeletion(String workbasketId)
throws NotAuthorizedException, InvalidArgumentException {
LOGGER.debug("entry to markWorkbasketForDeletion(workbasketId = {})", workbasketId);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
try {
taskanaEngine.openConnection();
if (workbasketId == null || workbasketId.isEmpty()) {
throw new InvalidArgumentException(
"The WorkbasketId can´t be NULL or EMPTY for markWorkbasketForDeletion()");
}
WorkbasketImpl workbasket = workbasketMapper.findById(workbasketId);
workbasket.setMarkedForDeletion(true);
workbasketMapper.update(workbasket);
distributionTargetMapper.deleteAllDistributionTargetsBySourceId(workbasketId);
distributionTargetMapper.deleteAllDistributionTargetsByTargetId(workbasketId);
workbasketAccessMapper.deleteAllAccessItemsForWorkbasketId(workbasketId);
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from markWorkbasketForDeletion(workbasketId = {}).", workbasketId);
}
}
@Override
public WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() throws NotAuthorizedException {
taskanaEngine.checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN);

View File

@ -23,6 +23,7 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
private String orgLevel2;
private String orgLevel3;
private String orgLevel4;
private boolean markedForDeletion;
WorkbasketSummaryImpl() {
}
@ -222,6 +223,15 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.orgLevel4 = orgLevel4;
}
@Override
public boolean isMarkedForDeletion() {
return markedForDeletion;
}
public void setMarkedForDeletion(boolean markedForDeletion) {
this.markedForDeletion = markedForDeletion;
}
@Override
public int hashCode() {
final int prime = 31;

View File

@ -454,7 +454,7 @@ public interface QueryMapper {
@Select("<script>"
+ "SELECT DISTINCT "
+ "w.ID, w.KEY, w.NAME, w.DOMAIN, W.TYPE, w.DESCRIPTION, w.OWNER, w.CUSTOM_1, w.CUSTOM_2, w.CUSTOM_3, w.CUSTOM_4, w.ORG_LEVEL_1, w.ORG_LEVEL_2, w.ORG_LEVEL_3, w.ORG_LEVEL_4 from WORKBASKET w "
+ "w.ID, w.KEY, w.NAME, w.DOMAIN, W.TYPE, w.DESCRIPTION, w.OWNER, w.CUSTOM_1, w.CUSTOM_2, w.CUSTOM_3, w.CUSTOM_4, w.ORG_LEVEL_1, w.ORG_LEVEL_2, w.ORG_LEVEL_3, w.ORG_LEVEL_4, w.MARKED_FOR_DELETION from WORKBASKET w "
+ "<if test = 'joinWithAccessList'> "
+ "<choose>"
+ "<when test=\"_databaseId == 'db2'\">"
@ -550,7 +550,8 @@ public interface QueryMapper {
@Result(property = "orgLevel1", column = "ORG_LEVEL_1"),
@Result(property = "orgLevel2", column = "ORG_LEVEL_2"),
@Result(property = "orgLevel3", column = "ORG_LEVEL_3"),
@Result(property = "orgLevel4", column = "ORG_LEVEL_4")})
@Result(property = "orgLevel4", column = "ORG_LEVEL_4"),
@Result(property = "markedForDeletion", column = "MARKED_FOR_DELETION")})
List<WorkbasketSummaryImpl> queryWorkbasketSummaries(WorkbasketQueryImpl workbasketQuery);
@Select("<script>"

View File

@ -19,7 +19,7 @@ import pro.taskana.impl.WorkbasketSummaryImpl;
*/
public interface WorkbasketMapper {
@Select("<script>SELECT 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 FROM WORKBASKET WHERE ID = #{id} "
@Select("<script>SELECT 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 FROM WORKBASKET WHERE ID = #{id} "
+ "<if test=\"_databaseId == 'db2'\">with UR </if> "
+ "</script>")
@Results(value = {@Result(property = "id", column = "ID"),
@ -38,10 +38,11 @@ public interface WorkbasketMapper {
@Result(property = "orgLevel1", column = "ORG_LEVEL_1"),
@Result(property = "orgLevel2", column = "ORG_LEVEL_2"),
@Result(property = "orgLevel3", column = "ORG_LEVEL_3"),
@Result(property = "orgLevel4", column = "ORG_LEVEL_4")})
@Result(property = "orgLevel4", column = "ORG_LEVEL_4"),
@Result(property = "markedForDeletion", column = "MARKED_FOR_DELETION")})
WorkbasketImpl findById(@Param("id") String id);
@Select("<script>SELECT 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 FROM WORKBASKET WHERE UPPER(KEY) = UPPER(#{key}) and UPPER(DOMAIN) = UPPER(#{domain}) "
@Select("<script>SELECT 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 FROM WORKBASKET WHERE UPPER(KEY) = UPPER(#{key}) and UPPER(DOMAIN) = UPPER(#{domain}) "
+ "<if test=\"_databaseId == 'db2'\">with UR </if> "
+ "</script>")
@Results(value = {@Result(property = "id", column = "ID"),
@ -60,7 +61,8 @@ public interface WorkbasketMapper {
@Result(property = "orgLevel1", column = "ORG_LEVEL_1"),
@Result(property = "orgLevel2", column = "ORG_LEVEL_2"),
@Result(property = "orgLevel3", column = "ORG_LEVEL_3"),
@Result(property = "orgLevel4", column = "ORG_LEVEL_4")})
@Result(property = "orgLevel4", column = "ORG_LEVEL_4"),
@Result(property = "markedForDeletion", column = "MARKED_FOR_DELETION")})
WorkbasketImpl findByKeyAndDomain(@Param("key") String key, @Param("domain") String domain);
@Select("<script>SELECT ID, KEY, NAME, DESCRIPTION, OWNER, DOMAIN, TYPE, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, ORG_LEVEL_1, ORG_LEVEL_2, ORG_LEVEL_3, ORG_LEVEL_4 FROM WORKBASKET WHERE ID IN (SELECT TARGET_ID FROM DISTRIBUTION_TARGETS WHERE SOURCE_ID = #{id}) "
@ -106,7 +108,7 @@ public interface WorkbasketMapper {
@Result(property = "orgLevel4", column = "ORG_LEVEL_4")})
List<WorkbasketSummaryImpl> findDistributionSources(@Param("id") String id);
@Select("<script>SELECT ID, KEY, NAME, DESCRIPTION, OWNER, DOMAIN, TYPE, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, ORG_LEVEL_1, ORG_LEVEL_2, ORG_LEVEL_3, ORG_LEVEL_4 FROM WORKBASKET WHERE ID = #{id} "
@Select("<script>SELECT ID, KEY, NAME, DESCRIPTION, OWNER, DOMAIN, TYPE, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, ORG_LEVEL_1, ORG_LEVEL_2, ORG_LEVEL_3, ORG_LEVEL_4 FROM WORKBASKET WHERE ID = #{id} "
+ "<if test=\"_databaseId == 'db2'\">with UR </if> "
+ "</script>")
@Results(value = {
@ -148,12 +150,12 @@ public interface WorkbasketMapper {
@Result(property = "orgLevel4", column = "ORG_LEVEL_4")})
List<WorkbasketSummaryImpl> findAll();
@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) 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}) "
@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>")
@Options(keyProperty = "id", keyColumn = "ID")
void insert(@Param("workbasket") WorkbasketImpl workbasket);
@Update("UPDATE WORKBASKET SET MODIFIED = #{workbasket.modified}, KEY = #{workbasket.key}, NAME = #{workbasket.name}, DOMAIN = #{workbasket.domain}, TYPE = #{workbasket.type}, DESCRIPTION = #{workbasket.description}, OWNER = #{workbasket.owner}, CUSTOM_1 = #{workbasket.custom1}, CUSTOM_2 = #{workbasket.custom2}, CUSTOM_3 = #{workbasket.custom3}, CUSTOM_4 = #{workbasket.custom4}, ORG_LEVEL_1 = #{workbasket.orgLevel1}, ORG_LEVEL_2 = #{workbasket.orgLevel2}, ORG_LEVEL_3 = #{workbasket.orgLevel3}, ORG_LEVEL_4 = #{workbasket.orgLevel4} WHERE id = #{workbasket.id}")
@Update("UPDATE WORKBASKET SET MODIFIED = #{workbasket.modified}, KEY = #{workbasket.key}, NAME = #{workbasket.name}, DOMAIN = #{workbasket.domain}, TYPE = #{workbasket.type}, DESCRIPTION = #{workbasket.description}, OWNER = #{workbasket.owner}, CUSTOM_1 = #{workbasket.custom1}, CUSTOM_2 = #{workbasket.custom2}, CUSTOM_3 = #{workbasket.custom3}, CUSTOM_4 = #{workbasket.custom4}, ORG_LEVEL_1 = #{workbasket.orgLevel1}, ORG_LEVEL_2 = #{workbasket.orgLevel2}, ORG_LEVEL_3 = #{workbasket.orgLevel3}, ORG_LEVEL_4 = #{workbasket.orgLevel4}, MARKED_FOR_DELETION = #{workbasket.markedForDeletion} WHERE id = #{workbasket.id}")
void update(@Param("workbasket") WorkbasketImpl workbasket);
@Delete("DELETE FROM WORKBASKET where id = #{id}")

View File

@ -7,7 +7,7 @@ CREATE TABLE TASKANA_SCHEMA_VERSION(
PRIMARY KEY (ID)
);
-- The VERSION value must match the value of TaskanaEngineConfiguration.TASKANA_SCHEMA_VERSION
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('1.0.2', CURRENT_TIMESTAMP);
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('1.0.4', CURRENT_TIMESTAMP);
CREATE TABLE CLASSIFICATION(
ID CHAR(40) NOT NULL,
@ -55,6 +55,7 @@ CREATE TABLE WORKBASKET(
ORG_LEVEL_2 VARCHAR(255) NULL,
ORG_LEVEL_3 VARCHAR(255) NULL,
ORG_LEVEL_4 VARCHAR(255) NULL,
MARKED_FOR_DELETION SMALLINT NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT WB_KEY_DOMAIN UNIQUE (KEY, DOMAIN)
);

View File

@ -9,7 +9,7 @@ CREATE TABLE TASKANA_SCHEMA_VERSION(
PRIMARY KEY (ID)
);
-- The VERSION value must match the value of TaskanaEngineConfiguration.TASKANA_SCHEMA_VERSION
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('1.0.2', CURRENT_TIMESTAMP);
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('1.0.4', CURRENT_TIMESTAMP);
CREATE TABLE CLASSIFICATION(
ID CHAR(40) NOT NULL,
@ -57,6 +57,7 @@ CREATE TABLE WORKBASKET(
ORG_LEVEL_2 VARCHAR(255) NULL,
ORG_LEVEL_3 VARCHAR(255) NULL,
ORG_LEVEL_4 VARCHAR(255) NULL,
MARKED_FOR_DELETION BOOLEAN NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT WB_KEY_DOMAIN UNIQUE (KEY, DOMAIN)
);

View File

@ -9,7 +9,7 @@ CREATE TABLE TASKANA_SCHEMA_VERSION(
PRIMARY KEY (ID)
);
-- The VERSION value must match the value of TaskanaEngineConfiguration.TASKANA_SCHEMA_VERSION
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('1.0.2', CURRENT_TIMESTAMP);
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('1.0.4', CURRENT_TIMESTAMP);
CREATE TABLE CLASSIFICATION(
ID CHAR(40) NOT NULL,
@ -57,6 +57,7 @@ CREATE TABLE WORKBASKET(
ORG_LEVEL_2 VARCHAR(255) NULL,
ORG_LEVEL_3 VARCHAR(255) NULL,
ORG_LEVEL_4 VARCHAR(255) NULL,
MARKED_FOR_DELETION SMALLINT NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT WB_KEY_DOMAIN UNIQUE (KEY, DOMAIN)
);

View File

@ -0,0 +1,7 @@
-- this script update the tables TASKANA_SCHEMA_VERSION and WORKBASKET.
SET SCHEMA %schemaName%;
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('1.0.4', CURRENT_TIMESTAMP);
ALTER TABLE WORKBASKET ADD COLUMN MARKED_FOR_DELETION SMALLINT NOT NULL DEFAULT false;

View File

@ -0,0 +1,7 @@
-- this script update the tables TASKANA_SCHEMA_VERSION and WORKBASKET in postgre database.
SET SCHEMA %schemaName%;
INSERT INTO TASKANA_SCHEMA_VERSION (VERSION, CREATED) VALUES ('1.0.4', CURRENT_TIMESTAMP);
ALTER TABLE WORKBASKET ADD COLUMN MARKED_FOR_DELETION BOOLEAN NOT NULL DEFAULT false;

View File

@ -3,6 +3,9 @@ package acceptance.jobs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -23,9 +26,6 @@ import pro.taskana.jobs.TaskCleanupJob;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
import java.util.ArrayList;
import java.util.List;
/**
* Acceptance test for all "jobs tasks runner" scenarios.
*/
@ -62,7 +62,9 @@ public class TaskCleanupJobAccTest extends AbstractAccTest {
taskanaEngine.getConfiguration().setTaskCleanupJobAllCompletedSameParentBusiness(true);
List<TaskSummary> tasks = taskService.createTaskQuery().parentBusinessProcessIdIn("DOC_0000000000000000006").list();
List<TaskSummary> tasks = taskService.createTaskQuery()
.parentBusinessProcessIdIn("DOC_0000000000000000006")
.list();
List<String> ids = new ArrayList<>();
tasks.forEach(item -> {
if (item.getCompleted() == null) {

View File

@ -29,31 +29,31 @@ public class CompleteTaskAccTest extends AbstractAccTest {
}
@WithAccessId(
userName = "user_1_1",
groupNames = {"group_1"})
userName = "user_1_1",
groupNames = {"group_1"})
@Test
public void testCompleteTask()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
Task completedTask = taskService.completeTask("TKI:000000000000000000000000000000000001");
assertNotNull(completedTask);
}
@WithAccessId(
userName = "user_1_1",
groupNames = {"group_1"})
userName = "user_1_1",
groupNames = {"group_1"})
@Test
public void testCompleteTaskTwice() throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
public void testCompleteTaskTwice()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
Task completedTask = taskService.completeTask("TKI:000000000000000000000000000000000002");
Task completedTask2 = taskService.completeTask("TKI:000000000000000000000000000000000002");
assertEquals(completedTask, completedTask2);
}
@WithAccessId(
userName = "user_1_1",
groupNames = {"group_1"})
userName = "user_1_1",
groupNames = {"group_1"})
@Test
public void testCompleteTaskThrowsErrors() {
TaskService taskService = taskanaEngine.getTaskService();

View File

@ -48,7 +48,8 @@ public class DeleteTaskAccTest extends AbstractAccTest {
userName = "user_1_2",
groupNames = {"group_1", "admin"})
@Test(expected = TaskNotFoundException.class)
public void testDeleteSingleTask() throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
public void testDeleteSingleTask()
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000036");
@ -92,7 +93,8 @@ public class DeleteTaskAccTest extends AbstractAccTest {
userName = "user_1_2",
groupNames = {"group_1"})
@Test(expected = TaskNotFoundException.class)
public void testBulkDeleteTask() throws TaskNotFoundException, InvalidArgumentException, NotAuthorizedException {
public void testBulkDeleteTask()
throws TaskNotFoundException, InvalidArgumentException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
ArrayList<String> taskIdList = new ArrayList<>();

View File

@ -2,13 +2,12 @@ package acceptance.task;
import static org.junit.Assert.assertEquals;
import java.util.HashMap;
import org.junit.Test;
import org.junit.runner.RunWith;
import acceptance.AbstractAccTest;
import java.util.HashMap;
import pro.taskana.Task;
import pro.taskana.TaskService;
import pro.taskana.TaskState;
@ -33,7 +32,8 @@ public class GetTaskAccTest extends AbstractAccTest {
userName = "user_1_1",
groupNames = {"group_1"})
@Test
public void testGetTaskById() throws TaskNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testGetTaskById()
throws TaskNotFoundException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");

View File

@ -16,6 +16,7 @@ import pro.taskana.AttachmentSummary;
import pro.taskana.Task;
import pro.taskana.TaskService;
import pro.taskana.TaskSummary;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.security.JAASRunner;
@ -111,4 +112,45 @@ public class QueryTaskWithAttachment extends AbstractAccTest {
assertNotEquals(originalAttachments.get(i).getClass(), queryAttachmentSummaries.get(i).getClass());
}
}
@WithAccessId(
userName = "user_1_1",
groupNames = {"group_1"})
@Test
public void testIfAttachmentSummariesAreCorrect()
throws InvalidArgumentException, TaskNotFoundException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
// find Task with ID TKI:00...00
List<TaskSummary> tasks = taskService.createTaskQuery()
.classificationKeyIn("T2000")
.customAttributeIn("1", "custom1")
.list();
assertEquals(1, tasks.size());
List<AttachmentSummary> queryAttachmentSummaries = tasks.get(0).getAttachmentSummaries();
Task originalTask = taskService.getTask("TKI:000000000000000000000000000000000000");
List<Attachment> originalAttachments = originalTask.getAttachments();
assertEquals(originalAttachments.size(), queryAttachmentSummaries.size());
for (int i = 0; i < queryAttachmentSummaries.size(); i++) {
// Test if it's the Summary of the Original Attachment
assertEquals(originalAttachments.get(i).asSummary(), queryAttachmentSummaries.get(i));
// Test if the values are correct
assertEquals(originalAttachments.get(i).getChannel(), queryAttachmentSummaries.get(i).getChannel());
assertEquals(originalAttachments.get(i).getClassificationSummary(),
queryAttachmentSummaries.get(i).getClassificationSummary());
assertEquals(originalAttachments.get(i).getCreated(), queryAttachmentSummaries.get(i).getCreated());
assertEquals(originalAttachments.get(i).getId(), queryAttachmentSummaries.get(i).getId());
assertEquals(originalAttachments.get(i).getModified(), queryAttachmentSummaries.get(i).getModified());
assertEquals(originalAttachments.get(i).getObjectReference(),
queryAttachmentSummaries.get(i).getObjectReference());
assertEquals(originalAttachments.get(i).getReceived(), queryAttachmentSummaries.get(i).getReceived());
assertEquals(originalAttachments.get(i).getTaskId(), queryAttachmentSummaries.get(i).getTaskId());
// Verify that they're not the same Object
assertNotEquals(originalAttachments.get(i).hashCode(), queryAttachmentSummaries.get(i).hashCode());
assertNotEquals(originalAttachments.get(i).getClass(), queryAttachmentSummaries.get(i).getClass());
}
}
}

View File

@ -311,7 +311,7 @@ public class TransferTaskAccTest extends AbstractAccTest {
taskIdList.add("TKI:000000000000000000000000000000000024");
BulkOperationResults<String, TaskanaException> results = taskService
.transferTasks("GPK_B_KSC_1", "DOMAIN_B", taskIdList);
.transferTasks("GPK_B_KSC_1", "DOMAIN_B", taskIdList);
assertFalse(results.containsErrors());
Workbasket wb = taskanaEngine.getWorkbasketService().getWorkbasket("GPK_B_KSC_1", "DOMAIN_B");

View File

@ -262,7 +262,8 @@ public class UpdateTaskAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testUpdateTasksByPor() throws InvalidArgumentException, TaskNotFoundException, NotAuthorizedException {
public void testUpdateTasksByPor()
throws InvalidArgumentException, TaskNotFoundException, NotAuthorizedException {
ObjectReference por = new ObjectReference();
por.setCompany("00");
por.setSystem("PASystem");

View File

@ -93,7 +93,8 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
assertThat(task.getAttachments().get(0).getObjectReference().getSystem(), equalTo("SYSTEM_B"));
assertThat(task.getAttachments().get(0).getObjectReference().getSystemInstance(), equalTo("INSTANCE_B"));
assertThat(task.getAttachments().get(0).getObjectReference().getType(), equalTo("ArchiveId"));
assertThat(task.getAttachments().get(0).getObjectReference().getValue(), equalTo("12345678901234567890123456789012345678901234567890"));
assertThat(task.getAttachments().get(0).getObjectReference().getValue(),
equalTo("12345678901234567890123456789012345678901234567890"));
assertTrue(task.getPriority() == 99);
assertTrue(task.getDue().equals(task.getPlanned().plus(Duration.ofDays(1))));
}

View File

@ -13,17 +13,22 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import acceptance.AbstractAccTest;
import pro.taskana.TaskService;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketAccessItem;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketType;
import pro.taskana.exceptions.DomainNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidOwnerException;
import pro.taskana.exceptions.InvalidStateException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.WorkbasketAlreadyExistException;
import pro.taskana.exceptions.WorkbasketInUseException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.TaskImpl;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
@ -35,6 +40,8 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
private WorkbasketService workbasketService;
private TaskService taskService;
public DeleteWorkbasketAccTest() {
super();
}
@ -42,19 +49,20 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
@Before
public void setUpMethod() {
workbasketService = taskanaEngine.getWorkbasketService();
taskService = taskanaEngine.getTaskService();
}
@WithAccessId(userName = "teamlead_2", groupNames = {"businessadmin"})
@WithAccessId(userName = "admin", groupNames = {"businessadmin"})
@Test
public void testDeleteWorkbasket()
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidArgumentException {
Workbasket wb = workbasketService.getWorkbasket("USER_2_2", "DOMAIN_A");
workbasketService.deleteWorkbasket(wb.getId());
try {
workbasketService.deleteWorkbasket(wb.getId());
workbasketService.getWorkbasket("USER_2_2", "DOMAIN_A");
fail("There should be no result for a deleted Workbasket.");
} catch (WorkbasketNotFoundException e) {
} catch (WorkbasketNotFoundException | WorkbasketInUseException e) {
// Workbasket is deleted
}
}
@ -73,17 +81,17 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
@WithAccessId(userName = "user_1_1", groupNames = {"teamlead_1", "group_1", "businessadmin"})
@Test
public void testDeleteWorkbasketAlsoAsDistributionTarget()
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidArgumentException {
Workbasket wb = workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A");
int distTargets = workbasketService.getDistributionTargets("WBI:100000000000000000000000000000000001")
.size();
// WB deleted
workbasketService.deleteWorkbasket(wb.getId());
try {
// WB deleted
workbasketService.deleteWorkbasket(wb.getId());
workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A");
fail("There should be no result for a deleted Workbasket.");
} catch (WorkbasketNotFoundException e) {
} catch (WorkbasketNotFoundException | WorkbasketInUseException e) {
// Workbasket is deleted
}
@ -125,12 +133,12 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
workbasketService.deleteWorkbasket("SOME NOT EXISTING ID");
}
@WithAccessId(userName = "user_1_1",
@WithAccessId(userName = "user_1_2",
groupNames = {"businessadmin"})
@Test(expected = WorkbasketInUseException.class)
public void testDeleteWorkbasketWhichIsUsed()
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
Workbasket wb = workbasketService.getWorkbasket("USER_1_1", "DOMAIN_A"); // all rights, DOMAIN_A with Tasks
Workbasket wb = workbasketService.getWorkbasket("USER_1_2", "DOMAIN_A"); // all rights, DOMAIN_A with Tasks
workbasketService.deleteWorkbasket(wb.getId());
}
@ -161,7 +169,7 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
@WithAccessId(userName = "teamlead_2", groupNames = {"businessadmin"})
@Test
public void testCascadingDeleteOfAccessItems()
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidArgumentException {
Workbasket wb = workbasketService.getWorkbasket("WBI:100000000000000000000000000000000008");
String wbId = wb.getId();
// create 2 access Items
@ -177,11 +185,11 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
workbasketService.createWorkbasketAccessItem(accessItem);
List<WorkbasketAccessItem> accessItemsBefore = workbasketService.getWorkbasketAccessItems(wbId);
assertEquals(5, accessItemsBefore.size());
workbasketService.deleteWorkbasket(wbId);
try {
workbasketService.deleteWorkbasket(wbId);
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000008");
fail("There should be no result for a deleted Workbasket.");
} catch (WorkbasketNotFoundException e) {
} catch (WorkbasketNotFoundException | WorkbasketInUseException e) {
// Workbasket is deleted
}
@ -189,4 +197,26 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
assertEquals(0, accessItemsAfter.size());
}
@WithAccessId(userName = "admin", groupNames = {"businessadmin"})
@Test
public void testMarkWorkbasketForDeletion()
throws WorkbasketInUseException, NotAuthorizedException, WorkbasketNotFoundException, InvalidArgumentException,
InvalidOwnerException, InvalidStateException, TaskNotFoundException {
Workbasket wb = workbasketService.getWorkbasket("WBI:100000000000000000000000000000000006");
boolean markedForDeletion;
TaskImpl task = (TaskImpl) taskService.getTask("TKI:000000000000000000000000000000000000");
taskService.forceCompleteTask(task.getId());
task = (TaskImpl) taskService.getTask("TKI:000000000000000000000000000000000001");
taskService.forceCompleteTask(task.getId());
task = (TaskImpl) taskService.getTask("TKI:000000000000000000000000000000000002");
taskService.forceCompleteTask(task.getId());
markedForDeletion = workbasketService.deleteWorkbasket(wb.getId());
assertTrue(markedForDeletion);
wb = workbasketService.getWorkbasket(wb.getId());
assertTrue(wb.isMarkedForDeletion());
}
}

View File

@ -2,12 +2,12 @@ package acceptance.workbasket;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
@ -265,8 +265,8 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
}
@WithAccessId(
userName = "teamlead_1",
groupNames = {"group_1", "businessadmin"})
userName = "teamlead_1",
groupNames = {"group_1", "businessadmin"})
@Test
public void testDeleteAccessItemForAccessItemId() throws NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
@ -285,14 +285,14 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
workbasketService.setWorkbasketAccessItems(wbId, accessList);
List<WorkbasketAccessItem> modifiedList = new ArrayList<>(
workbasketService.getWorkbasketAccessItems(wbId));
workbasketService.getWorkbasketAccessItems(wbId));
for (WorkbasketAccessItem a : modifiedList) {
if (!originalIds.contains(a.getId())) {
workbasketService.deleteWorkbasketAccessItem(a.getId());
}
}
List<WorkbasketAccessItem> listEqualToOriginal = new ArrayList<>(
workbasketService.getWorkbasketAccessItems(wbId));
workbasketService.getWorkbasketAccessItems(wbId));
assertEquals(originalList, listEqualToOriginal);
}

View File

@ -511,30 +511,24 @@ public class WorkbasketServiceImplTest {
}
}
@Test(expected = WorkbasketInUseException.class)
@Test(expected = WorkbasketNotFoundException.class)
public void testDeleteWorkbasketIsUsed()
throws NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException, WorkbasketNotFoundException {
Workbasket wb = createTestWorkbasket("WBI:0", "wb-key");
List<TaskSummary> usages = Arrays.asList(new TaskSummaryImpl(), new TaskSummaryImpl());
doReturn(wb).when(cutSpy).getWorkbasket(wb.getId());
doReturn(sqlSessionMock).when(taskanaEngineImplMock).getSqlSession();
doReturn(taskMapperMock).when(sqlSessionMock).getMapper(TaskMapper.class);
doReturn(new Long(1)).when(taskMapperMock).countTasksInWorkbasket(any());
try {
cutSpy.deleteWorkbasket(wb.getId());
} catch (WorkbasketNotFoundException e) {
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(2)).openConnection();
verify(cutSpy, times(1)).getWorkbasket(wb.getId());
verify(taskanaEngineImplMock, times(1)).getTaskService();
verify(taskServiceMock, times(1)).createTaskQuery();
verify(taskQueryMock, times(1)).workbasketIdIn(wb.getId());
verify(taskQueryMock, times(1)).list();
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
distributionTargetMapperMock,
taskanaEngineImplMock, taskanaEngineConfigurationMock);
verify(taskanaEngineImplMock, times(0)).getTaskService();
verify(taskServiceMock, times(0)).createTaskQuery();
verify(taskQueryMock, times(0)).workbasketIdIn(wb.getId());
verify(taskQueryMock, times(0)).count();
verify(taskanaEngineImplMock, times(2)).returnConnection();
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketAccessMapperMock,
distributionTargetMapperMock, taskanaEngineConfigurationMock);
throw e;
}
}
@ -543,26 +537,24 @@ public class WorkbasketServiceImplTest {
public void testDeleteWorkbasket()
throws NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException, WorkbasketNotFoundException {
Workbasket wb = createTestWorkbasket("WBI:0", "wb-key");
doReturn(wb).when(cutSpy).getWorkbasket(wb.getId());
doReturn(sqlSessionMock).when(taskanaEngineImplMock).getSqlSession();
doReturn(taskMapperMock).when(sqlSessionMock).getMapper(TaskMapper.class);
doReturn(new Long(0)).when(taskMapperMock).countTasksInWorkbasket(any());
cutSpy.deleteWorkbasket(wb.getId());
try {
// WB deleted
cutSpy.deleteWorkbasket(wb.getId());
} catch (WorkbasketNotFoundException e) {
// Workbasket is deleted
}
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(2)).openConnection();
verify(cutSpy, times(1)).getWorkbasket(wb.getId());
verify(taskanaEngineImplMock, times(1)).getSqlSession();
verify(sqlSessionMock, times(1)).getMapper(TaskMapper.class);
verify(taskMapperMock, times(1)).countTasksInWorkbasket(any());
verify(taskanaEngineImplMock, times(0)).getSqlSession();
verify(sqlSessionMock, times(0)).getMapper(TaskMapper.class);
verify(taskMapperMock, times(0)).countTasksInWorkbasket(any());
verify(distributionTargetMapperMock, times(1)).deleteAllDistributionTargetsBySourceId(wb.getId());
verify(distributionTargetMapperMock, times(1)).deleteAllDistributionTargetsByTargetId(wb.getId());
verify(workbasketAccessMapperMock, times(1)).deleteAllAccessItemsForWorkbasketId(wb.getId());
verify(workbasketMapperMock, times(1)).delete(wb.getId());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verify(workbasketMapperMock, times(1)).findById(wb.getId());
verify(taskanaEngineImplMock, times(2)).returnConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketAccessMapperMock,
distributionTargetMapperMock,
taskanaEngineImplMock, taskanaEngineConfigurationMock);
}

View File

@ -1,8 +1,8 @@
-- WORKBASKET TABLE (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 );
INSERT INTO WORKBASKET VALUES ('WBI:000000000000000000000000000000000001', 'USER_1_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 1', 'MONITOR_TEST_DOMAIN', 'PERSONAL', 'Monitor Test Postkorb 1', 'John' , '' , '' , '' , '' , '' , '' , '' , '' );
INSERT INTO WORKBASKET VALUES ('WBI:000000000000000000000000000000000002', 'USER_1_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 2', 'MONITOR_TEST_DOMAIN', 'PERSONAL', 'Monitor Test Postkorb 2', 'John' , '' , '' , '' , '' , '' , '' , '' , '' );
INSERT INTO WORKBASKET VALUES ('WBI:000000000000000000000000000000000003', 'USER_1_3', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 3', 'MONITOR_TEST_DOMAIN', 'PERSONAL', 'Monitor Test Postkorb 3', 'John' , '' , '' , '' , '' , '' , '' , '' , '' );
INSERT INTO WORKBASKET VALUES ('WBI:000000000000000000000000000000000004', 'USER_1_4', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 4', 'MONITOR_TEST_DOMAIN', 'PERSONAL', 'Monitor Test Postkorb 4', 'John' , '' , '' , '' , '' , '' , '' , '' , '' );
-- WORKBASKET TABLE (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 );
INSERT INTO WORKBASKET VALUES ('WBI:000000000000000000000000000000000001', 'USER_1_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 1', 'MONITOR_TEST_DOMAIN', 'PERSONAL', 'Monitor Test Postkorb 1', 'John' , '' , '' , '' , '' , '' , '' , '' , '' , FALSE );
INSERT INTO WORKBASKET VALUES ('WBI:000000000000000000000000000000000002', 'USER_1_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 2', 'MONITOR_TEST_DOMAIN', 'PERSONAL', 'Monitor Test Postkorb 2', 'John' , '' , '' , '' , '' , '' , '' , '' , '' , FALSE );
INSERT INTO WORKBASKET VALUES ('WBI:000000000000000000000000000000000003', 'USER_1_3', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 3', 'MONITOR_TEST_DOMAIN', 'PERSONAL', 'Monitor Test Postkorb 3', 'John' , '' , '' , '' , '' , '' , '' , '' , '' , FALSE );
INSERT INTO WORKBASKET VALUES ('WBI:000000000000000000000000000000000004', 'USER_1_4', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 4', 'MONITOR_TEST_DOMAIN', 'PERSONAL', 'Monitor Test Postkorb 4', 'John' , '' , '' , '' , '' , '' , '' , '' , '' , FALSE );
-- CLASSIFICATION TABLE (ID , KEY , PARENT_ID , PARENT_KEY, CATEGORY , TYPE , DOMAIN , VALID_IN_DOMAIN, CREATED , MODIFIED ,NAME , DESCRIPTION , PRIORITY, SERVICE_LEVEL, APPLICATION_ENTRY_POINT, CUSTOM_1 , CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8 );
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000001', 'L10000', '' , '' , 'EXTERN' , 'TASK', 'DOMAIN_A', TRUE , CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'OLD-Leistungsfall' , 'OLD-Leistungsfall' , 3 , 'P1D' , '' , 'VNR,RVNR,KOLVNR' , '' , '' , '' , '' , '' , '' , '' );

View File

@ -1,30 +1,30 @@
-- KSC workbaskets
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000001', 'GPK_KSC', '2018-02-01 12:00:00', '2018-02-01 12:00:00', 'Gruppenpostkorb KSC', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC', 'owner0815', 'ABCQVW', '', 'xyz4', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000002', 'GPK_KSC_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC 1', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC 1', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000003', 'GPK_KSC_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC 2', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC 2', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000004', 'TEAMLEAD_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK Teamlead KSC 1', 'DOMAIN_A', 'PERSONAL', 'PPK Teamlead KSC 1', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000005', 'TEAMLEAD_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK Teamlead KSC 2', 'DOMAIN_A', 'PERSONAL', 'PPK Teamlead KSC 2', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000006', 'USER_1_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 1', 'DOMAIN_A', 'PERSONAL', 'PPK User 1 KSC 1', '', '', '', '', 'custom4z', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000007', 'USER_1_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 2 KSC 1', 'DOMAIN_A', 'PERSONAL', 'PPK User 2 KSC 1', 'Peter Maier', 'custom1', 'custom2', 'custom3', 'custom4', 'versicherung', 'abteilung', 'projekt', 'team');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000008', 'USER_2_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 2', 'DOMAIN_A', 'PERSONAL', 'PPK User 1 KSC 2', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000009', 'USER_2_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 2 KSC 2', 'DOMAIN_A', 'PERSONAL', 'PPK User 2 KSC 2', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000010', 'TPK_VIP', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Themenpostkorb VIP', 'DOMAIN_A', 'TOPIC', 'Themenpostkorb VIP', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000001', 'GPK_KSC', '2018-02-01 12:00:00', '2018-02-01 12:00:00', 'Gruppenpostkorb KSC', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC', 'owner0815', 'ABCQVW', '', 'xyz4', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000002', 'GPK_KSC_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC 1', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC 1', '', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000003', 'GPK_KSC_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC 2', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC 2', '', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000004', 'TEAMLEAD_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK Teamlead KSC 1', 'DOMAIN_A', 'PERSONAL', 'PPK Teamlead KSC 1', '', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000005', 'TEAMLEAD_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK Teamlead KSC 2', 'DOMAIN_A', 'PERSONAL', 'PPK Teamlead KSC 2', '', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000006', 'USER_1_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 1', 'DOMAIN_A', 'PERSONAL', 'PPK User 1 KSC 1', '', '', '', '', 'custom4z', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000007', 'USER_1_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 2 KSC 1', 'DOMAIN_A', 'PERSONAL', 'PPK User 2 KSC 1', 'Peter Maier', 'custom1', 'custom2', 'custom3', 'custom4', 'versicherung', 'abteilung', 'projekt', 'team', FALSE);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000008', 'USER_2_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 2', 'DOMAIN_A', 'PERSONAL', 'PPK User 1 KSC 2', '', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000009', 'USER_2_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 2 KSC 2', 'DOMAIN_A', 'PERSONAL', 'PPK User 2 KSC 2', '', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000010', 'TPK_VIP', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Themenpostkorb VIP', 'DOMAIN_A', 'TOPIC', 'Themenpostkorb VIP', '', '', '', '', '', '', '', '', '', FALSE);
-- KSC workbaskets Domain_B
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000011', 'GPK_B_KSC', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000012', 'GPK_B_KSC_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B1', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC 1', '', 'custom1', 'custom2', 'custom3', 'custom4', 'orgl1', 'orgl2', 'orgl3', 'aorgl4');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000013', 'GPK_B_KSC_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B2', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC 2', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000014', 'USER_3_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 1 Domain B', 'DOMAIN_B', 'PERSONAL', 'PPK User 1 KSC 1 Domain B', '', '', 'custom20', '', 'custom4', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000015', 'USER_3_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 2 KSC 1 Domain B', 'DOMAIN_B', 'PERSONAL', 'PPK User 1 KSC 1 Domain B', 'owner0815', 'ABCABC', 'cust2', 'cust3', 'cust4', 'orgl1', 'orgl2', 'orgl3', 'orgl4');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000011', 'GPK_B_KSC', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC', '', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000012', 'GPK_B_KSC_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B1', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC 1', '', 'custom1', 'custom2', 'custom3', 'custom4', 'orgl1', 'orgl2', 'orgl3', 'aorgl4', FALSE);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000013', 'GPK_B_KSC_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B2', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC 2', '', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000014', 'USER_3_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 1 Domain B', 'DOMAIN_B', 'PERSONAL', 'PPK User 1 KSC 1 Domain B', '', '', 'custom20', '', 'custom4', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000015', 'USER_3_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 2 KSC 1 Domain B', 'DOMAIN_B', 'PERSONAL', 'PPK User 1 KSC 1 Domain B', 'owner0815', 'ABCABC', 'cust2', 'cust3', 'cust4', 'orgl1', 'orgl2', 'orgl3', 'orgl4', FALSE);
-- Workbaskets for sorting test
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000900', 'sort001', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basxet0', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000901', 'Sort002', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Basxet1', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000902', 'sOrt003', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'bAsxet2', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000903', 'soRt004', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'baSxet3', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000904', 'sorT005', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basXet4', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000905', 'Sort006', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basxEt5', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000906', 'SOrt007', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basxeT6', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000907', 'SoRt008', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'BAsxet7', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000908', 'SorT009', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'BaSxet8', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000909', 'Sort010', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'BasXet9', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000900', 'sort001', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basxet0', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000901', 'Sort002', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Basxet1', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000902', 'sOrt003', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'bAsxet2', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000903', 'soRt004', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'baSxet3', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000904', 'sorT005', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basXet4', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000905', 'Sort006', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basxEt5', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000906', 'SOrt007', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basxeT6', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000907', 'SoRt008', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'BAsxet7', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000908', 'SorT009', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'BaSxet8', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', FALSE);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000909', 'Sort010', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'BasXet9', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', FALSE);

View File

@ -8,9 +8,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import pro.taskana.TaskanaEngine;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketType;
import pro.taskana.exceptions.DomainNotFoundException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;

View File

@ -262,6 +262,18 @@ include::../../../{snippets}/UpdateWorkbasketDocTest/http-response.adoc[]
The response-body is essentially the same as for getting a single classification. +
Therefore for the response fields you can refer to the structure of the <<workbasket, single workbasket>>.
=== Mark workbasket for deletion
A `DELETE` request is used to update a workbasket
==== Example Request
include::../../../{snippets}/MarkWorkbasketForDeletionDocTest/http-request.adoc[]
==== Example Response
include::../../../{snippets}/MarkWorkbasketForDeletionDocTest/http-response.adoc[]
=== Remove a workbasket as distribution-target

View File

@ -1,30 +1,31 @@
-- KSC workbaskets
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000001', 'GPK_KSC', '2018-02-01 12:00:00', '2018-02-01 12:00:00', 'Gruppenpostkorb KSC', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC', 'owner0815', 'ABCQVW', '', 'xyz4', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000002', 'GPK_KSC_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC 1', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC 1', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000003', 'GPK_KSC_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC 2', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC 2', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000004', 'TEAMLEAD_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK Teamlead KSC 1', 'DOMAIN_A', 'PERSONAL', 'PPK Teamlead KSC 1', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000005', 'TEAMLEAD_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK Teamlead KSC 2', 'DOMAIN_A', 'PERSONAL', 'PPK Teamlead KSC 2', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000006', 'USER_1_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 1', 'DOMAIN_A', 'PERSONAL', 'PPK User 1 KSC 1', '', '', '', '', 'custom4z', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000007', 'USER_1_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 2 KSC 1', 'DOMAIN_A', 'PERSONAL', 'PPK User 2 KSC 1', 'Peter Maier', 'custom1', 'custom2', 'custom3', 'custom4', 'versicherung', 'abteilung', 'projekt', 'team');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000008', 'USER_2_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 2', 'DOMAIN_A', 'PERSONAL', 'PPK User 1 KSC 2', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000009', 'USER_2_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 2 KSC 2', 'DOMAIN_A', 'PERSONAL', 'PPK User 2 KSC 2', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000010', 'TPK_VIP', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Themenpostkorb VIP', 'DOMAIN_A', 'TOPIC', 'Themenpostkorb VIP', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000001', 'GPK_KSC', '2018-02-01 12:00:00', '2018-02-01 12:00:00', 'Gruppenpostkorb KSC', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC', 'owner0815', 'ABCQVW', '', 'xyz4', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000002', 'GPK_KSC_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC 1', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC 1', '', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000003', 'GPK_KSC_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC 2', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC 2', '', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000004', 'TEAMLEAD_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK Teamlead KSC 1', 'DOMAIN_A', 'PERSONAL', 'PPK Teamlead KSC 1', '', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000005', 'TEAMLEAD_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK Teamlead KSC 2', 'DOMAIN_A', 'PERSONAL', 'PPK Teamlead KSC 2', '', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000006', 'USER_1_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 1', 'DOMAIN_A', 'PERSONAL', 'PPK User 1 KSC 1', '', '', '', '', 'custom4z', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000007', 'USER_1_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 2 KSC 1', 'DOMAIN_A', 'PERSONAL', 'PPK User 2 KSC 1', 'Peter Maier', 'custom1', 'custom2', 'custom3', 'custom4', 'versicherung', 'abteilung', 'projekt', 'team', false);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000008', 'USER_2_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 2', 'DOMAIN_A', 'PERSONAL', 'PPK User 1 KSC 2', '', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000009', 'USER_2_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 2 KSC 2', 'DOMAIN_A', 'PERSONAL', 'PPK User 2 KSC 2', '', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000010', 'TPK_VIP', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Themenpostkorb VIP', 'DOMAIN_A', 'TOPIC', 'Themenpostkorb VIP', '', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000016', 'TPK_VIP_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Themenpostkorb VIP 2', 'DOMAIN_A', 'TOPIC', 'Themenpostkorb VIP', '', '', '', '', '', '', '', '', '', false);
-- KSC workbaskets Domain_B
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000011', 'GPK_B_KSC', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000012', 'GPK_B_KSC_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B1', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC 1', '', 'custom1', 'custom2', 'custom3', 'custom4', 'orgl1', 'orgl2', 'orgl3', 'aorgl4');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000013', 'GPK_B_KSC_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B2', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC 2', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000014', 'USER_3_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 1 Domain B', 'DOMAIN_B', 'PERSONAL', 'PPK User 1 KSC 1 Domain B', '', '', 'custom20', '', 'custom4', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000015', 'USER_3_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 2 KSC 1 Domain B', 'DOMAIN_B', 'PERSONAL', 'PPK User 1 KSC 1 Domain B', 'owner0815', 'ABCABC', 'cust2', 'cust3', 'cust4', 'orgl1', 'orgl2', 'orgl3', 'orgl4');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000011', 'GPK_B_KSC', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC', '', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000012', 'GPK_B_KSC_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B1', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC 1', '', 'custom1', 'custom2', 'custom3', 'custom4', 'orgl1', 'orgl2', 'orgl3', 'aorgl4', false);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000013', 'GPK_B_KSC_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B2', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC 2', '', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000014', 'USER_3_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 1 KSC 1 Domain B', 'DOMAIN_B', 'PERSONAL', 'PPK User 1 KSC 1 Domain B', '', '', 'custom20', '', 'custom4', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000015', 'USER_3_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK User 2 KSC 1 Domain B', 'DOMAIN_B', 'PERSONAL', 'PPK User 1 KSC 1 Domain B', 'owner0815', 'ABCABC', 'cust2', 'cust3', 'cust4', 'orgl1', 'orgl2', 'orgl3', 'orgl4', false);
-- Workbaskets for sorting test
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000900', 'sort001', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basxet0', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000901', 'Sort002', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Basxet1', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000902', 'sOrt003', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'bAsxet2', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000903', 'soRt004', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'baSxet3', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000904', 'sorT005', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basXet4', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000905', 'Sort006', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basxEt5', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000906', 'SOrt007', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basxeT6', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000907', 'SoRt008', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'BAsxet7', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000908', 'SorT009', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'BaSxet8', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000909', 'Sort010', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'BasXet9', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000900', 'sort001', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basxet0', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000901', 'Sort002', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Basxet1', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000902', 'sOrt003', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'bAsxet2', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000903', 'soRt004', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'baSxet3', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000904', 'sorT005', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basXet4', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000905', 'Sort006', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basxEt5', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000906', 'SOrt007', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'basxeT6', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000907', 'SoRt008', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'BAsxet7', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000908', 'SorT009', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'BaSxet8', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', false);
INSERT INTO WORKBASKET VALUES ('0000000000000000000000000000000000000909', 'Sort010', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'BasXet9', 'DOM_XY', 'TOPIC', 'Lorem ipsum dolor sit amet.', 'Max', '', '', '', '', '', '', '', '', false);

View File

@ -1,5 +1,23 @@
package pro.taskana.doc.api;
import static org.junit.Assert.assertEquals;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath;
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@ -14,44 +32,31 @@ import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import pro.taskana.rest.RestConfiguration;
import static org.junit.Assert.assertEquals;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
public class WorkbasketControllerRestDocumentation {
@LocalServerPort
int port;
@Rule
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
@Autowired
private WebApplicationContext context;
private MockMvc mockMvc;
// HashMaps to store the field descriptions centrally for multiple uses
private HashMap<String, String> workbasketFieldDescriptionsMap = new HashMap<String, String>();
private HashMap<String, String> accessItemFieldDescriptionsMap = new HashMap<String, String>();
private FieldDescriptor[] allWorkbasketsFieldDescriptors;
private FieldDescriptor[] workbasketFieldDescriptors;
private FieldDescriptor[] workbasketSubsetFieldDescriptors;
@ -59,29 +64,31 @@ public class WorkbasketControllerRestDocumentation {
private FieldDescriptor[] accessItemFieldDescriptors;
private FieldDescriptor[] allDistributionTargetsFieldDescriptors;
private FieldDescriptor[] createWorkbasketFieldDescriptors;
@Before
public void setUp() {
document("{methodName}",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()));
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()));
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(springSecurity())
.apply(documentationConfiguration(this.restDocumentation)
.operationPreprocessors()
.withResponseDefaults(prettyPrint())
.withRequestDefaults(prettyPrint()))
.build();
.apply(springSecurity())
.apply(documentationConfiguration(this.restDocumentation)
.operationPreprocessors()
.withResponseDefaults(prettyPrint())
.withRequestDefaults(prettyPrint()))
.build();
workbasketFieldDescriptionsMap.put("workbasketId", "Unique ID");
workbasketFieldDescriptionsMap.put("key", "");
workbasketFieldDescriptionsMap.put("name", "The name of the workbasket");
workbasketFieldDescriptionsMap.put("domain", "");
workbasketFieldDescriptionsMap.put("type", "");
workbasketFieldDescriptionsMap.put("description", "The description of the workbasket");
workbasketFieldDescriptionsMap.put("owner", "The owner of the workbasket. The owner is responsible for the on-time completion of all tasks in the workbasket.");
workbasketFieldDescriptionsMap.put("orgLevel1", "The first Org Level (the top one)\nThe Org Level is an association with an org hierarchie level in the organization. The values are used for monitoring and statistical purposes and should reflect the responsibility of the tasks in the workbasket.");
workbasketFieldDescriptionsMap.put("owner",
"The owner of the workbasket. The owner is responsible for the on-time completion of all tasks in the workbasket.");
workbasketFieldDescriptionsMap.put("orgLevel1",
"The first Org Level (the top one)\nThe Org Level is an association with an org hierarchie level in the organization. The values are used for monitoring and statistical purposes and should reflect the responsibility of the tasks in the workbasket.");
workbasketFieldDescriptionsMap.put("orgLevel2", "The second Org Level");
workbasketFieldDescriptionsMap.put("orgLevel3", "The third Org Level");
workbasketFieldDescriptionsMap.put("orgLevel4", "The fourth Org Level (the lowest one).");
@ -91,20 +98,28 @@ public class WorkbasketControllerRestDocumentation {
workbasketFieldDescriptionsMap.put("custom2", "A custom property with name \"2\"");
workbasketFieldDescriptionsMap.put("custom3", "A custom property with name \"3\"");
workbasketFieldDescriptionsMap.put("custom4", "A custom property with name \"4\"");
workbasketFieldDescriptionsMap.put("_links.distributionTargets.href", "The Distribution-Targets of the workbasket");
workbasketFieldDescriptionsMap.put("_links.removeDistributionTargets.href", "Link to remove all distribution-targets from the workbasket");
workbasketFieldDescriptionsMap.put("_links.distributionTargets.href",
"The Distribution-Targets of the workbasket");
workbasketFieldDescriptionsMap.put("_links.removeDistributionTargets.href",
"Link to remove all distribution-targets from the workbasket");
workbasketFieldDescriptionsMap.put("_links.accessItems.href", "The Access-Items of the workbasket");
workbasketFieldDescriptionsMap.put("_links.allWorkbaskets.href", "Link to all workbaskets");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessItemId", "Unique ID");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.workbasketId", "The workbasket");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessId", "The access id, this ACL entry refers to. This could be either a userid or a full qualified group id (both lower case)");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessId",
"The access id, this ACL entry refers to. This could be either a userid or a full qualified group id (both lower case)");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessName", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permRead", "The permission to read the information about the workbasket");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permOpen", "The permission to view the content (the tasks) of a workbasket");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permAppend", "The permission to add tasks to the workbasket (required for creation and tranferring of tasks)");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permTransfer", "The permission to transfer tasks (out of the current workbasket)");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permDistribute", "The permission to distribute tasks from the workbasket");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permRead",
"The permission to read the information about the workbasket");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permOpen",
"The permission to view the content (the tasks) of a workbasket");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permAppend",
"The permission to add tasks to the workbasket (required for creation and tranferring of tasks)");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permTransfer",
"The permission to transfer tasks (out of the current workbasket)");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permDistribute",
"The permission to distribute tasks from the workbasket");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom1", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom2", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom3", "");
@ -117,214 +132,259 @@ public class WorkbasketControllerRestDocumentation {
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom10", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom11", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom12", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems._links.workbasket.href", "Link to the workbasket");
accessItemFieldDescriptionsMap.put("_embedded.accessItems._links.workbasket.href", "Link to the workbasket");
allWorkbasketsFieldDescriptors = new FieldDescriptor[] {
subsectionWithPath("_embedded.workbaskets").description("An Array of <<workbasket-subset, Workbasket-Subsets>>"),
fieldWithPath("_links.self.href").ignored(),
fieldWithPath("page").ignored()
subsectionWithPath("_embedded.workbaskets").description(
"An Array of <<workbasket-subset, Workbasket-Subsets>>"),
fieldWithPath("_links.self.href").ignored(),
fieldWithPath("page").ignored()
};
workbasketFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("workbasketId").description(workbasketFieldDescriptionsMap.get("workbasketId")),
fieldWithPath("key").description(workbasketFieldDescriptionsMap.get("key")),
fieldWithPath("created").description(workbasketFieldDescriptionsMap.get("created")),
fieldWithPath("modified").description(workbasketFieldDescriptionsMap.get("modified")),
fieldWithPath("name").description(workbasketFieldDescriptionsMap.get("name")),
fieldWithPath("description").description(workbasketFieldDescriptionsMap.get("description")),
fieldWithPath("owner").description(workbasketFieldDescriptionsMap.get("owner")),
fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")),
fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")),
fieldWithPath("custom1").description(workbasketFieldDescriptionsMap.get("custom1")),
fieldWithPath("custom2").description(workbasketFieldDescriptionsMap.get("custom2")),
fieldWithPath("custom3").description(workbasketFieldDescriptionsMap.get("custom3")),
fieldWithPath("custom4").description(workbasketFieldDescriptionsMap.get("custom4")),
fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1")),
fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")),
fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")),
fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")),
fieldWithPath("_links.distributionTargets.href").description(workbasketFieldDescriptionsMap.get("_links.distributionTargets.href")),
fieldWithPath("_links.removeDistributionTargets.href").description(workbasketFieldDescriptionsMap.get("_links.removeDistributionTargets.href")),
fieldWithPath("_links.accessItems.href").description(workbasketFieldDescriptionsMap.get("_links.accessItems.href")),
fieldWithPath("_links.allWorkbaskets.href").description(workbasketFieldDescriptionsMap.get("_links.allWorkbaskets.href")),
fieldWithPath("_links.self.href").ignored()
fieldWithPath("workbasketId").description(workbasketFieldDescriptionsMap.get("workbasketId")),
fieldWithPath("key").description(workbasketFieldDescriptionsMap.get("key")),
fieldWithPath("created").description(workbasketFieldDescriptionsMap.get("created")),
fieldWithPath("modified").description(workbasketFieldDescriptionsMap.get("modified")),
fieldWithPath("name").description(workbasketFieldDescriptionsMap.get("name")),
fieldWithPath("description").description(workbasketFieldDescriptionsMap.get("description")),
fieldWithPath("owner").description(workbasketFieldDescriptionsMap.get("owner")),
fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")),
fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")),
fieldWithPath("custom1").description(workbasketFieldDescriptionsMap.get("custom1")),
fieldWithPath("custom2").description(workbasketFieldDescriptionsMap.get("custom2")),
fieldWithPath("custom3").description(workbasketFieldDescriptionsMap.get("custom3")),
fieldWithPath("custom4").description(workbasketFieldDescriptionsMap.get("custom4")),
fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1")),
fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")),
fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")),
fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")),
fieldWithPath("_links.distributionTargets.href").description(
workbasketFieldDescriptionsMap.get("_links.distributionTargets.href")),
fieldWithPath("_links.removeDistributionTargets.href").description(
workbasketFieldDescriptionsMap.get("_links.removeDistributionTargets.href")),
fieldWithPath("_links.accessItems.href").description(
workbasketFieldDescriptionsMap.get("_links.accessItems.href")),
fieldWithPath("_links.allWorkbaskets.href").description(
workbasketFieldDescriptionsMap.get("_links.allWorkbaskets.href")),
fieldWithPath("_links.self.href").ignored()
};
workbasketSubsetFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("workbasketId").description(workbasketFieldDescriptionsMap.get("workbasketId")),
fieldWithPath("key").description(workbasketFieldDescriptionsMap.get("key")),
fieldWithPath("name").description(workbasketFieldDescriptionsMap.get("name")),
fieldWithPath("description").description(workbasketFieldDescriptionsMap.get("description")),
fieldWithPath("owner").description(workbasketFieldDescriptionsMap.get("owner")),
fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")),
fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")),
fieldWithPath("custom1").description(workbasketFieldDescriptionsMap.get("custom1")),
fieldWithPath("custom2").description(workbasketFieldDescriptionsMap.get("custom2")),
fieldWithPath("custom3").description(workbasketFieldDescriptionsMap.get("custom3")),
fieldWithPath("custom4").description(workbasketFieldDescriptionsMap.get("custom4")),
fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1")),
fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")),
fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")),
fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")),
fieldWithPath("created").ignored(),
fieldWithPath("modified").ignored(),
fieldWithPath("_links.distributionTargets.href").ignored(),
fieldWithPath("_links.removeDistributionTargets.href").ignored(),
fieldWithPath("_links.accessItems.href").ignored(),
fieldWithPath("_links.allWorkbaskets.href").ignored(),
fieldWithPath("_links.self.href").ignored()
fieldWithPath("workbasketId").description(workbasketFieldDescriptionsMap.get("workbasketId")),
fieldWithPath("key").description(workbasketFieldDescriptionsMap.get("key")),
fieldWithPath("name").description(workbasketFieldDescriptionsMap.get("name")),
fieldWithPath("description").description(workbasketFieldDescriptionsMap.get("description")),
fieldWithPath("owner").description(workbasketFieldDescriptionsMap.get("owner")),
fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")),
fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")),
fieldWithPath("custom1").description(workbasketFieldDescriptionsMap.get("custom1")),
fieldWithPath("custom2").description(workbasketFieldDescriptionsMap.get("custom2")),
fieldWithPath("custom3").description(workbasketFieldDescriptionsMap.get("custom3")),
fieldWithPath("custom4").description(workbasketFieldDescriptionsMap.get("custom4")),
fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1")),
fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")),
fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")),
fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")),
fieldWithPath("created").ignored(),
fieldWithPath("modified").ignored(),
fieldWithPath("_links.distributionTargets.href").ignored(),
fieldWithPath("_links.removeDistributionTargets.href").ignored(),
fieldWithPath("_links.accessItems.href").ignored(),
fieldWithPath("_links.allWorkbaskets.href").ignored(),
fieldWithPath("_links.self.href").ignored()
};
accessItemFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("_embedded.accessItems[].accessItemId").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessItemId")),
fieldWithPath("_embedded.accessItems[].workbasketId").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketId")),
fieldWithPath("_embedded.accessItems[].accessId").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessId")),
fieldWithPath("_embedded.accessItems[].accessName").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessName")),
fieldWithPath("_embedded.accessItems[].permRead").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permRead")),
fieldWithPath("_embedded.accessItems[].permOpen").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permOpen")),
fieldWithPath("_embedded.accessItems[].permAppend").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permAppend")),
fieldWithPath("_embedded.accessItems[].permTransfer").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permTransfer")),
fieldWithPath("_embedded.accessItems[].permDistribute").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permDistribute")),
fieldWithPath("_embedded.accessItems[].permCustom1").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom1")),
fieldWithPath("_embedded.accessItems[].permCustom2").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom2")),
fieldWithPath("_embedded.accessItems[].permCustom3").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom3")),
fieldWithPath("_embedded.accessItems[].permCustom4").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom4")),
fieldWithPath("_embedded.accessItems[].permCustom5").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom5")),
fieldWithPath("_embedded.accessItems[].permCustom6").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom6")),
fieldWithPath("_embedded.accessItems[].permCustom7").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom7")),
fieldWithPath("_embedded.accessItems[].permCustom8").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom8")),
fieldWithPath("_embedded.accessItems[].permCustom9").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom9")),
fieldWithPath("_embedded.accessItems[].permCustom10").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom10")),
fieldWithPath("_embedded.accessItems[].permCustom11").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom11")),
fieldWithPath("_embedded.accessItems[].permCustom12").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom12")),
fieldWithPath("_embedded.accessItems[]._links.workbasket.href").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems._links.workbasket.href")),
fieldWithPath("_links.self.href").ignored(),
fieldWithPath("_links.workbasket.href").ignored()
fieldWithPath("_embedded.accessItems[].accessItemId").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessItemId")),
fieldWithPath("_embedded.accessItems[].workbasketId").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketId")),
fieldWithPath("_embedded.accessItems[].accessId").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessId")),
fieldWithPath("_embedded.accessItems[].accessName").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessName")),
fieldWithPath("_embedded.accessItems[].permRead").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permRead")),
fieldWithPath("_embedded.accessItems[].permOpen").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permOpen")),
fieldWithPath("_embedded.accessItems[].permAppend").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permAppend")),
fieldWithPath("_embedded.accessItems[].permTransfer").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permTransfer")),
fieldWithPath("_embedded.accessItems[].permDistribute").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permDistribute")),
fieldWithPath("_embedded.accessItems[].permCustom1").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom1")),
fieldWithPath("_embedded.accessItems[].permCustom2").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom2")),
fieldWithPath("_embedded.accessItems[].permCustom3").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom3")),
fieldWithPath("_embedded.accessItems[].permCustom4").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom4")),
fieldWithPath("_embedded.accessItems[].permCustom5").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom5")),
fieldWithPath("_embedded.accessItems[].permCustom6").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom6")),
fieldWithPath("_embedded.accessItems[].permCustom7").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom7")),
fieldWithPath("_embedded.accessItems[].permCustom8").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom8")),
fieldWithPath("_embedded.accessItems[].permCustom9").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom9")),
fieldWithPath("_embedded.accessItems[].permCustom10").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom10")),
fieldWithPath("_embedded.accessItems[].permCustom11").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom11")),
fieldWithPath("_embedded.accessItems[].permCustom12").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom12")),
fieldWithPath("_embedded.accessItems[]._links.workbasket.href").description(
accessItemFieldDescriptionsMap.get("_embedded.accessItems._links.workbasket.href")),
fieldWithPath("_links.self.href").ignored(),
fieldWithPath("_links.workbasket.href").ignored()
};
allWorkbasketAccessItemsFieldDescriptors = new FieldDescriptor[] {
subsectionWithPath("_embedded.accessItems").description("An array of <<access-item, Access Items>>"),
fieldWithPath("_links.workbasket.href").description("Link to the workbasket"),
fieldWithPath("_links.self.href").ignored()
subsectionWithPath("_embedded.accessItems").description("An array of <<access-item, Access Items>>"),
fieldWithPath("_links.workbasket.href").description("Link to the workbasket"),
fieldWithPath("_links.self.href").ignored()
};
allDistributionTargetsFieldDescriptors = new FieldDescriptor[] {
subsectionWithPath("_embedded.distributionTargets").description("An array of <<workbasket-subset, workbasket subsets>>"),
fieldWithPath("_links.workbasket.href").description("Link to the workbasket"),
fieldWithPath("_links.self.href").ignored()
subsectionWithPath("_embedded.distributionTargets").description(
"An array of <<workbasket-subset, workbasket subsets>>"),
fieldWithPath("_links.workbasket.href").description("Link to the workbasket"),
fieldWithPath("_links.self.href").ignored()
};
createWorkbasketFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("key").description(workbasketFieldDescriptionsMap.get("key")),
fieldWithPath("name").description(workbasketFieldDescriptionsMap.get("name")),
fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")),
fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")),
fieldWithPath("description").description(workbasketFieldDescriptionsMap.get("description")).type("String").optional(),
fieldWithPath("owner").description(workbasketFieldDescriptionsMap.get("owner")).type("String").optional(),
fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1")).type("String").optional(),
fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")).type("String").optional(),
fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")).type("String").optional(),
fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")).type("String").optional(),
fieldWithPath("created").description(workbasketFieldDescriptionsMap.get("created")).type("String").optional(),
fieldWithPath("modified").description(workbasketFieldDescriptionsMap.get("modified")).type("String").optional(),
fieldWithPath("custom1").description(workbasketFieldDescriptionsMap.get("custom1")).type("String").optional(),
fieldWithPath("custom2").description(workbasketFieldDescriptionsMap.get("custom2")).type("String").optional(),
fieldWithPath("custom3").description(workbasketFieldDescriptionsMap.get("custom3")).type("String").optional(),
fieldWithPath("custom4").description(workbasketFieldDescriptionsMap.get("custom4")).type("String").optional(),
fieldWithPath("_links.distributionTargets.href").description(workbasketFieldDescriptionsMap.get("_links.distributionTargets.href")).type("String").optional(),
fieldWithPath("_links.removeDistributionTargets.href").description(workbasketFieldDescriptionsMap.get("_links.removeDistributionTargets.href")).type("String").optional(),
fieldWithPath("_links.accessItems.href").description(workbasketFieldDescriptionsMap.get("_links.accessItems.href")).type("String").optional(),
fieldWithPath("_links.allWorkbaskets.href").description(workbasketFieldDescriptionsMap.get("_links.allWorkbaskets.href")).type("String").optional()
fieldWithPath("key").description(workbasketFieldDescriptionsMap.get("key")),
fieldWithPath("name").description(workbasketFieldDescriptionsMap.get("name")),
fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")),
fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")),
fieldWithPath("description").description(workbasketFieldDescriptionsMap.get("description"))
.type("String").optional(),
fieldWithPath("owner").description(workbasketFieldDescriptionsMap.get("owner")).type("String").optional(),
fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1"))
.type("String").optional(),
fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2"))
.type("String").optional(),
fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3"))
.type("String").optional(),
fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4"))
.type("String").optional(),
fieldWithPath("created").description(workbasketFieldDescriptionsMap.get("created"))
.type("String").optional(),
fieldWithPath("modified").description(workbasketFieldDescriptionsMap.get("modified"))
.type("String").optional(),
fieldWithPath("custom1").description(workbasketFieldDescriptionsMap.get("custom1"))
.type("String").optional(),
fieldWithPath("custom2").description(workbasketFieldDescriptionsMap.get("custom2"))
.type("String").optional(),
fieldWithPath("custom3").description(workbasketFieldDescriptionsMap.get("custom3"))
.type("String").optional(),
fieldWithPath("custom4").description(workbasketFieldDescriptionsMap.get("custom4"))
.type("String").optional(),
fieldWithPath("_links.distributionTargets.href").description(
workbasketFieldDescriptionsMap.get("_links.distributionTargets.href")).type("String").optional(),
fieldWithPath("_links.removeDistributionTargets.href").description(
workbasketFieldDescriptionsMap.get("_links.removeDistributionTargets.href")).type("String").optional(),
fieldWithPath("_links.accessItems.href").description(
workbasketFieldDescriptionsMap.get("_links.accessItems.href")).type("String").optional(),
fieldWithPath("_links.allWorkbaskets.href").description(
workbasketFieldDescriptionsMap.get("_links.allWorkbaskets.href")).type("String").optional()
};
}
@Test
public void getAllWorkbasketsDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbaskets?type=PERSONAL")
this.mockMvc.perform(
RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbaskets?type=PERSONAL")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetAllWorkbasketsDocTest",
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetAllWorkbasketsDocTest",
responseFields(allWorkbasketsFieldDescriptors)));
}
@Test
public void getSpecificWorkbasketDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000001")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetSpecificWorkbasketDocTest",
this.mockMvc.perform(RestDocumentationRequestBuilders.get(
"http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000001")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetSpecificWorkbasketDocTest",
responseFields(workbasketFieldDescriptors)));
}
@Test
public void getAllWorkbasketAccessItemsDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000001/workbasketAccessItems")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetAllWorkbasketAccessItemsDocTest",
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port
+ "/v1/workbaskets/WBI:100000000000000000000000000000000001/workbasketAccessItems")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetAllWorkbasketAccessItemsDocTest",
responseFields(allWorkbasketAccessItemsFieldDescriptors)));
}
@Test
public void workbasketSubsetDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000001")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("WorkbasketSubset",
this.mockMvc.perform(RestDocumentationRequestBuilders.get(
"http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000001")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("WorkbasketSubset",
responseFields(workbasketSubsetFieldDescriptors)));
}
@Test
public void removeWorkbasketAsDistributionTargetDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.delete("http://127.0.0.1:" + port + "/v1/workbaskets/distribution-targets/WBI:100000000000000000000000000000000007")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAsDistributionTargetDocTest"));
this.mockMvc.perform(RestDocumentationRequestBuilders.delete("http://127.0.0.1:" + port
+ "/v1/workbaskets/distribution-targets/WBI:100000000000000000000000000000000007")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAsDistributionTargetDocTest"));
}
@Test
public void getAllWorkbasketDistributionTargets() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000002/distribution-targets")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetAllWorkbasketDistributionTargets",
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port
+ "/v1/workbaskets/WBI:100000000000000000000000000000000002/distribution-targets")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetAllWorkbasketDistributionTargets",
responseFields(allDistributionTargetsFieldDescriptors)));
}
@Test
public void createAndDeleteWorkbasketDocTest() throws Exception {
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders.post("http://127.0.0.1:" + port + "/v1/workbaskets")
.contentType("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.content("{\"key\" : \"asdasdasd\", \"name\" : \"Gruppenpostkorb KSC\", \"domain\" : \"DOMAIN_A\", \"type\" : \"GROUP\", \"created\" : \"2018-02-01T11:00:00Z\",\r\n" +
" \"modified\" : \"2018-02-01T11:00:00Z\"}"))
.andExpect(MockMvcResultMatchers.status().isCreated())
.andDo(MockMvcRestDocumentation.document("CreateWorkbasketDocTest",
public void createWorkbasketDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.post("http://127.0.0.1:" + port + "/v1/workbaskets")
.contentType("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.content(
"{\"key\" : \"asdasdasd\", \"name\" : \"Gruppenpostkorb KSC\", \"domain\" : \"DOMAIN_A\", \"type\" : \"GROUP\", \"created\" : \"2018-02-01T11:00:00Z\",\r\n"
+
" \"modified\" : \"2018-02-01T11:00:00Z\"}"))
.andExpect(MockMvcResultMatchers.status().isCreated())
.andDo(MockMvcRestDocumentation.document("CreateWorkbasketDocTest",
requestFields(createWorkbasketFieldDescriptors),
responseFields(workbasketFieldDescriptors)))
.andReturn();
String newId = result.getResponse().getContentAsString().substring(17, 57);
this.mockMvc.perform(RestDocumentationRequestBuilders.delete("http://127.0.0.1:" + port + "/v1/workbaskets/" + newId)
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("DeleteWorkbasketDocTest"));
.andReturn();
}
@Test public void updateWorkbasketDocTest() throws Exception {
@Test
public void updateWorkbasketDocTest() throws Exception {
URL url = new URL("http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000002");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
assertEquals(200, con.getResponseCode());
BufferedReader in = new BufferedReader(
@ -338,24 +398,35 @@ public class WorkbasketControllerRestDocumentation {
con.disconnect();
String originalWorkbasket = content.toString();
String modifiedWorkbasket = new String(originalWorkbasket.toString());
this.mockMvc.perform(RestDocumentationRequestBuilders.put("http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000002")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.contentType("application/json")
.content(modifiedWorkbasket))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("UpdateWorkbasketDocTest",
this.mockMvc.perform(RestDocumentationRequestBuilders.put(
"http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000002")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.contentType("application/json")
.content(modifiedWorkbasket))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("UpdateWorkbasketDocTest",
requestFields(workbasketFieldDescriptors),
responseFields(workbasketFieldDescriptors)));
}
@Test
public void markWorkbasketForDeletionDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.delete(
"http://127.0.0.1:" + port + "/v1/workbaskets/" + "WBI:100000000000000000000000000000000005")
.header("Authorization", "Basic YWRtaW46YWRtaW4="))
.andExpect(MockMvcResultMatchers.status().isAccepted())
.andDo(MockMvcRestDocumentation.document("MarkWorkbasketForDeletionDocTest"));
}
@Test
public void accessItemDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbaskets/WBI:100000000000000000000000000000000001/workbasketAccessItems")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("AccessItemsDocTest",
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port
+ "/v1/workbaskets/WBI:100000000000000000000000000000000001/workbasketAccessItems")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("AccessItemsDocTest",
responseFields(accessItemFieldDescriptors)));
}
}

View File

@ -165,7 +165,8 @@ public class AsyncUpdateJobIntTest {
}
private void verifyTaskIsModifiedAfter(String taskId, Instant before) throws InvalidArgumentException {
private void verifyTaskIsModifiedAfter(String taskId, Instant before)
throws InvalidArgumentException {
RestTemplate admTemplate = getRestTemplate();
HttpHeaders admHeaders = new HttpHeaders();
admHeaders.add("Authorization", "Basic YWRtaW46YWRtaW4="); // admin:admin

View File

@ -319,7 +319,8 @@ public class ClassificationControllerIntTest {
});
}
private void verifyTaskIsModifiedAfter(String taskId, Instant before) throws InvalidArgumentException {
private void verifyTaskIsModifiedAfter(String taskId, Instant before)
throws InvalidArgumentException {
RestTemplate admTemplate = getRestTemplate();
HttpHeaders admHeaders = new HttpHeaders();
admHeaders.add("Authorization", "Basic YWRtaW46YWRtaW4="); // admin:admin

View File

@ -19,7 +19,6 @@ import java.util.Collections;
import javax.sql.DataSource;
import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@ -222,7 +221,7 @@ public class TaskControllerIntTest {
@Test
public void testGetLastPageSortedByDueWithHiddenTasksRemovedFromResult() {
resetDb(); // required because ClassificationControllerIntTest.testGetQueryByPorSecondPageSortedByType changes
// tasks and this test depends on the tasks as they are in sampledata
// tasks and this test depends on the tasks as they are in sampledata
RestTemplate template = getRestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -262,7 +261,7 @@ public class TaskControllerIntTest {
@Test
public void testGetQueryByPorSecondPageSortedByType() {
resetDb(); // required because ClassificationControllerIntTest.testGetQueryByPorSecondPageSortedByType changes
// tasks and this test depends on the tasks as they are in sampledata
// tasks and this test depends on the tasks as they are in sampledata
RestTemplate template = getRestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
@ -292,7 +291,7 @@ public class TaskControllerIntTest {
assertNotNull(response.getBody().getLink(Link.REL_LAST));
assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
}
@Test
public void testGetTaskWithAttachments() throws IOException {
URL url = new URL("http://127.0.0.1:" + port + "/v1/tasks/TKI:000000000000000000000000000000000002");
@ -300,7 +299,7 @@ public class TaskControllerIntTest {
con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
assertEquals(200, con.getResponseCode());
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
@ -314,7 +313,8 @@ public class TaskControllerIntTest {
assertFalse(response.contains("\"attachments\":[]"));
int start = response.indexOf("created", response.indexOf("created") + 1);
String createdString = response.substring(start + 10, start + 30);
assertTrue(createdString.matches("\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z)"));
assertTrue(
createdString.matches("\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z)"));
}
@Test
@ -431,10 +431,11 @@ public class TaskControllerIntTest {
assertEquals(400, con.getResponseCode());
con.disconnect();
taskToCreateJson = "{\"classificationSummaryResource\":{\"classificationId\":\"CLI:100000000000000000000000000000000004\"},"
+
"\"workbasketSummaryResource\":{\"workbasketId\":\"\"}," +
"\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}";
taskToCreateJson =
"{\"classificationSummaryResource\":{\"classificationId\":\"CLI:100000000000000000000000000000000004\"},"
+
"\"workbasketSummaryResource\":{\"workbasketId\":\"\"}," +
"\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}";
url = new URL("http://127.0.0.1:" + port + "/v1/tasks");
con = (HttpURLConnection) url.openConnection();
@ -466,7 +467,7 @@ public class TaskControllerIntTest {
// converter.setSupportedMediaTypes(ImmutableList.of(MediaTypes.HAL_JSON));
converter.setObjectMapper(mapper);
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
return template;
}

View File

@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import pro.taskana.BaseQuery.SortDirection;
import pro.taskana.TaskService;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketAccessItem;
import pro.taskana.WorkbasketPermission;
@ -79,6 +80,9 @@ public class WorkbasketController extends AbstractPagingController {
@Autowired
private WorkbasketService workbasketService;
@Autowired
private TaskService taskService;
@Autowired
private WorkbasketResourceAssembler workbasketResourceAssembler;
@ -138,12 +142,14 @@ public class WorkbasketController extends AbstractPagingController {
}
@DeleteMapping(path = "/{workbasketId}")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<?> deleteWorkbasket(@PathVariable(value = "workbasketId") String workbasketId)
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
ResponseEntity<?> result = ResponseEntity.status(HttpStatus.NO_CONTENT).build();
workbasketService.deleteWorkbasket(workbasketId);
return result;
@Transactional(rollbackFor = Exception.class, noRollbackFor = WorkbasketNotFoundException.class)
public ResponseEntity<?> markWorkbasketForDeletion(@PathVariable(value = "workbasketId") String workbasketId)
throws NotAuthorizedException, InvalidArgumentException,
WorkbasketNotFoundException, WorkbasketInUseException {
if (!workbasketService.deleteWorkbasket(workbasketId)) {
return new ResponseEntity<>("It not possible to mark the workbasket for deletion", HttpStatus.BAD_REQUEST);
}
return ResponseEntity.status(HttpStatus.ACCEPTED).build();
}
@PostMapping

View File

@ -37,6 +37,7 @@ public class WorkbasketSummaryResource extends ResourceSupport {
public String orgLevel2;
public String orgLevel3;
public String orgLevel4;
private boolean markedForDeletion;
public String getWorkbasketId() {
return workbasketId;
@ -157,4 +158,12 @@ public class WorkbasketSummaryResource extends ResourceSupport {
public void setOrgLevel4(String orgLevel4) {
this.orgLevel4 = orgLevel4;
}
public boolean getMarkedForDeletion() {
return markedForDeletion;
}
public void setMarkedForDeletion(boolean markedForDeletion) {
this.markedForDeletion = markedForDeletion;
}
}

View File

@ -12,8 +12,8 @@ td > input[type="checkbox"] {
width: 200px;
}
.required-header:after {
content:" *";
content:" *";
color: red;
}

View File

@ -48,16 +48,16 @@ describe('DistributionTargetsComponent', () => {
return of(new WorkbasketSummaryResource(
{
'workbaskets': new Array<WorkbasketSummary>(
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', new Links({ 'href': 'someurl' })),
new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', new Links({ 'href': 'someurl' })),
new WorkbasketSummary('id3', '', '', '', '', '', '', '', '', '', '', '', new Links({ 'href': 'someurl' })))
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })),
new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })),
new WorkbasketSummary('id3', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })))
}, new LinksWorkbasketSummary({ 'href': 'someurl' })))
})
spyOn(workbasketService, 'getWorkBasketsDistributionTargets').and.callFake(() => {
return of(new WorkbasketDistributionTargetsResource(
{
'distributionTargets': new Array<WorkbasketSummary>(
new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', new Links({ 'href': 'someurl' })))
new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })))
}, new LinksWorkbasketSummary({ 'href': 'someurl' })))
})
component.ngOnChanges({
@ -96,7 +96,7 @@ describe('DistributionTargetsComponent', () => {
component.performFilter({ filterBy: new FilterModel({
name: 'someName', owner: 'someOwner', description: 'someDescription', key: 'someKey'}), side: Side.LEFT });
component.distributionTargetsLeft = new Array<WorkbasketSummary>(
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', new Links({ 'href': 'someurl' }))
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' }))
)
expect(component.distributionTargetsLeft.length).toBe(1);
expect(component.distributionTargetsLeft[0].workbasketId).toBe('id1');
@ -105,9 +105,9 @@ describe('DistributionTargetsComponent', () => {
});
it('should reset distribution target and distribution target selected on reset', () => {
component.distributionTargetsLeft.push(
new WorkbasketSummary('id4', '', '', '', '', '', '', '', '', '', '', '', new Links({ 'href': 'someurl' })));
new WorkbasketSummary('id4', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })));
component.distributionTargetsRight.push(
new WorkbasketSummary('id5', '', '', '', '', '', '', '', '', '', '', '', new Links({ 'href': 'someurl' })));
new WorkbasketSummary('id5', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })));
expect(component.distributionTargetsLeft.length).toBe(3);
expect(component.distributionTargetsRight.length).toBe(2);
@ -125,8 +125,8 @@ describe('DistributionTargetsComponent', () => {
return of(new WorkbasketDistributionTargetsResource(
{
'distributionTargets': new Array<WorkbasketSummary>(
new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', new Links({ 'href': 'someurl' })),
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', new Links({ 'href': 'someurl' })))
new WorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })),
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '', false, new Links({ 'href': 'someurl' })))
}, new LinksWorkbasketSummary({ 'href': 'someurl' })))
})
component.onSave();

View File

@ -273,31 +273,20 @@ export class WorkbasketInformationComponent
private onRemoveConfirmed() {
this.requestInProgressService.setRequestInProgress(true);
this.workbasketService
.deleteWorkbasket(this.workbasket._links.self.href)
.markWorkbasketForDeletion(
this.workbasket._links.self.href
)
.subscribe(
response => {
this.requestInProgressService.setRequestInProgress(false);
this.workbasketService.triggerWorkBasketSaved();
this.alertService.triggerAlert(
new AlertModel(
AlertType.SUCCESS,
`Workbasket ${
this.workbasket.workbasketId
} was removed successfully`
)
new AlertModel(AlertType.SUCCESS, 'The Workbasket ' + this.workbasket.workbasketId + ' has been marked for deletion')
);
this.router.navigate(['administration/workbaskets']);
},
error => {
this.requestInProgressService.setRequestInProgress(false);
this.errorModalService.triggerError(
new ErrorModel(
`There was an error deleting workbasket ${
this.workbasket.workbasketId
}`,
error
)
);
}
);
}

View File

@ -79,7 +79,7 @@ describe('WorkbasketDetailsComponent', () => {
{
'workbaskets': new Array<WorkbasketSummary>(
new WorkbasketSummary('id1', '', '', '', '', '', '', '', '', '', '', '',
new Links({ 'href': 'someurl' })))
false, new Links({ 'href': 'someurl' })))
}, new LinksWorkbasketSummary({ 'href': 'someurl' })))
})

View File

@ -56,15 +56,15 @@ describe('WorkbasketListToolbarComponent', () => {
configureTests(configure).then(testBed => {
fixture = TestBed.createComponent(WorkbasketListToolbarComponent);
workbasketService = TestBed.get(WorkbasketService);
router = TestBed.get(Router);
spyOn(workbasketService, 'deleteWorkbasket').and.returnValue(of(''));
router = TestBed.get(Router);
spyOn(workbasketService, 'markWorkbasketForDeletion').and.returnValue(of(''));
spyOn(workbasketService, 'triggerWorkBasketSaved');
debugElement = fixture.debugElement.nativeElement;
component = fixture.componentInstance;
component.workbaskets = new Array<WorkbasketSummary>(
new WorkbasketSummary('1', 'key1', 'NAME1', 'description 1', 'owner 1',
undefined, undefined, undefined, undefined, undefined, undefined, undefined, new Links({ 'href': 'selfLink' })));
undefined, undefined, undefined, undefined, undefined, undefined, undefined, false, new Links({ 'href': 'selfLink' })));
fixture.detectChanges();
done();

View File

@ -22,6 +22,9 @@
<dd data-toggle="tooltip" title="{{workbasket.description}}">{{workbasket.description}} &nbsp;</dd>
<dd data-toggle="tooltip" title="{{workbasket.owner}}">{{workbasket.owner}} &nbsp;</dd>
</dl>
<dl *ngIf="workbasket.markedForDeletion">
<span class="{{workbasket.workbasketId === selectedId ? 'white': 'red' }} glyphicon glyphicon-exclamation-sign" aria-hidden="true" data-toggle="tooltip" title="Marked for deletion"></span>
</dl>
</div>
</li>
</ul>
@ -35,4 +38,4 @@
</ng-template>
</div>
<taskana-pagination [(workbasketsResource)]="workbasketsResource" (changePage)="changePage($event)"></taskana-pagination>
</div>
</div>

View File

@ -1,4 +1,3 @@
.workbasket-list-full-height{
height: calc(100vh - 55px);
}

View File

@ -1,7 +1,7 @@
@import './src/assets/_variables';
.navbar.main:before {
@include degraded-bar(right, 100%, 5px)
@include degraded-bar(right, 100%, 3px)
}
.navbar-inverse {
@ -16,7 +16,7 @@
&.logout{
font-size: 20px;
}
}
button.navbar-toggle:hover > span{
color:$aquamarine;
@ -54,7 +54,8 @@ h2.navbar-brand{
bottom: 0;
top: 0;
z-index: 990;
background-color: grey;
opacity: 0.5;
}
.domain-form {
@ -84,7 +85,7 @@ h2.navbar-brand{
bottom: 5px;
font-size: 12px;
}
/*
* All side bar links styling.
*/
@ -111,9 +112,9 @@ h2.navbar-brand{
}
.navbar {
height: 50px;
height: 52px;
margin-bottom: 0px;
}
.menu,.submenu > span {
@ -129,7 +130,7 @@ h2.navbar-brand{
padding-left: 12px;
color: $grey;
outline: none;
}
.menu.selected,.submenu.selected {
background-color: transparent;
@ -140,7 +141,7 @@ h2.navbar-brand{
}
}
.menu > .submenu{
.menu > .submenu{
margin-left: 30px;
}

View File

@ -16,6 +16,7 @@ export class WorkbasketSummary {
public orgLevel2: string = undefined,
public orgLevel3: string = undefined,
public orgLevel4: string = undefined,
public markedForDeletion: boolean = false,
public _links: Links = undefined,
public page: Page = undefined) {
}

View File

@ -1,4 +1,3 @@
import { throwError as observableThrowError, Observable, Subject } from 'rxjs';
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@ -83,10 +82,11 @@ export class WorkbasketService {
.put<Workbasket>(url, workbasket).pipe(
catchError(this.handleError)
);
}
// DELETE
deleteWorkbasket(url: string) {
return this.httpClient.delete(url);
}
// delete
markWorkbasketForDeletion(url: string): Observable<any> {
return this.httpClient
.delete<any>(url);
}
// GET
getWorkBasketAccessItems(url: string): Observable<WorkbasketAccessItemsResource> {
@ -152,6 +152,5 @@ export class WorkbasketService {
return observableThrowError(errMsg);
}
// #endregion
}

View File

@ -13,8 +13,8 @@ import { tap } from 'rxjs/operators';
export class HttpClientInterceptor implements HttpInterceptor {
constructor(
private errorModalService: ErrorModalService,
private requestInProgressService: RequestInProgressService) {
private errorModalService: ErrorModalService,
private requestInProgressService: RequestInProgressService) {
}
@ -30,7 +30,10 @@ export class HttpClientInterceptor implements HttpInterceptor {
new ErrorModel('You have no access to this resource ', error));
} else if (error instanceof HttpErrorResponse && (error.status === 404) && error.url.indexOf('environment-information.json')) {
// ignore this error message
} else {
} if (error.status === 400 && error.error.indexOf('mark')) {
this.errorModalService.triggerError(
new ErrorModel('There was error marking workbasket for deletion', error.error))
} else {
this.errorModalService.triggerError(
new ErrorModel('There was error, please contact with your administrator ', error))
}

View File

@ -5,7 +5,7 @@ $dark-green: #175263;
$grey: grey;
$light-grey: #ddd;
$brown: #f0ad4e;
$invalid: #a94442;
$invalid: #d82626;
$aquamarine: #22a39f;
$pallete-blue: #36bcee;
$pallete-green: #5fbca1;

View File

@ -104,9 +104,9 @@
}
.red {
color: crimson;
color: $invalid;
& svg {
fill: crimson;
fill: $invalid;
}
}
@ -287,8 +287,8 @@ taskana-task-list{
box-shadow: none;
margin-bottom: 0px;
&> .panel-body {
height: calc(100vh - 108px);
max-height: calc(100vh - 108px);
height: calc(100vh - 155px);
max-height: calc(100vh - 155px);
overflow-y: auto;
}
}