TSK-147 Introduce Workbasket summary to be returned in lists and from all queries.
This commit is contained in:
parent
46fe48fd36
commit
dea6f498ed
|
@ -3,6 +3,7 @@ package pro.taskana;
|
|||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
import pro.taskana.model.WorkbasketSummary;
|
||||
import pro.taskana.model.WorkbasketType;
|
||||
|
||||
/**
|
||||
|
@ -126,7 +127,7 @@ public interface Workbasket {
|
|||
*
|
||||
* @return distributionTargets
|
||||
*/
|
||||
List<Workbasket> getDistributionTargets();
|
||||
List<WorkbasketSummary> getDistributionTargets();
|
||||
|
||||
/**
|
||||
* Sets the list of distribution targets for this workbasket.
|
||||
|
@ -134,5 +135,132 @@ public interface Workbasket {
|
|||
* @param distributionTargets
|
||||
* the distribution targets of the workbasket
|
||||
*/
|
||||
void setDistributionTargets(List<Workbasket> distributionTargets);
|
||||
void setDistributionTargets(List<WorkbasketSummary> distributionTargets);
|
||||
|
||||
/**
|
||||
* Return the value for the custom1 attribute.
|
||||
*
|
||||
* @return custom1
|
||||
*/
|
||||
String getCustom1();
|
||||
|
||||
/**
|
||||
* Sets the value for custom1 Attribute.
|
||||
*
|
||||
* @param custom1
|
||||
* the custom1 property of the workbasket
|
||||
*/
|
||||
void setCustom1(String custom1);
|
||||
|
||||
/**
|
||||
* Return the value for the custom2 attribute.
|
||||
*
|
||||
* @return custom2
|
||||
*/
|
||||
String getCustom2();
|
||||
|
||||
/**
|
||||
* Sets the value for custom2 attribute.
|
||||
*
|
||||
* @param custom2
|
||||
* the custom2 property of the workbasket
|
||||
*/
|
||||
void setCustom2(String custom2);
|
||||
|
||||
/**
|
||||
* Return the value for the custom3 attribute.
|
||||
*
|
||||
* @return custom3
|
||||
*/
|
||||
String getCustom3();
|
||||
|
||||
/**
|
||||
* Sets the value for custom3 attribute.
|
||||
*
|
||||
* @param custom3
|
||||
* the custom3 property of the workbasket
|
||||
*/
|
||||
void setCustom3(String custom3);
|
||||
|
||||
/**
|
||||
* Return the value for the custom4 attribute.
|
||||
*
|
||||
* @return custom4
|
||||
*/
|
||||
String getCustom4();
|
||||
|
||||
/**
|
||||
* Sets the value for custom4 attribute.
|
||||
*
|
||||
* @param custom4
|
||||
* the custom4 property of the workbasket
|
||||
*/
|
||||
void setCustom4(String custom4);
|
||||
|
||||
/**
|
||||
* Return the value for the orgLevel1 attribute.
|
||||
*
|
||||
* @return orgLevel1
|
||||
*/
|
||||
String getOrgLevel1();
|
||||
|
||||
/**
|
||||
* Sets the value for orgLevel1 attribute.
|
||||
*
|
||||
* @param orgLevel1
|
||||
* the orgLevel1 property of the workbasket
|
||||
*/
|
||||
void setOrgLevel1(String orgLevel1);
|
||||
|
||||
/**
|
||||
* Return the value for the orgLevel2 attribute.
|
||||
*
|
||||
* @return orgLevel2
|
||||
*/
|
||||
String getOrgLevel2();
|
||||
|
||||
/**
|
||||
* Sets the value for orgLevel2 attribute.
|
||||
*
|
||||
* @param orgLevel2
|
||||
* the orgLevel2 property of the workbasket
|
||||
*/
|
||||
void setOrgLevel2(String orgLevel2);
|
||||
|
||||
/**
|
||||
* Return the value for the orgLevel3 attribute.
|
||||
*
|
||||
* @return orgLevel3
|
||||
*/
|
||||
String getOrgLevel3();
|
||||
|
||||
/**
|
||||
* Sets the value for orgLevel3 attribute.
|
||||
*
|
||||
* @param orgLevel3
|
||||
* the orgLevel3 property of the workbasket
|
||||
*/
|
||||
void setOrgLevel3(String orgLevel3);
|
||||
|
||||
/**
|
||||
* Return the value for the orgLevel4 attribute.
|
||||
*
|
||||
* @return orgLevel4
|
||||
*/
|
||||
String getOrgLevel4();
|
||||
|
||||
/**
|
||||
* Sets the value for orgLevel4 attribute.
|
||||
*
|
||||
* @param orgLevel4
|
||||
* the orgLevel4 property of the workbasket
|
||||
*/
|
||||
void setOrgLevel4(String orgLevel4);
|
||||
|
||||
/**
|
||||
* Return a summary of the current workbasket.
|
||||
*
|
||||
* @return the WorkbasketSummary object for the current work basket
|
||||
*/
|
||||
WorkbasketSummary asSummary();
|
||||
}
|
||||
|
|
|
@ -4,12 +4,13 @@ import java.util.Date;
|
|||
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
import pro.taskana.model.WorkbasketSummary;
|
||||
import pro.taskana.model.WorkbasketType;
|
||||
|
||||
/**
|
||||
* WorkitemQuery for generating dynamic sql.
|
||||
*/
|
||||
public interface WorkbasketQuery extends BaseQuery<Workbasket> {
|
||||
public interface WorkbasketQuery extends BaseQuery<WorkbasketSummary> {
|
||||
|
||||
/**
|
||||
* Add your keys to your query.
|
||||
|
|
|
@ -7,6 +7,7 @@ import pro.taskana.exceptions.NotAuthorizedException;
|
|||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.WorkbasketAccessItem;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
import pro.taskana.model.WorkbasketSummary;
|
||||
|
||||
/**
|
||||
* This service manages Workbaskets.
|
||||
|
@ -44,9 +45,9 @@ public interface WorkbasketService {
|
|||
/**
|
||||
* Get all available Workbaskets without checking any permission.
|
||||
*
|
||||
* @return a list containing all Workbaskets
|
||||
* @return a list containing all Workbasket Summaries
|
||||
*/
|
||||
List<Workbasket> getWorkbaskets();
|
||||
List<WorkbasketSummary> getWorkbaskets();
|
||||
|
||||
/**
|
||||
* Create a new Workbasket.
|
||||
|
@ -143,6 +144,16 @@ public interface WorkbasketService {
|
|||
*/
|
||||
List<WorkbasketAccessItem> getWorkbasketAuthorizations(String workbasketKey);
|
||||
|
||||
/**
|
||||
* This method returns the workbaskets for which the current user has all permissions specified in the permissions
|
||||
* list.
|
||||
*
|
||||
* @param permission
|
||||
* a List of WorkbasketAuthorization enums
|
||||
* @return the summaries of all Workbaskets for which the current user has the specified authorizations
|
||||
*/
|
||||
List<WorkbasketSummary> getWorkbaskets(List<WorkbasketAuthorization> permission);
|
||||
|
||||
/**
|
||||
* This method provides a query builder for querying the database.
|
||||
*
|
||||
|
@ -157,13 +168,4 @@ public interface WorkbasketService {
|
|||
*/
|
||||
Workbasket newWorkbasket();
|
||||
|
||||
/**
|
||||
* This method returns the workbaskets for which the current user has all permissions specified in the permissions
|
||||
* list.
|
||||
*
|
||||
* @param permissions
|
||||
* a List of WorkbasketAuthorization enums
|
||||
* @return all Workbaskets for which the current user has the specified authorizations
|
||||
*/
|
||||
List<Workbasket> getWorkbaskets(List<WorkbasketAuthorization> permissions);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.model.WorkbasketSummary;
|
||||
import pro.taskana.model.WorkbasketType;
|
||||
|
||||
/**
|
||||
|
@ -21,7 +22,7 @@ public class WorkbasketImpl implements Workbasket {
|
|||
private String owner;
|
||||
private String domain;
|
||||
private WorkbasketType type;
|
||||
private List<Workbasket> distributionTargets = new ArrayList<>();
|
||||
private List<WorkbasketSummary> distributionTargets = new ArrayList<>();
|
||||
private String custom1;
|
||||
private String custom2;
|
||||
private String custom3;
|
||||
|
@ -122,79 +123,112 @@ public class WorkbasketImpl implements Workbasket {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Workbasket> getDistributionTargets() {
|
||||
public List<WorkbasketSummary> getDistributionTargets() {
|
||||
return distributionTargets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDistributionTargets(List<Workbasket> distributionTargets) {
|
||||
public void setDistributionTargets(List<WorkbasketSummary> distributionTargets) {
|
||||
this.distributionTargets = distributionTargets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustom1() {
|
||||
return custom1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustom1(String custom1) {
|
||||
this.custom1 = custom1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustom2() {
|
||||
return custom2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustom2(String custom2) {
|
||||
this.custom2 = custom2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustom3() {
|
||||
return custom3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustom3(String custom3) {
|
||||
this.custom3 = custom3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustom4() {
|
||||
return custom4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustom4(String custom4) {
|
||||
this.custom4 = custom4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOrgLevel1() {
|
||||
return orgLevel1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrgLevel1(String orgLevel1) {
|
||||
this.orgLevel1 = orgLevel1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOrgLevel2() {
|
||||
return orgLevel2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrgLevel2(String orgLevel2) {
|
||||
this.orgLevel2 = orgLevel2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOrgLevel3() {
|
||||
return orgLevel3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrgLevel3(String orgLevel3) {
|
||||
this.orgLevel3 = orgLevel3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOrgLevel4() {
|
||||
return orgLevel4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrgLevel4(String orgLevel4) {
|
||||
this.orgLevel4 = orgLevel4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkbasketSummary asSummary() {
|
||||
WorkbasketSummary result = new WorkbasketSummary();
|
||||
result.setId(this.getId());
|
||||
result.setKey(this.getKey());
|
||||
result.setName(this.getName());
|
||||
result.setDescription(this.getDescription());
|
||||
result.setOwner(this.getOwner());
|
||||
result.setDomain(this.getDomain());
|
||||
result.setType(this.getType());
|
||||
result.setOrgLevel1(this.getOrgLevel1());
|
||||
result.setOrgLevel2(this.getOrgLevel2());
|
||||
result.setOrgLevel3(this.getOrgLevel3());
|
||||
result.setOrgLevel4(this.getOrgLevel4());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
@ -237,4 +271,5 @@ public class WorkbasketImpl implements Workbasket {
|
|||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,12 +9,12 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketQuery;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.impl.util.LoggerUtils;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
import pro.taskana.model.WorkbasketSummary;
|
||||
import pro.taskana.model.WorkbasketType;
|
||||
import pro.taskana.model.mappings.WorkbasketAccessMapper;
|
||||
import pro.taskana.security.CurrentUserContext;
|
||||
|
@ -130,18 +130,17 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
String[] accessIds;
|
||||
// Check pre-conditions
|
||||
if (permission == null) {
|
||||
throw new InvalidArgumentException("Permission can´t be null.");
|
||||
throw new InvalidArgumentException("Permission cannot be null.");
|
||||
}
|
||||
if (CurrentUserContext.getAccessIds() != null && CurrentUserContext.getAccessIds().size() > 0) {
|
||||
accessIds = new String[CurrentUserContext.getAccessIds().size()];
|
||||
accessIds = CurrentUserContext.getAccessIds().toArray(accessIds);
|
||||
List<String> ucAccessIds = CurrentUserContext.getAccessIds();
|
||||
if (ucAccessIds != null && ucAccessIds.size() > 0) {
|
||||
accessIds = new String[ucAccessIds.size()];
|
||||
accessIds = ucAccessIds.toArray(accessIds);
|
||||
} else {
|
||||
throw new InvalidArgumentException("CurrentUserContext need to have at least one accessId.");
|
||||
}
|
||||
|
||||
// set up permissions and ids
|
||||
accessIds = new String[CurrentUserContext.getAccessIds().size()];
|
||||
accessIds = CurrentUserContext.getAccessIds().toArray(accessIds);
|
||||
this.authorization = permission;
|
||||
this.accessId = accessIds;
|
||||
lowercaseAccessIds();
|
||||
|
@ -150,9 +149,9 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Workbasket> list() {
|
||||
public List<WorkbasketSummary> list() {
|
||||
LOGGER.debug("entry to list(), this = {}", this);
|
||||
List<Workbasket> workbaskets = null;
|
||||
List<WorkbasketSummary> workbaskets = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
workbaskets = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this);
|
||||
|
@ -168,9 +167,9 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Workbasket> list(int offset, int limit) {
|
||||
public List<WorkbasketSummary> list(int offset, int limit) {
|
||||
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
|
||||
List<Workbasket> workbaskets = null;
|
||||
List<WorkbasketSummary> workbaskets = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
RowBounds rowBounds = new RowBounds(offset, limit);
|
||||
|
@ -187,9 +186,9 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Workbasket single() {
|
||||
public WorkbasketSummary single() {
|
||||
LOGGER.debug("entry to single(), this = {}", this);
|
||||
WorkbasketImpl workbasket = null;
|
||||
WorkbasketSummary workbasket = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
workbasket = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this);
|
||||
|
@ -204,98 +203,50 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
return accessId;
|
||||
}
|
||||
|
||||
public void setAccessId(String[] accessId) {
|
||||
this.accessId = accessId;
|
||||
}
|
||||
|
||||
public WorkbasketAuthorization getAuthorization() {
|
||||
return authorization;
|
||||
}
|
||||
|
||||
public void setAuthorization(WorkbasketAuthorization authorization) {
|
||||
this.authorization = authorization;
|
||||
}
|
||||
|
||||
public String[] getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String[] name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String[] getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String[] key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String[] getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(String[] domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public WorkbasketType[] getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(WorkbasketType[] type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Date getCreatedAfter() {
|
||||
return createdAfter;
|
||||
}
|
||||
|
||||
public void setCreatedAfter(Date createdAfter) {
|
||||
this.createdAfter = createdAfter;
|
||||
}
|
||||
|
||||
public Date getCreatedBefore() {
|
||||
return createdBefore;
|
||||
}
|
||||
|
||||
public void setCreatedBefore(Date createdBefore) {
|
||||
this.createdBefore = createdBefore;
|
||||
}
|
||||
|
||||
public Date getModifiedAfter() {
|
||||
return modifiedAfter;
|
||||
}
|
||||
|
||||
public void setModifiedAfter(Date modifiedAfter) {
|
||||
this.modifiedAfter = modifiedAfter;
|
||||
}
|
||||
|
||||
public Date getModifiedBefore() {
|
||||
return modifiedBefore;
|
||||
}
|
||||
|
||||
public void setModifiedBefore(Date modifiedBefore) {
|
||||
this.modifiedBefore = modifiedBefore;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String[] getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String[] owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
|
|
@ -20,6 +20,7 @@ import pro.taskana.impl.util.IdGenerator;
|
|||
import pro.taskana.impl.util.LoggerUtils;
|
||||
import pro.taskana.model.WorkbasketAccessItem;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
import pro.taskana.model.WorkbasketSummary;
|
||||
import pro.taskana.model.mappings.DistributionTargetMapper;
|
||||
import pro.taskana.model.mappings.WorkbasketAccessMapper;
|
||||
import pro.taskana.model.mappings.WorkbasketMapper;
|
||||
|
@ -96,19 +97,19 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Workbasket> getWorkbaskets(List<WorkbasketAuthorization> permissions) {
|
||||
public List<WorkbasketSummary> getWorkbaskets(List<WorkbasketAuthorization> permissions) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("entry to getWorkbaskets(permissions = {})", LoggerUtils.listToString(permissions));
|
||||
}
|
||||
List<Workbasket> result = null;
|
||||
List<WorkbasketSummary> result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
// use a set to avoid duplicates
|
||||
Set<Workbasket> workbaskets = new HashSet<>();
|
||||
Set<WorkbasketSummary> workbaskets = new HashSet<>();
|
||||
for (String accessId : CurrentUserContext.getAccessIds()) {
|
||||
workbaskets.addAll(workbasketMapper.findByPermission(permissions, accessId));
|
||||
}
|
||||
result = new ArrayList<Workbasket>();
|
||||
result = new ArrayList<WorkbasketSummary>();
|
||||
result.addAll(workbaskets);
|
||||
return result;
|
||||
} finally {
|
||||
|
@ -122,13 +123,12 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Workbasket> getWorkbaskets() {
|
||||
public List<WorkbasketSummary> getWorkbaskets() {
|
||||
LOGGER.debug("entry to getWorkbaskets()");
|
||||
List<Workbasket> workbaskets = new ArrayList<>();
|
||||
List<WorkbasketSummary> workbaskets = new ArrayList<>();
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
List<WorkbasketImpl> results = workbasketMapper.findAll();
|
||||
results.stream().forEach(w -> workbaskets.add(w));
|
||||
workbaskets = workbasketMapper.findAll();
|
||||
return workbaskets;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
|
@ -159,7 +159,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
workbasketMapper.insert(workbasket);
|
||||
LOGGER.debug("Method createWorkbasket() created Workbasket '{}'", workbasket);
|
||||
if (workbasket.getDistributionTargets() != null) {
|
||||
for (Workbasket distributionTarget : workbasket.getDistributionTargets()) {
|
||||
for (WorkbasketSummary distributionTarget : workbasket.getDistributionTargets()) {
|
||||
// validate that all distribution targets exist
|
||||
this.getWorkbasket(distributionTarget.getId());
|
||||
distributionTargetMapper.insert(workbasket.getId(), distributionTarget.getId());
|
||||
|
@ -188,8 +188,8 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
workbasketMapper.update(workbasket);
|
||||
LOGGER.debug("Method updateWorkbasket() updated workbasket '{}'", workbasket.getId());
|
||||
List<String> oldDistributionTargets = distributionTargetMapper.findBySourceId(workbasket.getId());
|
||||
List<Workbasket> newDistributionTargets = workbasket.getDistributionTargets();
|
||||
for (Workbasket distributionTarget : newDistributionTargets) {
|
||||
List<WorkbasketSummary> newDistributionTargets = workbasket.getDistributionTargets();
|
||||
for (WorkbasketSummary distributionTarget : newDistributionTargets) {
|
||||
if (!oldDistributionTargets.contains(distributionTarget.getId())) {
|
||||
// check that old distribution target exists
|
||||
getWorkbasket(distributionTarget.getId());
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
package pro.taskana.model;
|
||||
|
||||
/**
|
||||
* This entity contains the most important information about a workbasket.
|
||||
*
|
||||
* @author bbr
|
||||
*/
|
||||
public class WorkbasketSummary {
|
||||
|
||||
private String id;
|
||||
private String key;
|
||||
private String name;
|
||||
private String description;
|
||||
private String owner;
|
||||
private String domain;
|
||||
private WorkbasketType type;
|
||||
private String orgLevel1;
|
||||
private String orgLevel2;
|
||||
private String orgLevel3;
|
||||
private String orgLevel4;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public WorkbasketType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(WorkbasketType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getOrgLevel1() {
|
||||
return orgLevel1;
|
||||
}
|
||||
|
||||
public void setOrgLevel1(String orgLevel1) {
|
||||
this.orgLevel1 = orgLevel1;
|
||||
}
|
||||
|
||||
public String getOrgLevel2() {
|
||||
return orgLevel2;
|
||||
}
|
||||
|
||||
public void setOrgLevel2(String orgLevel2) {
|
||||
this.orgLevel2 = orgLevel2;
|
||||
}
|
||||
|
||||
public String getOrgLevel3() {
|
||||
return orgLevel3;
|
||||
}
|
||||
|
||||
public void setOrgLevel3(String orgLevel3) {
|
||||
this.orgLevel3 = orgLevel3;
|
||||
}
|
||||
|
||||
public String getOrgLevel4() {
|
||||
return orgLevel4;
|
||||
}
|
||||
|
||||
public void setOrgLevel4(String orgLevel4) {
|
||||
this.orgLevel4 = orgLevel4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("WorkbasketSummary [id=");
|
||||
builder.append(id);
|
||||
builder.append(", key=");
|
||||
builder.append(key);
|
||||
builder.append(", name=");
|
||||
builder.append(name);
|
||||
builder.append(", description=");
|
||||
builder.append(description);
|
||||
builder.append(", owner=");
|
||||
builder.append(owner);
|
||||
builder.append(", domain=");
|
||||
builder.append(domain);
|
||||
builder.append(", type=");
|
||||
builder.append(type);
|
||||
builder.append(", orgLevel1=");
|
||||
builder.append(orgLevel1);
|
||||
builder.append(", orgLevel2=");
|
||||
builder.append(orgLevel2);
|
||||
builder.append(", orgLevel3=");
|
||||
builder.append(orgLevel3);
|
||||
builder.append(", orgLevel4=");
|
||||
builder.append(orgLevel4);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,6 @@ package pro.taskana.model.mappings;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Many;
|
||||
import org.apache.ibatis.annotations.Result;
|
||||
import org.apache.ibatis.annotations.Results;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
@ -12,9 +11,9 @@ import pro.taskana.impl.ClassificationQueryImpl;
|
|||
import pro.taskana.impl.ObjectReferenceQueryImpl;
|
||||
import pro.taskana.impl.TaskImpl;
|
||||
import pro.taskana.impl.TaskQueryImpl;
|
||||
import pro.taskana.impl.WorkbasketImpl;
|
||||
import pro.taskana.impl.WorkbasketQueryImpl;
|
||||
import pro.taskana.model.ObjectReference;
|
||||
import pro.taskana.model.WorkbasketSummary;
|
||||
|
||||
/**
|
||||
* This class provides a mapper for all queries.
|
||||
|
@ -149,7 +148,7 @@ public interface QueryMapper {
|
|||
@Result(property = "value", column = "VALUE") })
|
||||
List<ObjectReference> queryObjectReference(ObjectReferenceQueryImpl objectReference);
|
||||
|
||||
@Select("<script>SELECT w.ID, w.KEY, w.CREATED, w.MODIFIED, 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 "
|
||||
@Select("<script>SELECT w.ID, w.KEY, w.NAME, w.DOMAIN, W.TYPE, w.DESCRIPTION, w.OWNER, w.ORG_LEVEL_1, w.ORG_LEVEL_2, w.ORG_LEVEL_3, w.ORG_LEVEL_4 from WORKBASKET w "
|
||||
+ "<if test='accessId != null'>LEFT OUTER JOIN WORKBASKET_ACCESS_LIST a on w.KEY = a.WORKBASKET_KEY</if> "
|
||||
+ "<where>"
|
||||
+ "<if test='owner != null'>AND w.OWNER IN(<foreach item='item' collection='owner' separator=',' >#{item}</foreach>)</if> "
|
||||
|
@ -184,31 +183,14 @@ public interface QueryMapper {
|
|||
@Result(property = "id", column = "ID"),
|
||||
@Result(property = "key", column = "KEY"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "modified", column = "MODIFIED"),
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "owner", column = "OWNER"),
|
||||
@Result(property = "distributionTargets", column = "id", javaType = List.class,
|
||||
many = @Many(select = "findDistributionTargets")),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
@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") })
|
||||
List<WorkbasketImpl> queryWorkbasket(WorkbasketQueryImpl workbasketQuery);
|
||||
|
||||
@Select("<script>SELECT TARGET_ID from DISTRIBUTION_TARGETS "
|
||||
+ "<where>"
|
||||
+ "SOURCE_ID = #{sourceId}"
|
||||
+ "</where>"
|
||||
+ "</script>")
|
||||
@Results(value = {
|
||||
@Result(property = "distributionTarget", column = "TARGET_ID") })
|
||||
List<String> findDistributionTargets(String sourceId);
|
||||
List<WorkbasketSummary> queryWorkbasket(WorkbasketQueryImpl workbasketQuery);
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.apache.ibatis.mapping.FetchType;
|
|||
|
||||
import pro.taskana.impl.WorkbasketImpl;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
import pro.taskana.model.WorkbasketSummary;
|
||||
|
||||
/**
|
||||
* This class is the mybatis mapping of workbaskets.
|
||||
|
@ -37,12 +38,10 @@ public interface WorkbasketMapper {
|
|||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10") })
|
||||
@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")})
|
||||
WorkbasketImpl findById(@Param("id") String id);
|
||||
|
||||
@Select("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 KEY = #{key}")
|
||||
|
@ -61,65 +60,46 @@ public interface WorkbasketMapper {
|
|||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10") })
|
||||
|
||||
@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")})
|
||||
WorkbasketImpl findByKey(@Param("key") String key);
|
||||
|
||||
@Select("SELECT * FROM WORKBASKET WHERE id IN (SELECT TARGET_ID FROM DISTRIBUTION_TARGETS WHERE SOURCE_ID = #{id})")
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "ID"),
|
||||
@Result(property = "key", column = "KEY"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "modified", column = "MODIFIED"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "owner", column = "OWNER"),
|
||||
@Result(property = "distributionTargets", column = "ID", javaType = List.class,
|
||||
many = @Many(fetchType = FetchType.DEFAULT, select = "findByDistributionTargets")),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10") })
|
||||
List<WorkbasketImpl> findByDistributionTargets(@Param("id") String id);
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
|
||||
@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")})
|
||||
|
||||
List<WorkbasketSummary> findByDistributionTargets(@Param("id") String id);
|
||||
|
||||
@Select("SELECT * FROM WORKBASKET ORDER BY id")
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "ID"),
|
||||
@Result(property = "key", column = "KEY"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "modified", column = "MODIFIED"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "owner", column = "OWNER"),
|
||||
@Result(property = "distributionTargets", column = "ID", javaType = List.class,
|
||||
many = @Many(fetchType = FetchType.DEFAULT, select = "findByDistributionTargets")),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10") })
|
||||
List<WorkbasketImpl> findAll();
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
@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")})
|
||||
List<WorkbasketSummary> findAll();
|
||||
|
||||
@Select("<script>SELECT W.ID, W.KEY, W.CREATED, W.MODIFIED, W.NAME, W.DESCRIPTION, W.OWNER FROM WORKBASKET AS W "
|
||||
@Select("<script>SELECT W.ID, W.KEY, W.NAME, W.DESCRIPTION, W.OWNER, W.DOMAIN, W.TYPE, W.ORG_LEVEL_1, W.ORG_LEVEL_2, W.ORG_LEVEL_3, W.ORG_LEVEL_4 FROM WORKBASKET AS W "
|
||||
+ "INNER JOIN WORKBASKET_ACCESS_LIST AS ACL "
|
||||
+ "ON (W.KEY = ACL.WORKBASKET_KEY AND ACL.ACCESS_ID = #{accessId}) "
|
||||
+ "WHERE <foreach collection='authorizations' item='authorization' separator=' AND '>"
|
||||
|
@ -140,26 +120,18 @@ public interface WorkbasketMapper {
|
|||
@Results(value = {
|
||||
@Result(property = "id", column = "ID"),
|
||||
@Result(property = "key", column = "KEY"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "modified", column = "MODIFIED"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "owner", column = "OWNER"),
|
||||
@Result(property = "distributionTargets", column = "ID", javaType = List.class,
|
||||
many = @Many(fetchType = FetchType.DEFAULT, select = "findByDistributionTargets")),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10") })
|
||||
List<WorkbasketImpl> findByPermission(@Param("authorizations") List<WorkbasketAuthorization> authorizations,
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
|
||||
@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")})
|
||||
List<WorkbasketSummary> findByPermission(@Param("authorizations") List<WorkbasketAuthorization> authorizations,
|
||||
@Param("accessId") String accessId);
|
||||
|
||||
@Insert("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})")
|
||||
|
|
|
@ -10,12 +10,12 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
|
||||
import acceptance.AbstractAccTest;
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.SystemException;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
import pro.taskana.model.WorkbasketSummary;
|
||||
import pro.taskana.security.JAASRunner;
|
||||
import pro.taskana.security.WithAccessId;
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
|
|||
public void testQueryAllTransferTargetsForUser()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
List<Workbasket> results = workbasketService.createWorkbasketQuery()
|
||||
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
|
||||
.accessIdsHavePersmission(WorkbasketAuthorization.APPEND, "user_1_1")
|
||||
.list();
|
||||
Assert.assertEquals(1L, results.size());
|
||||
|
@ -44,7 +44,7 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
|
|||
public void testQueryAllTransferTargetsForUserAndGroup()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
List<Workbasket> results = workbasketService.createWorkbasketQuery()
|
||||
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
|
||||
.accessIdsHavePersmission(WorkbasketAuthorization.APPEND, "user_1_1", "group_1")
|
||||
.list();
|
||||
Assert.assertEquals(8L, results.size());
|
||||
|
@ -57,7 +57,7 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
|
|||
public void testQueryAllTransferTargetsForUserAndGroupFromSubject()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
List<Workbasket> results = workbasketService.createWorkbasketQuery()
|
||||
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
|
||||
.callerHasPermission(WorkbasketAuthorization.APPEND)
|
||||
.list();
|
||||
Assert.assertEquals(8L, results.size());
|
||||
|
@ -69,7 +69,7 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
|
|||
public void testQueryAllAvailableWorkbasketForOpeningForUserAndGroupFromSubject()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
List<Workbasket> results = workbasketService.createWorkbasketQuery()
|
||||
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
|
||||
.callerHasPermission(WorkbasketAuthorization.READ)
|
||||
.list();
|
||||
Assert.assertEquals(1L, results.size());
|
||||
|
|
|
@ -31,6 +31,7 @@ import pro.taskana.exceptions.InvalidWorkbasketException;
|
|||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
import pro.taskana.model.WorkbasketSummary;
|
||||
import pro.taskana.model.WorkbasketType;
|
||||
import pro.taskana.model.mappings.DistributionTargetMapper;
|
||||
import pro.taskana.model.mappings.WorkbasketAccessMapper;
|
||||
|
@ -147,6 +148,7 @@ public class WorkbasketServiceImplTest {
|
|||
taskanaEngineImplMock, taskanaEngineConfigurationMock);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
|
@ -176,7 +178,6 @@ public class WorkbasketServiceImplTest {
|
|||
doReturn(wb).when(workbasketMapperMock).findByKey(wbKey);
|
||||
|
||||
Workbasket actualWb = cutSpy.getWorkbasketByKey(wbKey);
|
||||
|
||||
verify(taskanaEngineImplMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).checkAuthorization(wbKey, authorization);
|
||||
verify(workbasketMapperMock, times(1)).findByKey(wbKey);
|
||||
|
@ -284,6 +285,7 @@ public class WorkbasketServiceImplTest {
|
|||
assertThat(wb.getCreated(), not(equalTo(null)));
|
||||
assertThat(wb.getModified(), not(equalTo(null)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -391,11 +393,11 @@ public class WorkbasketServiceImplTest {
|
|||
return workbasket;
|
||||
}
|
||||
|
||||
private List<Workbasket> createTestDistributionTargets(int amount) {
|
||||
List<Workbasket> distributionsTargets = new ArrayList<>();
|
||||
private List<WorkbasketSummary> createTestDistributionTargets(int amount) {
|
||||
List<WorkbasketSummary> distributionsTargets = new ArrayList<>();
|
||||
amount = (amount < 0) ? 0 : amount;
|
||||
for (int i = 0; i < amount; i++) {
|
||||
distributionsTargets.add(createTestWorkbasket("WB-ID-" + i, "WB-KEY-" + i));
|
||||
distributionsTargets.add(createTestWorkbasket("WB-ID-" + i, "WB-KEY-" + i).asSummary());
|
||||
}
|
||||
return distributionsTargets;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
|
|||
import pro.taskana.impl.util.IdGenerator;
|
||||
import pro.taskana.model.WorkbasketAccessItem;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
import pro.taskana.model.WorkbasketSummary;
|
||||
import pro.taskana.model.WorkbasketType;
|
||||
import pro.taskana.model.mappings.WorkbasketMapper;
|
||||
import pro.taskana.security.CurrentUserContext;
|
||||
|
@ -167,14 +168,15 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
id = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket = createTestWorkbasket(id, "key2", "novatec", "Hyperbasket", WorkbasketType.GROUP);
|
||||
workbasket.setDistributionTargets(new ArrayList<>());
|
||||
workbasket.getDistributionTargets().add(wbDist1);
|
||||
workbasket.getDistributionTargets().add(wbDist2);
|
||||
workbasket.getDistributionTargets().add(wbDist1.asSummary());
|
||||
workbasket.getDistributionTargets().add(wbDist2.asSummary());
|
||||
workbasket = workBasketService.createWorkbasket(workbasket);
|
||||
createWorkbasketWithSecurity(workbasket, "Elena", true, true, false, false);
|
||||
|
||||
Workbasket foundWorkbasket = workBasketService.getWorkbasket(workbasket.getId());
|
||||
Assert.assertEquals(id, foundWorkbasket.getId());
|
||||
Assert.assertEquals(2, foundWorkbasket.getDistributionTargets().size());
|
||||
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena")
|
||||
|
@ -193,8 +195,8 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
String id2 = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket2 = createTestWorkbasket(id2, "key2", "novatec", "Hyperbasket", WorkbasketType.GROUP);
|
||||
workbasket2.setDistributionTargets(new ArrayList<>());
|
||||
workbasket2.getDistributionTargets().add(workbasket0);
|
||||
workbasket2.getDistributionTargets().add(workbasket1);
|
||||
workbasket2.getDistributionTargets().add(workbasket0.asSummary());
|
||||
workbasket2.getDistributionTargets().add(workbasket1.asSummary());
|
||||
workbasket2 = workBasketService.createWorkbasket(workbasket2);
|
||||
createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false);
|
||||
|
||||
|
@ -205,13 +207,13 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
createWorkbasketWithSecurity(workbasket3, "Elena", true, true, false, false);
|
||||
|
||||
workbasket2.getDistributionTargets().clear();
|
||||
workbasket2.getDistributionTargets().add(workbasket3);
|
||||
workbasket2.getDistributionTargets().add(workbasket3.asSummary());
|
||||
Thread.sleep(SLEEP_TIME);
|
||||
workbasket2 = workBasketService.updateWorkbasket(workbasket2);
|
||||
|
||||
Workbasket foundBasket = workBasketService.getWorkbasket(workbasket2.getId());
|
||||
|
||||
List<Workbasket> distributionTargets = foundBasket.getDistributionTargets();
|
||||
List<WorkbasketSummary> distributionTargets = foundBasket.getDistributionTargets();
|
||||
Assert.assertEquals(1, distributionTargets.size());
|
||||
Assert.assertEquals(id3, distributionTargets.get(0).getId());
|
||||
Assert.assertNotEquals(workBasketService.getWorkbasket(id2).getCreated(),
|
||||
|
@ -275,36 +277,38 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
WorkbasketQuery query1 = workBasketService.createWorkbasketQuery()
|
||||
.accessIdsHavePersmission(WorkbasketAuthorization.OPEN, "Bernd")
|
||||
.nameIn("Basket4");
|
||||
List<Workbasket> result1 = query1.list();
|
||||
List<WorkbasketSummary> result1 = query1.list();
|
||||
|
||||
Assert.assertEquals(1, result1.size());
|
||||
Assert.assertEquals(THREE, result1.get(0).getDistributionTargets().size());
|
||||
String workbasketId = result1.get(0).getId();
|
||||
Workbasket workBasket = workBasketService.getWorkbasket(workbasketId);
|
||||
Assert.assertEquals(THREE, workBasket.getDistributionTargets().size());
|
||||
|
||||
WorkbasketQuery query2 = workBasketService.createWorkbasketQuery().accessIdsHavePersmission(
|
||||
WorkbasketAuthorization.OPEN, "Bernd",
|
||||
"Konstantin");
|
||||
List<Workbasket> result2 = query2.list();
|
||||
List<WorkbasketSummary> result2 = query2.list();
|
||||
Assert.assertEquals(2, result2.size());
|
||||
|
||||
WorkbasketQuery query3 = workBasketService.createWorkbasketQuery().accessIdsHavePersmission(
|
||||
WorkbasketAuthorization.CUSTOM_5,
|
||||
"Bernd", "Konstantin");
|
||||
List<Workbasket> result3 = query3.list();
|
||||
List<WorkbasketSummary> result3 = query3.list();
|
||||
Assert.assertEquals(0, result3.size());
|
||||
|
||||
WorkbasketQuery query4 = workBasketService.createWorkbasketQuery().accessIdsHavePersmission(
|
||||
WorkbasketAuthorization.CUSTOM_1,
|
||||
"Bernd");
|
||||
List<Workbasket> result4 = query4.list();
|
||||
List<WorkbasketSummary> result4 = query4.list();
|
||||
Assert.assertEquals(1, result4.size());
|
||||
|
||||
WorkbasketQuery query0 = workBasketService.createWorkbasketQuery()
|
||||
.createdBefore(tomorrow)
|
||||
.createdAfter(yesterday)
|
||||
.nameIn("Basket1", "Basket2", "Basket3");
|
||||
List<Workbasket> result0 = query0.list();
|
||||
List<WorkbasketSummary> result0 = query0.list();
|
||||
assertTrue(result0.size() == THREE);
|
||||
for (Workbasket workbasket : result0) {
|
||||
for (WorkbasketSummary workbasket : result0) {
|
||||
String name = workbasket.getName();
|
||||
assertTrue("Basket1".equals(name) || "Basket2".equals(name) || "Basket3".equals(name));
|
||||
}
|
||||
|
@ -312,9 +316,9 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
WorkbasketQuery query5 = workBasketService.createWorkbasketQuery()
|
||||
.modifiedAfter(thirtyDaysAgo)
|
||||
.modifiedBefore(tenDaysAgo);
|
||||
List<Workbasket> result5 = query5.list();
|
||||
List<WorkbasketSummary> result5 = query5.list();
|
||||
assertTrue(result5.size() == 2);
|
||||
for (Workbasket workbasket : result5) {
|
||||
for (WorkbasketSummary workbasket : result5) {
|
||||
String name = workbasket.getName();
|
||||
assertTrue("Basket1".equals(name) || "Basket2".equals(name));
|
||||
}
|
||||
|
@ -322,15 +326,15 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
WorkbasketQuery query6 = workBasketService.createWorkbasketQuery()
|
||||
.modifiedAfter(twentyDaysAgo)
|
||||
.domainIn("novatec", "consulting");
|
||||
List<Workbasket> result6 = query6.list();
|
||||
List<WorkbasketSummary> result6 = query6.list();
|
||||
assertTrue(result6.size() == 1);
|
||||
assertTrue("Basket1".equals(result6.get(0).getName()));
|
||||
|
||||
WorkbasketQuery query7 = workBasketService.createWorkbasketQuery()
|
||||
.typeIn(WorkbasketType.GROUP, WorkbasketType.CLEARANCE);
|
||||
List<Workbasket> result7 = query7.list();
|
||||
List<WorkbasketSummary> result7 = query7.list();
|
||||
assertTrue(result7.size() == 2);
|
||||
for (Workbasket workbasket : result7) {
|
||||
for (WorkbasketSummary workbasket : result7) {
|
||||
String name = workbasket.getName();
|
||||
assertTrue("Basket1".equals(name) || "Basket2".equals(name));
|
||||
}
|
||||
|
@ -402,10 +406,10 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
basket4.setOwner("Holger");
|
||||
basket4.setType(WorkbasketType.PERSONAL);
|
||||
basket4.setDomain("");
|
||||
List<Workbasket> distTargets = new ArrayList<Workbasket>();
|
||||
distTargets.add(basket1);
|
||||
distTargets.add(basket2);
|
||||
distTargets.add(basket3);
|
||||
List<WorkbasketSummary> distTargets = new ArrayList<WorkbasketSummary>();
|
||||
distTargets.add(basket1.asSummary());
|
||||
distTargets.add(basket2.asSummary());
|
||||
distTargets.add(basket3.asSummary());
|
||||
basket4.setDistributionTargets(distTargets);
|
||||
basket4 = (WorkbasketImpl) workBasketService.createWorkbasket(basket4);
|
||||
WorkbasketAccessItem accessItem4 = new WorkbasketAccessItem();
|
||||
|
|
|
@ -32,6 +32,7 @@ import pro.taskana.impl.configuration.DBCleaner;
|
|||
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
|
||||
import pro.taskana.impl.util.IdGenerator;
|
||||
import pro.taskana.model.WorkbasketAccessItem;
|
||||
import pro.taskana.model.WorkbasketSummary;
|
||||
import pro.taskana.model.WorkbasketType;
|
||||
import pro.taskana.security.JAASRunner;
|
||||
import pro.taskana.security.WithAccessId;
|
||||
|
@ -185,8 +186,8 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
String id2 = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket2 = createTestWorkbasket(id2, "key2", "novatec", "Hyperbasket", WorkbasketType.GROUP);
|
||||
workbasket2.setDistributionTargets(new ArrayList<>());
|
||||
workbasket2.getDistributionTargets().add(workbasket0);
|
||||
workbasket2.getDistributionTargets().add(workbasket1);
|
||||
workbasket2.getDistributionTargets().add(workbasket0.asSummary());
|
||||
workbasket2.getDistributionTargets().add(workbasket1.asSummary());
|
||||
workbasket2 = workBasketService.createWorkbasket(workbasket2);
|
||||
createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false);
|
||||
|
||||
|
@ -215,8 +216,8 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
String id2 = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket2 = createTestWorkbasket(id2, "key2", "novatec", "Hyperbasket", WorkbasketType.GROUP);
|
||||
workbasket2.setDistributionTargets(new ArrayList<>());
|
||||
workbasket2.getDistributionTargets().add(workbasket0);
|
||||
workbasket2.getDistributionTargets().add(workbasket1);
|
||||
workbasket2.getDistributionTargets().add(workbasket0.asSummary());
|
||||
workbasket2.getDistributionTargets().add(workbasket1.asSummary());
|
||||
workbasket2 = workBasketService.createWorkbasket(workbasket2);
|
||||
createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false);
|
||||
|
||||
|
@ -224,19 +225,19 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
Workbasket workbasket3 = createTestWorkbasket(id3, "key3", "novatec", "hm ... irgend ein basket",
|
||||
WorkbasketType.GROUP);
|
||||
workbasket3.setDistributionTargets(new ArrayList<>());
|
||||
workbasket3.getDistributionTargets().add(workbasket0);
|
||||
workbasket3.getDistributionTargets().add(workbasket1);
|
||||
workbasket3.getDistributionTargets().add(workbasket0.asSummary());
|
||||
workbasket3.getDistributionTargets().add(workbasket1.asSummary());
|
||||
workbasket3 = workBasketService.createWorkbasket(workbasket3);
|
||||
createWorkbasketWithSecurity(workbasket3, "Elena", true, true, false, false);
|
||||
|
||||
workbasket2.getDistributionTargets().clear();
|
||||
workbasket2.getDistributionTargets().add(workbasket3);
|
||||
workbasket2.getDistributionTargets().add(workbasket3.asSummary());
|
||||
Thread.sleep(SLEEP_TIME);
|
||||
workbasket2 = workBasketService.updateWorkbasket(workbasket2);
|
||||
|
||||
Workbasket foundBasket = workBasketService.getWorkbasket(workbasket2.getId());
|
||||
|
||||
List<Workbasket> distributionTargets = foundBasket.getDistributionTargets();
|
||||
List<WorkbasketSummary> distributionTargets = foundBasket.getDistributionTargets();
|
||||
Assert.assertEquals(1, distributionTargets.size());
|
||||
Assert.assertEquals(workbasket3.getId(), distributionTargets.get(0).getId());
|
||||
Assert.assertNotEquals(workBasketService.getWorkbasket(id2).getCreated(),
|
||||
|
|
|
@ -18,12 +18,12 @@ import pro.taskana.WorkbasketService;
|
|||
import pro.taskana.model.DueWorkbasketCounter;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.TaskStateCounter;
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.model.WorkbasketSummary;
|
||||
import pro.taskana.rest.model.WorkbasketCounterDataDto;
|
||||
import pro.taskana.rest.model.WorkbasketCounterDto;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(path = "/v1/monitor", produces = { MediaType.APPLICATION_JSON_VALUE })
|
||||
@RequestMapping(path = "/v1/monitor", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
public class MonitorController {
|
||||
|
||||
@Autowired
|
||||
|
@ -62,7 +62,7 @@ public class MonitorController {
|
|||
|
||||
List<WorkbasketCounterDataDto> data = new ArrayList<>();
|
||||
|
||||
for (Workbasket workbasket : workbasketService.getWorkbaskets()) {
|
||||
for (WorkbasketSummary workbasket : workbasketService.getWorkbaskets()) {
|
||||
WorkbasketCounterDataDto counterDto = new WorkbasketCounterDataDto();
|
||||
counterDto.setLabel(workbasket.getName());
|
||||
List<Integer> zeroData = new ArrayList<>();
|
||||
|
|
|
@ -24,6 +24,7 @@ import pro.taskana.exceptions.NotAuthorizedException;
|
|||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.WorkbasketAccessItem;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
import pro.taskana.model.WorkbasketSummary;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(path = "/v1/workbaskets", produces = { MediaType.APPLICATION_JSON_VALUE })
|
||||
|
@ -33,8 +34,8 @@ public class WorkbasketController {
|
|||
private WorkbasketService workbasketService;
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<List<Workbasket>> getWorkbaskets(@RequestParam MultiValueMap<String, String> params) {
|
||||
List<Workbasket> workbaskets = new ArrayList<>();
|
||||
public ResponseEntity<List<WorkbasketSummary>> getWorkbaskets(@RequestParam MultiValueMap<String, String> params) {
|
||||
List<WorkbasketSummary> workbaskets = new ArrayList<>();
|
||||
if (params.containsKey("requiredPermission")) {
|
||||
List<WorkbasketAuthorization> authorizations = new ArrayList<>();
|
||||
params.get("requiredPermission").stream().forEach(item -> {
|
||||
|
|
Loading…
Reference in New Issue