TSK-559: Removed unused methods

This commit is contained in:
julian.schallenmueller 2018-06-19 10:16:53 +02:00 committed by Holger Hagen
parent 3ec9359ff3
commit 13f0e0d8c7
4 changed files with 0 additions and 110 deletions

View File

@ -188,16 +188,6 @@ public interface WorkbasketService {
void setWorkbasketAccessItems(String workbasketId, List<WorkbasketAccessItem> wbAccessItems) void setWorkbasketAccessItems(String workbasketId, List<WorkbasketAccessItem> wbAccessItems)
throws InvalidArgumentException, NotAuthorizedException; throws InvalidArgumentException, NotAuthorizedException;
/**
* 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<WorkbasketPermission> permission);
/** /**
* This method provides a query builder for querying the database. * This method provides a query builder for querying the database.
* *

View File

@ -3,10 +3,7 @@ package pro.taskana.impl;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -102,32 +99,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
} }
} }
@Override
public List<WorkbasketSummary> getWorkbaskets(List<WorkbasketPermission> permissions) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("entry to getWorkbaskets(permissions = {})", LoggerUtils.listToString(permissions));
}
List<WorkbasketSummary> result = null;
try {
taskanaEngine.openConnection();
// use a set to avoid duplicates
Set<WorkbasketSummary> workbaskets = new HashSet<>();
for (String accessId : CurrentUserContext.getAccessIds()) {
workbaskets.addAll(workbasketMapper.findByPermission(permissions, accessId));
}
result = new ArrayList<>();
result.addAll(workbaskets);
return result;
} finally {
taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result == null ? 0 : result.size();
LOGGER.debug("exit from getWorkbaskets(permissions). Returning {} resulting Objects: {} ",
numberOfResultObjects, LoggerUtils.listToString(result));
}
}
}
@Override @Override
public Workbasket createWorkbasket(Workbasket newWorkbasket) public Workbasket createWorkbasket(Workbasket newWorkbasket)
throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException, throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException,

View File

@ -11,7 +11,6 @@ import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
import pro.taskana.WorkbasketPermission;
import pro.taskana.impl.WorkbasketImpl; import pro.taskana.impl.WorkbasketImpl;
import pro.taskana.impl.WorkbasketSummaryImpl; import pro.taskana.impl.WorkbasketSummaryImpl;
@ -133,46 +132,6 @@ public interface WorkbasketMapper {
@Result(property = "orgLevel4", column = "ORG_LEVEL_4")}) @Result(property = "orgLevel4", column = "ORG_LEVEL_4")})
List<WorkbasketSummaryImpl> findAll(); List<WorkbasketSummaryImpl> findAll();
@Select("<script>SELECT 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 TASKANA.WORKBASKET AS W "
+ "INNER JOIN TASKANA.WORKBASKET_ACCESS_LIST AS ACL "
+ "ON (W.ID = ACL.WORKBASKET_ID AND ACL.ACCESS_ID = #{accessId}) "
+ "WHERE <foreach collection='permissions' item='permission' separator=' AND '>"
+ "<if test=\"permission.name() == 'OPEN'\">PERM_OPEN</if>"
+ "<if test=\"permission.name() == 'READ'\">PERM_READ</if>"
+ "<if test=\"permission.name() == 'APPEND'\">PERM_APPEND</if>"
+ "<if test=\"permission.name() == 'TRANSFER'\">PERM_TRANSFER</if>"
+ "<if test=\"permission.name() == 'DISTRIBUTE'\">PERM_DISTRIBUTE</if>"
+ "<if test=\"permission.name() == 'CUSTOM_1'\">PERM_CUSTOM_1</if>"
+ "<if test=\"permission.name() == 'CUSTOM_2'\">PERM_CUSTOM_2</if>"
+ "<if test=\"permission.name() == 'CUSTOM_3'\">PERM_CUSTOM_3</if>"
+ "<if test=\"permission.name() == 'CUSTOM_4'\">PERM_CUSTOM_4</if>"
+ "<if test=\"permission.name() == 'CUSTOM_5'\">PERM_CUSTOM_5</if>"
+ "<if test=\"permission.name() == 'CUSTOM_6'\">PERM_CUSTOM_6</if>"
+ "<if test=\"permission.name() == 'CUSTOM_7'\">PERM_CUSTOM_7</if>"
+ "<if test=\"permission.name() == 'CUSTOM_8'\">PERM_CUSTOM_8</if>"
+ "<if test=\"permission.name() == 'CUSTOM_9'\">PERM_CUSTOM_9</if>"
+ "<if test=\"permission.name() == 'CUSTOM_10'\">PERM_CUSTOM_10</if>"
+ "<if test=\"permission.name() == 'CUSTOM_11'\">PERM_CUSTOM_11</if>"
+ "<if test=\"permission.name() == 'CUSTOM_12'\">PERM_CUSTOM_12</if> = 1 </foreach> "
+ "ORDER BY id "
+ "<if test=\"_databaseId == 'db2'\">with UR </if> "
+ "</script>")
@Results(value = {
@Result(property = "id", column = "ID"),
@Result(property = "key", column = "KEY"),
@Result(property = "modified", column = "MODIFIED"),
@Result(property = "name", column = "NAME"),
@Result(property = "description", column = "DESCRIPTION"),
@Result(property = "owner", column = "OWNER"),
@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<WorkbasketSummaryImpl> findByPermission(@Param("permissions") List<WorkbasketPermission> permissions,
@Param("accessId") String accessId);
@Insert("<script>INSERT INTO TASKANA.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 TASKANA.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}) "
+ "</script>") + "</script>")
@Options(keyProperty = "id", keyColumn = "ID") @Options(keyProperty = "id", keyColumn = "ID")

View File

@ -3,7 +3,6 @@ package acceptance.workbasket;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.Test;
@ -119,35 +118,6 @@ public class GetWorkbasketAccTest extends AbstractAccTest {
assertEquals("Team", workbasketSummary.getOrgLevel4()); assertEquals("Team", workbasketSummary.getOrgLevel4());
} }
@WithAccessId(
userName = "user_1_1",
groupNames = {"group_1"})
@Test
public void testGetWorkbasketsByPermissions()
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketPermission> permissions = new ArrayList<WorkbasketPermission>();
permissions.add(WorkbasketPermission.READ);
permissions.add(WorkbasketPermission.OPEN);
permissions.add(WorkbasketPermission.APPEND);
permissions.add(WorkbasketPermission.TRANSFER);
List<WorkbasketSummary> workbasketSummaries = workbasketService.getWorkbaskets(permissions);
List<WorkbasketSummary> expectedSummaries = new ArrayList<WorkbasketSummary>();
expectedSummaries.add(workbasketService.getWorkbasket("WBI:100000000000000000000000000000000002").asSummary());
expectedSummaries.add(workbasketService.getWorkbasket("WBI:100000000000000000000000000000000004").asSummary());
expectedSummaries.add(workbasketService.getWorkbasket("WBI:100000000000000000000000000000000006").asSummary());
expectedSummaries.add(workbasketService.getWorkbasket("WBI:100000000000000000000000000000000007").asSummary());
assertEquals(4, workbasketSummaries.size());
for (WorkbasketSummary wbSummary : workbasketSummaries) {
assertTrue(expectedSummaries.contains(wbSummary));
}
}
@Test(expected = WorkbasketNotFoundException.class) @Test(expected = WorkbasketNotFoundException.class)
public void testThrowsExceptionIfIdIsInvalid() public void testThrowsExceptionIfIdIsInvalid()
throws NotAuthorizedException, WorkbasketNotFoundException { throws NotAuthorizedException, WorkbasketNotFoundException {