[TSK-1208] changed HATE terminology and replaced list resources with generic one

This commit is contained in:
Christopher Heiting 2020-04-28 09:27:31 +02:00
parent b82741a2b4
commit bd116d4c2e
112 changed files with 3486 additions and 4176 deletions

View File

@ -6,6 +6,7 @@ import java.time.ZoneId;
import java.util.List; import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -23,7 +24,6 @@ import pro.taskana.common.api.LoggerUtils;
import pro.taskana.common.api.TimeInterval; import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.rest.AbstractPagingController; import pro.taskana.rest.AbstractPagingController;
import pro.taskana.rest.resource.PagedResources.PageMetadata;
import pro.taskana.simplehistory.impl.HistoryEventImpl; import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl; import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
import pro.taskana.simplehistory.query.HistoryQuery; import pro.taskana.simplehistory.query.HistoryQuery;

View File

@ -3,6 +3,7 @@ package pro.taskana.simplehistory.rest.resource;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collection; import java.util.Collection;
import org.springframework.hateoas.Link; import org.springframework.hateoas.Link;
import org.springframework.hateoas.PagedModel.PageMetadata;
import pro.taskana.rest.resource.PagedResources; import pro.taskana.rest.resource.PagedResources;

View File

@ -6,9 +6,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.hateoas.IanaLinkRelations; import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link; import org.springframework.hateoas.Link;
import org.springframework.hateoas.PagedModel.PageMetadata;
import pro.taskana.rest.resource.AbstractRessourcesAssembler; import pro.taskana.rest.resource.AbstractRessourcesAssembler;
import pro.taskana.rest.resource.PagedResources.PageMetadata;
import pro.taskana.simplehistory.impl.HistoryEventImpl; import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.rest.TaskHistoryEventController; import pro.taskana.simplehistory.rest.TaskHistoryEventController;

View File

@ -1,6 +1,5 @@
package pro.taskana.simplehistory.rest.resource; package pro.taskana.simplehistory.rest.resource;
import javax.validation.constraints.NotNull;
import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.RepresentationModel;
import pro.taskana.spi.history.api.events.TaskanaHistoryEvent; import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
@ -8,7 +7,7 @@ import pro.taskana.spi.history.api.events.TaskanaHistoryEvent;
/** Resource class for {@link TaskanaHistoryEvent}. */ /** Resource class for {@link TaskanaHistoryEvent}. */
public class TaskHistoryEventResource extends RepresentationModel<TaskHistoryEventResource> { public class TaskHistoryEventResource extends RepresentationModel<TaskHistoryEventResource> {
@NotNull private String taskHistoryEventId; private String taskHistoryEventId;
private String businessProcessId; private String businessProcessId;
private String parentBusinessProcessId; private String parentBusinessProcessId;
private String taskId; private String taskId;

View File

@ -5,6 +5,7 @@ import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.lang.NonNull;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.simplehistory.impl.HistoryEventImpl; import pro.taskana.simplehistory.impl.HistoryEventImpl;
@ -20,8 +21,9 @@ public class TaskHistoryEventResourceAssembler
super(HistoryEventImpl.class, TaskHistoryEventResource.class); super(HistoryEventImpl.class, TaskHistoryEventResource.class);
} }
@NonNull
@Override @Override
public TaskHistoryEventResource toModel(TaskanaHistoryEvent historyEvent) { public TaskHistoryEventResource toModel(@NonNull TaskanaHistoryEvent historyEvent) {
TaskHistoryEventResource resource = createModelWithId(historyEvent.getId(), historyEvent); TaskHistoryEventResource resource = createModelWithId(historyEvent.getId(), historyEvent);
try { try {
resource.removeLinks(); resource.removeLinks();

View File

@ -166,7 +166,7 @@ public class DbSchemaCreator {
line = reader.readLine(); line = reader.readLine();
if (line != null) { if (line != null) {
content content
.append(line.replaceAll("%schemaName%", schemaName)) .append(line.replace("%schemaName%", schemaName))
.append(System.lineSeparator()); .append(System.lineSeparator());
} }
} }

View File

@ -1,5 +1,7 @@
package pro.taskana.task.api; package pro.taskana.task.api;
import java.util.Arrays;
/** This enum contains all status of the tasks. */ /** This enum contains all status of the tasks. */
public enum TaskState { public enum TaskState {
READY, READY,
@ -9,15 +11,10 @@ public enum TaskState {
TERMINATED; TERMINATED;
public boolean in(TaskState... states) { public boolean in(TaskState... states) {
for (TaskState currState : states) { return Arrays.stream(states).anyMatch(state -> state == this);
if (this.equals(currState)) {
return true;
}
}
return false;
} }
public boolean isEndState() { public boolean isEndState() {
return this.equals(COMPLETED) || this.equals(CANCELLED) || this.equals(TERMINATED); return this == COMPLETED || this == CANCELLED || this == TERMINATED;
} }
} }

View File

@ -10,7 +10,7 @@ import java.util.stream.Collectors;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import pro.taskana.common.api.BaseQuery; import pro.taskana.common.api.BaseQuery.SortDirection;
import pro.taskana.common.api.BulkOperationResults; import pro.taskana.common.api.BulkOperationResults;
import pro.taskana.common.api.LoggerUtils; import pro.taskana.common.api.LoggerUtils;
import pro.taskana.common.api.ScheduledJob; import pro.taskana.common.api.ScheduledJob;
@ -24,19 +24,21 @@ import pro.taskana.common.internal.transaction.TaskanaTransactionProvider;
import pro.taskana.common.internal.util.LogSanitizer; import pro.taskana.common.internal.util.LogSanitizer;
import pro.taskana.task.api.models.TaskSummary; import pro.taskana.task.api.models.TaskSummary;
/** Job to cleanup completed tasks after a period of time. */ /**
* Job to cleanup completed tasks after a period of time.
*/
public class TaskCleanupJob extends AbstractTaskanaJob { public class TaskCleanupJob extends AbstractTaskanaJob {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskCleanupJob.class); private static final Logger LOGGER = LoggerFactory.getLogger(TaskCleanupJob.class);
private static BaseQuery.SortDirection asc = BaseQuery.SortDirection.ASCENDING; private static final SortDirection ASCENDING = SortDirection.ASCENDING;
// Parameter // Parameter
private Instant firstRun; private final Instant firstRun;
private Duration runEvery; private final Duration runEvery;
private Duration minimumAge; private final Duration minimumAge;
private int batchSize; private final int batchSize;
private boolean allCompletedSameParentBusiness; private final boolean allCompletedSameParentBusiness;
public TaskCleanupJob( public TaskCleanupJob(
TaskanaEngine taskanaEngine, TaskanaEngine taskanaEngine,
@ -55,7 +57,7 @@ public class TaskCleanupJob extends AbstractTaskanaJob {
public void run() throws TaskanaException { public void run() throws TaskanaException {
Instant completedBefore = Instant.now().minus(minimumAge); Instant completedBefore = Instant.now().minus(minimumAge);
LOGGER.info( LOGGER.info(
"Running job to delete all tasks completed before ({})", completedBefore.toString()); "Running job to delete all tasks completed before ({})", completedBefore);
try { try {
List<TaskSummary> tasksCompletedBefore = getTasksCompletedBefore(completedBefore); List<TaskSummary> tasksCompletedBefore = getTasksCompletedBefore(completedBefore);
int totalNumberOfTasksCompleted = 0; int totalNumberOfTasksCompleted = 0;
@ -94,7 +96,7 @@ public class TaskCleanupJob extends AbstractTaskanaJob {
.getTaskService() .getTaskService()
.createTaskQuery() .createTaskQuery()
.completedWithin(new TimeInterval(null, untilDate)) .completedWithin(new TimeInterval(null, untilDate))
.orderByBusinessProcessId(asc) .orderByBusinessProcessId(ASCENDING)
.list(); .list();
if (allCompletedSameParentBusiness) { if (allCompletedSameParentBusiness) {

View File

@ -26,9 +26,9 @@ public class WorkbasketCleanupJob extends AbstractTaskanaJob {
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketCleanupJob.class); private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketCleanupJob.class);
// Parameter // Parameter
private Instant firstRun; private final Instant firstRun;
private Duration runEvery; private final Duration runEvery;
private int batchSize; private final int batchSize;
public WorkbasketCleanupJob( public WorkbasketCleanupJob(
TaskanaEngine taskanaEngine, TaskanaEngine taskanaEngine,
@ -76,31 +76,27 @@ public class WorkbasketCleanupJob extends AbstractTaskanaJob {
} }
private List<String> getWorkbasketsMarkedForDeletion() { private List<String> getWorkbasketsMarkedForDeletion() {
List<String> workbasketList =
taskanaEngineImpl
.getWorkbasketService()
.createWorkbasketQuery()
.markedForDeletion(true)
.listValues(WorkbasketQueryColumnName.ID, BaseQuery.SortDirection.ASCENDING);
return workbasketList; return taskanaEngineImpl
.getWorkbasketService()
.createWorkbasketQuery()
.markedForDeletion(true)
.listValues(WorkbasketQueryColumnName.ID, BaseQuery.SortDirection.ASCENDING);
} }
private int deleteWorkbasketsTransactionally(List<String> workbasketsToBeDeleted) { private int deleteWorkbasketsTransactionally(List<String> workbasketsToBeDeleted) {
int deletedWorkbasketsCount = 0; int deletedWorkbasketsCount = 0;
if (txProvider != null) { if (txProvider != null) {
int count = return (Integer)
(Integer) txProvider.executeInTransaction(
txProvider.executeInTransaction( () -> {
() -> { try {
try { return deleteWorkbaskets(workbasketsToBeDeleted);
return deleteWorkbaskets(workbasketsToBeDeleted); } catch (Exception e) {
} catch (Exception e) { LOGGER.warn("Could not delete workbaskets.", e);
LOGGER.warn("Could not delete workbaskets.", e); return 0;
return 0; }
} });
});
return count;
} else { } else {
try { try {
deletedWorkbasketsCount = deleteWorkbaskets(workbasketsToBeDeleted); deletedWorkbasketsCount = deleteWorkbaskets(workbasketsToBeDeleted);

View File

@ -2,13 +2,14 @@ package pro.taskana.ldap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.AccessIdRepresentationModel;
/** /**
* Implementation of LdapCache used for Unit tests. * Implementation of LdapCache used for Unit tests.
@ -19,283 +20,292 @@ import pro.taskana.rest.resource.AccessIdResource;
public class LdapCacheTestImpl implements LdapCache { public class LdapCacheTestImpl implements LdapCache {
/** /**
* Dictionary is a {@link Map} collection that contains {@link AccessIdResource} as key (user) and * Dictionary is a {@link Map} collection that contains {@link AccessIdRepresentationModel} as key
* {@link List} as value (groups of which the user is a member) . * (user) and {@link List} as value (groups of which the user is a member) .
*/ */
private Map<AccessIdResource, List<AccessIdResource>> users; private Map<AccessIdRepresentationModel, List<AccessIdRepresentationModel>> users;
private List<AccessIdResource> accessIds = private final List<AccessIdRepresentationModel> accessIds =
new ArrayList<>( new ArrayList<>(
Arrays.asList( Arrays.asList(
new AccessIdResource("Martin, Rojas Miguel Angel", "user_1_1"), new AccessIdRepresentationModel("Martin, Rojas Miguel Angel", "user_1_1"),
new AccessIdResource("Zorgati, Mustapha", "user_2_1"), new AccessIdRepresentationModel("Zorgati, Mustapha", "user_2_1"),
new AccessIdResource("Behrendt, Maximilian", "max"), new AccessIdRepresentationModel("Behrendt, Maximilian", "max"),
new AccessIdResource("Bert, Ali", "teamlead_5"), new AccessIdRepresentationModel("Bert, Ali", "teamlead_5"),
new AccessIdResource("Hagen, Holger", "teamlead_3"), new AccessIdRepresentationModel("Hagen, Holger", "teamlead_3"),
new AccessIdResource("Breier, Bernd", "user_2_2"), new AccessIdRepresentationModel("Breier, Bernd", "user_2_2"),
new AccessIdResource("Fielmalz, Anke", "user017"), new AccessIdRepresentationModel("Fielmalz, Anke", "user017"),
new AccessIdResource("Mente, Maximilian", "max_mente"), new AccessIdRepresentationModel("Mente, Maximilian", "max_mente"),
new AccessIdResource("Theke, Bernd", "user_2_3"), new AccessIdRepresentationModel("Theke, Bernd", "user_2_3"),
new AccessIdResource("Ferrante, Elena", "elena"), new AccessIdRepresentationModel("Ferrante, Elena", "elena"),
new AccessIdResource("Mueller, Simone", "simone"), new AccessIdRepresentationModel("Mueller, Simone", "simone"),
new AccessIdResource("Sirup, Aaron", "user001"), new AccessIdRepresentationModel("Sirup, Aaron", "user001"),
new AccessIdResource("Nacho, recuerda", "user_1_2"), new AccessIdRepresentationModel("Nacho, recuerda", "user_1_2"),
new AccessIdResource("Lass, Ada", "user003"), new AccessIdRepresentationModel("Lass, Ada", "user003"),
new AccessIdResource("Tion, Addi", "user004"), new AccessIdRepresentationModel("Tion, Addi", "user004"),
new AccessIdResource("Lette, Adi", "user005"), new AccessIdRepresentationModel("Lette, Adi", "user005"),
new AccessIdResource("Admin", "teamlead_2"), new AccessIdRepresentationModel("Admin", "teamlead_2"),
new AccessIdResource("Native, Alter", "user006"), new AccessIdRepresentationModel("Native, Alter", "user006"),
new AccessIdResource("Herum, Albert", "user007"), new AccessIdRepresentationModel("Herum, Albert", "user007"),
new AccessIdResource("Meyer, Dominik", "teamlead_1"), new AccessIdRepresentationModel("Meyer, Dominik", "teamlead_1"),
new AccessIdResource("Mente, Ali", "user009"), new AccessIdRepresentationModel("Mente, Ali", "user009"),
new AccessIdResource("Nach, Alma", "user011"), new AccessIdRepresentationModel("Nach, Alma", "user011"),
new AccessIdResource("Gehzauch, Anders", "user012"), new AccessIdRepresentationModel("Gehzauch, Anders", "user012"),
new AccessIdResource("Theke, Andi", "user013"), new AccessIdRepresentationModel("Theke, Andi", "user013"),
new AccessIdResource("Kreuz, Andreas", "user014"), new AccessIdRepresentationModel("Kreuz, Andreas", "user014"),
new AccessIdResource("Tiefsee, Anka", "user016"), new AccessIdRepresentationModel("Tiefsee, Anka", "user016"),
new AccessIdResource("Fassen, Ann", "user018"), new AccessIdRepresentationModel("Fassen, Ann", "user018"),
new AccessIdResource("Probe, Ann", "user019"), new AccessIdRepresentationModel("Probe, Ann", "user019"),
new AccessIdResource("Bolika, Anna", "user020"), new AccessIdRepresentationModel("Bolika, Anna", "user020"),
new AccessIdResource("Ecke, Anna", "user021"), new AccessIdRepresentationModel("Ecke, Anna", "user021"),
new AccessIdResource("Hosi, Anna", "user022"), new AccessIdRepresentationModel("Hosi, Anna", "user022"),
new AccessIdResource("Kronis-Tisch, Anna", "user023"), new AccessIdRepresentationModel("Kronis-Tisch, Anna", "user023"),
new AccessIdResource("Logie, Anna", "user024"), new AccessIdRepresentationModel("Logie, Anna", "user024"),
new AccessIdResource("Luehse, Anna", "user025"), new AccessIdRepresentationModel("Luehse, Anna", "user025"),
new AccessIdResource("Nass, Anna", "user026"), new AccessIdRepresentationModel("Nass, Anna", "user026"),
new AccessIdResource("Thalb, Anna", "user027"), new AccessIdRepresentationModel("Thalb, Anna", "user027"),
new AccessIdResource("Tomie, Anna", "user028"), new AccessIdRepresentationModel("Tomie, Anna", "user028"),
new AccessIdResource("Donnich, Anne", "user029"), new AccessIdRepresentationModel("Donnich, Anne", "user029"),
new AccessIdResource("Kaffek, Anne", "user030"), new AccessIdRepresentationModel("Kaffek, Anne", "user030"),
new AccessIdResource("Thek, Anne", "user031"), new AccessIdRepresentationModel("Thek, Anne", "user031"),
new AccessIdResource("Matoer, Anni", "user032"), new AccessIdRepresentationModel("Matoer, Anni", "user032"),
new AccessIdResource("Ragentor, Ansgar", "user033"), new AccessIdRepresentationModel("Ragentor, Ansgar", "user033"),
new AccessIdResource("Stoteles, Ari", "user034"), new AccessIdRepresentationModel("Stoteles, Ari", "user034"),
new AccessIdResource("Thmetik, Ari", "user035"), new AccessIdRepresentationModel("Thmetik, Ari", "user035"),
new AccessIdResource("Nuehm, Arno", "user036"), new AccessIdRepresentationModel("Nuehm, Arno", "user036"),
new AccessIdResource("Schocke, Artie", "user037"), new AccessIdRepresentationModel("Schocke, Artie", "user037"),
new AccessIdResource("Stoppel, Bart", "user038"), new AccessIdRepresentationModel("Stoppel, Bart", "user038"),
new AccessIdResource("Beitung, Bea", "user039"), new AccessIdRepresentationModel("Beitung, Bea", "user039"),
new AccessIdResource("Ildich, Bea", "user040"), new AccessIdRepresentationModel("Ildich, Bea", "user040"),
new AccessIdResource("Vista, Bella", "user041"), new AccessIdRepresentationModel("Vista, Bella", "user041"),
new AccessIdResource("Utzer, Ben", "user042"), new AccessIdRepresentationModel("Utzer, Ben", "user042"),
new AccessIdResource("Zien, Ben", "user043"), new AccessIdRepresentationModel("Zien, Ben", "user043"),
new AccessIdResource("Stein, Bernd", "user044"), new AccessIdRepresentationModel("Stein, Bernd", "user044"),
new AccessIdResource("Deramen, Bill", "user045"), new AccessIdRepresentationModel("Deramen, Bill", "user045"),
new AccessIdResource("Honig, Bine", "user046"), new AccessIdRepresentationModel("Honig, Bine", "user046"),
new AccessIdResource("Densatz, Bo", "user047"), new AccessIdRepresentationModel("Densatz, Bo", "user047"),
new AccessIdResource("Densee, Bo", "user048"), new AccessIdRepresentationModel("Densee, Bo", "user048"),
new AccessIdResource("Lerwagen, Bo", "user049"), new AccessIdRepresentationModel("Lerwagen, Bo", "user049"),
new AccessIdResource("Tail, Bob", "user050"), new AccessIdRepresentationModel("Tail, Bob", "user050"),
new AccessIdResource("Ketta, Bruce", "user051"), new AccessIdRepresentationModel("Ketta, Bruce", "user051"),
new AccessIdResource("Terrie, Bud", "user052"), new AccessIdRepresentationModel("Terrie, Bud", "user052"),
new AccessIdResource("Biener-Haken, Cara", "user053"), new AccessIdRepresentationModel("Biener-Haken, Cara", "user053"),
new AccessIdResource("Ass, Caro", "user054"), new AccessIdRepresentationModel("Ass, Caro", "user054"),
new AccessIdResource("Kaffee, Caro", "user055"), new AccessIdRepresentationModel("Kaffee, Caro", "user055"),
new AccessIdResource("Linger, Caro", "user056"), new AccessIdRepresentationModel("Linger, Caro", "user056"),
new AccessIdResource("tenSaft, Caro", "user057"), new AccessIdRepresentationModel("tenSaft, Caro", "user057"),
new AccessIdResource("Antheme, Chris", "user058"), new AccessIdRepresentationModel("Antheme, Chris", "user058"),
new AccessIdResource("Baum, Chris", "user059"), new AccessIdRepresentationModel("Baum, Chris", "user059"),
new AccessIdResource("Tall, Chris", "user060"), new AccessIdRepresentationModel("Tall, Chris", "user060"),
new AccessIdResource("Reiniger, Claas", "user061"), new AccessIdRepresentationModel("Reiniger, Claas", "user061"),
new AccessIdResource("Grube, Claire", "user062"), new AccessIdRepresentationModel("Grube, Claire", "user062"),
new AccessIdResource("Fall, Clara", "user063"), new AccessIdRepresentationModel("Fall, Clara", "user063"),
new AccessIdResource("Korn, Clara", "user064"), new AccessIdRepresentationModel("Korn, Clara", "user064"),
new AccessIdResource("Lenriff, Cora", "user065"), new AccessIdRepresentationModel("Lenriff, Cora", "user065"),
new AccessIdResource("Schiert, Cora", "user066"), new AccessIdRepresentationModel("Schiert, Cora", "user066"),
new AccessIdResource("Hose, Cord", "user067"), new AccessIdRepresentationModel("Hose, Cord", "user067"),
new AccessIdResource("Onbleu, Cord", "user068"), new AccessIdRepresentationModel("Onbleu, Cord", "user068"),
new AccessIdResource("Umkleide, Damon", "user069"), new AccessIdRepresentationModel("Umkleide, Damon", "user069"),
new AccessIdResource("Affier, Dean", "user070"), new AccessIdRepresentationModel("Affier, Dean", "user070"),
new AccessIdResource("Orm, Dean", "user071"), new AccessIdRepresentationModel("Orm, Dean", "user071"),
new AccessIdResource("Platz, Dennis", "user072"), new AccessIdRepresentationModel("Platz, Dennis", "user072"),
new AccessIdResource("Milch, Dick", "user073"), new AccessIdRepresentationModel("Milch, Dick", "user073"),
new AccessIdResource("Mow, Dina", "user074"), new AccessIdRepresentationModel("Mow, Dina", "user074"),
new AccessIdResource("Keil, Donna", "user075"), new AccessIdRepresentationModel("Keil, Donna", "user075"),
new AccessIdResource("Littchen, Donna", "user076"), new AccessIdRepresentationModel("Littchen, Donna", "user076"),
new AccessIdResource("Wetter, Donna", "user077"), new AccessIdRepresentationModel("Wetter, Donna", "user077"),
new AccessIdResource("Was, Ed", "user078"), new AccessIdRepresentationModel("Was, Ed", "user078"),
new AccessIdResource("Khar, Ede", "user079"), new AccessIdRepresentationModel("Khar, Ede", "user079"),
new AccessIdResource("Nut, Ella", "user080"), new AccessIdRepresentationModel("Nut, Ella", "user080"),
new AccessIdResource("Stisch, Ella", "user081"), new AccessIdRepresentationModel("Stisch, Ella", "user081"),
new AccessIdResource("Diel, Emma", "user082"), new AccessIdRepresentationModel("Diel, Emma", "user082"),
new AccessIdResource("Herdamit, Emma", "user083"), new AccessIdRepresentationModel("Herdamit, Emma", "user083"),
new AccessIdResource("Mitter-Uhe, Emma", "user084"), new AccessIdRepresentationModel("Mitter-Uhe, Emma", "user084"),
new AccessIdResource("Tatt, Erich", "user085"), new AccessIdRepresentationModel("Tatt, Erich", "user085"),
new AccessIdResource("Drigend, Ernie", "user086"), new AccessIdRepresentationModel("Drigend, Ernie", "user086"),
new AccessIdResource("Poly, Esther", "user087"), new AccessIdRepresentationModel("Poly, Esther", "user087"),
new AccessIdResource("Trautz, Eugen", "user088"), new AccessIdRepresentationModel("Trautz, Eugen", "user088"),
new AccessIdResource("Quiert, Eva", "user089"), new AccessIdRepresentationModel("Quiert, Eva", "user089"),
new AccessIdResource("Inurlaub, Fatma", "user090"), new AccessIdRepresentationModel("Inurlaub, Fatma", "user090"),
new AccessIdResource("Land, Finn", "user091"), new AccessIdRepresentationModel("Land, Finn", "user091"),
new AccessIdResource("Sternis, Finn", "user092"), new AccessIdRepresentationModel("Sternis, Finn", "user092"),
new AccessIdResource("Furt, Frank", "user093"), new AccessIdRepresentationModel("Furt, Frank", "user093"),
new AccessIdResource("Reich, Frank", "user094"), new AccessIdRepresentationModel("Reich, Frank", "user094"),
new AccessIdResource("Iskaner, Franz", "user095"), new AccessIdRepresentationModel("Iskaner, Franz", "user095"),
new AccessIdResource("Nerr, Franziska", "user096"), new AccessIdRepresentationModel("Nerr, Franziska", "user096"),
new AccessIdResource("Zafen, Friedrich", "user097"), new AccessIdRepresentationModel("Zafen, Friedrich", "user097"),
new AccessIdResource("Pomm, Fritz", "user098"), new AccessIdRepresentationModel("Pomm, Fritz", "user098"),
new AccessIdResource("deWegs, Gera", "user099"), new AccessIdRepresentationModel("deWegs, Gera", "user099"),
new AccessIdResource("Staebe, Gitta", "user100"), new AccessIdRepresentationModel("Staebe, Gitta", "user100"),
new AccessIdResource("Zend, Glenn", "user101"), new AccessIdRepresentationModel("Zend, Glenn", "user101"),
new AccessIdResource("Fisch, Grete", "user102"), new AccessIdRepresentationModel("Fisch, Grete", "user102"),
new AccessIdResource("Zucker, Gus", "user103"), new AccessIdRepresentationModel("Zucker, Gus", "user103"),
new AccessIdResource("Muhn, Hanni", "user104"), new AccessIdRepresentationModel("Muhn, Hanni", "user104"),
new AccessIdResource("Fermesse, Hanno", "user105"), new AccessIdRepresentationModel("Fermesse, Hanno", "user105"),
new AccessIdResource("Aplast, Hans", "user106"), new AccessIdRepresentationModel("Aplast, Hans", "user106"),
new AccessIdResource("Eart, Hans", "user107"), new AccessIdRepresentationModel("Eart, Hans", "user107"),
new AccessIdResource("Back, Hardy", "user108"), new AccessIdRepresentationModel("Back, Hardy", "user108"),
new AccessIdResource("Beau, Harry", "user109"), new AccessIdRepresentationModel("Beau, Harry", "user109"),
new AccessIdResource("Kraut, Heide", "user110"), new AccessIdRepresentationModel("Kraut, Heide", "user110"),
new AccessIdResource("Witzka, Heide", "user111"), new AccessIdRepresentationModel("Witzka, Heide", "user111"),
new AccessIdResource("Buchen, Hein", "user112"), new AccessIdRepresentationModel("Buchen, Hein", "user112"),
new AccessIdResource("Lichkeit, Hein", "user113"), new AccessIdRepresentationModel("Lichkeit, Hein", "user113"),
new AccessIdResource("Suchung, Hein", "user114"), new AccessIdRepresentationModel("Suchung, Hein", "user114"),
new AccessIdResource("Ellmann, Heinz", "user115"), new AccessIdRepresentationModel("Ellmann, Heinz", "user115"),
new AccessIdResource("Ketchup, Heinz", "user116"), new AccessIdRepresentationModel("Ketchup, Heinz", "user116"),
new AccessIdResource("Zeim, Hilde", "user117"), new AccessIdRepresentationModel("Zeim, Hilde", "user117"),
new AccessIdResource("Bilien, Immo", "user118"), new AccessIdRepresentationModel("Bilien, Immo", "user118"),
new AccessIdResource("Her, Inge", "user119"), new AccessIdRepresentationModel("Her, Inge", "user119"),
new AccessIdResource("Wahrsam, Inge", "user120"), new AccessIdRepresentationModel("Wahrsam, Inge", "user120"),
new AccessIdResource("Flamm, Ingo", "user121"), new AccessIdRepresentationModel("Flamm, Ingo", "user121"),
new AccessIdResource("Enzien, Ingrid", "user122"), new AccessIdRepresentationModel("Enzien, Ingrid", "user122"),
new AccessIdResource("Rohsch, Inken", "user123"), new AccessIdRepresentationModel("Rohsch, Inken", "user123"),
new AccessIdResource("Ihr, Insa", "user124"), new AccessIdRepresentationModel("Ihr, Insa", "user124"),
new AccessIdResource("Nerda, Iska", "user125"), new AccessIdRepresentationModel("Nerda, Iska", "user125"),
new AccessIdResource("Eitz, Jens", "user126"), new AccessIdRepresentationModel("Eitz, Jens", "user126"),
new AccessIdResource("Nastik, Jim", "user127"), new AccessIdRepresentationModel("Nastik, Jim", "user127"),
new AccessIdResource("Gurt, Jo", "user128"), new AccessIdRepresentationModel("Gurt, Jo", "user128"),
new AccessIdResource("Kurrth, Jo", "user129"), new AccessIdRepresentationModel("Kurrth, Jo", "user129"),
new AccessIdResource("Kolade, Joe", "user130"), new AccessIdRepresentationModel("Kolade, Joe", "user130"),
new AccessIdResource("Iter, Johann", "user131"), new AccessIdRepresentationModel("Iter, Johann", "user131"),
new AccessIdResource("Tick, Joyce", "user132"), new AccessIdRepresentationModel("Tick, Joyce", "user132"),
new AccessIdResource("Case, Justin", "user133"), new AccessIdRepresentationModel("Case, Justin", "user133"),
new AccessIdResource("Time, Justin", "user134"), new AccessIdRepresentationModel("Time, Justin", "user134"),
new AccessIdResource("Komp, Jutta", "user135"), new AccessIdRepresentationModel("Komp, Jutta", "user135"),
new AccessIdResource("Mauer, Kai", "user136"), new AccessIdRepresentationModel("Mauer, Kai", "user136"),
new AccessIdResource("Pirinja, Kai", "user137"), new AccessIdRepresentationModel("Pirinja, Kai", "user137"),
new AccessIdResource("Serpfalz, Kai", "user138"), new AccessIdRepresentationModel("Serpfalz, Kai", "user138"),
new AccessIdResource("Auer, Karl", "user139"), new AccessIdRepresentationModel("Auer, Karl", "user139"),
new AccessIdResource("Ielauge, Karl", "user140"), new AccessIdRepresentationModel("Ielauge, Karl", "user140"),
new AccessIdResource("Ifornjen, Karl", "user141"), new AccessIdRepresentationModel("Ifornjen, Karl", "user141"),
new AccessIdResource("Radi, Karl", "user142"), new AccessIdRepresentationModel("Radi, Karl", "user142"),
new AccessIdResource("Verti, Karl", "user143"), new AccessIdRepresentationModel("Verti, Karl", "user143"),
new AccessIdResource("Sery, Karo", "user144"), new AccessIdRepresentationModel("Sery, Karo", "user144"),
new AccessIdResource("Lisator, Katha", "user145"), new AccessIdRepresentationModel("Lisator, Katha", "user145"),
new AccessIdResource("Flo, Kati", "user146"), new AccessIdRepresentationModel("Flo, Kati", "user146"),
new AccessIdResource("Schenn, Knut", "user147"), new AccessIdRepresentationModel("Schenn, Knut", "user147"),
new AccessIdResource("Achse, Kurt", "user148"), new AccessIdRepresentationModel("Achse, Kurt", "user148"),
new AccessIdResource("Zepause, Kurt", "user149"), new AccessIdRepresentationModel("Zepause, Kurt", "user149"),
new AccessIdResource("Zerr, Kurt", "user150"), new AccessIdRepresentationModel("Zerr, Kurt", "user150"),
new AccessIdResource("Reden, Lasse", "user151"), new AccessIdRepresentationModel("Reden, Lasse", "user151"),
new AccessIdResource("Metten, Lee", "user152"), new AccessIdRepresentationModel("Metten, Lee", "user152"),
new AccessIdResource("Arm, Lene", "user153"), new AccessIdRepresentationModel("Arm, Lene", "user153"),
new AccessIdResource("Thur, Linnea", "user154"), new AccessIdRepresentationModel("Thur, Linnea", "user154"),
new AccessIdResource("Bonn, Lisa", "user155"), new AccessIdRepresentationModel("Bonn, Lisa", "user155"),
new AccessIdResource("Sembourg, Luc", "user156"), new AccessIdRepresentationModel("Sembourg, Luc", "user156"),
new AccessIdResource("Rung, Lucky", "user157"), new AccessIdRepresentationModel("Rung, Lucky", "user157"),
new AccessIdResource("Zafen, Ludwig", "user158"), new AccessIdRepresentationModel("Zafen, Ludwig", "user158"),
new AccessIdResource("Hauden, Lukas", "user159"), new AccessIdRepresentationModel("Hauden, Lukas", "user159"),
new AccessIdResource("Hose, Lutz", "user160"), new AccessIdRepresentationModel("Hose, Lutz", "user160"),
new AccessIdResource("Tablette, Lutz", "user161"), new AccessIdRepresentationModel("Tablette, Lutz", "user161"),
new AccessIdResource("Fehr, Luzie", "user162"), new AccessIdRepresentationModel("Fehr, Luzie", "user162"),
new AccessIdResource("Nalyse, Magda", "user163"), new AccessIdRepresentationModel("Nalyse, Magda", "user163"),
new AccessIdResource("Ehfer, Maik", "user164"), new AccessIdRepresentationModel("Ehfer, Maik", "user164"),
new AccessIdResource("Sehr, Malte", "user165"), new AccessIdRepresentationModel("Sehr, Malte", "user165"),
new AccessIdResource("Thon, Mara", "user166"), new AccessIdRepresentationModel("Thon, Mara", "user166"),
new AccessIdResource("Quark, Marga", "user167"), new AccessIdRepresentationModel("Quark, Marga", "user167"),
new AccessIdResource("Nade, Marie", "user168"), new AccessIdRepresentationModel("Nade, Marie", "user168"),
new AccessIdResource("Niert, Marie", "user169"), new AccessIdRepresentationModel("Niert, Marie", "user169"),
new AccessIdResource("Neese, Mario", "user170"), new AccessIdRepresentationModel("Neese, Mario", "user170"),
new AccessIdResource("Nette, Marion", "user171"), new AccessIdRepresentationModel("Nette, Marion", "user171"),
new AccessIdResource("Nesium, Mark", "user172"), new AccessIdRepresentationModel("Nesium, Mark", "user172"),
new AccessIdResource("Thalle, Mark", "user173"), new AccessIdRepresentationModel("Thalle, Mark", "user173"),
new AccessIdResource("Diven, Marle", "user174"), new AccessIdRepresentationModel("Diven, Marle", "user174"),
new AccessIdResource("Fitz, Marle", "user175"), new AccessIdRepresentationModel("Fitz, Marle", "user175"),
new AccessIdResource("Pfahl, Marta", "user176"), new AccessIdRepresentationModel("Pfahl, Marta", "user176"),
new AccessIdResource("Zorn, Martin", "user177"), new AccessIdRepresentationModel("Zorn, Martin", "user177"),
new AccessIdResource("Krissmes, Mary", "user178"), new AccessIdRepresentationModel("Krissmes, Mary", "user178"),
new AccessIdResource("Jess, Matt", "user179"), new AccessIdRepresentationModel("Jess, Matt", "user179"),
new AccessIdResource("Strammer, Max", "user180"), new AccessIdRepresentationModel("Strammer, Max", "user180"),
new AccessIdResource("Mumm, Maxi", "user181"), new AccessIdRepresentationModel("Mumm, Maxi", "user181"),
new AccessIdResource("Morphose, Meta", "user182"), new AccessIdRepresentationModel("Morphose, Meta", "user182"),
new AccessIdResource("Uh, Mia", "user183"), new AccessIdRepresentationModel("Uh, Mia", "user183"),
new AccessIdResource("Rofon, Mike", "user184"), new AccessIdRepresentationModel("Rofon, Mike", "user184"),
new AccessIdResource("Rosoft, Mike", "user185"), new AccessIdRepresentationModel("Rosoft, Mike", "user185"),
new AccessIdResource("Liter, Milli", "user186"), new AccessIdRepresentationModel("Liter, Milli", "user186"),
new AccessIdResource("Thär, Milli", "user187"), new AccessIdRepresentationModel("Thär, Milli", "user187"),
new AccessIdResource("Welle, Mirko", "user188"), new AccessIdRepresentationModel("Welle, Mirko", "user188"),
new AccessIdResource("Thorat, Mo", "user189"), new AccessIdRepresentationModel("Thorat, Mo", "user189"),
new AccessIdResource("Thor, Moni", "user190"), new AccessIdRepresentationModel("Thor, Moni", "user190"),
new AccessIdResource("Kinolta, Monika", "user191"), new AccessIdRepresentationModel("Kinolta, Monika", "user191"),
new AccessIdResource("Mundhaar, Monika", "user192"), new AccessIdRepresentationModel("Mundhaar, Monika", "user192"),
new AccessIdResource("Munter, Monika", "user193"), new AccessIdRepresentationModel("Munter, Monika", "user193"),
new AccessIdResource("Zwerg, Nat", "user194"), new AccessIdRepresentationModel("Zwerg, Nat", "user194"),
new AccessIdResource("Elmine, Nick", "user195"), new AccessIdRepresentationModel("Elmine, Nick", "user195"),
new AccessIdResource("Thien, Niko", "user196"), new AccessIdRepresentationModel("Thien, Niko", "user196"),
new AccessIdResource("Pferd, Nils", "user197"), new AccessIdRepresentationModel("Pferd, Nils", "user197"),
new AccessIdResource("Lerweise, Norma", "user198"), new AccessIdRepresentationModel("Lerweise, Norma", "user198"),
new AccessIdResource("Motor, Otto", "user199"), new AccessIdRepresentationModel("Motor, Otto", "user199"),
new AccessIdResource("Totol, Otto", "user200"), new AccessIdRepresentationModel("Totol, Otto", "user200"),
new AccessIdResource("Nerr, Paula", "user201"), new AccessIdRepresentationModel("Nerr, Paula", "user201"),
new AccessIdResource("Imeter, Peer", "user202"), new AccessIdRepresentationModel("Imeter, Peer", "user202"),
new AccessIdResource("Serkatze, Peer", "user203"), new AccessIdRepresentationModel("Serkatze, Peer", "user203"),
new AccessIdResource("Gogisch, Peter", "user204"), new AccessIdRepresentationModel("Gogisch, Peter", "user204"),
new AccessIdResource("Silje, Peter", "user205"), new AccessIdRepresentationModel("Silje, Peter", "user205"),
new AccessIdResource("Harmonie, Phil", "user206"), new AccessIdRepresentationModel("Harmonie, Phil", "user206"),
new AccessIdResource("Ihnen, Philip", "user207"), new AccessIdRepresentationModel("Ihnen, Philip", "user207"),
new AccessIdResource("Uto, Pia", "user208"), new AccessIdRepresentationModel("Uto, Pia", "user208"),
new AccessIdResource("Kothek, Pina", "user209"), new AccessIdRepresentationModel("Kothek, Pina", "user209"),
new AccessIdResource("Zar, Pit", "user210"), new AccessIdRepresentationModel("Zar, Pit", "user210"),
new AccessIdResource("Zeih, Polly", "user211"), new AccessIdRepresentationModel("Zeih, Polly", "user211"),
new AccessIdResource("Tswan, Puh", "user212"), new AccessIdRepresentationModel("Tswan, Puh", "user212"),
new AccessIdResource("Zufall, Rainer", "user213"), new AccessIdRepresentationModel("Zufall, Rainer", "user213"),
new AccessIdResource("Lien, Rita", "user214"), new AccessIdRepresentationModel("Lien, Rita", "user214"),
new AccessIdResource("Held, Roman", "user215"), new AccessIdRepresentationModel("Held, Roman", "user215"),
new AccessIdResource("Haar, Ross", "user216"), new AccessIdRepresentationModel("Haar, Ross", "user216"),
new AccessIdResource("Dick, Roy", "user217"), new AccessIdRepresentationModel("Dick, Roy", "user217"),
new AccessIdResource("Enplaner, Ruth", "user218"), new AccessIdRepresentationModel("Enplaner, Ruth", "user218"),
new AccessIdResource("Kommen, Ryan", "user219"), new AccessIdRepresentationModel("Kommen, Ryan", "user219"),
new AccessIdResource("Philo, Sophie", "user220"), new AccessIdRepresentationModel("Philo, Sophie", "user220"),
new AccessIdResource("Matisier, Stig", "user221"), new AccessIdRepresentationModel("Matisier, Stig", "user221"),
new AccessIdResource("Loniki, Tessa", "user222"), new AccessIdRepresentationModel("Loniki, Tessa", "user222"),
new AccessIdResource("Tralisch, Thea", "user223"), new AccessIdRepresentationModel("Tralisch, Thea", "user223"),
new AccessIdResource("Logie, Theo", "user224"), new AccessIdRepresentationModel("Logie, Theo", "user224"),
new AccessIdResource("Ister, Thorn", "user225"), new AccessIdRepresentationModel("Ister, Thorn", "user225"),
new AccessIdResource("Buktu, Tim", "user226"), new AccessIdRepresentationModel("Buktu, Tim", "user226"),
new AccessIdResource("Ate, Tom", "user227"), new AccessIdRepresentationModel("Ate, Tom", "user227"),
new AccessIdResource("Pie, Udo", "user228"), new AccessIdRepresentationModel("Pie, Udo", "user228"),
new AccessIdResource("Aloe, Vera", "user229"), new AccessIdRepresentationModel("Aloe, Vera", "user229"),
new AccessIdResource("Hausver, Walter", "user230"), new AccessIdRepresentationModel("Hausver, Walter", "user230"),
new AccessIdResource("Schuh, Wanda", "user231"), new AccessIdRepresentationModel("Schuh, Wanda", "user231"),
new AccessIdResource("Rahm, Wolf", "user232"), new AccessIdRepresentationModel("Rahm, Wolf", "user232"),
new AccessIdResource("businessadmin", "cn=businessadmin,ou=groups,o=taskanatest"), new AccessIdRepresentationModel(
new AccessIdResource("UsersGroup", "cn=usersgroup,ou=groups,o=taskanatest"), "businessadmin", "cn=businessadmin,ou=groups,o=taskanatest"),
new AccessIdResource("DevelopersGroup", "cn=developersgroup,ou=groups,o=taskanatest"), new AccessIdRepresentationModel(
new AccessIdResource("businessadmin", "cn=customersgroup,ou=groups,o=taskanatest"), "UsersGroup", "cn=usersgroup,ou=groups,o=taskanatest"),
new AccessIdResource("user_domain_A", "cn=user_domain_a,ou=groups,o=taskanatest"), new AccessIdRepresentationModel(
new AccessIdResource("monitor", "cn=monitor,ou=groups,o=taskanatest"), "DevelopersGroup", "cn=developersgroup,ou=groups,o=taskanatest"),
new AccessIdResource("user_domain_C", "cn=user_domain_c,ou=groups,o=taskanatest"), new AccessIdRepresentationModel(
new AccessIdResource("user_domain_D", "cn=user_domain_d,ou=groups,o=taskanatest"), "businessadmin", "cn=customersgroup,ou=groups,o=taskanatest"),
new AccessIdResource("admin", "cn=admin,ou=groups,o=taskanatest"), new AccessIdRepresentationModel(
new AccessIdResource( "user_domain_A", "cn=user_domain_a,ou=groups,o=taskanatest"),
new AccessIdRepresentationModel("monitor", "cn=monitor,ou=groups,o=taskanatest"),
new AccessIdRepresentationModel(
"user_domain_C", "cn=user_domain_c,ou=groups,o=taskanatest"),
new AccessIdRepresentationModel(
"user_domain_D", "cn=user_domain_d,ou=groups,o=taskanatest"),
new AccessIdRepresentationModel("admin", "cn=admin,ou=groups,o=taskanatest"),
new AccessIdRepresentationModel(
"manager_domain_B", "cn=manager_domain_b,ou=groups,o=taskanatest"), "manager_domain_B", "cn=manager_domain_b,ou=groups,o=taskanatest"),
new AccessIdResource( new AccessIdRepresentationModel(
"manager_domain_C", "cn=manager_domain_c,ou=groups,o=taskanatest"), "manager_domain_C", "cn=manager_domain_c,ou=groups,o=taskanatest"),
new AccessIdResource( new AccessIdRepresentationModel(
"manager_domain_D", "cn=manager_domain_d,ou=groups,o=taskanatest"), "manager_domain_D", "cn=manager_domain_d,ou=groups,o=taskanatest"),
new AccessIdResource("teamlead_2", "cn=teamlead_2" + ",ou=groups,o=taskanatest"), new AccessIdRepresentationModel(
new AccessIdResource("teamlead_4", "cn=teamlead_4" + ",ou=groups,o=taskanatest"), "teamlead_2", "cn=teamlead_2" + ",ou=groups,o=taskanatest"),
new AccessIdResource("team_3", "cn=team_3" + ",ou=groups,o=taskanatest"), new AccessIdRepresentationModel(
new AccessIdResource("team_4", "cn=team_4" + ",ou=groups,o=taskanatest"))); "teamlead_4", "cn=teamlead_4" + ",ou=groups,o=taskanatest"),
new AccessIdRepresentationModel("team_3", "cn=team_3" + ",ou=groups,o=taskanatest"),
new AccessIdRepresentationModel("team_4", "cn=team_4" + ",ou=groups,o=taskanatest")));
@Override @Override
public List<AccessIdResource> findMatchingAccessId( public List<AccessIdRepresentationModel> findMatchingAccessId(
String searchFor, int maxNumberOfReturnedAccessIds) { String searchFor, int maxNumberOfReturnedAccessIds) {
return findAcessIdResource(searchFor, maxNumberOfReturnedAccessIds, false); return findAcessIdResource(searchFor, maxNumberOfReturnedAccessIds, false);
} }
@Override @Override
public List<AccessIdResource> findGroupsOfUser( public List<AccessIdRepresentationModel> findGroupsOfUser(
String searchFor, int maxNumberOfReturnedAccessIds) { String searchFor, int maxNumberOfReturnedAccessIds) {
if (users == null) { if (users == null) {
users = addUsersToGroups(); users = addUsersToGroups();
@ -304,15 +314,15 @@ public class LdapCacheTestImpl implements LdapCache {
} }
@Override @Override
public List<AccessIdResource> validateAccessId(String accessId) { public List<AccessIdRepresentationModel> validateAccessId(String accessId) {
return accessIds.stream() return accessIds.stream()
.filter(t -> (t.getAccessId().equalsIgnoreCase(accessId.toLowerCase()))) .filter(t -> (t.getAccessId().equalsIgnoreCase(accessId.toLowerCase())))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
private List<AccessIdResource> findAcessIdResource( private List<AccessIdRepresentationModel> findAcessIdResource(
String searchFor, int maxNumberOfReturnedAccessIds, boolean groupMember) { String searchFor, int maxNumberOfReturnedAccessIds, boolean groupMember) {
List<AccessIdResource> usersAndGroups = List<AccessIdRepresentationModel> usersAndGroups =
accessIds.stream() accessIds.stream()
.filter( .filter(
t -> t ->
@ -320,7 +330,7 @@ public class LdapCacheTestImpl implements LdapCache {
|| t.getAccessId().toLowerCase().contains(searchFor.toLowerCase()))) || t.getAccessId().toLowerCase().contains(searchFor.toLowerCase())))
.collect(Collectors.toList()); .collect(Collectors.toList());
List<AccessIdResource> usersAndGroupsAux = new ArrayList<>(usersAndGroups); List<AccessIdRepresentationModel> usersAndGroupsAux = new ArrayList<>(usersAndGroups);
if (groupMember) { if (groupMember) {
usersAndGroupsAux.forEach( usersAndGroupsAux.forEach(
item -> { item -> {
@ -331,36 +341,32 @@ public class LdapCacheTestImpl implements LdapCache {
} }
usersAndGroups.sort( usersAndGroups.sort(
(AccessIdResource a, AccessIdResource b) -> { Comparator.comparing(
return a.getAccessId().compareToIgnoreCase(b.getAccessId()); AccessIdRepresentationModel::getAccessId, String.CASE_INSENSITIVE_ORDER));
});
List<AccessIdResource> result = return usersAndGroups.subList(0, Math.min(usersAndGroups.size(), maxNumberOfReturnedAccessIds));
usersAndGroups.subList(0, Math.min(usersAndGroups.size(), maxNumberOfReturnedAccessIds));
return result;
} }
private Map<AccessIdResource, List<AccessIdResource>> addUsersToGroups() { private Map<AccessIdRepresentationModel, List<AccessIdRepresentationModel>> addUsersToGroups() {
List<AccessIdResource> groups = new ArrayList<>(); List<AccessIdRepresentationModel> groups = new ArrayList<>();
Map<AccessIdResource, List<AccessIdResource>> users = new HashMap<>(); Map<AccessIdRepresentationModel, List<AccessIdRepresentationModel>> userMap = new HashMap<>();
accessIds.forEach( accessIds.forEach(
item -> { item -> {
if (!item.getAccessId().contains("ou=groups")) { if (!item.getAccessId().contains("ou=groups")) {
users.put(item, new ArrayList<>()); userMap.put(item, new ArrayList<>());
} else { } else {
groups.add(item); groups.add(item);
} }
}); });
int groupNumber = 0; int groupNumber = 0;
List<AccessIdResource> group0 = new ArrayList<>(); List<AccessIdRepresentationModel> group0 = new ArrayList<>();
List<AccessIdResource> group1 = new ArrayList<>(); List<AccessIdRepresentationModel> group1 = new ArrayList<>();
List<AccessIdResource> group2 = new ArrayList<>(); List<AccessIdRepresentationModel> group2 = new ArrayList<>();
List<AccessIdResource> group3 = new ArrayList<>(); List<AccessIdRepresentationModel> group3 = new ArrayList<>();
for (AccessIdResource group : groups) { for (AccessIdRepresentationModel group : groups) {
switch (groupNumber) { switch (groupNumber) {
case 0: case 0:
group0.add(group); group0.add(group);
@ -381,20 +387,20 @@ public class LdapCacheTestImpl implements LdapCache {
} }
int countUser = 0; int countUser = 0;
for (AccessIdResource item : accessIds) { for (AccessIdRepresentationModel item : accessIds) {
if (!item.getAccessId().contains("ou=groups")) { if (!item.getAccessId().contains("ou=groups")) {
switch (countUser) { switch (countUser) {
case 0: case 0:
users.put(item, group0); userMap.put(item, group0);
break; break;
case 1: case 1:
users.put(item, group1); userMap.put(item, group1);
break; break;
case 2: case 2:
users.put(item, group2); userMap.put(item, group2);
break; break;
case 3: case 3:
users.put(item, group3); userMap.put(item, group3);
break; break;
default: default:
break; break;
@ -402,6 +408,6 @@ public class LdapCacheTestImpl implements LdapCache {
} }
countUser = (countUser + 1) % 4; countUser = (countUser + 1) % 4;
} }
return users; return userMap;
} }
} }

View File

@ -13,7 +13,7 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic
import pro.taskana.common.internal.security.GroupPrincipal; import pro.taskana.common.internal.security.GroupPrincipal;
import pro.taskana.common.internal.security.UserPrincipal; import pro.taskana.common.internal.security.UserPrincipal;
import pro.taskana.ldap.LdapCacheTestImpl; import pro.taskana.ldap.LdapCacheTestImpl;
import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.AccessIdRepresentationModel;
/** TODO. */ /** TODO. */
public class SampleLoginModule extends UsernamePasswordAuthenticationFilter implements LoginModule { public class SampleLoginModule extends UsernamePasswordAuthenticationFilter implements LoginModule {
@ -68,9 +68,10 @@ public class SampleLoginModule extends UsernamePasswordAuthenticationFilter impl
private void addGroupSubjectsDerivedFromUsername() { private void addGroupSubjectsDerivedFromUsername() {
LdapCacheTestImpl ldapCacheTest = new LdapCacheTestImpl(); LdapCacheTestImpl ldapCacheTest = new LdapCacheTestImpl();
String username = nameCallback.getName().toLowerCase(); String username = nameCallback.getName().toLowerCase();
List<AccessIdResource> groups = ldapCacheTest.findGroupsOfUser(username, Integer.MAX_VALUE); List<AccessIdRepresentationModel> groups =
ldapCacheTest.findGroupsOfUser(username, Integer.MAX_VALUE);
groups.forEach( groups.forEach(
(AccessIdResource group) -> { (AccessIdRepresentationModel group) -> {
if (group.getAccessId().contains("ou=groups")) { if (group.getAccessId().contains("ou=groups")) {
subject.getPrincipals().add(new GroupPrincipal(group.getName())); subject.getPrincipals().add(new GroupPrincipal(group.getName()));
} }

View File

@ -26,10 +26,10 @@ import pro.taskana.classification.api.models.Classification;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.rest.Mapping; import pro.taskana.rest.Mapping;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
import pro.taskana.rest.resource.ClassificationResource; import pro.taskana.rest.resource.ClassificationRepresentationModel;
import pro.taskana.rest.resource.ClassificationResourceAssembler; import pro.taskana.rest.resource.ClassificationRepresentationModelAssembler;
import pro.taskana.rest.resource.TaskResource; import pro.taskana.rest.resource.TaskRepresentationModel;
import pro.taskana.rest.resource.TaskResourceAssembler; import pro.taskana.rest.resource.TaskRepresentationModelAssembler;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
/** Test async updates. */ /** Test async updates. */
@ -45,8 +45,8 @@ class AsyncUpdateJobIntTest {
@SuppressWarnings("checkstyle:DeclarationOrder") @SuppressWarnings("checkstyle:DeclarationOrder")
static RestTemplate template; static RestTemplate template;
@Autowired ClassificationResourceAssembler classificationResourceAssembler; @Autowired ClassificationRepresentationModelAssembler classificationRepresentationModelAssembler;
@Autowired TaskResourceAssembler taskResourceAssembler; @Autowired TaskRepresentationModelAssembler taskRepresentationModelAssembler;
@Autowired JobScheduler jobScheduler; @Autowired JobScheduler jobScheduler;
@Autowired RestHelper restHelper; @Autowired RestHelper restHelper;
@ -62,15 +62,15 @@ class AsyncUpdateJobIntTest {
final Instant before = Instant.now(); final Instant before = Instant.now();
final ObjectMapper mapper = new ObjectMapper(); final ObjectMapper mapper = new ObjectMapper();
ResponseEntity<ClassificationResource> response = ResponseEntity<ClassificationRepresentationModel> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID), restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID),
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<String>(restHelper.getHeaders()), new HttpEntity<String>(restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
assertThat(response.getBody()).isNotNull(); assertThat(response.getBody()).isNotNull();
ClassificationResource classification = response.getBody(); ClassificationRepresentationModel classification = response.getBody();
assertThat(classification.getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(classification.getLink(IanaLinkRelations.SELF)).isNotNull();
// 2nd step: modify classification and trigger update // 2nd step: modify classification and trigger update
@ -88,18 +88,20 @@ class AsyncUpdateJobIntTest {
jobScheduler.triggerJobs(); jobScheduler.triggerJobs();
// verify the classification modified timestamp is after 'before' // verify the classification modified timestamp is after 'before'
ResponseEntity<ClassificationResource> repeatedResponse = ResponseEntity<ClassificationRepresentationModel> repeatedResponse =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID), restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID),
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<String>(restHelper.getHeaders()), new HttpEntity<String>(restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
assertThat(repeatedResponse.getBody()).isNotNull(); assertThat(repeatedResponse.getBody()).isNotNull();
ClassificationResource modifiedClassificationResource = repeatedResponse.getBody(); ClassificationRepresentationModel modifiedClassificationRepresentationModel =
repeatedResponse.getBody();
Classification modifiedClassification = Classification modifiedClassification =
classificationResourceAssembler.toModel(modifiedClassificationResource); classificationRepresentationModelAssembler.toEntityModel(
modifiedClassificationRepresentationModel);
assertThat(before).isBefore(modifiedClassification.getModified()); assertThat(before).isBefore(modifiedClassification.getModified());
@ -151,15 +153,15 @@ class AsyncUpdateJobIntTest {
private void verifyTaskIsModifiedAfterOrEquals(String taskId, Instant before) private void verifyTaskIsModifiedAfterOrEquals(String taskId, Instant before)
throws InvalidArgumentException { throws InvalidArgumentException {
ResponseEntity<TaskResource> taskResponse = ResponseEntity<TaskRepresentationModel> taskResponse =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS_ID, taskId), restHelper.toUrl(Mapping.URL_TASKS_ID, taskId),
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<>(restHelper.getHeadersAdmin()), new HttpEntity<>(restHelper.getHeadersAdmin()),
ParameterizedTypeReference.forType(TaskResource.class)); ParameterizedTypeReference.forType(TaskRepresentationModel.class));
TaskResource taskResource = taskResponse.getBody(); TaskRepresentationModel taskRepresentationModel = taskResponse.getBody();
Task task = taskResourceAssembler.toModel(taskResource); Task task = taskRepresentationModelAssembler.toEntityModel(taskRepresentationModel);
Instant modified = task.getModified(); Instant modified = task.getModified();
assertThat(before).as("Task " + task.getId() + " has not been refreshed.").isBefore(modified); assertThat(before).as("Task " + task.getId() + " has not been refreshed.").isBefore(modified);

View File

@ -13,7 +13,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
import pro.taskana.common.api.LoggerUtils; import pro.taskana.common.api.LoggerUtils;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.AccessIdRepresentationModel;
/** Test Ldap attachment. */ /** Test Ldap attachment. */
@ActiveProfiles({"test"}) @ActiveProfiles({"test"})
@ -28,7 +28,7 @@ class LdapTest {
@Test @Test
void testFindUsers() throws InvalidArgumentException { void testFindUsers() throws InvalidArgumentException {
if (ldapClient.useLdap()) { if (ldapClient.useLdap()) {
List<AccessIdResource> usersAndGroups = ldapClient.searchUsersAndGroups("ser0"); List<AccessIdRepresentationModel> usersAndGroups = ldapClient.searchUsersAndGroups("ser0");
System.out.println("#### found " + LoggerUtils.listToString(usersAndGroups)); System.out.println("#### found " + LoggerUtils.listToString(usersAndGroups));
assertThat(usersAndGroups).hasSize(50); assertThat(usersAndGroups).hasSize(50);
} }

View File

@ -22,11 +22,10 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import pro.taskana.rest.resource.TaskanaUserInfoResource; import pro.taskana.rest.resource.TaskanaUserInfoRepresentationModel;
/** /**
* This test class is configured to run with postgres DB if you want to run it with h2 it is needed. * This test class is configured to run with postgres DB if you want to run it with h2 it is needed.
@ -59,14 +58,14 @@ public class TaskanaWildflyTest {
public void shouldGetStatusOK() { public void shouldGetStatusOK() {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<>(headers);
ResponseEntity<TaskanaUserInfoResource> response = ResponseEntity<TaskanaUserInfoRepresentationModel> response =
getRestTemplate() getRestTemplate()
.exchange( .exchange(
"http://127.0.0.1:" + "8090" + "/api/v1/current-user-info", "http://127.0.0.1:" + "8090" + "/api/v1/current-user-info",
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(TaskanaUserInfoResource.class)); ParameterizedTypeReference.forType(TaskanaUserInfoRepresentationModel.class));
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.OK, response.getStatusCode());
} }
@ -78,8 +77,6 @@ public class TaskanaWildflyTest {
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/json")); converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/json"));
converter.setObjectMapper(mapper); converter.setObjectMapper(mapper);
RestTemplate template = return new RestTemplate(Collections.singletonList(converter));
new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
return template;
} }
} }

View File

@ -2,7 +2,7 @@ package pro.taskana.ldap;
import java.util.List; import java.util.List;
import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.AccessIdRepresentationModel;
/** /**
* This interface is used for caching Ldap data. * This interface is used for caching Ldap data.
@ -20,7 +20,8 @@ public interface LdapCache {
* @return a List of access ids for users and group where the name or id contains the search * @return a List of access ids for users and group where the name or id contains the search
* string. * string.
*/ */
List<AccessIdResource> findMatchingAccessId(String searchFor, int maxNumberOfReturnedAccessIds); List<AccessIdRepresentationModel> findMatchingAccessId(
String searchFor, int maxNumberOfReturnedAccessIds);
/** /**
* Find the groups belong to a user. * Find the groups belong to a user.
@ -29,7 +30,8 @@ public interface LdapCache {
* @param maxNumberOfReturnedAccessIds the maximum number of results to return. * @param maxNumberOfReturnedAccessIds the maximum number of results to return.
* @return a List of access ids for groups of users. * @return a List of access ids for groups of users.
*/ */
List<AccessIdResource> findGroupsOfUser(String searchFor, int maxNumberOfReturnedAccessIds); List<AccessIdRepresentationModel> findGroupsOfUser(
String searchFor, int maxNumberOfReturnedAccessIds);
/** /**
* Validate a access id. * Validate a access id.
@ -37,5 +39,5 @@ public interface LdapCache {
* @param accessId the search string. * @param accessId the search string.
* @return the corresponding access ids. * @return the corresponding access ids.
*/ */
List<AccessIdResource> validateAccessId(String accessId); List<AccessIdRepresentationModel> validateAccessId(String accessId);
} }

View File

@ -2,6 +2,7 @@ package pro.taskana.ldap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -24,7 +25,7 @@ import org.springframework.stereotype.Component;
import pro.taskana.common.api.LoggerUtils; import pro.taskana.common.api.LoggerUtils;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.AccessIdRepresentationModel;
/** /**
* Class for Ldap access. * Class for Ldap access.
@ -62,15 +63,15 @@ public class LdapClient {
* maxNumberOfReturnedAccessIds * maxNumberOfReturnedAccessIds
* @throws InvalidArgumentException if input is shorter than minSearchForLength * @throws InvalidArgumentException if input is shorter than minSearchForLength
*/ */
public List<AccessIdResource> searchUsersAndGroups(final String name) public List<AccessIdRepresentationModel> searchUsersAndGroups(final String name)
throws InvalidArgumentException { throws InvalidArgumentException {
LOGGER.debug("entry to searchUsersAndGroups(name = {})", name); LOGGER.debug("entry to searchUsersAndGroups(name = {})", name);
isInitOrFail(); isInitOrFail();
testMinSearchForLength(name); testMinSearchForLength(name);
List<AccessIdResource> accessIds = new ArrayList<>(); List<AccessIdRepresentationModel> accessIds = new ArrayList<>();
if (nameIsDn(name)) { if (nameIsDn(name)) {
AccessIdResource groupByDn = searchGroupByDn(name); AccessIdRepresentationModel groupByDn = searchGroupByDn(name);
if (groupByDn != null) { if (groupByDn != null) {
accessIds.add(groupByDn); accessIds.add(groupByDn);
} }
@ -79,7 +80,7 @@ public class LdapClient {
accessIds.addAll(searchGroupsByName(name)); accessIds.addAll(searchGroupsByName(name));
} }
sortListOfAccessIdResources(accessIds); sortListOfAccessIdResources(accessIds);
List<AccessIdResource> result = getFirstPageOfaResultList(accessIds); List<AccessIdRepresentationModel> result = getFirstPageOfaResultList(accessIds);
LOGGER.debug( LOGGER.debug(
"exit from searchUsersAndGroups(name = {}). Returning {} users and groups: {}", "exit from searchUsersAndGroups(name = {}). Returning {} users and groups: {}",
@ -90,7 +91,7 @@ public class LdapClient {
return result; return result;
} }
public List<AccessIdResource> searchUsersByName(final String name) public List<AccessIdRepresentationModel> searchUsersByName(final String name)
throws InvalidArgumentException { throws InvalidArgumentException {
LOGGER.debug("entry to searchUsersByName(name = {}).", name); LOGGER.debug("entry to searchUsersByName(name = {}).", name);
isInitOrFail(); isInitOrFail();
@ -109,7 +110,7 @@ public class LdapClient {
getUserFirstnameAttribute(), getUserLastnameAttribute(), getUserIdAttribute() getUserFirstnameAttribute(), getUserLastnameAttribute(), getUserIdAttribute()
}; };
final List<AccessIdResource> accessIds = final List<AccessIdRepresentationModel> accessIds =
ldapTemplate.search( ldapTemplate.search(
getUserSearchBase(), getUserSearchBase(),
andFilter.encode(), andFilter.encode(),
@ -122,7 +123,7 @@ public class LdapClient {
return accessIds; return accessIds;
} }
public List<AccessIdResource> searchGroupsByName(final String name) public List<AccessIdRepresentationModel> searchGroupsByName(final String name)
throws InvalidArgumentException { throws InvalidArgumentException {
LOGGER.debug("entry to searchGroupsByName(name = {}).", name); LOGGER.debug("entry to searchGroupsByName(name = {}).", name);
isInitOrFail(); isInitOrFail();
@ -137,7 +138,7 @@ public class LdapClient {
} }
andFilter.and(orFilter); andFilter.and(orFilter);
final List<AccessIdResource> accessIds = final List<AccessIdRepresentationModel> accessIds =
ldapTemplate.search( ldapTemplate.search(
getGroupSearchBase(), getGroupSearchBase(),
andFilter.encode(), andFilter.encode(),
@ -150,7 +151,7 @@ public class LdapClient {
return accessIds; return accessIds;
} }
public AccessIdResource searchGroupByDn(final String name) { public AccessIdRepresentationModel searchGroupByDn(final String name) {
LOGGER.debug("entry to searchGroupByDn(name = {}).", name); LOGGER.debug("entry to searchGroupByDn(name = {}).", name);
isInitOrFail(); isInitOrFail();
// Obviously Spring LdapTemplate does have a inconsistency and always adds the base name to the // Obviously Spring LdapTemplate does have a inconsistency and always adds the base name to the
@ -160,14 +161,14 @@ public class LdapClient {
String nameWithoutBaseDn = getNameWithoutBaseDn(name); String nameWithoutBaseDn = getNameWithoutBaseDn(name);
LOGGER.debug( LOGGER.debug(
"Removed baseDN {} from given DN. New DN to be used: {}", getBaseDn(), nameWithoutBaseDn); "Removed baseDN {} from given DN. New DN to be used: {}", getBaseDn(), nameWithoutBaseDn);
final AccessIdResource accessId = final AccessIdRepresentationModel accessId =
ldapTemplate.lookup( ldapTemplate.lookup(
nameWithoutBaseDn, getLookUpGoupAttributesToReturn(), new GroupContextMapper()); nameWithoutBaseDn, getLookUpGoupAttributesToReturn(), new GroupContextMapper());
LOGGER.debug("Exit from searchGroupByDn. Retrieved the following group: {}", accessId); LOGGER.debug("Exit from searchGroupByDn. Retrieved the following group: {}", accessId);
return accessId; return accessId;
} }
public List<AccessIdResource> searchGroupsofUsersIsMember(final String name) public List<AccessIdRepresentationModel> searchGroupsofUsersIsMember(final String name)
throws InvalidArgumentException { throws InvalidArgumentException {
LOGGER.debug("entry to searchGroupsofUsersIsMember(name = {}).", name); LOGGER.debug("entry to searchGroupsofUsersIsMember(name = {}).", name);
isInitOrFail(); isInitOrFail();
@ -179,7 +180,7 @@ public class LdapClient {
String[] userAttributesToReturn = {getUserIdAttribute(), getGroupNameAttribute()}; String[] userAttributesToReturn = {getUserIdAttribute(), getGroupNameAttribute()};
final List<AccessIdResource> accessIds = final List<AccessIdRepresentationModel> accessIds =
ldapTemplate.search( ldapTemplate.search(
getGroupSearchBase(), getGroupSearchBase(),
andFilter.encode(), andFilter.encode(),
@ -278,7 +279,8 @@ public class LdapClient {
return name.toLowerCase().endsWith(getBaseDn().toLowerCase()); return name.toLowerCase().endsWith(getBaseDn().toLowerCase());
} }
List<AccessIdResource> getFirstPageOfaResultList(List<AccessIdResource> accessIds) { List<AccessIdRepresentationModel> getFirstPageOfaResultList(
List<AccessIdRepresentationModel> accessIds) {
return accessIds.subList(0, Math.min(accessIds.size(), maxNumberOfReturnedAccessIds)); return accessIds.subList(0, Math.min(accessIds.size(), maxNumberOfReturnedAccessIds));
} }
@ -288,10 +290,10 @@ public class LdapClient {
} }
} }
void sortListOfAccessIdResources(List<AccessIdResource> accessIds) { void sortListOfAccessIdResources(List<AccessIdRepresentationModel> accessIds) {
accessIds.sort( accessIds.sort(
(AccessIdResource a, AccessIdResource b) -> Comparator.comparing(
a.getAccessId().compareToIgnoreCase(b.getAccessId())); AccessIdRepresentationModel::getAccessId, String.CASE_INSENSITIVE_ORDER));
} }
String getNameWithoutBaseDn(String name) { String getNameWithoutBaseDn(String name) {
@ -357,11 +359,11 @@ public class LdapClient {
} }
/** Context Mapper for user entries. */ /** Context Mapper for user entries. */
class GroupContextMapper extends AbstractContextMapper<AccessIdResource> { class GroupContextMapper extends AbstractContextMapper<AccessIdRepresentationModel> {
@Override @Override
public AccessIdResource doMapFromContext(final DirContextOperations context) { public AccessIdRepresentationModel doMapFromContext(final DirContextOperations context) {
final AccessIdResource accessId = new AccessIdResource(); final AccessIdRepresentationModel accessId = new AccessIdRepresentationModel();
String dn = getDnWithBaseDn(context.getDn().toString()); String dn = getDnWithBaseDn(context.getDn().toString());
accessId.setAccessId(dn); // fully qualified dn accessId.setAccessId(dn); // fully qualified dn
accessId.setName(context.getStringAttribute(getGroupNameAttribute())); accessId.setName(context.getStringAttribute(getGroupNameAttribute()));
@ -370,11 +372,11 @@ public class LdapClient {
} }
/** Context Mapper for user entries. */ /** Context Mapper for user entries. */
class UserContextMapper extends AbstractContextMapper<AccessIdResource> { class UserContextMapper extends AbstractContextMapper<AccessIdRepresentationModel> {
@Override @Override
public AccessIdResource doMapFromContext(final DirContextOperations context) { public AccessIdRepresentationModel doMapFromContext(final DirContextOperations context) {
final AccessIdResource accessId = new AccessIdResource(); final AccessIdRepresentationModel accessId = new AccessIdRepresentationModel();
accessId.setAccessId(context.getStringAttribute(getUserIdAttribute())); accessId.setAccessId(context.getStringAttribute(getUserIdAttribute()));
String firstName = context.getStringAttribute(getUserFirstnameAttribute()); String firstName = context.getStringAttribute(getUserFirstnameAttribute());
String lastName = context.getStringAttribute(getUserLastnameAttribute()); String lastName = context.getStringAttribute(getUserLastnameAttribute());

View File

@ -3,11 +3,11 @@ package pro.taskana.rest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import pro.taskana.common.api.BaseQuery; import pro.taskana.common.api.BaseQuery;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.rest.resource.PagedResources.PageMetadata;
/** Abstract superclass for taskana REST controller with pageable resources. */ /** Abstract superclass for taskana REST controller with pageable resources. */
public abstract class AbstractPagingController { public abstract class AbstractPagingController {

View File

@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.ldap.LdapCache; import pro.taskana.ldap.LdapCache;
import pro.taskana.ldap.LdapClient; import pro.taskana.ldap.LdapClient;
import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.AccessIdRepresentationModel;
/** /**
* Controller for access id validation. * Controller for access id validation.
@ -30,7 +30,7 @@ public class AccessIdController {
@Autowired LdapClient ldapClient; @Autowired LdapClient ldapClient;
@GetMapping(path = Mapping.URL_ACCESSID) @GetMapping(path = Mapping.URL_ACCESSID)
public ResponseEntity<List<AccessIdResource>> validateAccessIds( public ResponseEntity<List<AccessIdRepresentationModel>> validateAccessIds(
@RequestParam("search-for") String searchFor) throws InvalidArgumentException { @RequestParam("search-for") String searchFor) throws InvalidArgumentException {
LOGGER.debug("Entry to validateAccessIds(search-for= {})", searchFor); LOGGER.debug("Entry to validateAccessIds(search-for= {})", searchFor);
if (searchFor.length() < ldapClient.getMinSearchForLength()) { if (searchFor.length() < ldapClient.getMinSearchForLength()) {
@ -40,9 +40,9 @@ public class AccessIdController {
+ "' is too short. Minimum searchFor length = " + "' is too short. Minimum searchFor length = "
+ ldapClient.getMinSearchForLength()); + ldapClient.getMinSearchForLength());
} }
ResponseEntity<List<AccessIdResource>> response; ResponseEntity<List<AccessIdRepresentationModel>> response;
if (ldapClient.useLdap()) { if (ldapClient.useLdap()) {
List<AccessIdResource> accessIdUsers = ldapClient.searchUsersAndGroups(searchFor); List<AccessIdRepresentationModel> accessIdUsers = ldapClient.searchUsersAndGroups(searchFor);
response = ResponseEntity.ok(accessIdUsers); response = ResponseEntity.ok(accessIdUsers);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from validateAccessIds(), returning {}", response); LOGGER.debug("Exit from validateAccessIds(), returning {}", response);
@ -67,7 +67,7 @@ public class AccessIdController {
} }
@GetMapping(path = Mapping.URL_ACCESSID_GROUPS) @GetMapping(path = Mapping.URL_ACCESSID_GROUPS)
public ResponseEntity<List<AccessIdResource>> getGroupsByAccessId( public ResponseEntity<List<AccessIdRepresentationModel>> getGroupsByAccessId(
@RequestParam("access-id") String accessId) throws InvalidArgumentException { @RequestParam("access-id") String accessId) throws InvalidArgumentException {
LOGGER.debug("Entry to getGroupsByAccessId(access-id= {})", accessId); LOGGER.debug("Entry to getGroupsByAccessId(access-id= {})", accessId);
if (ldapClient.useLdap() || ldapCache != null) { if (ldapClient.useLdap() || ldapCache != null) {
@ -75,8 +75,8 @@ public class AccessIdController {
throw new InvalidArgumentException("The accessId is invalid"); throw new InvalidArgumentException("The accessId is invalid");
} }
} }
List<AccessIdResource> accessIdUsers; List<AccessIdRepresentationModel> accessIdUsers;
ResponseEntity<List<AccessIdResource>> response; ResponseEntity<List<AccessIdRepresentationModel>> response;
if (ldapClient.useLdap()) { if (ldapClient.useLdap()) {
accessIdUsers = ldapClient.searchUsersAndGroups(accessId); accessIdUsers = ldapClient.searchUsersAndGroups(accessId);
accessIdUsers.addAll(ldapClient.searchGroupsofUsersIsMember(accessId)); accessIdUsers.addAll(ldapClient.searchGroupsofUsersIsMember(accessId));

View File

@ -4,6 +4,7 @@ import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.hateoas.MediaTypes; import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType; import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -31,11 +32,11 @@ import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.DomainNotFoundException; import pro.taskana.common.api.exceptions.DomainNotFoundException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.rest.resource.ClassificationResource; import pro.taskana.rest.resource.ClassificationRepresentationModel;
import pro.taskana.rest.resource.ClassificationResourceAssembler; import pro.taskana.rest.resource.ClassificationRepresentationModelAssembler;
import pro.taskana.rest.resource.ClassificationSummaryListResource; import pro.taskana.rest.resource.ClassificationSummaryRepresentationModel;
import pro.taskana.rest.resource.ClassificationSummaryResourceAssembler; import pro.taskana.rest.resource.ClassificationSummaryRepresentationModelAssembler;
import pro.taskana.rest.resource.PagedResources.PageMetadata; import pro.taskana.rest.resource.TaskanaPagedModel;
/** Controller for all {@link Classification} related endpoints. */ /** Controller for all {@link Classification} related endpoints. */
@RestController @RestController
@ -78,39 +79,45 @@ public class ClassificationController extends AbstractPagingController {
private static final String SORT_DIRECTION = "order"; private static final String SORT_DIRECTION = "order";
private ClassificationService classificationService; private final ClassificationService classificationService;
private ClassificationResourceAssembler classificationResourceAssembler; private final ClassificationRepresentationModelAssembler
classificationRepresentationModelAssembler;
private ClassificationSummaryResourceAssembler classificationSummaryResourceAssembler; private final ClassificationSummaryRepresentationModelAssembler
classificationSummaryRepresentationModelAssembler;
ClassificationController( ClassificationController(
ClassificationService classificationService, ClassificationService classificationService,
ClassificationResourceAssembler classificationResourceAssembler, ClassificationRepresentationModelAssembler classificationRepresentationModelAssembler,
ClassificationSummaryResourceAssembler classificationSummaryResourceAssembler) { ClassificationSummaryRepresentationModelAssembler
classificationSummaryRepresentationModelAssembler) {
this.classificationService = classificationService; this.classificationService = classificationService;
this.classificationResourceAssembler = classificationResourceAssembler; this.classificationRepresentationModelAssembler = classificationRepresentationModelAssembler;
this.classificationSummaryResourceAssembler = classificationSummaryResourceAssembler; this.classificationSummaryRepresentationModelAssembler =
classificationSummaryRepresentationModelAssembler;
} }
@GetMapping(path = Mapping.URL_CLASSIFICATIONS) @GetMapping(path = Mapping.URL_CLASSIFICATIONS)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<ClassificationSummaryListResource> getClassifications( public ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>>
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException { getClassifications(
@RequestParam MultiValueMap<String, String> params)
throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getClassifications(params= {})", params); LOGGER.debug("Entry to getClassifications(params= {})", params);
} }
ClassificationQuery query = classificationService.createClassificationQuery(); ClassificationQuery query = classificationService.createClassificationQuery();
query = applySortingParams(query, params); query = applySortingParams(query, params);
query = applyFilterParams(query, params); applyFilterParams(query, params);
PageMetadata pageMetadata = getPageMetadata(params, query); PageMetadata pageMetadata = getPageMetadata(params, query);
List<ClassificationSummary> classificationSummaries = getQueryList(query, pageMetadata); List<ClassificationSummary> classificationSummaries = getQueryList(query, pageMetadata);
ResponseEntity<ClassificationSummaryListResource> response = ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response =
ResponseEntity.ok( ResponseEntity.ok(
classificationSummaryResourceAssembler.toCollectionModel( classificationSummaryRepresentationModelAssembler.toPageModel(
classificationSummaries, pageMetadata)); classificationSummaries, pageMetadata));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getClassifications(), returning {}", response); LOGGER.debug("Exit from getClassifications(), returning {}", response);
@ -121,15 +128,15 @@ public class ClassificationController extends AbstractPagingController {
@GetMapping(path = Mapping.URL_CLASSIFICATIONS_ID, produces = MediaTypes.HAL_JSON_VALUE) @GetMapping(path = Mapping.URL_CLASSIFICATIONS_ID, produces = MediaTypes.HAL_JSON_VALUE)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<ClassificationResource> getClassification( public ResponseEntity<ClassificationRepresentationModel> getClassification(
@PathVariable String classificationId) throws ClassificationNotFoundException { @PathVariable String classificationId) throws ClassificationNotFoundException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getClassification(classificationId= {})", classificationId); LOGGER.debug("Entry to getClassification(classificationId= {})", classificationId);
} }
Classification classification = classificationService.getClassification(classificationId); Classification classification = classificationService.getClassification(classificationId);
ResponseEntity<ClassificationResource> response = ResponseEntity<ClassificationRepresentationModel> response =
ResponseEntity.ok(classificationResourceAssembler.toModel(classification)); ResponseEntity.ok(classificationRepresentationModelAssembler.toModel(classification));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getClassification(), returning {}", response); LOGGER.debug("Exit from getClassification(), returning {}", response);
} }
@ -139,19 +146,20 @@ public class ClassificationController extends AbstractPagingController {
@PostMapping(path = Mapping.URL_CLASSIFICATIONS) @PostMapping(path = Mapping.URL_CLASSIFICATIONS)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<ClassificationResource> createClassification( public ResponseEntity<ClassificationRepresentationModel> createClassification(
@RequestBody ClassificationResource resource) @RequestBody ClassificationRepresentationModel resource)
throws NotAuthorizedException, ClassificationAlreadyExistException, DomainNotFoundException, throws NotAuthorizedException, ClassificationAlreadyExistException, DomainNotFoundException,
InvalidArgumentException { InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to createClassification(resource= {})", resource); LOGGER.debug("Entry to createClassification(resource= {})", resource);
} }
Classification classification = classificationResourceAssembler.toModel(resource); Classification classification = classificationRepresentationModelAssembler
.toEntityModel(resource);
classification = classificationService.createClassification(classification); classification = classificationService.createClassification(classification);
ResponseEntity<ClassificationResource> response = ResponseEntity<ClassificationRepresentationModel> response =
ResponseEntity.status(HttpStatus.CREATED) ResponseEntity.status(HttpStatus.CREATED)
.body(classificationResourceAssembler.toModel(classification)); .body(classificationRepresentationModelAssembler.toModel(classification));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from createClassification(), returning {}", response); LOGGER.debug("Exit from createClassification(), returning {}", response);
} }
@ -161,9 +169,9 @@ public class ClassificationController extends AbstractPagingController {
@PutMapping(path = Mapping.URL_CLASSIFICATIONS_ID) @PutMapping(path = Mapping.URL_CLASSIFICATIONS_ID)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<ClassificationResource> updateClassification( public ResponseEntity<ClassificationRepresentationModel> updateClassification(
@PathVariable(value = "classificationId") String classificationId, @PathVariable(value = "classificationId") String classificationId,
@RequestBody ClassificationResource resource) @RequestBody ClassificationRepresentationModel resource)
throws NotAuthorizedException, ClassificationNotFoundException, ConcurrencyException, throws NotAuthorizedException, ClassificationNotFoundException, ConcurrencyException,
InvalidArgumentException { InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
@ -173,11 +181,13 @@ public class ClassificationController extends AbstractPagingController {
resource); resource);
} }
ResponseEntity<ClassificationResource> result; ResponseEntity<ClassificationRepresentationModel> result;
if (classificationId.equals(resource.getClassificationId())) { if (classificationId.equals(resource.getClassificationId())) {
Classification classification = classificationResourceAssembler.toModel(resource); Classification classification = classificationRepresentationModelAssembler
.toEntityModel(resource);
classification = classificationService.updateClassification(classification); classification = classificationService.updateClassification(classification);
result = ResponseEntity.ok(classificationResourceAssembler.toModel(classification)); result =
ResponseEntity.ok(classificationRepresentationModelAssembler.toModel(classification));
} else { } else {
throw new InvalidArgumentException( throw new InvalidArgumentException(
"ClassificationId ('" "ClassificationId ('"
@ -247,7 +257,7 @@ public class ClassificationController extends AbstractPagingController {
return query; return query;
} }
private ClassificationQuery applyFilterParams( private void applyFilterParams(
ClassificationQuery query, MultiValueMap<String, String> params) ClassificationQuery query, MultiValueMap<String, String> params)
throws InvalidArgumentException { throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
@ -320,6 +330,5 @@ public class ClassificationController extends AbstractPagingController {
LOGGER.debug("Exit from applyFilterParams(), returning {}", query); LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
} }
return query;
} }
} }

View File

@ -34,8 +34,8 @@ import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.DomainNotFoundException; import pro.taskana.common.api.exceptions.DomainNotFoundException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.rest.resource.ClassificationResource; import pro.taskana.rest.resource.ClassificationRepresentationModel;
import pro.taskana.rest.resource.ClassificationResourceAssembler; import pro.taskana.rest.resource.ClassificationRepresentationModelAssembler;
/** Controller for Importing / Exporting classifications. */ /** Controller for Importing / Exporting classifications. */
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -48,34 +48,34 @@ public class ClassificationDefinitionController {
private ClassificationService classificationService; private ClassificationService classificationService;
private ClassificationResourceAssembler classificationResourceAssembler; private ClassificationRepresentationModelAssembler classificationRepresentationModelAssembler;
ClassificationDefinitionController( ClassificationDefinitionController(
ClassificationService classificationService, ClassificationService classificationService,
ClassificationResourceAssembler classificationResourceAssembler) { ClassificationRepresentationModelAssembler classificationRepresentationModelAssembler) {
this.classificationService = classificationService; this.classificationService = classificationService;
this.classificationResourceAssembler = classificationResourceAssembler; this.classificationRepresentationModelAssembler = classificationRepresentationModelAssembler;
} }
@GetMapping(path = Mapping.URL_CLASSIFICATIONDEFINITION) @GetMapping(path = Mapping.URL_CLASSIFICATIONDEFINITION)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<List<ClassificationResource>> exportClassifications( public ResponseEntity<List<ClassificationRepresentationModel>> exportClassifications(
@RequestParam(required = false) String domain) throws ClassificationNotFoundException { @RequestParam(required = false) String domain) throws ClassificationNotFoundException {
LOGGER.debug("Entry to exportClassifications(domain= {})", domain); LOGGER.debug("Entry to exportClassifications(domain= {})", domain);
ClassificationQuery query = classificationService.createClassificationQuery(); ClassificationQuery query = classificationService.createClassificationQuery();
List<ClassificationSummary> summaries = List<ClassificationSummary> summaries =
domain != null ? query.domainIn(domain).list() : query.list(); domain != null ? query.domainIn(domain).list() : query.list();
List<ClassificationResource> export = new ArrayList<>(); List<ClassificationRepresentationModel> export = new ArrayList<>();
for (ClassificationSummary summary : summaries) { for (ClassificationSummary summary : summaries) {
Classification classification = Classification classification =
classificationService.getClassification(summary.getKey(), summary.getDomain()); classificationService.getClassification(summary.getKey(), summary.getDomain());
export.add(classificationResourceAssembler.toDefinition(classification)); export.add(classificationRepresentationModelAssembler.toModel(classification));
} }
ResponseEntity<List<ClassificationResource>> response = ResponseEntity.ok(export); ResponseEntity<List<ClassificationRepresentationModel>> response = ResponseEntity.ok(export);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from exportClassifications(), returning {}", response); LOGGER.debug("Exit from exportClassifications(), returning {}", response);
} }
@ -91,7 +91,7 @@ public class ClassificationDefinitionController {
DomainNotFoundException, IOException { DomainNotFoundException, IOException {
LOGGER.debug("Entry to importClassifications()"); LOGGER.debug("Entry to importClassifications()");
Map<String, String> systemIds = getSystemIds(); Map<String, String> systemIds = getSystemIds();
List<ClassificationResource> classificationsResources = List<ClassificationRepresentationModel> classificationsResources =
extractClassificationResourcesFromFile(file); extractClassificationResourcesFromFile(file);
checkForDuplicates(classificationsResources); checkForDuplicates(classificationsResources);
@ -110,18 +110,18 @@ public class ClassificationDefinitionController {
Collectors.toMap(i -> i.getKey() + "|" + i.getDomain(), ClassificationSummary::getId)); Collectors.toMap(i -> i.getKey() + "|" + i.getDomain(), ClassificationSummary::getId));
} }
private List<ClassificationResource> extractClassificationResourcesFromFile(MultipartFile file) private List<ClassificationRepresentationModel> extractClassificationResourcesFromFile(
throws IOException { MultipartFile file) throws IOException {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return mapper.readValue( return mapper.readValue(
file.getInputStream(), new TypeReference<List<ClassificationResource>>() {}); file.getInputStream(), new TypeReference<List<ClassificationRepresentationModel>>() {});
} }
private void checkForDuplicates(List<ClassificationResource> classificationList) { private void checkForDuplicates(List<ClassificationRepresentationModel> classificationList) {
List<String> identifiers = new ArrayList<>(); List<String> identifiers = new ArrayList<>();
Set<String> duplicates = new HashSet<>(); Set<String> duplicates = new HashSet<>();
for (ClassificationResource classification : classificationList) { for (ClassificationRepresentationModel classification : classificationList) {
String identifier = classification.getKey() + "|" + classification.getDomain(); String identifier = classification.getKey() + "|" + classification.getDomain();
if (identifiers.contains(identifier)) { if (identifiers.contains(identifier)) {
duplicates.add(identifier); duplicates.add(identifier);
@ -136,19 +136,20 @@ public class ClassificationDefinitionController {
} }
private Map<Classification, String> mapChildrenToParentKeys( private Map<Classification, String> mapChildrenToParentKeys(
List<ClassificationResource> classificationResources, Map<String, String> systemIds) { List<ClassificationRepresentationModel> classificationRepresentationModels,
Map<String, String> systemIds) {
LOGGER.debug("Entry to mapChildrenToParentKeys()"); LOGGER.debug("Entry to mapChildrenToParentKeys()");
Map<Classification, String> childrenInFile = new HashMap<>(); Map<Classification, String> childrenInFile = new HashMap<>();
Set<String> newKeysWithDomain = new HashSet<>(); Set<String> newKeysWithDomain = new HashSet<>();
classificationResources.forEach( classificationRepresentationModels.forEach(
cl -> newKeysWithDomain.add(cl.getKey() + "|" + cl.getDomain())); cl -> newKeysWithDomain.add(cl.getKey() + "|" + cl.getDomain()));
for (ClassificationResource cl : classificationResources) { for (ClassificationRepresentationModel cl : classificationRepresentationModels) {
cl.setParentId(cl.getParentId() == null ? "" : cl.getParentId()); cl.setParentId(cl.getParentId() == null ? "" : cl.getParentId());
cl.setParentKey(cl.getParentKey() == null ? "" : cl.getParentKey()); cl.setParentKey(cl.getParentKey() == null ? "" : cl.getParentKey());
if (!cl.getParentId().equals("") && cl.getParentKey().equals("")) { if (!cl.getParentId().equals("") && cl.getParentKey().equals("")) {
for (ClassificationResource parent : classificationResources) { for (ClassificationRepresentationModel parent : classificationRepresentationModels) {
if (cl.getParentId().equals(parent.getClassificationId())) { if (cl.getParentId().equals(parent.getClassificationId())) {
cl.setParentKey(parent.getKey()); cl.setParentKey(parent.getKey());
} }
@ -159,7 +160,8 @@ public class ClassificationDefinitionController {
if (!cl.getParentKey().isEmpty() && !cl.getParentKey().equals("")) { if (!cl.getParentKey().isEmpty() && !cl.getParentKey().equals("")) {
if (newKeysWithDomain.contains(parentKeyAndDomain) if (newKeysWithDomain.contains(parentKeyAndDomain)
|| systemIds.containsKey(parentKeyAndDomain)) { || systemIds.containsKey(parentKeyAndDomain)) {
childrenInFile.put(classificationResourceAssembler.toModel(cl), cl.getParentKey()); childrenInFile.put(
classificationRepresentationModelAssembler.toEntityModel(cl), cl.getParentKey());
} }
} }
} }
@ -173,23 +175,29 @@ public class ClassificationDefinitionController {
} }
private void insertOrUpdateClassificationsWithoutParent( private void insertOrUpdateClassificationsWithoutParent(
List<ClassificationResource> classificationResources, Map<String, String> systemIds) List<ClassificationRepresentationModel> classificationRepresentationModels,
Map<String, String> systemIds)
throws ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException, throws ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException,
ClassificationAlreadyExistException, DomainNotFoundException, ConcurrencyException { ClassificationAlreadyExistException, DomainNotFoundException, ConcurrencyException {
LOGGER.debug("Entry to insertOrUpdateClassificationsWithoutParent()"); LOGGER.debug("Entry to insertOrUpdateClassificationsWithoutParent()");
for (ClassificationResource classificationResource : classificationResources) { for (ClassificationRepresentationModel classificationRepresentationModel :
classificationResource.setParentKey(null); classificationRepresentationModels) {
classificationResource.setParentId(null); classificationRepresentationModel.setParentKey(null);
classificationResource.setClassificationId(null); classificationRepresentationModel.setParentId(null);
classificationRepresentationModel.setClassificationId(null);
String systemId = String systemId =
systemIds.get(classificationResource.getKey() + "|" + classificationResource.getDomain()); systemIds.get(
classificationRepresentationModel.getKey()
+ "|"
+ classificationRepresentationModel.getDomain());
if (systemId != null) { if (systemId != null) {
updateExistingClassification(classificationResource, systemId); updateExistingClassification(classificationRepresentationModel, systemId);
} else { } else {
classificationService.createClassification( classificationService.createClassification(
classificationResourceAssembler.toModel(classificationResource)); classificationRepresentationModelAssembler
.toEntityModel(classificationRepresentationModel));
} }
} }
LOGGER.debug("Exit from insertOrUpdateClassificationsWithoutParent()"); LOGGER.debug("Exit from insertOrUpdateClassificationsWithoutParent()");
@ -221,7 +229,7 @@ public class ClassificationDefinitionController {
LOGGER.debug("Exit from updateParentChildrenRelations()"); LOGGER.debug("Exit from updateParentChildrenRelations()");
} }
private void updateExistingClassification(ClassificationResource cl, String systemId) private void updateExistingClassification(ClassificationRepresentationModel cl, String systemId)
throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException,
InvalidArgumentException { InvalidArgumentException {
LOGGER.debug("Entry to updateExistingClassification()"); LOGGER.debug("Entry to updateExistingClassification()");

View File

@ -19,8 +19,8 @@ import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.monitor.api.MonitorService; import pro.taskana.monitor.api.MonitorService;
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader; import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
import pro.taskana.rest.resource.ReportResource; import pro.taskana.rest.resource.ReportRepresentationModel;
import pro.taskana.rest.resource.ReportResourceAssembler; import pro.taskana.rest.resource.ReportRepresentationModelAssembler;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** Controller for all monitoring endpoints. */ /** Controller for all monitoring endpoints. */
@ -32,24 +32,25 @@ public class MonitorController {
private MonitorService monitorService; private MonitorService monitorService;
private ReportResourceAssembler reportResourceAssembler; private ReportRepresentationModelAssembler reportRepresentationModelAssembler;
MonitorController( MonitorController(
MonitorService monitorService, ReportResourceAssembler reportResourceAssembler) { MonitorService monitorService,
ReportRepresentationModelAssembler reportRepresentationModelAssembler) {
this.monitorService = monitorService; this.monitorService = monitorService;
this.reportResourceAssembler = reportResourceAssembler; this.reportRepresentationModelAssembler = reportRepresentationModelAssembler;
} }
@GetMapping(path = Mapping.URL_MONITOR_TASKSSTATUS) @GetMapping(path = Mapping.URL_MONITOR_TASKSSTATUS)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<ReportResource> getTasksStatusReport( public ResponseEntity<ReportRepresentationModel> getTasksStatusReport(
@RequestParam(required = false) List<String> domains, @RequestParam(required = false) List<String> domains,
@RequestParam(required = false) List<TaskState> states) @RequestParam(required = false) List<TaskState> states)
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
LOGGER.debug("Entry to getTasksStatusReport()"); LOGGER.debug("Entry to getTasksStatusReport()");
ResponseEntity<ReportResource> response = ResponseEntity<ReportRepresentationModel> response =
ResponseEntity.ok( ResponseEntity.ok(
reportResourceAssembler.toModel( reportRepresentationModelAssembler.toModel(
monitorService monitorService
.createTaskStatusReportBuilder() .createTaskStatusReportBuilder()
.stateIn(states) .stateIn(states)
@ -71,8 +72,8 @@ public class MonitorController {
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
LOGGER.debug("Entry to getTasksWorkbasketReport()"); LOGGER.debug("Entry to getTasksWorkbasketReport()");
ReportResource report = ReportRepresentationModel report =
reportResourceAssembler.toModel( reportRepresentationModelAssembler.toModel(
monitorService monitorService
.createWorkbasketReportBuilder() .createWorkbasketReportBuilder()
.withColumnHeaders(getRangeTimeInterval()) .withColumnHeaders(getRangeTimeInterval())
@ -94,8 +95,8 @@ public class MonitorController {
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
LOGGER.debug("Entry to getTasksWorkbasketPlannedDateReport()"); LOGGER.debug("Entry to getTasksWorkbasketPlannedDateReport()");
ReportResource report = ReportRepresentationModel report =
reportResourceAssembler.toModel( reportRepresentationModelAssembler.toModel(
monitorService monitorService
.createWorkbasketReportBuilder() .createWorkbasketReportBuilder()
.stateIn(states) .stateIn(states)
@ -112,12 +113,12 @@ public class MonitorController {
@GetMapping(path = Mapping.URL_MONITOR_TASKSCLASSIFICATION) @GetMapping(path = Mapping.URL_MONITOR_TASKSCLASSIFICATION)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<ReportResource> getTasksClassificationReport() public ResponseEntity<ReportRepresentationModel> getTasksClassificationReport()
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
LOGGER.debug("Entry to getTasksClassificationReport()"); LOGGER.debug("Entry to getTasksClassificationReport()");
ReportResource report = ReportRepresentationModel report =
reportResourceAssembler.toModel( reportRepresentationModelAssembler.toModel(
monitorService monitorService
.createClassificationReportBuilder() .createClassificationReportBuilder()
.withColumnHeaders(getRangeTimeInterval()) .withColumnHeaders(getRangeTimeInterval())
@ -132,7 +133,7 @@ public class MonitorController {
@GetMapping(path = Mapping.URL_MONITOR_TIMESTAMP) @GetMapping(path = Mapping.URL_MONITOR_TIMESTAMP)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<ReportResource> getDailyEntryExitReport() public ResponseEntity<ReportRepresentationModel> getDailyEntryExitReport()
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
List<TimeIntervalColumnHeader> columnHeaders = List<TimeIntervalColumnHeader> columnHeaders =
IntStream.range(-14, 0) IntStream.range(-14, 0)
@ -140,7 +141,7 @@ public class MonitorController {
.collect(Collectors.toList()); .collect(Collectors.toList());
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body( .body(
reportResourceAssembler.toModel( reportRepresentationModelAssembler.toModel(
monitorService monitorService
.createTimestampReportBuilder() .createTimestampReportBuilder()
.withColumnHeaders(columnHeaders) .withColumnHeaders(columnHeaders)

View File

@ -19,9 +19,9 @@ import org.springframework.web.bind.annotation.RestController;
import pro.taskana.common.api.exceptions.ConcurrencyException; import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.rest.resource.TaskCommentListResource; import pro.taskana.rest.resource.TaskCommentRepresentationModel;
import pro.taskana.rest.resource.TaskCommentResource; import pro.taskana.rest.resource.TaskCommentRepresentationModelAssembler;
import pro.taskana.rest.resource.TaskCommentResourceAssembler; import pro.taskana.rest.resource.TaskanaPagedModel;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.exceptions.TaskCommentNotFoundException; import pro.taskana.task.api.exceptions.TaskCommentNotFoundException;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
@ -35,17 +35,19 @@ public class TaskCommentController {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskCommentController.class); private static final Logger LOGGER = LoggerFactory.getLogger(TaskCommentController.class);
private TaskService taskService; private TaskService taskService;
private TaskCommentResourceAssembler taskCommentResourceAssembler; private TaskCommentRepresentationModelAssembler taskCommentRepresentationModelAssembler;
TaskCommentController( TaskCommentController(
TaskService taskService, TaskCommentResourceAssembler taskCommentResourceAssembler) { TaskService taskService,
TaskCommentRepresentationModelAssembler taskCommentRepresentationModelAssembler) {
this.taskService = taskService; this.taskService = taskService;
this.taskCommentResourceAssembler = taskCommentResourceAssembler; this.taskCommentRepresentationModelAssembler = taskCommentRepresentationModelAssembler;
} }
@GetMapping(path = Mapping.URL_TASK_COMMENT) @GetMapping(path = Mapping.URL_TASK_COMMENT)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskCommentResource> getTaskComment(@PathVariable String taskCommentId) public ResponseEntity<TaskCommentRepresentationModel> getTaskComment(
@PathVariable String taskCommentId)
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException, throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
InvalidArgumentException { InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
@ -54,9 +56,11 @@ public class TaskCommentController {
TaskComment taskComment = taskService.getTaskComment(taskCommentId); TaskComment taskComment = taskService.getTaskComment(taskCommentId);
TaskCommentResource taskCommentResource = taskCommentResourceAssembler.toModel(taskComment); TaskCommentRepresentationModel taskCommentRepresentationModel =
taskCommentRepresentationModelAssembler.toModel(taskComment);
ResponseEntity<TaskCommentResource> response = ResponseEntity.ok(taskCommentResource); ResponseEntity<TaskCommentRepresentationModel> response =
ResponseEntity.ok(taskCommentRepresentationModel);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTaskComment(), returning {}", response); LOGGER.debug("Exit from getTaskComment(), returning {}", response);
@ -67,18 +71,19 @@ public class TaskCommentController {
@GetMapping(path = Mapping.URL_TASK_GET_POST_COMMENTS) @GetMapping(path = Mapping.URL_TASK_GET_POST_COMMENTS)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskCommentListResource> getTaskComments(@PathVariable String taskId) public ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>> getTaskComments(
throws NotAuthorizedException, TaskNotFoundException { @PathVariable String taskId) throws NotAuthorizedException, TaskNotFoundException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getTaskComments(taskId= {})", taskId); LOGGER.debug("Entry to getTaskComments(taskId= {})", taskId);
} }
List<TaskComment> taskComments = taskService.getTaskComments(taskId); List<TaskComment> taskComments = taskService.getTaskComments(taskId);
TaskCommentListResource taskCommentListResource = TaskanaPagedModel<TaskCommentRepresentationModel> taskCommentListResource =
taskCommentResourceAssembler.toListResource(taskComments); taskCommentRepresentationModelAssembler.toPageModel(taskComments, null);
ResponseEntity<TaskCommentListResource> response = ResponseEntity.ok(taskCommentListResource); ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>> response =
ResponseEntity.ok(taskCommentListResource);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTaskComments(), returning {}", response); LOGGER.debug("Exit from getTaskComments(), returning {}", response);
@ -89,7 +94,8 @@ public class TaskCommentController {
@DeleteMapping(path = Mapping.URL_TASK_COMMENT) @DeleteMapping(path = Mapping.URL_TASK_COMMENT)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskCommentResource> deleteTaskComment(@PathVariable String taskCommentId) public ResponseEntity<TaskCommentRepresentationModel> deleteTaskComment(
@PathVariable String taskCommentId)
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException, throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
InvalidArgumentException { InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
@ -98,7 +104,7 @@ public class TaskCommentController {
taskService.deleteTaskComment(taskCommentId); taskService.deleteTaskComment(taskCommentId);
ResponseEntity<TaskCommentResource> result = ResponseEntity.noContent().build(); ResponseEntity<TaskCommentRepresentationModel> result = ResponseEntity.noContent().build();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from deleteTaskComment(), returning {}", result); LOGGER.debug("Exit from deleteTaskComment(), returning {}", result);
@ -109,25 +115,27 @@ public class TaskCommentController {
@PutMapping(path = Mapping.URL_TASK_COMMENT) @PutMapping(path = Mapping.URL_TASK_COMMENT)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskCommentResource> updateTaskComment( public ResponseEntity<TaskCommentRepresentationModel> updateTaskComment(
@PathVariable String taskCommentId, @RequestBody TaskCommentResource taskCommentResource) @PathVariable String taskCommentId,
@RequestBody TaskCommentRepresentationModel taskCommentRepresentationModel)
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException, throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
InvalidArgumentException, ConcurrencyException { InvalidArgumentException, ConcurrencyException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
"Entry to updateTaskComment(taskCommentId= {}, taskCommentResource= {})", "Entry to updateTaskComment(taskCommentId= {}, taskCommentResource= {})",
taskCommentId, taskCommentId,
taskCommentResource); taskCommentRepresentationModel);
} }
ResponseEntity<TaskCommentResource> result = null; ResponseEntity<TaskCommentRepresentationModel> result = null;
if ((taskCommentId.equals(taskCommentResource.getTaskCommentId()))) { if ((taskCommentId.equals(taskCommentRepresentationModel.getTaskCommentId()))) {
TaskComment taskComment = taskCommentResourceAssembler.toModel(taskCommentResource); TaskComment taskComment =
taskCommentRepresentationModelAssembler.toEntityModel(taskCommentRepresentationModel);
taskComment = taskService.updateTaskComment(taskComment); taskComment = taskService.updateTaskComment(taskComment);
result = ResponseEntity.ok(taskCommentResourceAssembler.toModel(taskComment)); result = ResponseEntity.ok(taskCommentRepresentationModelAssembler.toModel(taskComment));
} else { } else {
throw new InvalidArgumentException( throw new InvalidArgumentException(
String.format( String.format(
@ -145,27 +153,29 @@ public class TaskCommentController {
@PostMapping(path = Mapping.URL_TASK_GET_POST_COMMENTS) @PostMapping(path = Mapping.URL_TASK_GET_POST_COMMENTS)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<TaskCommentResource> createTaskComment( public ResponseEntity<TaskCommentRepresentationModel> createTaskComment(
@PathVariable String taskId, @RequestBody TaskCommentResource taskCommentResource) @PathVariable String taskId,
@RequestBody TaskCommentRepresentationModel taskCommentRepresentationModel)
throws NotAuthorizedException, InvalidArgumentException, TaskNotFoundException { throws NotAuthorizedException, InvalidArgumentException, TaskNotFoundException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug( LOGGER.debug(
"Entry to createTaskComment(taskId= {}, taskCommentResource= {})", "Entry to createTaskComment(taskId= {}, taskCommentResource= {})",
taskId, taskId,
taskCommentResource); taskCommentRepresentationModel);
} }
taskCommentResource.setTaskId(taskId); taskCommentRepresentationModel.setTaskId(taskId);
TaskComment taskCommentFromResource = taskCommentResourceAssembler.toModel(taskCommentResource); TaskComment taskCommentFromResource =
taskCommentRepresentationModelAssembler.toEntityModel(taskCommentRepresentationModel);
TaskComment createdTaskComment = taskService.createTaskComment(taskCommentFromResource); TaskComment createdTaskComment = taskService.createTaskComment(taskCommentFromResource);
ResponseEntity<TaskCommentResource> result; ResponseEntity<TaskCommentRepresentationModel> result;
result = result =
ResponseEntity.status(HttpStatus.CREATED) ResponseEntity.status(HttpStatus.CREATED)
.body(taskCommentResourceAssembler.toModel(createdTaskComment)); .body(taskCommentRepresentationModelAssembler.toModel(createdTaskComment));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from createTaskComment(), returning {}", result); LOGGER.debug("Exit from createTaskComment(), returning {}", result);

View File

@ -7,6 +7,7 @@ import java.util.Objects;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType; import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -29,11 +30,11 @@ import pro.taskana.common.api.TimeInterval;
import pro.taskana.common.api.exceptions.ConcurrencyException; import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.rest.resource.PagedResources.PageMetadata; import pro.taskana.rest.resource.TaskRepresentationModel;
import pro.taskana.rest.resource.TaskResource; import pro.taskana.rest.resource.TaskRepresentationModelAssembler;
import pro.taskana.rest.resource.TaskResourceAssembler; import pro.taskana.rest.resource.TaskSummaryRepresentationModel;
import pro.taskana.rest.resource.TaskSummaryListResource; import pro.taskana.rest.resource.TaskSummaryRepresentationModelAssembler;
import pro.taskana.rest.resource.TaskSummaryResourceAssembler; import pro.taskana.rest.resource.TaskanaPagedModel;
import pro.taskana.task.api.TaskQuery; import pro.taskana.task.api.TaskQuery;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
@ -90,22 +91,22 @@ public class TaskController extends AbstractPagingController {
private TaskService taskService; private TaskService taskService;
private TaskResourceAssembler taskResourceAssembler; private TaskRepresentationModelAssembler taskRepresentationModelAssembler;
private TaskSummaryResourceAssembler taskSummaryResourceAssembler; private TaskSummaryRepresentationModelAssembler taskSummaryRepresentationModelAssembler;
TaskController( TaskController(
TaskService taskService, TaskService taskService,
TaskResourceAssembler taskResourceAssembler, TaskRepresentationModelAssembler taskRepresentationModelAssembler,
TaskSummaryResourceAssembler taskSummaryResourceAssembler) { TaskSummaryRepresentationModelAssembler taskSummaryRepresentationModelAssembler) {
this.taskService = taskService; this.taskService = taskService;
this.taskResourceAssembler = taskResourceAssembler; this.taskRepresentationModelAssembler = taskRepresentationModelAssembler;
this.taskSummaryResourceAssembler = taskSummaryResourceAssembler; this.taskSummaryRepresentationModelAssembler = taskSummaryRepresentationModelAssembler;
} }
@GetMapping(path = Mapping.URL_TASKS) @GetMapping(path = Mapping.URL_TASKS)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskSummaryListResource> getTasks( public ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> getTasks(
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException { @RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getTasks(params= {})", params); LOGGER.debug("Entry to getTasks(params= {})", params);
@ -118,9 +119,10 @@ public class TaskController extends AbstractPagingController {
PageMetadata pageMetadata = getPageMetadata(params, query); PageMetadata pageMetadata = getPageMetadata(params, query);
List<TaskSummary> taskSummaries = getQueryList(query, pageMetadata); List<TaskSummary> taskSummaries = getQueryList(query, pageMetadata);
TaskSummaryListResource pagedResources = TaskanaPagedModel<TaskSummaryRepresentationModel> pagedModels =
taskSummaryResourceAssembler.toCollectionModel(taskSummaries, pageMetadata); taskSummaryRepresentationModelAssembler.toPageModel(taskSummaries, pageMetadata);
ResponseEntity<TaskSummaryListResource> response = ResponseEntity.ok(pagedResources); ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
ResponseEntity.ok(pagedModels);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTasks(), returning {}", response); LOGGER.debug("Exit from getTasks(), returning {}", response);
} }
@ -130,11 +132,12 @@ public class TaskController extends AbstractPagingController {
@GetMapping(path = Mapping.URL_TASKS_ID) @GetMapping(path = Mapping.URL_TASKS_ID)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskResource> getTask(@PathVariable String taskId) public ResponseEntity<TaskRepresentationModel> getTask(@PathVariable String taskId)
throws TaskNotFoundException, NotAuthorizedException { throws TaskNotFoundException, NotAuthorizedException {
LOGGER.debug("Entry to getTask(taskId= {})", taskId); LOGGER.debug("Entry to getTask(taskId= {})", taskId);
Task task = taskService.getTask(taskId); Task task = taskService.getTask(taskId);
ResponseEntity<TaskResource> result = ResponseEntity.ok(taskResourceAssembler.toModel(task)); ResponseEntity<TaskRepresentationModel> result =
ResponseEntity.ok(taskRepresentationModelAssembler.toModel(task));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTask(), returning {}", result); LOGGER.debug("Exit from getTask(), returning {}", result);
} }
@ -144,7 +147,7 @@ public class TaskController extends AbstractPagingController {
@PostMapping(path = Mapping.URL_TASKS_ID_CLAIM) @PostMapping(path = Mapping.URL_TASKS_ID_CLAIM)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<TaskResource> claimTask( public ResponseEntity<TaskRepresentationModel> claimTask(
@PathVariable String taskId, @RequestBody String userName) @PathVariable String taskId, @RequestBody String userName)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException { NotAuthorizedException {
@ -152,8 +155,8 @@ public class TaskController extends AbstractPagingController {
// TODO verify user // TODO verify user
taskService.claim(taskId); taskService.claim(taskId);
Task updatedTask = taskService.getTask(taskId); Task updatedTask = taskService.getTask(taskId);
ResponseEntity<TaskResource> result = ResponseEntity<TaskRepresentationModel> result =
ResponseEntity.ok(taskResourceAssembler.toModel(updatedTask)); ResponseEntity.ok(taskRepresentationModelAssembler.toModel(updatedTask));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from claimTask(), returning {}", result); LOGGER.debug("Exit from claimTask(), returning {}", result);
} }
@ -163,7 +166,7 @@ public class TaskController extends AbstractPagingController {
@DeleteMapping(path = Mapping.URL_TASKS_ID_CLAIM) @DeleteMapping(path = Mapping.URL_TASKS_ID_CLAIM)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<TaskResource> cancelClaimTask(@PathVariable String taskId) public ResponseEntity<TaskRepresentationModel> cancelClaimTask(@PathVariable String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException { NotAuthorizedException {
@ -172,8 +175,8 @@ public class TaskController extends AbstractPagingController {
taskService.cancelClaim(taskId); taskService.cancelClaim(taskId);
Task updatedTask = taskService.getTask(taskId); Task updatedTask = taskService.getTask(taskId);
ResponseEntity<TaskResource> result = ResponseEntity<TaskRepresentationModel> result =
ResponseEntity.ok(taskResourceAssembler.toModel(updatedTask)); ResponseEntity.ok(taskRepresentationModelAssembler.toModel(updatedTask));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from cancelClaimTask(), returning {}", result); LOGGER.debug("Exit from cancelClaimTask(), returning {}", result);
} }
@ -182,14 +185,14 @@ public class TaskController extends AbstractPagingController {
@PostMapping(path = Mapping.URL_TASKS_ID_COMPLETE) @PostMapping(path = Mapping.URL_TASKS_ID_COMPLETE)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<TaskResource> completeTask(@PathVariable String taskId) public ResponseEntity<TaskRepresentationModel> completeTask(@PathVariable String taskId)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, throws TaskNotFoundException, InvalidOwnerException, InvalidStateException,
NotAuthorizedException { NotAuthorizedException {
LOGGER.debug("Entry to completeTask(taskId= {})", taskId); LOGGER.debug("Entry to completeTask(taskId= {})", taskId);
taskService.forceCompleteTask(taskId); taskService.forceCompleteTask(taskId);
Task updatedTask = taskService.getTask(taskId); Task updatedTask = taskService.getTask(taskId);
ResponseEntity<TaskResource> result = ResponseEntity<TaskRepresentationModel> result =
ResponseEntity.ok(taskResourceAssembler.toModel(updatedTask)); ResponseEntity.ok(taskRepresentationModelAssembler.toModel(updatedTask));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from completeTask(), returning {}", result); LOGGER.debug("Exit from completeTask(), returning {}", result);
} }
@ -199,29 +202,31 @@ public class TaskController extends AbstractPagingController {
@DeleteMapping(path = Mapping.URL_TASKS_ID) @DeleteMapping(path = Mapping.URL_TASKS_ID)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<TaskResource> deleteTask(@PathVariable String taskId) public ResponseEntity<TaskRepresentationModel> deleteTask(@PathVariable String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException { throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
LOGGER.debug("Entry to deleteTask(taskId= {})", taskId); LOGGER.debug("Entry to deleteTask(taskId= {})", taskId);
taskService.forceDeleteTask(taskId); taskService.forceDeleteTask(taskId);
ResponseEntity<TaskResource> result = ResponseEntity.noContent().build(); ResponseEntity<TaskRepresentationModel> result = ResponseEntity.noContent().build();
LOGGER.debug("Exit from deleteTask(), returning {}", result); LOGGER.debug("Exit from deleteTask(), returning {}", result);
return result; return result;
} }
@PostMapping(path = Mapping.URL_TASKS) @PostMapping(path = Mapping.URL_TASKS)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<TaskResource> createTask(@RequestBody TaskResource taskResource) public ResponseEntity<TaskRepresentationModel> createTask(
@RequestBody TaskRepresentationModel taskRepresentationModel)
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException, throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
TaskAlreadyExistException, InvalidArgumentException { TaskAlreadyExistException, InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to createTask(params= {})", taskResource); LOGGER.debug("Entry to createTask(params= {})", taskRepresentationModel);
} }
Task fromResource = taskResourceAssembler.toModel(taskResource); Task fromResource = taskRepresentationModelAssembler.toEntityModel(taskRepresentationModel);
Task createdTask = taskService.createTask(fromResource); Task createdTask = taskService.createTask(fromResource);
ResponseEntity<TaskResource> result = ResponseEntity<TaskRepresentationModel> result =
ResponseEntity.status(HttpStatus.CREATED).body(taskResourceAssembler.toModel(createdTask)); ResponseEntity.status(HttpStatus.CREATED)
.body(taskRepresentationModelAssembler.toModel(createdTask));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from createTask(), returning {}", result); LOGGER.debug("Exit from createTask(), returning {}", result);
} }
@ -231,14 +236,14 @@ public class TaskController extends AbstractPagingController {
@PostMapping(path = Mapping.URL_TASKS_ID_TRANSFER_WORKBASKETID) @PostMapping(path = Mapping.URL_TASKS_ID_TRANSFER_WORKBASKETID)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<TaskResource> transferTask( public ResponseEntity<TaskRepresentationModel> transferTask(
@PathVariable String taskId, @PathVariable String workbasketId) @PathVariable String taskId, @PathVariable String workbasketId)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
InvalidStateException { InvalidStateException {
LOGGER.debug("Entry to transferTask(taskId= {}, workbasketId= {})", taskId, workbasketId); LOGGER.debug("Entry to transferTask(taskId= {}, workbasketId= {})", taskId, workbasketId);
Task updatedTask = taskService.transfer(taskId, workbasketId); Task updatedTask = taskService.transfer(taskId, workbasketId);
ResponseEntity<TaskResource> result = ResponseEntity<TaskRepresentationModel> result =
ResponseEntity.ok(taskResourceAssembler.toModel(updatedTask)); ResponseEntity.ok(taskRepresentationModelAssembler.toModel(updatedTask));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from transferTask(), returning {}", result); LOGGER.debug("Exit from transferTask(), returning {}", result);
} }
@ -248,23 +253,25 @@ public class TaskController extends AbstractPagingController {
@PutMapping(path = Mapping.URL_TASKS_ID) @PutMapping(path = Mapping.URL_TASKS_ID)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<TaskResource> updateTask( public ResponseEntity<TaskRepresentationModel> updateTask(
@PathVariable(value = "taskId") String taskId, @RequestBody TaskResource taskResource) @PathVariable(value = "taskId") String taskId,
@RequestBody TaskRepresentationModel taskRepresentationModel)
throws TaskNotFoundException, ClassificationNotFoundException, InvalidArgumentException, throws TaskNotFoundException, ClassificationNotFoundException, InvalidArgumentException,
ConcurrencyException, NotAuthorizedException, AttachmentPersistenceException, ConcurrencyException, NotAuthorizedException, AttachmentPersistenceException,
InvalidStateException { InvalidStateException {
LOGGER.debug("Entry to updateTask(taskId= {}, taskResource= {})", taskId, taskResource); LOGGER.debug(
ResponseEntity<TaskResource> result; "Entry to updateTask(taskId= {}, taskResource= {})", taskId, taskRepresentationModel);
if (taskId.equals(taskResource.getTaskId())) { ResponseEntity<TaskRepresentationModel> result;
Task task = taskResourceAssembler.toModel(taskResource); if (taskId.equals(taskRepresentationModel.getTaskId())) {
Task task = taskRepresentationModelAssembler.toEntityModel(taskRepresentationModel);
task = taskService.updateTask(task); task = taskService.updateTask(task);
result = ResponseEntity.ok(taskResourceAssembler.toModel(task)); result = ResponseEntity.ok(taskRepresentationModelAssembler.toModel(task));
} else { } else {
throw new InvalidArgumentException( throw new InvalidArgumentException(
String.format( String.format(
"TaskId ('%s') is not identical with the taskId of to " "TaskId ('%s') is not identical with the taskId of to "
+ "object in the payload which should be updated. ID=('%s')", + "object in the payload which should be updated. ID=('%s')",
taskId, taskResource.getTaskId())); taskId, taskRepresentationModel.getTaskId()));
} }
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {

View File

@ -14,8 +14,8 @@ import pro.taskana.TaskanaEngineConfiguration;
import pro.taskana.common.api.TaskanaEngine; import pro.taskana.common.api.TaskanaEngine;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.common.internal.security.CurrentUserContext; import pro.taskana.common.internal.security.CurrentUserContext;
import pro.taskana.rest.resource.TaskanaUserInfoResource; import pro.taskana.rest.resource.TaskanaUserInfoRepresentationModel;
import pro.taskana.rest.resource.VersionResource; import pro.taskana.rest.resource.VersionRepresentationModel;
/** Controller for TaskanaEngine related tasks. */ /** Controller for TaskanaEngine related tasks. */
@RestController @RestController
@ -24,9 +24,9 @@ public class TaskanaEngineController {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineController.class); private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineController.class);
private TaskanaEngineConfiguration taskanaEngineConfiguration; private final TaskanaEngineConfiguration taskanaEngineConfiguration;
private TaskanaEngine taskanaEngine; private final TaskanaEngine taskanaEngine;
@Value("${version:Local build}") @Value("${version:Local build}")
private String version; private String version;
@ -87,9 +87,9 @@ public class TaskanaEngineController {
} }
@GetMapping(path = Mapping.URL_CURRENT_USER) @GetMapping(path = Mapping.URL_CURRENT_USER)
public ResponseEntity<TaskanaUserInfoResource> getCurrentUserInfo() { public ResponseEntity<TaskanaUserInfoRepresentationModel> getCurrentUserInfo() {
LOGGER.debug("Entry to getCurrentUserInfo()"); LOGGER.debug("Entry to getCurrentUserInfo()");
TaskanaUserInfoResource resource = new TaskanaUserInfoResource(); TaskanaUserInfoRepresentationModel resource = new TaskanaUserInfoRepresentationModel();
resource.setUserId(CurrentUserContext.getUserid()); resource.setUserId(CurrentUserContext.getUserid());
resource.setGroupIds(CurrentUserContext.getGroupIds()); resource.setGroupIds(CurrentUserContext.getGroupIds());
for (TaskanaRole role : taskanaEngineConfiguration.getRoleMap().keySet()) { for (TaskanaRole role : taskanaEngineConfiguration.getRoleMap().keySet()) {
@ -97,7 +97,7 @@ public class TaskanaEngineController {
resource.getRoles().add(role); resource.getRoles().add(role);
} }
} }
ResponseEntity<TaskanaUserInfoResource> response = ResponseEntity.ok(resource); ResponseEntity<TaskanaUserInfoRepresentationModel> response = ResponseEntity.ok(resource);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getCurrentUserInfo(), returning {}", response); LOGGER.debug("Exit from getCurrentUserInfo(), returning {}", response);
} }
@ -118,11 +118,11 @@ public class TaskanaEngineController {
* @return The current version. * @return The current version.
*/ */
@GetMapping(path = Mapping.URL_VERSION) @GetMapping(path = Mapping.URL_VERSION)
public ResponseEntity<VersionResource> currentVersion() { public ResponseEntity<VersionRepresentationModel> currentVersion() {
LOGGER.debug("Entry to currentVersion()"); LOGGER.debug("Entry to currentVersion()");
VersionResource resource = new VersionResource(); VersionRepresentationModel resource = new VersionRepresentationModel();
resource.setVersion(TaskanaEngineConfiguration.class.getPackage().getImplementationVersion()); resource.setVersion(TaskanaEngineConfiguration.class.getPackage().getImplementationVersion());
ResponseEntity<VersionResource> response = ResponseEntity.ok(resource); ResponseEntity<VersionRepresentationModel> response = ResponseEntity.ok(resource);
LOGGER.debug("Exit from currentVersion(), returning {}", response); LOGGER.debug("Exit from currentVersion(), returning {}", response);
return response; return response;
} }

View File

@ -6,6 +6,7 @@ import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
@ -18,9 +19,9 @@ import pro.taskana.common.api.BaseQuery;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.ldap.LdapClient; import pro.taskana.ldap.LdapClient;
import pro.taskana.rest.resource.PagedResources.PageMetadata; import pro.taskana.rest.resource.TaskanaPagedModel;
import pro.taskana.rest.resource.WorkbasketAccessItemListResource; import pro.taskana.rest.resource.WorkbasketAccessItemRepresentationModel;
import pro.taskana.rest.resource.WorkbasketAccessItemResourceAssembler; import pro.taskana.rest.resource.WorkbasketAccessItemRepresentationModelAssembler;
import pro.taskana.workbasket.api.WorkbasketAccessItemQuery; import pro.taskana.workbasket.api.WorkbasketAccessItemQuery;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.models.WorkbasketAccessItem; import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
@ -43,22 +44,35 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
private static final String SORT_BY = "sort-by"; private static final String SORT_BY = "sort-by";
private static final String SORT_DIRECTION = "order"; private static final String SORT_DIRECTION = "order";
@Autowired LdapClient ldapClient; final LdapClient ldapClient;
@Autowired private WorkbasketService workbasketService; private final WorkbasketService workbasketService;
@Autowired private WorkbasketAccessItemResourceAssembler workbasketAccessItemResourceAssembler; private final WorkbasketAccessItemRepresentationModelAssembler
workbasketAccessItemRepresentationModelAssembler;
@Autowired
public WorkbasketAccessItemController(
LdapClient ldapClient, WorkbasketService workbasketService,
WorkbasketAccessItemRepresentationModelAssembler
workbasketAccessItemRepresentationModelAssembler) {
this.ldapClient = ldapClient;
this.workbasketService = workbasketService;
this.workbasketAccessItemRepresentationModelAssembler
= workbasketAccessItemRepresentationModelAssembler;
}
/** /**
* This GET method return all workbasketAccessItems that correspond the given data. * This GET method return all workbasketAccessItems that correspond the given data.
* *
* @param params filter, order and access ids. * @param params filter, order and access ids.
* @return all WorkbasketAccesItemResource. * @return all WorkbasketAccesItemResource.
* @throws NotAuthorizedException if the user is not authorized. * @throws NotAuthorizedException if the user is not authorized.
* @throws InvalidArgumentException if some argument is invalid. * @throws InvalidArgumentException if some argument is invalid.
*/ */
@GetMapping(path = Mapping.URL_WORKBASKETACCESSITEMS) @GetMapping(path = Mapping.URL_WORKBASKETACCESSITEMS)
public ResponseEntity<WorkbasketAccessItemListResource> getWorkbasketAccessItems( public ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>>
getWorkbasketAccessItems(
@RequestParam MultiValueMap<String, String> params) @RequestParam MultiValueMap<String, String> params)
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
@ -66,18 +80,19 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
} }
WorkbasketAccessItemQuery query = workbasketService.createWorkbasketAccessItemQuery(); WorkbasketAccessItemQuery query = workbasketService.createWorkbasketAccessItemQuery();
query = getAccessIds(query, params); getAccessIds(query, params);
query = applyFilterParams(query, params); applyFilterParams(query, params);
query = applySortingParams(query, params); query = applySortingParams(query, params);
PageMetadata pageMetadata = getPageMetadata(params, query); PageMetadata pageMetadata = getPageMetadata(params, query);
List<WorkbasketAccessItem> workbasketAccessItems = getQueryList(query, pageMetadata); List<WorkbasketAccessItem> workbasketAccessItems = getQueryList(query, pageMetadata);
WorkbasketAccessItemListResource pagedResources = TaskanaPagedModel<WorkbasketAccessItemRepresentationModel> pagedResources =
workbasketAccessItemResourceAssembler.toCollectionModel( workbasketAccessItemRepresentationModelAssembler.toPageModel(
workbasketAccessItems, pageMetadata); workbasketAccessItems, pageMetadata);
ResponseEntity<WorkbasketAccessItemListResource> response = ResponseEntity.ok(pagedResources); ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> response =
ResponseEntity.ok(pagedResources);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", response); LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", response);
} }
@ -118,7 +133,7 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
return response; return response;
} }
private WorkbasketAccessItemQuery getAccessIds( private void getAccessIds(
WorkbasketAccessItemQuery query, MultiValueMap<String, String> params) { WorkbasketAccessItemQuery query, MultiValueMap<String, String> params) {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getAccessIds(query= {}, params= {})", params); LOGGER.debug("Entry to getAccessIds(query= {}, params= {})", params);
@ -134,10 +149,9 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
LOGGER.debug("Exit from getAccessIds(), returning {}", query); LOGGER.debug("Exit from getAccessIds(), returning {}", query);
} }
return query;
} }
private WorkbasketAccessItemQuery applyFilterParams( private void applyFilterParams(
WorkbasketAccessItemQuery query, MultiValueMap<String, String> params) { WorkbasketAccessItemQuery query, MultiValueMap<String, String> params) {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", params); LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", params);
@ -165,7 +179,6 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
LOGGER.debug("Exit from applyFilterParams(), returning {}", query); LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
} }
return query;
} }
private WorkbasketAccessItemQuery applySortingParams( private WorkbasketAccessItemQuery applySortingParams(

View File

@ -4,8 +4,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.MediaTypes; import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType; import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -27,17 +27,14 @@ import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.DomainNotFoundException; import pro.taskana.common.api.exceptions.DomainNotFoundException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.rest.resource.DistributionTargetListResource; import pro.taskana.rest.resource.DistributionTargetRepresentationModelAssembler;
import pro.taskana.rest.resource.DistributionTargetResource; import pro.taskana.rest.resource.TaskanaPagedModel;
import pro.taskana.rest.resource.DistributionTargetResourceAssembler; import pro.taskana.rest.resource.WorkbasketAccessItemRepresentationModel;
import pro.taskana.rest.resource.PagedResources.PageMetadata; import pro.taskana.rest.resource.WorkbasketAccessItemRepresentationModelAssembler;
import pro.taskana.rest.resource.WorkbasketAccessItemListResource; import pro.taskana.rest.resource.WorkbasketRepresentationModel;
import pro.taskana.rest.resource.WorkbasketAccessItemResource; import pro.taskana.rest.resource.WorkbasketRepresentationModelAssembler;
import pro.taskana.rest.resource.WorkbasketAccessItemResourceAssembler; import pro.taskana.rest.resource.WorkbasketSummaryRepresentationModel;
import pro.taskana.rest.resource.WorkbasketResource; import pro.taskana.rest.resource.WorkbasketSummaryRepresentationModelAssembler;
import pro.taskana.rest.resource.WorkbasketResourceAssembler;
import pro.taskana.rest.resource.WorkbasketSummaryListResource;
import pro.taskana.rest.resource.WorkbasketSummaryResourceAssembler;
import pro.taskana.workbasket.api.WorkbasketPermission; import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketQuery; import pro.taskana.workbasket.api.WorkbasketQuery;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
@ -74,32 +71,39 @@ public class WorkbasketController extends AbstractPagingController {
private static final String SORT_BY = "sort-by"; private static final String SORT_BY = "sort-by";
private static final String SORT_DIRECTION = "order"; private static final String SORT_DIRECTION = "order";
private WorkbasketService workbasketService; private final WorkbasketService workbasketService;
private WorkbasketResourceAssembler workbasketResourceAssembler; private final WorkbasketRepresentationModelAssembler workbasketRepresentationModelAssembler;
private WorkbasketSummaryResourceAssembler workbasketSummaryResourceAssembler; private final WorkbasketSummaryRepresentationModelAssembler
workbasketSummaryRepresentationModelAssembler;
private DistributionTargetResourceAssembler distributionTargetResourceAssembler; private final DistributionTargetRepresentationModelAssembler
distributionTargetRepresentationModelAssembler;
private WorkbasketAccessItemResourceAssembler workbasketAccessItemResourceAssembler; private final WorkbasketAccessItemRepresentationModelAssembler
workbasketAccessItemRepresentationModelAssembler;
WorkbasketController( WorkbasketController(
WorkbasketService workbasketService, WorkbasketService workbasketService,
WorkbasketResourceAssembler workbasketResourceAssembler, WorkbasketRepresentationModelAssembler workbasketRepresentationModelAssembler,
WorkbasketSummaryResourceAssembler workbasketSummaryResourceAssembler, WorkbasketSummaryRepresentationModelAssembler workbasketSummaryRepresentationModelAssembler,
DistributionTargetResourceAssembler distributionTargetResourceAssembler, DistributionTargetRepresentationModelAssembler distributionTargetRepresentationModelAssembler,
WorkbasketAccessItemResourceAssembler workbasketAccessItemResourceAssembler) { WorkbasketAccessItemRepresentationModelAssembler
workbasketAccessItemRepresentationModelAssembler) {
this.workbasketService = workbasketService; this.workbasketService = workbasketService;
this.workbasketResourceAssembler = workbasketResourceAssembler; this.workbasketRepresentationModelAssembler = workbasketRepresentationModelAssembler;
this.workbasketSummaryResourceAssembler = workbasketSummaryResourceAssembler; this.workbasketSummaryRepresentationModelAssembler =
this.distributionTargetResourceAssembler = distributionTargetResourceAssembler; workbasketSummaryRepresentationModelAssembler;
this.workbasketAccessItemResourceAssembler = workbasketAccessItemResourceAssembler; this.distributionTargetRepresentationModelAssembler =
distributionTargetRepresentationModelAssembler;
this.workbasketAccessItemRepresentationModelAssembler =
workbasketAccessItemRepresentationModelAssembler;
} }
@GetMapping(path = Mapping.URL_WORKBASKET) @GetMapping(path = Mapping.URL_WORKBASKET)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<WorkbasketSummaryListResource> getWorkbaskets( public ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> getWorkbaskets(
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException { @RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getWorkbaskets(params= {})", params); LOGGER.debug("Entry to getWorkbaskets(params= {})", params);
@ -107,14 +111,16 @@ public class WorkbasketController extends AbstractPagingController {
WorkbasketQuery query = workbasketService.createWorkbasketQuery(); WorkbasketQuery query = workbasketService.createWorkbasketQuery();
query = applySortingParams(query, params); query = applySortingParams(query, params);
query = applyFilterParams(query, params); applyFilterParams(query, params);
PageMetadata pageMetadata = getPageMetadata(params, query); PageMetadata pageMetadata = getPageMetadata(params, query);
List<WorkbasketSummary> workbasketSummaries = getQueryList(query, pageMetadata); List<WorkbasketSummary> workbasketSummaries = getQueryList(query, pageMetadata);
WorkbasketSummaryListResource pagedResources = TaskanaPagedModel<WorkbasketSummaryRepresentationModel> pagedModels =
workbasketSummaryResourceAssembler.toCollectionModel(workbasketSummaries, pageMetadata); workbasketSummaryRepresentationModelAssembler.toPageModel(
workbasketSummaries, pageMetadata);
ResponseEntity<WorkbasketSummaryListResource> response = ResponseEntity.ok(pagedResources); ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
ResponseEntity.ok(pagedModels);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getWorkbaskets(), returning {}", response); LOGGER.debug("Exit from getWorkbaskets(), returning {}", response);
} }
@ -124,13 +130,13 @@ public class WorkbasketController extends AbstractPagingController {
@GetMapping(path = Mapping.URL_WORKBASKET_ID, produces = MediaTypes.HAL_JSON_VALUE) @GetMapping(path = Mapping.URL_WORKBASKET_ID, produces = MediaTypes.HAL_JSON_VALUE)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<WorkbasketResource> getWorkbasket( public ResponseEntity<WorkbasketRepresentationModel> getWorkbasket(
@PathVariable(value = "workbasketId") String workbasketId) @PathVariable(value = "workbasketId") String workbasketId)
throws WorkbasketNotFoundException, NotAuthorizedException { throws WorkbasketNotFoundException, NotAuthorizedException {
LOGGER.debug("Entry to getWorkbasket(workbasketId= {})", workbasketId); LOGGER.debug("Entry to getWorkbasket(workbasketId= {})", workbasketId);
ResponseEntity<WorkbasketResource> result; ResponseEntity<WorkbasketRepresentationModel> result;
Workbasket workbasket = workbasketService.getWorkbasket(workbasketId); Workbasket workbasket = workbasketService.getWorkbasket(workbasketId);
result = ResponseEntity.ok(workbasketResourceAssembler.toModel(workbasket)); result = ResponseEntity.ok(workbasketRepresentationModelAssembler.toModel(workbasket));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getWorkbasket(), returning {}", result); LOGGER.debug("Exit from getWorkbasket(), returning {}", result);
} }
@ -164,19 +170,21 @@ public class WorkbasketController extends AbstractPagingController {
@PostMapping(path = Mapping.URL_WORKBASKET) @PostMapping(path = Mapping.URL_WORKBASKET)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<WorkbasketResource> createWorkbasket( public ResponseEntity<WorkbasketRepresentationModel> createWorkbasket(
@RequestBody WorkbasketResource workbasketResource) @RequestBody WorkbasketRepresentationModel workbasketRepresentationModel)
throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException, throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException,
DomainNotFoundException { DomainNotFoundException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to createWorkbasket(workbasketResource= {})", workbasketResource); LOGGER.debug(
"Entry to createWorkbasket(workbasketResource= {})", workbasketRepresentationModel);
} }
Workbasket workbasket = workbasketResourceAssembler.toModel(workbasketResource); Workbasket workbasket =
workbasketRepresentationModelAssembler.toEntityModel(workbasketRepresentationModel);
workbasket = workbasketService.createWorkbasket(workbasket); workbasket = workbasketService.createWorkbasket(workbasket);
ResponseEntity<WorkbasketResource> response = ResponseEntity<WorkbasketRepresentationModel> response =
ResponseEntity.status(HttpStatus.CREATED) ResponseEntity.status(HttpStatus.CREATED)
.body(workbasketResourceAssembler.toModel(workbasket)); .body(workbasketRepresentationModelAssembler.toModel(workbasket));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from createWorkbasket(), returning {}", response); LOGGER.debug("Exit from createWorkbasket(), returning {}", response);
} }
@ -186,23 +194,24 @@ public class WorkbasketController extends AbstractPagingController {
@PutMapping(path = Mapping.URL_WORKBASKET_ID) @PutMapping(path = Mapping.URL_WORKBASKET_ID)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<WorkbasketResource> updateWorkbasket( public ResponseEntity<WorkbasketRepresentationModel> updateWorkbasket(
@PathVariable(value = "workbasketId") String workbasketId, @PathVariable(value = "workbasketId") String workbasketId,
@RequestBody WorkbasketResource workbasketResource) @RequestBody WorkbasketRepresentationModel workbasketRepresentationModel)
throws InvalidWorkbasketException, WorkbasketNotFoundException, NotAuthorizedException, throws InvalidWorkbasketException, WorkbasketNotFoundException, NotAuthorizedException,
ConcurrencyException { ConcurrencyException {
LOGGER.debug("Entry to updateWorkbasket(workbasketId= {})", workbasketId); LOGGER.debug("Entry to updateWorkbasket(workbasketId= {})", workbasketId);
ResponseEntity<WorkbasketResource> result; ResponseEntity<WorkbasketRepresentationModel> result;
if (workbasketId.equals(workbasketResource.getWorkbasketId())) { if (workbasketId.equals(workbasketRepresentationModel.getWorkbasketId())) {
Workbasket workbasket = workbasketResourceAssembler.toModel(workbasketResource); Workbasket workbasket =
workbasketRepresentationModelAssembler.toEntityModel(workbasketRepresentationModel);
workbasket = workbasketService.updateWorkbasket(workbasket); workbasket = workbasketService.updateWorkbasket(workbasket);
result = ResponseEntity.ok(workbasketResourceAssembler.toModel(workbasket)); result = ResponseEntity.ok(workbasketRepresentationModelAssembler.toModel(workbasket));
} else { } else {
throw new InvalidWorkbasketException( throw new InvalidWorkbasketException(
"Target-WB-ID('" "Target-WB-ID('"
+ workbasketId + workbasketId
+ "') is not identical with the WB-ID of to object which should be updated. ID=('" + "') is not identical with the WB-ID of to object which should be updated. ID=('"
+ workbasketResource.getWorkbasketId() + workbasketRepresentationModel.getWorkbasketId()
+ "')"); + "')");
} }
@ -215,17 +224,18 @@ public class WorkbasketController extends AbstractPagingController {
@GetMapping(path = Mapping.URL_WORKBASKET_ID_ACCESSITEMS, produces = MediaTypes.HAL_JSON_VALUE) @GetMapping(path = Mapping.URL_WORKBASKET_ID_ACCESSITEMS, produces = MediaTypes.HAL_JSON_VALUE)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<WorkbasketAccessItemListResource> getWorkbasketAccessItems( public ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>>
@PathVariable(value = "workbasketId") String workbasketId) getWorkbasketAccessItems(@PathVariable(value = "workbasketId") String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException { throws NotAuthorizedException, WorkbasketNotFoundException {
LOGGER.debug("Entry to getWorkbasketAccessItems(workbasketId= {})", workbasketId); LOGGER.debug("Entry to getWorkbasketAccessItems(workbasketId= {})", workbasketId);
ResponseEntity<WorkbasketAccessItemListResource> result; ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> result;
List<WorkbasketAccessItem> accessItems = List<WorkbasketAccessItem> accessItems =
workbasketService.getWorkbasketAccessItems(workbasketId); workbasketService.getWorkbasketAccessItems(workbasketId);
result = result =
ResponseEntity.ok( ResponseEntity.ok(
workbasketAccessItemResourceAssembler.toCollectionModel(workbasketId, accessItems)); workbasketAccessItemRepresentationModelAssembler.toPageModel(
workbasketId, accessItems, null));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", result); LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", result);
} }
@ -235,11 +245,12 @@ public class WorkbasketController extends AbstractPagingController {
@PutMapping(path = Mapping.URL_WORKBASKET_ID_ACCESSITEMS) @PutMapping(path = Mapping.URL_WORKBASKET_ID_ACCESSITEMS)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<WorkbasketAccessItemListResource> setWorkbasketAccessItems( public ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>>
setWorkbasketAccessItems(
@PathVariable(value = "workbasketId") String workbasketId, @PathVariable(value = "workbasketId") String workbasketId,
@RequestBody List<WorkbasketAccessItemResource> workbasketAccessResourceItems) @RequestBody List<WorkbasketAccessItemRepresentationModel> workbasketAccessResourceItems)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
WorkbasketAccessItemAlreadyExistException { WorkbasketAccessItemAlreadyExistException {
LOGGER.debug("Entry to setWorkbasketAccessItems(workbasketId= {})", workbasketId); LOGGER.debug("Entry to setWorkbasketAccessItems(workbasketId= {})", workbasketId);
if (workbasketAccessResourceItems == null) { if (workbasketAccessResourceItems == null) {
throw new InvalidArgumentException("Can´t create something with NULL body-value."); throw new InvalidArgumentException("Can´t create something with NULL body-value.");
@ -247,15 +258,16 @@ public class WorkbasketController extends AbstractPagingController {
List<WorkbasketAccessItem> wbAccessItems = new ArrayList<>(); List<WorkbasketAccessItem> wbAccessItems = new ArrayList<>();
workbasketAccessResourceItems.forEach( workbasketAccessResourceItems.forEach(
item -> wbAccessItems.add(workbasketAccessItemResourceAssembler.toModel(item))); item -> wbAccessItems
.add(workbasketAccessItemRepresentationModelAssembler.toEntityModel(item)));
workbasketService.setWorkbasketAccessItems(workbasketId, wbAccessItems); workbasketService.setWorkbasketAccessItems(workbasketId, wbAccessItems);
List<WorkbasketAccessItem> updatedWbAccessItems = List<WorkbasketAccessItem> updatedWbAccessItems =
workbasketService.getWorkbasketAccessItems(workbasketId); workbasketService.getWorkbasketAccessItems(workbasketId);
ResponseEntity<WorkbasketAccessItemListResource> response = ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> response =
ResponseEntity.ok( ResponseEntity.ok(
workbasketAccessItemResourceAssembler.toCollectionModel( workbasketAccessItemRepresentationModelAssembler.toPageModel(
workbasketId, updatedWbAccessItems)); workbasketId, updatedWbAccessItems, null));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from setWorkbasketAccessItems(), returning {}", response); LOGGER.debug("Exit from setWorkbasketAccessItems(), returning {}", response);
} }
@ -265,16 +277,16 @@ public class WorkbasketController extends AbstractPagingController {
@GetMapping(path = Mapping.URL_WORKBASKET_ID_DISTRIBUTION, produces = MediaTypes.HAL_JSON_VALUE) @GetMapping(path = Mapping.URL_WORKBASKET_ID_DISTRIBUTION, produces = MediaTypes.HAL_JSON_VALUE)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<DistributionTargetListResource> getDistributionTargets( public ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>>
@PathVariable(value = "workbasketId") String workbasketId) getDistributionTargets(@PathVariable(value = "workbasketId") String workbasketId)
throws WorkbasketNotFoundException, NotAuthorizedException { throws WorkbasketNotFoundException, NotAuthorizedException {
LOGGER.debug("Entry to getDistributionTargets(workbasketId= {})", workbasketId); LOGGER.debug("Entry to getDistributionTargets(workbasketId= {})", workbasketId);
List<WorkbasketSummary> distributionTargets = List<WorkbasketSummary> distributionTargets =
workbasketService.getDistributionTargets(workbasketId); workbasketService.getDistributionTargets(workbasketId);
DistributionTargetListResource distributionTargetListResource = TaskanaPagedModel<WorkbasketSummaryRepresentationModel> distributionTargetListResource =
distributionTargetResourceAssembler.toCollectionModel(workbasketId, distributionTargets); distributionTargetRepresentationModelAssembler.toPageModel(distributionTargets, null);
ResponseEntity<DistributionTargetListResource> result = ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> result =
ResponseEntity.ok(distributionTargetListResource); ResponseEntity.ok(distributionTargetListResource);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getDistributionTargets(), returning {}", result); LOGGER.debug("Exit from getDistributionTargets(), returning {}", result);
@ -285,7 +297,8 @@ public class WorkbasketController extends AbstractPagingController {
@PutMapping(path = Mapping.URL_WORKBASKET_ID_DISTRIBUTION) @PutMapping(path = Mapping.URL_WORKBASKET_ID_DISTRIBUTION)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<DistributionTargetListResource> setDistributionTargetsForWorkbasketId( public ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>>
setDistributionTargetsForWorkbasketId(
@PathVariable(value = "workbasketId") String sourceWorkbasketId, @PathVariable(value = "workbasketId") String sourceWorkbasketId,
@RequestBody List<String> targetWorkbasketIds) @RequestBody List<String> targetWorkbasketIds)
throws WorkbasketNotFoundException, NotAuthorizedException { throws WorkbasketNotFoundException, NotAuthorizedException {
@ -300,10 +313,9 @@ public class WorkbasketController extends AbstractPagingController {
List<WorkbasketSummary> distributionTargets = List<WorkbasketSummary> distributionTargets =
workbasketService.getDistributionTargets(sourceWorkbasketId); workbasketService.getDistributionTargets(sourceWorkbasketId);
ResponseEntity<DistributionTargetListResource> response = ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
ResponseEntity.ok( ResponseEntity.ok(
distributionTargetResourceAssembler.toCollectionModel( distributionTargetRepresentationModelAssembler.toPageModel(distributionTargets, null));
sourceWorkbasketId, distributionTargets));
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response); LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response);
} }
@ -313,10 +325,10 @@ public class WorkbasketController extends AbstractPagingController {
@DeleteMapping(path = Mapping.URL_WORKBASKET_ID_DISTRIBUTION) @DeleteMapping(path = Mapping.URL_WORKBASKET_ID_DISTRIBUTION)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<CollectionModel<DistributionTargetResource>> public ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>>
removeDistributionTargetForWorkbasketId( removeDistributionTargetForWorkbasketId(
@PathVariable(value = "workbasketId") String targetWorkbasketId) @PathVariable(value = "workbasketId") String targetWorkbasketId)
throws WorkbasketNotFoundException, NotAuthorizedException { throws WorkbasketNotFoundException, NotAuthorizedException {
LOGGER.debug( LOGGER.debug(
"Entry to removeDistributionTargetForWorkbasketId(workbasketId= {})", targetWorkbasketId); "Entry to removeDistributionTargetForWorkbasketId(workbasketId= {})", targetWorkbasketId);
@ -326,7 +338,7 @@ public class WorkbasketController extends AbstractPagingController {
workbasketService.removeDistributionTarget(source.getId(), targetWorkbasketId); workbasketService.removeDistributionTarget(source.getId(), targetWorkbasketId);
} }
ResponseEntity<CollectionModel<DistributionTargetResource>> response = ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
ResponseEntity.noContent().build(); ResponseEntity.noContent().build();
LOGGER.debug("Exit from removeDistributionTargetForWorkbasketId(), returning {}", response); LOGGER.debug("Exit from removeDistributionTargetForWorkbasketId(), returning {}", response);
return response; return response;
@ -377,7 +389,7 @@ public class WorkbasketController extends AbstractPagingController {
return query; return query;
} }
private WorkbasketQuery applyFilterParams( private void applyFilterParams(
WorkbasketQuery query, MultiValueMap<String, String> params) throws InvalidArgumentException { WorkbasketQuery query, MultiValueMap<String, String> params) throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params); LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params);
@ -502,6 +514,5 @@ public class WorkbasketController extends AbstractPagingController {
LOGGER.debug("Exit from applyFilterParams(), returning {}", query); LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
} }
return query;
} }
} }

View File

@ -28,9 +28,9 @@ import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.DomainNotFoundException; import pro.taskana.common.api.exceptions.DomainNotFoundException;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.rest.resource.WorkbasketDefinitionResource; import pro.taskana.rest.resource.WorkbasketDefinitionRepresentationModel;
import pro.taskana.rest.resource.WorkbasketDefinitionResourceAssembler; import pro.taskana.rest.resource.WorkbasketDefinitionRepresentationModelAssembler;
import pro.taskana.rest.resource.WorkbasketResource; import pro.taskana.rest.resource.WorkbasketRepresentationModel;
import pro.taskana.workbasket.api.WorkbasketQuery; import pro.taskana.workbasket.api.WorkbasketQuery;
import pro.taskana.workbasket.api.WorkbasketService; import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.exceptions.InvalidWorkbasketException; import pro.taskana.workbasket.api.exceptions.InvalidWorkbasketException;
@ -43,7 +43,7 @@ import pro.taskana.workbasket.api.models.WorkbasketSummary;
import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl; import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl;
import pro.taskana.workbasket.internal.models.WorkbasketImpl; import pro.taskana.workbasket.internal.models.WorkbasketImpl;
/** Controller for all {@link WorkbasketDefinitionResource} related endpoints. */ /** Controller for all {@link WorkbasketDefinitionRepresentationModel} related endpoints. */
@RestController @RestController
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL) @EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
public class WorkbasketDefinitionController { public class WorkbasketDefinitionController {
@ -53,31 +53,32 @@ public class WorkbasketDefinitionController {
private WorkbasketService workbasketService; private WorkbasketService workbasketService;
private WorkbasketDefinitionResourceAssembler workbasketDefinitionAssembler; private WorkbasketDefinitionRepresentationModelAssembler workbasketDefinitionAssembler;
WorkbasketDefinitionController( WorkbasketDefinitionController(
WorkbasketService workbasketService, WorkbasketService workbasketService,
WorkbasketDefinitionResourceAssembler workbasketDefinitionAssembler) { WorkbasketDefinitionRepresentationModelAssembler workbasketDefinitionAssembler) {
this.workbasketService = workbasketService; this.workbasketService = workbasketService;
this.workbasketDefinitionAssembler = workbasketDefinitionAssembler; this.workbasketDefinitionAssembler = workbasketDefinitionAssembler;
} }
@GetMapping(path = Mapping.URL_WORKBASKETDEFIITIONS) @GetMapping(path = Mapping.URL_WORKBASKETDEFIITIONS)
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<List<WorkbasketDefinitionResource>> exportWorkbaskets( public ResponseEntity<List<WorkbasketDefinitionRepresentationModel>> exportWorkbaskets(
@RequestParam(required = false) String domain) @RequestParam(required = false) String domain)
throws NotAuthorizedException, WorkbasketNotFoundException { throws NotAuthorizedException, WorkbasketNotFoundException {
LOGGER.debug("Entry to exportWorkbaskets(domain= {})", domain); LOGGER.debug("Entry to exportWorkbaskets(domain= {})", domain);
WorkbasketQuery workbasketQuery = workbasketService.createWorkbasketQuery(); WorkbasketQuery workbasketQuery = workbasketService.createWorkbasketQuery();
List<WorkbasketSummary> workbasketSummaryList = List<WorkbasketSummary> workbasketSummaryList =
domain != null ? workbasketQuery.domainIn(domain).list() : workbasketQuery.list(); domain != null ? workbasketQuery.domainIn(domain).list() : workbasketQuery.list();
List<WorkbasketDefinitionResource> basketExports = new ArrayList<>(); List<WorkbasketDefinitionRepresentationModel> basketExports = new ArrayList<>();
for (WorkbasketSummary summary : workbasketSummaryList) { for (WorkbasketSummary summary : workbasketSummaryList) {
Workbasket workbasket = workbasketService.getWorkbasket(summary.getId()); Workbasket workbasket = workbasketService.getWorkbasket(summary.getId());
basketExports.add(workbasketDefinitionAssembler.toModel(workbasket)); basketExports.add(workbasketDefinitionAssembler.toEntityModel(workbasket));
} }
ResponseEntity<List<WorkbasketDefinitionResource>> response = ResponseEntity.ok(basketExports); ResponseEntity<List<WorkbasketDefinitionRepresentationModel>> response =
ResponseEntity.ok(basketExports);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from exportWorkbaskets(), returning {}", response); LOGGER.debug("Exit from exportWorkbaskets(), returning {}", response);
} }
@ -86,9 +87,9 @@ public class WorkbasketDefinitionController {
} }
/** /**
* This method imports a <b>list of {@link WorkbasketDefinitionResource}</b>. This does not * This method imports a <b>list of {@link WorkbasketDefinitionRepresentationModel}</b>. This does
* exactly match the REST norm, but we want to have an option to import all settings at once. When * not exactly match the REST norm, but we want to have an option to import all settings at once.
* a logical equal (key and domain are equal) workbasket already exists an update will be * When a logical equal (key and domain are equal) workbasket already exists an update will be
* executed. Otherwise a new workbasket will be created. * executed. Otherwise a new workbasket will be created.
* *
* @param file the list of workbasket definitions which will be imported to the current system. * @param file the list of workbasket definitions which will be imported to the current system.
@ -119,9 +120,10 @@ public class WorkbasketDefinitionController {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT); mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
List<WorkbasketDefinitionResource> definitions = List<WorkbasketDefinitionRepresentationModel> definitions =
mapper.readValue( mapper.readValue(
file.getInputStream(), new TypeReference<List<WorkbasketDefinitionResource>>() {}); file.getInputStream(),
new TypeReference<List<WorkbasketDefinitionRepresentationModel>>() {});
// key: logical ID // key: logical ID
// value: system ID (in database) // value: system ID (in database)
@ -135,8 +137,9 @@ public class WorkbasketDefinitionController {
Map<String, String> idConversion = new HashMap<>(); Map<String, String> idConversion = new HashMap<>();
// STEP 1: update or create workbaskets from the import // STEP 1: update or create workbaskets from the import
for (WorkbasketDefinitionResource definition : definitions) { for (WorkbasketDefinitionRepresentationModel definition : definitions) {
Workbasket importedWb = workbasketDefinitionAssembler.toModel(definition.getWorkbasket()); Workbasket importedWb = workbasketDefinitionAssembler
.toEntityModel(definition.getWorkbasket());
String newId; String newId;
WorkbasketImpl wbWithoutId = (WorkbasketImpl) removeId(importedWb); WorkbasketImpl wbWithoutId = (WorkbasketImpl) removeId(importedWb);
if (systemIds.containsKey(logicalId(importedWb))) { if (systemIds.containsKey(logicalId(importedWb))) {
@ -179,7 +182,7 @@ public class WorkbasketDefinitionController {
// STEP 2: update distribution targets // STEP 2: update distribution targets
// This can not be done in step 1 because the system IDs are only known after step 1 // This can not be done in step 1 because the system IDs are only known after step 1
for (WorkbasketDefinitionResource definition : definitions) { for (WorkbasketDefinitionRepresentationModel definition : definitions) {
List<String> distributionTargets = new ArrayList<>(); List<String> distributionTargets = new ArrayList<>();
for (String oldId : definition.getDistributionTargets()) { for (String oldId : definition.getDistributionTargets()) {
if (idConversion.containsKey(oldId)) { if (idConversion.containsKey(oldId)) {
@ -204,17 +207,17 @@ public class WorkbasketDefinitionController {
} }
private Workbasket removeId(Workbasket importedWb) { private Workbasket removeId(Workbasket importedWb) {
WorkbasketResource wbRes = new WorkbasketResource(importedWb); WorkbasketRepresentationModel wbRes = new WorkbasketRepresentationModel(importedWb);
wbRes.setWorkbasketId(null); wbRes.setWorkbasketId(null);
return workbasketDefinitionAssembler.toModel(wbRes); return workbasketDefinitionAssembler.toEntityModel(wbRes);
} }
private void checkForDuplicates(List<WorkbasketDefinitionResource> definitions) { private void checkForDuplicates(List<WorkbasketDefinitionRepresentationModel> definitions) {
List<String> identifiers = new ArrayList<>(); List<String> identifiers = new ArrayList<>();
Set<String> duplicates = new HashSet<>(); Set<String> duplicates = new HashSet<>();
for (WorkbasketDefinitionResource definition : definitions) { for (WorkbasketDefinitionRepresentationModel definition : definitions) {
String identifier = String identifier =
logicalId(workbasketDefinitionAssembler.toModel(definition.getWorkbasket())); logicalId(workbasketDefinitionAssembler.toEntityModel(definition.getWorkbasket()));
if (identifiers.contains(identifier)) { if (identifiers.contains(identifier)) {
duplicates.add(identifier); duplicates.add(identifier);
} else { } else {

View File

@ -3,6 +3,7 @@ package pro.taskana.rest.resource;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.hateoas.Link; import org.springframework.hateoas.Link;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder; import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
@ -41,7 +42,7 @@ public abstract class AbstractRessourcesAssembler {
} }
protected PagedResources<?> addPageLinks( protected PagedResources<?> addPageLinks(
PagedResources<?> pagedResources, PagedResources.PageMetadata pageMetadata) { PagedResources<?> pagedResources, PageMetadata pageMetadata) {
UriComponentsBuilder original = getBuilderForOriginalUri(); UriComponentsBuilder original = getBuilderForOriginalUri();
pagedResources.add( pagedResources.add(
(new Link(original.replaceQueryParam("page", 1).toUriString())).withRel("first")); (new Link(original.replaceQueryParam("page", 1).toUriString())).withRel("first"));
@ -51,7 +52,7 @@ public abstract class AbstractRessourcesAssembler {
if (pageMetadata.getNumber() > 1L) { if (pageMetadata.getNumber() > 1L) {
pagedResources.add( pagedResources.add(
(new Link( (new Link(
original.replaceQueryParam("page", pageMetadata.getNumber() - 1L).toUriString())) original.replaceQueryParam("page", pageMetadata.getNumber() - 1L).toUriString()))
.withRel("prev")); .withRel("prev"));
} }

View File

@ -5,14 +5,14 @@ package pro.taskana.rest.resource;
* *
* @author bbr * @author bbr
*/ */
public class AccessIdResource { public class AccessIdRepresentationModel {
private String name; private String name;
private String accessId; private String accessId;
public AccessIdResource() {} public AccessIdRepresentationModel() {}
public AccessIdResource(String name, String accessId) { public AccessIdRepresentationModel(String name, String accessId) {
this.accessId = accessId; this.accessId = accessId;
this.name = name; this.name = name;
} }

View File

@ -0,0 +1,54 @@
package pro.taskana.rest.resource;
import java.util.HashMap;
import java.util.Map;
import pro.taskana.task.api.models.Attachment;
/**
* EntityModel class for {@link Attachment}.
*/
public class AttachmentRepresentationModel
extends AttachmentSummaryRepresentationModel {
private Map<String, String> customAttributes = new HashMap<>();
public AttachmentRepresentationModel() {
}
public AttachmentRepresentationModel(Attachment attachment) {
super(attachment);
this.customAttributes = attachment.getCustomAttributes();
}
public Map<String, String> getCustomAttributes() {
return customAttributes;
}
public void setCustomAttributes(Map<String, String> customAttributes) {
this.customAttributes = customAttributes;
}
@Override
public String toString() {
return "AttachmentRepresentationModel [customAttributes="
+ customAttributes
+ ", attachmentId="
+ attachmentId
+ ", taskId="
+ taskId
+ ", created="
+ created
+ ", modified="
+ modified
+ ", classificationSummaryRepresentationModel="
+ classificationSummary
+ ", objectReference="
+ objectReference
+ ", channel="
+ channel
+ ", received="
+ received
+ "]";
}
}

View File

@ -0,0 +1,56 @@
package pro.taskana.rest.resource;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.server.RepresentationModelAssembler;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import pro.taskana.rest.AttachmentController;
import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.models.Attachment;
import pro.taskana.task.internal.models.AttachmentImpl;
/**
* EntityModel assembler for {@link AttachmentRepresentationModel}.
*/
@Component
public class AttachmentRepresentationModelAssembler
implements RepresentationModelAssembler<Attachment, AttachmentRepresentationModel> {
private final TaskService taskService;
private final ClassificationSummaryRepresentationModelAssembler classificationAssembler;
@Autowired
public AttachmentRepresentationModelAssembler(TaskService taskService,
ClassificationSummaryRepresentationModelAssembler classificationAssembler) {
this.taskService = taskService;
this.classificationAssembler = classificationAssembler;
}
@NonNull
@Override
public AttachmentRepresentationModel toModel(@NonNull Attachment attachment) {
AttachmentRepresentationModel resource = new AttachmentRepresentationModel(attachment);
resource.add(linkTo(AttachmentController.class).slash(attachment.getId()).withSelfRel());
return resource;
}
public List<Attachment> toAttachmentList(List<AttachmentRepresentationModel> resources) {
return resources.stream().map(this::apply).collect(Collectors.toList());
}
private AttachmentImpl apply(AttachmentRepresentationModel attachmentRepresentationModel) {
AttachmentImpl attachment = (AttachmentImpl) taskService.newAttachment();
BeanUtils.copyProperties(attachmentRepresentationModel, attachment);
attachment.setId(attachmentRepresentationModel.getAttachmentId());
attachment.setClassificationSummary(classificationAssembler.toEntityModel(
attachmentRepresentationModel.getClassificationSummary()));
return attachment;
}
}

View File

@ -1,132 +0,0 @@
package pro.taskana.rest.resource;
import java.util.HashMap;
import java.util.Map;
import org.springframework.hateoas.RepresentationModel;
import pro.taskana.task.api.models.Attachment;
import pro.taskana.task.api.models.ObjectReference;
/** EntityModel class for {@link Attachment}. */
public class AttachmentResource extends RepresentationModel<AttachmentResource> {
private String attachmentId;
private String taskId;
private String created;
private String modified;
private ClassificationSummaryResource classificationSummaryResource;
private ObjectReference objectReference;
private String channel;
private String received;
private Map<String, String> customAttributes = new HashMap<String, String>();
public AttachmentResource() {}
public AttachmentResource(Attachment attachment) {
this.attachmentId = attachment.getId();
this.taskId = attachment.getTaskId();
this.created = attachment.getCreated() != null ? attachment.getCreated().toString() : null;
this.modified = attachment.getModified() != null ? attachment.getModified().toString() : null;
this.classificationSummaryResource =
new ClassificationSummaryResource(attachment.getClassificationSummary());
this.objectReference = attachment.getObjectReference();
this.channel = attachment.getChannel();
this.received = attachment.getReceived() != null ? attachment.getReceived().toString() : null;
this.customAttributes = attachment.getCustomAttributes();
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
public String getModified() {
return modified;
}
public void setModified(String modified) {
this.modified = modified;
}
public String getReceived() {
return received;
}
public void setReceived(String received) {
this.received = received;
}
public String getAttachmentId() {
return attachmentId;
}
public void setAttachmentId(String attachmentId) {
this.attachmentId = attachmentId;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public ClassificationSummaryResource getClassificationSummary() {
return classificationSummaryResource;
}
public void setClassificationSummary(
ClassificationSummaryResource classificationSummaryResource) {
this.classificationSummaryResource = classificationSummaryResource;
}
public ObjectReference getObjectReference() {
return objectReference;
}
public void setObjectReference(ObjectReference objectReference) {
this.objectReference = objectReference;
}
public String getChannel() {
return channel;
}
public void setChannel(String channel) {
this.channel = channel;
}
public Map<String, String> getCustomAttributes() {
return customAttributes;
}
public void setCustomAttributes(Map<String, String> customAttributes) {
this.customAttributes = customAttributes;
}
@Override
public String toString() {
return "AttachmentResource ["
+ "attachmentId= "
+ this.attachmentId
+ "taskId= "
+ this.taskId
+ "created= "
+ this.created
+ "modified= "
+ this.modified
+ "classificationSummaryResource= "
+ this.classificationSummaryResource
+ "objectReference= "
+ this.objectReference
+ "channel= "
+ this.channel
+ "received= "
+ this.received
+ "]";
}
}

View File

@ -1,50 +0,0 @@
package pro.taskana.rest.resource;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.stereotype.Component;
import pro.taskana.rest.AttachmentController;
import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.models.Attachment;
import pro.taskana.task.internal.models.AttachmentImpl;
/** EntityModel assembler for {@link AttachmentResource}. */
@Component
public class AttachmentResourceAssembler
extends RepresentationModelAssemblerSupport<Attachment, AttachmentResource> {
@Autowired private TaskService taskService;
@Autowired private ClassificationSummaryResourceAssembler classificationAssembler;
public AttachmentResourceAssembler() {
super(AttachmentController.class, AttachmentResource.class);
}
@Override
public AttachmentResource toModel(Attachment attachment) {
AttachmentResource resource = new AttachmentResource(attachment);
resource.add(linkTo(AttachmentController.class).slash(attachment.getId()).withSelfRel());
return resource;
}
public List<Attachment> toModel(List<AttachmentResource> resources) {
return resources.stream()
.map(
attachmentResource -> {
AttachmentImpl attachment = (AttachmentImpl) taskService.newAttachment();
BeanUtils.copyProperties(attachmentResource, attachment);
attachment.setId(attachmentResource.getAttachmentId());
attachment.setClassificationSummary(
classificationAssembler.toModel(attachmentResource.getClassificationSummary()));
return attachment;
})
.collect(Collectors.toList());
}
}

View File

@ -5,29 +5,33 @@ import org.springframework.hateoas.RepresentationModel;
import pro.taskana.task.api.models.AttachmentSummary; import pro.taskana.task.api.models.AttachmentSummary;
import pro.taskana.task.api.models.ObjectReference; import pro.taskana.task.api.models.ObjectReference;
/** EntityModel class for {@link AttachmentSummary}. */ /**
public class AttachmentSummaryResource extends RepresentationModel<AttachmentSummaryResource> { * EntityModel class for {@link AttachmentSummary}.
*/
public class AttachmentSummaryRepresentationModel
extends RepresentationModel<AttachmentSummaryRepresentationModel> {
private String attachmentId; protected String attachmentId;
private String taskId; protected String taskId;
private String created; protected String created;
private String modified; protected String modified;
private ClassificationSummaryResource classificationSummaryResource; protected ClassificationSummaryRepresentationModel classificationSummary;
private ObjectReference objectReference; protected ObjectReference objectReference;
private String channel; protected String channel;
private String received; protected String received;
AttachmentSummaryResource() {} AttachmentSummaryRepresentationModel() {
}
public AttachmentSummaryResource(AttachmentSummary attachmentSummary) { public AttachmentSummaryRepresentationModel(AttachmentSummary attachmentSummary) {
this.attachmentId = attachmentSummary.getId(); this.attachmentId = attachmentSummary.getId();
this.taskId = attachmentSummary.getTaskId(); this.taskId = attachmentSummary.getTaskId();
this.created = this.created =
attachmentSummary.getCreated() != null ? attachmentSummary.getCreated().toString() : null; attachmentSummary.getCreated() != null ? attachmentSummary.getCreated().toString() : null;
this.modified = this.modified =
attachmentSummary.getModified() != null ? attachmentSummary.getModified().toString() : null; attachmentSummary.getModified() != null ? attachmentSummary.getModified().toString() : null;
this.classificationSummaryResource = this.classificationSummary =
new ClassificationSummaryResource(attachmentSummary.getClassificationSummary()); new ClassificationSummaryRepresentationModel(attachmentSummary.getClassificationSummary());
this.objectReference = attachmentSummary.getObjectReference(); this.objectReference = attachmentSummary.getObjectReference();
this.channel = attachmentSummary.getChannel(); this.channel = attachmentSummary.getChannel();
this.received = this.received =
@ -66,13 +70,13 @@ public class AttachmentSummaryResource extends RepresentationModel<AttachmentSum
this.modified = modified; this.modified = modified;
} }
public ClassificationSummaryResource getClassificationSummary() { public ClassificationSummaryRepresentationModel getClassificationSummary() {
return classificationSummaryResource; return classificationSummary;
} }
public void setClassificationSummary( public void setClassificationSummary(
ClassificationSummaryResource classificationSummaryResource) { ClassificationSummaryRepresentationModel classificationSummary) {
this.classificationSummaryResource = classificationSummaryResource; this.classificationSummary = classificationSummary;
} }
public ObjectReference getObjectReference() { public ObjectReference getObjectReference() {
@ -102,22 +106,22 @@ public class AttachmentSummaryResource extends RepresentationModel<AttachmentSum
@Override @Override
public String toString() { public String toString() {
return "AttachmentSummaryResource [" return "AttachmentSummaryResource ["
+ "attachmentId= " + "attachmentId= "
+ this.attachmentId + this.attachmentId
+ "taskId= " + "taskId= "
+ this.taskId + this.taskId
+ "created= " + "created= "
+ this.created + this.created
+ "modified= " + "modified= "
+ this.modified + this.modified
+ "classificationSummaryResource= " + "classificationSummaryResource= "
+ this.classificationSummaryResource + this.classificationSummary
+ "objectReference= " + "objectReference= "
+ this.objectReference + this.objectReference
+ "channel= " + "channel= "
+ this.channel + this.channel
+ "received= " + "received= "
+ this.received + this.received
+ "]"; + "]";
} }
} }

View File

@ -0,0 +1,22 @@
package pro.taskana.rest.resource;
import org.springframework.hateoas.server.RepresentationModelAssembler;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import pro.taskana.task.api.models.AttachmentSummary;
/**
* EntityModel assembler for {@link AttachmentSummaryRepresentationModel}.
*/
@Component
public class AttachmentSummaryRepresentationModelAssembler implements
RepresentationModelAssembler<AttachmentSummary, AttachmentSummaryRepresentationModel> {
@NonNull
@Override
public AttachmentSummaryRepresentationModel toModel(
@NonNull AttachmentSummary attachmentSummary) {
return new AttachmentSummaryRepresentationModel(attachmentSummary);
}
}

View File

@ -1,22 +0,0 @@
package pro.taskana.rest.resource;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.stereotype.Component;
import pro.taskana.rest.AttachmentController;
import pro.taskana.task.api.models.AttachmentSummary;
/** EntityModel assembler for {@link AttachmentSummaryResource}. */
@Component
public class AttachmentSummaryResourceAssembler
extends RepresentationModelAssemblerSupport<AttachmentSummary, AttachmentSummaryResource> {
public AttachmentSummaryResourceAssembler() {
super(AttachmentController.class, AttachmentSummaryResource.class);
}
@Override
public AttachmentSummaryResource toModel(AttachmentSummary attachmentSummary) {
return new AttachmentSummaryResource(attachmentSummary);
}
}

View File

@ -0,0 +1,111 @@
package pro.taskana.rest.resource;
import pro.taskana.classification.api.models.Classification;
/**
* EntityModel class for {@link Classification}.
*/
public class ClassificationRepresentationModel
extends ClassificationSummaryRepresentationModel {
private Boolean isValidInDomain;
private String created; // ISO-8601
private String modified; // ISO-8601
private String description;
public ClassificationRepresentationModel() {
}
public ClassificationRepresentationModel(Classification classification) {
super(classification);
this.isValidInDomain = classification.getIsValidInDomain();
this.created =
classification.getCreated() != null ? classification.getCreated().toString() : null;
this.modified =
classification.getModified() != null ? classification.getModified().toString() : null;
this.description = classification.getDescription();
}
public Boolean getIsValidInDomain() {
return isValidInDomain;
}
public void setIsValidInDomain(Boolean validInDomain) {
isValidInDomain = validInDomain;
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
public String getModified() {
return modified;
}
public void setModified(String modified) {
this.modified = modified;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public String toString() {
return "ClassificationResource [classificationId="
+ classificationId
+ ", key="
+ key
+ ", parentId="
+ parentId
+ ", parentKey="
+ parentKey
+ ", category="
+ category
+ ", type="
+ type
+ ", domain="
+ domain
+ ", isValidInDomain="
+ isValidInDomain
+ ", created="
+ created
+ ", modified="
+ modified
+ ", name="
+ name
+ ", description="
+ description
+ ", priority="
+ priority
+ ", serviceLevel="
+ serviceLevel
+ ", applicationEntryPoint="
+ applicationEntryPoint
+ ", custom1="
+ custom1
+ ", custom2="
+ custom2
+ ", custom3="
+ custom3
+ ", custom4="
+ custom4
+ ", custom5="
+ custom5
+ ", custom6="
+ custom6
+ ", custom7="
+ custom7
+ ", custom8="
+ custom8
+ "]";
}
}

View File

@ -0,0 +1,70 @@
package pro.taskana.rest.resource;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import java.time.Instant;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.server.RepresentationModelAssembler;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import pro.taskana.classification.api.ClassificationService;
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
import pro.taskana.classification.api.models.Classification;
import pro.taskana.classification.internal.models.ClassificationImpl;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.rest.ClassificationController;
/**
* Transforms {@link Classification} to its resource counterpart {@link
* ClassificationRepresentationModel} and vice versa.
*/
@Component
public class ClassificationRepresentationModelAssembler
implements RepresentationModelAssembler<Classification, ClassificationRepresentationModel> {
final ClassificationService classificationService;
@Autowired
public ClassificationRepresentationModelAssembler(
ClassificationService classificationService) {
this.classificationService = classificationService;
}
@NonNull
@Override
public ClassificationRepresentationModel toModel(@NonNull Classification classification) {
ClassificationRepresentationModel resource =
new ClassificationRepresentationModel(classification);
try {
resource.add(
linkTo(methodOn(ClassificationController.class).getClassification(classification.getId()))
.withSelfRel());
} catch (ClassificationNotFoundException e) {
throw new SystemException("caught unexpected Exception.", e.getCause());
}
return resource;
}
public Classification toEntityModel(
ClassificationRepresentationModel classificationRepresentationModel) {
ClassificationImpl classification =
(ClassificationImpl)
classificationService.newClassification(
classificationRepresentationModel.getKey(),
classificationRepresentationModel.getDomain(),
classificationRepresentationModel.getType());
BeanUtils.copyProperties(classificationRepresentationModel, classification);
classification.setId(classificationRepresentationModel.getClassificationId());
if (classificationRepresentationModel.getCreated() != null) {
classification.setCreated(Instant.parse(classificationRepresentationModel.getCreated()));
}
if (classificationRepresentationModel.getModified() != null) {
classification.setModified(Instant.parse(classificationRepresentationModel.getModified()));
}
return classification;
}
}

View File

@ -1,299 +0,0 @@
package pro.taskana.rest.resource;
import javax.validation.constraints.NotNull;
import org.springframework.hateoas.RepresentationModel;
import pro.taskana.classification.api.models.Classification;
/** EntityModel class for {@link Classification}. */
public class ClassificationResource extends RepresentationModel<ClassificationResource> {
@NotNull private String classificationId;
@NotNull private String key;
private String parentId;
private String parentKey;
private String category;
private String type;
private String domain;
private Boolean isValidInDomain;
private String created; // ISO-8601
private String modified; // ISO-8601
private String name;
private String description;
private int priority;
private String serviceLevel; // PddDThhHmmM
private String applicationEntryPoint;
private String custom1;
private String custom2;
private String custom3;
private String custom4;
private String custom5;
private String custom6;
private String custom7;
private String custom8;
public ClassificationResource() {}
public ClassificationResource(Classification classification) {
this.classificationId = classification.getId();
this.key = classification.getKey();
this.parentId = classification.getParentId();
this.parentKey = classification.getParentKey();
this.category = classification.getCategory();
this.type = classification.getType();
this.domain = classification.getDomain();
this.isValidInDomain = classification.getIsValidInDomain();
this.created =
classification.getCreated() != null ? classification.getCreated().toString() : null;
this.modified =
classification.getModified() != null ? classification.getModified().toString() : null;
this.name = classification.getName();
this.description = classification.getDescription();
this.priority = classification.getPriority();
this.serviceLevel = classification.getServiceLevel();
this.applicationEntryPoint = classification.getApplicationEntryPoint();
this.custom1 = classification.getCustom1();
this.custom2 = classification.getCustom2();
this.custom3 = classification.getCustom3();
this.custom4 = classification.getCustom4();
this.custom5 = classification.getCustom5();
this.custom6 = classification.getCustom6();
this.custom7 = classification.getCustom7();
this.custom8 = classification.getCustom8();
}
public String getClassificationId() {
return classificationId;
}
public void setClassificationId(String classificationId) {
this.classificationId = classificationId;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getParentKey() {
return parentKey;
}
public void setParentKey(String parentKey) {
this.parentKey = parentKey;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public Boolean getIsValidInDomain() {
return isValidInDomain;
}
public void setIsValidInDomain(Boolean validInDomain) {
isValidInDomain = validInDomain;
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
public String getModified() {
return modified;
}
public void setModified(String modified) {
this.modified = modified;
}
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 int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
public String getServiceLevel() {
return serviceLevel;
}
public void setServiceLevel(String serviceLevel) {
this.serviceLevel = serviceLevel;
}
public String getApplicationEntryPoint() {
return applicationEntryPoint;
}
public void setApplicationEntryPoint(String applicationEntryPoint) {
this.applicationEntryPoint = applicationEntryPoint;
}
public String getCustom1() {
return custom1;
}
public void setCustom1(String custom1) {
this.custom1 = custom1;
}
public String getCustom2() {
return custom2;
}
public void setCustom2(String custom2) {
this.custom2 = custom2;
}
public String getCustom3() {
return custom3;
}
public void setCustom3(String custom3) {
this.custom3 = custom3;
}
public String getCustom4() {
return custom4;
}
public void setCustom4(String custom4) {
this.custom4 = custom4;
}
public String getCustom5() {
return custom5;
}
public void setCustom5(String custom5) {
this.custom5 = custom5;
}
public String getCustom6() {
return custom6;
}
public void setCustom6(String custom6) {
this.custom6 = custom6;
}
public String getCustom7() {
return custom7;
}
public void setCustom7(String custom7) {
this.custom7 = custom7;
}
public String getCustom8() {
return custom8;
}
public void setCustom8(String custom8) {
this.custom8 = custom8;
}
@Override
public String toString() {
return "ClassificationResource [classificationId="
+ classificationId
+ ", key="
+ key
+ ", parentId="
+ parentId
+ ", parentKey="
+ parentKey
+ ", category="
+ category
+ ", type="
+ type
+ ", domain="
+ domain
+ ", isValidInDomain="
+ isValidInDomain
+ ", created="
+ created
+ ", modified="
+ modified
+ ", name="
+ name
+ ", description="
+ description
+ ", priority="
+ priority
+ ", serviceLevel="
+ serviceLevel
+ ", applicationEntryPoint="
+ applicationEntryPoint
+ ", custom1="
+ custom1
+ ", custom2="
+ custom2
+ ", custom3="
+ custom3
+ ", custom4="
+ custom4
+ ", custom5="
+ custom5
+ ", custom6="
+ custom6
+ ", custom7="
+ custom7
+ ", custom8="
+ custom8
+ "]";
}
}

View File

@ -1,72 +0,0 @@
package pro.taskana.rest.resource;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import java.time.Instant;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.stereotype.Component;
import pro.taskana.classification.api.ClassificationService;
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
import pro.taskana.classification.api.models.Classification;
import pro.taskana.classification.internal.models.ClassificationImpl;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.rest.ClassificationController;
/**
* Transforms {@link Classification} to its resource counterpart {@link ClassificationResource} and
* vice versa.
*/
@Component
public class ClassificationResourceAssembler
extends RepresentationModelAssemblerSupport<Classification, ClassificationResource> {
final ClassificationService classificationService;
@Autowired
public ClassificationResourceAssembler(ClassificationService classificationService) {
super(ClassificationController.class, ClassificationResource.class);
this.classificationService = classificationService;
}
public ClassificationResource toDefinition(Classification classification) {
ClassificationResource resource = new ClassificationResource(classification);
resource.add(
linkTo(ClassificationController.class).slash(classification.getId()).withSelfRel());
return resource;
}
public ClassificationResource toModel(Classification classification) {
ClassificationResource resource = new ClassificationResource(classification);
try {
resource.add(
linkTo(methodOn(ClassificationController.class).getClassification(classification.getId()))
.withSelfRel());
} catch (ClassificationNotFoundException e) {
throw new SystemException("caught unexpected Exception.", e.getCause());
}
return resource;
}
public Classification toModel(ClassificationResource classificationResource) {
ClassificationImpl classification =
(ClassificationImpl)
classificationService.newClassification(
classificationResource.getKey(),
classificationResource.getDomain(),
classificationResource.getType());
BeanUtils.copyProperties(classificationResource, classification);
classification.setId(classificationResource.getClassificationId());
if (classificationResource.getCreated() != null) {
classification.setCreated(Instant.parse(classificationResource.getCreated()));
}
if (classificationResource.getModified() != null) {
classification.setModified(Instant.parse(classificationResource.getModified()));
}
return classification;
}
}

View File

@ -1,24 +0,0 @@
package pro.taskana.rest.resource;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collection;
import org.springframework.hateoas.Link;
/** EntityModel class for {@link ClassificationSummaryResource} with Pagination. */
public class ClassificationSummaryListResource
extends PagedResources<ClassificationSummaryResource> {
public ClassificationSummaryListResource() {
super();
}
public ClassificationSummaryListResource(
Collection<ClassificationSummaryResource> content, PageMetadata metadata, Link... links) {
super(content, metadata, links);
}
@JsonProperty("classifications")
public Collection<ClassificationSummaryResource> getContent() {
return super.getContent();
}
}

View File

@ -4,33 +4,36 @@ import org.springframework.hateoas.RepresentationModel;
import pro.taskana.classification.api.models.ClassificationSummary; import pro.taskana.classification.api.models.ClassificationSummary;
/** EntityModel class for {@link ClassificationSummary}. */ /**
public class ClassificationSummaryResource * EntityModel class for {@link ClassificationSummary}.
extends RepresentationModel<ClassificationSummaryResource> { */
public class ClassificationSummaryRepresentationModel
extends RepresentationModel<ClassificationSummaryRepresentationModel> {
private String classificationId; protected String classificationId;
private String applicationEntryPoint; protected String key;
private String category; protected String applicationEntryPoint;
private String domain; protected String category;
private String key; protected String domain;
private String name; protected String name;
private String parentId; protected String parentId;
private String parentKey; protected String parentKey;
private int priority; protected int priority;
private String serviceLevel; protected String serviceLevel;
private String type; protected String type;
private String custom1; protected String custom1;
private String custom2; protected String custom2;
private String custom3; protected String custom3;
private String custom4; protected String custom4;
private String custom5; protected String custom5;
private String custom6; protected String custom6;
private String custom7; protected String custom7;
private String custom8; protected String custom8;
public ClassificationSummaryResource() {} public ClassificationSummaryRepresentationModel() {
}
public ClassificationSummaryResource(ClassificationSummary classification) { public ClassificationSummaryRepresentationModel(ClassificationSummary classification) {
classificationId = classification.getId(); classificationId = classification.getId();
applicationEntryPoint = classification.getApplicationEntryPoint(); applicationEntryPoint = classification.getApplicationEntryPoint();
category = classification.getCategory(); category = classification.getCategory();

View File

@ -0,0 +1,63 @@
package pro.taskana.rest.resource;
import static pro.taskana.rest.resource.TaskanaPagedModelKeys.CLASSIFICATIONS;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.server.RepresentationModelAssembler;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import pro.taskana.classification.api.ClassificationService;
import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.classification.internal.models.ClassificationImpl;
import pro.taskana.rest.Mapping;
import pro.taskana.rest.resource.links.PageLinks;
/**
* EntityModel assembler for {@link ClassificationSummaryRepresentationModel}.
*/
@Component
public class ClassificationSummaryRepresentationModelAssembler
implements
RepresentationModelAssembler<ClassificationSummary, ClassificationSummaryRepresentationModel> {
private final ClassificationService classificationService;
@Autowired
public ClassificationSummaryRepresentationModelAssembler(
ClassificationService classificationService) {
this.classificationService = classificationService;
}
@NonNull
@Override
public ClassificationSummaryRepresentationModel toModel(
@NonNull ClassificationSummary classificationSummary) {
return new ClassificationSummaryRepresentationModel(classificationSummary);
}
public ClassificationSummary toEntityModel(ClassificationSummaryRepresentationModel resource) {
ClassificationImpl classification =
(ClassificationImpl)
classificationService.newClassification(
resource.getKey(), resource.getDomain(), resource.getType());
classification.setId(resource.getClassificationId());
BeanUtils.copyProperties(resource, classification);
return classification.asSummary();
}
@PageLinks(Mapping.URL_CLASSIFICATIONS)
public TaskanaPagedModel<ClassificationSummaryRepresentationModel> toPageModel(
List<ClassificationSummary> classificationSummaries, PageMetadata pageMetadata) {
return classificationSummaries.stream()
.map(this::toModel)
.collect(
Collectors.collectingAndThen(
Collectors.toList(),
list -> new TaskanaPagedModel<>(CLASSIFICATIONS, list, pageMetadata)));
}
}

View File

@ -1,50 +0,0 @@
package pro.taskana.rest.resource;
import java.util.Collection;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.stereotype.Component;
import pro.taskana.classification.api.ClassificationService;
import pro.taskana.classification.api.models.ClassificationSummary;
import pro.taskana.classification.internal.models.ClassificationImpl;
import pro.taskana.rest.ClassificationController;
import pro.taskana.rest.Mapping;
import pro.taskana.rest.resource.PagedResources.PageMetadata;
import pro.taskana.rest.resource.links.PageLinks;
/** EntityModel assembler for {@link ClassificationSummaryResource}. */
@Component
public class ClassificationSummaryResourceAssembler
extends RepresentationModelAssemblerSupport<
ClassificationSummary, ClassificationSummaryResource> {
@Autowired private ClassificationService classificationService;
public ClassificationSummaryResourceAssembler() {
super(ClassificationController.class, ClassificationSummaryResource.class);
}
@Override
public ClassificationSummaryResource toModel(ClassificationSummary classificationSummary) {
return new ClassificationSummaryResource(classificationSummary);
}
public ClassificationSummary toModel(ClassificationSummaryResource resource) {
ClassificationImpl classification =
(ClassificationImpl)
classificationService.newClassification(
resource.getKey(), resource.getDomain(), resource.getType());
classification.setId(resource.getClassificationId());
BeanUtils.copyProperties(resource, classification);
return classification.asSummary();
}
@PageLinks(Mapping.URL_CLASSIFICATIONS)
public ClassificationSummaryListResource toCollectionModel(
Collection<ClassificationSummary> entities, PageMetadata pageMetadata) {
return new ClassificationSummaryListResource(
toCollectionModel(entities).getContent(), pageMetadata);
}
}

View File

@ -1,31 +0,0 @@
package pro.taskana.rest.resource;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collection;
import org.springframework.hateoas.Link;
/** EntityModel class for {@link DistributionTargetResource} with Pagination. */
public class DistributionTargetListResource extends PagedResources<DistributionTargetResource> {
public DistributionTargetListResource() {
super();
}
public DistributionTargetListResource(
Collection<DistributionTargetResource> content, Link... links) {
super(content, null, links);
}
@Override
@JsonIgnore
public PageMetadata getMetadata() {
return super.getMetadata();
}
@Override
@JsonProperty("distributionTargets")
public Collection<DistributionTargetResource> getContent() {
return super.getContent();
}
}

View File

@ -0,0 +1,19 @@
package pro.taskana.rest.resource;
import static pro.taskana.rest.resource.TaskanaPagedModelKeys.DISTRIBUTION_TARGETS;
import org.springframework.stereotype.Component;
/**
* Transforms WorkbasketSummary to its resource counterpart DistributionTargerResource and vice
* versa.
*/
@Component
public class DistributionTargetRepresentationModelAssembler
extends WorkbasketSummaryRepresentationModelAssembler {
@Override
protected TaskanaPagedModelKeys getKey() {
return DISTRIBUTION_TARGETS;
}
}

View File

@ -1,16 +0,0 @@
package pro.taskana.rest.resource;
import org.springframework.hateoas.server.core.Relation;
import pro.taskana.workbasket.api.models.WorkbasketSummary;
/** EntityModel class for a distribution target based on {@link WorkbasketSummary}. */
@Relation(collectionRelation = "distributionTargets")
public class DistributionTargetResource extends WorkbasketSummaryResource {
DistributionTargetResource() {}
DistributionTargetResource(WorkbasketSummary workbasketSummary) {
super(workbasketSummary);
}
}

View File

@ -1,46 +0,0 @@
package pro.taskana.rest.resource;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import java.util.List;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.stereotype.Component;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.rest.WorkbasketController;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.WorkbasketSummary;
/**
* Transforms WorkbasketSummary to its resource counterpart DistributionTargerResource and vice
* versa.
*/
@Component
public class DistributionTargetResourceAssembler
extends RepresentationModelAssemblerSupport<WorkbasketSummary, DistributionTargetResource> {
public DistributionTargetResourceAssembler() {
super(WorkbasketController.class, DistributionTargetResource.class);
}
public DistributionTargetResource toModel(WorkbasketSummary summary) {
return new DistributionTargetResource(summary);
}
public DistributionTargetListResource toCollectionModel(
String workbasketId, List<WorkbasketSummary> distributionTargets)
throws WorkbasketNotFoundException, NotAuthorizedException {
DistributionTargetListResource distributionTargetListResource =
new DistributionTargetListResource(toCollectionModel(distributionTargets).getContent());
distributionTargetListResource.add(
linkTo(methodOn(WorkbasketController.class).getDistributionTargets(workbasketId))
.withSelfRel());
distributionTargetListResource.add(
linkTo(methodOn(WorkbasketController.class).getWorkbasket(workbasketId))
.withRel("workbasket"));
return distributionTargetListResource;
}
}

View File

@ -6,10 +6,9 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Objects; import java.util.Objects;
import javax.xml.bind.annotation.XmlAttribute;
import org.springframework.hateoas.Link; import org.springframework.hateoas.Link;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.RepresentationModel;
import org.springframework.util.Assert;
/** /**
* Base Class for CollectionModel with pagination. * Base Class for CollectionModel with pagination.
@ -78,135 +77,4 @@ public class PagedResources<T> extends RepresentationModel<PagedResources<T>> {
return Collections.unmodifiableCollection(content); return Collections.unmodifiableCollection(content);
} }
/** Class for Page Metadata. */
public static class PageMetadata {
@XmlAttribute @JsonProperty private long size;
@XmlAttribute @JsonProperty private long totalElements;
@XmlAttribute @JsonProperty private long totalPages;
@XmlAttribute @JsonProperty private long number;
protected PageMetadata() {}
/**
* Creates a new {@link PageMetadata} from the given size, number, total elements and total
* pages.
*
* @param size the size
* @param number zero-indexed, must be less than totalPages
* @param totalElements number of elements
* @param totalPages the total pages
*/
public PageMetadata(long size, long number, long totalElements, long totalPages) {
Assert.isTrue(size > -1, "Size must not be negative!");
Assert.isTrue(number > -1, "Number must not be negative!");
Assert.isTrue(totalElements > -1, "Total elements must not be negative!");
Assert.isTrue(totalPages > -1, "Total pages must not be negative!");
this.size = size;
this.number = number;
this.totalElements = totalElements;
this.totalPages = totalPages;
}
/**
* Creates a new {@link PageMetadata} from the given size, number and total elements.
*
* @param size the size of the page
* @param number the number of the page
* @param totalElements the total number of elements available
*/
public PageMetadata(long size, long number, long totalElements) {
this(
size,
number,
totalElements,
size == 0 ? 0 : (long) Math.ceil((double) totalElements / (double) size));
}
/**
* Returns the requested size of the page.
*
* @return the size a positive long.
*/
public long getSize() {
return size;
}
/**
* Returns the total number of elements available.
*
* @return the totalElements a positive long.
*/
public long getTotalElements() {
return totalElements;
}
/**
* Returns how many pages are available in total.
*
* @return the totalPages a positive long.
*/
public long getTotalPages() {
return totalPages;
}
/**
* Returns the number of the current page.
*
* @return the number a positive long.
*/
public long getNumber() {
return number;
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
int result = 17;
result += 31 * (int) (this.number ^ this.number >>> 32);
result += 31 * (int) (this.size ^ this.size >>> 32);
result += 31 * (int) (this.totalElements ^ this.totalElements >>> 32);
result += 31 * (int) (this.totalPages ^ this.totalPages >>> 32);
return result;
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || !obj.getClass().equals(getClass())) {
return false;
}
PageMetadata that = (PageMetadata) obj;
return this.number == that.number
&& this.size == that.size
&& this.totalElements == that.totalElements
&& this.totalPages == that.totalPages;
}
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return String.format(
"Metadata { number: %d, total pages: %d, total elements: %d, size: %d }",
number, totalPages, totalElements, size);
}
}
} }

View File

@ -8,7 +8,7 @@ import pro.taskana.monitor.api.reports.Report;
import pro.taskana.monitor.api.reports.row.SingleRow; import pro.taskana.monitor.api.reports.row.SingleRow;
/** EntityModel class for {@link Report}. */ /** EntityModel class for {@link Report}. */
public class ReportResource extends RepresentationModel<ReportResource> { public class ReportRepresentationModel extends RepresentationModel<ReportRepresentationModel> {
private MetaInformation meta; private MetaInformation meta;
@ -16,7 +16,8 @@ public class ReportResource extends RepresentationModel<ReportResource> {
private List<RowResource> sumRow; private List<RowResource> sumRow;
public ReportResource(MetaInformation meta, List<RowResource> rows, List<RowResource> sumRow) { public ReportRepresentationModel(
MetaInformation meta, List<RowResource> rows, List<RowResource> sumRow) {
this.meta = meta; this.meta = meta;
this.rows = rows; this.rows = rows;
this.sumRow = sumRow; this.sumRow = sumRow;

View File

@ -10,6 +10,7 @@ import java.util.Comparator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
@ -27,14 +28,16 @@ import pro.taskana.monitor.api.reports.row.SingleRow;
import pro.taskana.rest.MonitorController; import pro.taskana.rest.MonitorController;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
/** Transforms any {@link Report} into its {@link ReportResource}. */ /** Transforms any {@link Report} into its {@link ReportRepresentationModel}. */
@Component @Component
public class ReportResourceAssembler { public class ReportRepresentationModelAssembler {
public ReportResource toModel( @NonNull
TaskStatusReport report, List<String> domains, List<TaskState> states) public ReportRepresentationModel toModel(
@NonNull TaskStatusReport report, @NonNull List<String> domains,
@NonNull List<TaskState> states)
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
ReportResource resource = toReportResource(report); ReportRepresentationModel resource = toReportResource(report);
resource.add( resource.add(
linkTo(methodOn(MonitorController.class).getTasksStatusReport(domains, states)) linkTo(methodOn(MonitorController.class).getTasksStatusReport(domains, states))
.withSelfRel() .withSelfRel()
@ -42,9 +45,10 @@ public class ReportResourceAssembler {
return resource; return resource;
} }
public ReportResource toModel(ClassificationReport report) @NonNull
public ReportRepresentationModel toModel(@NonNull ClassificationReport report)
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
ReportResource resource = toReportResource(report); ReportRepresentationModel resource = toReportResource(report);
resource.add( resource.add(
linkTo(methodOn(MonitorController.class).getTasksClassificationReport()) linkTo(methodOn(MonitorController.class).getTasksClassificationReport())
.withSelfRel() .withSelfRel()
@ -52,9 +56,11 @@ public class ReportResourceAssembler {
return resource; return resource;
} }
public ReportResource toModel(WorkbasketReport report, List<TaskState> states) @NonNull
public ReportRepresentationModel toModel(@NonNull WorkbasketReport report,
@NonNull List<TaskState> states)
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
ReportResource resource = toReportResource(report); ReportRepresentationModel resource = toReportResource(report);
resource.add( resource.add(
linkTo(methodOn(MonitorController.class).getTasksWorkbasketReport(states)) linkTo(methodOn(MonitorController.class).getTasksWorkbasketReport(states))
.withSelfRel() .withSelfRel()
@ -62,41 +68,44 @@ public class ReportResourceAssembler {
return resource; return resource;
} }
public ReportResource toModel(WorkbasketReport report, int daysInPast, List<TaskState> states) @NonNull
public ReportRepresentationModel toModel(
@NonNull WorkbasketReport report, int daysInPast, @NonNull List<TaskState> states)
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
ReportResource resource = toReportResource(report); ReportRepresentationModel resource = toReportResource(report);
resource.add( resource.add(
linkTo( linkTo(
methodOn(MonitorController.class) methodOn(MonitorController.class)
.getTasksWorkbasketPlannedDateReport(daysInPast, states)) .getTasksWorkbasketPlannedDateReport(daysInPast, states))
.withSelfRel() .withSelfRel()
.expand()); .expand());
return resource; return resource;
} }
public ReportResource toModel(TimestampReport report) @NonNull
public ReportRepresentationModel toModel(@NonNull TimestampReport report)
throws NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
ReportResource resource = toReportResource(report); ReportRepresentationModel resource = toReportResource(report);
resource.add( resource.add(
linkTo(methodOn(MonitorController.class).getDailyEntryExitReport()).withSelfRel().expand()); linkTo(methodOn(MonitorController.class).getDailyEntryExitReport()).withSelfRel().expand());
return resource; return resource;
} }
<I extends QueryItem, H extends ColumnHeader<? super I>> ReportResource toReportResource( <I extends QueryItem, H extends ColumnHeader<? super I>>
Report<I, H> report) { ReportRepresentationModel toReportResource(Report<I, H> report) {
return toReportResource(report, Instant.now()); return toReportResource(report, Instant.now());
} }
<I extends QueryItem, H extends ColumnHeader<? super I>> ReportResource toReportResource( <I extends QueryItem, H extends ColumnHeader<? super I>>
Report<I, H> report, Instant time) { ReportRepresentationModel toReportResource(Report<I, H> report, Instant time) {
String[] header = String[] header =
report.getColumnHeaders().stream().map(H::getDisplayName).toArray(String[]::new); report.getColumnHeaders().stream().map(H::getDisplayName).toArray(String[]::new);
ReportResource.MetaInformation meta = ReportRepresentationModel.MetaInformation meta =
new ReportResource.MetaInformation( new ReportRepresentationModel.MetaInformation(
report.getClass().getSimpleName(), time.toString(), header, report.getRowDesc()); report.getClass().getSimpleName(), time.toString(), header, report.getRowDesc());
// iterate over each Row and transform it to a RowResource while keeping the domain key. // iterate over each Row and transform it to a RowResource while keeping the domain key.
List<ReportResource.RowResource> rows = List<ReportRepresentationModel.RowResource> rows =
report.getRows().entrySet().stream() report.getRows().entrySet().stream()
.sorted(Comparator.comparing(e -> e.getKey().toLowerCase())) .sorted(Comparator.comparing(e -> e.getKey().toLowerCase()))
.map( .map(
@ -106,14 +115,14 @@ public class ReportResourceAssembler {
.flatMap(Collection::stream) .flatMap(Collection::stream)
.collect(Collectors.toList()); .collect(Collectors.toList());
List<ReportResource.RowResource> sumRow = List<ReportRepresentationModel.RowResource> sumRow =
transformRow( transformRow(
report.getSumRow(), meta.getTotalDesc(), new String[report.getRowDesc().length], 0); report.getSumRow(), meta.getTotalDesc(), new String[report.getRowDesc().length], 0);
return new ReportResource(meta, rows, sumRow); return new ReportRepresentationModel(meta, rows, sumRow);
} }
private <I extends QueryItem> List<ReportResource.RowResource> transformRow( private <I extends QueryItem> List<ReportRepresentationModel.RowResource> transformRow(
Row<I> row, String currentDesc, String[] desc, int depth) { Row<I> row, String currentDesc, String[] desc, int depth) {
// This is a very dirty solution.. Personally I'd prefer to use a visitor-like pattern here. // This is a very dirty solution.. Personally I'd prefer to use a visitor-like pattern here.
// The issue with that: Addition of the visitor code within taskana-core - and having clean code // The issue with that: Addition of the visitor code within taskana-core - and having clean code
@ -126,20 +135,20 @@ public class ReportResourceAssembler {
return transformFoldableRow((FoldableRow<I>) row, currentDesc, desc, depth); return transformFoldableRow((FoldableRow<I>) row, currentDesc, desc, depth);
} }
private <I extends QueryItem> ReportResource.RowResource transformSingleRow( private <I extends QueryItem> ReportRepresentationModel.RowResource transformSingleRow(
SingleRow<I> row, String currentDesc, String[] previousRowDesc, int depth) { SingleRow<I> row, String currentDesc, String[] previousRowDesc, int depth) {
String[] rowDesc = new String[previousRowDesc.length]; String[] rowDesc = new String[previousRowDesc.length];
System.arraycopy(previousRowDesc, 0, rowDesc, 0, depth); System.arraycopy(previousRowDesc, 0, rowDesc, 0, depth);
rowDesc[depth] = currentDesc; rowDesc[depth] = currentDesc;
return new ReportResource.RowResource( return new ReportRepresentationModel.RowResource(
row.getCells(), row.getTotalValue(), depth, rowDesc, depth == 0); row.getCells(), row.getTotalValue(), depth, rowDesc, depth == 0);
} }
private <I extends QueryItem> List<ReportResource.RowResource> transformFoldableRow( private <I extends QueryItem> List<ReportRepresentationModel.RowResource> transformFoldableRow(
FoldableRow<I> row, String currentDesc, String[] previousRowDesc, int depth) { FoldableRow<I> row, String currentDesc, String[] previousRowDesc, int depth) {
ReportResource.RowResource baseRow = ReportRepresentationModel.RowResource baseRow =
transformSingleRow(row, currentDesc, previousRowDesc, depth); transformSingleRow(row, currentDesc, previousRowDesc, depth);
List<ReportResource.RowResource> rowList = new LinkedList<>(); List<ReportRepresentationModel.RowResource> rowList = new LinkedList<>();
rowList.add(baseRow); rowList.add(baseRow);
row.getFoldableRowKeySet().stream() row.getFoldableRowKeySet().stream()
.sorted(String.CASE_INSENSITIVE_ORDER) .sorted(String.CASE_INSENSITIVE_ORDER)

View File

@ -1,24 +0,0 @@
package pro.taskana.rest.resource;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import org.springframework.hateoas.RepresentationModel;
/** EntityModel class for {@link TaskCommentResource} with Pagination. */
public class TaskCommentListResource extends RepresentationModel<TaskCommentListResource> {
private List<TaskCommentResource> content;
public TaskCommentListResource() {
super();
}
public TaskCommentListResource(List<TaskCommentResource> taskCommentResources) {
this.content = taskCommentResources;
}
@JsonProperty("task comments")
public List<TaskCommentResource> getContent() {
return content;
}
}

View File

@ -5,7 +5,8 @@ import org.springframework.hateoas.RepresentationModel;
import pro.taskana.task.api.models.TaskComment; import pro.taskana.task.api.models.TaskComment;
/** EntityModel class for {@link TaskComment}. */ /** EntityModel class for {@link TaskComment}. */
public class TaskCommentResource extends RepresentationModel<TaskCommentResource> { public class TaskCommentRepresentationModel
extends RepresentationModel<TaskCommentRepresentationModel> {
private String taskCommentId; private String taskCommentId;
private String taskId; private String taskId;
@ -14,9 +15,9 @@ public class TaskCommentResource extends RepresentationModel<TaskCommentResource
private String created; private String created;
private String modified; private String modified;
public TaskCommentResource() {} public TaskCommentRepresentationModel() {}
public TaskCommentResource(TaskComment taskComment) { public TaskCommentRepresentationModel(TaskComment taskComment) {
this.taskCommentId = taskComment.getId(); this.taskCommentId = taskComment.getId();
this.taskId = taskComment.getTaskId(); this.taskId = taskComment.getTaskId();
this.textField = taskComment.getTextField(); this.textField = taskComment.getTextField();

View File

@ -0,0 +1,81 @@
package pro.taskana.rest.resource;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import static pro.taskana.rest.resource.TaskanaPagedModelKeys.TASK_COMMENTS;
import java.time.Instant;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.server.RepresentationModelAssembler;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.rest.Mapping;
import pro.taskana.rest.TaskCommentController;
import pro.taskana.rest.resource.links.PageLinks;
import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.models.TaskComment;
import pro.taskana.task.internal.models.TaskCommentImpl;
/** EntityModel assembler for {@link TaskCommentRepresentationModel}. */
@Component
public class TaskCommentRepresentationModelAssembler
implements RepresentationModelAssembler<TaskComment, TaskCommentRepresentationModel> {
private final TaskService taskService;
@Autowired
public TaskCommentRepresentationModelAssembler(TaskService taskService) {
this.taskService = taskService;
}
@NonNull
@Override
public TaskCommentRepresentationModel toModel(@NonNull TaskComment taskComment) {
TaskCommentRepresentationModel taskCommentRepresentationModel =
new TaskCommentRepresentationModel(taskComment);
try {
taskCommentRepresentationModel.add(
linkTo(methodOn(TaskCommentController.class).getTaskComment(taskComment.getId()))
.withSelfRel());
} catch (Exception e) {
throw new SystemException("caught unexpected Exception.", e.getCause());
}
return taskCommentRepresentationModel;
}
public TaskComment toEntityModel(TaskCommentRepresentationModel taskCommentRepresentationModel) {
TaskCommentImpl taskComment =
(TaskCommentImpl) taskService.newTaskComment(taskCommentRepresentationModel.getTaskId());
taskComment.setId(taskCommentRepresentationModel.getTaskCommentId());
BeanUtils.copyProperties(taskCommentRepresentationModel, taskComment);
if (taskCommentRepresentationModel.getCreated() != null) {
taskComment.setCreated(Instant.parse(taskCommentRepresentationModel.getCreated()));
}
if (taskCommentRepresentationModel.getModified() != null) {
taskComment.setModified(Instant.parse(taskCommentRepresentationModel.getModified()));
}
return taskComment;
}
@PageLinks(Mapping.URL_TASK_COMMENTS)
public TaskanaPagedModel<TaskCommentRepresentationModel> toPageModel(
List<TaskComment> taskComments, PageMetadata pageMetadata) {
return taskComments.stream()
.map(this::toModel)
.collect(
Collectors.collectingAndThen(
Collectors.toList(),
list -> new TaskanaPagedModel<>(TASK_COMMENTS, list, pageMetadata)));
}
}

View File

@ -1,82 +0,0 @@
package pro.taskana.rest.resource;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.stereotype.Component;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.rest.Mapping;
import pro.taskana.rest.TaskCommentController;
import pro.taskana.rest.resource.links.PageLinks;
import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.exceptions.TaskCommentNotFoundException;
import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.TaskComment;
import pro.taskana.task.internal.models.TaskCommentImpl;
/** EntityModel assembler for {@link TaskCommentResource}. */
@Component
public class TaskCommentResourceAssembler
extends RepresentationModelAssemblerSupport<TaskComment, TaskCommentResource> {
private final TaskService taskService;
@Autowired
public TaskCommentResourceAssembler(TaskService taskService) {
super(TaskCommentController.class, TaskCommentResource.class);
this.taskService = taskService;
}
@PageLinks(Mapping.URL_TASK_COMMENTS)
public TaskCommentListResource toListResource(List<TaskComment> taskComments) {
Collection<TaskCommentResource> col = toCollectionModel(taskComments).getContent();
List<TaskCommentResource> resourceList = new ArrayList<>(col);
return new TaskCommentListResource(resourceList);
}
@Override
public TaskCommentResource toModel(TaskComment taskComment) {
TaskCommentResource taskCommentResource = new TaskCommentResource(taskComment);
try {
taskCommentResource.add(
linkTo(methodOn(TaskCommentController.class).getTaskComment(taskComment.getId()))
.withSelfRel());
} catch (TaskCommentNotFoundException
| TaskNotFoundException
| NotAuthorizedException
| InvalidArgumentException e) {
throw new SystemException("caught unexpected Exception.", e.getCause());
}
return taskCommentResource;
}
public TaskComment toModel(TaskCommentResource taskCommentResource) {
TaskCommentImpl taskComment =
(TaskCommentImpl) taskService.newTaskComment(taskCommentResource.getTaskId());
taskComment.setId(taskCommentResource.getTaskCommentId());
BeanUtils.copyProperties(taskCommentResource, taskComment);
if (taskCommentResource.getCreated() != null) {
taskComment.setCreated(Instant.parse(taskCommentResource.getCreated()));
}
if (taskCommentResource.getModified() != null) {
taskComment.setModified(Instant.parse(taskCommentResource.getModified()));
}
return taskComment;
}
}

View File

@ -0,0 +1,133 @@
package pro.taskana.rest.resource;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.task.api.models.Task;
/**
* EntityModel class for {@link Task}.
*/
@JsonIgnoreProperties("attachmentSummaries")
public class TaskRepresentationModel extends TaskSummaryRepresentationModel {
// All objects have to be serializable
private List<CustomAttribute> customAttributes = Collections.emptyList();
private List<CustomAttribute> callbackInfo = Collections.emptyList();
private List<AttachmentRepresentationModel> attachments = new ArrayList<>();
public TaskRepresentationModel() {
}
public TaskRepresentationModel(Task task) throws InvalidArgumentException {
super(task);
customAttributes =
task.getCustomAttributes().entrySet().stream()
.map(e -> new TaskRepresentationModel.CustomAttribute(e.getKey(), e.getValue()))
.collect(Collectors.toList());
callbackInfo =
task.getCallbackInfo().entrySet().stream()
.map(e -> new TaskRepresentationModel.CustomAttribute(e.getKey(), e.getValue()))
.collect(Collectors.toList());
attachments =
task.getAttachments().stream()
.map(AttachmentRepresentationModel::new)
.collect(Collectors.toList());
}
public List<CustomAttribute> getCustomAttributes() {
return customAttributes;
}
public void setCustomAttributes(List<CustomAttribute> customAttributes) {
this.customAttributes = customAttributes;
}
public List<CustomAttribute> getCallbackInfo() {
return callbackInfo;
}
public void setCallbackInfo(List<CustomAttribute> callbackInfo) {
this.callbackInfo = callbackInfo;
}
public List<AttachmentRepresentationModel> getAttachments() {
return attachments;
}
public void setAttachments(List<AttachmentRepresentationModel> attachments) {
this.attachments = attachments;
}
@Override
public String toString() {
return "TaskResource ["
+ "taskId= "
+ this.taskId
+ "externalId= "
+ this.externalId
+ "created= "
+ this.created
+ "modified= "
+ this.modified
+ "claimed= "
+ this.claimed
+ "completed= "
+ this.completed
+ "planned= "
+ this.planned
+ "due= "
+ this.due
+ "name= "
+ this.name
+ "creator= "
+ this.creator
+ "description= "
+ this.description
+ "priority= "
+ this.priority
+ "owner= "
+ this.owner
+ "]";
}
/**
* A CustomAttribute is a user customized attribute which is saved as a Map and can be retreived
* from either {@link Task#getCustomAttributes()} or {@link Task#getCallbackInfo()}.
*/
public static class CustomAttribute {
private final String key;
private final String value;
@SuppressWarnings("unused")
public CustomAttribute() {
this(null, null);
// necessary for jackson.
}
public CustomAttribute(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return "CustomAttribute [" + "key= " + this.key + "value= " + this.value + "]";
}
}
}

View File

@ -9,47 +9,55 @@ import java.util.stream.Collectors;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.rest.TaskController; import pro.taskana.rest.TaskController;
import pro.taskana.rest.resource.TaskRepresentationModel.CustomAttribute;
import pro.taskana.task.api.TaskService; import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.exceptions.TaskNotFoundException; import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.Task; import pro.taskana.task.api.models.Task;
import pro.taskana.task.internal.models.TaskImpl; import pro.taskana.task.internal.models.TaskImpl;
/** EntityModel assembler for {@link TaskResource}. */ /**
* EntityModel assembler for {@link TaskRepresentationModel}.
*/
@Component @Component
public class TaskResourceAssembler extends RepresentationModelAssemblerSupport<Task, TaskResource> { public class TaskRepresentationModelAssembler
extends RepresentationModelAssemblerSupport<Task, TaskRepresentationModel> {
private final TaskService taskService; private final TaskService taskService;
private final ClassificationSummaryResourceAssembler classificationAssembler; private final ClassificationSummaryRepresentationModelAssembler classificationAssembler;
private final WorkbasketSummaryResourceAssembler workbasketAssembler; private final WorkbasketSummaryRepresentationModelAssembler
workbasketSummaryRepresentationModelAssembler;
private final AttachmentResourceAssembler attachmentAssembler; private final AttachmentRepresentationModelAssembler attachmentAssembler;
@Autowired @Autowired
public TaskResourceAssembler( public TaskRepresentationModelAssembler(
TaskService taskService, TaskService taskService,
ClassificationSummaryResourceAssembler classificationAssembler, ClassificationSummaryRepresentationModelAssembler classificationAssembler,
WorkbasketSummaryResourceAssembler workbasketAssembler, WorkbasketSummaryRepresentationModelAssembler workbasketSummaryRepresentationModelAssembler,
AttachmentResourceAssembler attachmentAssembler) { AttachmentRepresentationModelAssembler attachmentAssembler) {
super(TaskController.class, TaskResource.class); super(TaskController.class, TaskRepresentationModel.class);
this.taskService = taskService; this.taskService = taskService;
this.classificationAssembler = classificationAssembler; this.classificationAssembler = classificationAssembler;
this.workbasketAssembler = workbasketAssembler; this.workbasketSummaryRepresentationModelAssembler
= workbasketSummaryRepresentationModelAssembler;
this.attachmentAssembler = attachmentAssembler; this.attachmentAssembler = attachmentAssembler;
} }
@NonNull
@Override @Override
public TaskResource toModel(Task task) { public TaskRepresentationModel toModel(@NonNull Task task) {
TaskResource resource; TaskRepresentationModel resource;
try { try {
resource = new TaskResource(task); resource = new TaskRepresentationModel(task);
resource.add(linkTo(methodOn(TaskController.class).getTask(task.getId())).withSelfRel()); resource.add(linkTo(methodOn(TaskController.class).getTask(task.getId())).withSelfRel());
} catch (InvalidArgumentException | TaskNotFoundException | NotAuthorizedException e) { } catch (InvalidArgumentException | TaskNotFoundException | NotAuthorizedException e) {
throw new SystemException("caught unexpected Exception.", e.getCause()); throw new SystemException("caught unexpected Exception.", e.getCause());
@ -57,10 +65,12 @@ public class TaskResourceAssembler extends RepresentationModelAssemblerSupport<T
return resource; return resource;
} }
public Task toModel(TaskResource resource) throws InvalidArgumentException { public Task toEntityModel(TaskRepresentationModel resource) throws InvalidArgumentException {
validateTaskResource(resource); validateTaskResource(resource);
TaskImpl task = TaskImpl task =
(TaskImpl) taskService.newTask(resource.getWorkbasketSummaryResource().getWorkbasketId()); (TaskImpl)
taskService.newTask(
resource.getWorkbasketSummary().getWorkbasketId());
task.setId(resource.getTaskId()); task.setId(resource.getTaskId());
task.setExternalId(resource.getExternalId()); task.setExternalId(resource.getExternalId());
BeanUtils.copyProperties(resource, task); BeanUtils.copyProperties(resource, task);
@ -83,35 +93,35 @@ public class TaskResourceAssembler extends RepresentationModelAssemblerSupport<T
task.setPlanned(Instant.parse(resource.getPlanned())); task.setPlanned(Instant.parse(resource.getPlanned()));
} }
task.setClassificationSummary( task.setClassificationSummary(
classificationAssembler.toModel(resource.getClassificationSummaryResource())); classificationAssembler.toEntityModel(
task.setWorkbasketSummary(workbasketAssembler.toModel(resource.getWorkbasketSummaryResource())); resource.getClassificationSummary()));
task.setAttachments(attachmentAssembler.toModel(resource.getAttachments())); task.setWorkbasketSummary(
workbasketSummaryRepresentationModelAssembler
.toEntityModel(resource.getWorkbasketSummary()));
task.setAttachments(attachmentAssembler.toAttachmentList(resource.getAttachments()));
task.setCustomAttributes( task.setCustomAttributes(
resource.getCustomAttributes().stream() resource.getCustomAttributes().stream()
.filter(e -> Objects.nonNull(e.getKey()) && !e.getKey().isEmpty()) .filter(e -> Objects.nonNull(e.getKey()) && !e.getKey().isEmpty())
.collect( .collect(Collectors.toMap(CustomAttribute::getKey, CustomAttribute::getValue)));
Collectors.toMap(
TaskResource.CustomAttribute::getKey, TaskResource.CustomAttribute::getValue)));
task.setCallbackInfo( task.setCallbackInfo(
resource.getCallbackInfo().stream() resource.getCallbackInfo().stream()
.filter(e -> Objects.nonNull(e.getKey()) && !e.getKey().isEmpty()) .filter(e -> Objects.nonNull(e.getKey()) && !e.getKey().isEmpty())
.collect( .collect(Collectors.toMap(CustomAttribute::getKey, CustomAttribute::getValue)));
Collectors.toMap(
TaskResource.CustomAttribute::getKey, TaskResource.CustomAttribute::getValue)));
return task; return task;
} }
private void validateTaskResource(TaskResource resource) throws InvalidArgumentException { private void validateTaskResource(TaskRepresentationModel resource)
if (resource.getWorkbasketSummaryResource() == null throws InvalidArgumentException {
|| resource.getWorkbasketSummaryResource().getWorkbasketId() == null if (resource.getWorkbasketSummary() == null
|| resource.getWorkbasketSummaryResource().getWorkbasketId().isEmpty()) { || resource.getWorkbasketSummary().getWorkbasketId() == null
|| resource.getWorkbasketSummary().getWorkbasketId().isEmpty()) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
"TaskResource must have a workbasket summary with a valid workbasketId."); "TaskResource must have a workbasket summary with a valid workbasketId.");
} }
if (resource.getClassificationSummaryResource() == null if (resource.getClassificationSummary() == null
|| resource.getClassificationSummaryResource().getKey() == null || resource.getClassificationSummary().getKey() == null
|| resource.getClassificationSummaryResource().getKey().isEmpty()) { || resource.getClassificationSummary().getKey().isEmpty()) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
"TaskResource must have a classification summary with a valid classification key."); "TaskResource must have a classification summary with a valid classification key.");
} }

View File

@ -1,510 +0,0 @@
package pro.taskana.rest.resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.hateoas.RepresentationModel;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.models.ObjectReference;
import pro.taskana.task.api.models.Task;
/** EntityModel class for {@link Task}. */
public class TaskResource extends RepresentationModel<TaskResource> {
private String taskId;
private String externalId;
private String created; // ISO-8601
private String claimed; // ISO-8601
private String completed; // ISO-8601
private String modified; // ISO-8601
private String planned; // ISO-8601
private String due; // ISO-8601
private String name;
private String creator;
private String description;
private String note;
private int priority;
private TaskState state;
private ClassificationSummaryResource classificationSummaryResource;
private WorkbasketSummaryResource workbasketSummaryResource;
private String businessProcessId;
private String parentBusinessProcessId;
private String owner;
private ObjectReference primaryObjRef;
private boolean isRead;
private boolean isTransferred;
// All objects have to be serializable
private List<CustomAttribute> customAttributes = Collections.emptyList();
private List<CustomAttribute> callbackInfo = Collections.emptyList();
private List<AttachmentResource> attachments = new ArrayList<>();
private String custom1;
private String custom2;
private String custom3;
private String custom4;
private String custom5;
private String custom6;
private String custom7;
private String custom8;
private String custom9;
private String custom10;
private String custom11;
private String custom12;
private String custom13;
private String custom14;
private String custom15;
private String custom16;
public TaskResource() {}
public TaskResource(Task task) throws InvalidArgumentException {
taskId = task.getId();
externalId = task.getExternalId();
created = task.getCreated() != null ? task.getCreated().toString() : null;
claimed = task.getClaimed() != null ? task.getClaimed().toString() : null;
completed = task.getCompleted() != null ? task.getCompleted().toString() : null;
modified = task.getModified() != null ? task.getModified().toString() : null;
planned = task.getPlanned() != null ? task.getPlanned().toString() : null;
due = task.getDue() != null ? task.getDue().toString() : null;
name = task.getName();
creator = task.getCreator();
description = task.getDescription();
note = task.getNote();
priority = task.getPriority();
state = task.getState();
classificationSummaryResource =
new ClassificationSummaryResource(task.getClassificationSummary());
workbasketSummaryResource = new WorkbasketSummaryResource(task.getWorkbasketSummary());
businessProcessId = task.getBusinessProcessId();
parentBusinessProcessId = task.getParentBusinessProcessId();
owner = task.getOwner();
primaryObjRef = task.getPrimaryObjRef();
isRead = task.isRead();
isTransferred = task.isTransferred();
customAttributes =
task.getCustomAttributes().entrySet().stream()
.map(e -> new TaskResource.CustomAttribute(e.getKey(), e.getValue()))
.collect(Collectors.toList());
callbackInfo =
task.getCallbackInfo().entrySet().stream()
.map(e -> new TaskResource.CustomAttribute(e.getKey(), e.getValue()))
.collect(Collectors.toList());
attachments =
task.getAttachments().stream().map(AttachmentResource::new).collect(Collectors.toList());
custom1 = task.getCustomAttribute("1");
custom2 = task.getCustomAttribute("2");
custom3 = task.getCustomAttribute("3");
custom4 = task.getCustomAttribute("4");
custom5 = task.getCustomAttribute("5");
custom6 = task.getCustomAttribute("6");
custom7 = task.getCustomAttribute("7");
custom8 = task.getCustomAttribute("8");
custom9 = task.getCustomAttribute("9");
custom10 = task.getCustomAttribute("10");
custom11 = task.getCustomAttribute("11");
custom12 = task.getCustomAttribute("12");
custom13 = task.getCustomAttribute("13");
custom14 = task.getCustomAttribute("14");
custom15 = task.getCustomAttribute("15");
custom16 = task.getCustomAttribute("16");
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getExternalId() {
return externalId;
}
public void setExternalId(String externalId) {
this.externalId = externalId;
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
public String getClaimed() {
return claimed;
}
public void setClaimed(String claimed) {
this.claimed = claimed;
}
public String getCompleted() {
return completed;
}
public void setCompleted(String completed) {
this.completed = completed;
}
public String getModified() {
return modified;
}
public void setModified(String modified) {
this.modified = modified;
}
public String getPlanned() {
return planned;
}
public void setPlanned(String planned) {
this.planned = planned;
}
public String getDue() {
return due;
}
public void setDue(String due) {
this.due = due;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCreator() {
return creator;
}
public void setCreator(String creator) {
this.creator = creator;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
public TaskState getState() {
return state;
}
public void setState(TaskState state) {
this.state = state;
}
public ClassificationSummaryResource getClassificationSummaryResource() {
return classificationSummaryResource;
}
public void setClassificationSummaryResource(
ClassificationSummaryResource classificationSummaryResource) {
this.classificationSummaryResource = classificationSummaryResource;
}
public WorkbasketSummaryResource getWorkbasketSummaryResource() {
return workbasketSummaryResource;
}
public void setWorkbasketSummaryResource(WorkbasketSummaryResource workbasketSummaryResource) {
this.workbasketSummaryResource = workbasketSummaryResource;
}
public String getBusinessProcessId() {
return businessProcessId;
}
public void setBusinessProcessId(String businessProcessId) {
this.businessProcessId = businessProcessId;
}
public String getParentBusinessProcessId() {
return parentBusinessProcessId;
}
public void setParentBusinessProcessId(String parentBusinessProcessId) {
this.parentBusinessProcessId = parentBusinessProcessId;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public ObjectReference getPrimaryObjRef() {
return primaryObjRef;
}
public void setPrimaryObjRef(ObjectReference primaryObjRef) {
this.primaryObjRef = primaryObjRef;
}
public boolean isRead() {
return isRead;
}
public void setRead(boolean isRead) {
this.isRead = isRead;
}
public boolean isTransferred() {
return isTransferred;
}
public void setTransferred(boolean isTransferred) {
this.isTransferred = isTransferred;
}
public List<CustomAttribute> getCustomAttributes() {
return customAttributes;
}
public void setCustomAttributes(List<CustomAttribute> customAttributes) {
this.customAttributes = customAttributes;
}
public List<CustomAttribute> getCallbackInfo() {
return callbackInfo;
}
public void setCallbackInfo(List<CustomAttribute> callbackInfo) {
this.callbackInfo = callbackInfo;
}
public List<AttachmentResource> getAttachments() {
return attachments;
}
public void setAttachments(List<AttachmentResource> attachments) {
this.attachments = attachments;
}
public String getCustom1() {
return custom1;
}
public void setCustom1(String custom1) {
this.custom1 = custom1;
}
public String getCustom2() {
return custom2;
}
public void setCustom2(String custom2) {
this.custom2 = custom2;
}
public String getCustom3() {
return custom3;
}
public void setCustom3(String custom3) {
this.custom3 = custom3;
}
public String getCustom4() {
return custom4;
}
public void setCustom4(String custom4) {
this.custom4 = custom4;
}
public String getCustom5() {
return custom5;
}
public void setCustom5(String custom5) {
this.custom5 = custom5;
}
public String getCustom6() {
return custom6;
}
public void setCustom6(String custom6) {
this.custom6 = custom6;
}
public String getCustom7() {
return custom7;
}
public void setCustom7(String custom7) {
this.custom7 = custom7;
}
public String getCustom8() {
return custom8;
}
public void setCustom8(String custom8) {
this.custom8 = custom8;
}
public String getCustom9() {
return custom9;
}
public void setCustom9(String custom9) {
this.custom9 = custom9;
}
public String getCustom10() {
return custom10;
}
public void setCustom10(String custom10) {
this.custom10 = custom10;
}
public String getCustom11() {
return custom11;
}
public void setCustom11(String custom11) {
this.custom11 = custom11;
}
public String getCustom12() {
return custom12;
}
public void setCustom12(String custom12) {
this.custom12 = custom12;
}
public String getCustom13() {
return custom13;
}
public void setCustom13(String custom13) {
this.custom13 = custom13;
}
public String getCustom14() {
return custom14;
}
public void setCustom14(String custom14) {
this.custom14 = custom14;
}
public String getCustom15() {
return custom15;
}
public void setCustom15(String custom15) {
this.custom15 = custom15;
}
public String getCustom16() {
return custom16;
}
public void setCustom16(String custom16) {
this.custom16 = custom16;
}
@Override
public String toString() {
return "TaskResource ["
+ "taskId= "
+ this.taskId
+ "externalId= "
+ this.externalId
+ "created= "
+ this.created
+ "modified= "
+ this.modified
+ "claimed= "
+ this.claimed
+ "completed= "
+ this.completed
+ "planned= "
+ this.planned
+ "due= "
+ this.due
+ "name= "
+ this.name
+ "creator= "
+ this.creator
+ "description= "
+ this.description
+ "priority= "
+ this.priority
+ "owner= "
+ this.owner
+ "]";
}
/**
* A CustomAttribute is a user customized attribute which is saved as a Map and can be retreived
* from either {@link Task#getCustomAttributes()} or {@link Task#getCallbackInfo()}.
*/
public static class CustomAttribute {
private final String key;
private final String value;
@SuppressWarnings("unused")
public CustomAttribute() {
this(null, null);
// necessary for jackson.
}
public CustomAttribute(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return "CustomAttribute [" + "key= " + this.key + "value= " + this.value + "]";
}
}
}

View File

@ -1,29 +0,0 @@
package pro.taskana.rest.resource;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collection;
import org.springframework.hateoas.Link;
/** EntityModel class for {@link TaskSummaryResource} with Pagination. */
public class TaskSummaryListResource extends PagedResources<TaskSummaryResource> {
public TaskSummaryListResource() {
super();
}
public TaskSummaryListResource(
Collection<TaskSummaryResource> content, PageMetadata metadata, Iterable<Link> links) {
super(content, metadata, links);
}
public TaskSummaryListResource(
Collection<TaskSummaryResource> content, PageMetadata metadata, Link... links) {
super(content, metadata, links);
}
@Override
@JsonProperty("tasks")
public Collection<TaskSummaryResource> getContent() {
return super.getContent();
}
}

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.RepresentationModel;
import org.springframework.hateoas.server.core.Relation;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
@ -12,53 +11,57 @@ import pro.taskana.task.api.models.ObjectReference;
import pro.taskana.task.api.models.TaskSummary; import pro.taskana.task.api.models.TaskSummary;
import pro.taskana.workbasket.api.models.WorkbasketSummary; import pro.taskana.workbasket.api.models.WorkbasketSummary;
/** EntityModel class for {@link WorkbasketSummary}. */ /**
@Relation(collectionRelation = "tasks") * EntityModel class for {@link WorkbasketSummary}.
public class TaskSummaryResource extends RepresentationModel<TaskSummaryResource> { */
public class TaskSummaryRepresentationModel
extends RepresentationModel<TaskSummaryRepresentationModel> {
private String taskId; protected String taskId;
private String externalId; protected String externalId;
private String created; // ISO-8601 protected String created; // ISO-8601
private String claimed; // ISO-8601 protected String claimed; // ISO-8601
private String completed; // ISO-8601 protected String completed; // ISO-8601
private String modified; // ISO-8601 protected String modified; // ISO-8601
private String planned; // ISO-8601 protected String planned; // ISO-8601
private String due; // ISO-8601 protected String due; // ISO-8601
private String name; protected String name;
private String creator; protected String creator;
private String note; protected String note;
private String description; protected String description;
private int priority; protected int priority;
private TaskState state; protected TaskState state;
private ClassificationSummaryResource classificationSummaryResource; protected ClassificationSummaryRepresentationModel classificationSummary;
private WorkbasketSummaryResource workbasketSummaryResource; protected WorkbasketSummaryRepresentationModel workbasketSummary;
private String businessProcessId; protected String businessProcessId;
private String parentBusinessProcessId; protected String parentBusinessProcessId;
private String owner; protected String owner;
private ObjectReference primaryObjRef; protected ObjectReference primaryObjRef;
private boolean isRead; protected boolean isRead;
private boolean isTransferred; protected boolean isTransferred;
private List<AttachmentSummaryResource> attachmentSummaryResources = new ArrayList<>(); protected String custom1;
private String custom1; protected String custom2;
private String custom2; protected String custom3;
private String custom3; protected String custom4;
private String custom4; protected String custom5;
private String custom5; protected String custom6;
private String custom6; protected String custom7;
private String custom7; protected String custom8;
private String custom8; protected String custom9;
private String custom9; protected String custom10;
private String custom10; protected String custom11;
private String custom11; protected String custom12;
private String custom12; protected String custom13;
private String custom13; protected String custom14;
private String custom14; protected String custom15;
private String custom15; protected String custom16;
private String custom16; private List<AttachmentSummaryRepresentationModel> attachmentSummaries =
new ArrayList<>();
TaskSummaryResource() {} TaskSummaryRepresentationModel() {
}
public TaskSummaryResource(TaskSummary taskSummary) throws InvalidArgumentException { public TaskSummaryRepresentationModel(TaskSummary taskSummary) throws InvalidArgumentException {
this.taskId = taskSummary.getId(); this.taskId = taskSummary.getId();
this.externalId = taskSummary.getExternalId(); this.externalId = taskSummary.getExternalId();
created = taskSummary.getCreated() != null ? taskSummary.getCreated().toString() : null; created = taskSummary.getCreated() != null ? taskSummary.getCreated().toString() : null;
@ -73,19 +76,19 @@ public class TaskSummaryResource extends RepresentationModel<TaskSummaryResource
this.description = taskSummary.getDescription(); this.description = taskSummary.getDescription();
this.priority = taskSummary.getPriority(); this.priority = taskSummary.getPriority();
this.state = taskSummary.getState(); this.state = taskSummary.getState();
this.classificationSummaryResource = this.classificationSummary =
new ClassificationSummaryResource(taskSummary.getClassificationSummary()); new ClassificationSummaryRepresentationModel(taskSummary.getClassificationSummary());
this.workbasketSummaryResource = this.workbasketSummary =
new WorkbasketSummaryResource(taskSummary.getWorkbasketSummary()); new WorkbasketSummaryRepresentationModel(taskSummary.getWorkbasketSummary());
this.businessProcessId = taskSummary.getBusinessProcessId(); this.businessProcessId = taskSummary.getBusinessProcessId();
this.parentBusinessProcessId = taskSummary.getParentBusinessProcessId(); this.parentBusinessProcessId = taskSummary.getParentBusinessProcessId();
this.owner = taskSummary.getOwner(); this.owner = taskSummary.getOwner();
this.primaryObjRef = taskSummary.getPrimaryObjRef(); this.primaryObjRef = taskSummary.getPrimaryObjRef();
this.isRead = taskSummary.isRead(); this.isRead = taskSummary.isRead();
this.isTransferred = taskSummary.isTransferred(); this.isTransferred = taskSummary.isTransferred();
this.attachmentSummaryResources = this.attachmentSummaries =
taskSummary.getAttachmentSummaries().stream() taskSummary.getAttachmentSummaries().stream()
.map(AttachmentSummaryResource::new) .map(AttachmentSummaryRepresentationModel::new)
.collect(Collectors.toList()); .collect(Collectors.toList());
this.custom1 = taskSummary.getCustomAttribute("1"); this.custom1 = taskSummary.getCustomAttribute("1");
this.custom2 = taskSummary.getCustomAttribute("2"); this.custom2 = taskSummary.getCustomAttribute("2");
@ -217,21 +220,22 @@ public class TaskSummaryResource extends RepresentationModel<TaskSummaryResource
this.state = state; this.state = state;
} }
public ClassificationSummaryResource getClassificationSummaryResource() { public ClassificationSummaryRepresentationModel getClassificationSummary() {
return classificationSummaryResource; return classificationSummary;
} }
public void setClassificationSummaryResource( public void setClassificationSummary(
ClassificationSummaryResource classificationSummaryResource) { ClassificationSummaryRepresentationModel classificationSummary) {
this.classificationSummaryResource = classificationSummaryResource; this.classificationSummary = classificationSummary;
} }
public WorkbasketSummaryResource getWorkbasketSummaryResource() { public WorkbasketSummaryRepresentationModel getWorkbasketSummary() {
return workbasketSummaryResource; return workbasketSummary;
} }
public void setWorkbasketSummaryResource(WorkbasketSummaryResource workbasketSummaryResource) { public void setWorkbasketSummary(
this.workbasketSummaryResource = workbasketSummaryResource; WorkbasketSummaryRepresentationModel workbasketSummary) {
this.workbasketSummary = workbasketSummary;
} }
public String getBusinessProcessId() { public String getBusinessProcessId() {
@ -282,12 +286,13 @@ public class TaskSummaryResource extends RepresentationModel<TaskSummaryResource
this.isTransferred = isTransferred; this.isTransferred = isTransferred;
} }
public List<AttachmentSummaryResource> getAttachmentSummaries() { public List<AttachmentSummaryRepresentationModel> getAttachmentSummaries() {
return attachmentSummaryResources; return attachmentSummaries;
} }
public void setAttachmentSummaries(List<AttachmentSummaryResource> attachmentSummaryResources) { public void setAttachmentSummaries(
this.attachmentSummaryResources = attachmentSummaryResources; List<AttachmentSummaryRepresentationModel> attachmentSummaries) {
this.attachmentSummaries = attachmentSummaries;
} }
public String getCustom1() { public String getCustom1() {

View File

@ -0,0 +1,44 @@
package pro.taskana.rest.resource;
import static pro.taskana.rest.resource.TaskanaPagedModelKeys.TASKS;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.server.RepresentationModelAssembler;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.rest.Mapping;
import pro.taskana.rest.resource.links.PageLinks;
import pro.taskana.task.api.models.TaskSummary;
/** EntityModel assembler for {@link TaskSummaryRepresentationModel}. */
@Component
public class TaskSummaryRepresentationModelAssembler
implements RepresentationModelAssembler<TaskSummary, TaskSummaryRepresentationModel> {
@NonNull
@Override
public TaskSummaryRepresentationModel toModel(@NonNull TaskSummary taskSummary) {
TaskSummaryRepresentationModel resource;
try {
resource = new TaskSummaryRepresentationModel(taskSummary);
return resource;
} catch (InvalidArgumentException e) {
throw new SystemException("caught unexpected Exception.", e.getCause());
}
}
@PageLinks(Mapping.URL_TASKS)
public TaskanaPagedModel<TaskSummaryRepresentationModel> toPageModel(
List<TaskSummary> taskSummaries, PageMetadata pageMetadata) {
return taskSummaries.stream()
.map(this::toModel)
.collect(
Collectors.collectingAndThen(
Collectors.toList(), list -> new TaskanaPagedModel<>(TASKS, list, pageMetadata)));
}
}

View File

@ -1,40 +0,0 @@
package pro.taskana.rest.resource;
import java.util.List;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.stereotype.Component;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.rest.Mapping;
import pro.taskana.rest.TaskController;
import pro.taskana.rest.resource.PagedResources.PageMetadata;
import pro.taskana.rest.resource.links.PageLinks;
import pro.taskana.task.api.models.TaskSummary;
/** EntityModel assembler for {@link TaskSummaryResource}. */
@Component
public class TaskSummaryResourceAssembler
extends RepresentationModelAssemblerSupport<TaskSummary, TaskSummaryResource> {
public TaskSummaryResourceAssembler() {
super(TaskController.class, TaskSummaryResource.class);
}
@Override
public TaskSummaryResource toModel(TaskSummary taskSummary) {
TaskSummaryResource resource;
try {
resource = new TaskSummaryResource(taskSummary);
return resource;
} catch (InvalidArgumentException e) {
throw new SystemException("caught unexpected Exception.", e.getCause());
}
}
@PageLinks(Mapping.URL_TASKS)
public TaskSummaryListResource toCollectionModel(
List<TaskSummary> taskSummaries, PageMetadata pageMetadata) {
return new TaskSummaryListResource(toCollectionModel(taskSummaries).getContent(), pageMetadata);
}
}

View File

@ -0,0 +1,76 @@
package pro.taskana.rest.resource;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.RepresentationModel;
/**
* Optional Paging model for RepresentationModels.
*
* @param <T> The class of the paginated content
*/
public class TaskanaPagedModel<T extends RepresentationModel<T>>
extends RepresentationModel<TaskanaPagedModel<T>> {
@JsonIgnore
private TaskanaPagedModelKeys key;
@JsonIgnore
private Collection<? extends T> content;
@JsonProperty(value = "page", access = Access.WRITE_ONLY)
private PageMetadata metadata;
@SuppressWarnings("unused") // needed for jackson
private TaskanaPagedModel() {
}
/**
* Creates a new {@link TaskanaPagedModel} from the given content.
*
* @param property property which will be used for serialization.
* @param content must not be {@literal null}.
* @param metadata the metadata. Can be null. If null, no metadata will be serialized.
*/
public TaskanaPagedModel(
TaskanaPagedModelKeys property, Collection<? extends T> content, PageMetadata metadata) {
this.content = content;
this.metadata = metadata;
this.key = property;
}
public Collection<T> getContent() {
return Collections.unmodifiableCollection(content);
}
public PageMetadata getMetadata() {
return metadata;
}
@JsonAnySetter
private void deserialize(String propertyName, Collection<T> content) {
TaskanaPagedModelKeys.getEnumFromPropertyName(propertyName)
.ifPresent(
pagedModelKey -> {
this.key = pagedModelKey;
this.content = content;
});
}
@JsonAnyGetter
private Map<String, Object> serialize() {
HashMap<String, Object> jsonMap = new HashMap<>();
if (metadata != null) {
jsonMap.put("page", metadata);
}
jsonMap.put(key.getPropertyName(), content);
return jsonMap;
}
}

View File

@ -0,0 +1,34 @@
package pro.taskana.rest.resource;
import java.util.Arrays;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
public enum TaskanaPagedModelKeys {
ACCESSITEMS("accessItems"),
CLASSIFICATIONS("classifications"),
DISTRIBUTION_TARGETS("distributionTargets"),
TASKS("tasks"),
TASK_COMMENTS("taskComments"),
WORKBASKETS("workbaskets");
private static final Map<String, TaskanaPagedModelKeys> PROPERTY_MAP =
Arrays.stream(TaskanaPagedModelKeys.values())
.collect(Collectors.toMap(TaskanaPagedModelKeys::getPropertyName, Function.identity()));
private final String propertyName;
TaskanaPagedModelKeys(String propertyName) {
this.propertyName = propertyName;
}
public String getPropertyName() {
return propertyName;
}
public static Optional<TaskanaPagedModelKeys> getEnumFromPropertyName(String propertyName) {
return Optional.ofNullable(PROPERTY_MAP.get(propertyName));
}
}

View File

@ -8,7 +8,8 @@ import pro.taskana.common.api.LoggerUtils;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
/** EntityModel class for user information. */ /** EntityModel class for user information. */
public class TaskanaUserInfoResource extends RepresentationModel<TaskanaUserInfoResource> { public class TaskanaUserInfoRepresentationModel
extends RepresentationModel<TaskanaUserInfoRepresentationModel> {
private String userId; private String userId;
private List<String> groupIds = new ArrayList<>(); private List<String> groupIds = new ArrayList<>();
@ -40,7 +41,7 @@ public class TaskanaUserInfoResource extends RepresentationModel<TaskanaUserInfo
@Override @Override
public String toString() { public String toString() {
return "TaskanaUserInfoResource [" return "TaskanaUserInfoRepresentationModel ["
+ "userId= " + "userId= "
+ this.userId + this.userId
+ "groupIds= " + "groupIds= "

View File

@ -3,7 +3,7 @@ package pro.taskana.rest.resource;
import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.RepresentationModel;
/** EntityModel class for version information. */ /** EntityModel class for version information. */
public class VersionResource extends RepresentationModel<VersionResource> { public class VersionRepresentationModel extends RepresentationModel<VersionRepresentationModel> {
private String version; private String version;

View File

@ -1,24 +0,0 @@
package pro.taskana.rest.resource;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collection;
import org.springframework.hateoas.Link;
/** EntityModel class for {@link WorkbasketAccessItemResource} with Pagination. */
public class WorkbasketAccessItemListResource extends PagedResources<WorkbasketAccessItemResource> {
public WorkbasketAccessItemListResource() {
super();
}
public WorkbasketAccessItemListResource(
Collection<WorkbasketAccessItemResource> content, PageMetadata metadata, Link... links) {
super(content, metadata, links);
}
@Override
@JsonProperty("accessItems")
public Collection<WorkbasketAccessItemResource> getContent() {
return super.getContent();
}
}

View File

@ -1,26 +1,20 @@
package pro.taskana.rest.resource; package pro.taskana.rest.resource;
import javax.validation.constraints.NotNull;
import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.RepresentationModel;
import org.springframework.hateoas.server.core.Relation;
import pro.taskana.workbasket.api.models.WorkbasketAccessItem; import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
/** EntityModel class for {@link WorkbasketAccessItem}. */ /**
@Relation(collectionRelation = "accessItems") * EntityModel class for {@link WorkbasketAccessItem}.
public class WorkbasketAccessItemResource */
extends RepresentationModel<WorkbasketAccessItemResource> { public class WorkbasketAccessItemRepresentationModel
extends RepresentationModel<WorkbasketAccessItemRepresentationModel> {
private String accessItemId; private String accessItemId;
private String workbasketId;
@NotNull private String workbasketId; private String workbasketKey;
private String accessId;
@NotNull private String workbasketKey;
@NotNull private String accessId;
private String accessName; private String accessName;
private boolean permRead; private boolean permRead;
private boolean permOpen; private boolean permOpen;
private boolean permAppend; private boolean permAppend;
@ -39,9 +33,9 @@ public class WorkbasketAccessItemResource
private boolean permCustom11; private boolean permCustom11;
private boolean permCustom12; private boolean permCustom12;
public WorkbasketAccessItemResource() {} public WorkbasketAccessItemRepresentationModel() {}
public WorkbasketAccessItemResource(WorkbasketAccessItem workbasketAccessItem) { public WorkbasketAccessItemRepresentationModel(WorkbasketAccessItem workbasketAccessItem) {
this.accessItemId = workbasketAccessItem.getId(); this.accessItemId = workbasketAccessItem.getId();
this.workbasketId = workbasketAccessItem.getWorkbasketId(); this.workbasketId = workbasketAccessItem.getWorkbasketId();
this.workbasketKey = workbasketAccessItem.getWorkbasketKey(); this.workbasketKey = workbasketAccessItem.getWorkbasketKey();

View File

@ -0,0 +1,85 @@
package pro.taskana.rest.resource;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import static pro.taskana.rest.resource.TaskanaPagedModelKeys.ACCESSITEMS;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.server.RepresentationModelAssembler;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.rest.Mapping;
import pro.taskana.rest.WorkbasketController;
import pro.taskana.rest.resource.links.PageLinks;
import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl;
/**
* Transforms {@link WorkbasketAccessItem} to its resource counterpart {@link
* WorkbasketAccessItemRepresentationModel} and vice versa.
*/
@Component
public class WorkbasketAccessItemRepresentationModelAssembler
implements RepresentationModelAssembler<
WorkbasketAccessItem, WorkbasketAccessItemRepresentationModel> {
private final WorkbasketService workbasketService;
@Autowired
public WorkbasketAccessItemRepresentationModelAssembler(
WorkbasketService workbasketService) {
this.workbasketService = workbasketService;
}
@NonNull
@Override
public WorkbasketAccessItemRepresentationModel toModel(@NonNull WorkbasketAccessItem wbAccItem) {
return new WorkbasketAccessItemRepresentationModel(wbAccItem);
}
public WorkbasketAccessItem toEntityModel(
WorkbasketAccessItemRepresentationModel wbAccItemResource) {
WorkbasketAccessItemImpl wbAccItemModel =
(WorkbasketAccessItemImpl)
workbasketService.newWorkbasketAccessItem(
wbAccItemResource.getWorkbasketId(), wbAccItemResource.getAccessId());
BeanUtils.copyProperties(wbAccItemResource, wbAccItemModel);
wbAccItemModel.setId(wbAccItemResource.getAccessItemId());
return wbAccItemModel;
}
public TaskanaPagedModel<WorkbasketAccessItemRepresentationModel> toPageModel(
String workbasketId,
List<WorkbasketAccessItem> workbasketAccessItems,
PageMetadata pageMetadata)
throws NotAuthorizedException, WorkbasketNotFoundException {
TaskanaPagedModel<WorkbasketAccessItemRepresentationModel> pageModel =
toPageModel(workbasketAccessItems, pageMetadata);
pageModel.add(
linkTo(methodOn(WorkbasketController.class).getWorkbasketAccessItems(workbasketId))
.withSelfRel());
pageModel.add(
linkTo(methodOn(WorkbasketController.class).getWorkbasket(workbasketId))
.withRel("workbasket"));
return pageModel;
}
@PageLinks(Mapping.URL_WORKBASKETACCESSITEMS)
public TaskanaPagedModel<WorkbasketAccessItemRepresentationModel> toPageModel(
List<WorkbasketAccessItem> workbasketAccessItems, PageMetadata pageMetadata) {
return workbasketAccessItems.stream()
.map(this::toModel)
.collect(
Collectors.collectingAndThen(
Collectors.toList(),
list -> new TaskanaPagedModel<>(ACCESSITEMS, list, pageMetadata)));
}
}

View File

@ -1,71 +0,0 @@
package pro.taskana.rest.resource;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.stereotype.Component;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.rest.Mapping;
import pro.taskana.rest.WorkbasketController;
import pro.taskana.rest.resource.PagedResources.PageMetadata;
import pro.taskana.rest.resource.links.PageLinks;
import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl;
/**
* Transforms {@link WorkbasketAccessItem} to its resource counterpart {@link
* WorkbasketAccessItemResource} and vice versa.
*/
@Component
public class WorkbasketAccessItemResourceAssembler
extends RepresentationModelAssemblerSupport<
WorkbasketAccessItem, WorkbasketAccessItemResource> {
@Autowired private WorkbasketService workbasketService;
public WorkbasketAccessItemResourceAssembler() {
super(WorkbasketController.class, WorkbasketAccessItemResource.class);
}
public WorkbasketAccessItemResource toModel(WorkbasketAccessItem wbAccItem) {
return new WorkbasketAccessItemResource(wbAccItem);
}
public WorkbasketAccessItem toModel(WorkbasketAccessItemResource wbAccItemResource) {
WorkbasketAccessItemImpl wbAccItemModel =
(WorkbasketAccessItemImpl)
workbasketService.newWorkbasketAccessItem(
wbAccItemResource.getWorkbasketId(), wbAccItemResource.getAccessId());
BeanUtils.copyProperties(wbAccItemResource, wbAccItemModel);
wbAccItemModel.setId(wbAccItemResource.getAccessItemId());
return wbAccItemModel;
}
@PageLinks(Mapping.URL_WORKBASKETACCESSITEMS)
public WorkbasketAccessItemListResource toCollectionModel(
List<WorkbasketAccessItem> entities, PageMetadata pageMetadata) {
return new WorkbasketAccessItemListResource(
toCollectionModel(entities).getContent(), pageMetadata);
}
public WorkbasketAccessItemListResource toCollectionModel(
String workbasketId, List<WorkbasketAccessItem> entities)
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketAccessItemListResource accessItemListResource =
new WorkbasketAccessItemListResource(super.toCollectionModel(entities).getContent(), null);
accessItemListResource.add(
linkTo(methodOn(WorkbasketController.class).getWorkbasketAccessItems(workbasketId))
.withSelfRel());
accessItemListResource.add(
linkTo(methodOn(WorkbasketController.class).getWorkbasket(workbasketId))
.withRel("workbasket"));
return accessItemListResource;
}
}

View File

@ -2,23 +2,25 @@ package pro.taskana.rest.resource;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.springframework.hateoas.RepresentationModel;
import pro.taskana.common.api.LoggerUtils; import pro.taskana.common.api.LoggerUtils;
import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl; import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl;
/** this class represents a workbasket including its distro targets and authorisations. */ /** this class represents a workbasket including its distro targets and authorisations. */
public class WorkbasketDefinitionResource { public class WorkbasketDefinitionRepresentationModel
extends RepresentationModel<WorkbasketDefinitionRepresentationModel> {
private Set<String> distributionTargets; private Set<String> distributionTargets;
private List<WorkbasketAccessItemImpl> authorizations; private List<WorkbasketAccessItemImpl> authorizations;
private WorkbasketResourceWithoutLinks workbasket; private WorkbasketRepresentationModelWithoutLinks workbasket;
public WorkbasketDefinitionResource() { public WorkbasketDefinitionRepresentationModel() {
// necessary for de-serializing // necessary for de-serializing
} }
public WorkbasketDefinitionResource( public WorkbasketDefinitionRepresentationModel(
WorkbasketResourceWithoutLinks workbasket, WorkbasketRepresentationModelWithoutLinks workbasket,
Set<String> distributionTargets, Set<String> distributionTargets,
List<WorkbasketAccessItemImpl> authorizations) { List<WorkbasketAccessItemImpl> authorizations) {
super(); super();
@ -43,11 +45,11 @@ public class WorkbasketDefinitionResource {
this.authorizations = authorizations; this.authorizations = authorizations;
} }
public WorkbasketResourceWithoutLinks getWorkbasket() { public WorkbasketRepresentationModelWithoutLinks getWorkbasket() {
return workbasket; return workbasket;
} }
public void setWorkbasket(WorkbasketResourceWithoutLinks workbasket) { public void setWorkbasket(WorkbasketRepresentationModelWithoutLinks workbasket) {
this.workbasket = workbasket; this.workbasket = workbasket;
} }

View File

@ -7,6 +7,7 @@ import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import pro.taskana.common.api.exceptions.NotAuthorizedException; import pro.taskana.common.api.exceptions.NotAuthorizedException;
@ -19,27 +20,35 @@ import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl;
import pro.taskana.workbasket.internal.models.WorkbasketImpl; import pro.taskana.workbasket.internal.models.WorkbasketImpl;
/** /**
* Transforms {@link Workbasket} into a {@link WorkbasketDefinitionResource} containing all * Transforms {@link Workbasket} into a {@link WorkbasketDefinitionRepresentationModel} containing
* additional information about that workbasket. * all additional information about that workbasket.
*/ */
@Component @Component
public class WorkbasketDefinitionResourceAssembler { public class WorkbasketDefinitionRepresentationModelAssembler {
@Autowired private WorkbasketService workbasketService; private final WorkbasketService workbasketService;
@Autowired
public WorkbasketDefinitionRepresentationModelAssembler(
WorkbasketService workbasketService) {
this.workbasketService = workbasketService;
}
/** /**
* maps the distro targets to their id to remove overhead. * maps the distro targets to their id to remove overhead.
* *
* @param workbasket {@link Workbasket} which will be converted * @param workbasket {@link Workbasket} which will be converted
* @return a {@link WorkbasketDefinitionResource}, containing the {@code basket}, its distribution * @return a {@link WorkbasketDefinitionRepresentationModel}, containing the {@code basket}, its
* targets and its authorizations * distribution targets and its authorizations
* @throws NotAuthorizedException if the user is not authorized * @throws NotAuthorizedException if the user is not authorized
* @throws WorkbasketNotFoundException if {@code basket} is an unknown workbasket * @throws WorkbasketNotFoundException if {@code basket} is an unknown workbasket
*/ */
public WorkbasketDefinitionResource toModel(Workbasket workbasket) @NonNull
public WorkbasketDefinitionRepresentationModel toEntityModel(Workbasket workbasket)
throws NotAuthorizedException, WorkbasketNotFoundException { throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketResourceWithoutLinks basket = new WorkbasketResourceWithoutLinks(workbasket); WorkbasketRepresentationModelWithoutLinks basket =
new WorkbasketRepresentationModelWithoutLinks(workbasket);
List<WorkbasketAccessItemImpl> authorizations = new ArrayList<>(); List<WorkbasketAccessItemImpl> authorizations = new ArrayList<>();
for (WorkbasketAccessItem accessItem : for (WorkbasketAccessItem accessItem :
@ -50,10 +59,10 @@ public class WorkbasketDefinitionResourceAssembler {
workbasketService.getDistributionTargets(workbasket.getId()).stream() workbasketService.getDistributionTargets(workbasket.getId()).stream()
.map(WorkbasketSummary::getId) .map(WorkbasketSummary::getId)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
return new WorkbasketDefinitionResource(basket, distroTargets, authorizations); return new WorkbasketDefinitionRepresentationModel(basket, distroTargets, authorizations);
} }
public Workbasket toModel(WorkbasketResource wbResource) { public Workbasket toEntityModel(WorkbasketRepresentationModel wbResource) {
WorkbasketImpl workbasket = WorkbasketImpl workbasket =
(WorkbasketImpl) (WorkbasketImpl)
workbasketService.newWorkbasket(wbResource.getKey(), wbResource.getDomain()); workbasketService.newWorkbasket(wbResource.getKey(), wbResource.getDomain());

View File

@ -0,0 +1,58 @@
package pro.taskana.rest.resource;
import pro.taskana.workbasket.api.models.Workbasket;
/**
* EntityModel class for {@link Workbasket}.
*/
public class WorkbasketRepresentationModel
extends WorkbasketSummaryRepresentationModel {
private String created; // ISO-8601
private String modified; // ISO-8601
@SuppressWarnings("unused") //Mandatory for Jackson
protected WorkbasketRepresentationModel() {
}
public WorkbasketRepresentationModel(Workbasket workbasket) {
super(workbasket);
this.created = workbasket.getCreated() != null ? workbasket.getCreated().toString() : null;
this.modified = workbasket.getModified() != null ? workbasket.getModified().toString() : null;
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
public String getModified() {
return modified;
}
public void setModified(String modified) {
this.modified = modified;
}
@Override
public String toString() {
return "WorkbasketResource ["
+ "workbasketId= "
+ this.workbasketId
+ "key= "
+ this.key
+ "name= "
+ this.name
+ "domain= "
+ this.domain
+ "type= "
+ this.type
+ "owner= "
+ this.owner
+ "]";
}
}

View File

@ -6,7 +6,8 @@ import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import java.time.Instant; import java.time.Instant;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; import org.springframework.hateoas.server.RepresentationModelAssembler;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
@ -20,31 +21,33 @@ import pro.taskana.workbasket.api.models.Workbasket;
import pro.taskana.workbasket.internal.models.WorkbasketImpl; import pro.taskana.workbasket.internal.models.WorkbasketImpl;
/** /**
* Transforms {@link Workbasket} to its resource counterpart {@link WorkbasketResource} and vice * Transforms {@link Workbasket} to its resource counterpart {@link WorkbasketRepresentationModel}
* versa. * and vice versa.
*/ */
@Component @Component
public class WorkbasketResourceAssembler public class WorkbasketRepresentationModelAssembler
extends RepresentationModelAssemblerSupport<Workbasket, WorkbasketResource> { implements RepresentationModelAssembler<Workbasket, WorkbasketRepresentationModel> {
private final WorkbasketService workbasketService; private final WorkbasketService workbasketService;
@Autowired @Autowired
public WorkbasketResourceAssembler(WorkbasketService workbasketService) { public WorkbasketRepresentationModelAssembler(
super(WorkbasketController.class, WorkbasketResource.class); WorkbasketService workbasketService) {
this.workbasketService = workbasketService; this.workbasketService = workbasketService;
} }
public WorkbasketResource toModel(Workbasket wb) { @NonNull
@Override
public WorkbasketRepresentationModel toModel(@NonNull Workbasket wb) {
try { try {
WorkbasketResource resource = new WorkbasketResource(wb); WorkbasketRepresentationModel resource = new WorkbasketRepresentationModel(wb);
return addLinks(resource, wb); return addLinks(resource, wb);
} catch (Exception e) { } catch (Exception e) {
throw new SystemException("caught unexpected Exception.", e.getCause()); throw new SystemException("caught unexpected Exception.", e.getCause());
} }
} }
public Workbasket toModel(WorkbasketResource wbResource) { public Workbasket toEntityModel(WorkbasketRepresentationModel wbResource) {
String wbKey = wbResource.getKey(); String wbKey = wbResource.getKey();
String wbDomain = wbResource.getDomain(); String wbDomain = wbResource.getDomain();
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket(wbKey, wbDomain); WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket(wbKey, wbDomain);
@ -60,7 +63,8 @@ public class WorkbasketResourceAssembler
return workbasket; return workbasket;
} }
private WorkbasketResource addLinks(WorkbasketResource resource, Workbasket wb) private WorkbasketRepresentationModel addLinks(
WorkbasketRepresentationModel resource, Workbasket wb)
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidArgumentException { throws NotAuthorizedException, WorkbasketNotFoundException, InvalidArgumentException {
resource.add( resource.add(
linkTo(methodOn(WorkbasketController.class).getWorkbasket(wb.getId())).withSelfRel()); linkTo(methodOn(WorkbasketController.class).getWorkbasket(wb.getId())).withSelfRel());

View File

@ -6,11 +6,11 @@ import pro.taskana.workbasket.api.models.Workbasket;
/** EntityModel class for {@link Workbasket} but without links property. */ /** EntityModel class for {@link Workbasket} but without links property. */
@JsonIgnoreProperties(value = {"links"}) @JsonIgnoreProperties(value = {"links"})
public class WorkbasketResourceWithoutLinks extends WorkbasketResource { public class WorkbasketRepresentationModelWithoutLinks extends WorkbasketRepresentationModel {
WorkbasketResourceWithoutLinks() {} WorkbasketRepresentationModelWithoutLinks() {}
WorkbasketResourceWithoutLinks(Workbasket workbasket) { WorkbasketRepresentationModelWithoutLinks(Workbasket workbasket) {
super(workbasket); super(workbasket);
} }
} }

View File

@ -1,205 +0,0 @@
package pro.taskana.rest.resource;
import javax.validation.constraints.NotNull;
import org.springframework.hateoas.RepresentationModel;
import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.models.Workbasket;
/** EntityModel class for {@link Workbasket}. */
public class WorkbasketResource extends RepresentationModel<WorkbasketResource> {
private String workbasketId;
@NotNull private String key;
@NotNull private String name;
@NotNull private String domain;
@NotNull private WorkbasketType type;
private String created; // ISO-8601
private String modified; // ISO-8601
private String description;
private String owner;
private String custom1;
private String custom2;
private String custom3;
private String custom4;
private String orgLevel1;
private String orgLevel2;
private String orgLevel3;
private String orgLevel4;
public WorkbasketResource() {}
public WorkbasketResource(Workbasket workbasket) {
this.workbasketId = workbasket.getId();
this.key = workbasket.getKey();
this.name = workbasket.getName();
this.domain = workbasket.getDomain();
this.type = workbasket.getType();
this.created = workbasket.getCreated() != null ? workbasket.getCreated().toString() : null;
this.modified = workbasket.getModified() != null ? workbasket.getModified().toString() : null;
this.description = workbasket.getDescription();
this.owner = workbasket.getOwner();
this.custom1 = workbasket.getCustom1();
this.custom2 = workbasket.getCustom2();
this.custom3 = workbasket.getCustom3();
this.custom4 = workbasket.getCustom4();
this.orgLevel1 = workbasket.getOrgLevel1();
this.orgLevel2 = workbasket.getOrgLevel2();
this.orgLevel3 = workbasket.getOrgLevel3();
this.orgLevel4 = workbasket.getOrgLevel4();
}
public String getWorkbasketId() {
return workbasketId;
}
public void setWorkbasketId(String workbasketId) {
this.workbasketId = workbasketId;
}
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 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 getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
public String getModified() {
return modified;
}
public void setModified(String modified) {
this.modified = modified;
}
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 getCustom1() {
return custom1;
}
public void setCustom1(String custom1) {
this.custom1 = custom1;
}
public String getCustom2() {
return custom2;
}
public void setCustom2(String custom2) {
this.custom2 = custom2;
}
public String getCustom3() {
return custom3;
}
public void setCustom3(String custom3) {
this.custom3 = custom3;
}
public String getCustom4() {
return custom4;
}
public void setCustom4(String custom4) {
this.custom4 = custom4;
}
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() {
return "WorkbasketResource ["
+ "workbasketId= "
+ this.workbasketId
+ "key= "
+ this.key
+ "name= "
+ this.name
+ "domain= "
+ this.domain
+ "type= "
+ this.type
+ "owner= "
+ this.owner
+ "]";
}
}

View File

@ -1,29 +0,0 @@
package pro.taskana.rest.resource;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collection;
import org.springframework.hateoas.Link;
/** EntityModel class for {@link WorkbasketSummaryResource} with Pagination. */
public class WorkbasketSummaryListResource extends PagedResources<WorkbasketSummaryResource> {
public WorkbasketSummaryListResource() {
super();
}
public WorkbasketSummaryListResource(
Collection<WorkbasketSummaryResource> content, PageMetadata metadata, Link... links) {
super(content, metadata, links);
}
public WorkbasketSummaryListResource(
Collection<WorkbasketSummaryResource> content, PageMetadata metadata, Iterable<Link> links) {
super(content, metadata, links);
}
@Override
@JsonProperty("workbaskets")
public Collection<WorkbasketSummaryResource> getContent() {
return super.getContent();
}
}

View File

@ -1,41 +1,37 @@
package pro.taskana.rest.resource; package pro.taskana.rest.resource;
import javax.validation.constraints.NotNull;
import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.RepresentationModel;
import org.springframework.hateoas.server.core.Relation;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
import pro.taskana.workbasket.api.models.WorkbasketSummary; import pro.taskana.workbasket.api.models.WorkbasketSummary;
/** EntityModel class for {@link WorkbasketSummary}. */ /**
@Relation(collectionRelation = "workbaskets") * EntityModel class for {@link WorkbasketSummary}.
public class WorkbasketSummaryResource extends RepresentationModel<WorkbasketSummaryResource> { */
public class WorkbasketSummaryRepresentationModel
extends RepresentationModel<WorkbasketSummaryRepresentationModel> {
private String workbasketId; protected String workbasketId;
protected String key;
@NotNull private String key; protected String name;
protected String domain;
@NotNull private String name; protected WorkbasketType type;
protected String description;
@NotNull private String domain; protected String owner;
protected String custom1;
@NotNull private WorkbasketType type; protected String custom2;
protected String custom3;
private String description; protected String custom4;
private String owner; protected String orgLevel1;
private String custom1; protected String orgLevel2;
private String custom2; protected String orgLevel3;
private String custom3; protected String orgLevel4;
private String custom4;
private String orgLevel1;
private String orgLevel2;
private String orgLevel3;
private String orgLevel4;
private boolean markedForDeletion; private boolean markedForDeletion;
public WorkbasketSummaryResource() {} public WorkbasketSummaryRepresentationModel() {
}
public WorkbasketSummaryResource(WorkbasketSummary workbasketSummary) { public WorkbasketSummaryRepresentationModel(WorkbasketSummary workbasketSummary) {
this.workbasketId = workbasketSummary.getId(); this.workbasketId = workbasketSummary.getId();
this.key = workbasketSummary.getKey(); this.key = workbasketSummary.getKey();
this.name = workbasketSummary.getName(); this.name = workbasketSummary.getName();

View File

@ -0,0 +1,66 @@
package pro.taskana.rest.resource;
import static pro.taskana.rest.resource.TaskanaPagedModelKeys.WORKBASKETS;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.server.RepresentationModelAssembler;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import pro.taskana.rest.Mapping;
import pro.taskana.rest.resource.links.PageLinks;
import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.models.WorkbasketSummary;
import pro.taskana.workbasket.internal.models.WorkbasketImpl;
/**
* EntityModel assembler for {@link WorkbasketSummaryRepresentationModel}.
*/
@Component
public class WorkbasketSummaryRepresentationModelAssembler implements
RepresentationModelAssembler<WorkbasketSummary, WorkbasketSummaryRepresentationModel> {
private WorkbasketService workbasketService;
public WorkbasketSummaryRepresentationModelAssembler() {
}
@Autowired
public WorkbasketSummaryRepresentationModelAssembler(WorkbasketService workbasketService) {
this.workbasketService = workbasketService;
}
@NonNull
@Override
public WorkbasketSummaryRepresentationModel toModel(
@NonNull WorkbasketSummary workbasketSummary) {
return new WorkbasketSummaryRepresentationModel(workbasketSummary);
}
public WorkbasketSummary toEntityModel(WorkbasketSummaryRepresentationModel resource) {
WorkbasketImpl workbasket =
(WorkbasketImpl) workbasketService.newWorkbasket(resource.getKey(), resource.getDomain());
workbasket.setId(resource.getWorkbasketId());
BeanUtils.copyProperties(resource, workbasket);
return workbasket.asSummary();
}
@PageLinks(Mapping.URL_WORKBASKET)
public TaskanaPagedModel<WorkbasketSummaryRepresentationModel> toPageModel(
List<WorkbasketSummary> workbasketSummaries, PageMetadata pageMetadata) {
return workbasketSummaries.stream()
.map(this::toModel)
.collect(
Collectors.collectingAndThen(
Collectors.toList(),
list -> new TaskanaPagedModel<>(getKey(), list, pageMetadata)));
}
protected TaskanaPagedModelKeys getKey() {
return WORKBASKETS;
}
}

View File

@ -1,47 +0,0 @@
package pro.taskana.rest.resource;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.stereotype.Component;
import pro.taskana.rest.Mapping;
import pro.taskana.rest.WorkbasketController;
import pro.taskana.rest.resource.PagedResources.PageMetadata;
import pro.taskana.rest.resource.links.PageLinks;
import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.models.WorkbasketSummary;
import pro.taskana.workbasket.internal.models.WorkbasketImpl;
/** EntityModel assembler for {@link WorkbasketSummaryResource}. */
@Component
public class WorkbasketSummaryResourceAssembler
extends RepresentationModelAssemblerSupport<WorkbasketSummary, WorkbasketSummaryResource> {
@Autowired private WorkbasketService workbasketService;
public WorkbasketSummaryResourceAssembler() {
super(WorkbasketController.class, WorkbasketSummaryResource.class);
}
@PageLinks(Mapping.URL_WORKBASKET)
public WorkbasketSummaryListResource toCollectionModel(
List<WorkbasketSummary> entities, PageMetadata pageMetadata) {
return new WorkbasketSummaryListResource(
toCollectionModel(entities).getContent(), pageMetadata);
}
@Override
public WorkbasketSummaryResource toModel(WorkbasketSummary workbasketSummary) {
return new WorkbasketSummaryResource(workbasketSummary);
}
public WorkbasketSummary toModel(WorkbasketSummaryResource resource) {
WorkbasketImpl workbasket =
(WorkbasketImpl) workbasketService.newWorkbasket(resource.getKey(), resource.getDomain());
workbasket.setId(resource.getWorkbasketId());
BeanUtils.copyProperties(resource, workbasket);
return workbasket.asSummary();
}
}

View File

@ -13,13 +13,12 @@ import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.hateoas.IanaLinkRelations; import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link; import org.springframework.hateoas.Link;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.RepresentationModel;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
import pro.taskana.rest.resource.PagedResources.PageMetadata;
/** /**
* Implementation of the PageLinks annotation to generate HATEOAS Links for paged list resources. * Implementation of the PageLinks annotation to generate HATEOAS Links for paged list resources.
*/ */
@ -39,8 +38,10 @@ public class PageLinksAspect {
String relativeUrl = pageLinks.value(); String relativeUrl = pageLinks.value();
UriComponentsBuilder original = originalUri(relativeUrl, request); UriComponentsBuilder original = originalUri(relativeUrl, request);
RepresentationModel<T> resourceSupport = (RepresentationModel<T>) joinPoint.proceed(); RepresentationModel<T> resourceSupport = (RepresentationModel<T>) joinPoint.proceed();
resourceSupport.add(new Link(original.toUriString()).withSelfRel());
if (page != null) { if (page != null) {
resourceSupport.add(
new Link(original.replaceQueryParam("page", page.getNumber()).toUriString())
.withSelfRel());
resourceSupport.add( resourceSupport.add(
new Link(original.replaceQueryParam("page", 1).toUriString()) new Link(original.replaceQueryParam("page", 1).toUriString())
.withRel(IanaLinkRelations.FIRST)); .withRel(IanaLinkRelations.FIRST));
@ -57,6 +58,8 @@ public class PageLinksAspect {
new Link(original.replaceQueryParam("page", page.getNumber() + 1).toUriString()) new Link(original.replaceQueryParam("page", page.getNumber() + 1).toUriString())
.withRel(IanaLinkRelations.NEXT)); .withRel(IanaLinkRelations.NEXT));
} }
} else {
resourceSupport.add(new Link(original.toUriString()).withSelfRel());
} }
return resourceSupport; return resourceSupport;
} }

View File

@ -17,7 +17,7 @@ import pro.taskana.rest.Mapping;
/** Generate Rest Docu for AbstractPagingController. */ /** Generate Rest Docu for AbstractPagingController. */
class AbstractPagingControllerRestDocumentation extends BaseRestDocumentation { class AbstractPagingControllerRestDocumentation extends BaseRestDocumentation {
private HashMap<String, String> pagingFieldDescriptionsMap = new HashMap<String, String>(); private final HashMap<String, String> pagingFieldDescriptionsMap = new HashMap<>();
private FieldDescriptor[] pagingFieldDescriptors; private FieldDescriptor[] pagingFieldDescriptors;

View File

@ -22,11 +22,13 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import pro.taskana.rest.Mapping; import pro.taskana.rest.Mapping;
/** Generate REST Dokumentation for ClassificationController. */ /**
* Generate REST Dokumentation for ClassificationController.
*/
class ClassificationControllerRestDocumentation extends BaseRestDocumentation { class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
private HashMap<String, String> classificationFieldDescriptionsMap = private final HashMap<String, String> classificationFieldDescriptionsMap =
new HashMap<String, String>(); new HashMap<>();
private FieldDescriptor[] allClassificationsFieldDescriptors; private FieldDescriptor[] allClassificationsFieldDescriptors;
private FieldDescriptor[] classificationFieldDescriptors; private FieldDescriptor[] classificationFieldDescriptors;
@ -87,11 +89,6 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
subsectionWithPath("classifications") subsectionWithPath("classifications")
.description("An Array of <<classification-subset, Classification-Subsets>>"), .description("An Array of <<classification-subset, Classification-Subsets>>"),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("_links.self.href").ignored(),
fieldWithPath("page").ignored(),
fieldWithPath("page.size").ignored(),
fieldWithPath("page.totalElements").ignored(),
fieldWithPath("page.totalPages").ignored(),
fieldWithPath("page.number").ignored()
}; };
classificationFieldDescriptors = classificationFieldDescriptors =
@ -256,7 +253,7 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
this.mockMvc this.mockMvc
.perform( .perform(
RestDocumentationRequestBuilders.get( RestDocumentationRequestBuilders.get(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?domain=DOMAIN_B") restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?domain=DOMAIN_B")
.accept("application/hal+json") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -337,14 +334,13 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), UTF_8)); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), UTF_8));
String inputLine; String inputLine;
StringBuffer content = new StringBuffer(); StringBuilder content = new StringBuilder();
while ((inputLine = in.readLine()) != null) { while ((inputLine = in.readLine()) != null) {
content.append(inputLine); content.append(inputLine);
} }
in.close(); in.close();
con.disconnect(); con.disconnect();
String originalTask = content.toString(); String modifiedTask = content.toString();
String modifiedTask = originalTask;
this.mockMvc this.mockMvc
.perform( .perform(

View File

@ -22,10 +22,11 @@ import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import pro.taskana.rest.Mapping; import pro.taskana.rest.Mapping;
import pro.taskana.rest.resource.TaskanaPagedModelKeys;
public class TaskCommentControllerRestDocumentation extends BaseRestDocumentation { public class TaskCommentControllerRestDocumentation extends BaseRestDocumentation {
private HashMap<String, String> taskCommentFieldDescriptionsMap = new HashMap<>(); private final HashMap<String, String> taskCommentFieldDescriptionsMap = new HashMap<>();
private FieldDescriptor[] allTaskCommentsFieldDescriptors; private FieldDescriptor[] allTaskCommentsFieldDescriptors;
private FieldDescriptor[] taskCommentFieldDescriptors; private FieldDescriptor[] taskCommentFieldDescriptors;
@ -81,8 +82,10 @@ public class TaskCommentControllerRestDocumentation extends BaseRestDocumentatio
}; };
allTaskCommentsFieldDescriptors = allTaskCommentsFieldDescriptors =
new FieldDescriptor[] { new FieldDescriptor[]{
subsectionWithPath("task comments").description("An Array of task comments") subsectionWithPath(TaskanaPagedModelKeys.TASK_COMMENTS.getPropertyName()).description(
"An Array of task comments"),
fieldWithPath("_links.self.href").ignored()
}; };
} }

View File

@ -25,7 +25,7 @@ import pro.taskana.rest.Mapping;
/** Generate REST Documentation for the TaskController. */ /** Generate REST Documentation for the TaskController. */
class TaskControllerRestDocumentation extends BaseRestDocumentation { class TaskControllerRestDocumentation extends BaseRestDocumentation {
private HashMap<String, String> taskFieldDescriptionsMap = new HashMap<String, String>(); private final HashMap<String, String> taskFieldDescriptionsMap = new HashMap<>();
private FieldDescriptor[] allTasksFieldDescriptors; private FieldDescriptor[] allTasksFieldDescriptors;
private FieldDescriptor[] taskFieldDescriptors; private FieldDescriptor[] taskFieldDescriptors;
@ -60,10 +60,11 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
taskFieldDescriptionsMap.put("priority", "The priority of the task"); taskFieldDescriptionsMap.put("priority", "The priority of the task");
taskFieldDescriptionsMap.put("state", "he state of the task. See (...)"); taskFieldDescriptionsMap.put("state", "he state of the task. See (...)");
taskFieldDescriptionsMap.put( taskFieldDescriptionsMap.put(
"classificationSummaryResource", "classificationSummary",
"The <<classification-subset, Classification>> of the task"); "The <<classification-subset, Classification>> of the task");
taskFieldDescriptionsMap.put( taskFieldDescriptionsMap.put(
"workbasketSummaryResource", "The <<workbasket-subset, Workbasket>> of the task"); "workbasketSummary",
"The <<workbasket-subset, Workbasket>> of the task");
taskFieldDescriptionsMap.put("businessProcessId", ""); taskFieldDescriptionsMap.put("businessProcessId", "");
taskFieldDescriptionsMap.put("parentBusinessProcessId", ""); taskFieldDescriptionsMap.put("parentBusinessProcessId", "");
taskFieldDescriptionsMap.put( taskFieldDescriptionsMap.put(
@ -112,11 +113,6 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
fieldWithPath("_links").ignored(), fieldWithPath("_links").ignored(),
fieldWithPath("_links.self").ignored(), fieldWithPath("_links.self").ignored(),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("_links.self.href").ignored(),
fieldWithPath("page").ignored(),
fieldWithPath("page.size").ignored(),
fieldWithPath("page.totalElements").ignored(),
fieldWithPath("page.totalPages").ignored(),
fieldWithPath("page.number").ignored()
}; };
taskFieldDescriptors = taskFieldDescriptors =
@ -137,28 +133,30 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
.description(taskFieldDescriptionsMap.get("planned")) .description(taskFieldDescriptionsMap.get("planned"))
.type("String"), .type("String"),
fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"), fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"),
fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")), fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")),
fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")), fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")),
fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")), fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")),
fieldWithPath("note") fieldWithPath("note")
.description(taskFieldDescriptionsMap.get("note")) .description(taskFieldDescriptionsMap.get("note"))
.description("Some custom Note"), .description("Some custom Note"),
fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")), fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")),
fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")), fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")),
subsectionWithPath("classificationSummaryResource") subsectionWithPath("classificationSummary")
.description(taskFieldDescriptionsMap.get("classificationSummaryResource")), .description(
subsectionWithPath("workbasketSummaryResource") taskFieldDescriptionsMap.get("classificationSummary")),
.description(taskFieldDescriptionsMap.get("workbasketSummaryResource")), subsectionWithPath("workbasketSummary")
fieldWithPath("businessProcessId") .description(taskFieldDescriptionsMap.get("workbasketSummary")),
.description(taskFieldDescriptionsMap.get("businessProcessId")), fieldWithPath("businessProcessId")
fieldWithPath("parentBusinessProcessId") .description(taskFieldDescriptionsMap.get("businessProcessId")),
.description(taskFieldDescriptionsMap.get("parentBusinessProcessId")), fieldWithPath("parentBusinessProcessId")
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String"), .description(taskFieldDescriptionsMap.get("parentBusinessProcessId")),
fieldWithPath("primaryObjRef.id") fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type(
.description(taskFieldDescriptionsMap.get("primaryObjRef.id")) "String"),
.type("String"), fieldWithPath("primaryObjRef.id")
fieldWithPath("primaryObjRef.company") .description(taskFieldDescriptionsMap.get("primaryObjRef.id"))
.description(taskFieldDescriptionsMap.get("primaryObjRef.company")), .type("String"),
fieldWithPath("primaryObjRef.company")
.description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
fieldWithPath("primaryObjRef.system") fieldWithPath("primaryObjRef.system")
.description(taskFieldDescriptionsMap.get("primaryObjRef.system")), .description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
fieldWithPath("primaryObjRef.systemInstance") fieldWithPath("primaryObjRef.systemInstance")
@ -240,28 +238,29 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
.description(taskFieldDescriptionsMap.get("planned")) .description(taskFieldDescriptionsMap.get("planned"))
.type("String"), .type("String"),
fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"), fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"),
fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")), fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")),
fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")), fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")),
fieldWithPath("description").ignored(), fieldWithPath("description").ignored(),
fieldWithPath("note") fieldWithPath("note")
.description(taskFieldDescriptionsMap.get("note")) .description(taskFieldDescriptionsMap.get("note"))
.description("Some custom Note"), .description("Some custom Note"),
fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")), fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")),
fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")), fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")),
subsectionWithPath("classificationSummaryResource") subsectionWithPath("classificationSummary")
.description(taskFieldDescriptionsMap.get("classificationSummaryResource")), .description(
subsectionWithPath("workbasketSummaryResource") taskFieldDescriptionsMap.get("classificationSummary")),
.description(taskFieldDescriptionsMap.get("workbasketSummaryResource")), subsectionWithPath("workbasketSummary")
fieldWithPath("businessProcessId") .description(taskFieldDescriptionsMap.get("workbasketSummary")),
.description(taskFieldDescriptionsMap.get("businessProcessId")), fieldWithPath("businessProcessId")
fieldWithPath("parentBusinessProcessId") .description(taskFieldDescriptionsMap.get("businessProcessId")),
.description(taskFieldDescriptionsMap.get("parentBusinessProcessId")), fieldWithPath("parentBusinessProcessId")
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")), .description(taskFieldDescriptionsMap.get("parentBusinessProcessId")),
fieldWithPath("primaryObjRef.id") fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")),
.description(taskFieldDescriptionsMap.get("primaryObjRef.id")) fieldWithPath("primaryObjRef.id")
.type("String"), .description(taskFieldDescriptionsMap.get("primaryObjRef.id"))
fieldWithPath("primaryObjRef.company") .type("String"),
.description(taskFieldDescriptionsMap.get("primaryObjRef.company")), fieldWithPath("primaryObjRef.company")
.description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
fieldWithPath("primaryObjRef.system") fieldWithPath("primaryObjRef.system")
.description(taskFieldDescriptionsMap.get("primaryObjRef.system")), .description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
fieldWithPath("primaryObjRef.systemInstance") fieldWithPath("primaryObjRef.systemInstance")
@ -295,21 +294,21 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
}; };
createTaskFieldDescriptors = createTaskFieldDescriptors =
new FieldDescriptor[] { new FieldDescriptor[]{
subsectionWithPath("classificationSummaryResource") subsectionWithPath("classificationSummary")
.description("The new classificationSummaryResource for the task"), .description("The new classificationSummary for the task"),
subsectionWithPath("workbasketSummaryResource") subsectionWithPath("workbasketSummary")
.description("The new workbasketSummaryResource for the task"), .description("The new workbasketSummary for the task"),
fieldWithPath("externalId") fieldWithPath("externalId")
.description(taskFieldDescriptionsMap.get("externalId")) .description(taskFieldDescriptionsMap.get("externalId"))
.type("String") .type("String")
.optional(), .optional(),
fieldWithPath("primaryObjRef.company") fieldWithPath("primaryObjRef.company")
.description(taskFieldDescriptionsMap.get("primaryObjRef.company")), .description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
fieldWithPath("primaryObjRef.system") fieldWithPath("primaryObjRef.system")
.description(taskFieldDescriptionsMap.get("primaryObjRef.system")), .description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
fieldWithPath("primaryObjRef.systemInstance") fieldWithPath("primaryObjRef.systemInstance")
.description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")), .description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")),
fieldWithPath("primaryObjRef.type") fieldWithPath("primaryObjRef.type")
.description(taskFieldDescriptionsMap.get("primaryObjRef.type")), .description(taskFieldDescriptionsMap.get("primaryObjRef.type")),
fieldWithPath("primaryObjRef.value") fieldWithPath("primaryObjRef.value")
@ -554,8 +553,8 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_TASKS)) RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_TASKS))
.contentType("application/hal+json") .contentType("application/hal+json")
.content( .content(
"{\"classificationSummaryResource\":{\"key\":\"L11010\"}," "{\"classificationSummary\":{\"key\":\"L11010\"},"
+ "\"workbasketSummaryResource\":" + "\"workbasketSummary\":"
+ "{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + "{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\"," + "\"primaryObjRef\":{\"company\":\"MyCompany1\","
+ "\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\"," + "\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\","
@ -589,8 +588,8 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_TASKS)) RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_TASKS))
.contentType("application/hal+json") .contentType("application/hal+json")
.content( .content(
"{\"classificationSummaryResource\":{\"key\":\"L11010\"}," "{\"classificationSummary\":{\"key\":\"L11010\"},"
+ "\"workbasketSummaryResource\":" + "\"workbasketSummary\":"
+ "{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + "{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\"," + "\"primaryObjRef\":{\"company\":\"MyCompany1\","
+ "\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\"," + "\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\","
@ -625,8 +624,8 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_TASKS)) RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_TASKS))
.contentType("application/hal+json") .contentType("application/hal+json")
.content( .content(
"{\"classificationSummaryResource\":{\"key\":\"L11010\"}," "{\"classificationSummary\":{\"key\":\"L11010\"},"
+ "\"workbasketSummaryResource\":" + "\"workbasketSummary\":"
+ "{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + "{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\"," + "\"primaryObjRef\":{\"company\":\"MyCompany1\","
+ "\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\"," + "\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\","
@ -660,8 +659,8 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_TASKS)) RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_TASKS))
.contentType("application/hal+json") .contentType("application/hal+json")
.content( .content(
"{\"classificationSummaryResource\":{\"key\":\"L11010\"}," "{\"classificationSummary\":{\"key\":\"L11010\"},"
+ "\"workbasketSummaryResource\":" + "\"workbasketSummary\":"
+ "{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + "{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\"," + "\"primaryObjRef\":{\"company\":\"MyCompany1\","
+ "\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\"," + "\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\","
@ -673,7 +672,6 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
String content = result.getResponse().getContentAsString(); String content = result.getResponse().getContentAsString();
String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40); String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40);
this.mockMvc this.mockMvc
.perform( .perform(
RestDocumentationRequestBuilders.post( RestDocumentationRequestBuilders.post(
@ -695,8 +693,8 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_TASKS)) RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_TASKS))
.contentType("application/hal+json") .contentType("application/hal+json")
.content( .content(
"{\"classificationSummaryResource\":{\"key\":\"L11010\"}," "{\"classificationSummary\":{\"key\":\"L11010\"},"
+ "\"workbasketSummaryResource\":" + "\"workbasketSummary\":"
+ "{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + "{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\"," + "\"primaryObjRef\":{\"company\":\"MyCompany1\","
+ "\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\"," + "\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\","

View File

@ -105,10 +105,6 @@ class WorkbasketAccessItemControllerRestDocumentation extends BaseRestDocumentat
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom12")), .description(accessItemFieldDescriptionsMap.get("accessItems.permCustom12")),
fieldWithPath("_links.self.href") fieldWithPath("_links.self.href")
.description(accessItemFieldDescriptionsMap.get("_links.self.href")), .description(accessItemFieldDescriptionsMap.get("_links.self.href")),
fieldWithPath("page.size").ignored(),
fieldWithPath("page.totalElements").ignored(),
fieldWithPath("page.totalPages").ignored(),
fieldWithPath("page.number").ignored()
}; };
} }

View File

@ -20,13 +20,15 @@ import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import pro.taskana.rest.Mapping; import pro.taskana.rest.Mapping;
import pro.taskana.rest.resource.TaskanaPagedModelKeys;
/** Generate REST Documentatioon for the WorkbasketController. */ /** Generate REST Documentatioon for the WorkbasketController. */
class WorkbasketControllerRestDocumentation extends BaseRestDocumentation { class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
public static final String PROPERTY_NAME = TaskanaPagedModelKeys.ACCESSITEMS.getPropertyName();
// HashMaps to store the field descriptions centrally for multiple uses // HashMaps to store the field descriptions centrally for multiple uses
private HashMap<String, String> workbasketFieldDescriptionsMap = new HashMap<String, String>(); private final HashMap<String, String> workbasketFieldDescriptionsMap = new HashMap<>();
private HashMap<String, String> accessItemFieldDescriptionsMap = new HashMap<String, String>(); private final HashMap<String, String> accessItemFieldDescriptionsMap = new HashMap<>();
private FieldDescriptor[] allWorkbasketsFieldDescriptors; private FieldDescriptor[] allWorkbasketsFieldDescriptors;
private FieldDescriptor[] workbasketFieldDescriptors; private FieldDescriptor[] workbasketFieldDescriptors;
@ -52,12 +54,13 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
workbasketFieldDescriptionsMap.put( workbasketFieldDescriptionsMap.put(
"orgLevel1", "orgLevel1",
"The first Org Level (the top one)\nThe Org Level is an association with an org " "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 " + "hierarchy level in the organization. The values are used for monitoring "
+ "and statistical purposes and should reflect the responsibility of the " + "and statistical purposes and should reflect the responsibility of the "
+ "tasks in the workbasket."); + "tasks in the workbasket.");
workbasketFieldDescriptionsMap.put("orgLevel2", "The second Org Level"); workbasketFieldDescriptionsMap.put("orgLevel2", "The second Org Level");
workbasketFieldDescriptionsMap.put("orgLevel3", "The third Org Level"); workbasketFieldDescriptionsMap.put("orgLevel3", "The third Org Level");
workbasketFieldDescriptionsMap.put("orgLevel4", "The fourth Org Level (the lowest one)."); workbasketFieldDescriptionsMap.put("orgLevel4", "The fourth Org Level (the lowest one).");
workbasketFieldDescriptionsMap.put("markedForDeletion", "can this be deleted");
workbasketFieldDescriptionsMap.put( workbasketFieldDescriptionsMap.put(
"created", "The creation timestamp of the workbasket in the system."); "created", "The creation timestamp of the workbasket in the system.");
workbasketFieldDescriptionsMap.put( workbasketFieldDescriptionsMap.put(
@ -72,55 +75,52 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
"_links.removeDistributionTargets.href", "_links.removeDistributionTargets.href",
"Link to remove all distribution-targets from the workbasket"); "Link to remove all distribution-targets from the workbasket");
workbasketFieldDescriptionsMap.put( workbasketFieldDescriptionsMap.put(
"_links.accessItems.href", "The Access-Items of the workbasket"); "_links." + PROPERTY_NAME + ".href", "The Access-Items of the workbasket");
workbasketFieldDescriptionsMap.put("_links.allWorkbaskets.href", "Link to all workbaskets"); workbasketFieldDescriptionsMap.put("_links.allWorkbaskets.href", "Link to all workbaskets");
accessItemFieldDescriptionsMap.put("accessItems.accessItemId", "Unique ID"); accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".accessItemId", "Unique ID");
accessItemFieldDescriptionsMap.put("accessItems.workbasketId", "The workbasket"); accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".workbasketId", "The workbasket");
accessItemFieldDescriptionsMap.put("accessItems.workbasketKey", "The workbasket key"); accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".workbasketKey", "The workbasket key");
accessItemFieldDescriptionsMap.put( accessItemFieldDescriptionsMap.put(
"accessItems.accessId", PROPERTY_NAME + ".accessId",
"The access id, this ACL entry refers to. This could be either a userid or a " "The access id, this ACL entry refers to. This could be either a userid or a "
+ "full qualified group id (both lower case)"); + "full qualified group id (both lower case)");
accessItemFieldDescriptionsMap.put("accessItems.accessName", ""); accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".accessName", "");
accessItemFieldDescriptionsMap.put( accessItemFieldDescriptionsMap.put(
"accessItems.permRead", "The permission to read the information about the workbasket"); PROPERTY_NAME + ".permRead", "The permission to read the information about the workbasket");
accessItemFieldDescriptionsMap.put( accessItemFieldDescriptionsMap.put(
"accessItems.permOpen", "The permission to view the content (the tasks) of a workbasket"); PROPERTY_NAME + ".permOpen",
"The permission to view the content (the tasks) of a workbasket");
accessItemFieldDescriptionsMap.put( accessItemFieldDescriptionsMap.put(
"accessItems.permAppend", PROPERTY_NAME + ".permAppend",
"The permission to add tasks to the workbasket (required for creation " "The permission to add tasks to the workbasket (required for creation "
+ "and transferring of tasks)"); + "and transferring of tasks)");
accessItemFieldDescriptionsMap.put( accessItemFieldDescriptionsMap.put(
"accessItems.permTransfer", PROPERTY_NAME + ".permTransfer",
"The permission to transfer tasks (out of the current workbasket)"); "The permission to transfer tasks (out of the current workbasket)");
accessItemFieldDescriptionsMap.put( accessItemFieldDescriptionsMap.put(
"accessItems.permDistribute", "The permission to distribute tasks from the workbasket"); PROPERTY_NAME + ".permDistribute",
accessItemFieldDescriptionsMap.put("accessItems.permCustom1", ""); "The permission to distribute tasks from the workbasket");
accessItemFieldDescriptionsMap.put("accessItems.permCustom2", ""); accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom1", "");
accessItemFieldDescriptionsMap.put("accessItems.permCustom3", ""); accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom2", "");
accessItemFieldDescriptionsMap.put("accessItems.permCustom4", ""); accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom3", "");
accessItemFieldDescriptionsMap.put("accessItems.permCustom5", ""); accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom4", "");
accessItemFieldDescriptionsMap.put("accessItems.permCustom6", ""); accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom5", "");
accessItemFieldDescriptionsMap.put("accessItems.permCustom7", ""); accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom6", "");
accessItemFieldDescriptionsMap.put("accessItems.permCustom8", ""); accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom7", "");
accessItemFieldDescriptionsMap.put("accessItems.permCustom9", ""); accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom8", "");
accessItemFieldDescriptionsMap.put("accessItems.permCustom10", ""); accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom9", "");
accessItemFieldDescriptionsMap.put("accessItems.permCustom11", ""); accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom10", "");
accessItemFieldDescriptionsMap.put("accessItems.permCustom12", ""); accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom11", "");
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom12", "");
accessItemFieldDescriptionsMap.put( accessItemFieldDescriptionsMap.put(
"accessItems._links.workbasket.href", "Link to the workbasket"); PROPERTY_NAME + "._links.workbasket.href", "Link to the workbasket");
allWorkbasketsFieldDescriptors = allWorkbasketsFieldDescriptors =
new FieldDescriptor[] { new FieldDescriptor[] {
subsectionWithPath("workbaskets") subsectionWithPath("workbaskets")
.description("An Array of <<workbasket-subset, Workbasket-Subsets>>"), .description("An Array of <<workbasket-subset, Workbasket-Subsets>>"),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("_links.self.href").ignored(),
fieldWithPath("page").ignored(),
fieldWithPath("page.size").ignored(),
fieldWithPath("page.totalElements").ignored(),
fieldWithPath("page.totalPages").ignored(),
fieldWithPath("page.number").ignored()
}; };
workbasketFieldDescriptors = workbasketFieldDescriptors =
@ -144,13 +144,15 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")), fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")),
fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")), fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")),
fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")), fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")),
fieldWithPath("markedForDeletion").description(
workbasketFieldDescriptionsMap.get("markedForDeletion")),
fieldWithPath("_links.distributionTargets.href") fieldWithPath("_links.distributionTargets.href")
.description(workbasketFieldDescriptionsMap.get("_links.distributionTargets.href")), .description(workbasketFieldDescriptionsMap.get("_links.distributionTargets.href")),
fieldWithPath("_links.removeDistributionTargets.href") fieldWithPath("_links.removeDistributionTargets.href")
.description( .description(
workbasketFieldDescriptionsMap.get("_links.removeDistributionTargets.href")), workbasketFieldDescriptionsMap.get("_links.removeDistributionTargets.href")),
fieldWithPath("_links.accessItems.href") fieldWithPath("_links." + PROPERTY_NAME + ".href")
.description(workbasketFieldDescriptionsMap.get("_links.accessItems.href")), .description(workbasketFieldDescriptionsMap.get("_links." + PROPERTY_NAME + ".href")),
fieldWithPath("_links.allWorkbaskets.href") fieldWithPath("_links.allWorkbaskets.href")
.description(workbasketFieldDescriptionsMap.get("_links.allWorkbaskets.href")), .description(workbasketFieldDescriptionsMap.get("_links.allWorkbaskets.href")),
fieldWithPath("_links.self.href").ignored() fieldWithPath("_links.self.href").ignored()
@ -165,88 +167,81 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
fieldWithPath("description") fieldWithPath("description")
.description(workbasketFieldDescriptionsMap.get("description")), .description(workbasketFieldDescriptionsMap.get("description")),
fieldWithPath("owner").description(workbasketFieldDescriptionsMap.get("owner")), fieldWithPath("owner").description(workbasketFieldDescriptionsMap.get("owner")),
fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")), fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")),
fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")), fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")),
fieldWithPath("custom1").description(workbasketFieldDescriptionsMap.get("custom1")), fieldWithPath("custom1").description(workbasketFieldDescriptionsMap.get("custom1")),
fieldWithPath("custom2").description(workbasketFieldDescriptionsMap.get("custom2")), fieldWithPath("custom2").description(workbasketFieldDescriptionsMap.get("custom2")),
fieldWithPath("custom3").description(workbasketFieldDescriptionsMap.get("custom3")), fieldWithPath("custom3").description(workbasketFieldDescriptionsMap.get("custom3")),
fieldWithPath("custom4").description(workbasketFieldDescriptionsMap.get("custom4")), fieldWithPath("custom4").description(workbasketFieldDescriptionsMap.get("custom4")),
fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1")), fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1")),
fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")), fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")),
fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")), fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")),
fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")), fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")),
fieldWithPath("created").ignored(), fieldWithPath("markedForDeletion").description(
fieldWithPath("modified").ignored(), workbasketFieldDescriptionsMap.get("markedForDeletion")),
fieldWithPath("_links.distributionTargets.href").ignored(), fieldWithPath("created").ignored(),
fieldWithPath("_links.removeDistributionTargets.href").ignored(), fieldWithPath("modified").ignored(),
fieldWithPath("_links.accessItems.href").ignored(), fieldWithPath("_links.distributionTargets.href").ignored(),
fieldWithPath("_links.allWorkbaskets.href").ignored(), fieldWithPath("_links.removeDistributionTargets.href").ignored(),
fieldWithPath("_links.self.href").ignored() fieldWithPath("_links." + PROPERTY_NAME + ".href").ignored(),
fieldWithPath("_links.allWorkbaskets.href").ignored(),
fieldWithPath("_links.self.href").ignored()
}; };
accessItemFieldDescriptors = accessItemFieldDescriptors =
new FieldDescriptor[] { new FieldDescriptor[] {
fieldWithPath("accessItems[].accessItemId") fieldWithPath(PROPERTY_NAME + "[].accessItemId")
.description(accessItemFieldDescriptionsMap.get("accessItems.accessItemId")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".accessItemId")),
fieldWithPath("accessItems[].workbasketId") fieldWithPath(PROPERTY_NAME + "[].workbasketId")
.description(accessItemFieldDescriptionsMap.get("accessItems.workbasketId")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".workbasketId")),
fieldWithPath("accessItems[].workbasketKey") fieldWithPath(PROPERTY_NAME + "[].workbasketKey")
.description(accessItemFieldDescriptionsMap.get("accessItems.workbasketKey")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".workbasketKey")),
fieldWithPath("accessItems[].accessId") fieldWithPath(PROPERTY_NAME + "[].accessId")
.description(accessItemFieldDescriptionsMap.get("accessItems.accessId")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".accessId")),
fieldWithPath("accessItems[].accessName") fieldWithPath(PROPERTY_NAME + "[].accessName")
.description(accessItemFieldDescriptionsMap.get("accessItems.accessName")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".accessName")),
fieldWithPath("accessItems[].permRead") fieldWithPath(PROPERTY_NAME + "[].permRead")
.description(accessItemFieldDescriptionsMap.get("accessItems.permRead")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permRead")),
fieldWithPath("accessItems[].permOpen") fieldWithPath(PROPERTY_NAME + "[].permOpen")
.description(accessItemFieldDescriptionsMap.get("accessItems.permOpen")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permOpen")),
fieldWithPath("accessItems[].permAppend") fieldWithPath(PROPERTY_NAME + "[].permAppend")
.description(accessItemFieldDescriptionsMap.get("accessItems.permAppend")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permAppend")),
fieldWithPath("accessItems[].permTransfer") fieldWithPath(PROPERTY_NAME + "[].permTransfer")
.description(accessItemFieldDescriptionsMap.get("accessItems.permTransfer")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permTransfer")),
fieldWithPath("accessItems[].permDistribute") fieldWithPath(PROPERTY_NAME + "[].permDistribute")
.description(accessItemFieldDescriptionsMap.get("accessItems.permDistribute")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permDistribute")),
fieldWithPath("accessItems[].permCustom1") fieldWithPath(PROPERTY_NAME + "[].permCustom1")
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom1")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom1")),
fieldWithPath("accessItems[].permCustom2") fieldWithPath(PROPERTY_NAME + "[].permCustom2")
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom2")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom2")),
fieldWithPath("accessItems[].permCustom3") fieldWithPath(PROPERTY_NAME + "[].permCustom3")
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom3")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom3")),
fieldWithPath("accessItems[].permCustom4") fieldWithPath(PROPERTY_NAME + "[].permCustom4")
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom4")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom4")),
fieldWithPath("accessItems[].permCustom5") fieldWithPath(PROPERTY_NAME + "[].permCustom5")
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom5")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom5")),
fieldWithPath("accessItems[].permCustom6") fieldWithPath(PROPERTY_NAME + "[].permCustom6")
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom6")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom6")),
fieldWithPath("accessItems[].permCustom7") fieldWithPath(PROPERTY_NAME + "[].permCustom7")
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom7")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom7")),
fieldWithPath("accessItems[].permCustom8") fieldWithPath(PROPERTY_NAME + "[].permCustom8")
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom8")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom8")),
fieldWithPath("accessItems[].permCustom9") fieldWithPath(PROPERTY_NAME + "[].permCustom9")
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom9")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom9")),
fieldWithPath("accessItems[].permCustom10") fieldWithPath(PROPERTY_NAME + "[].permCustom10")
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom10")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom10")),
fieldWithPath("accessItems[].permCustom11") fieldWithPath(PROPERTY_NAME + "[].permCustom11")
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom11")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom11")),
fieldWithPath("accessItems[].permCustom12") fieldWithPath(PROPERTY_NAME + "[].permCustom12")
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom12")), .description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom12")),
fieldWithPath("page.size").ignored(),
fieldWithPath("page.totalElements").ignored(),
fieldWithPath("page.totalPages").ignored(),
fieldWithPath("page.number").ignored(),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("_links.self.href").ignored(),
fieldWithPath("_links.workbasket.href").ignored() fieldWithPath("_links.workbasket.href").ignored()
}; };
allWorkbasketAccessItemsFieldDescriptors = allWorkbasketAccessItemsFieldDescriptors =
new FieldDescriptor[] { new FieldDescriptor[] {
subsectionWithPath("accessItems") subsectionWithPath(PROPERTY_NAME)
.description("An array of <<access-item, Access Items>>"), .description("An array of <<access-item, Access Items>>"),
fieldWithPath("page").ignored(),
fieldWithPath("page.size").ignored(),
fieldWithPath("page.totalElements").ignored(),
fieldWithPath("page.totalPages").ignored(),
fieldWithPath("page.number").ignored(),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("_links.self.href").ignored(),
fieldWithPath("_links.workbasket.href").ignored() fieldWithPath("_links.workbasket.href").ignored()
}; };
@ -256,7 +251,6 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
subsectionWithPath("distributionTargets") subsectionWithPath("distributionTargets")
.description("An array of <<workbasket-subset, workbasket subsets>>"), .description("An array of <<workbasket-subset, workbasket subsets>>"),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("_links.self.href").ignored(),
fieldWithPath("_links.workbasket.href").ignored()
}; };
createWorkbasketFieldDescriptors = createWorkbasketFieldDescriptors =
@ -322,8 +316,8 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
workbasketFieldDescriptionsMap.get("_links.removeDistributionTargets.href")) workbasketFieldDescriptionsMap.get("_links.removeDistributionTargets.href"))
.type("String") .type("String")
.optional(), .optional(),
fieldWithPath("_links.accessItems.href") fieldWithPath("_links." + PROPERTY_NAME + ".href")
.description(workbasketFieldDescriptionsMap.get("_links.accessItems.href")) .description(workbasketFieldDescriptionsMap.get("_links." + PROPERTY_NAME + ".href"))
.type("String") .type("String")
.optional(), .optional(),
fieldWithPath("_links.allWorkbaskets.href") fieldWithPath("_links.allWorkbaskets.href")

View File

@ -7,7 +7,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.AccessIdRepresentationModel;
/** /**
* Implementation of LdapCache used for Unit tests. * Implementation of LdapCache used for Unit tests.
@ -16,284 +16,292 @@ import pro.taskana.rest.resource.AccessIdResource;
*/ */
public class LdapCacheTestImpl implements LdapCache { public class LdapCacheTestImpl implements LdapCache {
/** private final List<AccessIdRepresentationModel> accessIds =
* Dictionary is a {@link Map} collection that contains {@link AccessIdResource} as key (user) and
* {@link List} as value (groups of which the user is a member) .
*/
private Map<AccessIdResource, List<AccessIdResource>> users;
private List<AccessIdResource> accessIds =
new ArrayList<>( new ArrayList<>(
Arrays.asList( Arrays.asList(
new AccessIdResource("Martin, Rojas Miguel Angel", "user_1_1"), new AccessIdRepresentationModel("Martin, Rojas Miguel Angel", "user_1_1"),
new AccessIdResource("Zorgati, Mustapha", "user_2_1"), new AccessIdRepresentationModel("Zorgati, Mustapha", "user_2_1"),
new AccessIdResource("Behrendt, Maximilian", "max"), new AccessIdRepresentationModel("Behrendt, Maximilian", "max"),
new AccessIdResource("Bert, Ali", "teamlead_5"), new AccessIdRepresentationModel("Bert, Ali", "teamlead_5"),
new AccessIdResource("Hagen, Holger", "teamlead_3"), new AccessIdRepresentationModel("Hagen, Holger", "teamlead_3"),
new AccessIdResource("Breier, Bernd", "user_2_2"), new AccessIdRepresentationModel("Breier, Bernd", "user_2_2"),
new AccessIdResource("Fielmalz, Anke", "user017"), new AccessIdRepresentationModel("Fielmalz, Anke", "user017"),
new AccessIdResource("Mente, Maximilian", "max_mente"), new AccessIdRepresentationModel("Mente, Maximilian", "max_mente"),
new AccessIdResource("Theke, Bernd", "user_2_3"), new AccessIdRepresentationModel("Theke, Bernd", "user_2_3"),
new AccessIdResource("Ferrante, Elena", "elena"), new AccessIdRepresentationModel("Ferrante, Elena", "elena"),
new AccessIdResource("Mueller, Simone", "simone"), new AccessIdRepresentationModel("Mueller, Simone", "simone"),
new AccessIdResource("Sirup, Aaron", "user001"), new AccessIdRepresentationModel("Sirup, Aaron", "user001"),
new AccessIdResource("Nacho, recuerda", "user_1_2"), new AccessIdRepresentationModel("Nacho, recuerda", "user_1_2"),
new AccessIdResource("Lass, Ada", "user003"), new AccessIdRepresentationModel("Lass, Ada", "user003"),
new AccessIdResource("Tion, Addi", "user004"), new AccessIdRepresentationModel("Tion, Addi", "user004"),
new AccessIdResource("Lette, Adi", "user005"), new AccessIdRepresentationModel("Lette, Adi", "user005"),
new AccessIdResource("Admin", "teamlead_2"), new AccessIdRepresentationModel("Admin", "teamlead_2"),
new AccessIdResource("Native, Alter", "user006"), new AccessIdRepresentationModel("Native, Alter", "user006"),
new AccessIdResource("Herum, Albert", "user007"), new AccessIdRepresentationModel("Herum, Albert", "user007"),
new AccessIdResource("Meyer, Dominik", "teamlead_1"), new AccessIdRepresentationModel("Meyer, Dominik", "teamlead_1"),
new AccessIdResource("Mente, Ali", "user009"), new AccessIdRepresentationModel("Mente, Ali", "user009"),
new AccessIdResource("Nach, Alma", "user011"), new AccessIdRepresentationModel("Nach, Alma", "user011"),
new AccessIdResource("Gehzauch, Anders", "user012"), new AccessIdRepresentationModel("Gehzauch, Anders", "user012"),
new AccessIdResource("Theke, Andi", "user013"), new AccessIdRepresentationModel("Theke, Andi", "user013"),
new AccessIdResource("Kreuz, Andreas", "user014"), new AccessIdRepresentationModel("Kreuz, Andreas", "user014"),
new AccessIdResource("Tiefsee, Anka", "user016"), new AccessIdRepresentationModel("Tiefsee, Anka", "user016"),
new AccessIdResource("Fassen, Ann", "user018"), new AccessIdRepresentationModel("Fassen, Ann", "user018"),
new AccessIdResource("Probe, Ann", "user019"), new AccessIdRepresentationModel("Probe, Ann", "user019"),
new AccessIdResource("Bolika, Anna", "user020"), new AccessIdRepresentationModel("Bolika, Anna", "user020"),
new AccessIdResource("Ecke, Anna", "user021"), new AccessIdRepresentationModel("Ecke, Anna", "user021"),
new AccessIdResource("Hosi, Anna", "user022"), new AccessIdRepresentationModel("Hosi, Anna", "user022"),
new AccessIdResource("Kronis-Tisch, Anna", "user023"), new AccessIdRepresentationModel("Kronis-Tisch, Anna", "user023"),
new AccessIdResource("Logie, Anna", "user024"), new AccessIdRepresentationModel("Logie, Anna", "user024"),
new AccessIdResource("Luehse, Anna", "user025"), new AccessIdRepresentationModel("Luehse, Anna", "user025"),
new AccessIdResource("Nass, Anna", "user026"), new AccessIdRepresentationModel("Nass, Anna", "user026"),
new AccessIdResource("Thalb, Anna", "user027"), new AccessIdRepresentationModel("Thalb, Anna", "user027"),
new AccessIdResource("Tomie, Anna", "user028"), new AccessIdRepresentationModel("Tomie, Anna", "user028"),
new AccessIdResource("Donnich, Anne", "user029"), new AccessIdRepresentationModel("Donnich, Anne", "user029"),
new AccessIdResource("Kaffek, Anne", "user030"), new AccessIdRepresentationModel("Kaffek, Anne", "user030"),
new AccessIdResource("Thek, Anne", "user031"), new AccessIdRepresentationModel("Thek, Anne", "user031"),
new AccessIdResource("Matoer, Anni", "user032"), new AccessIdRepresentationModel("Matoer, Anni", "user032"),
new AccessIdResource("Ragentor, Ansgar", "user033"), new AccessIdRepresentationModel("Ragentor, Ansgar", "user033"),
new AccessIdResource("Stoteles, Ari", "user034"), new AccessIdRepresentationModel("Stoteles, Ari", "user034"),
new AccessIdResource("Thmetik, Ari", "user035"), new AccessIdRepresentationModel("Thmetik, Ari", "user035"),
new AccessIdResource("Nuehm, Arno", "user036"), new AccessIdRepresentationModel("Nuehm, Arno", "user036"),
new AccessIdResource("Schocke, Artie", "user037"), new AccessIdRepresentationModel("Schocke, Artie", "user037"),
new AccessIdResource("Stoppel, Bart", "user038"), new AccessIdRepresentationModel("Stoppel, Bart", "user038"),
new AccessIdResource("Beitung, Bea", "user039"), new AccessIdRepresentationModel("Beitung, Bea", "user039"),
new AccessIdResource("Ildich, Bea", "user040"), new AccessIdRepresentationModel("Ildich, Bea", "user040"),
new AccessIdResource("Vista, Bella", "user041"), new AccessIdRepresentationModel("Vista, Bella", "user041"),
new AccessIdResource("Utzer, Ben", "user042"), new AccessIdRepresentationModel("Utzer, Ben", "user042"),
new AccessIdResource("Zien, Ben", "user043"), new AccessIdRepresentationModel("Zien, Ben", "user043"),
new AccessIdResource("Stein, Bernd", "user044"), new AccessIdRepresentationModel("Stein, Bernd", "user044"),
new AccessIdResource("Deramen, Bill", "user045"), new AccessIdRepresentationModel("Deramen, Bill", "user045"),
new AccessIdResource("Honig, Bine", "user046"), new AccessIdRepresentationModel("Honig, Bine", "user046"),
new AccessIdResource("Densatz, Bo", "user047"), new AccessIdRepresentationModel("Densatz, Bo", "user047"),
new AccessIdResource("Densee, Bo", "user048"), new AccessIdRepresentationModel("Densee, Bo", "user048"),
new AccessIdResource("Lerwagen, Bo", "user049"), new AccessIdRepresentationModel("Lerwagen, Bo", "user049"),
new AccessIdResource("Tail, Bob", "user050"), new AccessIdRepresentationModel("Tail, Bob", "user050"),
new AccessIdResource("Ketta, Bruce", "user051"), new AccessIdRepresentationModel("Ketta, Bruce", "user051"),
new AccessIdResource("Terrie, Bud", "user052"), new AccessIdRepresentationModel("Terrie, Bud", "user052"),
new AccessIdResource("Biener-Haken, Cara", "user053"), new AccessIdRepresentationModel("Biener-Haken, Cara", "user053"),
new AccessIdResource("Ass, Caro", "user054"), new AccessIdRepresentationModel("Ass, Caro", "user054"),
new AccessIdResource("Kaffee, Caro", "user055"), new AccessIdRepresentationModel("Kaffee, Caro", "user055"),
new AccessIdResource("Linger, Caro", "user056"), new AccessIdRepresentationModel("Linger, Caro", "user056"),
new AccessIdResource("tenSaft, Caro", "user057"), new AccessIdRepresentationModel("tenSaft, Caro", "user057"),
new AccessIdResource("Antheme, Chris", "user058"), new AccessIdRepresentationModel("Antheme, Chris", "user058"),
new AccessIdResource("Baum, Chris", "user059"), new AccessIdRepresentationModel("Baum, Chris", "user059"),
new AccessIdResource("Tall, Chris", "user060"), new AccessIdRepresentationModel("Tall, Chris", "user060"),
new AccessIdResource("Reiniger, Claas", "user061"), new AccessIdRepresentationModel("Reiniger, Claas", "user061"),
new AccessIdResource("Grube, Claire", "user062"), new AccessIdRepresentationModel("Grube, Claire", "user062"),
new AccessIdResource("Fall, Clara", "user063"), new AccessIdRepresentationModel("Fall, Clara", "user063"),
new AccessIdResource("Korn, Clara", "user064"), new AccessIdRepresentationModel("Korn, Clara", "user064"),
new AccessIdResource("Lenriff, Cora", "user065"), new AccessIdRepresentationModel("Lenriff, Cora", "user065"),
new AccessIdResource("Schiert, Cora", "user066"), new AccessIdRepresentationModel("Schiert, Cora", "user066"),
new AccessIdResource("Hose, Cord", "user067"), new AccessIdRepresentationModel("Hose, Cord", "user067"),
new AccessIdResource("Onbleu, Cord", "user068"), new AccessIdRepresentationModel("Onbleu, Cord", "user068"),
new AccessIdResource("Umkleide, Damon", "user069"), new AccessIdRepresentationModel("Umkleide, Damon", "user069"),
new AccessIdResource("Affier, Dean", "user070"), new AccessIdRepresentationModel("Affier, Dean", "user070"),
new AccessIdResource("Orm, Dean", "user071"), new AccessIdRepresentationModel("Orm, Dean", "user071"),
new AccessIdResource("Platz, Dennis", "user072"), new AccessIdRepresentationModel("Platz, Dennis", "user072"),
new AccessIdResource("Milch, Dick", "user073"), new AccessIdRepresentationModel("Milch, Dick", "user073"),
new AccessIdResource("Mow, Dina", "user074"), new AccessIdRepresentationModel("Mow, Dina", "user074"),
new AccessIdResource("Keil, Donna", "user075"), new AccessIdRepresentationModel("Keil, Donna", "user075"),
new AccessIdResource("Littchen, Donna", "user076"), new AccessIdRepresentationModel("Littchen, Donna", "user076"),
new AccessIdResource("Wetter, Donna", "user077"), new AccessIdRepresentationModel("Wetter, Donna", "user077"),
new AccessIdResource("Was, Ed", "user078"), new AccessIdRepresentationModel("Was, Ed", "user078"),
new AccessIdResource("Khar, Ede", "user079"), new AccessIdRepresentationModel("Khar, Ede", "user079"),
new AccessIdResource("Nut, Ella", "user080"), new AccessIdRepresentationModel("Nut, Ella", "user080"),
new AccessIdResource("Stisch, Ella", "user081"), new AccessIdRepresentationModel("Stisch, Ella", "user081"),
new AccessIdResource("Diel, Emma", "user082"), new AccessIdRepresentationModel("Diel, Emma", "user082"),
new AccessIdResource("Herdamit, Emma", "user083"), new AccessIdRepresentationModel("Herdamit, Emma", "user083"),
new AccessIdResource("Mitter-Uhe, Emma", "user084"), new AccessIdRepresentationModel("Mitter-Uhe, Emma", "user084"),
new AccessIdResource("Tatt, Erich", "user085"), new AccessIdRepresentationModel("Tatt, Erich", "user085"),
new AccessIdResource("Drigend, Ernie", "user086"), new AccessIdRepresentationModel("Drigend, Ernie", "user086"),
new AccessIdResource("Poly, Esther", "user087"), new AccessIdRepresentationModel("Poly, Esther", "user087"),
new AccessIdResource("Trautz, Eugen", "user088"), new AccessIdRepresentationModel("Trautz, Eugen", "user088"),
new AccessIdResource("Quiert, Eva", "user089"), new AccessIdRepresentationModel("Quiert, Eva", "user089"),
new AccessIdResource("Inurlaub, Fatma", "user090"), new AccessIdRepresentationModel("Inurlaub, Fatma", "user090"),
new AccessIdResource("Land, Finn", "user091"), new AccessIdRepresentationModel("Land, Finn", "user091"),
new AccessIdResource("Sternis, Finn", "user092"), new AccessIdRepresentationModel("Sternis, Finn", "user092"),
new AccessIdResource("Furt, Frank", "user093"), new AccessIdRepresentationModel("Furt, Frank", "user093"),
new AccessIdResource("Reich, Frank", "user094"), new AccessIdRepresentationModel("Reich, Frank", "user094"),
new AccessIdResource("Iskaner, Franz", "user095"), new AccessIdRepresentationModel("Iskaner, Franz", "user095"),
new AccessIdResource("Nerr, Franziska", "user096"), new AccessIdRepresentationModel("Nerr, Franziska", "user096"),
new AccessIdResource("Zafen, Friedrich", "user097"), new AccessIdRepresentationModel("Zafen, Friedrich", "user097"),
new AccessIdResource("Pomm, Fritz", "user098"), new AccessIdRepresentationModel("Pomm, Fritz", "user098"),
new AccessIdResource("deWegs, Gera", "user099"), new AccessIdRepresentationModel("deWegs, Gera", "user099"),
new AccessIdResource("Staebe, Gitta", "user100"), new AccessIdRepresentationModel("Staebe, Gitta", "user100"),
new AccessIdResource("Zend, Glenn", "user101"), new AccessIdRepresentationModel("Zend, Glenn", "user101"),
new AccessIdResource("Fisch, Grete", "user102"), new AccessIdRepresentationModel("Fisch, Grete", "user102"),
new AccessIdResource("Zucker, Gus", "user103"), new AccessIdRepresentationModel("Zucker, Gus", "user103"),
new AccessIdResource("Muhn, Hanni", "user104"), new AccessIdRepresentationModel("Muhn, Hanni", "user104"),
new AccessIdResource("Fermesse, Hanno", "user105"), new AccessIdRepresentationModel("Fermesse, Hanno", "user105"),
new AccessIdResource("Aplast, Hans", "user106"), new AccessIdRepresentationModel("Aplast, Hans", "user106"),
new AccessIdResource("Eart, Hans", "user107"), new AccessIdRepresentationModel("Eart, Hans", "user107"),
new AccessIdResource("Back, Hardy", "user108"), new AccessIdRepresentationModel("Back, Hardy", "user108"),
new AccessIdResource("Beau, Harry", "user109"), new AccessIdRepresentationModel("Beau, Harry", "user109"),
new AccessIdResource("Kraut, Heide", "user110"), new AccessIdRepresentationModel("Kraut, Heide", "user110"),
new AccessIdResource("Witzka, Heide", "user111"), new AccessIdRepresentationModel("Witzka, Heide", "user111"),
new AccessIdResource("Buchen, Hein", "user112"), new AccessIdRepresentationModel("Buchen, Hein", "user112"),
new AccessIdResource("Lichkeit, Hein", "user113"), new AccessIdRepresentationModel("Lichkeit, Hein", "user113"),
new AccessIdResource("Suchung, Hein", "user114"), new AccessIdRepresentationModel("Suchung, Hein", "user114"),
new AccessIdResource("Ellmann, Heinz", "user115"), new AccessIdRepresentationModel("Ellmann, Heinz", "user115"),
new AccessIdResource("Ketchup, Heinz", "user116"), new AccessIdRepresentationModel("Ketchup, Heinz", "user116"),
new AccessIdResource("Zeim, Hilde", "user117"), new AccessIdRepresentationModel("Zeim, Hilde", "user117"),
new AccessIdResource("Bilien, Immo", "user118"), new AccessIdRepresentationModel("Bilien, Immo", "user118"),
new AccessIdResource("Her, Inge", "user119"), new AccessIdRepresentationModel("Her, Inge", "user119"),
new AccessIdResource("Wahrsam, Inge", "user120"), new AccessIdRepresentationModel("Wahrsam, Inge", "user120"),
new AccessIdResource("Flamm, Ingo", "user121"), new AccessIdRepresentationModel("Flamm, Ingo", "user121"),
new AccessIdResource("Enzien, Ingrid", "user122"), new AccessIdRepresentationModel("Enzien, Ingrid", "user122"),
new AccessIdResource("Rohsch, Inken", "user123"), new AccessIdRepresentationModel("Rohsch, Inken", "user123"),
new AccessIdResource("Ihr, Insa", "user124"), new AccessIdRepresentationModel("Ihr, Insa", "user124"),
new AccessIdResource("Nerda, Iska", "user125"), new AccessIdRepresentationModel("Nerda, Iska", "user125"),
new AccessIdResource("Eitz, Jens", "user126"), new AccessIdRepresentationModel("Eitz, Jens", "user126"),
new AccessIdResource("Nastik, Jim", "user127"), new AccessIdRepresentationModel("Nastik, Jim", "user127"),
new AccessIdResource("Gurt, Jo", "user128"), new AccessIdRepresentationModel("Gurt, Jo", "user128"),
new AccessIdResource("Kurrth, Jo", "user129"), new AccessIdRepresentationModel("Kurrth, Jo", "user129"),
new AccessIdResource("Kolade, Joe", "user130"), new AccessIdRepresentationModel("Kolade, Joe", "user130"),
new AccessIdResource("Iter, Johann", "user131"), new AccessIdRepresentationModel("Iter, Johann", "user131"),
new AccessIdResource("Tick, Joyce", "user132"), new AccessIdRepresentationModel("Tick, Joyce", "user132"),
new AccessIdResource("Case, Justin", "user133"), new AccessIdRepresentationModel("Case, Justin", "user133"),
new AccessIdResource("Time, Justin", "user134"), new AccessIdRepresentationModel("Time, Justin", "user134"),
new AccessIdResource("Komp, Jutta", "user135"), new AccessIdRepresentationModel("Komp, Jutta", "user135"),
new AccessIdResource("Mauer, Kai", "user136"), new AccessIdRepresentationModel("Mauer, Kai", "user136"),
new AccessIdResource("Pirinja, Kai", "user137"), new AccessIdRepresentationModel("Pirinja, Kai", "user137"),
new AccessIdResource("Serpfalz, Kai", "user138"), new AccessIdRepresentationModel("Serpfalz, Kai", "user138"),
new AccessIdResource("Auer, Karl", "user139"), new AccessIdRepresentationModel("Auer, Karl", "user139"),
new AccessIdResource("Ielauge, Karl", "user140"), new AccessIdRepresentationModel("Ielauge, Karl", "user140"),
new AccessIdResource("Ifornjen, Karl", "user141"), new AccessIdRepresentationModel("Ifornjen, Karl", "user141"),
new AccessIdResource("Radi, Karl", "user142"), new AccessIdRepresentationModel("Radi, Karl", "user142"),
new AccessIdResource("Verti, Karl", "user143"), new AccessIdRepresentationModel("Verti, Karl", "user143"),
new AccessIdResource("Sery, Karo", "user144"), new AccessIdRepresentationModel("Sery, Karo", "user144"),
new AccessIdResource("Lisator, Katha", "user145"), new AccessIdRepresentationModel("Lisator, Katha", "user145"),
new AccessIdResource("Flo, Kati", "user146"), new AccessIdRepresentationModel("Flo, Kati", "user146"),
new AccessIdResource("Schenn, Knut", "user147"), new AccessIdRepresentationModel("Schenn, Knut", "user147"),
new AccessIdResource("Achse, Kurt", "user148"), new AccessIdRepresentationModel("Achse, Kurt", "user148"),
new AccessIdResource("Zepause, Kurt", "user149"), new AccessIdRepresentationModel("Zepause, Kurt", "user149"),
new AccessIdResource("Zerr, Kurt", "user150"), new AccessIdRepresentationModel("Zerr, Kurt", "user150"),
new AccessIdResource("Reden, Lasse", "user151"), new AccessIdRepresentationModel("Reden, Lasse", "user151"),
new AccessIdResource("Metten, Lee", "user152"), new AccessIdRepresentationModel("Metten, Lee", "user152"),
new AccessIdResource("Arm, Lene", "user153"), new AccessIdRepresentationModel("Arm, Lene", "user153"),
new AccessIdResource("Thur, Linnea", "user154"), new AccessIdRepresentationModel("Thur, Linnea", "user154"),
new AccessIdResource("Bonn, Lisa", "user155"), new AccessIdRepresentationModel("Bonn, Lisa", "user155"),
new AccessIdResource("Sembourg, Luc", "user156"), new AccessIdRepresentationModel("Sembourg, Luc", "user156"),
new AccessIdResource("Rung, Lucky", "user157"), new AccessIdRepresentationModel("Rung, Lucky", "user157"),
new AccessIdResource("Zafen, Ludwig", "user158"), new AccessIdRepresentationModel("Zafen, Ludwig", "user158"),
new AccessIdResource("Hauden, Lukas", "user159"), new AccessIdRepresentationModel("Hauden, Lukas", "user159"),
new AccessIdResource("Hose, Lutz", "user160"), new AccessIdRepresentationModel("Hose, Lutz", "user160"),
new AccessIdResource("Tablette, Lutz", "user161"), new AccessIdRepresentationModel("Tablette, Lutz", "user161"),
new AccessIdResource("Fehr, Luzie", "user162"), new AccessIdRepresentationModel("Fehr, Luzie", "user162"),
new AccessIdResource("Nalyse, Magda", "user163"), new AccessIdRepresentationModel("Nalyse, Magda", "user163"),
new AccessIdResource("Ehfer, Maik", "user164"), new AccessIdRepresentationModel("Ehfer, Maik", "user164"),
new AccessIdResource("Sehr, Malte", "user165"), new AccessIdRepresentationModel("Sehr, Malte", "user165"),
new AccessIdResource("Thon, Mara", "user166"), new AccessIdRepresentationModel("Thon, Mara", "user166"),
new AccessIdResource("Quark, Marga", "user167"), new AccessIdRepresentationModel("Quark, Marga", "user167"),
new AccessIdResource("Nade, Marie", "user168"), new AccessIdRepresentationModel("Nade, Marie", "user168"),
new AccessIdResource("Niert, Marie", "user169"), new AccessIdRepresentationModel("Niert, Marie", "user169"),
new AccessIdResource("Neese, Mario", "user170"), new AccessIdRepresentationModel("Neese, Mario", "user170"),
new AccessIdResource("Nette, Marion", "user171"), new AccessIdRepresentationModel("Nette, Marion", "user171"),
new AccessIdResource("Nesium, Mark", "user172"), new AccessIdRepresentationModel("Nesium, Mark", "user172"),
new AccessIdResource("Thalle, Mark", "user173"), new AccessIdRepresentationModel("Thalle, Mark", "user173"),
new AccessIdResource("Diven, Marle", "user174"), new AccessIdRepresentationModel("Diven, Marle", "user174"),
new AccessIdResource("Fitz, Marle", "user175"), new AccessIdRepresentationModel("Fitz, Marle", "user175"),
new AccessIdResource("Pfahl, Marta", "user176"), new AccessIdRepresentationModel("Pfahl, Marta", "user176"),
new AccessIdResource("Zorn, Martin", "user177"), new AccessIdRepresentationModel("Zorn, Martin", "user177"),
new AccessIdResource("Krissmes, Mary", "user178"), new AccessIdRepresentationModel("Krissmes, Mary", "user178"),
new AccessIdResource("Jess, Matt", "user179"), new AccessIdRepresentationModel("Jess, Matt", "user179"),
new AccessIdResource("Strammer, Max", "user180"), new AccessIdRepresentationModel("Strammer, Max", "user180"),
new AccessIdResource("Mumm, Maxi", "user181"), new AccessIdRepresentationModel("Mumm, Maxi", "user181"),
new AccessIdResource("Morphose, Meta", "user182"), new AccessIdRepresentationModel("Morphose, Meta", "user182"),
new AccessIdResource("Uh, Mia", "user183"), new AccessIdRepresentationModel("Uh, Mia", "user183"),
new AccessIdResource("Rofon, Mike", "user184"), new AccessIdRepresentationModel("Rofon, Mike", "user184"),
new AccessIdResource("Rosoft, Mike", "user185"), new AccessIdRepresentationModel("Rosoft, Mike", "user185"),
new AccessIdResource("Liter, Milli", "user186"), new AccessIdRepresentationModel("Liter, Milli", "user186"),
new AccessIdResource("Thär, Milli", "user187"), new AccessIdRepresentationModel("Thär, Milli", "user187"),
new AccessIdResource("Welle, Mirko", "user188"), new AccessIdRepresentationModel("Welle, Mirko", "user188"),
new AccessIdResource("Thorat, Mo", "user189"), new AccessIdRepresentationModel("Thorat, Mo", "user189"),
new AccessIdResource("Thor, Moni", "user190"), new AccessIdRepresentationModel("Thor, Moni", "user190"),
new AccessIdResource("Kinolta, Monika", "user191"), new AccessIdRepresentationModel("Kinolta, Monika", "user191"),
new AccessIdResource("Mundhaar, Monika", "user192"), new AccessIdRepresentationModel("Mundhaar, Monika", "user192"),
new AccessIdResource("Munter, Monika", "user193"), new AccessIdRepresentationModel("Munter, Monika", "user193"),
new AccessIdResource("Zwerg, Nat", "user194"), new AccessIdRepresentationModel("Zwerg, Nat", "user194"),
new AccessIdResource("Elmine, Nick", "user195"), new AccessIdRepresentationModel("Elmine, Nick", "user195"),
new AccessIdResource("Thien, Niko", "user196"), new AccessIdRepresentationModel("Thien, Niko", "user196"),
new AccessIdResource("Pferd, Nils", "user197"), new AccessIdRepresentationModel("Pferd, Nils", "user197"),
new AccessIdResource("Lerweise, Norma", "user198"), new AccessIdRepresentationModel("Lerweise, Norma", "user198"),
new AccessIdResource("Motor, Otto", "user199"), new AccessIdRepresentationModel("Motor, Otto", "user199"),
new AccessIdResource("Totol, Otto", "user200"), new AccessIdRepresentationModel("Totol, Otto", "user200"),
new AccessIdResource("Nerr, Paula", "user201"), new AccessIdRepresentationModel("Nerr, Paula", "user201"),
new AccessIdResource("Imeter, Peer", "user202"), new AccessIdRepresentationModel("Imeter, Peer", "user202"),
new AccessIdResource("Serkatze, Peer", "user203"), new AccessIdRepresentationModel("Serkatze, Peer", "user203"),
new AccessIdResource("Gogisch, Peter", "user204"), new AccessIdRepresentationModel("Gogisch, Peter", "user204"),
new AccessIdResource("Silje, Peter", "user205"), new AccessIdRepresentationModel("Silje, Peter", "user205"),
new AccessIdResource("Harmonie, Phil", "user206"), new AccessIdRepresentationModel("Harmonie, Phil", "user206"),
new AccessIdResource("Ihnen, Philip", "user207"), new AccessIdRepresentationModel("Ihnen, Philip", "user207"),
new AccessIdResource("Uto, Pia", "user208"), new AccessIdRepresentationModel("Uto, Pia", "user208"),
new AccessIdResource("Kothek, Pina", "user209"), new AccessIdRepresentationModel("Kothek, Pina", "user209"),
new AccessIdResource("Zar, Pit", "user210"), new AccessIdRepresentationModel("Zar, Pit", "user210"),
new AccessIdResource("Zeih, Polly", "user211"), new AccessIdRepresentationModel("Zeih, Polly", "user211"),
new AccessIdResource("Tswan, Puh", "user212"), new AccessIdRepresentationModel("Tswan, Puh", "user212"),
new AccessIdResource("Zufall, Rainer", "user213"), new AccessIdRepresentationModel("Zufall, Rainer", "user213"),
new AccessIdResource("Lien, Rita", "user214"), new AccessIdRepresentationModel("Lien, Rita", "user214"),
new AccessIdResource("Held, Roman", "user215"), new AccessIdRepresentationModel("Held, Roman", "user215"),
new AccessIdResource("Haar, Ross", "user216"), new AccessIdRepresentationModel("Haar, Ross", "user216"),
new AccessIdResource("Dick, Roy", "user217"), new AccessIdRepresentationModel("Dick, Roy", "user217"),
new AccessIdResource("Enplaner, Ruth", "user218"), new AccessIdRepresentationModel("Enplaner, Ruth", "user218"),
new AccessIdResource("Kommen, Ryan", "user219"), new AccessIdRepresentationModel("Kommen, Ryan", "user219"),
new AccessIdResource("Philo, Sophie", "user220"), new AccessIdRepresentationModel("Philo, Sophie", "user220"),
new AccessIdResource("Matisier, Stig", "user221"), new AccessIdRepresentationModel("Matisier, Stig", "user221"),
new AccessIdResource("Loniki, Tessa", "user222"), new AccessIdRepresentationModel("Loniki, Tessa", "user222"),
new AccessIdResource("Tralisch, Thea", "user223"), new AccessIdRepresentationModel("Tralisch, Thea", "user223"),
new AccessIdResource("Logie, Theo", "user224"), new AccessIdRepresentationModel("Logie, Theo", "user224"),
new AccessIdResource("Ister, Thorn", "user225"), new AccessIdRepresentationModel("Ister, Thorn", "user225"),
new AccessIdResource("Buktu, Tim", "user226"), new AccessIdRepresentationModel("Buktu, Tim", "user226"),
new AccessIdResource("Ate, Tom", "user227"), new AccessIdRepresentationModel("Ate, Tom", "user227"),
new AccessIdResource("Pie, Udo", "user228"), new AccessIdRepresentationModel("Pie, Udo", "user228"),
new AccessIdResource("Aloe, Vera", "user229"), new AccessIdRepresentationModel("Aloe, Vera", "user229"),
new AccessIdResource("Hausver, Walter", "user230"), new AccessIdRepresentationModel("Hausver, Walter", "user230"),
new AccessIdResource("Schuh, Wanda", "user231"), new AccessIdRepresentationModel("Schuh, Wanda", "user231"),
new AccessIdResource("Rahm, Wolf", "user232"), new AccessIdRepresentationModel("Rahm, Wolf", "user232"),
new AccessIdResource("businessadmin", "cn=businessadmin,ou=groups,o=taskanatest"), new AccessIdRepresentationModel(
new AccessIdResource("UsersGroup", "cn=usersgroup,ou=groups,o=taskanatest"), "businessadmin", "cn=businessadmin,ou=groups,o=taskanatest"),
new AccessIdResource("DevelopersGroup", "cn=developersgroup,ou=groups,o=taskanatest"), new AccessIdRepresentationModel(
new AccessIdResource("businessadmin", "cn=customersgroup,ou=groups,o=taskanatest"), "UsersGroup", "cn=usersgroup,ou=groups,o=taskanatest"),
new AccessIdResource("user_domain_A", "cn=user_domain_a,ou=groups,o=taskanatest"), new AccessIdRepresentationModel(
new AccessIdResource("monitor", "cn=monitor,ou=groups,o=taskanatest"), "DevelopersGroup", "cn=developersgroup,ou=groups,o=taskanatest"),
new AccessIdResource("user_domain_C", "cn=user_domain_c,ou=groups,o=taskanatest"), new AccessIdRepresentationModel(
new AccessIdResource("user_domain_D", "cn=user_domain_d,ou=groups,o=taskanatest"), "businessadmin", "cn=customersgroup,ou=groups,o=taskanatest"),
new AccessIdResource("admin", "cn=admin,ou=groups,o=taskanatest"), new AccessIdRepresentationModel(
new AccessIdResource( "user_domain_A", "cn=user_domain_a,ou=groups,o=taskanatest"),
new AccessIdRepresentationModel("monitor", "cn=monitor,ou=groups,o=taskanatest"),
new AccessIdRepresentationModel(
"user_domain_C", "cn=user_domain_c,ou=groups,o=taskanatest"),
new AccessIdRepresentationModel(
"user_domain_D", "cn=user_domain_d,ou=groups,o=taskanatest"),
new AccessIdRepresentationModel("admin", "cn=admin,ou=groups,o=taskanatest"),
new AccessIdRepresentationModel(
"manager_domain_B", "cn=manager_domain_b,ou=groups,o=taskanatest"), "manager_domain_B", "cn=manager_domain_b,ou=groups,o=taskanatest"),
new AccessIdResource( new AccessIdRepresentationModel(
"manager_domain_C", "cn=manager_domain_c,ou=groups,o=taskanatest"), "manager_domain_C", "cn=manager_domain_c,ou=groups,o=taskanatest"),
new AccessIdResource( new AccessIdRepresentationModel(
"manager_domain_D", "cn=manager_domain_d,ou=groups,o=taskanatest"), "manager_domain_D", "cn=manager_domain_d,ou=groups,o=taskanatest"),
new AccessIdResource("teamlead_2", "cn=teamlead_2" + ",ou=groups,o=taskanatest"), new AccessIdRepresentationModel(
new AccessIdResource("teamlead_4", "cn=teamlead_4" + ",ou=groups,o=taskanatest"), "teamlead_2", "cn=teamlead_2" + ",ou=groups,o=taskanatest"),
new AccessIdResource("team_3", "cn=team_3" + ",ou=groups,o=taskanatest"), new AccessIdRepresentationModel(
new AccessIdResource("team_4", "cn=team_4" + ",ou=groups,o=taskanatest"))); "teamlead_4", "cn=teamlead_4" + ",ou=groups,o=taskanatest"),
new AccessIdRepresentationModel("team_3", "cn=team_3" + ",ou=groups,o=taskanatest"),
new AccessIdRepresentationModel("team_4", "cn=team_4" + ",ou=groups,o=taskanatest")));
/**
* Dictionary is a {@link Map} collection that contains {@link AccessIdRepresentationModel} as key
* (user) and {@link List} as value (groups of which the user is a member) .
*/
private Map<AccessIdRepresentationModel, List<AccessIdRepresentationModel>> users;
@Override @Override
public List<AccessIdResource> findMatchingAccessId( public List<AccessIdRepresentationModel> findMatchingAccessId(
String searchFor, int maxNumberOfReturnedAccessIds) { String searchFor, int maxNumberOfReturnedAccessIds) {
return findAcessIdResource(searchFor, maxNumberOfReturnedAccessIds, false); return findAcessIdResource(searchFor, maxNumberOfReturnedAccessIds, false);
} }
@Override @Override
public List<AccessIdResource> findGroupsOfUser( public List<AccessIdRepresentationModel> findGroupsOfUser(
String searchFor, int maxNumberOfReturnedAccessIds) { String searchFor, int maxNumberOfReturnedAccessIds) {
if (users == null) { if (users == null) {
addUsersToGroups(); addUsersToGroups();
@ -302,15 +310,15 @@ public class LdapCacheTestImpl implements LdapCache {
} }
@Override @Override
public List<AccessIdResource> validateAccessId(String accessId) { public List<AccessIdRepresentationModel> validateAccessId(String accessId) {
return accessIds.stream() return accessIds.stream()
.filter(t -> (t.getAccessId().equalsIgnoreCase(accessId.toLowerCase()))) .filter(t -> (t.getAccessId().equalsIgnoreCase(accessId.toLowerCase())))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
private List<AccessIdResource> findAcessIdResource( private List<AccessIdRepresentationModel> findAcessIdResource(
String searchFor, int maxNumberOfReturnedAccessIds, boolean groupMember) { String searchFor, int maxNumberOfReturnedAccessIds, boolean groupMember) {
List<AccessIdResource> usersAndGroups = List<AccessIdRepresentationModel> usersAndGroups =
accessIds.stream() accessIds.stream()
.filter( .filter(
t -> t ->
@ -318,7 +326,7 @@ public class LdapCacheTestImpl implements LdapCache {
|| t.getAccessId().toLowerCase().contains(searchFor.toLowerCase()))) || t.getAccessId().toLowerCase().contains(searchFor.toLowerCase())))
.collect(Collectors.toList()); .collect(Collectors.toList());
List<AccessIdResource> usersAndGroupsAux = new ArrayList<>(usersAndGroups); List<AccessIdRepresentationModel> usersAndGroupsAux = new ArrayList<>(usersAndGroups);
if (groupMember) { if (groupMember) {
usersAndGroupsAux.forEach( usersAndGroupsAux.forEach(
item -> { item -> {
@ -329,18 +337,15 @@ public class LdapCacheTestImpl implements LdapCache {
} }
usersAndGroups.sort( usersAndGroups.sort(
(AccessIdResource a, AccessIdResource b) -> { (AccessIdRepresentationModel a, AccessIdRepresentationModel b) -> a.getAccessId()
return a.getAccessId().compareToIgnoreCase(b.getAccessId()); .compareToIgnoreCase(
}); b.getAccessId()));
List<AccessIdResource> result = return usersAndGroups.subList(0, Math.min(usersAndGroups.size(), maxNumberOfReturnedAccessIds));
usersAndGroups.subList(0, Math.min(usersAndGroups.size(), maxNumberOfReturnedAccessIds));
return result;
} }
private void addUsersToGroups() { private void addUsersToGroups() {
List<AccessIdResource> groups = new ArrayList<>(); List<AccessIdRepresentationModel> groups = new ArrayList<>();
users = new HashMap<>(); users = new HashMap<>();
accessIds.forEach( accessIds.forEach(
@ -353,12 +358,12 @@ public class LdapCacheTestImpl implements LdapCache {
}); });
int groupNumber = 0; int groupNumber = 0;
List<AccessIdResource> group0 = new ArrayList<>(); List<AccessIdRepresentationModel> group0 = new ArrayList<>();
List<AccessIdResource> group1 = new ArrayList<>(); List<AccessIdRepresentationModel> group1 = new ArrayList<>();
List<AccessIdResource> group2 = new ArrayList<>(); List<AccessIdRepresentationModel> group2 = new ArrayList<>();
List<AccessIdResource> group3 = new ArrayList<>(); List<AccessIdRepresentationModel> group3 = new ArrayList<>();
for (AccessIdResource group : groups) { for (AccessIdRepresentationModel group : groups) {
switch (groupNumber) { switch (groupNumber) {
case 0: case 0:
group0.add(group); group0.add(group);
@ -379,7 +384,7 @@ public class LdapCacheTestImpl implements LdapCache {
} }
int countUser = 0; int countUser = 0;
for (AccessIdResource item : accessIds) { for (AccessIdRepresentationModel item : accessIds) {
if (!item.getAccessId().contains("ou=groups")) { if (!item.getAccessId().contains("ou=groups")) {
switch (countUser) { switch (countUser) {
case 0: case 0:

View File

@ -26,7 +26,7 @@ import org.springframework.ldap.core.LdapTemplate;
import pro.taskana.common.api.exceptions.InvalidArgumentException; import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.SystemException; import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.AccessIdRepresentationModel;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
class LdapClientTest { class LdapClientTest {
@ -56,8 +56,8 @@ class LdapClientTest {
setUpEnvMock(); setUpEnvMock();
cut.init(); cut.init();
AccessIdResource group = new AccessIdResource("testG", "testGId"); AccessIdRepresentationModel group = new AccessIdRepresentationModel("testG", "testGId");
AccessIdResource user = new AccessIdResource("testU", "testUId"); AccessIdRepresentationModel user = new AccessIdRepresentationModel("testU", "testUId");
when(ldapTemplate.search( when(ldapTemplate.search(
any(String.class), any(), anyInt(), any(), any(LdapClient.GroupContextMapper.class))) any(String.class), any(), anyInt(), any(), any(LdapClient.GroupContextMapper.class)))
@ -89,9 +89,9 @@ class LdapClientTest {
setUpEnvMock(); setUpEnvMock();
cut.init(); cut.init();
List<AccessIdResource> result = List<AccessIdRepresentationModel> result =
IntStream.range(0, 100) IntStream.range(0, 100)
.mapToObj(i -> new AccessIdResource("" + i, "" + i)) .mapToObj(i -> new AccessIdRepresentationModel("" + i, "" + i))
.collect(Collectors.toList()); .collect(Collectors.toList());
assertThat(cut.getFirstPageOfaResultList(result)) assertThat(cut.getFirstPageOfaResultList(result))

View File

@ -19,7 +19,7 @@ import org.springframework.web.client.RestTemplate;
import pro.taskana.RestHelper; import pro.taskana.RestHelper;
import pro.taskana.TaskanaSpringBootTest; import pro.taskana.TaskanaSpringBootTest;
import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.AccessIdRepresentationModel;
@TaskanaSpringBootTest @TaskanaSpringBootTest
@ActiveProfiles({"test", "ldap"}) @ActiveProfiles({"test", "ldap"})
@ -63,18 +63,18 @@ class AccessIdControllerIntTest {
@Test @Test
void testGetMatches() { void testGetMatches() {
ResponseEntity<List<AccessIdResource>> response = ResponseEntity<List<AccessIdRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=rig", restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=rig",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(AccessIdListResource.class)); ParameterizedTypeReference.forType(AccessIdListResource.class));
List<AccessIdResource> body = response.getBody(); List<AccessIdRepresentationModel> body = response.getBody();
assertThat(body).isNotNull(); assertThat(body).isNotNull();
assertThat(body).hasSize(2); assertThat(body).hasSize(2);
assertThat(body) assertThat(body)
.extracting(AccessIdResource::getName) .extracting(AccessIdRepresentationModel::getName)
.containsExactlyInAnyOrder("Schläfrig, Tim", "Eifrig, Elena"); .containsExactlyInAnyOrder("Schläfrig, Tim", "Eifrig, Elena");
} }
@ -95,7 +95,7 @@ class AccessIdControllerIntTest {
.isEqualTo(HttpStatus.BAD_REQUEST); .isEqualTo(HttpStatus.BAD_REQUEST);
} }
static class AccessIdListResource extends ArrayList<AccessIdResource> { static class AccessIdListResource extends ArrayList<AccessIdRepresentationModel> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
} }

View File

@ -19,9 +19,9 @@ import org.springframework.web.client.RestTemplate;
import pro.taskana.RestHelper; import pro.taskana.RestHelper;
import pro.taskana.TaskanaSpringBootTest; import pro.taskana.TaskanaSpringBootTest;
import pro.taskana.rest.resource.ClassificationResource; import pro.taskana.rest.resource.ClassificationRepresentationModel;
import pro.taskana.rest.resource.ClassificationSummaryListResource; import pro.taskana.rest.resource.ClassificationSummaryRepresentationModel;
import pro.taskana.rest.resource.ClassificationSummaryResource; import pro.taskana.rest.resource.TaskanaPagedModel;
/** /**
* Test ClassificationController. * Test ClassificationController.
@ -31,18 +31,23 @@ import pro.taskana.rest.resource.ClassificationSummaryResource;
@TaskanaSpringBootTest @TaskanaSpringBootTest
class ClassificationControllerIntTest { class ClassificationControllerIntTest {
private static final ParameterizedTypeReference<
TaskanaPagedModel<ClassificationSummaryRepresentationModel>>
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE =
new ParameterizedTypeReference<
TaskanaPagedModel<ClassificationSummaryRepresentationModel>>() {};
static RestTemplate template = RestHelper.TEMPLATE; static RestTemplate template = RestHelper.TEMPLATE;
@Autowired RestHelper restHelper; @Autowired RestHelper restHelper;
@Test @Test
void testGetClassification() { void testGetClassification() {
ResponseEntity<ClassificationResource> response = ResponseEntity<ClassificationRepresentationModel> response =
template.exchange( template.exchange(
restHelper.toUrl( restHelper.toUrl(
Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000002"), Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000002"),
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getHeaders().getContentType().toString()) assertThat(response.getHeaders().getContentType().toString())
.isEqualTo(MediaTypes.HAL_JSON_VALUE); .isEqualTo(MediaTypes.HAL_JSON_VALUE);
@ -50,36 +55,36 @@ class ClassificationControllerIntTest {
@Test @Test
void testGetAllClassifications() { void testGetAllClassifications() {
ResponseEntity<ClassificationSummaryListResource> response = ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS), restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)); CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
} }
@Test @Test
void testGetAllClassificationsFilterByCustomAttribute() { void testGetAllClassificationsFilterByCustomAttribute() {
ResponseEntity<ClassificationSummaryListResource> response = ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?domain=DOMAIN_A&custom-1-like=RVNR", restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?domain=DOMAIN_A&custom-1-like=RVNR",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)); CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getBody().getContent()).hasSize(13); assertThat(response.getBody().getContent()).hasSize(13);
} }
@Test @Test
void testGetAllClassificationsKeepingFilters() { void testGetAllClassificationsKeepingFilters() {
ResponseEntity<ClassificationSummaryListResource> response = ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) restHelper.toUrl(Mapping.URL_CLASSIFICATIONS)
+ "?domain=DOMAIN_A&sort-by=key&order=asc", + "?domain=DOMAIN_A&sort-by=key&order=asc",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)); CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat( assertThat(
response response
@ -94,13 +99,13 @@ class ClassificationControllerIntTest {
@Test @Test
void testGetSecondPageSortedByKey() { void testGetSecondPageSortedByKey() {
ResponseEntity<ClassificationSummaryListResource> response = ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) restHelper.toUrl(Mapping.URL_CLASSIFICATIONS)
+ "?domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5", + "?domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)); CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getContent()).hasSize(5); assertThat(response.getBody().getContent()).hasSize(5);
assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("L1050"); assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("L1050");
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
@ -111,7 +116,7 @@ class ClassificationControllerIntTest {
.getHref() .getHref()
.endsWith( .endsWith(
"/api/v1/classifications?" "/api/v1/classifications?"
+ "domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5")) + "domain=DOMAIN_A&sort-by=key&order=asc&page-size=5&page=2"))
.isTrue(); .isTrue();
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull();
@ -127,12 +132,12 @@ class ClassificationControllerIntTest {
+ "\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\"," + "\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\","
+ "\"name\":\"new classification\",\"type\":\"TASK\"}"; + "\"name\":\"new classification\",\"type\":\"TASK\"}";
ResponseEntity<ClassificationResource> responseEntity = ResponseEntity<ClassificationRepresentationModel> responseEntity =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS), restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
HttpMethod.POST, HttpMethod.POST,
new HttpEntity<>(newClassification, restHelper.getHeaders()), new HttpEntity<>(newClassification, restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
assertThat(responseEntity).isNotNull(); assertThat(responseEntity).isNotNull();
assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode()); assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode());
@ -147,7 +152,7 @@ class ClassificationControllerIntTest {
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS), restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
HttpMethod.POST, HttpMethod.POST,
new HttpEntity<>(newClassification, restHelper.getHeaders()), new HttpEntity<>(newClassification, restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode()); assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode());
} }
@ -161,12 +166,12 @@ class ClassificationControllerIntTest {
+ "\"name\":\"new classification\",\"type\":\"TASK\"," + "\"name\":\"new classification\",\"type\":\"TASK\","
+ "\"parentId\":\"CLI:200000000000000000000000000000000015\"}"; + "\"parentId\":\"CLI:200000000000000000000000000000000015\"}";
ResponseEntity<ClassificationResource> responseEntity = ResponseEntity<ClassificationRepresentationModel> responseEntity =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS), restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
HttpMethod.POST, HttpMethod.POST,
new HttpEntity<>(newClassification, restHelper.getHeaders()), new HttpEntity<>(newClassification, restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
assertThat(responseEntity).isNotNull(); assertThat(responseEntity).isNotNull();
assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode()); assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode());
@ -181,12 +186,12 @@ class ClassificationControllerIntTest {
+ "\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\"," + "\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\","
+ "\"type\":\"TASK\",\"parentKey\":\"T2100\"}"; + "\"type\":\"TASK\",\"parentKey\":\"T2100\"}";
ResponseEntity<ClassificationResource> responseEntity = ResponseEntity<ClassificationRepresentationModel> responseEntity =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS), restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
HttpMethod.POST, HttpMethod.POST,
new HttpEntity<>(newClassification, restHelper.getHeaders()), new HttpEntity<>(newClassification, restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
assertThat(responseEntity).isNotNull(); assertThat(responseEntity).isNotNull();
assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode()); assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode());
@ -200,25 +205,26 @@ class ClassificationControllerIntTest {
+ "\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\"," + "\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\","
+ "\"type\":\"TASK\",\"parentKey\":\"T2100\"}"; + "\"type\":\"TASK\",\"parentKey\":\"T2100\"}";
ResponseEntity<ClassificationResource> responseEntity = ResponseEntity<ClassificationRepresentationModel> responseEntity =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS), restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
HttpMethod.POST, HttpMethod.POST,
new HttpEntity<>(newClassification, restHelper.getHeaders()), new HttpEntity<>(newClassification, restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
assertThat(responseEntity).isNotNull(); assertThat(responseEntity).isNotNull();
assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode()); assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode());
ResponseEntity<ClassificationSummaryListResource> response = ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS), restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)); CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
boolean foundClassificationCreated = false; boolean foundClassificationCreated = false;
for (ClassificationSummaryResource classification : response.getBody().getContent()) { for (ClassificationSummaryRepresentationModel classification :
response.getBody().getContent()) {
if ("NEW_CLASS_P2".equals(classification.getKey()) if ("NEW_CLASS_P2".equals(classification.getKey())
&& "".equals(classification.getDomain()) && "".equals(classification.getDomain())
&& "T2100".equals(classification.getParentKey())) { && "T2100".equals(classification.getParentKey())) {
@ -245,7 +251,7 @@ class ClassificationControllerIntTest {
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS), restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
HttpMethod.POST, HttpMethod.POST,
new HttpEntity<>(newClassification, restHelper.getHeaders()), new HttpEntity<>(newClassification, restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
@ -267,7 +273,7 @@ class ClassificationControllerIntTest {
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS), restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
HttpMethod.POST, HttpMethod.POST,
new HttpEntity<>(newClassification, restHelper.getHeaders()), new HttpEntity<>(newClassification, restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
@ -279,13 +285,13 @@ class ClassificationControllerIntTest {
void testGetClassificationWithSpecialCharacter() { void testGetClassificationWithSpecialCharacter() {
HttpEntity<String> request = new HttpEntity<>(restHelper.getHeadersAdmin()); HttpEntity<String> request = new HttpEntity<>(restHelper.getHeadersAdmin());
ResponseEntity<ClassificationSummaryResource> response = ResponseEntity<ClassificationSummaryRepresentationModel> response =
template.exchange( template.exchange(
restHelper.toUrl( restHelper.toUrl(
Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009"), Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009"),
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(ClassificationSummaryResource.class)); ParameterizedTypeReference.forType(ClassificationSummaryRepresentationModel.class));
assertThat(response.getBody().getName()).isEqualTo("Zustimmungserklärung"); assertThat(response.getBody().getName()).isEqualTo("Zustimmungserklärung");
} }
@ -294,13 +300,13 @@ class ClassificationControllerIntTest {
void testDeleteClassification() { void testDeleteClassification() {
HttpEntity<String> request = new HttpEntity<>(restHelper.getHeaders()); HttpEntity<String> request = new HttpEntity<>(restHelper.getHeaders());
ResponseEntity<ClassificationSummaryResource> response = ResponseEntity<ClassificationSummaryRepresentationModel> response =
template.exchange( template.exchange(
restHelper.toUrl( restHelper.toUrl(
Mapping.URL_CLASSIFICATIONS_ID, "CLI:200000000000000000000000000000000004"), Mapping.URL_CLASSIFICATIONS_ID, "CLI:200000000000000000000000000000000004"),
HttpMethod.DELETE, HttpMethod.DELETE,
request, request,
ParameterizedTypeReference.forType(ClassificationSummaryResource.class)); ParameterizedTypeReference.forType(ClassificationSummaryRepresentationModel.class));
assertThat(HttpStatus.NO_CONTENT).isEqualTo(response.getStatusCode()); assertThat(HttpStatus.NO_CONTENT).isEqualTo(response.getStatusCode());
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
@ -311,7 +317,7 @@ class ClassificationControllerIntTest {
Mapping.URL_CLASSIFICATIONS_ID, "CLI:200000000000000000000000000000000004"), Mapping.URL_CLASSIFICATIONS_ID, "CLI:200000000000000000000000000000000004"),
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(ClassificationSummaryResource.class)); ParameterizedTypeReference.forType(ClassificationSummaryRepresentationModel.class));
}; };
assertThatThrownBy(httpCall).isInstanceOf(HttpClientErrorException.class); assertThatThrownBy(httpCall).isInstanceOf(HttpClientErrorException.class);
} }

View File

@ -31,14 +31,19 @@ import org.springframework.web.client.RestTemplate;
import pro.taskana.RestHelper; import pro.taskana.RestHelper;
import pro.taskana.TaskanaSpringBootTest; import pro.taskana.TaskanaSpringBootTest;
import pro.taskana.rest.resource.ClassificationResource; import pro.taskana.rest.resource.ClassificationRepresentationModel;
import pro.taskana.rest.resource.ClassificationSummaryListResource; import pro.taskana.rest.resource.ClassificationSummaryRepresentationModel;
import pro.taskana.rest.resource.ClassificationSummaryResource; import pro.taskana.rest.resource.TaskanaPagedModel;
/** Test classification definitions. */ /** Test classification definitions. */
@TaskanaSpringBootTest @TaskanaSpringBootTest
class ClassificationDefinitionControllerIntTest { class ClassificationDefinitionControllerIntTest {
private static final ParameterizedTypeReference<
TaskanaPagedModel<ClassificationSummaryRepresentationModel>>
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE =
new ParameterizedTypeReference<
TaskanaPagedModel<ClassificationSummaryRepresentationModel>>() {};
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationController.class); private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationController.class);
private static RestTemplate template; private static RestTemplate template;
@Autowired RestHelper restHelper; @Autowired RestHelper restHelper;
@ -51,32 +56,32 @@ class ClassificationDefinitionControllerIntTest {
@Test @Test
void testExportClassifications() { void testExportClassifications() {
ResponseEntity<ClassificationResource[]> response = ResponseEntity<ClassificationRepresentationModel[]> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONDEFINITION) + "?domain=DOMAIN_B", restHelper.toUrl(Mapping.URL_CLASSIFICATIONDEFINITION) + "?domain=DOMAIN_B",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationResource[].class)); ParameterizedTypeReference.forType(ClassificationRepresentationModel[].class));
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getBody().length >= 5).isTrue(); assertThat(response.getBody().length >= 5).isTrue();
assertThat(response.getBody().length <= 7).isTrue(); assertThat(response.getBody().length <= 7).isTrue();
assertThat(response.getBody()[0]).isInstanceOf(ClassificationResource.class); assertThat(response.getBody()[0]).isInstanceOf(ClassificationRepresentationModel.class);
} }
@Test @Test
void testExportClassificationsFromWrongDomain() { void testExportClassificationsFromWrongDomain() {
ResponseEntity<ClassificationResource[]> response = ResponseEntity<ClassificationRepresentationModel[]> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONDEFINITION) + "?domain=ADdfe", restHelper.toUrl(Mapping.URL_CLASSIFICATIONDEFINITION) + "?domain=ADdfe",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationResource[].class)); ParameterizedTypeReference.forType(ClassificationRepresentationModel[].class));
assertThat(response.getBody()).isEmpty(); assertThat(response.getBody()).isEmpty();
} }
@Test @Test
void testImportFilledClassification() throws IOException { void testImportFilledClassification() throws IOException {
ClassificationResource classification = new ClassificationResource(); ClassificationRepresentationModel classification = new ClassificationRepresentationModel();
classification.setClassificationId("classificationId_"); classification.setClassificationId("classificationId_");
classification.setKey("key drelf"); classification.setKey("key drelf");
classification.setParentId("CLI:100000000000000000000000000000000016"); classification.setParentId("CLI:100000000000000000000000000000000016");
@ -110,7 +115,7 @@ class ClassificationDefinitionControllerIntTest {
@Test @Test
void testFailureWhenKeyIsMissing() throws IOException { void testFailureWhenKeyIsMissing() throws IOException {
ClassificationResource classification = new ClassificationResource(); ClassificationRepresentationModel classification = new ClassificationRepresentationModel();
classification.setDomain("DOMAIN_A"); classification.setDomain("DOMAIN_A");
List<String> clList = new ArrayList<>(); List<String> clList = new ArrayList<>();
clList.add(objMapper.writeValueAsString(classification)); clList.add(objMapper.writeValueAsString(classification));
@ -124,7 +129,7 @@ class ClassificationDefinitionControllerIntTest {
@Test @Test
void testFailureWhenDomainIsMissing() throws IOException { void testFailureWhenDomainIsMissing() throws IOException {
ClassificationResource classification = new ClassificationResource(); ClassificationRepresentationModel classification = new ClassificationRepresentationModel();
classification.setKey("one"); classification.setKey("one");
List<String> clList = new ArrayList<>(); List<String> clList = new ArrayList<>();
clList.add(objMapper.writeValueAsString(classification)); clList.add(objMapper.writeValueAsString(classification));
@ -138,7 +143,7 @@ class ClassificationDefinitionControllerIntTest {
@Test @Test
void testFailureWhenUpdatingTypeOfExistingClassification() throws IOException { void testFailureWhenUpdatingTypeOfExistingClassification() throws IOException {
ClassificationSummaryResource classification = ClassificationSummaryRepresentationModel classification =
this.getClassificationWithKeyAndDomain("T6310", ""); this.getClassificationWithKeyAndDomain("T6310", "");
classification.setType("DOCUMENT"); classification.setType("DOCUMENT");
List<String> clList = new ArrayList<>(); List<String> clList = new ArrayList<>();
@ -153,11 +158,11 @@ class ClassificationDefinitionControllerIntTest {
@Test @Test
void testImportMultipleClassifications() throws IOException { void testImportMultipleClassifications() throws IOException {
ClassificationResource classification1 = ClassificationRepresentationModel classification1 =
this.createClassification("id1", "ImportKey1", "DOMAIN_A", null, null); this.createClassification("id1", "ImportKey1", "DOMAIN_A", null, null);
final String c1 = objMapper.writeValueAsString(classification1); final String c1 = objMapper.writeValueAsString(classification1);
ClassificationResource classification2 = ClassificationRepresentationModel classification2 =
this.createClassification( this.createClassification(
"id2", "ImportKey2", "DOMAIN_A", "CLI:100000000000000000000000000000000016", "T2000"); "id2", "ImportKey2", "DOMAIN_A", "CLI:100000000000000000000000000000000016", "T2000");
classification2.setCategory("MANUAL"); classification2.setCategory("MANUAL");
@ -182,7 +187,7 @@ class ClassificationDefinitionControllerIntTest {
@Test @Test
void testImportDuplicateClassification() throws IOException { void testImportDuplicateClassification() throws IOException {
ClassificationResource classification1 = new ClassificationResource(); ClassificationRepresentationModel classification1 = new ClassificationRepresentationModel();
classification1.setClassificationId("id1"); classification1.setClassificationId("id1");
classification1.setKey("ImportKey3"); classification1.setKey("ImportKey3");
classification1.setDomain("DOMAIN_A"); classification1.setDomain("DOMAIN_A");
@ -201,7 +206,7 @@ class ClassificationDefinitionControllerIntTest {
@Test @Test
void testInsertExistingClassificationWithOlderTimestamp() throws IOException { void testInsertExistingClassificationWithOlderTimestamp() throws IOException {
ClassificationSummaryResource existingClassification = ClassificationSummaryRepresentationModel existingClassification =
getClassificationWithKeyAndDomain("L110107", "DOMAIN_A"); getClassificationWithKeyAndDomain("L110107", "DOMAIN_A");
existingClassification.setName("first new Name"); existingClassification.setName("first new Name");
List<String> clList = new ArrayList<>(); List<String> clList = new ArrayList<>();
@ -217,16 +222,16 @@ class ClassificationDefinitionControllerIntTest {
response = importRequest(clList); response = importRequest(clList);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
ClassificationSummaryResource testClassification = ClassificationSummaryRepresentationModel testClassification =
this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A"); this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A");
assertThat(testClassification.getName()).isEqualTo("second new Name"); assertThat(testClassification.getName()).isEqualTo("second new Name");
} }
@Test @Test
void testHookExistingChildToNewParent() throws IOException { void testHookExistingChildToNewParent() throws IOException {
final ClassificationResource newClassification = final ClassificationRepresentationModel newClassification =
createClassification("new Classification", "newClass", "DOMAIN_A", null, "L11010"); createClassification("new Classification", "newClass", "DOMAIN_A", null, "L11010");
ClassificationSummaryResource existingClassification = ClassificationSummaryRepresentationModel existingClassification =
getClassificationWithKeyAndDomain("L110102", "DOMAIN_A"); getClassificationWithKeyAndDomain("L110102", "DOMAIN_A");
existingClassification.setParentId("new Classification"); existingClassification.setParentId("new Classification");
existingClassification.setParentKey("newClass"); existingClassification.setParentKey("newClass");
@ -238,11 +243,11 @@ class ClassificationDefinitionControllerIntTest {
ResponseEntity<Void> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
ClassificationSummaryResource parentCl = ClassificationSummaryRepresentationModel parentCl =
getClassificationWithKeyAndDomain("L11010", "DOMAIN_A"); getClassificationWithKeyAndDomain("L11010", "DOMAIN_A");
ClassificationSummaryResource testNewCl = ClassificationSummaryRepresentationModel testNewCl =
getClassificationWithKeyAndDomain("newClass", "DOMAIN_A"); getClassificationWithKeyAndDomain("newClass", "DOMAIN_A");
ClassificationSummaryResource testExistingCl = ClassificationSummaryRepresentationModel testExistingCl =
getClassificationWithKeyAndDomain("L110102", "DOMAIN_A"); getClassificationWithKeyAndDomain("L110102", "DOMAIN_A");
assertThat(parentCl).isNotNull(); assertThat(parentCl).isNotNull();
@ -254,18 +259,18 @@ class ClassificationDefinitionControllerIntTest {
@Test @Test
void testImportParentAndChildClassification() throws IOException { void testImportParentAndChildClassification() throws IOException {
ClassificationResource classification1 = ClassificationRepresentationModel classification1 =
this.createClassification("parentId", "ImportKey6", "DOMAIN_A", null, null); this.createClassification("parentId", "ImportKey6", "DOMAIN_A", null, null);
final String c1 = objMapper.writeValueAsString(classification1); final String c1 = objMapper.writeValueAsString(classification1);
ClassificationResource classification2 = ClassificationRepresentationModel classification2 =
this.createClassification("childId1", "ImportKey7", "DOMAIN_A", null, "ImportKey6"); this.createClassification("childId1", "ImportKey7", "DOMAIN_A", null, "ImportKey6");
final String c21 = objMapper.writeValueAsString(classification2); final String c21 = objMapper.writeValueAsString(classification2);
classification2 = classification2 =
this.createClassification("childId2", "ImportKey8", "DOMAIN_A", "parentId", null); this.createClassification("childId2", "ImportKey8", "DOMAIN_A", "parentId", null);
final String c22 = objMapper.writeValueAsString(classification2); final String c22 = objMapper.writeValueAsString(classification2);
ClassificationResource classification3 = ClassificationRepresentationModel classification3 =
this.createClassification( this.createClassification(
"grandchildId1", "ImportKey9", "DOMAIN_A", "childId1", "ImportKey7"); "grandchildId1", "ImportKey9", "DOMAIN_A", "childId1", "ImportKey7");
final String c31 = objMapper.writeValueAsString(classification3); final String c31 = objMapper.writeValueAsString(classification3);
@ -283,11 +288,11 @@ class ClassificationDefinitionControllerIntTest {
ResponseEntity<Void> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
ClassificationSummaryResource parentCl = ClassificationSummaryRepresentationModel parentCl =
getClassificationWithKeyAndDomain("ImportKey6", "DOMAIN_A"); getClassificationWithKeyAndDomain("ImportKey6", "DOMAIN_A");
ClassificationSummaryResource childCl = ClassificationSummaryRepresentationModel childCl =
getClassificationWithKeyAndDomain("ImportKey7", "DOMAIN_A"); getClassificationWithKeyAndDomain("ImportKey7", "DOMAIN_A");
ClassificationSummaryResource grandchildCl = ClassificationSummaryRepresentationModel grandchildCl =
getClassificationWithKeyAndDomain("ImportKey9", "DOMAIN_A"); getClassificationWithKeyAndDomain("ImportKey9", "DOMAIN_A");
assertThat(parentCl).isNotNull(); assertThat(parentCl).isNotNull();
@ -299,14 +304,14 @@ class ClassificationDefinitionControllerIntTest {
@Test @Test
void testImportParentAndChildClassificationWithKey() throws IOException { void testImportParentAndChildClassificationWithKey() throws IOException {
ClassificationResource classification1 = ClassificationRepresentationModel classification1 =
createClassification("parent", "ImportKey11", "DOMAIN_A", null, null); createClassification("parent", "ImportKey11", "DOMAIN_A", null, null);
classification1.setCustom1("parent is correct"); classification1.setCustom1("parent is correct");
String parent = objMapper.writeValueAsString(classification1); String parent = objMapper.writeValueAsString(classification1);
ClassificationResource classification2 = ClassificationRepresentationModel classification2 =
createClassification("wrongParent", "ImportKey11", "DOMAIN_B", null, null); createClassification("wrongParent", "ImportKey11", "DOMAIN_B", null, null);
String wrongParent = objMapper.writeValueAsString(classification2); String wrongParent = objMapper.writeValueAsString(classification2);
ClassificationResource classification3 = ClassificationRepresentationModel classification3 =
createClassification("child", "ImportKey13", "DOMAIN_A", null, "ImportKey11"); createClassification("child", "ImportKey13", "DOMAIN_A", null, "ImportKey11");
String child = objMapper.writeValueAsString(classification3); String child = objMapper.writeValueAsString(classification3);
@ -318,11 +323,11 @@ class ClassificationDefinitionControllerIntTest {
ResponseEntity<Void> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
ClassificationSummaryResource rightParentCl = ClassificationSummaryRepresentationModel rightParentCl =
getClassificationWithKeyAndDomain("ImportKey11", "DOMAIN_A"); getClassificationWithKeyAndDomain("ImportKey11", "DOMAIN_A");
ClassificationSummaryResource wrongParentCl = ClassificationSummaryRepresentationModel wrongParentCl =
getClassificationWithKeyAndDomain("ImportKey11", "DOMAIN_B"); getClassificationWithKeyAndDomain("ImportKey11", "DOMAIN_B");
ClassificationSummaryResource childCl = ClassificationSummaryRepresentationModel childCl =
getClassificationWithKeyAndDomain("ImportKey13", "DOMAIN_A"); getClassificationWithKeyAndDomain("ImportKey13", "DOMAIN_A");
assertThat(rightParentCl).isNotNull(); assertThat(rightParentCl).isNotNull();
@ -335,14 +340,14 @@ class ClassificationDefinitionControllerIntTest {
@Test @Test
void testChangeParentByImportingExistingClassification() void testChangeParentByImportingExistingClassification()
throws IOException, InterruptedException { throws IOException, InterruptedException {
ClassificationSummaryResource child1 = ClassificationSummaryRepresentationModel child1 =
this.getClassificationWithKeyAndDomain("L110105", "DOMAIN_A"); this.getClassificationWithKeyAndDomain("L110105", "DOMAIN_A");
assertThat(child1.getParentKey()).isEqualTo("L11010"); assertThat(child1.getParentKey()).isEqualTo("L11010");
child1.setParentId("CLI:100000000000000000000000000000000002"); child1.setParentId("CLI:100000000000000000000000000000000002");
child1.setParentKey("L10303"); child1.setParentKey("L10303");
final String withNewParent = objMapper.writeValueAsString(child1); final String withNewParent = objMapper.writeValueAsString(child1);
ClassificationSummaryResource child2 = ClassificationSummaryRepresentationModel child2 =
this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A"); this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A");
assertThat(child2.getParentKey()).isEqualTo("L11010"); assertThat(child2.getParentKey()).isEqualTo("L11010");
child2.setParentId(""); child2.setParentId("");
@ -358,11 +363,11 @@ class ClassificationDefinitionControllerIntTest {
Thread.sleep(10); Thread.sleep(10);
LOGGER.debug("Wait 10 ms to give the system a chance to update"); LOGGER.debug("Wait 10 ms to give the system a chance to update");
ClassificationSummaryResource childWithNewParent = ClassificationSummaryRepresentationModel childWithNewParent =
this.getClassificationWithKeyAndDomain("L110105", "DOMAIN_A"); this.getClassificationWithKeyAndDomain("L110105", "DOMAIN_A");
assertThat(childWithNewParent.getParentKey()).isEqualTo(child1.getParentKey()); assertThat(childWithNewParent.getParentKey()).isEqualTo(child1.getParentKey());
ClassificationSummaryResource childWithoutParent = ClassificationSummaryRepresentationModel childWithoutParent =
this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A"); this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A");
assertThat(childWithoutParent.getParentId()).isEqualTo(child2.getParentId()); assertThat(childWithoutParent.getParentId()).isEqualTo(child2.getParentId());
assertThat(childWithoutParent.getParentKey()).isEqualTo(child2.getParentKey()); assertThat(childWithoutParent.getParentKey()).isEqualTo(child2.getParentKey());
@ -370,7 +375,7 @@ class ClassificationDefinitionControllerIntTest {
@Test @Test
void testFailOnImportDuplicates() throws IOException { void testFailOnImportDuplicates() throws IOException {
ClassificationSummaryResource classification = ClassificationSummaryRepresentationModel classification =
this.getClassificationWithKeyAndDomain("L110105", "DOMAIN_A"); this.getClassificationWithKeyAndDomain("L110105", "DOMAIN_A");
String classificationString = objMapper.writeValueAsString(classification); String classificationString = objMapper.writeValueAsString(classification);
@ -384,28 +389,32 @@ class ClassificationDefinitionControllerIntTest {
.isEqualTo(HttpStatus.CONFLICT); .isEqualTo(HttpStatus.CONFLICT);
} }
private ClassificationResource createClassification( private ClassificationRepresentationModel createClassification(
String id, String key, String domain, String parentId, String parentKey) { String id, String key, String domain, String parentId, String parentKey) {
ClassificationResource classificationResource = new ClassificationResource(); ClassificationRepresentationModel classificationRepresentationModel =
classificationResource.setClassificationId(id); new ClassificationRepresentationModel();
classificationResource.setKey(key); classificationRepresentationModel.setClassificationId(id);
classificationResource.setDomain(domain); classificationRepresentationModel.setKey(key);
classificationResource.setParentId(parentId); classificationRepresentationModel.setDomain(domain);
classificationResource.setParentKey(parentKey); classificationRepresentationModel.setParentId(parentId);
return classificationResource; classificationRepresentationModel.setParentKey(parentKey);
return classificationRepresentationModel;
} }
private ClassificationSummaryResource getClassificationWithKeyAndDomain( private ClassificationSummaryRepresentationModel getClassificationWithKeyAndDomain(
String key, String domain) { String key, String domain) {
LOGGER.debug("Request classification with key={} in domain={}", key, domain); LOGGER.debug("Request classification with key={} in domain={}", key, domain);
HttpEntity<String> request = new HttpEntity<>(restHelper.getHeaders()); HttpEntity<String> request = new HttpEntity<>(restHelper.getHeaders());
ResponseEntity<ClassificationSummaryListResource> response = ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?key=" + key + "&domain=" + domain, restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?key=" + key + "&domain=" + domain,
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)); CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
return response.getBody().getContent().toArray(new ClassificationSummaryResource[1])[0]; return response
.getBody()
.getContent()
.toArray(new ClassificationSummaryRepresentationModel[1])[0];
} }
private ResponseEntity<Void> importRequest(List<String> clList) throws IOException { private ResponseEntity<Void> importRequest(List<String> clList) throws IOException {

View File

@ -13,12 +13,18 @@ import org.springframework.web.client.RestTemplate;
import pro.taskana.RestHelper; import pro.taskana.RestHelper;
import pro.taskana.TaskanaSpringBootTest; import pro.taskana.TaskanaSpringBootTest;
import pro.taskana.rest.resource.ClassificationSummaryListResource; import pro.taskana.rest.resource.ClassificationSummaryRepresentationModel;
import pro.taskana.rest.resource.TaskanaPagedModel;
/** Test general Exception Handling. */ /** Test general Exception Handling. */
@TaskanaSpringBootTest @TaskanaSpringBootTest
class GeneralExceptionHandlingTest { class GeneralExceptionHandlingTest {
private static final ParameterizedTypeReference<
TaskanaPagedModel<ClassificationSummaryRepresentationModel>>
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE =
new ParameterizedTypeReference<
TaskanaPagedModel<ClassificationSummaryRepresentationModel>>() {};
private static RestTemplate template; private static RestTemplate template;
@Autowired RestHelper restHelper; @Autowired RestHelper restHelper;
@ -35,7 +41,7 @@ class GeneralExceptionHandlingTest {
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, "non-existing-id"), restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, "non-existing-id"),
HttpMethod.DELETE, HttpMethod.DELETE,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)); CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)

View File

@ -22,13 +22,16 @@ import org.springframework.web.client.RestTemplate;
import pro.taskana.RestHelper; import pro.taskana.RestHelper;
import pro.taskana.TaskanaSpringBootTest; import pro.taskana.TaskanaSpringBootTest;
import pro.taskana.rest.resource.TaskCommentListResource; import pro.taskana.rest.resource.TaskCommentRepresentationModel;
import pro.taskana.rest.resource.TaskCommentResource; import pro.taskana.rest.resource.TaskanaPagedModel;
/** Test TaskCommentController. */ /** Test TaskCommentController. */
@TaskanaSpringBootTest @TaskanaSpringBootTest
class TaskCommentControllerIntTest { class TaskCommentControllerIntTest {
private static final ParameterizedTypeReference<TaskanaPagedModel<TaskCommentRepresentationModel>>
TASK_COMMENT_PAGE_MODEL_TYPE =
new ParameterizedTypeReference<TaskanaPagedModel<TaskCommentRepresentationModel>>() {};
private static RestTemplate template; private static RestTemplate template;
@Value("${taskana.schemaName:TASKANA}") @Value("${taskana.schemaName:TASKANA}")
@ -53,7 +56,7 @@ class TaskCommentControllerIntTest {
urlToNonExistingTaskComment, urlToNonExistingTaskComment,
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<String>(restHelper.getHeadersAdmin()), new HttpEntity<String>(restHelper.getHeadersAdmin()),
ParameterizedTypeReference.forType(TaskCommentResource.class)); ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
@ -73,7 +76,7 @@ class TaskCommentControllerIntTest {
urlToNotVisibleTask, urlToNotVisibleTask,
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<String>(restHelper.getHeadersUser_1_1()), new HttpEntity<String>(restHelper.getHeadersUser_1_1()),
ParameterizedTypeReference.forType(TaskCommentListResource.class)); TASK_COMMENT_PAGE_MODEL_TYPE);
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
@ -93,7 +96,7 @@ class TaskCommentControllerIntTest {
urlToNotVisibleTask, urlToNotVisibleTask,
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<String>(restHelper.getHeadersUser_1_2()), new HttpEntity<String>(restHelper.getHeadersUser_1_2()),
ParameterizedTypeReference.forType(TaskCommentResource.class)); ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
@ -104,9 +107,10 @@ class TaskCommentControllerIntTest {
@Test @Test
void should_FailToCreateTaskComment_When_TaskIsNotVisible() { void should_FailToCreateTaskComment_When_TaskIsNotVisible() {
TaskCommentResource taskCommentResourceToCreate = new TaskCommentResource(); TaskCommentRepresentationModel taskCommentRepresentationModelToCreate =
taskCommentResourceToCreate.setTaskId("TKI:000000000000000000000000000000000000"); new TaskCommentRepresentationModel();
taskCommentResourceToCreate.setTextField("newly created task comment"); taskCommentRepresentationModelToCreate.setTaskId("TKI:000000000000000000000000000000000000");
taskCommentRepresentationModelToCreate.setTextField("newly created task comment");
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> {
@ -114,8 +118,9 @@ class TaskCommentControllerIntTest {
restHelper.toUrl( restHelper.toUrl(
Mapping.URL_TASK_GET_POST_COMMENTS, "TKI:000000000000000000000000000000000000"), Mapping.URL_TASK_GET_POST_COMMENTS, "TKI:000000000000000000000000000000000000"),
HttpMethod.POST, HttpMethod.POST,
new HttpEntity<>(taskCommentResourceToCreate, restHelper.getHeadersUser_1_1()), new HttpEntity<>(
ParameterizedTypeReference.forType(TaskCommentResource.class)); taskCommentRepresentationModelToCreate, restHelper.getHeadersUser_1_1()),
ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
@ -125,17 +130,19 @@ class TaskCommentControllerIntTest {
@Test @Test
void should_FailToCreateTaskComment_When_TaskIdIsNonExisting() { void should_FailToCreateTaskComment_When_TaskIdIsNonExisting() {
TaskCommentResource taskCommentResourceToCreate = new TaskCommentResource(); TaskCommentRepresentationModel taskCommentRepresentationModelToCreate =
taskCommentResourceToCreate.setTaskId("DefinatelyNotExistingId"); new TaskCommentRepresentationModel();
taskCommentResourceToCreate.setTextField("newly created task comment"); taskCommentRepresentationModelToCreate.setTaskId("DefinatelyNotExistingId");
taskCommentRepresentationModelToCreate.setTextField("newly created task comment");
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> {
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASK_GET_POST_COMMENTS, "DefinatelyNotExistingId"), restHelper.toUrl(Mapping.URL_TASK_GET_POST_COMMENTS, "DefinatelyNotExistingId"),
HttpMethod.POST, HttpMethod.POST,
new HttpEntity<>(taskCommentResourceToCreate, restHelper.getHeadersAdmin()), new HttpEntity<>(
ParameterizedTypeReference.forType(TaskCommentResource.class)); taskCommentRepresentationModelToCreate, restHelper.getHeadersAdmin()),
ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
@ -150,18 +157,19 @@ class TaskCommentControllerIntTest {
String url = String url =
restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000"); restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000");
ResponseEntity<TaskCommentResource> getTaskCommentResponse = ResponseEntity<TaskCommentRepresentationModel> getTaskCommentResponse =
template.exchange( template.exchange(
url, url,
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<String>(restHelper.getHeadersAdmin()), new HttpEntity<String>(restHelper.getHeadersAdmin()),
ParameterizedTypeReference.forType(TaskCommentResource.class)); ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
assertThat(getTaskCommentResponse.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(getTaskCommentResponse.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(getTaskCommentResponse.getBody().getCreator()).isEqualTo("user_1_1"); assertThat(getTaskCommentResponse.getBody().getCreator()).isEqualTo("user_1_1");
assertThat(getTaskCommentResponse.getBody().getTextField()).isEqualTo("some text in textfield"); assertThat(getTaskCommentResponse.getBody().getTextField()).isEqualTo("some text in textfield");
TaskCommentResource taskCommentResourceToUpdate = getTaskCommentResponse.getBody(); TaskCommentRepresentationModel taskCommentRepresentationModelToUpdate =
taskCommentResourceToUpdate.setModified(Instant.now().toString()); getTaskCommentResponse.getBody();
taskCommentRepresentationModelToUpdate.setModified(Instant.now().toString());
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> {
@ -169,9 +177,9 @@ class TaskCommentControllerIntTest {
url, url,
HttpMethod.PUT, HttpMethod.PUT,
new HttpEntity<>( new HttpEntity<>(
mapper.writeValueAsString(taskCommentResourceToUpdate), mapper.writeValueAsString(taskCommentRepresentationModelToUpdate),
restHelper.getHeadersUser_1_1()), restHelper.getHeadersUser_1_1()),
ParameterizedTypeReference.forType(TaskCommentResource.class)); ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
@ -187,18 +195,19 @@ class TaskCommentControllerIntTest {
String url = String url =
restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000"); restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000");
ResponseEntity<TaskCommentResource> getTaskCommentResponse = ResponseEntity<TaskCommentRepresentationModel> getTaskCommentResponse =
template.exchange( template.exchange(
url, url,
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<String>(restHelper.getHeadersUser_1_1()), new HttpEntity<String>(restHelper.getHeadersUser_1_1()),
ParameterizedTypeReference.forType(TaskCommentResource.class)); ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
assertThat(getTaskCommentResponse.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(getTaskCommentResponse.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(getTaskCommentResponse.getBody().getCreator()).isEqualTo("user_1_1"); assertThat(getTaskCommentResponse.getBody().getCreator()).isEqualTo("user_1_1");
assertThat(getTaskCommentResponse.getBody().getTextField()).isEqualTo("some text in textfield"); assertThat(getTaskCommentResponse.getBody().getTextField()).isEqualTo("some text in textfield");
TaskCommentResource taskCommentResourceToUpdate = getTaskCommentResponse.getBody(); TaskCommentRepresentationModel taskCommentRepresentationModelToUpdate =
taskCommentResourceToUpdate.setTextField("updated textfield"); getTaskCommentResponse.getBody();
taskCommentRepresentationModelToUpdate.setTextField("updated textfield");
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> {
@ -206,9 +215,9 @@ class TaskCommentControllerIntTest {
url, url,
HttpMethod.PUT, HttpMethod.PUT,
new HttpEntity<>( new HttpEntity<>(
mapper.writeValueAsString(taskCommentResourceToUpdate), mapper.writeValueAsString(taskCommentRepresentationModelToUpdate),
restHelper.getHeadersUser_1_2()), restHelper.getHeadersUser_1_2()),
ParameterizedTypeReference.forType(TaskCommentResource.class)); ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
@ -223,19 +232,20 @@ class TaskCommentControllerIntTest {
String url = String url =
restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000"); restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000");
ResponseEntity<TaskCommentResource> getTaskCommentResponse = ResponseEntity<TaskCommentRepresentationModel> getTaskCommentResponse =
template.exchange( template.exchange(
url, url,
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<String>(restHelper.getHeadersAdmin()), new HttpEntity<String>(restHelper.getHeadersAdmin()),
ParameterizedTypeReference.forType(TaskCommentResource.class)); ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
assertThat(getTaskCommentResponse.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(getTaskCommentResponse.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(getTaskCommentResponse.getBody().getCreator()).isEqualTo("user_1_1"); assertThat(getTaskCommentResponse.getBody().getCreator()).isEqualTo("user_1_1");
assertThat(getTaskCommentResponse.getBody().getTextField()).isEqualTo("some text in textfield"); assertThat(getTaskCommentResponse.getBody().getTextField()).isEqualTo("some text in textfield");
TaskCommentResource taskCommentResourceToUpdate = getTaskCommentResponse.getBody(); TaskCommentRepresentationModel taskCommentRepresentationModelToUpdate =
taskCommentResourceToUpdate.setTextField("updated text"); getTaskCommentResponse.getBody();
taskCommentResourceToUpdate.setTaskCommentId("DifferentTaskCommentId"); taskCommentRepresentationModelToUpdate.setTextField("updated text");
taskCommentRepresentationModelToUpdate.setTaskCommentId("DifferentTaskCommentId");
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> {
@ -243,9 +253,9 @@ class TaskCommentControllerIntTest {
url, url,
HttpMethod.PUT, HttpMethod.PUT,
new HttpEntity<>( new HttpEntity<>(
mapper.writeValueAsString(taskCommentResourceToUpdate), mapper.writeValueAsString(taskCommentRepresentationModelToUpdate),
restHelper.getHeadersUser_1_1()), restHelper.getHeadersUser_1_1()),
ParameterizedTypeReference.forType(TaskCommentResource.class)); ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
@ -256,12 +266,14 @@ class TaskCommentControllerIntTest {
@Test @Test
void should_FailToDeleteTaskComment_When_UserHasNoAuthorization() { void should_FailToDeleteTaskComment_When_UserHasNoAuthorization() {
ResponseEntity<TaskCommentListResource> getTaskCommentsBeforeDeleteionResponse = ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>>
template.exchange( getTaskCommentsBeforeDeleteionResponse =
restHelper.toUrl(Mapping.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000001"), template.exchange(
HttpMethod.GET, restHelper.toUrl(
new HttpEntity<String>(restHelper.getHeadersAdmin()), Mapping.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000001"),
ParameterizedTypeReference.forType(TaskCommentListResource.class)); HttpMethod.GET,
new HttpEntity<String>(restHelper.getHeadersAdmin()),
TASK_COMMENT_PAGE_MODEL_TYPE);
assertThat(getTaskCommentsBeforeDeleteionResponse.getBody().getContent()).hasSize(2); assertThat(getTaskCommentsBeforeDeleteionResponse.getBody().getContent()).hasSize(2);
String url = String url =
@ -273,7 +285,7 @@ class TaskCommentControllerIntTest {
url, url,
HttpMethod.DELETE, HttpMethod.DELETE,
new HttpEntity<String>(restHelper.getHeadersUser_1_2()), new HttpEntity<String>(restHelper.getHeadersUser_1_2()),
ParameterizedTypeReference.forType(TaskCommentResource.class)); ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
@ -291,7 +303,7 @@ class TaskCommentControllerIntTest {
url, url,
HttpMethod.DELETE, HttpMethod.DELETE,
new HttpEntity<String>(restHelper.getHeadersAdmin()), new HttpEntity<String>(restHelper.getHeadersAdmin()),
ParameterizedTypeReference.forType(TaskCommentResource.class)); ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())

View File

@ -34,10 +34,11 @@ import org.springframework.web.client.RestTemplate;
import pro.taskana.RestHelper; import pro.taskana.RestHelper;
import pro.taskana.TaskanaSpringBootTest; import pro.taskana.TaskanaSpringBootTest;
import pro.taskana.rest.resource.ClassificationSummaryResource; import pro.taskana.rest.resource.ClassificationSummaryRepresentationModel;
import pro.taskana.rest.resource.TaskResource; import pro.taskana.rest.resource.TaskRepresentationModel;
import pro.taskana.rest.resource.TaskSummaryListResource; import pro.taskana.rest.resource.TaskSummaryRepresentationModel;
import pro.taskana.rest.resource.WorkbasketSummaryResource; import pro.taskana.rest.resource.TaskanaPagedModel;
import pro.taskana.rest.resource.WorkbasketSummaryRepresentationModel;
import pro.taskana.sampledata.SampleDataGenerator; import pro.taskana.sampledata.SampleDataGenerator;
import pro.taskana.task.api.TaskState; import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.models.ObjectReference; import pro.taskana.task.api.models.ObjectReference;
@ -46,6 +47,9 @@ import pro.taskana.task.api.models.ObjectReference;
@TaskanaSpringBootTest @TaskanaSpringBootTest
class TaskControllerIntTest { class TaskControllerIntTest {
private static final ParameterizedTypeReference<TaskanaPagedModel<TaskSummaryRepresentationModel>>
TASK_SUMMARY_PAGE_MODEL_TYPE =
new ParameterizedTypeReference<TaskanaPagedModel<TaskSummaryRepresentationModel>>() {};
private static RestTemplate template; private static RestTemplate template;
@Value("${taskana.schemaName:TASKANA}") @Value("${taskana.schemaName:TASKANA}")
@ -67,26 +71,30 @@ class TaskControllerIntTest {
@Test @Test
void testGetAllTasks() { void testGetAllTasks() {
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS), restHelper.toUrl(Mapping.URL_TASKS),
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
.isNotNull();
assertThat(response.getBody().getContent()).hasSize(25); assertThat(response.getBody().getContent()).hasSize(25);
} }
@Test @Test
void testGetAllTasksByWorkbasketId() { void testGetAllTasksByWorkbasketId() {
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
+ "?workbasket-id=WBI:100000000000000000000000000000000001", + "?workbasket-id=WBI:100000000000000000000000000000000001",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
.isNotNull();
assertThat(response.getBody().getContent()).hasSize(22); assertThat(response.getBody().getContent()).hasSize(22);
} }
@ -98,7 +106,7 @@ class TaskControllerIntTest {
Instant thirdInstant = Instant.now().minus(10, ChronoUnit.DAYS); Instant thirdInstant = Instant.now().minus(10, ChronoUnit.DAYS);
Instant fourthInstant = Instant.now().minus(11, ChronoUnit.DAYS); Instant fourthInstant = Instant.now().minus(11, ChronoUnit.DAYS);
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
+ "?workbasket-id=WBI:100000000000000000000000000000000001" + "?workbasket-id=WBI:100000000000000000000000000000000001"
@ -114,8 +122,10 @@ class TaskControllerIntTest {
+ "&sort-by=planned", + "&sort-by=planned",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
.isNotNull();
assertThat(response.getBody().getContent()).hasSize(6); assertThat(response.getBody().getContent()).hasSize(6);
} }
@ -125,7 +135,7 @@ class TaskControllerIntTest {
Instant plannedFromInstant = Instant.now().minus(6, ChronoUnit.DAYS); Instant plannedFromInstant = Instant.now().minus(6, ChronoUnit.DAYS);
Instant plannedToInstant = Instant.now().minus(3, ChronoUnit.DAYS); Instant plannedToInstant = Instant.now().minus(3, ChronoUnit.DAYS);
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
+ "?workbasket-id=WBI:100000000000000000000000000000000001" + "?workbasket-id=WBI:100000000000000000000000000000000001"
@ -136,8 +146,10 @@ class TaskControllerIntTest {
+ "&sort-by=planned", + "&sort-by=planned",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
.isNotNull();
assertThat(response.getBody().getContent()).hasSize(3); assertThat(response.getBody().getContent()).hasSize(3);
} }
@ -146,7 +158,7 @@ class TaskControllerIntTest {
Instant plannedFromInstant = Instant.now().minus(6, ChronoUnit.DAYS); Instant plannedFromInstant = Instant.now().minus(6, ChronoUnit.DAYS);
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
+ "?workbasket-id=WBI:100000000000000000000000000000000001" + "?workbasket-id=WBI:100000000000000000000000000000000001"
@ -155,27 +167,27 @@ class TaskControllerIntTest {
+ "&sort-by=planned", + "&sort-by=planned",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
.isNotNull();
assertThat(response.getBody().getContent()).hasSize(4); assertThat(response.getBody().getContent()).hasSize(4);
} }
@Test @Test
void testGetAllTasksByWorkbasketIdWithInvalidPlannedParamsCombination() { void testGetAllTasksByWorkbasketIdWithInvalidPlannedParamsCombination() {
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> template.exchange(
template.exchange( restHelper.toUrl(Mapping.URL_TASKS)
restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-id=WBI:100000000000000000000000000000000001"
+ "?workbasket-id=WBI:100000000000000000000000000000000001" + "&planned=2020-01-22T09:44:47.453Z,,"
+ "&planned=2020-01-22T09:44:47.453Z,," + "2020-01-19T07:44:47.453Z,2020-01-19T19:44:47.453Z,"
+ "2020-01-19T07:44:47.453Z,2020-01-19T19:44:47.453Z," + ",2020-01-18T09:44:47.453Z"
+ ",2020-01-18T09:44:47.453Z" + "&planned-from=2020-01-19T07:44:47.453Z"
+ "&planned-from=2020-01-19T07:44:47.453Z" + "&sort-by=planned",
+ "&sort-by=planned", HttpMethod.GET,
HttpMethod.GET, restHelper.defaultRequest(),
restHelper.defaultRequest(), TASK_SUMMARY_PAGE_MODEL_TYPE);
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
};
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining("400"); .hasMessageContaining("400");
@ -189,7 +201,7 @@ class TaskControllerIntTest {
Instant thirdInstant = Instant.now().minus(10, ChronoUnit.DAYS); Instant thirdInstant = Instant.now().minus(10, ChronoUnit.DAYS);
Instant fourthInstant = Instant.now().minus(11, ChronoUnit.DAYS); Instant fourthInstant = Instant.now().minus(11, ChronoUnit.DAYS);
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
+ "?workbasket-id=WBI:100000000000000000000000000000000001" + "?workbasket-id=WBI:100000000000000000000000000000000001"
@ -205,22 +217,26 @@ class TaskControllerIntTest {
+ "&sort-by=due", + "&sort-by=due",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
.isNotNull();
assertThat(response.getBody().getContent()).hasSize(6); assertThat(response.getBody().getContent()).hasSize(6);
} }
@Test @Test
void should_ReturnAllTasksByWildcardSearch_For_ProvidedSearchValue() { void should_ReturnAllTasksByWildcardSearch_For_ProvidedSearchValue() {
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
+ "?wildcard-search-value=%99%" + "?wildcard-search-value=%99%"
+ "&wildcard-search-fields=NAME,custom_3,CuStOM_4", + "&wildcard-search-fields=NAME,custom_3,CuStOM_4",
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<String>(restHelper.getHeadersAdmin()), new HttpEntity<String>(restHelper.getHeadersAdmin()),
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
.isNotNull();
assertThat(response.getBody().getContent()).hasSize(4); assertThat(response.getBody().getContent()).hasSize(4);
} }
@ -228,13 +244,11 @@ class TaskControllerIntTest {
void should_ThrowException_When_ProvidingInvalidWildcardSearchParameters() { void should_ThrowException_When_ProvidingInvalidWildcardSearchParameters() {
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> template.exchange(
template.exchange( restHelper.toUrl(Mapping.URL_TASKS) + "?wildcard-search-value=%rt%",
restHelper.toUrl(Mapping.URL_TASKS) + "?wildcard-search-value=%rt%", HttpMethod.GET,
HttpMethod.GET, restHelper.defaultRequest(),
restHelper.defaultRequest(), TASK_SUMMARY_PAGE_MODEL_TYPE);
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
};
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining("400") .hasMessageContaining("400")
@ -242,14 +256,12 @@ class TaskControllerIntTest {
.isEqualTo(HttpStatus.BAD_REQUEST); .isEqualTo(HttpStatus.BAD_REQUEST);
ThrowingCallable httpCall2 = ThrowingCallable httpCall2 =
() -> { () -> template.exchange(
template.exchange( restHelper.toUrl(Mapping.URL_TASKS)
restHelper.toUrl(Mapping.URL_TASKS) + "?wildcard-search-fields=NAME,CUSTOM_3,CUSTOM_4",
+ "?wildcard-search-fields=NAME,CUSTOM_3,CUSTOM_4", HttpMethod.GET,
HttpMethod.GET, restHelper.defaultRequest(),
restHelper.defaultRequest(), TASK_SUMMARY_PAGE_MODEL_TYPE);
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
};
assertThatThrownBy(httpCall2) assertThatThrownBy(httpCall2)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining("400") .hasMessageContaining("400")
@ -263,7 +275,7 @@ class TaskControllerIntTest {
Instant dueFromInstant = Instant.now().minus(8, ChronoUnit.DAYS); Instant dueFromInstant = Instant.now().minus(8, ChronoUnit.DAYS);
Instant dueToInstant = Instant.now().minus(3, ChronoUnit.DAYS); Instant dueToInstant = Instant.now().minus(3, ChronoUnit.DAYS);
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
+ "?workbasket-id=WBI:100000000000000000000000000000000001" + "?workbasket-id=WBI:100000000000000000000000000000000001"
@ -274,8 +286,10 @@ class TaskControllerIntTest {
+ "&sort-by=due", + "&sort-by=due",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
.isNotNull();
assertThat(response.getBody().getContent()).hasSize(9); assertThat(response.getBody().getContent()).hasSize(9);
} }
@ -284,7 +298,7 @@ class TaskControllerIntTest {
Instant dueToInstant = Instant.now().minus(1, ChronoUnit.DAYS); Instant dueToInstant = Instant.now().minus(1, ChronoUnit.DAYS);
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
+ "?workbasket-id=WBI:100000000000000000000000000000000001" + "?workbasket-id=WBI:100000000000000000000000000000000001"
@ -293,27 +307,27 @@ class TaskControllerIntTest {
+ "&sort-by=due", + "&sort-by=due",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
.isNotNull();
assertThat(response.getBody().getContent()).hasSize(6); assertThat(response.getBody().getContent()).hasSize(6);
} }
@Test @Test
void testGetAllTasksByWorkbasketIdWithInvalidDueParamsCombination() { void testGetAllTasksByWorkbasketIdWithInvalidDueParamsCombination() {
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> template.exchange(
template.exchange( restHelper.toUrl(Mapping.URL_TASKS)
restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-id=WBI:100000000000000000000000000000000001"
+ "?workbasket-id=WBI:100000000000000000000000000000000001" + "&due=2020-01-22T09:44:47.453Z,,"
+ "&due=2020-01-22T09:44:47.453Z,," + "2020-01-19T07:44:47.453Z,2020-01-19T19:44:47.453Z,"
+ "2020-01-19T07:44:47.453Z,2020-01-19T19:44:47.453Z," + ",2020-01-18T09:44:47.453Z"
+ ",2020-01-18T09:44:47.453Z" + "&due-from=2020-01-19T07:44:47.453Z"
+ "&due-from=2020-01-19T07:44:47.453Z" + "&sort-by=planned",
+ "&sort-by=planned", HttpMethod.GET,
HttpMethod.GET, restHelper.defaultRequest(),
restHelper.defaultRequest(), TASK_SUMMARY_PAGE_MODEL_TYPE);
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
};
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining("400"); .hasMessageContaining("400");
@ -324,27 +338,31 @@ class TaskControllerIntTest {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dXNlcl8xXzI6dXNlcl8xXzI="); // user_1_2 headers.add("Authorization", "Basic dXNlcl8xXzI6dXNlcl8xXzI="); // user_1_2
HttpEntity<String> request = new HttpEntity<>(headers); HttpEntity<String> request = new HttpEntity<>(headers);
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-key=USER_1_2&domain=DOMAIN_A", restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-key=USER_1_2&domain=DOMAIN_A",
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
.isNotNull();
assertThat(response.getBody().getContent()).hasSize(20); assertThat(response.getBody().getContent()).hasSize(20);
} }
@Test @Test
void testGetAllTasksByExternalId() { void testGetAllTasksByExternalId() {
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
+ "?external-id=ETI:000000000000000000000000000000000003," + "?external-id=ETI:000000000000000000000000000000000003,"
+ "ETI:000000000000000000000000000000000004", + "ETI:000000000000000000000000000000000004",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
.isNotNull();
assertThat(response.getBody().getContent()).hasSize(2); assertThat(response.getBody().getContent()).hasSize(2);
} }
@ -356,13 +374,11 @@ class TaskControllerIntTest {
HttpEntity<String> request = new HttpEntity<>(headers); HttpEntity<String> request = new HttpEntity<>(headers);
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> template.exchange(
template.exchange( restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-key=USER_1_2",
restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-key=USER_1_2", HttpMethod.GET,
HttpMethod.GET, request,
request, TASK_SUMMARY_PAGE_MODEL_TYPE);
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
};
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining("400"); .hasMessageContaining("400");
@ -370,46 +386,48 @@ class TaskControllerIntTest {
@Test @Test
void testGetAllTasksWithAdminRole() { void testGetAllTasksWithAdminRole() {
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS), restHelper.toUrl(Mapping.URL_TASKS),
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<>(restHelper.getHeadersAdmin()), new HttpEntity<>(restHelper.getHeadersAdmin()),
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
.isNotNull();
assertThat(response.getBody().getContent()).hasSize(73); assertThat(response.getBody().getContent()).hasSize(73);
} }
@Test @Test
void testGetAllTasksKeepingFilters() { void testGetAllTasksKeepingFilters() {
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
+ "?por.type=VNR&por.value=22334455&sort-by=por.value&order=desc", + "?por.type=VNR&por.value=22334455&sort-by=por.value&order=desc",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
.isNotNull();
assertThat( assertThat(
response response
.getBody() .getBody()
.getRequiredLink(IanaLinkRelations.SELF) .getRequiredLink(IanaLinkRelations.SELF)
.getHref() .getHref()
.endsWith( .endsWith(
"/api/v1/tasks?por.type=VNR&por.value=22334455&sort-by=por.value&order=desc")) "/api/v1/tasks?por.type=VNR&por.value=22334455&sort-by=por.value&order=desc"))
.isTrue(); .isTrue();
} }
@Test @Test
void testThrowsExceptionIfInvalidFilterIsUsed() { void testThrowsExceptionIfInvalidFilterIsUsed() {
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> template.exchange(
template.exchange( restHelper.toUrl(Mapping.URL_TASKS) + "?invalid=VNR",
restHelper.toUrl(Mapping.URL_TASKS) + "?invalid=VNR", HttpMethod.GET,
HttpMethod.GET, restHelper.defaultRequest(),
restHelper.defaultRequest(), TASK_SUMMARY_PAGE_MODEL_TYPE);
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
};
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining("[invalid]") .hasMessageContaining("[invalid]")
@ -421,20 +439,21 @@ class TaskControllerIntTest {
void testGetLastPageSortedByPorValue() { void testGetLastPageSortedByPorValue() {
HttpEntity<String> request = new HttpEntity<>(restHelper.getHeadersAdmin()); HttpEntity<String> request = new HttpEntity<>(restHelper.getHeadersAdmin());
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
+ "?state=READY,CLAIMED&sort-by=por.value&order=desc&page=15&page-size=5", + "?state=READY,CLAIMED&sort-by=por.value&order=desc&page-size=5&page=14",
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getContent()).hasSize(1); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getContent()).hasSize(1);
assertThat( assertThat(
response response
.getBody() .getBody()
.getRequiredLink(IanaLinkRelations.LAST) .getRequiredLink(IanaLinkRelations.LAST)
.getHref() .getHref()
.contains("page=14")) .contains("page=14"))
.isTrue(); .isTrue();
assertThat("TKI:100000000000000000000000000000000000") assertThat("TKI:100000000000000000000000000000000000")
.isEqualTo(response.getBody().getContent().iterator().next().getTaskId()); .isEqualTo(response.getBody().getContent().iterator().next().getTaskId());
@ -447,7 +466,7 @@ class TaskControllerIntTest {
.getHref() .getHref()
.endsWith( .endsWith(
"/api/v1/tasks?" "/api/v1/tasks?"
+ "state=READY,CLAIMED&sort-by=por.value&order=desc&page=15&page-size=5")) + "state=READY,CLAIMED&sort-by=por.value&order=desc&page-size=5&page=14"))
.isTrue(); .isTrue();
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
@ -466,34 +485,36 @@ class TaskControllerIntTest {
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
HttpEntity<String> request = new HttpEntity<>(headers); HttpEntity<String> request = new HttpEntity<>(headers);
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) + "?sort-by=due&order=desc", restHelper.toUrl(Mapping.URL_TASKS) + "?sort-by=due&order=desc",
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getContent()).hasSize(25); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getContent()).hasSize(25);
response = response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) + "?sort-by=due&order=desc&page=5&page-size=5", restHelper.toUrl(Mapping.URL_TASKS) + "?sort-by=due&order=desc&page-size=5&page=5",
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getContent()).hasSize(5); assertThat(response.getBody()).isNotNull();
assertThat((response.getBody()).getContent()).hasSize(5);
assertThat( assertThat(
response.getBody().getRequiredLink(IanaLinkRelations.LAST).getHref().contains("page=5")) response.getBody().getRequiredLink(IanaLinkRelations.LAST).getHref().contains("page=5"))
.isTrue(); .isTrue();
assertThat("TKI:000000000000000000000000000000000023") assertThat("TKI:000000000000000000000000000000000023")
.isEqualTo(response.getBody().getContent().iterator().next().getTaskId()); .isEqualTo(response.getBody().getContent().iterator().next().getTaskId());
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat( assertThat(
response response
.getBody() .getBody()
.getRequiredLink(IanaLinkRelations.SELF) .getRequiredLink(IanaLinkRelations.SELF)
.getHref() .getHref()
.endsWith("/api/v1/tasks?sort-by=due&order=desc&page=5&page-size=5")) .endsWith("/api/v1/tasks?sort-by=due&order=desc&page-size=5&page=5"))
.isTrue(); .isTrue();
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
@ -510,30 +531,31 @@ class TaskControllerIntTest {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
HttpEntity<String> request = new HttpEntity<>(headers); HttpEntity<String> request = new HttpEntity<>(headers);
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
+ "?por.company=00&por.system=PASystem&por.instance=00&" + "?por.company=00&por.system=PASystem&por.instance=00&"
+ "por.type=VNR&por.value=22334455&sort-by=por.type&" + "por.type=VNR&por.value=22334455&sort-by=por.type&"
+ "order=asc&page=2&page-size=5", + "order=asc&page-size=5&page=2",
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getContent()).hasSize(1); assertThat(response.getBody()).isNotNull();
assertThat("TKI:000000000000000000000000000000000013") assertThat(response.getBody().getContent())
.isEqualTo(response.getBody().getContent().iterator().next().getTaskId()); .extracting(TaskSummaryRepresentationModel::getTaskId)
.containsOnly("TKI:000000000000000000000000000000000013");
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat( assertThat(
response response
.getBody() .getBody()
.getRequiredLink(IanaLinkRelations.SELF) .getRequiredLink(IanaLinkRelations.SELF)
.getHref() .getHref()
.endsWith( .endsWith(
"/api/v1/tasks?por.company=00&por.system=PASystem&por.instance=00&" "/api/v1/tasks?por.company=00&por.system=PASystem&por.instance=00&"
+ "por.type=VNR&por.value=22334455&sort-by=por.type&order=asc&" + "por.type=VNR&por.value=22334455&sort-by=por.type&order=asc&"
+ "page=2&page-size=5")) + "page-size=5&page=2"))
.isTrue(); .isTrue();
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
@ -553,7 +575,7 @@ class TaskControllerIntTest {
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), UTF_8)); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), UTF_8));
String inputLine; String inputLine;
StringBuffer content = new StringBuffer(); StringBuilder content = new StringBuilder();
while ((inputLine = in.readLine()) != null) { while ((inputLine = in.readLine()) != null) {
content.append(inputLine); content.append(inputLine);
} }
@ -613,8 +635,10 @@ class TaskControllerIntTest {
String updatedTask = content.toString(); String updatedTask = content.toString();
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
TaskResource originalTaskObject = mapper.readValue(originalTask, TaskResource.class); TaskRepresentationModel originalTaskObject =
TaskResource updatedTaskObject = mapper.readValue(updatedTask, TaskResource.class); mapper.readValue(originalTask, TaskRepresentationModel.class);
TaskRepresentationModel updatedTaskObject =
mapper.readValue(updatedTask, TaskRepresentationModel.class);
assertThat(updatedTaskObject.getModified()).isNotEqualTo(originalTaskObject.getModified()); assertThat(updatedTaskObject.getModified()).isNotEqualTo(originalTaskObject.getModified());
} }
@ -622,13 +646,13 @@ class TaskControllerIntTest {
@Test @Test
void testCreateAndDeleteTask() { void testCreateAndDeleteTask() {
TaskResource taskResource = getTaskResourceSample(); TaskRepresentationModel taskRepresentationModel = getTaskResourceSample();
ResponseEntity<TaskResource> responseCreate = ResponseEntity<TaskRepresentationModel> responseCreate =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS), restHelper.toUrl(Mapping.URL_TASKS),
HttpMethod.POST, HttpMethod.POST,
new HttpEntity<>(taskResource, restHelper.getHeaders()), new HttpEntity<>(taskRepresentationModel, restHelper.getHeaders()),
ParameterizedTypeReference.forType(TaskResource.class)); ParameterizedTypeReference.forType(TaskRepresentationModel.class));
assertThat(HttpStatus.CREATED).isEqualTo(responseCreate.getStatusCode()); assertThat(HttpStatus.CREATED).isEqualTo(responseCreate.getStatusCode());
assertThat(responseCreate.getBody()).isNotNull(); assertThat(responseCreate.getBody()).isNotNull();
@ -637,7 +661,7 @@ class TaskControllerIntTest {
assertThat(taskIdOfCreatedTask).isNotNull(); assertThat(taskIdOfCreatedTask).isNotNull();
assertThat(taskIdOfCreatedTask.startsWith("TKI:")).isTrue(); assertThat(taskIdOfCreatedTask.startsWith("TKI:")).isTrue();
ResponseEntity<TaskResource> responseDeleted = ResponseEntity<TaskRepresentationModel> responseDeleted =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS_ID, taskIdOfCreatedTask), restHelper.toUrl(Mapping.URL_TASKS_ID, taskIdOfCreatedTask),
HttpMethod.DELETE, HttpMethod.DELETE,
@ -653,19 +677,17 @@ class TaskControllerIntTest {
*/ */
@Test @Test
void testCreateWithPlannedAndDueDate() { void testCreateWithPlannedAndDueDate() {
TaskResource taskResource = getTaskResourceSample(); TaskRepresentationModel taskRepresentationModel = getTaskResourceSample();
Instant now = Instant.now(); Instant now = Instant.now();
taskResource.setPlanned(now.toString()); taskRepresentationModel.setPlanned(now.toString());
taskResource.setDue(now.toString()); taskRepresentationModel.setDue(now.toString());
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> template.exchange(
template.exchange( restHelper.toUrl(Mapping.URL_TASKS),
restHelper.toUrl(Mapping.URL_TASKS), HttpMethod.POST,
HttpMethod.POST, new HttpEntity<>(taskRepresentationModel, restHelper.getHeaders()),
new HttpEntity<>(taskResource, restHelper.getHeaders()), ParameterizedTypeReference.forType(TaskRepresentationModel.class));
ParameterizedTypeReference.forType(TaskResource.class));
};
assertThatThrownBy(httpCall).isInstanceOf(HttpClientErrorException.class); assertThatThrownBy(httpCall).isInstanceOf(HttpClientErrorException.class);
} }
@ -720,34 +742,34 @@ class TaskControllerIntTest {
final String user_id_of_claimed_task = "user_1_2"; final String user_id_of_claimed_task = "user_1_2";
// retrieve task from Rest Api // retrieve task from Rest Api
ResponseEntity<TaskResource> getTaskResponse = ResponseEntity<TaskRepresentationModel> getTaskResponse =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS_ID, claimed_task_id), restHelper.toUrl(Mapping.URL_TASKS_ID, claimed_task_id),
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<>(restHelper.getHeadersUser_1_2()), new HttpEntity<>(restHelper.getHeadersUser_1_2()),
ParameterizedTypeReference.forType(TaskResource.class)); ParameterizedTypeReference.forType(TaskRepresentationModel.class));
assertThat(getTaskResponse.getBody()).isNotNull(); assertThat(getTaskResponse.getBody()).isNotNull();
TaskResource claimedTaskResource = getTaskResponse.getBody(); TaskRepresentationModel claimedTaskRepresentationModel = getTaskResponse.getBody();
assertThat(claimedTaskResource.getState()).isEqualTo(TaskState.CLAIMED); assertThat(claimedTaskRepresentationModel.getState()).isEqualTo(TaskState.CLAIMED);
assertThat(claimedTaskResource.getOwner()).isEqualTo(user_id_of_claimed_task); assertThat(claimedTaskRepresentationModel.getOwner()).isEqualTo(user_id_of_claimed_task);
// cancel claim // cancel claim
ResponseEntity<TaskResource> cancelClaimResponse = ResponseEntity<TaskRepresentationModel> cancelClaimResponse =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS_ID_CLAIM, claimed_task_id), restHelper.toUrl(Mapping.URL_TASKS_ID_CLAIM, claimed_task_id),
HttpMethod.DELETE, HttpMethod.DELETE,
new HttpEntity<>(restHelper.getHeadersUser_1_2()), new HttpEntity<>(restHelper.getHeadersUser_1_2()),
ParameterizedTypeReference.forType(TaskResource.class)); ParameterizedTypeReference.forType(TaskRepresentationModel.class));
assertThat(cancelClaimResponse.getBody()).isNotNull(); assertThat(cancelClaimResponse.getBody()).isNotNull();
assertThat(cancelClaimResponse.getStatusCode().is2xxSuccessful()); assertThat(cancelClaimResponse.getStatusCode().is2xxSuccessful());
TaskResource cancelClaimedtaskResource = cancelClaimResponse.getBody(); TaskRepresentationModel cancelClaimedtaskRepresentationModel = cancelClaimResponse.getBody();
assertThat(cancelClaimedtaskResource.getOwner()).isNull(); assertThat(cancelClaimedtaskRepresentationModel.getOwner()).isNull();
assertThat(cancelClaimedtaskResource.getClaimed()).isNull(); assertThat(cancelClaimedtaskRepresentationModel.getClaimed()).isNull();
assertThat(cancelClaimedtaskResource.getState()).isEqualTo(TaskState.READY); assertThat(cancelClaimedtaskRepresentationModel.getState()).isEqualTo(TaskState.READY);
} }
@Test @Test
@ -757,27 +779,25 @@ class TaskControllerIntTest {
final String user_id_of_claimed_task = "user_1_1"; final String user_id_of_claimed_task = "user_1_1";
// retrieve task from Rest Api // retrieve task from Rest Api
ResponseEntity<TaskResource> responseGet = ResponseEntity<TaskRepresentationModel> responseGet =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS_ID, claimed_task_id), restHelper.toUrl(Mapping.URL_TASKS_ID, claimed_task_id),
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<>(restHelper.getHeadersUser_1_2()), new HttpEntity<>(restHelper.getHeadersUser_1_2()),
ParameterizedTypeReference.forType(TaskResource.class)); ParameterizedTypeReference.forType(TaskRepresentationModel.class));
assertThat(responseGet.getBody()).isNotNull(); assertThat(responseGet.getBody()).isNotNull();
TaskResource theTaskResource = responseGet.getBody(); TaskRepresentationModel theTaskRepresentationModel = responseGet.getBody();
assertThat(theTaskResource.getState()).isEqualTo(TaskState.CLAIMED); assertThat(theTaskRepresentationModel.getState()).isEqualTo(TaskState.CLAIMED);
assertThat(theTaskResource.getOwner()).isEqualTo(user_id_of_claimed_task); assertThat(theTaskRepresentationModel.getOwner()).isEqualTo(user_id_of_claimed_task);
// try to cancel claim // try to cancel claim
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> template.exchange(
template.exchange( restHelper.toUrl(Mapping.URL_TASKS_ID_CLAIM, claimed_task_id),
restHelper.toUrl(Mapping.URL_TASKS_ID_CLAIM, claimed_task_id), HttpMethod.DELETE,
HttpMethod.DELETE, new HttpEntity<>(restHelper.getHeadersUser_1_2()),
new HttpEntity<>(restHelper.getHeadersUser_1_2()), ParameterizedTypeReference.forType(TaskRepresentationModel.class));
ParameterizedTypeReference.forType(TaskResource.class));
};
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
.isEqualTo(HttpStatus.CONFLICT); .isEqualTo(HttpStatus.CONFLICT);
@ -790,33 +810,33 @@ class TaskControllerIntTest {
restHelper.toUrl("/api/v1/tasks/TKI:000000000000000000000000000000000025"); restHelper.toUrl("/api/v1/tasks/TKI:000000000000000000000000000000000025");
// retrieve task from Rest Api // retrieve task from Rest Api
ResponseEntity<TaskResource> responseGet = ResponseEntity<TaskRepresentationModel> responseGet =
template.exchange( template.exchange(
taskUrlString, taskUrlString,
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<>(restHelper.getHeadersUser_1_2()), new HttpEntity<>(restHelper.getHeadersUser_1_2()),
ParameterizedTypeReference.forType(TaskResource.class)); ParameterizedTypeReference.forType(TaskRepresentationModel.class));
assertThat(responseGet.getBody()).isNotNull(); assertThat(responseGet.getBody()).isNotNull();
TaskResource theTaskResource = responseGet.getBody(); TaskRepresentationModel theTaskRepresentationModel = responseGet.getBody();
assertThat(theTaskResource.getState()).isEqualTo(TaskState.READY); assertThat(theTaskRepresentationModel.getState()).isEqualTo(TaskState.READY);
assertThat(theTaskResource.getOwner() == null); assertThat(theTaskRepresentationModel.getOwner()).isNull();
// set Owner and update Task // set Owner and update Task
final String anyUserName = "dummyUser"; final String anyUserName = "dummyUser";
theTaskResource.setOwner(anyUserName); theTaskRepresentationModel.setOwner(anyUserName);
ResponseEntity<TaskResource> responseUpdate = ResponseEntity<TaskRepresentationModel> responseUpdate =
template.exchange( template.exchange(
taskUrlString, taskUrlString,
HttpMethod.PUT, HttpMethod.PUT,
new HttpEntity<>(theTaskResource, restHelper.getHeadersUser_1_2()), new HttpEntity<>(theTaskRepresentationModel, restHelper.getHeadersUser_1_2()),
ParameterizedTypeReference.forType(TaskResource.class)); ParameterizedTypeReference.forType(TaskRepresentationModel.class));
assertThat(responseUpdate.getBody()).isNotNull(); assertThat(responseUpdate.getBody()).isNotNull();
TaskResource theUpdatedTaskResource = responseUpdate.getBody(); TaskRepresentationModel theUpdatedTaskRepresentationModel = responseUpdate.getBody();
assertThat(theUpdatedTaskResource.getState()).isEqualTo(TaskState.READY); assertThat(theUpdatedTaskRepresentationModel.getState()).isEqualTo(TaskState.READY);
assertThat(theUpdatedTaskResource.getOwner()).isEqualTo(anyUserName); assertThat(theUpdatedTaskRepresentationModel.getOwner()).isEqualTo(anyUserName);
} }
@Test @Test
@ -826,41 +846,42 @@ class TaskControllerIntTest {
restHelper.toUrl("/api/v1/tasks/TKI:000000000000000000000000000000000026"); restHelper.toUrl("/api/v1/tasks/TKI:000000000000000000000000000000000026");
// retrieve task from Rest Api // retrieve task from Rest Api
ResponseEntity<TaskResource> responseGet = ResponseEntity<TaskRepresentationModel> responseGet =
template.exchange( template.exchange(
taskUrlString, taskUrlString,
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<>(restHelper.getHeadersUser_1_2()), new HttpEntity<>(restHelper.getHeadersUser_1_2()),
ParameterizedTypeReference.forType(TaskResource.class)); ParameterizedTypeReference.forType(TaskRepresentationModel.class));
assertThat(responseGet.getBody()).isNotNull(); assertThat(responseGet.getBody()).isNotNull();
TaskResource theTaskResource = responseGet.getBody(); TaskRepresentationModel theTaskRepresentationModel = responseGet.getBody();
assertThat(theTaskResource.getState()).isEqualTo(TaskState.CLAIMED); assertThat(theTaskRepresentationModel.getState()).isEqualTo(TaskState.CLAIMED);
assertThat(theTaskResource.getOwner()).isEqualTo("user_1_1"); assertThat(theTaskRepresentationModel.getOwner()).isEqualTo("user_1_1");
// set Owner and update Task // set Owner and update Task
final String anyUserName = "dummyuser"; final String anyUserName = "dummyuser";
theTaskResource.setOwner(anyUserName); theTaskRepresentationModel.setOwner(anyUserName);
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> template.exchange(
template.exchange( taskUrlString,
taskUrlString, HttpMethod.PUT,
HttpMethod.PUT, new HttpEntity<>(theTaskRepresentationModel, restHelper.getHeadersUser_1_2()),
new HttpEntity<>(theTaskResource, restHelper.getHeadersUser_1_2()), ParameterizedTypeReference.forType(TaskRepresentationModel.class));
ParameterizedTypeReference.forType(TaskResource.class));
};
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining("409"); .hasMessageContaining("409");
} }
private TaskResource getTaskResourceSample() { private TaskRepresentationModel getTaskResourceSample() {
ClassificationSummaryResource classificationResource = new ClassificationSummaryResource(); ClassificationSummaryRepresentationModel classificationResource =
new ClassificationSummaryRepresentationModel();
classificationResource.setKey("L11010"); classificationResource.setKey("L11010");
WorkbasketSummaryResource workbasketSummaryResource = new WorkbasketSummaryResource(); WorkbasketSummaryRepresentationModel workbasketSummary =
workbasketSummaryResource.setWorkbasketId("WBI:100000000000000000000000000000000004"); new WorkbasketSummaryRepresentationModel();
workbasketSummary.setWorkbasketId(
"WBI:100000000000000000000000000000000004");
ObjectReference objectReference = new ObjectReference(); ObjectReference objectReference = new ObjectReference();
objectReference.setCompany("MyCompany1"); objectReference.setCompany("MyCompany1");
@ -869,10 +890,11 @@ class TaskControllerIntTest {
objectReference.setType("MyType1"); objectReference.setType("MyType1");
objectReference.setValue("00000001"); objectReference.setValue("00000001");
TaskResource taskResource = new TaskResource(); TaskRepresentationModel taskRepresentationModel = new TaskRepresentationModel();
taskResource.setClassificationSummaryResource(classificationResource); taskRepresentationModel.setClassificationSummary(classificationResource);
taskResource.setWorkbasketSummaryResource(workbasketSummaryResource); taskRepresentationModel.setWorkbasketSummary(
taskResource.setPrimaryObjRef(objectReference); workbasketSummary);
return taskResource; taskRepresentationModel.setPrimaryObjRef(objectReference);
return taskRepresentationModel;
} }
} }

View File

@ -14,7 +14,7 @@ import org.springframework.web.client.RestTemplate;
import pro.taskana.RestHelper; import pro.taskana.RestHelper;
import pro.taskana.TaskanaSpringBootTest; import pro.taskana.TaskanaSpringBootTest;
import pro.taskana.common.api.TaskanaRole; import pro.taskana.common.api.TaskanaRole;
import pro.taskana.rest.resource.TaskanaUserInfoResource; import pro.taskana.rest.resource.TaskanaUserInfoRepresentationModel;
/** Test TaskanaEngineController. */ /** Test TaskanaEngineController. */
@TaskanaSpringBootTest @TaskanaSpringBootTest
@ -63,12 +63,12 @@ class TaskanaEngineControllerIntTest {
@Test @Test
void testGetCurrentUserInfo() { void testGetCurrentUserInfo() {
ResponseEntity<TaskanaUserInfoResource> response = ResponseEntity<TaskanaUserInfoRepresentationModel> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CURRENT_USER), restHelper.toUrl(Mapping.URL_CURRENT_USER),
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(TaskanaUserInfoResource.class)); ParameterizedTypeReference.forType(TaskanaUserInfoRepresentationModel.class));
assertThat(response.getBody().getUserId()).isEqualTo("teamlead_1"); assertThat(response.getBody().getUserId()).isEqualTo("teamlead_1");
assertThat(response.getBody().getGroupIds()).contains("businessadmin"); assertThat(response.getBody().getGroupIds()).contains("businessadmin");
assertThat(response.getBody().getRoles()).contains(TaskanaRole.BUSINESS_ADMIN); assertThat(response.getBody().getRoles()).contains(TaskanaRole.BUSINESS_ADMIN);

View File

@ -19,13 +19,19 @@ import org.springframework.web.client.RestTemplate;
import pro.taskana.RestHelper; import pro.taskana.RestHelper;
import pro.taskana.TaskanaSpringBootTest; import pro.taskana.TaskanaSpringBootTest;
import pro.taskana.rest.resource.WorkbasketAccessItemListResource; import pro.taskana.rest.resource.TaskanaPagedModel;
import pro.taskana.rest.resource.WorkbasketAccessItemRepresentationModel;
/** Test WorkbasketAccessItemController. */ /** Test WorkbasketAccessItemController. */
@TestMethodOrder(MethodOrderer.Alphanumeric.class) @TestMethodOrder(MethodOrderer.Alphanumeric.class)
@TaskanaSpringBootTest @TaskanaSpringBootTest
class WorkbasketAccessItemControllerIntTest { class WorkbasketAccessItemControllerIntTest {
private static final ParameterizedTypeReference<
TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>>
WORKBASKET_ACCESS_ITEM_PAGE_MODEL_TYPE =
new ParameterizedTypeReference<
TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>>() {};
private static RestTemplate template; private static RestTemplate template;
@Autowired RestHelper restHelper; @Autowired RestHelper restHelper;
@ -36,24 +42,26 @@ class WorkbasketAccessItemControllerIntTest {
@Test @Test
void testGetAllWorkbasketAccessItems() { void testGetAllWorkbasketAccessItems() {
ResponseEntity<WorkbasketAccessItemListResource> response = ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS), restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS),
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class)); WORKBASKET_ACCESS_ITEM_PAGE_MODEL_TYPE);
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
} }
@Test @Test
void testGetWorkbasketAccessItemsKeepingFilters() { void testGetWorkbasketAccessItemsKeepingFilters() {
String parameters = "?sort-by=workbasket-key&order=asc&page=1&page-size=9&access-ids=user_1_1"; String parameters = "?sort-by=workbasket-key&order=asc&page-size=9&access-ids=user_1_1&page=1";
ResponseEntity<WorkbasketAccessItemListResource> response = ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS) + parameters, restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS) + parameters,
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class)); WORKBASKET_ACCESS_ITEM_PAGE_MODEL_TYPE);
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat( assertThat(
response response
@ -67,14 +75,12 @@ class WorkbasketAccessItemControllerIntTest {
@Test @Test
void testThrowsExceptionIfInvalidFilterIsUsed() { void testThrowsExceptionIfInvalidFilterIsUsed() {
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> template.exchange(
template.exchange( restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS)
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS) + "?sort-by=workbasket-key&order=asc&page=1&page-size=9&invalid=user_1_1",
+ "?sort-by=workbasket-key&order=asc&page=1&page-size=9&invalid=user_1_1", HttpMethod.GET,
HttpMethod.GET, restHelper.defaultRequest(),
restHelper.defaultRequest(), WORKBASKET_ACCESS_ITEM_PAGE_MODEL_TYPE);
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class));
};
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining("[invalid]") .hasMessageContaining("[invalid]")
@ -84,13 +90,14 @@ class WorkbasketAccessItemControllerIntTest {
@Test @Test
void testGetSecondPageSortedByWorkbasketKey() { void testGetSecondPageSortedByWorkbasketKey() {
String parameters = "?sort-by=workbasket-key&order=asc&page=2&page-size=9&access-ids=user_1_1"; String parameters = "?sort-by=workbasket-key&order=asc&page-size=9&access-ids=user_1_1&page=1";
ResponseEntity<WorkbasketAccessItemListResource> response = ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS) + parameters, restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS) + parameters,
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class)); WORKBASKET_ACCESS_ITEM_PAGE_MODEL_TYPE);
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getContent()).hasSize(1); assertThat(response.getBody().getContent()).hasSize(1);
assertThat(response.getBody().getContent().iterator().next().getAccessId()) assertThat(response.getBody().getContent().iterator().next().getAccessId())
.isEqualTo("user_1_1"); .isEqualTo("user_1_1");
@ -128,13 +135,11 @@ class WorkbasketAccessItemControllerIntTest {
void testGetBadRequestIfTryingToDeleteAccessItemsForGroup() { void testGetBadRequestIfTryingToDeleteAccessItemsForGroup() {
String parameters = "?access-id=cn=DevelopersGroup,ou=groups,o=TaskanaTest"; String parameters = "?access-id=cn=DevelopersGroup,ou=groups,o=TaskanaTest";
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> template.exchange(
template.exchange( restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS) + parameters,
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS) + parameters, HttpMethod.DELETE,
HttpMethod.DELETE, restHelper.defaultRequest(),
restHelper.defaultRequest(), ParameterizedTypeReference.forType(Void.class));
ParameterizedTypeReference.forType(Void.class));
};
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())

View File

@ -21,17 +21,26 @@ import org.springframework.web.client.RestTemplate;
import pro.taskana.RestHelper; import pro.taskana.RestHelper;
import pro.taskana.TaskanaSpringBootTest; import pro.taskana.TaskanaSpringBootTest;
import pro.taskana.rest.resource.DistributionTargetListResource; import pro.taskana.rest.resource.TaskanaPagedModel;
import pro.taskana.rest.resource.DistributionTargetResource; import pro.taskana.rest.resource.WorkbasketAccessItemRepresentationModel;
import pro.taskana.rest.resource.WorkbasketAccessItemListResource; import pro.taskana.rest.resource.WorkbasketRepresentationModel;
import pro.taskana.rest.resource.WorkbasketResource; import pro.taskana.rest.resource.WorkbasketSummaryRepresentationModel;
import pro.taskana.rest.resource.WorkbasketSummaryListResource;
import pro.taskana.workbasket.api.WorkbasketType; import pro.taskana.workbasket.api.WorkbasketType;
/** Test WorkbasketController. */ /** Test WorkbasketController. */
@TaskanaSpringBootTest @TaskanaSpringBootTest
class WorkbasketControllerIntTest { class WorkbasketControllerIntTest {
private static final ParameterizedTypeReference<
TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>>
WORKBASKET_ACCESS_ITEM_PAGE_MODEL_TYPE =
new ParameterizedTypeReference<
TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>>() {};
private static final ParameterizedTypeReference<
TaskanaPagedModel<WorkbasketSummaryRepresentationModel>>
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE =
new ParameterizedTypeReference<
TaskanaPagedModel<WorkbasketSummaryRepresentationModel>>() {};
private static RestTemplate template; private static RestTemplate template;
@Autowired RestHelper restHelper; @Autowired RestHelper restHelper;
@ -42,12 +51,12 @@ class WorkbasketControllerIntTest {
@Test @Test
void testGetWorkbasket() { void testGetWorkbasket() {
ResponseEntity<WorkbasketResource> response = ResponseEntity<WorkbasketRepresentationModel> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, "WBI:100000000000000000000000000000000006"), restHelper.toUrl(Mapping.URL_WORKBASKET_ID, "WBI:100000000000000000000000000000000006"),
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(WorkbasketResource.class)); ParameterizedTypeReference.forType(WorkbasketRepresentationModel.class));
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getHeaders().getContentType().toString()) assertThat(response.getHeaders().getContentType().toString())
.isEqualTo(MediaTypes.HAL_JSON_VALUE); .isEqualTo(MediaTypes.HAL_JSON_VALUE);
@ -55,23 +64,23 @@ class WorkbasketControllerIntTest {
@Test @Test
void testGetAllWorkbaskets() { void testGetAllWorkbaskets() {
ResponseEntity<WorkbasketSummaryListResource> response = ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_WORKBASKET), restHelper.toUrl(Mapping.URL_WORKBASKET),
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class)); WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
} }
@Test @Test
void testGetAllWorkbasketsBusinessAdminHasOpenPermission() { void testGetAllWorkbasketsBusinessAdminHasOpenPermission() {
ResponseEntity<WorkbasketSummaryListResource> response = ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_WORKBASKET) + "?required-permission=OPEN", restHelper.toUrl(Mapping.URL_WORKBASKET) + "?required-permission=OPEN",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class)); WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getRequiredLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getRequiredLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getBody().getContent()).hasSize(3); assertThat(response.getBody().getContent()).hasSize(3);
} }
@ -79,12 +88,12 @@ class WorkbasketControllerIntTest {
@Test @Test
void testGetAllWorkbasketsKeepingFilters() { void testGetAllWorkbasketsKeepingFilters() {
String parameters = "?type=PERSONAL&sort-by=key&order=desc"; String parameters = "?type=PERSONAL&sort-by=key&order=desc";
ResponseEntity<WorkbasketSummaryListResource> response = ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_WORKBASKET) + parameters, restHelper.toUrl(Mapping.URL_WORKBASKET) + parameters,
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class)); WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat( assertThat(
response response
@ -98,13 +107,11 @@ class WorkbasketControllerIntTest {
@Test @Test
void testThrowsExceptionIfInvalidFilterIsUsed() { void testThrowsExceptionIfInvalidFilterIsUsed() {
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> template.exchange(
template.exchange( restHelper.toUrl(Mapping.URL_WORKBASKET) + "?invalid=PERSONAL",
restHelper.toUrl(Mapping.URL_WORKBASKET) + "?invalid=PERSONAL", HttpMethod.GET,
HttpMethod.GET, restHelper.defaultRequest(),
restHelper.defaultRequest(), WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
};
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining("[invalid]") .hasMessageContaining("[invalid]")
@ -119,21 +126,22 @@ class WorkbasketControllerIntTest {
final ObjectMapper mapper = new ObjectMapper(); final ObjectMapper mapper = new ObjectMapper();
ResponseEntity<WorkbasketResource> initialWorkbasketResourceRequestResponse = ResponseEntity<WorkbasketRepresentationModel> initialWorkbasketResourceRequestResponse =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId), restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId),
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<String>(restHelper.getHeaders()), new HttpEntity<String>(restHelper.getHeaders()),
ParameterizedTypeReference.forType(WorkbasketResource.class)); ParameterizedTypeReference.forType(WorkbasketRepresentationModel.class));
WorkbasketResource workbasketResource = initialWorkbasketResourceRequestResponse.getBody(); WorkbasketRepresentationModel workbasketRepresentationModel =
initialWorkbasketResourceRequestResponse.getBody();
workbasketResource.setKey("GPK_KSC"); workbasketRepresentationModel.setKey("GPK_KSC");
workbasketResource.setDomain("DOMAIN_A"); workbasketRepresentationModel.setDomain("DOMAIN_A");
workbasketResource.setType(WorkbasketType.PERSONAL); workbasketRepresentationModel.setType(WorkbasketType.PERSONAL);
workbasketResource.setName("was auch immer"); workbasketRepresentationModel.setName("was auch immer");
workbasketResource.setOwner("Joerg"); workbasketRepresentationModel.setOwner("Joerg");
workbasketResource.setModified(String.valueOf(Instant.now())); workbasketRepresentationModel.setModified(String.valueOf(Instant.now()));
ThrowingCallable httpCall = ThrowingCallable httpCall =
() -> { () -> {
@ -141,8 +149,9 @@ class WorkbasketControllerIntTest {
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId), restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId),
HttpMethod.PUT, HttpMethod.PUT,
new HttpEntity<>( new HttpEntity<>(
mapper.writeValueAsString(workbasketResource), restHelper.getHeaders()), mapper.writeValueAsString(workbasketRepresentationModel),
ParameterizedTypeReference.forType(WorkbasketResource.class)); restHelper.getHeaders()),
ParameterizedTypeReference.forType(WorkbasketRepresentationModel.class));
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
@ -160,7 +169,7 @@ class WorkbasketControllerIntTest {
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId), restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId),
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<String>(restHelper.getHeaders()), new HttpEntity<String>(restHelper.getHeaders()),
ParameterizedTypeReference.forType(WorkbasketResource.class)); ParameterizedTypeReference.forType(WorkbasketRepresentationModel.class));
}; };
assertThatThrownBy(httpCall) assertThatThrownBy(httpCall)
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
@ -171,13 +180,13 @@ class WorkbasketControllerIntTest {
@Test @Test
void testGetSecondPageSortedByKey() { void testGetSecondPageSortedByKey() {
String parameters = "?sort-by=key&order=desc&page=2&page-size=5"; String parameters = "?sort-by=key&order=desc&page-size=5&page=2";
ResponseEntity<WorkbasketSummaryListResource> response = ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_WORKBASKET) + parameters, restHelper.toUrl(Mapping.URL_WORKBASKET) + parameters,
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class)); WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getContent()).hasSize(5); assertThat(response.getBody().getContent()).hasSize(5);
assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("USER_1_1"); assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("USER_1_1");
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
@ -236,30 +245,30 @@ class WorkbasketControllerIntTest {
Void.class); Void.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
ResponseEntity<DistributionTargetListResource> response2 = ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response2 =
template.exchange( template.exchange(
restHelper.toUrl( restHelper.toUrl(
Mapping.URL_WORKBASKET_ID_DISTRIBUTION, "WBI:100000000000000000000000000000000002"), Mapping.URL_WORKBASKET_ID_DISTRIBUTION, "WBI:100000000000000000000000000000000002"),
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(DistributionTargetListResource.class)); WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response2.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(response2.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat( assertThat(
response2.getBody().getContent().stream() response2.getBody().getContent().stream()
.map(DistributionTargetResource::getWorkbasketId) .map(WorkbasketSummaryRepresentationModel::getWorkbasketId)
.noneMatch("WBI:100000000000000000000000000000000007"::equals)) .noneMatch("WBI:100000000000000000000000000000000007"::equals))
.isTrue(); .isTrue();
} }
@Test @Test
void testGetWorkbasketAccessItems() { void testGetWorkbasketAccessItems() {
ResponseEntity<WorkbasketAccessItemListResource> response = ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl( restHelper.toUrl(
Mapping.URL_WORKBASKET_ID_ACCESSITEMS, "WBI:100000000000000000000000000000000005"), Mapping.URL_WORKBASKET_ID_ACCESSITEMS, "WBI:100000000000000000000000000000000005"),
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class)); WORKBASKET_ACCESS_ITEM_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getHeaders().getContentType().toString()) assertThat(response.getHeaders().getContentType().toString())
.isEqualTo(MediaTypes.HAL_JSON_VALUE); .isEqualTo(MediaTypes.HAL_JSON_VALUE);
@ -268,13 +277,13 @@ class WorkbasketControllerIntTest {
@Test @Test
void testGetWorkbasketDistributionTargets() { void testGetWorkbasketDistributionTargets() {
ResponseEntity<DistributionTargetListResource> response = ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
template.exchange( template.exchange(
restHelper.toUrl( restHelper.toUrl(
Mapping.URL_WORKBASKET_ID_DISTRIBUTION, "WBI:100000000000000000000000000000000001"), Mapping.URL_WORKBASKET_ID_DISTRIBUTION, "WBI:100000000000000000000000000000000001"),
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(DistributionTargetListResource.class)); WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull(); assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
assertThat(response.getHeaders().getContentType().toString()) assertThat(response.getHeaders().getContentType().toString())
.isEqualTo(MediaTypes.HAL_JSON_VALUE); .isEqualTo(MediaTypes.HAL_JSON_VALUE);

View File

@ -38,7 +38,7 @@ import org.springframework.web.client.RestTemplate;
import pro.taskana.RestHelper; import pro.taskana.RestHelper;
import pro.taskana.TaskanaSpringBootTest; import pro.taskana.TaskanaSpringBootTest;
import pro.taskana.rest.resource.WorkbasketDefinitionResource; import pro.taskana.rest.resource.WorkbasketDefinitionRepresentationModel;
import pro.taskana.sampledata.SampleDataGenerator; import pro.taskana.sampledata.SampleDataGenerator;
/** Integration tests for WorkbasketDefinitionController. */ /** Integration tests for WorkbasketDefinitionController. */
@ -69,16 +69,17 @@ class WorkbasketDefinitionControllerIntTest {
@Test @Test
void testExportWorkbasketFromDomain() { void testExportWorkbasketFromDomain() {
ResponseEntity<List<WorkbasketDefinitionResource>> response = ResponseEntity<List<WorkbasketDefinitionRepresentationModel>> response =
executeExportRequestForDomain("DOMAIN_A"); executeExportRequestForDomain("DOMAIN_A");
assertThat(response.getBody()).isNotNull(); assertThat(response.getBody()).isNotNull();
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getBody().get(0)).isInstanceOf(WorkbasketDefinitionResource.class); assertThat(response.getBody().get(0))
.isInstanceOf(WorkbasketDefinitionRepresentationModel.class);
boolean allAuthorizationsAreEmpty = true; boolean allAuthorizationsAreEmpty = true;
boolean allDistributionTargetsAreEmpty = true; boolean allDistributionTargetsAreEmpty = true;
for (WorkbasketDefinitionResource workbasketDefinition : response.getBody()) { for (WorkbasketDefinitionRepresentationModel workbasketDefinition : response.getBody()) {
if (allAuthorizationsAreEmpty && !workbasketDefinition.getAuthorizations().isEmpty()) { if (allAuthorizationsAreEmpty && !workbasketDefinition.getAuthorizations().isEmpty()) {
allAuthorizationsAreEmpty = false; allAuthorizationsAreEmpty = false;
} }
@ -96,22 +97,24 @@ class WorkbasketDefinitionControllerIntTest {
@Test @Test
void testExportWorkbasketsFromWrongDomain() { void testExportWorkbasketsFromWrongDomain() {
ResponseEntity<List<WorkbasketDefinitionResource>> response = ResponseEntity<List<WorkbasketDefinitionRepresentationModel>> response =
executeExportRequestForDomain("wrongDomain"); executeExportRequestForDomain("wrongDomain");
assertThat(response.getBody()).isEmpty(); assertThat(response.getBody()).isEmpty();
} }
@Test @Test
void testImportEveryWorkbasketFromDomainA() throws IOException { void testImportEveryWorkbasketFromDomainA() throws IOException {
List<WorkbasketDefinitionResource> wbList = executeExportRequestForDomain("DOMAIN_A").getBody(); List<WorkbasketDefinitionRepresentationModel> wbList =
for (WorkbasketDefinitionResource w : wbList) { executeExportRequestForDomain("DOMAIN_A").getBody();
for (WorkbasketDefinitionRepresentationModel w : wbList) {
expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.NO_CONTENT, w); expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.NO_CONTENT, w);
} }
} }
@Test @Test
void testImportWorkbasketWithoutDistributionTargets() throws IOException { void testImportWorkbasketWithoutDistributionTargets() throws IOException {
WorkbasketDefinitionResource w = executeExportRequestForDomain("DOMAIN_A").getBody().get(0); WorkbasketDefinitionRepresentationModel w =
executeExportRequestForDomain("DOMAIN_A").getBody().get(0);
w.setDistributionTargets(new HashSet<>()); w.setDistributionTargets(new HashSet<>());
this.expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.NO_CONTENT, w); this.expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.NO_CONTENT, w);
@ -123,12 +126,13 @@ class WorkbasketDefinitionControllerIntTest {
@Test @Test
void testImportWorkbasketWithDistributionTargetsInImportFile() throws IOException { void testImportWorkbasketWithDistributionTargetsInImportFile() throws IOException {
List<WorkbasketDefinitionResource> wbList = executeExportRequestForDomain("DOMAIN_A").getBody(); List<WorkbasketDefinitionRepresentationModel> wbList =
executeExportRequestForDomain("DOMAIN_A").getBody();
WorkbasketDefinitionResource w = wbList.get(0); WorkbasketDefinitionRepresentationModel w = wbList.get(0);
w.setDistributionTargets(new HashSet<>()); w.setDistributionTargets(new HashSet<>());
String letMeBeYourDistributionTarget = w.getWorkbasket().getWorkbasketId(); String letMeBeYourDistributionTarget = w.getWorkbasket().getWorkbasketId();
WorkbasketDefinitionResource w2 = wbList.get(1); WorkbasketDefinitionRepresentationModel w2 = wbList.get(1);
w2.setDistributionTargets(Collections.singleton(letMeBeYourDistributionTarget)); w2.setDistributionTargets(Collections.singleton(letMeBeYourDistributionTarget));
expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.NO_CONTENT, w, w2); expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.NO_CONTENT, w, w2);
@ -145,10 +149,11 @@ class WorkbasketDefinitionControllerIntTest {
@Test @Test
void testImportWorkbasketWithDistributionTargetsInSystem() throws IOException { void testImportWorkbasketWithDistributionTargetsInSystem() throws IOException {
List<WorkbasketDefinitionResource> wbList = executeExportRequestForDomain("DOMAIN_A").getBody(); List<WorkbasketDefinitionRepresentationModel> wbList =
executeExportRequestForDomain("DOMAIN_A").getBody();
wbList.removeIf(definition -> definition.getDistributionTargets().isEmpty()); wbList.removeIf(definition -> definition.getDistributionTargets().isEmpty());
WorkbasketDefinitionResource w = wbList.get(0); WorkbasketDefinitionRepresentationModel w = wbList.get(0);
expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.NO_CONTENT, w); expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.NO_CONTENT, w);
changeWorkbasketIdOrKey(w, null, "new"); changeWorkbasketIdOrKey(w, null, "new");
@ -157,9 +162,10 @@ class WorkbasketDefinitionControllerIntTest {
@Test @Test
void testImportWorkbasketWithDistributionTargetsNotInSystem() throws IOException { void testImportWorkbasketWithDistributionTargetsNotInSystem() throws IOException {
List<WorkbasketDefinitionResource> wbList = executeExportRequestForDomain("DOMAIN_A").getBody(); List<WorkbasketDefinitionRepresentationModel> wbList =
executeExportRequestForDomain("DOMAIN_A").getBody();
WorkbasketDefinitionResource w = wbList.get(0); WorkbasketDefinitionRepresentationModel w = wbList.get(0);
w.setDistributionTargets(Collections.singleton("invalidWorkbasketId")); w.setDistributionTargets(Collections.singleton("invalidWorkbasketId"));
try { try {
expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.BAD_REQUEST, w); expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.BAD_REQUEST, w);
@ -179,7 +185,8 @@ class WorkbasketDefinitionControllerIntTest {
@Test @Test
void testFailOnImportDuplicates() throws IOException { void testFailOnImportDuplicates() throws IOException {
WorkbasketDefinitionResource w = executeExportRequestForDomain("DOMAIN_A").getBody().get(0); WorkbasketDefinitionRepresentationModel w =
executeExportRequestForDomain("DOMAIN_A").getBody().get(0);
try { try {
expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.CONFLICT, w, w); expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.CONFLICT, w, w);
fail("Expected http-Status 409"); fail("Expected http-Status 409");
@ -190,14 +197,15 @@ class WorkbasketDefinitionControllerIntTest {
@Test @Test
void testNoErrorWhenImportWithSameIdButDifferentKeyAndDomain() throws IOException { void testNoErrorWhenImportWithSameIdButDifferentKeyAndDomain() throws IOException {
List<WorkbasketDefinitionResource> wbList = executeExportRequestForDomain("DOMAIN_A").getBody(); List<WorkbasketDefinitionRepresentationModel> wbList =
executeExportRequestForDomain("DOMAIN_A").getBody();
WorkbasketDefinitionResource w = wbList.get(0); WorkbasketDefinitionRepresentationModel w = wbList.get(0);
WorkbasketDefinitionResource differentLogicalId = wbList.get(1); WorkbasketDefinitionRepresentationModel differentLogicalId = wbList.get(1);
this.changeWorkbasketIdOrKey(differentLogicalId, w.getWorkbasket().getWorkbasketId(), null); this.changeWorkbasketIdOrKey(differentLogicalId, w.getWorkbasket().getWorkbasketId(), null);
// breaks the logic but not the script- should we really allow this case? // breaks the logic but not the script- should we really allow this case?
WorkbasketDefinitionResource theDestroyer = wbList.get(2); WorkbasketDefinitionRepresentationModel theDestroyer = wbList.get(2);
theDestroyer.setDistributionTargets( theDestroyer.setDistributionTargets(
Collections.singleton(differentLogicalId.getWorkbasket().getWorkbasketId())); Collections.singleton(differentLogicalId.getWorkbasket().getWorkbasketId()));
@ -207,7 +215,8 @@ class WorkbasketDefinitionControllerIntTest {
@Test @Test
void testErrorWhenImportWithSameAccessIdAndWorkbasket() { void testErrorWhenImportWithSameAccessIdAndWorkbasket() {
WorkbasketDefinitionResource w = executeExportRequestForDomain("DOMAIN_A").getBody().get(0); WorkbasketDefinitionRepresentationModel w =
executeExportRequestForDomain("DOMAIN_A").getBody().get(0);
String w1String = workbasketToString(w); String w1String = workbasketToString(w);
w.getWorkbasket().setKey("new Key for this WB"); w.getWorkbasket().setKey("new Key for this WB");
@ -221,7 +230,7 @@ class WorkbasketDefinitionControllerIntTest {
} }
private void changeWorkbasketIdOrKey( private void changeWorkbasketIdOrKey(
WorkbasketDefinitionResource w, String newId, String newKey) { WorkbasketDefinitionRepresentationModel w, String newId, String newKey) {
if (newId != null && !newId.isEmpty()) { if (newId != null && !newId.isEmpty()) {
w.getWorkbasket().setWorkbasketId(newId); w.getWorkbasket().setWorkbasketId(newId);
w.getAuthorizations().forEach(auth -> auth.setWorkbasketId(newId)); w.getAuthorizations().forEach(auth -> auth.setWorkbasketId(newId));
@ -232,17 +241,18 @@ class WorkbasketDefinitionControllerIntTest {
} }
} }
private ResponseEntity<List<WorkbasketDefinitionResource>> executeExportRequestForDomain( private ResponseEntity<List<WorkbasketDefinitionRepresentationModel>>
String domain) { executeExportRequestForDomain(String domain) {
return template.exchange( return template.exchange(
restHelper.toUrl(Mapping.URL_WORKBASKETDEFIITIONS) + "?domain=" + domain, restHelper.toUrl(Mapping.URL_WORKBASKETDEFIITIONS) + "?domain=" + domain,
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
new ParameterizedTypeReference<List<WorkbasketDefinitionResource>>() {}); new ParameterizedTypeReference<List<WorkbasketDefinitionRepresentationModel>>() {});
} }
private void expectStatusWhenExecutingImportRequestOfWorkbaskets( private void expectStatusWhenExecutingImportRequestOfWorkbaskets(
HttpStatus expectedStatus, WorkbasketDefinitionResource... workbaskets) throws IOException { HttpStatus expectedStatus, WorkbasketDefinitionRepresentationModel... workbaskets)
throws IOException {
List<String> workbasketStrings = List<String> workbasketStrings =
Arrays.stream(workbaskets).map(this::workbasketToString).collect(Collectors.toList()); Arrays.stream(workbaskets).map(this::workbasketToString).collect(Collectors.toList());
expectStatusWhenExecutingImportRequestOfWorkbaskets(expectedStatus, workbasketStrings); expectStatusWhenExecutingImportRequestOfWorkbaskets(expectedStatus, workbasketStrings);
@ -268,9 +278,10 @@ class WorkbasketDefinitionControllerIntTest {
assertThat(responseImport.getStatusCode()).isEqualTo(expectedStatus); assertThat(responseImport.getStatusCode()).isEqualTo(expectedStatus);
} }
private String workbasketToString(WorkbasketDefinitionResource workbasketDefinitionResource) { private String workbasketToString(
WorkbasketDefinitionRepresentationModel workbasketDefinitionRepresentationModel) {
try { try {
return objMapper.writeValueAsString(workbasketDefinitionResource); return objMapper.writeValueAsString(workbasketDefinitionRepresentationModel);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
return ""; return "";
} }

View File

@ -12,11 +12,11 @@ import pro.taskana.classification.api.models.Classification;
import pro.taskana.classification.internal.models.ClassificationImpl; import pro.taskana.classification.internal.models.ClassificationImpl;
import pro.taskana.rest.Mapping; import pro.taskana.rest.Mapping;
/** Test for {@link ClassificationResourceAssembler}. */ /** Test for {@link ClassificationRepresentationModelAssembler}. */
@TaskanaSpringBootTest @TaskanaSpringBootTest
class ClassificationAssemblerTest { class ClassificationAssemblerTest {
@Autowired ClassificationResourceAssembler classificationResourceAssembler; @Autowired ClassificationRepresentationModelAssembler classificationRepresentationModelAssembler;
@Autowired ClassificationService classificationService; @Autowired ClassificationService classificationService;
@ -46,11 +46,11 @@ class ClassificationAssemblerTest {
classification.setCreated(Instant.parse("2010-01-01T12:00:00Z")); classification.setCreated(Instant.parse("2010-01-01T12:00:00Z"));
classification.setModified(Instant.parse("2011-11-11T11:00:00Z")); classification.setModified(Instant.parse("2011-11-11T11:00:00Z"));
// when // when
ClassificationResource classificationResource = ClassificationRepresentationModel classificationRepresentationModel =
classificationResourceAssembler.toModel(classification); classificationRepresentationModelAssembler.toModel(classification);
// then // then
testEquality(classification, classificationResource); testEquality(classification, classificationRepresentationModel);
testLinks(classificationResource); testLinks(classificationRepresentationModel);
} }
@Test @Test
@ -80,48 +80,68 @@ class ClassificationAssemblerTest {
classification.setDescription("Test"); classification.setDescription("Test");
classification.setIsValidInDomain(true); classification.setIsValidInDomain(true);
ClassificationResource classificationResource = new ClassificationResource(classification); ClassificationRepresentationModel classificationRepresentationModel =
new ClassificationRepresentationModel(classification);
// when // when
classification = classification =
(ClassificationImpl) classificationResourceAssembler.toModel(classificationResource); (ClassificationImpl)
classificationRepresentationModelAssembler
.toEntityModel(classificationRepresentationModel);
// then // then
testEquality(classification, classificationResource); testEquality(classification, classificationRepresentationModel);
} }
private void testLinks(ClassificationResource resource) { private void testLinks(ClassificationRepresentationModel resource) {
assertThat(resource.getLinks()).hasSize(1); assertThat(resource.getLinks()).hasSize(1);
assertThat(Mapping.URL_CLASSIFICATIONS_ID.replaceAll("\\{.*}", resource.getClassificationId())) assertThat(Mapping.URL_CLASSIFICATIONS_ID.replaceAll("\\{.*}", resource.getClassificationId()))
.isEqualTo(resource.getRequiredLink("self").getHref()); .isEqualTo(resource.getRequiredLink("self").getHref());
} }
private void testEquality( private void testEquality(
Classification classification, ClassificationResource classificationResource) { Classification classification,
ClassificationRepresentationModel classificationRepresentationModel) {
assertThat(classification.getApplicationEntryPoint()) assertThat(classification.getApplicationEntryPoint())
.isEqualTo(classificationResource.getApplicationEntryPoint()); .isEqualTo(classificationRepresentationModel.getApplicationEntryPoint());
assertThat(classification.getKey()).isEqualTo(classificationResource.getKey()); assertThat(classification.getKey()).isEqualTo(classificationRepresentationModel.getKey());
assertThat(classification.getDomain()).isEqualTo(classificationResource.getDomain()); assertThat(classification.getDomain()).isEqualTo(classificationRepresentationModel.getDomain());
assertThat(classification.getId()).isEqualTo(classificationResource.getClassificationId()); assertThat(classification.getId())
assertThat(classification.getDescription()).isEqualTo(classificationResource.getDescription()); .isEqualTo(classificationRepresentationModel.getClassificationId());
assertThat(classification.getName()).isEqualTo(classificationResource.getName()); assertThat(classification.getDescription())
.isEqualTo(classificationRepresentationModel.getDescription());
assertThat(classification.getName()).isEqualTo(classificationRepresentationModel.getName());
assertThat(classification.getServiceLevel()) assertThat(classification.getServiceLevel())
.isEqualTo(classificationResource.getServiceLevel()); .isEqualTo(classificationRepresentationModel.getServiceLevel());
assertThat(classification.getCategory()).isEqualTo(classificationResource.getCategory()); assertThat(classification.getCategory())
assertThat(classification.getCustom1()).isEqualTo(classificationResource.getCustom1()); .isEqualTo(classificationRepresentationModel.getCategory());
assertThat(classification.getCustom2()).isEqualTo(classificationResource.getCustom2()); assertThat(classification.getCustom1())
assertThat(classification.getCustom3()).isEqualTo(classificationResource.getCustom3()); .isEqualTo(classificationRepresentationModel.getCustom1());
assertThat(classification.getCustom4()).isEqualTo(classificationResource.getCustom4()); assertThat(classification.getCustom2())
assertThat(classification.getCustom5()).isEqualTo(classificationResource.getCustom5()); .isEqualTo(classificationRepresentationModel.getCustom2());
assertThat(classification.getCustom6()).isEqualTo(classificationResource.getCustom6()); assertThat(classification.getCustom3())
assertThat(classification.getCustom7()).isEqualTo(classificationResource.getCustom7()); .isEqualTo(classificationRepresentationModel.getCustom3());
assertThat(classification.getCustom8()).isEqualTo(classificationResource.getCustom8()); assertThat(classification.getCustom4())
assertThat(classification.getParentId()).isEqualTo(classificationResource.getParentId()); .isEqualTo(classificationRepresentationModel.getCustom4());
assertThat(classification.getParentKey()).isEqualTo(classificationResource.getParentKey()); assertThat(classification.getCustom5())
assertThat(classification.getType()).isEqualTo(classificationResource.getType()); .isEqualTo(classificationRepresentationModel.getCustom5());
assertThat(classification.getPriority()).isEqualTo(classificationResource.getPriority()); assertThat(classification.getCustom6())
.isEqualTo(classificationRepresentationModel.getCustom6());
assertThat(classification.getCustom7())
.isEqualTo(classificationRepresentationModel.getCustom7());
assertThat(classification.getCustom8())
.isEqualTo(classificationRepresentationModel.getCustom8());
assertThat(classification.getParentId())
.isEqualTo(classificationRepresentationModel.getParentId());
assertThat(classification.getParentKey())
.isEqualTo(classificationRepresentationModel.getParentKey());
assertThat(classification.getType()).isEqualTo(classificationRepresentationModel.getType());
assertThat(classification.getPriority())
.isEqualTo(classificationRepresentationModel.getPriority());
assertThat(classification.getIsValidInDomain()) assertThat(classification.getIsValidInDomain())
.isEqualTo(classificationResource.getIsValidInDomain()); .isEqualTo(classificationRepresentationModel.getIsValidInDomain());
assertThat(classification.getCreated()).isEqualTo(classificationResource.getCreated()); assertThat(classification.getCreated())
assertThat(classification.getModified()).isEqualTo(classificationResource.getModified()); .isEqualTo(classificationRepresentationModel.getCreated());
assertThat(classification.getModified())
.isEqualTo(classificationRepresentationModel.getModified());
} }
} }

Some files were not shown because too many files have changed in this diff Show More