[TSK-1208] changed HATE terminology and replaced list resources with generic one
This commit is contained in:
parent
b82741a2b4
commit
bd116d4c2e
|
|
@ -6,6 +6,7 @@ import java.time.ZoneId;
|
|||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.hateoas.PagedModel.PageMetadata;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||
import org.springframework.http.HttpStatus;
|
||||
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.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.rest.AbstractPagingController;
|
||||
import pro.taskana.rest.resource.PagedResources.PageMetadata;
|
||||
import pro.taskana.simplehistory.impl.HistoryEventImpl;
|
||||
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
|
||||
import pro.taskana.simplehistory.query.HistoryQuery;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package pro.taskana.simplehistory.rest.resource;
|
|||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.Collection;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedModel.PageMetadata;
|
||||
|
||||
import pro.taskana.rest.resource.PagedResources;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedModel.PageMetadata;
|
||||
|
||||
import pro.taskana.rest.resource.AbstractRessourcesAssembler;
|
||||
import pro.taskana.rest.resource.PagedResources.PageMetadata;
|
||||
import pro.taskana.simplehistory.impl.HistoryEventImpl;
|
||||
import pro.taskana.simplehistory.rest.TaskHistoryEventController;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package pro.taskana.simplehistory.rest.resource;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
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}. */
|
||||
public class TaskHistoryEventResource extends RepresentationModel<TaskHistoryEventResource> {
|
||||
|
||||
@NotNull private String taskHistoryEventId;
|
||||
private String taskHistoryEventId;
|
||||
private String businessProcessId;
|
||||
private String parentBusinessProcessId;
|
||||
private String taskId;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
|
|||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
import pro.taskana.common.api.exceptions.SystemException;
|
||||
import pro.taskana.simplehistory.impl.HistoryEventImpl;
|
||||
|
|
@ -20,8 +21,9 @@ public class TaskHistoryEventResourceAssembler
|
|||
super(HistoryEventImpl.class, TaskHistoryEventResource.class);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public TaskHistoryEventResource toModel(TaskanaHistoryEvent historyEvent) {
|
||||
public TaskHistoryEventResource toModel(@NonNull TaskanaHistoryEvent historyEvent) {
|
||||
TaskHistoryEventResource resource = createModelWithId(historyEvent.getId(), historyEvent);
|
||||
try {
|
||||
resource.removeLinks();
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ public class DbSchemaCreator {
|
|||
line = reader.readLine();
|
||||
if (line != null) {
|
||||
content
|
||||
.append(line.replaceAll("%schemaName%", schemaName))
|
||||
.append(line.replace("%schemaName%", schemaName))
|
||||
.append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package pro.taskana.task.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/** This enum contains all status of the tasks. */
|
||||
public enum TaskState {
|
||||
READY,
|
||||
|
|
@ -9,15 +11,10 @@ public enum TaskState {
|
|||
TERMINATED;
|
||||
|
||||
public boolean in(TaskState... states) {
|
||||
for (TaskState currState : states) {
|
||||
if (this.equals(currState)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return Arrays.stream(states).anyMatch(state -> state == this);
|
||||
}
|
||||
|
||||
public boolean isEndState() {
|
||||
return this.equals(COMPLETED) || this.equals(CANCELLED) || this.equals(TERMINATED);
|
||||
return this == COMPLETED || this == CANCELLED || this == TERMINATED;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import java.util.stream.Collectors;
|
|||
import org.slf4j.Logger;
|
||||
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.LoggerUtils;
|
||||
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.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 {
|
||||
|
||||
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
|
||||
private Instant firstRun;
|
||||
private Duration runEvery;
|
||||
private Duration minimumAge;
|
||||
private int batchSize;
|
||||
private boolean allCompletedSameParentBusiness;
|
||||
private final Instant firstRun;
|
||||
private final Duration runEvery;
|
||||
private final Duration minimumAge;
|
||||
private final int batchSize;
|
||||
private final boolean allCompletedSameParentBusiness;
|
||||
|
||||
public TaskCleanupJob(
|
||||
TaskanaEngine taskanaEngine,
|
||||
|
|
@ -55,7 +57,7 @@ public class TaskCleanupJob extends AbstractTaskanaJob {
|
|||
public void run() throws TaskanaException {
|
||||
Instant completedBefore = Instant.now().minus(minimumAge);
|
||||
LOGGER.info(
|
||||
"Running job to delete all tasks completed before ({})", completedBefore.toString());
|
||||
"Running job to delete all tasks completed before ({})", completedBefore);
|
||||
try {
|
||||
List<TaskSummary> tasksCompletedBefore = getTasksCompletedBefore(completedBefore);
|
||||
int totalNumberOfTasksCompleted = 0;
|
||||
|
|
@ -94,7 +96,7 @@ public class TaskCleanupJob extends AbstractTaskanaJob {
|
|||
.getTaskService()
|
||||
.createTaskQuery()
|
||||
.completedWithin(new TimeInterval(null, untilDate))
|
||||
.orderByBusinessProcessId(asc)
|
||||
.orderByBusinessProcessId(ASCENDING)
|
||||
.list();
|
||||
|
||||
if (allCompletedSameParentBusiness) {
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ public class WorkbasketCleanupJob extends AbstractTaskanaJob {
|
|||
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketCleanupJob.class);
|
||||
|
||||
// Parameter
|
||||
private Instant firstRun;
|
||||
private Duration runEvery;
|
||||
private int batchSize;
|
||||
private final Instant firstRun;
|
||||
private final Duration runEvery;
|
||||
private final int batchSize;
|
||||
|
||||
public WorkbasketCleanupJob(
|
||||
TaskanaEngine taskanaEngine,
|
||||
|
|
@ -76,31 +76,27 @@ public class WorkbasketCleanupJob extends AbstractTaskanaJob {
|
|||
}
|
||||
|
||||
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) {
|
||||
int deletedWorkbasketsCount = 0;
|
||||
if (txProvider != null) {
|
||||
int count =
|
||||
(Integer)
|
||||
txProvider.executeInTransaction(
|
||||
() -> {
|
||||
try {
|
||||
return deleteWorkbaskets(workbasketsToBeDeleted);
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Could not delete workbaskets.", e);
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
return count;
|
||||
return (Integer)
|
||||
txProvider.executeInTransaction(
|
||||
() -> {
|
||||
try {
|
||||
return deleteWorkbaskets(workbasketsToBeDeleted);
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Could not delete workbaskets.", e);
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
try {
|
||||
deletedWorkbasketsCount = deleteWorkbaskets(workbasketsToBeDeleted);
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@ package pro.taskana.ldap;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import pro.taskana.rest.resource.AccessIdResource;
|
||||
import pro.taskana.rest.resource.AccessIdRepresentationModel;
|
||||
|
||||
/**
|
||||
* Implementation of LdapCache used for Unit tests.
|
||||
|
|
@ -19,283 +20,292 @@ import pro.taskana.rest.resource.AccessIdResource;
|
|||
public class LdapCacheTestImpl implements LdapCache {
|
||||
|
||||
/**
|
||||
* 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) .
|
||||
* 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<AccessIdResource, List<AccessIdResource>> users;
|
||||
private Map<AccessIdRepresentationModel, List<AccessIdRepresentationModel>> users;
|
||||
|
||||
private List<AccessIdResource> accessIds =
|
||||
private final List<AccessIdRepresentationModel> accessIds =
|
||||
new ArrayList<>(
|
||||
Arrays.asList(
|
||||
new AccessIdResource("Martin, Rojas Miguel Angel", "user_1_1"),
|
||||
new AccessIdResource("Zorgati, Mustapha", "user_2_1"),
|
||||
new AccessIdResource("Behrendt, Maximilian", "max"),
|
||||
new AccessIdResource("Bert, Ali", "teamlead_5"),
|
||||
new AccessIdResource("Hagen, Holger", "teamlead_3"),
|
||||
new AccessIdResource("Breier, Bernd", "user_2_2"),
|
||||
new AccessIdResource("Fielmalz, Anke", "user017"),
|
||||
new AccessIdResource("Mente, Maximilian", "max_mente"),
|
||||
new AccessIdResource("Theke, Bernd", "user_2_3"),
|
||||
new AccessIdResource("Ferrante, Elena", "elena"),
|
||||
new AccessIdResource("Mueller, Simone", "simone"),
|
||||
new AccessIdResource("Sirup, Aaron", "user001"),
|
||||
new AccessIdResource("Nacho, recuerda", "user_1_2"),
|
||||
new AccessIdResource("Lass, Ada", "user003"),
|
||||
new AccessIdResource("Tion, Addi", "user004"),
|
||||
new AccessIdResource("Lette, Adi", "user005"),
|
||||
new AccessIdResource("Admin", "teamlead_2"),
|
||||
new AccessIdResource("Native, Alter", "user006"),
|
||||
new AccessIdResource("Herum, Albert", "user007"),
|
||||
new AccessIdResource("Meyer, Dominik", "teamlead_1"),
|
||||
new AccessIdResource("Mente, Ali", "user009"),
|
||||
new AccessIdResource("Nach, Alma", "user011"),
|
||||
new AccessIdResource("Gehzauch, Anders", "user012"),
|
||||
new AccessIdResource("Theke, Andi", "user013"),
|
||||
new AccessIdResource("Kreuz, Andreas", "user014"),
|
||||
new AccessIdResource("Tiefsee, Anka", "user016"),
|
||||
new AccessIdResource("Fassen, Ann", "user018"),
|
||||
new AccessIdResource("Probe, Ann", "user019"),
|
||||
new AccessIdResource("Bolika, Anna", "user020"),
|
||||
new AccessIdResource("Ecke, Anna", "user021"),
|
||||
new AccessIdResource("Hosi, Anna", "user022"),
|
||||
new AccessIdResource("Kronis-Tisch, Anna", "user023"),
|
||||
new AccessIdResource("Logie, Anna", "user024"),
|
||||
new AccessIdResource("Luehse, Anna", "user025"),
|
||||
new AccessIdResource("Nass, Anna", "user026"),
|
||||
new AccessIdResource("Thalb, Anna", "user027"),
|
||||
new AccessIdResource("Tomie, Anna", "user028"),
|
||||
new AccessIdResource("Donnich, Anne", "user029"),
|
||||
new AccessIdResource("Kaffek, Anne", "user030"),
|
||||
new AccessIdResource("Thek, Anne", "user031"),
|
||||
new AccessIdResource("Matoer, Anni", "user032"),
|
||||
new AccessIdResource("Ragentor, Ansgar", "user033"),
|
||||
new AccessIdResource("Stoteles, Ari", "user034"),
|
||||
new AccessIdResource("Thmetik, Ari", "user035"),
|
||||
new AccessIdResource("Nuehm, Arno", "user036"),
|
||||
new AccessIdResource("Schocke, Artie", "user037"),
|
||||
new AccessIdResource("Stoppel, Bart", "user038"),
|
||||
new AccessIdResource("Beitung, Bea", "user039"),
|
||||
new AccessIdResource("Ildich, Bea", "user040"),
|
||||
new AccessIdResource("Vista, Bella", "user041"),
|
||||
new AccessIdResource("Utzer, Ben", "user042"),
|
||||
new AccessIdResource("Zien, Ben", "user043"),
|
||||
new AccessIdResource("Stein, Bernd", "user044"),
|
||||
new AccessIdResource("Deramen, Bill", "user045"),
|
||||
new AccessIdResource("Honig, Bine", "user046"),
|
||||
new AccessIdResource("Densatz, Bo", "user047"),
|
||||
new AccessIdResource("Densee, Bo", "user048"),
|
||||
new AccessIdResource("Lerwagen, Bo", "user049"),
|
||||
new AccessIdResource("Tail, Bob", "user050"),
|
||||
new AccessIdResource("Ketta, Bruce", "user051"),
|
||||
new AccessIdResource("Terrie, Bud", "user052"),
|
||||
new AccessIdResource("Biener-Haken, Cara", "user053"),
|
||||
new AccessIdResource("Ass, Caro", "user054"),
|
||||
new AccessIdResource("Kaffee, Caro", "user055"),
|
||||
new AccessIdResource("Linger, Caro", "user056"),
|
||||
new AccessIdResource("tenSaft, Caro", "user057"),
|
||||
new AccessIdResource("Antheme, Chris", "user058"),
|
||||
new AccessIdResource("Baum, Chris", "user059"),
|
||||
new AccessIdResource("Tall, Chris", "user060"),
|
||||
new AccessIdResource("Reiniger, Claas", "user061"),
|
||||
new AccessIdResource("Grube, Claire", "user062"),
|
||||
new AccessIdResource("Fall, Clara", "user063"),
|
||||
new AccessIdResource("Korn, Clara", "user064"),
|
||||
new AccessIdResource("Lenriff, Cora", "user065"),
|
||||
new AccessIdResource("Schiert, Cora", "user066"),
|
||||
new AccessIdResource("Hose, Cord", "user067"),
|
||||
new AccessIdResource("Onbleu, Cord", "user068"),
|
||||
new AccessIdResource("Umkleide, Damon", "user069"),
|
||||
new AccessIdResource("Affier, Dean", "user070"),
|
||||
new AccessIdResource("Orm, Dean", "user071"),
|
||||
new AccessIdResource("Platz, Dennis", "user072"),
|
||||
new AccessIdResource("Milch, Dick", "user073"),
|
||||
new AccessIdResource("Mow, Dina", "user074"),
|
||||
new AccessIdResource("Keil, Donna", "user075"),
|
||||
new AccessIdResource("Littchen, Donna", "user076"),
|
||||
new AccessIdResource("Wetter, Donna", "user077"),
|
||||
new AccessIdResource("Was, Ed", "user078"),
|
||||
new AccessIdResource("Khar, Ede", "user079"),
|
||||
new AccessIdResource("Nut, Ella", "user080"),
|
||||
new AccessIdResource("Stisch, Ella", "user081"),
|
||||
new AccessIdResource("Diel, Emma", "user082"),
|
||||
new AccessIdResource("Herdamit, Emma", "user083"),
|
||||
new AccessIdResource("Mitter-Uhe, Emma", "user084"),
|
||||
new AccessIdResource("Tatt, Erich", "user085"),
|
||||
new AccessIdResource("Drigend, Ernie", "user086"),
|
||||
new AccessIdResource("Poly, Esther", "user087"),
|
||||
new AccessIdResource("Trautz, Eugen", "user088"),
|
||||
new AccessIdResource("Quiert, Eva", "user089"),
|
||||
new AccessIdResource("Inurlaub, Fatma", "user090"),
|
||||
new AccessIdResource("Land, Finn", "user091"),
|
||||
new AccessIdResource("Sternis, Finn", "user092"),
|
||||
new AccessIdResource("Furt, Frank", "user093"),
|
||||
new AccessIdResource("Reich, Frank", "user094"),
|
||||
new AccessIdResource("Iskaner, Franz", "user095"),
|
||||
new AccessIdResource("Nerr, Franziska", "user096"),
|
||||
new AccessIdResource("Zafen, Friedrich", "user097"),
|
||||
new AccessIdResource("Pomm, Fritz", "user098"),
|
||||
new AccessIdResource("deWegs, Gera", "user099"),
|
||||
new AccessIdResource("Staebe, Gitta", "user100"),
|
||||
new AccessIdResource("Zend, Glenn", "user101"),
|
||||
new AccessIdResource("Fisch, Grete", "user102"),
|
||||
new AccessIdResource("Zucker, Gus", "user103"),
|
||||
new AccessIdResource("Muhn, Hanni", "user104"),
|
||||
new AccessIdResource("Fermesse, Hanno", "user105"),
|
||||
new AccessIdResource("Aplast, Hans", "user106"),
|
||||
new AccessIdResource("Eart, Hans", "user107"),
|
||||
new AccessIdResource("Back, Hardy", "user108"),
|
||||
new AccessIdResource("Beau, Harry", "user109"),
|
||||
new AccessIdResource("Kraut, Heide", "user110"),
|
||||
new AccessIdResource("Witzka, Heide", "user111"),
|
||||
new AccessIdResource("Buchen, Hein", "user112"),
|
||||
new AccessIdResource("Lichkeit, Hein", "user113"),
|
||||
new AccessIdResource("Suchung, Hein", "user114"),
|
||||
new AccessIdResource("Ellmann, Heinz", "user115"),
|
||||
new AccessIdResource("Ketchup, Heinz", "user116"),
|
||||
new AccessIdResource("Zeim, Hilde", "user117"),
|
||||
new AccessIdResource("Bilien, Immo", "user118"),
|
||||
new AccessIdResource("Her, Inge", "user119"),
|
||||
new AccessIdResource("Wahrsam, Inge", "user120"),
|
||||
new AccessIdResource("Flamm, Ingo", "user121"),
|
||||
new AccessIdResource("Enzien, Ingrid", "user122"),
|
||||
new AccessIdResource("Rohsch, Inken", "user123"),
|
||||
new AccessIdResource("Ihr, Insa", "user124"),
|
||||
new AccessIdResource("Nerda, Iska", "user125"),
|
||||
new AccessIdResource("Eitz, Jens", "user126"),
|
||||
new AccessIdResource("Nastik, Jim", "user127"),
|
||||
new AccessIdResource("Gurt, Jo", "user128"),
|
||||
new AccessIdResource("Kurrth, Jo", "user129"),
|
||||
new AccessIdResource("Kolade, Joe", "user130"),
|
||||
new AccessIdResource("Iter, Johann", "user131"),
|
||||
new AccessIdResource("Tick, Joyce", "user132"),
|
||||
new AccessIdResource("Case, Justin", "user133"),
|
||||
new AccessIdResource("Time, Justin", "user134"),
|
||||
new AccessIdResource("Komp, Jutta", "user135"),
|
||||
new AccessIdResource("Mauer, Kai", "user136"),
|
||||
new AccessIdResource("Pirinja, Kai", "user137"),
|
||||
new AccessIdResource("Serpfalz, Kai", "user138"),
|
||||
new AccessIdResource("Auer, Karl", "user139"),
|
||||
new AccessIdResource("Ielauge, Karl", "user140"),
|
||||
new AccessIdResource("Ifornjen, Karl", "user141"),
|
||||
new AccessIdResource("Radi, Karl", "user142"),
|
||||
new AccessIdResource("Verti, Karl", "user143"),
|
||||
new AccessIdResource("Sery, Karo", "user144"),
|
||||
new AccessIdResource("Lisator, Katha", "user145"),
|
||||
new AccessIdResource("Flo, Kati", "user146"),
|
||||
new AccessIdResource("Schenn, Knut", "user147"),
|
||||
new AccessIdResource("Achse, Kurt", "user148"),
|
||||
new AccessIdResource("Zepause, Kurt", "user149"),
|
||||
new AccessIdResource("Zerr, Kurt", "user150"),
|
||||
new AccessIdResource("Reden, Lasse", "user151"),
|
||||
new AccessIdResource("Metten, Lee", "user152"),
|
||||
new AccessIdResource("Arm, Lene", "user153"),
|
||||
new AccessIdResource("Thur, Linnea", "user154"),
|
||||
new AccessIdResource("Bonn, Lisa", "user155"),
|
||||
new AccessIdResource("Sembourg, Luc", "user156"),
|
||||
new AccessIdResource("Rung, Lucky", "user157"),
|
||||
new AccessIdResource("Zafen, Ludwig", "user158"),
|
||||
new AccessIdResource("Hauden, Lukas", "user159"),
|
||||
new AccessIdResource("Hose, Lutz", "user160"),
|
||||
new AccessIdResource("Tablette, Lutz", "user161"),
|
||||
new AccessIdResource("Fehr, Luzie", "user162"),
|
||||
new AccessIdResource("Nalyse, Magda", "user163"),
|
||||
new AccessIdResource("Ehfer, Maik", "user164"),
|
||||
new AccessIdResource("Sehr, Malte", "user165"),
|
||||
new AccessIdResource("Thon, Mara", "user166"),
|
||||
new AccessIdResource("Quark, Marga", "user167"),
|
||||
new AccessIdResource("Nade, Marie", "user168"),
|
||||
new AccessIdResource("Niert, Marie", "user169"),
|
||||
new AccessIdResource("Neese, Mario", "user170"),
|
||||
new AccessIdResource("Nette, Marion", "user171"),
|
||||
new AccessIdResource("Nesium, Mark", "user172"),
|
||||
new AccessIdResource("Thalle, Mark", "user173"),
|
||||
new AccessIdResource("Diven, Marle", "user174"),
|
||||
new AccessIdResource("Fitz, Marle", "user175"),
|
||||
new AccessIdResource("Pfahl, Marta", "user176"),
|
||||
new AccessIdResource("Zorn, Martin", "user177"),
|
||||
new AccessIdResource("Krissmes, Mary", "user178"),
|
||||
new AccessIdResource("Jess, Matt", "user179"),
|
||||
new AccessIdResource("Strammer, Max", "user180"),
|
||||
new AccessIdResource("Mumm, Maxi", "user181"),
|
||||
new AccessIdResource("Morphose, Meta", "user182"),
|
||||
new AccessIdResource("Uh, Mia", "user183"),
|
||||
new AccessIdResource("Rofon, Mike", "user184"),
|
||||
new AccessIdResource("Rosoft, Mike", "user185"),
|
||||
new AccessIdResource("Liter, Milli", "user186"),
|
||||
new AccessIdResource("Thär, Milli", "user187"),
|
||||
new AccessIdResource("Welle, Mirko", "user188"),
|
||||
new AccessIdResource("Thorat, Mo", "user189"),
|
||||
new AccessIdResource("Thor, Moni", "user190"),
|
||||
new AccessIdResource("Kinolta, Monika", "user191"),
|
||||
new AccessIdResource("Mundhaar, Monika", "user192"),
|
||||
new AccessIdResource("Munter, Monika", "user193"),
|
||||
new AccessIdResource("Zwerg, Nat", "user194"),
|
||||
new AccessIdResource("Elmine, Nick", "user195"),
|
||||
new AccessIdResource("Thien, Niko", "user196"),
|
||||
new AccessIdResource("Pferd, Nils", "user197"),
|
||||
new AccessIdResource("Lerweise, Norma", "user198"),
|
||||
new AccessIdResource("Motor, Otto", "user199"),
|
||||
new AccessIdResource("Totol, Otto", "user200"),
|
||||
new AccessIdResource("Nerr, Paula", "user201"),
|
||||
new AccessIdResource("Imeter, Peer", "user202"),
|
||||
new AccessIdResource("Serkatze, Peer", "user203"),
|
||||
new AccessIdResource("Gogisch, Peter", "user204"),
|
||||
new AccessIdResource("Silje, Peter", "user205"),
|
||||
new AccessIdResource("Harmonie, Phil", "user206"),
|
||||
new AccessIdResource("Ihnen, Philip", "user207"),
|
||||
new AccessIdResource("Uto, Pia", "user208"),
|
||||
new AccessIdResource("Kothek, Pina", "user209"),
|
||||
new AccessIdResource("Zar, Pit", "user210"),
|
||||
new AccessIdResource("Zeih, Polly", "user211"),
|
||||
new AccessIdResource("Tswan, Puh", "user212"),
|
||||
new AccessIdResource("Zufall, Rainer", "user213"),
|
||||
new AccessIdResource("Lien, Rita", "user214"),
|
||||
new AccessIdResource("Held, Roman", "user215"),
|
||||
new AccessIdResource("Haar, Ross", "user216"),
|
||||
new AccessIdResource("Dick, Roy", "user217"),
|
||||
new AccessIdResource("Enplaner, Ruth", "user218"),
|
||||
new AccessIdResource("Kommen, Ryan", "user219"),
|
||||
new AccessIdResource("Philo, Sophie", "user220"),
|
||||
new AccessIdResource("Matisier, Stig", "user221"),
|
||||
new AccessIdResource("Loniki, Tessa", "user222"),
|
||||
new AccessIdResource("Tralisch, Thea", "user223"),
|
||||
new AccessIdResource("Logie, Theo", "user224"),
|
||||
new AccessIdResource("Ister, Thorn", "user225"),
|
||||
new AccessIdResource("Buktu, Tim", "user226"),
|
||||
new AccessIdResource("Ate, Tom", "user227"),
|
||||
new AccessIdResource("Pie, Udo", "user228"),
|
||||
new AccessIdResource("Aloe, Vera", "user229"),
|
||||
new AccessIdResource("Hausver, Walter", "user230"),
|
||||
new AccessIdResource("Schuh, Wanda", "user231"),
|
||||
new AccessIdResource("Rahm, Wolf", "user232"),
|
||||
new AccessIdResource("businessadmin", "cn=businessadmin,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("UsersGroup", "cn=usersgroup,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("DevelopersGroup", "cn=developersgroup,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("businessadmin", "cn=customersgroup,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("user_domain_A", "cn=user_domain_a,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("monitor", "cn=monitor,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("user_domain_C", "cn=user_domain_c,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("user_domain_D", "cn=user_domain_d,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("admin", "cn=admin,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource(
|
||||
new AccessIdRepresentationModel("Martin, Rojas Miguel Angel", "user_1_1"),
|
||||
new AccessIdRepresentationModel("Zorgati, Mustapha", "user_2_1"),
|
||||
new AccessIdRepresentationModel("Behrendt, Maximilian", "max"),
|
||||
new AccessIdRepresentationModel("Bert, Ali", "teamlead_5"),
|
||||
new AccessIdRepresentationModel("Hagen, Holger", "teamlead_3"),
|
||||
new AccessIdRepresentationModel("Breier, Bernd", "user_2_2"),
|
||||
new AccessIdRepresentationModel("Fielmalz, Anke", "user017"),
|
||||
new AccessIdRepresentationModel("Mente, Maximilian", "max_mente"),
|
||||
new AccessIdRepresentationModel("Theke, Bernd", "user_2_3"),
|
||||
new AccessIdRepresentationModel("Ferrante, Elena", "elena"),
|
||||
new AccessIdRepresentationModel("Mueller, Simone", "simone"),
|
||||
new AccessIdRepresentationModel("Sirup, Aaron", "user001"),
|
||||
new AccessIdRepresentationModel("Nacho, recuerda", "user_1_2"),
|
||||
new AccessIdRepresentationModel("Lass, Ada", "user003"),
|
||||
new AccessIdRepresentationModel("Tion, Addi", "user004"),
|
||||
new AccessIdRepresentationModel("Lette, Adi", "user005"),
|
||||
new AccessIdRepresentationModel("Admin", "teamlead_2"),
|
||||
new AccessIdRepresentationModel("Native, Alter", "user006"),
|
||||
new AccessIdRepresentationModel("Herum, Albert", "user007"),
|
||||
new AccessIdRepresentationModel("Meyer, Dominik", "teamlead_1"),
|
||||
new AccessIdRepresentationModel("Mente, Ali", "user009"),
|
||||
new AccessIdRepresentationModel("Nach, Alma", "user011"),
|
||||
new AccessIdRepresentationModel("Gehzauch, Anders", "user012"),
|
||||
new AccessIdRepresentationModel("Theke, Andi", "user013"),
|
||||
new AccessIdRepresentationModel("Kreuz, Andreas", "user014"),
|
||||
new AccessIdRepresentationModel("Tiefsee, Anka", "user016"),
|
||||
new AccessIdRepresentationModel("Fassen, Ann", "user018"),
|
||||
new AccessIdRepresentationModel("Probe, Ann", "user019"),
|
||||
new AccessIdRepresentationModel("Bolika, Anna", "user020"),
|
||||
new AccessIdRepresentationModel("Ecke, Anna", "user021"),
|
||||
new AccessIdRepresentationModel("Hosi, Anna", "user022"),
|
||||
new AccessIdRepresentationModel("Kronis-Tisch, Anna", "user023"),
|
||||
new AccessIdRepresentationModel("Logie, Anna", "user024"),
|
||||
new AccessIdRepresentationModel("Luehse, Anna", "user025"),
|
||||
new AccessIdRepresentationModel("Nass, Anna", "user026"),
|
||||
new AccessIdRepresentationModel("Thalb, Anna", "user027"),
|
||||
new AccessIdRepresentationModel("Tomie, Anna", "user028"),
|
||||
new AccessIdRepresentationModel("Donnich, Anne", "user029"),
|
||||
new AccessIdRepresentationModel("Kaffek, Anne", "user030"),
|
||||
new AccessIdRepresentationModel("Thek, Anne", "user031"),
|
||||
new AccessIdRepresentationModel("Matoer, Anni", "user032"),
|
||||
new AccessIdRepresentationModel("Ragentor, Ansgar", "user033"),
|
||||
new AccessIdRepresentationModel("Stoteles, Ari", "user034"),
|
||||
new AccessIdRepresentationModel("Thmetik, Ari", "user035"),
|
||||
new AccessIdRepresentationModel("Nuehm, Arno", "user036"),
|
||||
new AccessIdRepresentationModel("Schocke, Artie", "user037"),
|
||||
new AccessIdRepresentationModel("Stoppel, Bart", "user038"),
|
||||
new AccessIdRepresentationModel("Beitung, Bea", "user039"),
|
||||
new AccessIdRepresentationModel("Ildich, Bea", "user040"),
|
||||
new AccessIdRepresentationModel("Vista, Bella", "user041"),
|
||||
new AccessIdRepresentationModel("Utzer, Ben", "user042"),
|
||||
new AccessIdRepresentationModel("Zien, Ben", "user043"),
|
||||
new AccessIdRepresentationModel("Stein, Bernd", "user044"),
|
||||
new AccessIdRepresentationModel("Deramen, Bill", "user045"),
|
||||
new AccessIdRepresentationModel("Honig, Bine", "user046"),
|
||||
new AccessIdRepresentationModel("Densatz, Bo", "user047"),
|
||||
new AccessIdRepresentationModel("Densee, Bo", "user048"),
|
||||
new AccessIdRepresentationModel("Lerwagen, Bo", "user049"),
|
||||
new AccessIdRepresentationModel("Tail, Bob", "user050"),
|
||||
new AccessIdRepresentationModel("Ketta, Bruce", "user051"),
|
||||
new AccessIdRepresentationModel("Terrie, Bud", "user052"),
|
||||
new AccessIdRepresentationModel("Biener-Haken, Cara", "user053"),
|
||||
new AccessIdRepresentationModel("Ass, Caro", "user054"),
|
||||
new AccessIdRepresentationModel("Kaffee, Caro", "user055"),
|
||||
new AccessIdRepresentationModel("Linger, Caro", "user056"),
|
||||
new AccessIdRepresentationModel("tenSaft, Caro", "user057"),
|
||||
new AccessIdRepresentationModel("Antheme, Chris", "user058"),
|
||||
new AccessIdRepresentationModel("Baum, Chris", "user059"),
|
||||
new AccessIdRepresentationModel("Tall, Chris", "user060"),
|
||||
new AccessIdRepresentationModel("Reiniger, Claas", "user061"),
|
||||
new AccessIdRepresentationModel("Grube, Claire", "user062"),
|
||||
new AccessIdRepresentationModel("Fall, Clara", "user063"),
|
||||
new AccessIdRepresentationModel("Korn, Clara", "user064"),
|
||||
new AccessIdRepresentationModel("Lenriff, Cora", "user065"),
|
||||
new AccessIdRepresentationModel("Schiert, Cora", "user066"),
|
||||
new AccessIdRepresentationModel("Hose, Cord", "user067"),
|
||||
new AccessIdRepresentationModel("Onbleu, Cord", "user068"),
|
||||
new AccessIdRepresentationModel("Umkleide, Damon", "user069"),
|
||||
new AccessIdRepresentationModel("Affier, Dean", "user070"),
|
||||
new AccessIdRepresentationModel("Orm, Dean", "user071"),
|
||||
new AccessIdRepresentationModel("Platz, Dennis", "user072"),
|
||||
new AccessIdRepresentationModel("Milch, Dick", "user073"),
|
||||
new AccessIdRepresentationModel("Mow, Dina", "user074"),
|
||||
new AccessIdRepresentationModel("Keil, Donna", "user075"),
|
||||
new AccessIdRepresentationModel("Littchen, Donna", "user076"),
|
||||
new AccessIdRepresentationModel("Wetter, Donna", "user077"),
|
||||
new AccessIdRepresentationModel("Was, Ed", "user078"),
|
||||
new AccessIdRepresentationModel("Khar, Ede", "user079"),
|
||||
new AccessIdRepresentationModel("Nut, Ella", "user080"),
|
||||
new AccessIdRepresentationModel("Stisch, Ella", "user081"),
|
||||
new AccessIdRepresentationModel("Diel, Emma", "user082"),
|
||||
new AccessIdRepresentationModel("Herdamit, Emma", "user083"),
|
||||
new AccessIdRepresentationModel("Mitter-Uhe, Emma", "user084"),
|
||||
new AccessIdRepresentationModel("Tatt, Erich", "user085"),
|
||||
new AccessIdRepresentationModel("Drigend, Ernie", "user086"),
|
||||
new AccessIdRepresentationModel("Poly, Esther", "user087"),
|
||||
new AccessIdRepresentationModel("Trautz, Eugen", "user088"),
|
||||
new AccessIdRepresentationModel("Quiert, Eva", "user089"),
|
||||
new AccessIdRepresentationModel("Inurlaub, Fatma", "user090"),
|
||||
new AccessIdRepresentationModel("Land, Finn", "user091"),
|
||||
new AccessIdRepresentationModel("Sternis, Finn", "user092"),
|
||||
new AccessIdRepresentationModel("Furt, Frank", "user093"),
|
||||
new AccessIdRepresentationModel("Reich, Frank", "user094"),
|
||||
new AccessIdRepresentationModel("Iskaner, Franz", "user095"),
|
||||
new AccessIdRepresentationModel("Nerr, Franziska", "user096"),
|
||||
new AccessIdRepresentationModel("Zafen, Friedrich", "user097"),
|
||||
new AccessIdRepresentationModel("Pomm, Fritz", "user098"),
|
||||
new AccessIdRepresentationModel("deWegs, Gera", "user099"),
|
||||
new AccessIdRepresentationModel("Staebe, Gitta", "user100"),
|
||||
new AccessIdRepresentationModel("Zend, Glenn", "user101"),
|
||||
new AccessIdRepresentationModel("Fisch, Grete", "user102"),
|
||||
new AccessIdRepresentationModel("Zucker, Gus", "user103"),
|
||||
new AccessIdRepresentationModel("Muhn, Hanni", "user104"),
|
||||
new AccessIdRepresentationModel("Fermesse, Hanno", "user105"),
|
||||
new AccessIdRepresentationModel("Aplast, Hans", "user106"),
|
||||
new AccessIdRepresentationModel("Eart, Hans", "user107"),
|
||||
new AccessIdRepresentationModel("Back, Hardy", "user108"),
|
||||
new AccessIdRepresentationModel("Beau, Harry", "user109"),
|
||||
new AccessIdRepresentationModel("Kraut, Heide", "user110"),
|
||||
new AccessIdRepresentationModel("Witzka, Heide", "user111"),
|
||||
new AccessIdRepresentationModel("Buchen, Hein", "user112"),
|
||||
new AccessIdRepresentationModel("Lichkeit, Hein", "user113"),
|
||||
new AccessIdRepresentationModel("Suchung, Hein", "user114"),
|
||||
new AccessIdRepresentationModel("Ellmann, Heinz", "user115"),
|
||||
new AccessIdRepresentationModel("Ketchup, Heinz", "user116"),
|
||||
new AccessIdRepresentationModel("Zeim, Hilde", "user117"),
|
||||
new AccessIdRepresentationModel("Bilien, Immo", "user118"),
|
||||
new AccessIdRepresentationModel("Her, Inge", "user119"),
|
||||
new AccessIdRepresentationModel("Wahrsam, Inge", "user120"),
|
||||
new AccessIdRepresentationModel("Flamm, Ingo", "user121"),
|
||||
new AccessIdRepresentationModel("Enzien, Ingrid", "user122"),
|
||||
new AccessIdRepresentationModel("Rohsch, Inken", "user123"),
|
||||
new AccessIdRepresentationModel("Ihr, Insa", "user124"),
|
||||
new AccessIdRepresentationModel("Nerda, Iska", "user125"),
|
||||
new AccessIdRepresentationModel("Eitz, Jens", "user126"),
|
||||
new AccessIdRepresentationModel("Nastik, Jim", "user127"),
|
||||
new AccessIdRepresentationModel("Gurt, Jo", "user128"),
|
||||
new AccessIdRepresentationModel("Kurrth, Jo", "user129"),
|
||||
new AccessIdRepresentationModel("Kolade, Joe", "user130"),
|
||||
new AccessIdRepresentationModel("Iter, Johann", "user131"),
|
||||
new AccessIdRepresentationModel("Tick, Joyce", "user132"),
|
||||
new AccessIdRepresentationModel("Case, Justin", "user133"),
|
||||
new AccessIdRepresentationModel("Time, Justin", "user134"),
|
||||
new AccessIdRepresentationModel("Komp, Jutta", "user135"),
|
||||
new AccessIdRepresentationModel("Mauer, Kai", "user136"),
|
||||
new AccessIdRepresentationModel("Pirinja, Kai", "user137"),
|
||||
new AccessIdRepresentationModel("Serpfalz, Kai", "user138"),
|
||||
new AccessIdRepresentationModel("Auer, Karl", "user139"),
|
||||
new AccessIdRepresentationModel("Ielauge, Karl", "user140"),
|
||||
new AccessIdRepresentationModel("Ifornjen, Karl", "user141"),
|
||||
new AccessIdRepresentationModel("Radi, Karl", "user142"),
|
||||
new AccessIdRepresentationModel("Verti, Karl", "user143"),
|
||||
new AccessIdRepresentationModel("Sery, Karo", "user144"),
|
||||
new AccessIdRepresentationModel("Lisator, Katha", "user145"),
|
||||
new AccessIdRepresentationModel("Flo, Kati", "user146"),
|
||||
new AccessIdRepresentationModel("Schenn, Knut", "user147"),
|
||||
new AccessIdRepresentationModel("Achse, Kurt", "user148"),
|
||||
new AccessIdRepresentationModel("Zepause, Kurt", "user149"),
|
||||
new AccessIdRepresentationModel("Zerr, Kurt", "user150"),
|
||||
new AccessIdRepresentationModel("Reden, Lasse", "user151"),
|
||||
new AccessIdRepresentationModel("Metten, Lee", "user152"),
|
||||
new AccessIdRepresentationModel("Arm, Lene", "user153"),
|
||||
new AccessIdRepresentationModel("Thur, Linnea", "user154"),
|
||||
new AccessIdRepresentationModel("Bonn, Lisa", "user155"),
|
||||
new AccessIdRepresentationModel("Sembourg, Luc", "user156"),
|
||||
new AccessIdRepresentationModel("Rung, Lucky", "user157"),
|
||||
new AccessIdRepresentationModel("Zafen, Ludwig", "user158"),
|
||||
new AccessIdRepresentationModel("Hauden, Lukas", "user159"),
|
||||
new AccessIdRepresentationModel("Hose, Lutz", "user160"),
|
||||
new AccessIdRepresentationModel("Tablette, Lutz", "user161"),
|
||||
new AccessIdRepresentationModel("Fehr, Luzie", "user162"),
|
||||
new AccessIdRepresentationModel("Nalyse, Magda", "user163"),
|
||||
new AccessIdRepresentationModel("Ehfer, Maik", "user164"),
|
||||
new AccessIdRepresentationModel("Sehr, Malte", "user165"),
|
||||
new AccessIdRepresentationModel("Thon, Mara", "user166"),
|
||||
new AccessIdRepresentationModel("Quark, Marga", "user167"),
|
||||
new AccessIdRepresentationModel("Nade, Marie", "user168"),
|
||||
new AccessIdRepresentationModel("Niert, Marie", "user169"),
|
||||
new AccessIdRepresentationModel("Neese, Mario", "user170"),
|
||||
new AccessIdRepresentationModel("Nette, Marion", "user171"),
|
||||
new AccessIdRepresentationModel("Nesium, Mark", "user172"),
|
||||
new AccessIdRepresentationModel("Thalle, Mark", "user173"),
|
||||
new AccessIdRepresentationModel("Diven, Marle", "user174"),
|
||||
new AccessIdRepresentationModel("Fitz, Marle", "user175"),
|
||||
new AccessIdRepresentationModel("Pfahl, Marta", "user176"),
|
||||
new AccessIdRepresentationModel("Zorn, Martin", "user177"),
|
||||
new AccessIdRepresentationModel("Krissmes, Mary", "user178"),
|
||||
new AccessIdRepresentationModel("Jess, Matt", "user179"),
|
||||
new AccessIdRepresentationModel("Strammer, Max", "user180"),
|
||||
new AccessIdRepresentationModel("Mumm, Maxi", "user181"),
|
||||
new AccessIdRepresentationModel("Morphose, Meta", "user182"),
|
||||
new AccessIdRepresentationModel("Uh, Mia", "user183"),
|
||||
new AccessIdRepresentationModel("Rofon, Mike", "user184"),
|
||||
new AccessIdRepresentationModel("Rosoft, Mike", "user185"),
|
||||
new AccessIdRepresentationModel("Liter, Milli", "user186"),
|
||||
new AccessIdRepresentationModel("Thär, Milli", "user187"),
|
||||
new AccessIdRepresentationModel("Welle, Mirko", "user188"),
|
||||
new AccessIdRepresentationModel("Thorat, Mo", "user189"),
|
||||
new AccessIdRepresentationModel("Thor, Moni", "user190"),
|
||||
new AccessIdRepresentationModel("Kinolta, Monika", "user191"),
|
||||
new AccessIdRepresentationModel("Mundhaar, Monika", "user192"),
|
||||
new AccessIdRepresentationModel("Munter, Monika", "user193"),
|
||||
new AccessIdRepresentationModel("Zwerg, Nat", "user194"),
|
||||
new AccessIdRepresentationModel("Elmine, Nick", "user195"),
|
||||
new AccessIdRepresentationModel("Thien, Niko", "user196"),
|
||||
new AccessIdRepresentationModel("Pferd, Nils", "user197"),
|
||||
new AccessIdRepresentationModel("Lerweise, Norma", "user198"),
|
||||
new AccessIdRepresentationModel("Motor, Otto", "user199"),
|
||||
new AccessIdRepresentationModel("Totol, Otto", "user200"),
|
||||
new AccessIdRepresentationModel("Nerr, Paula", "user201"),
|
||||
new AccessIdRepresentationModel("Imeter, Peer", "user202"),
|
||||
new AccessIdRepresentationModel("Serkatze, Peer", "user203"),
|
||||
new AccessIdRepresentationModel("Gogisch, Peter", "user204"),
|
||||
new AccessIdRepresentationModel("Silje, Peter", "user205"),
|
||||
new AccessIdRepresentationModel("Harmonie, Phil", "user206"),
|
||||
new AccessIdRepresentationModel("Ihnen, Philip", "user207"),
|
||||
new AccessIdRepresentationModel("Uto, Pia", "user208"),
|
||||
new AccessIdRepresentationModel("Kothek, Pina", "user209"),
|
||||
new AccessIdRepresentationModel("Zar, Pit", "user210"),
|
||||
new AccessIdRepresentationModel("Zeih, Polly", "user211"),
|
||||
new AccessIdRepresentationModel("Tswan, Puh", "user212"),
|
||||
new AccessIdRepresentationModel("Zufall, Rainer", "user213"),
|
||||
new AccessIdRepresentationModel("Lien, Rita", "user214"),
|
||||
new AccessIdRepresentationModel("Held, Roman", "user215"),
|
||||
new AccessIdRepresentationModel("Haar, Ross", "user216"),
|
||||
new AccessIdRepresentationModel("Dick, Roy", "user217"),
|
||||
new AccessIdRepresentationModel("Enplaner, Ruth", "user218"),
|
||||
new AccessIdRepresentationModel("Kommen, Ryan", "user219"),
|
||||
new AccessIdRepresentationModel("Philo, Sophie", "user220"),
|
||||
new AccessIdRepresentationModel("Matisier, Stig", "user221"),
|
||||
new AccessIdRepresentationModel("Loniki, Tessa", "user222"),
|
||||
new AccessIdRepresentationModel("Tralisch, Thea", "user223"),
|
||||
new AccessIdRepresentationModel("Logie, Theo", "user224"),
|
||||
new AccessIdRepresentationModel("Ister, Thorn", "user225"),
|
||||
new AccessIdRepresentationModel("Buktu, Tim", "user226"),
|
||||
new AccessIdRepresentationModel("Ate, Tom", "user227"),
|
||||
new AccessIdRepresentationModel("Pie, Udo", "user228"),
|
||||
new AccessIdRepresentationModel("Aloe, Vera", "user229"),
|
||||
new AccessIdRepresentationModel("Hausver, Walter", "user230"),
|
||||
new AccessIdRepresentationModel("Schuh, Wanda", "user231"),
|
||||
new AccessIdRepresentationModel("Rahm, Wolf", "user232"),
|
||||
new AccessIdRepresentationModel(
|
||||
"businessadmin", "cn=businessadmin,ou=groups,o=taskanatest"),
|
||||
new AccessIdRepresentationModel(
|
||||
"UsersGroup", "cn=usersgroup,ou=groups,o=taskanatest"),
|
||||
new AccessIdRepresentationModel(
|
||||
"DevelopersGroup", "cn=developersgroup,ou=groups,o=taskanatest"),
|
||||
new AccessIdRepresentationModel(
|
||||
"businessadmin", "cn=customersgroup,ou=groups,o=taskanatest"),
|
||||
new AccessIdRepresentationModel(
|
||||
"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"),
|
||||
new AccessIdResource(
|
||||
new AccessIdRepresentationModel(
|
||||
"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"),
|
||||
new AccessIdResource("teamlead_2", "cn=teamlead_2" + ",ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("teamlead_4", "cn=teamlead_4" + ",ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("team_3", "cn=team_3" + ",ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("team_4", "cn=team_4" + ",ou=groups,o=taskanatest")));
|
||||
new AccessIdRepresentationModel(
|
||||
"teamlead_2", "cn=teamlead_2" + ",ou=groups,o=taskanatest"),
|
||||
new AccessIdRepresentationModel(
|
||||
"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
|
||||
public List<AccessIdResource> findMatchingAccessId(
|
||||
public List<AccessIdRepresentationModel> findMatchingAccessId(
|
||||
String searchFor, int maxNumberOfReturnedAccessIds) {
|
||||
return findAcessIdResource(searchFor, maxNumberOfReturnedAccessIds, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccessIdResource> findGroupsOfUser(
|
||||
public List<AccessIdRepresentationModel> findGroupsOfUser(
|
||||
String searchFor, int maxNumberOfReturnedAccessIds) {
|
||||
if (users == null) {
|
||||
users = addUsersToGroups();
|
||||
|
|
@ -304,15 +314,15 @@ public class LdapCacheTestImpl implements LdapCache {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<AccessIdResource> validateAccessId(String accessId) {
|
||||
public List<AccessIdRepresentationModel> validateAccessId(String accessId) {
|
||||
return accessIds.stream()
|
||||
.filter(t -> (t.getAccessId().equalsIgnoreCase(accessId.toLowerCase())))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<AccessIdResource> findAcessIdResource(
|
||||
private List<AccessIdRepresentationModel> findAcessIdResource(
|
||||
String searchFor, int maxNumberOfReturnedAccessIds, boolean groupMember) {
|
||||
List<AccessIdResource> usersAndGroups =
|
||||
List<AccessIdRepresentationModel> usersAndGroups =
|
||||
accessIds.stream()
|
||||
.filter(
|
||||
t ->
|
||||
|
|
@ -320,7 +330,7 @@ public class LdapCacheTestImpl implements LdapCache {
|
|||
|| t.getAccessId().toLowerCase().contains(searchFor.toLowerCase())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<AccessIdResource> usersAndGroupsAux = new ArrayList<>(usersAndGroups);
|
||||
List<AccessIdRepresentationModel> usersAndGroupsAux = new ArrayList<>(usersAndGroups);
|
||||
if (groupMember) {
|
||||
usersAndGroupsAux.forEach(
|
||||
item -> {
|
||||
|
|
@ -331,36 +341,32 @@ public class LdapCacheTestImpl implements LdapCache {
|
|||
}
|
||||
|
||||
usersAndGroups.sort(
|
||||
(AccessIdResource a, AccessIdResource b) -> {
|
||||
return a.getAccessId().compareToIgnoreCase(b.getAccessId());
|
||||
});
|
||||
Comparator.comparing(
|
||||
AccessIdRepresentationModel::getAccessId, String.CASE_INSENSITIVE_ORDER));
|
||||
|
||||
List<AccessIdResource> result =
|
||||
usersAndGroups.subList(0, Math.min(usersAndGroups.size(), maxNumberOfReturnedAccessIds));
|
||||
|
||||
return result;
|
||||
return usersAndGroups.subList(0, Math.min(usersAndGroups.size(), maxNumberOfReturnedAccessIds));
|
||||
}
|
||||
|
||||
private Map<AccessIdResource, List<AccessIdResource>> addUsersToGroups() {
|
||||
List<AccessIdResource> groups = new ArrayList<>();
|
||||
Map<AccessIdResource, List<AccessIdResource>> users = new HashMap<>();
|
||||
private Map<AccessIdRepresentationModel, List<AccessIdRepresentationModel>> addUsersToGroups() {
|
||||
List<AccessIdRepresentationModel> groups = new ArrayList<>();
|
||||
Map<AccessIdRepresentationModel, List<AccessIdRepresentationModel>> userMap = new HashMap<>();
|
||||
|
||||
accessIds.forEach(
|
||||
item -> {
|
||||
if (!item.getAccessId().contains("ou=groups")) {
|
||||
users.put(item, new ArrayList<>());
|
||||
userMap.put(item, new ArrayList<>());
|
||||
} else {
|
||||
groups.add(item);
|
||||
}
|
||||
});
|
||||
|
||||
int groupNumber = 0;
|
||||
List<AccessIdResource> group0 = new ArrayList<>();
|
||||
List<AccessIdResource> group1 = new ArrayList<>();
|
||||
List<AccessIdResource> group2 = new ArrayList<>();
|
||||
List<AccessIdResource> group3 = new ArrayList<>();
|
||||
List<AccessIdRepresentationModel> group0 = new ArrayList<>();
|
||||
List<AccessIdRepresentationModel> group1 = new ArrayList<>();
|
||||
List<AccessIdRepresentationModel> group2 = new ArrayList<>();
|
||||
List<AccessIdRepresentationModel> group3 = new ArrayList<>();
|
||||
|
||||
for (AccessIdResource group : groups) {
|
||||
for (AccessIdRepresentationModel group : groups) {
|
||||
switch (groupNumber) {
|
||||
case 0:
|
||||
group0.add(group);
|
||||
|
|
@ -381,20 +387,20 @@ public class LdapCacheTestImpl implements LdapCache {
|
|||
}
|
||||
|
||||
int countUser = 0;
|
||||
for (AccessIdResource item : accessIds) {
|
||||
for (AccessIdRepresentationModel item : accessIds) {
|
||||
if (!item.getAccessId().contains("ou=groups")) {
|
||||
switch (countUser) {
|
||||
case 0:
|
||||
users.put(item, group0);
|
||||
userMap.put(item, group0);
|
||||
break;
|
||||
case 1:
|
||||
users.put(item, group1);
|
||||
userMap.put(item, group1);
|
||||
break;
|
||||
case 2:
|
||||
users.put(item, group2);
|
||||
userMap.put(item, group2);
|
||||
break;
|
||||
case 3:
|
||||
users.put(item, group3);
|
||||
userMap.put(item, group3);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -402,6 +408,6 @@ public class LdapCacheTestImpl implements LdapCache {
|
|||
}
|
||||
countUser = (countUser + 1) % 4;
|
||||
}
|
||||
return users;
|
||||
return userMap;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic
|
|||
import pro.taskana.common.internal.security.GroupPrincipal;
|
||||
import pro.taskana.common.internal.security.UserPrincipal;
|
||||
import pro.taskana.ldap.LdapCacheTestImpl;
|
||||
import pro.taskana.rest.resource.AccessIdResource;
|
||||
import pro.taskana.rest.resource.AccessIdRepresentationModel;
|
||||
|
||||
/** TODO. */
|
||||
public class SampleLoginModule extends UsernamePasswordAuthenticationFilter implements LoginModule {
|
||||
|
|
@ -68,9 +68,10 @@ public class SampleLoginModule extends UsernamePasswordAuthenticationFilter impl
|
|||
private void addGroupSubjectsDerivedFromUsername() {
|
||||
LdapCacheTestImpl ldapCacheTest = new LdapCacheTestImpl();
|
||||
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(
|
||||
(AccessIdResource group) -> {
|
||||
(AccessIdRepresentationModel group) -> {
|
||||
if (group.getAccessId().contains("ou=groups")) {
|
||||
subject.getPrincipals().add(new GroupPrincipal(group.getName()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ import pro.taskana.classification.api.models.Classification;
|
|||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.rest.Mapping;
|
||||
import pro.taskana.rest.RestConfiguration;
|
||||
import pro.taskana.rest.resource.ClassificationResource;
|
||||
import pro.taskana.rest.resource.ClassificationResourceAssembler;
|
||||
import pro.taskana.rest.resource.TaskResource;
|
||||
import pro.taskana.rest.resource.TaskResourceAssembler;
|
||||
import pro.taskana.rest.resource.ClassificationRepresentationModel;
|
||||
import pro.taskana.rest.resource.ClassificationRepresentationModelAssembler;
|
||||
import pro.taskana.rest.resource.TaskRepresentationModel;
|
||||
import pro.taskana.rest.resource.TaskRepresentationModelAssembler;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
|
||||
/** Test async updates. */
|
||||
|
|
@ -45,8 +45,8 @@ class AsyncUpdateJobIntTest {
|
|||
@SuppressWarnings("checkstyle:DeclarationOrder")
|
||||
static RestTemplate template;
|
||||
|
||||
@Autowired ClassificationResourceAssembler classificationResourceAssembler;
|
||||
@Autowired TaskResourceAssembler taskResourceAssembler;
|
||||
@Autowired ClassificationRepresentationModelAssembler classificationRepresentationModelAssembler;
|
||||
@Autowired TaskRepresentationModelAssembler taskRepresentationModelAssembler;
|
||||
@Autowired JobScheduler jobScheduler;
|
||||
@Autowired RestHelper restHelper;
|
||||
|
||||
|
|
@ -62,15 +62,15 @@ class AsyncUpdateJobIntTest {
|
|||
final Instant before = Instant.now();
|
||||
final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
ResponseEntity<ClassificationResource> response =
|
||||
ResponseEntity<ClassificationRepresentationModel> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(ClassificationResource.class));
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
ClassificationResource classification = response.getBody();
|
||||
ClassificationRepresentationModel classification = response.getBody();
|
||||
assertThat(classification.getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
|
||||
// 2nd step: modify classification and trigger update
|
||||
|
|
@ -88,18 +88,20 @@ class AsyncUpdateJobIntTest {
|
|||
jobScheduler.triggerJobs();
|
||||
|
||||
// verify the classification modified timestamp is after 'before'
|
||||
ResponseEntity<ClassificationResource> repeatedResponse =
|
||||
ResponseEntity<ClassificationRepresentationModel> repeatedResponse =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(ClassificationResource.class));
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
|
||||
assertThat(repeatedResponse.getBody()).isNotNull();
|
||||
|
||||
ClassificationResource modifiedClassificationResource = repeatedResponse.getBody();
|
||||
ClassificationRepresentationModel modifiedClassificationRepresentationModel =
|
||||
repeatedResponse.getBody();
|
||||
Classification modifiedClassification =
|
||||
classificationResourceAssembler.toModel(modifiedClassificationResource);
|
||||
classificationRepresentationModelAssembler.toEntityModel(
|
||||
modifiedClassificationRepresentationModel);
|
||||
|
||||
assertThat(before).isBefore(modifiedClassification.getModified());
|
||||
|
||||
|
|
@ -151,15 +153,15 @@ class AsyncUpdateJobIntTest {
|
|||
private void verifyTaskIsModifiedAfterOrEquals(String taskId, Instant before)
|
||||
throws InvalidArgumentException {
|
||||
|
||||
ResponseEntity<TaskResource> taskResponse =
|
||||
ResponseEntity<TaskRepresentationModel> taskResponse =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS_ID, taskId),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersAdmin()),
|
||||
ParameterizedTypeReference.forType(TaskResource.class));
|
||||
ParameterizedTypeReference.forType(TaskRepresentationModel.class));
|
||||
|
||||
TaskResource taskResource = taskResponse.getBody();
|
||||
Task task = taskResourceAssembler.toModel(taskResource);
|
||||
TaskRepresentationModel taskRepresentationModel = taskResponse.getBody();
|
||||
Task task = taskRepresentationModelAssembler.toEntityModel(taskRepresentationModel);
|
||||
|
||||
Instant modified = task.getModified();
|
||||
assertThat(before).as("Task " + task.getId() + " has not been refreshed.").isBefore(modified);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|||
import pro.taskana.common.api.LoggerUtils;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.rest.RestConfiguration;
|
||||
import pro.taskana.rest.resource.AccessIdResource;
|
||||
import pro.taskana.rest.resource.AccessIdRepresentationModel;
|
||||
|
||||
/** Test Ldap attachment. */
|
||||
@ActiveProfiles({"test"})
|
||||
|
|
@ -28,7 +28,7 @@ class LdapTest {
|
|||
@Test
|
||||
void testFindUsers() throws InvalidArgumentException {
|
||||
if (ldapClient.useLdap()) {
|
||||
List<AccessIdResource> usersAndGroups = ldapClient.searchUsersAndGroups("ser0");
|
||||
List<AccessIdRepresentationModel> usersAndGroups = ldapClient.searchUsersAndGroups("ser0");
|
||||
System.out.println("#### found " + LoggerUtils.listToString(usersAndGroups));
|
||||
assertThat(usersAndGroups).hasSize(50);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,11 +22,10 @@ import org.springframework.http.HttpMethod;
|
|||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
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.
|
||||
|
|
@ -59,14 +58,14 @@ public class TaskanaWildflyTest {
|
|||
public void shouldGetStatusOK() {
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
HttpEntity<String> request = new HttpEntity<String>(headers);
|
||||
ResponseEntity<TaskanaUserInfoResource> response =
|
||||
HttpEntity<String> request = new HttpEntity<>(headers);
|
||||
ResponseEntity<TaskanaUserInfoRepresentationModel> response =
|
||||
getRestTemplate()
|
||||
.exchange(
|
||||
"http://127.0.0.1:" + "8090" + "/api/v1/current-user-info",
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(TaskanaUserInfoResource.class));
|
||||
ParameterizedTypeReference.forType(TaskanaUserInfoRepresentationModel.class));
|
||||
assertEquals(HttpStatus.OK, response.getStatusCode());
|
||||
}
|
||||
|
||||
|
|
@ -78,8 +77,6 @@ public class TaskanaWildflyTest {
|
|||
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/json"));
|
||||
converter.setObjectMapper(mapper);
|
||||
|
||||
RestTemplate template =
|
||||
new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
|
||||
return template;
|
||||
return new RestTemplate(Collections.singletonList(converter));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package pro.taskana.ldap;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import pro.taskana.rest.resource.AccessIdResource;
|
||||
import pro.taskana.rest.resource.AccessIdRepresentationModel;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* string.
|
||||
*/
|
||||
List<AccessIdResource> findMatchingAccessId(String searchFor, int maxNumberOfReturnedAccessIds);
|
||||
List<AccessIdRepresentationModel> findMatchingAccessId(
|
||||
String searchFor, int maxNumberOfReturnedAccessIds);
|
||||
|
||||
/**
|
||||
* Find the groups belong to a user.
|
||||
|
|
@ -29,7 +30,8 @@ public interface LdapCache {
|
|||
* @param maxNumberOfReturnedAccessIds the maximum number of results to return.
|
||||
* @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.
|
||||
|
|
@ -37,5 +39,5 @@ public interface LdapCache {
|
|||
* @param accessId the search string.
|
||||
* @return the corresponding access ids.
|
||||
*/
|
||||
List<AccessIdResource> validateAccessId(String accessId);
|
||||
List<AccessIdRepresentationModel> validateAccessId(String accessId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package pro.taskana.ldap;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
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.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.common.api.exceptions.SystemException;
|
||||
import pro.taskana.rest.resource.AccessIdResource;
|
||||
import pro.taskana.rest.resource.AccessIdRepresentationModel;
|
||||
|
||||
/**
|
||||
* Class for Ldap access.
|
||||
|
|
@ -62,15 +63,15 @@ public class LdapClient {
|
|||
* maxNumberOfReturnedAccessIds
|
||||
* @throws InvalidArgumentException if input is shorter than minSearchForLength
|
||||
*/
|
||||
public List<AccessIdResource> searchUsersAndGroups(final String name)
|
||||
public List<AccessIdRepresentationModel> searchUsersAndGroups(final String name)
|
||||
throws InvalidArgumentException {
|
||||
LOGGER.debug("entry to searchUsersAndGroups(name = {})", name);
|
||||
isInitOrFail();
|
||||
testMinSearchForLength(name);
|
||||
|
||||
List<AccessIdResource> accessIds = new ArrayList<>();
|
||||
List<AccessIdRepresentationModel> accessIds = new ArrayList<>();
|
||||
if (nameIsDn(name)) {
|
||||
AccessIdResource groupByDn = searchGroupByDn(name);
|
||||
AccessIdRepresentationModel groupByDn = searchGroupByDn(name);
|
||||
if (groupByDn != null) {
|
||||
accessIds.add(groupByDn);
|
||||
}
|
||||
|
|
@ -79,7 +80,7 @@ public class LdapClient {
|
|||
accessIds.addAll(searchGroupsByName(name));
|
||||
}
|
||||
sortListOfAccessIdResources(accessIds);
|
||||
List<AccessIdResource> result = getFirstPageOfaResultList(accessIds);
|
||||
List<AccessIdRepresentationModel> result = getFirstPageOfaResultList(accessIds);
|
||||
|
||||
LOGGER.debug(
|
||||
"exit from searchUsersAndGroups(name = {}). Returning {} users and groups: {}",
|
||||
|
|
@ -90,7 +91,7 @@ public class LdapClient {
|
|||
return result;
|
||||
}
|
||||
|
||||
public List<AccessIdResource> searchUsersByName(final String name)
|
||||
public List<AccessIdRepresentationModel> searchUsersByName(final String name)
|
||||
throws InvalidArgumentException {
|
||||
LOGGER.debug("entry to searchUsersByName(name = {}).", name);
|
||||
isInitOrFail();
|
||||
|
|
@ -109,7 +110,7 @@ public class LdapClient {
|
|||
getUserFirstnameAttribute(), getUserLastnameAttribute(), getUserIdAttribute()
|
||||
};
|
||||
|
||||
final List<AccessIdResource> accessIds =
|
||||
final List<AccessIdRepresentationModel> accessIds =
|
||||
ldapTemplate.search(
|
||||
getUserSearchBase(),
|
||||
andFilter.encode(),
|
||||
|
|
@ -122,7 +123,7 @@ public class LdapClient {
|
|||
return accessIds;
|
||||
}
|
||||
|
||||
public List<AccessIdResource> searchGroupsByName(final String name)
|
||||
public List<AccessIdRepresentationModel> searchGroupsByName(final String name)
|
||||
throws InvalidArgumentException {
|
||||
LOGGER.debug("entry to searchGroupsByName(name = {}).", name);
|
||||
isInitOrFail();
|
||||
|
|
@ -137,7 +138,7 @@ public class LdapClient {
|
|||
}
|
||||
andFilter.and(orFilter);
|
||||
|
||||
final List<AccessIdResource> accessIds =
|
||||
final List<AccessIdRepresentationModel> accessIds =
|
||||
ldapTemplate.search(
|
||||
getGroupSearchBase(),
|
||||
andFilter.encode(),
|
||||
|
|
@ -150,7 +151,7 @@ public class LdapClient {
|
|||
return accessIds;
|
||||
}
|
||||
|
||||
public AccessIdResource searchGroupByDn(final String name) {
|
||||
public AccessIdRepresentationModel searchGroupByDn(final String name) {
|
||||
LOGGER.debug("entry to searchGroupByDn(name = {}).", name);
|
||||
isInitOrFail();
|
||||
// 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);
|
||||
LOGGER.debug(
|
||||
"Removed baseDN {} from given DN. New DN to be used: {}", getBaseDn(), nameWithoutBaseDn);
|
||||
final AccessIdResource accessId =
|
||||
final AccessIdRepresentationModel accessId =
|
||||
ldapTemplate.lookup(
|
||||
nameWithoutBaseDn, getLookUpGoupAttributesToReturn(), new GroupContextMapper());
|
||||
LOGGER.debug("Exit from searchGroupByDn. Retrieved the following group: {}", accessId);
|
||||
return accessId;
|
||||
}
|
||||
|
||||
public List<AccessIdResource> searchGroupsofUsersIsMember(final String name)
|
||||
public List<AccessIdRepresentationModel> searchGroupsofUsersIsMember(final String name)
|
||||
throws InvalidArgumentException {
|
||||
LOGGER.debug("entry to searchGroupsofUsersIsMember(name = {}).", name);
|
||||
isInitOrFail();
|
||||
|
|
@ -179,7 +180,7 @@ public class LdapClient {
|
|||
|
||||
String[] userAttributesToReturn = {getUserIdAttribute(), getGroupNameAttribute()};
|
||||
|
||||
final List<AccessIdResource> accessIds =
|
||||
final List<AccessIdRepresentationModel> accessIds =
|
||||
ldapTemplate.search(
|
||||
getGroupSearchBase(),
|
||||
andFilter.encode(),
|
||||
|
|
@ -278,7 +279,8 @@ public class LdapClient {
|
|||
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));
|
||||
}
|
||||
|
||||
|
|
@ -288,10 +290,10 @@ public class LdapClient {
|
|||
}
|
||||
}
|
||||
|
||||
void sortListOfAccessIdResources(List<AccessIdResource> accessIds) {
|
||||
void sortListOfAccessIdResources(List<AccessIdRepresentationModel> accessIds) {
|
||||
accessIds.sort(
|
||||
(AccessIdResource a, AccessIdResource b) ->
|
||||
a.getAccessId().compareToIgnoreCase(b.getAccessId()));
|
||||
Comparator.comparing(
|
||||
AccessIdRepresentationModel::getAccessId, String.CASE_INSENSITIVE_ORDER));
|
||||
}
|
||||
|
||||
String getNameWithoutBaseDn(String name) {
|
||||
|
|
@ -357,11 +359,11 @@ public class LdapClient {
|
|||
}
|
||||
|
||||
/** Context Mapper for user entries. */
|
||||
class GroupContextMapper extends AbstractContextMapper<AccessIdResource> {
|
||||
class GroupContextMapper extends AbstractContextMapper<AccessIdRepresentationModel> {
|
||||
|
||||
@Override
|
||||
public AccessIdResource doMapFromContext(final DirContextOperations context) {
|
||||
final AccessIdResource accessId = new AccessIdResource();
|
||||
public AccessIdRepresentationModel doMapFromContext(final DirContextOperations context) {
|
||||
final AccessIdRepresentationModel accessId = new AccessIdRepresentationModel();
|
||||
String dn = getDnWithBaseDn(context.getDn().toString());
|
||||
accessId.setAccessId(dn); // fully qualified dn
|
||||
accessId.setName(context.getStringAttribute(getGroupNameAttribute()));
|
||||
|
|
@ -370,11 +372,11 @@ public class LdapClient {
|
|||
}
|
||||
|
||||
/** Context Mapper for user entries. */
|
||||
class UserContextMapper extends AbstractContextMapper<AccessIdResource> {
|
||||
class UserContextMapper extends AbstractContextMapper<AccessIdRepresentationModel> {
|
||||
|
||||
@Override
|
||||
public AccessIdResource doMapFromContext(final DirContextOperations context) {
|
||||
final AccessIdResource accessId = new AccessIdResource();
|
||||
public AccessIdRepresentationModel doMapFromContext(final DirContextOperations context) {
|
||||
final AccessIdRepresentationModel accessId = new AccessIdRepresentationModel();
|
||||
accessId.setAccessId(context.getStringAttribute(getUserIdAttribute()));
|
||||
String firstName = context.getStringAttribute(getUserFirstnameAttribute());
|
||||
String lastName = context.getStringAttribute(getUserLastnameAttribute());
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ package pro.taskana.rest;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.springframework.hateoas.PagedModel.PageMetadata;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import pro.taskana.common.api.BaseQuery;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.rest.resource.PagedResources.PageMetadata;
|
||||
|
||||
/** Abstract superclass for taskana REST controller with pageable resources. */
|
||||
public abstract class AbstractPagingController {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.ldap.LdapCache;
|
||||
import pro.taskana.ldap.LdapClient;
|
||||
import pro.taskana.rest.resource.AccessIdResource;
|
||||
import pro.taskana.rest.resource.AccessIdRepresentationModel;
|
||||
|
||||
/**
|
||||
* Controller for access id validation.
|
||||
|
|
@ -30,7 +30,7 @@ public class AccessIdController {
|
|||
@Autowired LdapClient ldapClient;
|
||||
|
||||
@GetMapping(path = Mapping.URL_ACCESSID)
|
||||
public ResponseEntity<List<AccessIdResource>> validateAccessIds(
|
||||
public ResponseEntity<List<AccessIdRepresentationModel>> validateAccessIds(
|
||||
@RequestParam("search-for") String searchFor) throws InvalidArgumentException {
|
||||
LOGGER.debug("Entry to validateAccessIds(search-for= {})", searchFor);
|
||||
if (searchFor.length() < ldapClient.getMinSearchForLength()) {
|
||||
|
|
@ -40,9 +40,9 @@ public class AccessIdController {
|
|||
+ "' is too short. Minimum searchFor length = "
|
||||
+ ldapClient.getMinSearchForLength());
|
||||
}
|
||||
ResponseEntity<List<AccessIdResource>> response;
|
||||
ResponseEntity<List<AccessIdRepresentationModel>> response;
|
||||
if (ldapClient.useLdap()) {
|
||||
List<AccessIdResource> accessIdUsers = ldapClient.searchUsersAndGroups(searchFor);
|
||||
List<AccessIdRepresentationModel> accessIdUsers = ldapClient.searchUsersAndGroups(searchFor);
|
||||
response = ResponseEntity.ok(accessIdUsers);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from validateAccessIds(), returning {}", response);
|
||||
|
|
@ -67,7 +67,7 @@ public class AccessIdController {
|
|||
}
|
||||
|
||||
@GetMapping(path = Mapping.URL_ACCESSID_GROUPS)
|
||||
public ResponseEntity<List<AccessIdResource>> getGroupsByAccessId(
|
||||
public ResponseEntity<List<AccessIdRepresentationModel>> getGroupsByAccessId(
|
||||
@RequestParam("access-id") String accessId) throws InvalidArgumentException {
|
||||
LOGGER.debug("Entry to getGroupsByAccessId(access-id= {})", accessId);
|
||||
if (ldapClient.useLdap() || ldapCache != null) {
|
||||
|
|
@ -75,8 +75,8 @@ public class AccessIdController {
|
|||
throw new InvalidArgumentException("The accessId is invalid");
|
||||
}
|
||||
}
|
||||
List<AccessIdResource> accessIdUsers;
|
||||
ResponseEntity<List<AccessIdResource>> response;
|
||||
List<AccessIdRepresentationModel> accessIdUsers;
|
||||
ResponseEntity<List<AccessIdRepresentationModel>> response;
|
||||
if (ldapClient.useLdap()) {
|
||||
accessIdUsers = ldapClient.searchUsersAndGroups(accessId);
|
||||
accessIdUsers.addAll(ldapClient.searchGroupsofUsersIsMember(accessId));
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.hateoas.PagedModel.PageMetadata;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
|
||||
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.InvalidArgumentException;
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.rest.resource.ClassificationResource;
|
||||
import pro.taskana.rest.resource.ClassificationResourceAssembler;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryListResource;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryResourceAssembler;
|
||||
import pro.taskana.rest.resource.PagedResources.PageMetadata;
|
||||
import pro.taskana.rest.resource.ClassificationRepresentationModel;
|
||||
import pro.taskana.rest.resource.ClassificationRepresentationModelAssembler;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryRepresentationModel;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryRepresentationModelAssembler;
|
||||
import pro.taskana.rest.resource.TaskanaPagedModel;
|
||||
|
||||
/** Controller for all {@link Classification} related endpoints. */
|
||||
@RestController
|
||||
|
|
@ -78,39 +79,45 @@ public class ClassificationController extends AbstractPagingController {
|
|||
|
||||
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(
|
||||
ClassificationService classificationService,
|
||||
ClassificationResourceAssembler classificationResourceAssembler,
|
||||
ClassificationSummaryResourceAssembler classificationSummaryResourceAssembler) {
|
||||
ClassificationRepresentationModelAssembler classificationRepresentationModelAssembler,
|
||||
ClassificationSummaryRepresentationModelAssembler
|
||||
classificationSummaryRepresentationModelAssembler) {
|
||||
this.classificationService = classificationService;
|
||||
this.classificationResourceAssembler = classificationResourceAssembler;
|
||||
this.classificationSummaryResourceAssembler = classificationSummaryResourceAssembler;
|
||||
this.classificationRepresentationModelAssembler = classificationRepresentationModelAssembler;
|
||||
this.classificationSummaryRepresentationModelAssembler =
|
||||
classificationSummaryRepresentationModelAssembler;
|
||||
}
|
||||
|
||||
@GetMapping(path = Mapping.URL_CLASSIFICATIONS)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<ClassificationSummaryListResource> getClassifications(
|
||||
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
|
||||
public ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>>
|
||||
getClassifications(
|
||||
@RequestParam MultiValueMap<String, String> params)
|
||||
throws InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Entry to getClassifications(params= {})", params);
|
||||
}
|
||||
|
||||
ClassificationQuery query = classificationService.createClassificationQuery();
|
||||
query = applySortingParams(query, params);
|
||||
query = applyFilterParams(query, params);
|
||||
applyFilterParams(query, params);
|
||||
|
||||
PageMetadata pageMetadata = getPageMetadata(params, query);
|
||||
List<ClassificationSummary> classificationSummaries = getQueryList(query, pageMetadata);
|
||||
|
||||
ResponseEntity<ClassificationSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response =
|
||||
ResponseEntity.ok(
|
||||
classificationSummaryResourceAssembler.toCollectionModel(
|
||||
classificationSummaryRepresentationModelAssembler.toPageModel(
|
||||
classificationSummaries, pageMetadata));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
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)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<ClassificationResource> getClassification(
|
||||
public ResponseEntity<ClassificationRepresentationModel> getClassification(
|
||||
@PathVariable String classificationId) throws ClassificationNotFoundException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Entry to getClassification(classificationId= {})", classificationId);
|
||||
}
|
||||
|
||||
Classification classification = classificationService.getClassification(classificationId);
|
||||
ResponseEntity<ClassificationResource> response =
|
||||
ResponseEntity.ok(classificationResourceAssembler.toModel(classification));
|
||||
ResponseEntity<ClassificationRepresentationModel> response =
|
||||
ResponseEntity.ok(classificationRepresentationModelAssembler.toModel(classification));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getClassification(), returning {}", response);
|
||||
}
|
||||
|
|
@ -139,19 +146,20 @@ public class ClassificationController extends AbstractPagingController {
|
|||
|
||||
@PostMapping(path = Mapping.URL_CLASSIFICATIONS)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<ClassificationResource> createClassification(
|
||||
@RequestBody ClassificationResource resource)
|
||||
public ResponseEntity<ClassificationRepresentationModel> createClassification(
|
||||
@RequestBody ClassificationRepresentationModel resource)
|
||||
throws NotAuthorizedException, ClassificationAlreadyExistException, DomainNotFoundException,
|
||||
InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Entry to createClassification(resource= {})", resource);
|
||||
}
|
||||
Classification classification = classificationResourceAssembler.toModel(resource);
|
||||
Classification classification = classificationRepresentationModelAssembler
|
||||
.toEntityModel(resource);
|
||||
classification = classificationService.createClassification(classification);
|
||||
|
||||
ResponseEntity<ClassificationResource> response =
|
||||
ResponseEntity<ClassificationRepresentationModel> response =
|
||||
ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(classificationResourceAssembler.toModel(classification));
|
||||
.body(classificationRepresentationModelAssembler.toModel(classification));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from createClassification(), returning {}", response);
|
||||
}
|
||||
|
|
@ -161,9 +169,9 @@ public class ClassificationController extends AbstractPagingController {
|
|||
|
||||
@PutMapping(path = Mapping.URL_CLASSIFICATIONS_ID)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<ClassificationResource> updateClassification(
|
||||
public ResponseEntity<ClassificationRepresentationModel> updateClassification(
|
||||
@PathVariable(value = "classificationId") String classificationId,
|
||||
@RequestBody ClassificationResource resource)
|
||||
@RequestBody ClassificationRepresentationModel resource)
|
||||
throws NotAuthorizedException, ClassificationNotFoundException, ConcurrencyException,
|
||||
InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
|
@ -173,11 +181,13 @@ public class ClassificationController extends AbstractPagingController {
|
|||
resource);
|
||||
}
|
||||
|
||||
ResponseEntity<ClassificationResource> result;
|
||||
ResponseEntity<ClassificationRepresentationModel> result;
|
||||
if (classificationId.equals(resource.getClassificationId())) {
|
||||
Classification classification = classificationResourceAssembler.toModel(resource);
|
||||
Classification classification = classificationRepresentationModelAssembler
|
||||
.toEntityModel(resource);
|
||||
classification = classificationService.updateClassification(classification);
|
||||
result = ResponseEntity.ok(classificationResourceAssembler.toModel(classification));
|
||||
result =
|
||||
ResponseEntity.ok(classificationRepresentationModelAssembler.toModel(classification));
|
||||
} else {
|
||||
throw new InvalidArgumentException(
|
||||
"ClassificationId ('"
|
||||
|
|
@ -247,7 +257,7 @@ public class ClassificationController extends AbstractPagingController {
|
|||
return query;
|
||||
}
|
||||
|
||||
private ClassificationQuery applyFilterParams(
|
||||
private void applyFilterParams(
|
||||
ClassificationQuery query, MultiValueMap<String, String> params)
|
||||
throws InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
|
@ -320,6 +330,5 @@ public class ClassificationController extends AbstractPagingController {
|
|||
LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ import pro.taskana.common.api.exceptions.ConcurrencyException;
|
|||
import pro.taskana.common.api.exceptions.DomainNotFoundException;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.rest.resource.ClassificationResource;
|
||||
import pro.taskana.rest.resource.ClassificationResourceAssembler;
|
||||
import pro.taskana.rest.resource.ClassificationRepresentationModel;
|
||||
import pro.taskana.rest.resource.ClassificationRepresentationModelAssembler;
|
||||
|
||||
/** Controller for Importing / Exporting classifications. */
|
||||
@SuppressWarnings("unused")
|
||||
|
|
@ -48,34 +48,34 @@ public class ClassificationDefinitionController {
|
|||
|
||||
private ClassificationService classificationService;
|
||||
|
||||
private ClassificationResourceAssembler classificationResourceAssembler;
|
||||
private ClassificationRepresentationModelAssembler classificationRepresentationModelAssembler;
|
||||
|
||||
ClassificationDefinitionController(
|
||||
ClassificationService classificationService,
|
||||
ClassificationResourceAssembler classificationResourceAssembler) {
|
||||
ClassificationRepresentationModelAssembler classificationRepresentationModelAssembler) {
|
||||
this.classificationService = classificationService;
|
||||
this.classificationResourceAssembler = classificationResourceAssembler;
|
||||
this.classificationRepresentationModelAssembler = classificationRepresentationModelAssembler;
|
||||
}
|
||||
|
||||
@GetMapping(path = Mapping.URL_CLASSIFICATIONDEFINITION)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<List<ClassificationResource>> exportClassifications(
|
||||
public ResponseEntity<List<ClassificationRepresentationModel>> exportClassifications(
|
||||
@RequestParam(required = false) String domain) throws ClassificationNotFoundException {
|
||||
LOGGER.debug("Entry to exportClassifications(domain= {})", domain);
|
||||
ClassificationQuery query = classificationService.createClassificationQuery();
|
||||
|
||||
List<ClassificationSummary> summaries =
|
||||
domain != null ? query.domainIn(domain).list() : query.list();
|
||||
List<ClassificationResource> export = new ArrayList<>();
|
||||
List<ClassificationRepresentationModel> export = new ArrayList<>();
|
||||
|
||||
for (ClassificationSummary summary : summaries) {
|
||||
Classification classification =
|
||||
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()) {
|
||||
LOGGER.debug("Exit from exportClassifications(), returning {}", response);
|
||||
}
|
||||
|
|
@ -91,7 +91,7 @@ public class ClassificationDefinitionController {
|
|||
DomainNotFoundException, IOException {
|
||||
LOGGER.debug("Entry to importClassifications()");
|
||||
Map<String, String> systemIds = getSystemIds();
|
||||
List<ClassificationResource> classificationsResources =
|
||||
List<ClassificationRepresentationModel> classificationsResources =
|
||||
extractClassificationResourcesFromFile(file);
|
||||
checkForDuplicates(classificationsResources);
|
||||
|
||||
|
|
@ -110,18 +110,18 @@ public class ClassificationDefinitionController {
|
|||
Collectors.toMap(i -> i.getKey() + "|" + i.getDomain(), ClassificationSummary::getId));
|
||||
}
|
||||
|
||||
private List<ClassificationResource> extractClassificationResourcesFromFile(MultipartFile file)
|
||||
throws IOException {
|
||||
private List<ClassificationRepresentationModel> extractClassificationResourcesFromFile(
|
||||
MultipartFile file) throws IOException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
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<>();
|
||||
Set<String> duplicates = new HashSet<>();
|
||||
for (ClassificationResource classification : classificationList) {
|
||||
for (ClassificationRepresentationModel classification : classificationList) {
|
||||
String identifier = classification.getKey() + "|" + classification.getDomain();
|
||||
if (identifiers.contains(identifier)) {
|
||||
duplicates.add(identifier);
|
||||
|
|
@ -136,19 +136,20 @@ public class ClassificationDefinitionController {
|
|||
}
|
||||
|
||||
private Map<Classification, String> mapChildrenToParentKeys(
|
||||
List<ClassificationResource> classificationResources, Map<String, String> systemIds) {
|
||||
List<ClassificationRepresentationModel> classificationRepresentationModels,
|
||||
Map<String, String> systemIds) {
|
||||
LOGGER.debug("Entry to mapChildrenToParentKeys()");
|
||||
Map<Classification, String> childrenInFile = new HashMap<>();
|
||||
Set<String> newKeysWithDomain = new HashSet<>();
|
||||
classificationResources.forEach(
|
||||
classificationRepresentationModels.forEach(
|
||||
cl -> newKeysWithDomain.add(cl.getKey() + "|" + cl.getDomain()));
|
||||
|
||||
for (ClassificationResource cl : classificationResources) {
|
||||
for (ClassificationRepresentationModel cl : classificationRepresentationModels) {
|
||||
cl.setParentId(cl.getParentId() == null ? "" : cl.getParentId());
|
||||
cl.setParentKey(cl.getParentKey() == null ? "" : cl.getParentKey());
|
||||
|
||||
if (!cl.getParentId().equals("") && cl.getParentKey().equals("")) {
|
||||
for (ClassificationResource parent : classificationResources) {
|
||||
for (ClassificationRepresentationModel parent : classificationRepresentationModels) {
|
||||
if (cl.getParentId().equals(parent.getClassificationId())) {
|
||||
cl.setParentKey(parent.getKey());
|
||||
}
|
||||
|
|
@ -159,7 +160,8 @@ public class ClassificationDefinitionController {
|
|||
if (!cl.getParentKey().isEmpty() && !cl.getParentKey().equals("")) {
|
||||
if (newKeysWithDomain.contains(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(
|
||||
List<ClassificationResource> classificationResources, Map<String, String> systemIds)
|
||||
List<ClassificationRepresentationModel> classificationRepresentationModels,
|
||||
Map<String, String> systemIds)
|
||||
throws ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException,
|
||||
ClassificationAlreadyExistException, DomainNotFoundException, ConcurrencyException {
|
||||
LOGGER.debug("Entry to insertOrUpdateClassificationsWithoutParent()");
|
||||
|
||||
for (ClassificationResource classificationResource : classificationResources) {
|
||||
classificationResource.setParentKey(null);
|
||||
classificationResource.setParentId(null);
|
||||
classificationResource.setClassificationId(null);
|
||||
for (ClassificationRepresentationModel classificationRepresentationModel :
|
||||
classificationRepresentationModels) {
|
||||
classificationRepresentationModel.setParentKey(null);
|
||||
classificationRepresentationModel.setParentId(null);
|
||||
classificationRepresentationModel.setClassificationId(null);
|
||||
|
||||
String systemId =
|
||||
systemIds.get(classificationResource.getKey() + "|" + classificationResource.getDomain());
|
||||
systemIds.get(
|
||||
classificationRepresentationModel.getKey()
|
||||
+ "|"
|
||||
+ classificationRepresentationModel.getDomain());
|
||||
if (systemId != null) {
|
||||
updateExistingClassification(classificationResource, systemId);
|
||||
updateExistingClassification(classificationRepresentationModel, systemId);
|
||||
} else {
|
||||
classificationService.createClassification(
|
||||
classificationResourceAssembler.toModel(classificationResource));
|
||||
classificationRepresentationModelAssembler
|
||||
.toEntityModel(classificationRepresentationModel));
|
||||
}
|
||||
}
|
||||
LOGGER.debug("Exit from insertOrUpdateClassificationsWithoutParent()");
|
||||
|
|
@ -221,7 +229,7 @@ public class ClassificationDefinitionController {
|
|||
LOGGER.debug("Exit from updateParentChildrenRelations()");
|
||||
}
|
||||
|
||||
private void updateExistingClassification(ClassificationResource cl, String systemId)
|
||||
private void updateExistingClassification(ClassificationRepresentationModel cl, String systemId)
|
||||
throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException,
|
||||
InvalidArgumentException {
|
||||
LOGGER.debug("Entry to updateExistingClassification()");
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
|||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.monitor.api.MonitorService;
|
||||
import pro.taskana.monitor.api.reports.header.TimeIntervalColumnHeader;
|
||||
import pro.taskana.rest.resource.ReportResource;
|
||||
import pro.taskana.rest.resource.ReportResourceAssembler;
|
||||
import pro.taskana.rest.resource.ReportRepresentationModel;
|
||||
import pro.taskana.rest.resource.ReportRepresentationModelAssembler;
|
||||
import pro.taskana.task.api.TaskState;
|
||||
|
||||
/** Controller for all monitoring endpoints. */
|
||||
|
|
@ -32,24 +32,25 @@ public class MonitorController {
|
|||
|
||||
private MonitorService monitorService;
|
||||
|
||||
private ReportResourceAssembler reportResourceAssembler;
|
||||
private ReportRepresentationModelAssembler reportRepresentationModelAssembler;
|
||||
|
||||
MonitorController(
|
||||
MonitorService monitorService, ReportResourceAssembler reportResourceAssembler) {
|
||||
MonitorService monitorService,
|
||||
ReportRepresentationModelAssembler reportRepresentationModelAssembler) {
|
||||
this.monitorService = monitorService;
|
||||
this.reportResourceAssembler = reportResourceAssembler;
|
||||
this.reportRepresentationModelAssembler = reportRepresentationModelAssembler;
|
||||
}
|
||||
|
||||
@GetMapping(path = Mapping.URL_MONITOR_TASKSSTATUS)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<ReportResource> getTasksStatusReport(
|
||||
public ResponseEntity<ReportRepresentationModel> getTasksStatusReport(
|
||||
@RequestParam(required = false) List<String> domains,
|
||||
@RequestParam(required = false) List<TaskState> states)
|
||||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
LOGGER.debug("Entry to getTasksStatusReport()");
|
||||
ResponseEntity<ReportResource> response =
|
||||
ResponseEntity<ReportRepresentationModel> response =
|
||||
ResponseEntity.ok(
|
||||
reportResourceAssembler.toModel(
|
||||
reportRepresentationModelAssembler.toModel(
|
||||
monitorService
|
||||
.createTaskStatusReportBuilder()
|
||||
.stateIn(states)
|
||||
|
|
@ -71,8 +72,8 @@ public class MonitorController {
|
|||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
LOGGER.debug("Entry to getTasksWorkbasketReport()");
|
||||
|
||||
ReportResource report =
|
||||
reportResourceAssembler.toModel(
|
||||
ReportRepresentationModel report =
|
||||
reportRepresentationModelAssembler.toModel(
|
||||
monitorService
|
||||
.createWorkbasketReportBuilder()
|
||||
.withColumnHeaders(getRangeTimeInterval())
|
||||
|
|
@ -94,8 +95,8 @@ public class MonitorController {
|
|||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
LOGGER.debug("Entry to getTasksWorkbasketPlannedDateReport()");
|
||||
|
||||
ReportResource report =
|
||||
reportResourceAssembler.toModel(
|
||||
ReportRepresentationModel report =
|
||||
reportRepresentationModelAssembler.toModel(
|
||||
monitorService
|
||||
.createWorkbasketReportBuilder()
|
||||
.stateIn(states)
|
||||
|
|
@ -112,12 +113,12 @@ public class MonitorController {
|
|||
|
||||
@GetMapping(path = Mapping.URL_MONITOR_TASKSCLASSIFICATION)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<ReportResource> getTasksClassificationReport()
|
||||
public ResponseEntity<ReportRepresentationModel> getTasksClassificationReport()
|
||||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
LOGGER.debug("Entry to getTasksClassificationReport()");
|
||||
|
||||
ReportResource report =
|
||||
reportResourceAssembler.toModel(
|
||||
ReportRepresentationModel report =
|
||||
reportRepresentationModelAssembler.toModel(
|
||||
monitorService
|
||||
.createClassificationReportBuilder()
|
||||
.withColumnHeaders(getRangeTimeInterval())
|
||||
|
|
@ -132,7 +133,7 @@ public class MonitorController {
|
|||
|
||||
@GetMapping(path = Mapping.URL_MONITOR_TIMESTAMP)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<ReportResource> getDailyEntryExitReport()
|
||||
public ResponseEntity<ReportRepresentationModel> getDailyEntryExitReport()
|
||||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
List<TimeIntervalColumnHeader> columnHeaders =
|
||||
IntStream.range(-14, 0)
|
||||
|
|
@ -140,7 +141,7 @@ public class MonitorController {
|
|||
.collect(Collectors.toList());
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(
|
||||
reportResourceAssembler.toModel(
|
||||
reportRepresentationModelAssembler.toModel(
|
||||
monitorService
|
||||
.createTimestampReportBuilder()
|
||||
.withColumnHeaders(columnHeaders)
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import pro.taskana.common.api.exceptions.ConcurrencyException;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.rest.resource.TaskCommentListResource;
|
||||
import pro.taskana.rest.resource.TaskCommentResource;
|
||||
import pro.taskana.rest.resource.TaskCommentResourceAssembler;
|
||||
import pro.taskana.rest.resource.TaskCommentRepresentationModel;
|
||||
import pro.taskana.rest.resource.TaskCommentRepresentationModelAssembler;
|
||||
import pro.taskana.rest.resource.TaskanaPagedModel;
|
||||
import pro.taskana.task.api.TaskService;
|
||||
import pro.taskana.task.api.exceptions.TaskCommentNotFoundException;
|
||||
import pro.taskana.task.api.exceptions.TaskNotFoundException;
|
||||
|
|
@ -35,17 +35,19 @@ public class TaskCommentController {
|
|||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskCommentController.class);
|
||||
|
||||
private TaskService taskService;
|
||||
private TaskCommentResourceAssembler taskCommentResourceAssembler;
|
||||
private TaskCommentRepresentationModelAssembler taskCommentRepresentationModelAssembler;
|
||||
|
||||
TaskCommentController(
|
||||
TaskService taskService, TaskCommentResourceAssembler taskCommentResourceAssembler) {
|
||||
TaskService taskService,
|
||||
TaskCommentRepresentationModelAssembler taskCommentRepresentationModelAssembler) {
|
||||
this.taskService = taskService;
|
||||
this.taskCommentResourceAssembler = taskCommentResourceAssembler;
|
||||
this.taskCommentRepresentationModelAssembler = taskCommentRepresentationModelAssembler;
|
||||
}
|
||||
|
||||
@GetMapping(path = Mapping.URL_TASK_COMMENT)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskCommentResource> getTaskComment(@PathVariable String taskCommentId)
|
||||
public ResponseEntity<TaskCommentRepresentationModel> getTaskComment(
|
||||
@PathVariable String taskCommentId)
|
||||
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
|
||||
InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
|
@ -54,9 +56,11 @@ public class TaskCommentController {
|
|||
|
||||
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()) {
|
||||
LOGGER.debug("Exit from getTaskComment(), returning {}", response);
|
||||
|
|
@ -67,18 +71,19 @@ public class TaskCommentController {
|
|||
|
||||
@GetMapping(path = Mapping.URL_TASK_GET_POST_COMMENTS)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskCommentListResource> getTaskComments(@PathVariable String taskId)
|
||||
throws NotAuthorizedException, TaskNotFoundException {
|
||||
public ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>> getTaskComments(
|
||||
@PathVariable String taskId) throws NotAuthorizedException, TaskNotFoundException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Entry to getTaskComments(taskId= {})", taskId);
|
||||
}
|
||||
|
||||
List<TaskComment> taskComments = taskService.getTaskComments(taskId);
|
||||
|
||||
TaskCommentListResource taskCommentListResource =
|
||||
taskCommentResourceAssembler.toListResource(taskComments);
|
||||
TaskanaPagedModel<TaskCommentRepresentationModel> taskCommentListResource =
|
||||
taskCommentRepresentationModelAssembler.toPageModel(taskComments, null);
|
||||
|
||||
ResponseEntity<TaskCommentListResource> response = ResponseEntity.ok(taskCommentListResource);
|
||||
ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>> response =
|
||||
ResponseEntity.ok(taskCommentListResource);
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getTaskComments(), returning {}", response);
|
||||
|
|
@ -89,7 +94,8 @@ public class TaskCommentController {
|
|||
|
||||
@DeleteMapping(path = Mapping.URL_TASK_COMMENT)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskCommentResource> deleteTaskComment(@PathVariable String taskCommentId)
|
||||
public ResponseEntity<TaskCommentRepresentationModel> deleteTaskComment(
|
||||
@PathVariable String taskCommentId)
|
||||
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
|
||||
InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
|
@ -98,7 +104,7 @@ public class TaskCommentController {
|
|||
|
||||
taskService.deleteTaskComment(taskCommentId);
|
||||
|
||||
ResponseEntity<TaskCommentResource> result = ResponseEntity.noContent().build();
|
||||
ResponseEntity<TaskCommentRepresentationModel> result = ResponseEntity.noContent().build();
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from deleteTaskComment(), returning {}", result);
|
||||
|
|
@ -109,25 +115,27 @@ public class TaskCommentController {
|
|||
|
||||
@PutMapping(path = Mapping.URL_TASK_COMMENT)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskCommentResource> updateTaskComment(
|
||||
@PathVariable String taskCommentId, @RequestBody TaskCommentResource taskCommentResource)
|
||||
public ResponseEntity<TaskCommentRepresentationModel> updateTaskComment(
|
||||
@PathVariable String taskCommentId,
|
||||
@RequestBody TaskCommentRepresentationModel taskCommentRepresentationModel)
|
||||
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
|
||||
InvalidArgumentException, ConcurrencyException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(
|
||||
"Entry to updateTaskComment(taskCommentId= {}, taskCommentResource= {})",
|
||||
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);
|
||||
result = ResponseEntity.ok(taskCommentResourceAssembler.toModel(taskComment));
|
||||
result = ResponseEntity.ok(taskCommentRepresentationModelAssembler.toModel(taskComment));
|
||||
} else {
|
||||
throw new InvalidArgumentException(
|
||||
String.format(
|
||||
|
|
@ -145,27 +153,29 @@ public class TaskCommentController {
|
|||
|
||||
@PostMapping(path = Mapping.URL_TASK_GET_POST_COMMENTS)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskCommentResource> createTaskComment(
|
||||
@PathVariable String taskId, @RequestBody TaskCommentResource taskCommentResource)
|
||||
public ResponseEntity<TaskCommentRepresentationModel> createTaskComment(
|
||||
@PathVariable String taskId,
|
||||
@RequestBody TaskCommentRepresentationModel taskCommentRepresentationModel)
|
||||
throws NotAuthorizedException, InvalidArgumentException, TaskNotFoundException {
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(
|
||||
"Entry to createTaskComment(taskId= {}, taskCommentResource= {})",
|
||||
taskId,
|
||||
taskCommentResource);
|
||||
taskCommentRepresentationModel);
|
||||
}
|
||||
|
||||
taskCommentResource.setTaskId(taskId);
|
||||
taskCommentRepresentationModel.setTaskId(taskId);
|
||||
|
||||
TaskComment taskCommentFromResource = taskCommentResourceAssembler.toModel(taskCommentResource);
|
||||
TaskComment taskCommentFromResource =
|
||||
taskCommentRepresentationModelAssembler.toEntityModel(taskCommentRepresentationModel);
|
||||
TaskComment createdTaskComment = taskService.createTaskComment(taskCommentFromResource);
|
||||
|
||||
ResponseEntity<TaskCommentResource> result;
|
||||
ResponseEntity<TaskCommentRepresentationModel> result;
|
||||
|
||||
result =
|
||||
ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(taskCommentResourceAssembler.toModel(createdTaskComment));
|
||||
.body(taskCommentRepresentationModelAssembler.toModel(createdTaskComment));
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from createTaskComment(), returning {}", result);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import java.util.Objects;
|
|||
import java.util.stream.Stream;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.hateoas.PagedModel.PageMetadata;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
|
||||
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.InvalidArgumentException;
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.rest.resource.PagedResources.PageMetadata;
|
||||
import pro.taskana.rest.resource.TaskResource;
|
||||
import pro.taskana.rest.resource.TaskResourceAssembler;
|
||||
import pro.taskana.rest.resource.TaskSummaryListResource;
|
||||
import pro.taskana.rest.resource.TaskSummaryResourceAssembler;
|
||||
import pro.taskana.rest.resource.TaskRepresentationModel;
|
||||
import pro.taskana.rest.resource.TaskRepresentationModelAssembler;
|
||||
import pro.taskana.rest.resource.TaskSummaryRepresentationModel;
|
||||
import pro.taskana.rest.resource.TaskSummaryRepresentationModelAssembler;
|
||||
import pro.taskana.rest.resource.TaskanaPagedModel;
|
||||
import pro.taskana.task.api.TaskQuery;
|
||||
import pro.taskana.task.api.TaskService;
|
||||
import pro.taskana.task.api.TaskState;
|
||||
|
|
@ -90,22 +91,22 @@ public class TaskController extends AbstractPagingController {
|
|||
|
||||
private TaskService taskService;
|
||||
|
||||
private TaskResourceAssembler taskResourceAssembler;
|
||||
private TaskRepresentationModelAssembler taskRepresentationModelAssembler;
|
||||
|
||||
private TaskSummaryResourceAssembler taskSummaryResourceAssembler;
|
||||
private TaskSummaryRepresentationModelAssembler taskSummaryRepresentationModelAssembler;
|
||||
|
||||
TaskController(
|
||||
TaskService taskService,
|
||||
TaskResourceAssembler taskResourceAssembler,
|
||||
TaskSummaryResourceAssembler taskSummaryResourceAssembler) {
|
||||
TaskRepresentationModelAssembler taskRepresentationModelAssembler,
|
||||
TaskSummaryRepresentationModelAssembler taskSummaryRepresentationModelAssembler) {
|
||||
this.taskService = taskService;
|
||||
this.taskResourceAssembler = taskResourceAssembler;
|
||||
this.taskSummaryResourceAssembler = taskSummaryResourceAssembler;
|
||||
this.taskRepresentationModelAssembler = taskRepresentationModelAssembler;
|
||||
this.taskSummaryRepresentationModelAssembler = taskSummaryRepresentationModelAssembler;
|
||||
}
|
||||
|
||||
@GetMapping(path = Mapping.URL_TASKS)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskSummaryListResource> getTasks(
|
||||
public ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> getTasks(
|
||||
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Entry to getTasks(params= {})", params);
|
||||
|
|
@ -118,9 +119,10 @@ public class TaskController extends AbstractPagingController {
|
|||
PageMetadata pageMetadata = getPageMetadata(params, query);
|
||||
List<TaskSummary> taskSummaries = getQueryList(query, pageMetadata);
|
||||
|
||||
TaskSummaryListResource pagedResources =
|
||||
taskSummaryResourceAssembler.toCollectionModel(taskSummaries, pageMetadata);
|
||||
ResponseEntity<TaskSummaryListResource> response = ResponseEntity.ok(pagedResources);
|
||||
TaskanaPagedModel<TaskSummaryRepresentationModel> pagedModels =
|
||||
taskSummaryRepresentationModelAssembler.toPageModel(taskSummaries, pageMetadata);
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
ResponseEntity.ok(pagedModels);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getTasks(), returning {}", response);
|
||||
}
|
||||
|
|
@ -130,11 +132,12 @@ public class TaskController extends AbstractPagingController {
|
|||
|
||||
@GetMapping(path = Mapping.URL_TASKS_ID)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskResource> getTask(@PathVariable String taskId)
|
||||
public ResponseEntity<TaskRepresentationModel> getTask(@PathVariable String taskId)
|
||||
throws TaskNotFoundException, NotAuthorizedException {
|
||||
LOGGER.debug("Entry to getTask(taskId= {})", 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()) {
|
||||
LOGGER.debug("Exit from getTask(), returning {}", result);
|
||||
}
|
||||
|
|
@ -144,7 +147,7 @@ public class TaskController extends AbstractPagingController {
|
|||
|
||||
@PostMapping(path = Mapping.URL_TASKS_ID_CLAIM)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskResource> claimTask(
|
||||
public ResponseEntity<TaskRepresentationModel> claimTask(
|
||||
@PathVariable String taskId, @RequestBody String userName)
|
||||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
|
||||
NotAuthorizedException {
|
||||
|
|
@ -152,8 +155,8 @@ public class TaskController extends AbstractPagingController {
|
|||
// TODO verify user
|
||||
taskService.claim(taskId);
|
||||
Task updatedTask = taskService.getTask(taskId);
|
||||
ResponseEntity<TaskResource> result =
|
||||
ResponseEntity.ok(taskResourceAssembler.toModel(updatedTask));
|
||||
ResponseEntity<TaskRepresentationModel> result =
|
||||
ResponseEntity.ok(taskRepresentationModelAssembler.toModel(updatedTask));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from claimTask(), returning {}", result);
|
||||
}
|
||||
|
|
@ -163,7 +166,7 @@ public class TaskController extends AbstractPagingController {
|
|||
|
||||
@DeleteMapping(path = Mapping.URL_TASKS_ID_CLAIM)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskResource> cancelClaimTask(@PathVariable String taskId)
|
||||
public ResponseEntity<TaskRepresentationModel> cancelClaimTask(@PathVariable String taskId)
|
||||
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
|
||||
NotAuthorizedException {
|
||||
|
||||
|
|
@ -172,8 +175,8 @@ public class TaskController extends AbstractPagingController {
|
|||
taskService.cancelClaim(taskId);
|
||||
Task updatedTask = taskService.getTask(taskId);
|
||||
|
||||
ResponseEntity<TaskResource> result =
|
||||
ResponseEntity.ok(taskResourceAssembler.toModel(updatedTask));
|
||||
ResponseEntity<TaskRepresentationModel> result =
|
||||
ResponseEntity.ok(taskRepresentationModelAssembler.toModel(updatedTask));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from cancelClaimTask(), returning {}", result);
|
||||
}
|
||||
|
|
@ -182,14 +185,14 @@ public class TaskController extends AbstractPagingController {
|
|||
|
||||
@PostMapping(path = Mapping.URL_TASKS_ID_COMPLETE)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskResource> completeTask(@PathVariable String taskId)
|
||||
public ResponseEntity<TaskRepresentationModel> completeTask(@PathVariable String taskId)
|
||||
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException,
|
||||
NotAuthorizedException {
|
||||
LOGGER.debug("Entry to completeTask(taskId= {})", taskId);
|
||||
taskService.forceCompleteTask(taskId);
|
||||
Task updatedTask = taskService.getTask(taskId);
|
||||
ResponseEntity<TaskResource> result =
|
||||
ResponseEntity.ok(taskResourceAssembler.toModel(updatedTask));
|
||||
ResponseEntity<TaskRepresentationModel> result =
|
||||
ResponseEntity.ok(taskRepresentationModelAssembler.toModel(updatedTask));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from completeTask(), returning {}", result);
|
||||
}
|
||||
|
|
@ -199,29 +202,31 @@ public class TaskController extends AbstractPagingController {
|
|||
|
||||
@DeleteMapping(path = Mapping.URL_TASKS_ID)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskResource> deleteTask(@PathVariable String taskId)
|
||||
public ResponseEntity<TaskRepresentationModel> deleteTask(@PathVariable String taskId)
|
||||
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
|
||||
LOGGER.debug("Entry to deleteTask(taskId= {})", taskId);
|
||||
taskService.forceDeleteTask(taskId);
|
||||
ResponseEntity<TaskResource> result = ResponseEntity.noContent().build();
|
||||
ResponseEntity<TaskRepresentationModel> result = ResponseEntity.noContent().build();
|
||||
LOGGER.debug("Exit from deleteTask(), returning {}", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping(path = Mapping.URL_TASKS)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskResource> createTask(@RequestBody TaskResource taskResource)
|
||||
public ResponseEntity<TaskRepresentationModel> createTask(
|
||||
@RequestBody TaskRepresentationModel taskRepresentationModel)
|
||||
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
|
||||
TaskAlreadyExistException, InvalidArgumentException {
|
||||
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);
|
||||
|
||||
ResponseEntity<TaskResource> result =
|
||||
ResponseEntity.status(HttpStatus.CREATED).body(taskResourceAssembler.toModel(createdTask));
|
||||
ResponseEntity<TaskRepresentationModel> result =
|
||||
ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(taskRepresentationModelAssembler.toModel(createdTask));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from createTask(), returning {}", result);
|
||||
}
|
||||
|
|
@ -231,14 +236,14 @@ public class TaskController extends AbstractPagingController {
|
|||
|
||||
@PostMapping(path = Mapping.URL_TASKS_ID_TRANSFER_WORKBASKETID)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskResource> transferTask(
|
||||
public ResponseEntity<TaskRepresentationModel> transferTask(
|
||||
@PathVariable String taskId, @PathVariable String workbasketId)
|
||||
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
|
||||
InvalidStateException {
|
||||
LOGGER.debug("Entry to transferTask(taskId= {}, workbasketId= {})", taskId, workbasketId);
|
||||
Task updatedTask = taskService.transfer(taskId, workbasketId);
|
||||
ResponseEntity<TaskResource> result =
|
||||
ResponseEntity.ok(taskResourceAssembler.toModel(updatedTask));
|
||||
ResponseEntity<TaskRepresentationModel> result =
|
||||
ResponseEntity.ok(taskRepresentationModelAssembler.toModel(updatedTask));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from transferTask(), returning {}", result);
|
||||
}
|
||||
|
|
@ -248,23 +253,25 @@ public class TaskController extends AbstractPagingController {
|
|||
|
||||
@PutMapping(path = Mapping.URL_TASKS_ID)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskResource> updateTask(
|
||||
@PathVariable(value = "taskId") String taskId, @RequestBody TaskResource taskResource)
|
||||
public ResponseEntity<TaskRepresentationModel> updateTask(
|
||||
@PathVariable(value = "taskId") String taskId,
|
||||
@RequestBody TaskRepresentationModel taskRepresentationModel)
|
||||
throws TaskNotFoundException, ClassificationNotFoundException, InvalidArgumentException,
|
||||
ConcurrencyException, NotAuthorizedException, AttachmentPersistenceException,
|
||||
InvalidStateException {
|
||||
LOGGER.debug("Entry to updateTask(taskId= {}, taskResource= {})", taskId, taskResource);
|
||||
ResponseEntity<TaskResource> result;
|
||||
if (taskId.equals(taskResource.getTaskId())) {
|
||||
Task task = taskResourceAssembler.toModel(taskResource);
|
||||
LOGGER.debug(
|
||||
"Entry to updateTask(taskId= {}, taskResource= {})", taskId, taskRepresentationModel);
|
||||
ResponseEntity<TaskRepresentationModel> result;
|
||||
if (taskId.equals(taskRepresentationModel.getTaskId())) {
|
||||
Task task = taskRepresentationModelAssembler.toEntityModel(taskRepresentationModel);
|
||||
task = taskService.updateTask(task);
|
||||
result = ResponseEntity.ok(taskResourceAssembler.toModel(task));
|
||||
result = ResponseEntity.ok(taskRepresentationModelAssembler.toModel(task));
|
||||
} else {
|
||||
throw new InvalidArgumentException(
|
||||
String.format(
|
||||
"TaskId ('%s') is not identical with the taskId of to "
|
||||
+ "object in the payload which should be updated. ID=('%s')",
|
||||
taskId, taskResource.getTaskId()));
|
||||
taskId, taskRepresentationModel.getTaskId()));
|
||||
}
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ import pro.taskana.TaskanaEngineConfiguration;
|
|||
import pro.taskana.common.api.TaskanaEngine;
|
||||
import pro.taskana.common.api.TaskanaRole;
|
||||
import pro.taskana.common.internal.security.CurrentUserContext;
|
||||
import pro.taskana.rest.resource.TaskanaUserInfoResource;
|
||||
import pro.taskana.rest.resource.VersionResource;
|
||||
import pro.taskana.rest.resource.TaskanaUserInfoRepresentationModel;
|
||||
import pro.taskana.rest.resource.VersionRepresentationModel;
|
||||
|
||||
/** Controller for TaskanaEngine related tasks. */
|
||||
@RestController
|
||||
|
|
@ -24,9 +24,9 @@ public class TaskanaEngineController {
|
|||
|
||||
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}")
|
||||
private String version;
|
||||
|
|
@ -87,9 +87,9 @@ public class TaskanaEngineController {
|
|||
}
|
||||
|
||||
@GetMapping(path = Mapping.URL_CURRENT_USER)
|
||||
public ResponseEntity<TaskanaUserInfoResource> getCurrentUserInfo() {
|
||||
public ResponseEntity<TaskanaUserInfoRepresentationModel> getCurrentUserInfo() {
|
||||
LOGGER.debug("Entry to getCurrentUserInfo()");
|
||||
TaskanaUserInfoResource resource = new TaskanaUserInfoResource();
|
||||
TaskanaUserInfoRepresentationModel resource = new TaskanaUserInfoRepresentationModel();
|
||||
resource.setUserId(CurrentUserContext.getUserid());
|
||||
resource.setGroupIds(CurrentUserContext.getGroupIds());
|
||||
for (TaskanaRole role : taskanaEngineConfiguration.getRoleMap().keySet()) {
|
||||
|
|
@ -97,7 +97,7 @@ public class TaskanaEngineController {
|
|||
resource.getRoles().add(role);
|
||||
}
|
||||
}
|
||||
ResponseEntity<TaskanaUserInfoResource> response = ResponseEntity.ok(resource);
|
||||
ResponseEntity<TaskanaUserInfoRepresentationModel> response = ResponseEntity.ok(resource);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getCurrentUserInfo(), returning {}", response);
|
||||
}
|
||||
|
|
@ -118,11 +118,11 @@ public class TaskanaEngineController {
|
|||
* @return The current version.
|
||||
*/
|
||||
@GetMapping(path = Mapping.URL_VERSION)
|
||||
public ResponseEntity<VersionResource> currentVersion() {
|
||||
public ResponseEntity<VersionRepresentationModel> currentVersion() {
|
||||
LOGGER.debug("Entry to currentVersion()");
|
||||
VersionResource resource = new VersionResource();
|
||||
VersionRepresentationModel resource = new VersionRepresentationModel();
|
||||
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);
|
||||
return response;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.hateoas.PagedModel.PageMetadata;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
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.NotAuthorizedException;
|
||||
import pro.taskana.ldap.LdapClient;
|
||||
import pro.taskana.rest.resource.PagedResources.PageMetadata;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemListResource;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemResourceAssembler;
|
||||
import pro.taskana.rest.resource.TaskanaPagedModel;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemRepresentationModel;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemRepresentationModelAssembler;
|
||||
import pro.taskana.workbasket.api.WorkbasketAccessItemQuery;
|
||||
import pro.taskana.workbasket.api.WorkbasketService;
|
||||
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_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.
|
||||
*
|
||||
* @param params filter, order and access ids.
|
||||
* @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.
|
||||
*/
|
||||
@GetMapping(path = Mapping.URL_WORKBASKETACCESSITEMS)
|
||||
public ResponseEntity<WorkbasketAccessItemListResource> getWorkbasketAccessItems(
|
||||
public ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>>
|
||||
getWorkbasketAccessItems(
|
||||
@RequestParam MultiValueMap<String, String> params)
|
||||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
|
@ -66,18 +80,19 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
|
|||
}
|
||||
|
||||
WorkbasketAccessItemQuery query = workbasketService.createWorkbasketAccessItemQuery();
|
||||
query = getAccessIds(query, params);
|
||||
query = applyFilterParams(query, params);
|
||||
getAccessIds(query, params);
|
||||
applyFilterParams(query, params);
|
||||
query = applySortingParams(query, params);
|
||||
|
||||
PageMetadata pageMetadata = getPageMetadata(params, query);
|
||||
List<WorkbasketAccessItem> workbasketAccessItems = getQueryList(query, pageMetadata);
|
||||
|
||||
WorkbasketAccessItemListResource pagedResources =
|
||||
workbasketAccessItemResourceAssembler.toCollectionModel(
|
||||
TaskanaPagedModel<WorkbasketAccessItemRepresentationModel> pagedResources =
|
||||
workbasketAccessItemRepresentationModelAssembler.toPageModel(
|
||||
workbasketAccessItems, pageMetadata);
|
||||
|
||||
ResponseEntity<WorkbasketAccessItemListResource> response = ResponseEntity.ok(pagedResources);
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> response =
|
||||
ResponseEntity.ok(pagedResources);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", response);
|
||||
}
|
||||
|
|
@ -118,7 +133,7 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
|
|||
return response;
|
||||
}
|
||||
|
||||
private WorkbasketAccessItemQuery getAccessIds(
|
||||
private void getAccessIds(
|
||||
WorkbasketAccessItemQuery query, MultiValueMap<String, String> params) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Entry to getAccessIds(query= {}, params= {})", params);
|
||||
|
|
@ -134,10 +149,9 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
|
|||
LOGGER.debug("Exit from getAccessIds(), returning {}", query);
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
private WorkbasketAccessItemQuery applyFilterParams(
|
||||
private void applyFilterParams(
|
||||
WorkbasketAccessItemQuery query, MultiValueMap<String, String> params) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", params);
|
||||
|
|
@ -165,7 +179,6 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
|
|||
LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
private WorkbasketAccessItemQuery applySortingParams(
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.hateoas.CollectionModel;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.hateoas.PagedModel.PageMetadata;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
|
||||
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.InvalidArgumentException;
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.rest.resource.DistributionTargetListResource;
|
||||
import pro.taskana.rest.resource.DistributionTargetResource;
|
||||
import pro.taskana.rest.resource.DistributionTargetResourceAssembler;
|
||||
import pro.taskana.rest.resource.PagedResources.PageMetadata;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemListResource;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemResource;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemResourceAssembler;
|
||||
import pro.taskana.rest.resource.WorkbasketResource;
|
||||
import pro.taskana.rest.resource.WorkbasketResourceAssembler;
|
||||
import pro.taskana.rest.resource.WorkbasketSummaryListResource;
|
||||
import pro.taskana.rest.resource.WorkbasketSummaryResourceAssembler;
|
||||
import pro.taskana.rest.resource.DistributionTargetRepresentationModelAssembler;
|
||||
import pro.taskana.rest.resource.TaskanaPagedModel;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemRepresentationModel;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemRepresentationModelAssembler;
|
||||
import pro.taskana.rest.resource.WorkbasketRepresentationModel;
|
||||
import pro.taskana.rest.resource.WorkbasketRepresentationModelAssembler;
|
||||
import pro.taskana.rest.resource.WorkbasketSummaryRepresentationModel;
|
||||
import pro.taskana.rest.resource.WorkbasketSummaryRepresentationModelAssembler;
|
||||
import pro.taskana.workbasket.api.WorkbasketPermission;
|
||||
import pro.taskana.workbasket.api.WorkbasketQuery;
|
||||
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_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(
|
||||
WorkbasketService workbasketService,
|
||||
WorkbasketResourceAssembler workbasketResourceAssembler,
|
||||
WorkbasketSummaryResourceAssembler workbasketSummaryResourceAssembler,
|
||||
DistributionTargetResourceAssembler distributionTargetResourceAssembler,
|
||||
WorkbasketAccessItemResourceAssembler workbasketAccessItemResourceAssembler) {
|
||||
WorkbasketRepresentationModelAssembler workbasketRepresentationModelAssembler,
|
||||
WorkbasketSummaryRepresentationModelAssembler workbasketSummaryRepresentationModelAssembler,
|
||||
DistributionTargetRepresentationModelAssembler distributionTargetRepresentationModelAssembler,
|
||||
WorkbasketAccessItemRepresentationModelAssembler
|
||||
workbasketAccessItemRepresentationModelAssembler) {
|
||||
this.workbasketService = workbasketService;
|
||||
this.workbasketResourceAssembler = workbasketResourceAssembler;
|
||||
this.workbasketSummaryResourceAssembler = workbasketSummaryResourceAssembler;
|
||||
this.distributionTargetResourceAssembler = distributionTargetResourceAssembler;
|
||||
this.workbasketAccessItemResourceAssembler = workbasketAccessItemResourceAssembler;
|
||||
this.workbasketRepresentationModelAssembler = workbasketRepresentationModelAssembler;
|
||||
this.workbasketSummaryRepresentationModelAssembler =
|
||||
workbasketSummaryRepresentationModelAssembler;
|
||||
this.distributionTargetRepresentationModelAssembler =
|
||||
distributionTargetRepresentationModelAssembler;
|
||||
this.workbasketAccessItemRepresentationModelAssembler =
|
||||
workbasketAccessItemRepresentationModelAssembler;
|
||||
}
|
||||
|
||||
@GetMapping(path = Mapping.URL_WORKBASKET)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<WorkbasketSummaryListResource> getWorkbaskets(
|
||||
public ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> getWorkbaskets(
|
||||
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Entry to getWorkbaskets(params= {})", params);
|
||||
|
|
@ -107,14 +111,16 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
|
||||
WorkbasketQuery query = workbasketService.createWorkbasketQuery();
|
||||
query = applySortingParams(query, params);
|
||||
query = applyFilterParams(query, params);
|
||||
applyFilterParams(query, params);
|
||||
|
||||
PageMetadata pageMetadata = getPageMetadata(params, query);
|
||||
List<WorkbasketSummary> workbasketSummaries = getQueryList(query, pageMetadata);
|
||||
WorkbasketSummaryListResource pagedResources =
|
||||
workbasketSummaryResourceAssembler.toCollectionModel(workbasketSummaries, pageMetadata);
|
||||
TaskanaPagedModel<WorkbasketSummaryRepresentationModel> pagedModels =
|
||||
workbasketSummaryRepresentationModelAssembler.toPageModel(
|
||||
workbasketSummaries, pageMetadata);
|
||||
|
||||
ResponseEntity<WorkbasketSummaryListResource> response = ResponseEntity.ok(pagedResources);
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
|
||||
ResponseEntity.ok(pagedModels);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
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)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<WorkbasketResource> getWorkbasket(
|
||||
public ResponseEntity<WorkbasketRepresentationModel> getWorkbasket(
|
||||
@PathVariable(value = "workbasketId") String workbasketId)
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
LOGGER.debug("Entry to getWorkbasket(workbasketId= {})", workbasketId);
|
||||
ResponseEntity<WorkbasketResource> result;
|
||||
ResponseEntity<WorkbasketRepresentationModel> result;
|
||||
Workbasket workbasket = workbasketService.getWorkbasket(workbasketId);
|
||||
result = ResponseEntity.ok(workbasketResourceAssembler.toModel(workbasket));
|
||||
result = ResponseEntity.ok(workbasketRepresentationModelAssembler.toModel(workbasket));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getWorkbasket(), returning {}", result);
|
||||
}
|
||||
|
|
@ -164,19 +170,21 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
|
||||
@PostMapping(path = Mapping.URL_WORKBASKET)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<WorkbasketResource> createWorkbasket(
|
||||
@RequestBody WorkbasketResource workbasketResource)
|
||||
public ResponseEntity<WorkbasketRepresentationModel> createWorkbasket(
|
||||
@RequestBody WorkbasketRepresentationModel workbasketRepresentationModel)
|
||||
throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException,
|
||||
DomainNotFoundException {
|
||||
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);
|
||||
ResponseEntity<WorkbasketResource> response =
|
||||
ResponseEntity<WorkbasketRepresentationModel> response =
|
||||
ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(workbasketResourceAssembler.toModel(workbasket));
|
||||
.body(workbasketRepresentationModelAssembler.toModel(workbasket));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from createWorkbasket(), returning {}", response);
|
||||
}
|
||||
|
|
@ -186,23 +194,24 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
|
||||
@PutMapping(path = Mapping.URL_WORKBASKET_ID)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<WorkbasketResource> updateWorkbasket(
|
||||
public ResponseEntity<WorkbasketRepresentationModel> updateWorkbasket(
|
||||
@PathVariable(value = "workbasketId") String workbasketId,
|
||||
@RequestBody WorkbasketResource workbasketResource)
|
||||
@RequestBody WorkbasketRepresentationModel workbasketRepresentationModel)
|
||||
throws InvalidWorkbasketException, WorkbasketNotFoundException, NotAuthorizedException,
|
||||
ConcurrencyException {
|
||||
LOGGER.debug("Entry to updateWorkbasket(workbasketId= {})", workbasketId);
|
||||
ResponseEntity<WorkbasketResource> result;
|
||||
if (workbasketId.equals(workbasketResource.getWorkbasketId())) {
|
||||
Workbasket workbasket = workbasketResourceAssembler.toModel(workbasketResource);
|
||||
ResponseEntity<WorkbasketRepresentationModel> result;
|
||||
if (workbasketId.equals(workbasketRepresentationModel.getWorkbasketId())) {
|
||||
Workbasket workbasket =
|
||||
workbasketRepresentationModelAssembler.toEntityModel(workbasketRepresentationModel);
|
||||
workbasket = workbasketService.updateWorkbasket(workbasket);
|
||||
result = ResponseEntity.ok(workbasketResourceAssembler.toModel(workbasket));
|
||||
result = ResponseEntity.ok(workbasketRepresentationModelAssembler.toModel(workbasket));
|
||||
} else {
|
||||
throw new InvalidWorkbasketException(
|
||||
"Target-WB-ID('"
|
||||
+ workbasketId
|
||||
+ "') 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)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<WorkbasketAccessItemListResource> getWorkbasketAccessItems(
|
||||
@PathVariable(value = "workbasketId") String workbasketId)
|
||||
public ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>>
|
||||
getWorkbasketAccessItems(@PathVariable(value = "workbasketId") String workbasketId)
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
LOGGER.debug("Entry to getWorkbasketAccessItems(workbasketId= {})", workbasketId);
|
||||
ResponseEntity<WorkbasketAccessItemListResource> result;
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> result;
|
||||
|
||||
List<WorkbasketAccessItem> accessItems =
|
||||
workbasketService.getWorkbasketAccessItems(workbasketId);
|
||||
result =
|
||||
ResponseEntity.ok(
|
||||
workbasketAccessItemResourceAssembler.toCollectionModel(workbasketId, accessItems));
|
||||
workbasketAccessItemRepresentationModelAssembler.toPageModel(
|
||||
workbasketId, accessItems, null));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", result);
|
||||
}
|
||||
|
|
@ -235,11 +245,12 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
|
||||
@PutMapping(path = Mapping.URL_WORKBASKET_ID_ACCESSITEMS)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<WorkbasketAccessItemListResource> setWorkbasketAccessItems(
|
||||
public ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>>
|
||||
setWorkbasketAccessItems(
|
||||
@PathVariable(value = "workbasketId") String workbasketId,
|
||||
@RequestBody List<WorkbasketAccessItemResource> workbasketAccessResourceItems)
|
||||
@RequestBody List<WorkbasketAccessItemRepresentationModel> workbasketAccessResourceItems)
|
||||
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
|
||||
WorkbasketAccessItemAlreadyExistException {
|
||||
WorkbasketAccessItemAlreadyExistException {
|
||||
LOGGER.debug("Entry to setWorkbasketAccessItems(workbasketId= {})", workbasketId);
|
||||
if (workbasketAccessResourceItems == null) {
|
||||
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<>();
|
||||
workbasketAccessResourceItems.forEach(
|
||||
item -> wbAccessItems.add(workbasketAccessItemResourceAssembler.toModel(item)));
|
||||
item -> wbAccessItems
|
||||
.add(workbasketAccessItemRepresentationModelAssembler.toEntityModel(item)));
|
||||
workbasketService.setWorkbasketAccessItems(workbasketId, wbAccessItems);
|
||||
List<WorkbasketAccessItem> updatedWbAccessItems =
|
||||
workbasketService.getWorkbasketAccessItems(workbasketId);
|
||||
|
||||
ResponseEntity<WorkbasketAccessItemListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> response =
|
||||
ResponseEntity.ok(
|
||||
workbasketAccessItemResourceAssembler.toCollectionModel(
|
||||
workbasketId, updatedWbAccessItems));
|
||||
workbasketAccessItemRepresentationModelAssembler.toPageModel(
|
||||
workbasketId, updatedWbAccessItems, null));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
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)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<DistributionTargetListResource> getDistributionTargets(
|
||||
@PathVariable(value = "workbasketId") String workbasketId)
|
||||
public ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>>
|
||||
getDistributionTargets(@PathVariable(value = "workbasketId") String workbasketId)
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
|
||||
LOGGER.debug("Entry to getDistributionTargets(workbasketId= {})", workbasketId);
|
||||
List<WorkbasketSummary> distributionTargets =
|
||||
workbasketService.getDistributionTargets(workbasketId);
|
||||
DistributionTargetListResource distributionTargetListResource =
|
||||
distributionTargetResourceAssembler.toCollectionModel(workbasketId, distributionTargets);
|
||||
ResponseEntity<DistributionTargetListResource> result =
|
||||
TaskanaPagedModel<WorkbasketSummaryRepresentationModel> distributionTargetListResource =
|
||||
distributionTargetRepresentationModelAssembler.toPageModel(distributionTargets, null);
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> result =
|
||||
ResponseEntity.ok(distributionTargetListResource);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getDistributionTargets(), returning {}", result);
|
||||
|
|
@ -285,7 +297,8 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
|
||||
@PutMapping(path = Mapping.URL_WORKBASKET_ID_DISTRIBUTION)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<DistributionTargetListResource> setDistributionTargetsForWorkbasketId(
|
||||
public ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>>
|
||||
setDistributionTargetsForWorkbasketId(
|
||||
@PathVariable(value = "workbasketId") String sourceWorkbasketId,
|
||||
@RequestBody List<String> targetWorkbasketIds)
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
|
|
@ -300,10 +313,9 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
|
||||
List<WorkbasketSummary> distributionTargets =
|
||||
workbasketService.getDistributionTargets(sourceWorkbasketId);
|
||||
ResponseEntity<DistributionTargetListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
|
||||
ResponseEntity.ok(
|
||||
distributionTargetResourceAssembler.toCollectionModel(
|
||||
sourceWorkbasketId, distributionTargets));
|
||||
distributionTargetRepresentationModelAssembler.toPageModel(distributionTargets, null));
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response);
|
||||
}
|
||||
|
|
@ -313,10 +325,10 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
|
||||
@DeleteMapping(path = Mapping.URL_WORKBASKET_ID_DISTRIBUTION)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<CollectionModel<DistributionTargetResource>>
|
||||
public ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>>
|
||||
removeDistributionTargetForWorkbasketId(
|
||||
@PathVariable(value = "workbasketId") String targetWorkbasketId)
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
@PathVariable(value = "workbasketId") String targetWorkbasketId)
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
LOGGER.debug(
|
||||
"Entry to removeDistributionTargetForWorkbasketId(workbasketId= {})", targetWorkbasketId);
|
||||
|
||||
|
|
@ -326,7 +338,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
workbasketService.removeDistributionTarget(source.getId(), targetWorkbasketId);
|
||||
}
|
||||
|
||||
ResponseEntity<CollectionModel<DistributionTargetResource>> response =
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
|
||||
ResponseEntity.noContent().build();
|
||||
LOGGER.debug("Exit from removeDistributionTargetForWorkbasketId(), returning {}", response);
|
||||
return response;
|
||||
|
|
@ -377,7 +389,7 @@ public class WorkbasketController extends AbstractPagingController {
|
|||
return query;
|
||||
}
|
||||
|
||||
private WorkbasketQuery applyFilterParams(
|
||||
private void applyFilterParams(
|
||||
WorkbasketQuery query, MultiValueMap<String, String> params) throws InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
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);
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ import pro.taskana.common.api.exceptions.ConcurrencyException;
|
|||
import pro.taskana.common.api.exceptions.DomainNotFoundException;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.rest.resource.WorkbasketDefinitionResource;
|
||||
import pro.taskana.rest.resource.WorkbasketDefinitionResourceAssembler;
|
||||
import pro.taskana.rest.resource.WorkbasketResource;
|
||||
import pro.taskana.rest.resource.WorkbasketDefinitionRepresentationModel;
|
||||
import pro.taskana.rest.resource.WorkbasketDefinitionRepresentationModelAssembler;
|
||||
import pro.taskana.rest.resource.WorkbasketRepresentationModel;
|
||||
import pro.taskana.workbasket.api.WorkbasketQuery;
|
||||
import pro.taskana.workbasket.api.WorkbasketService;
|
||||
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.WorkbasketImpl;
|
||||
|
||||
/** Controller for all {@link WorkbasketDefinitionResource} related endpoints. */
|
||||
/** Controller for all {@link WorkbasketDefinitionRepresentationModel} related endpoints. */
|
||||
@RestController
|
||||
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
|
||||
public class WorkbasketDefinitionController {
|
||||
|
|
@ -53,31 +53,32 @@ public class WorkbasketDefinitionController {
|
|||
|
||||
private WorkbasketService workbasketService;
|
||||
|
||||
private WorkbasketDefinitionResourceAssembler workbasketDefinitionAssembler;
|
||||
private WorkbasketDefinitionRepresentationModelAssembler workbasketDefinitionAssembler;
|
||||
|
||||
WorkbasketDefinitionController(
|
||||
WorkbasketService workbasketService,
|
||||
WorkbasketDefinitionResourceAssembler workbasketDefinitionAssembler) {
|
||||
WorkbasketDefinitionRepresentationModelAssembler workbasketDefinitionAssembler) {
|
||||
this.workbasketService = workbasketService;
|
||||
this.workbasketDefinitionAssembler = workbasketDefinitionAssembler;
|
||||
}
|
||||
|
||||
@GetMapping(path = Mapping.URL_WORKBASKETDEFIITIONS)
|
||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||
public ResponseEntity<List<WorkbasketDefinitionResource>> exportWorkbaskets(
|
||||
public ResponseEntity<List<WorkbasketDefinitionRepresentationModel>> exportWorkbaskets(
|
||||
@RequestParam(required = false) String domain)
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
LOGGER.debug("Entry to exportWorkbaskets(domain= {})", domain);
|
||||
WorkbasketQuery workbasketQuery = workbasketService.createWorkbasketQuery();
|
||||
List<WorkbasketSummary> workbasketSummaryList =
|
||||
domain != null ? workbasketQuery.domainIn(domain).list() : workbasketQuery.list();
|
||||
List<WorkbasketDefinitionResource> basketExports = new ArrayList<>();
|
||||
List<WorkbasketDefinitionRepresentationModel> basketExports = new ArrayList<>();
|
||||
for (WorkbasketSummary summary : workbasketSummaryList) {
|
||||
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()) {
|
||||
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
|
||||
* exactly match the REST norm, but we want to have an option to import all settings at once. When
|
||||
* a logical equal (key and domain are equal) workbasket already exists an update will be
|
||||
* This method imports a <b>list of {@link WorkbasketDefinitionRepresentationModel}</b>. This does
|
||||
* not exactly match the REST norm, but we want to have an option to import all settings at once.
|
||||
* When a logical equal (key and domain are equal) workbasket already exists an update will be
|
||||
* executed. Otherwise a new workbasket will be created.
|
||||
*
|
||||
* @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();
|
||||
mapper.enable(SerializationFeature.INDENT_OUTPUT);
|
||||
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
List<WorkbasketDefinitionResource> definitions =
|
||||
List<WorkbasketDefinitionRepresentationModel> definitions =
|
||||
mapper.readValue(
|
||||
file.getInputStream(), new TypeReference<List<WorkbasketDefinitionResource>>() {});
|
||||
file.getInputStream(),
|
||||
new TypeReference<List<WorkbasketDefinitionRepresentationModel>>() {});
|
||||
|
||||
// key: logical ID
|
||||
// value: system ID (in database)
|
||||
|
|
@ -135,8 +137,9 @@ public class WorkbasketDefinitionController {
|
|||
Map<String, String> idConversion = new HashMap<>();
|
||||
|
||||
// STEP 1: update or create workbaskets from the import
|
||||
for (WorkbasketDefinitionResource definition : definitions) {
|
||||
Workbasket importedWb = workbasketDefinitionAssembler.toModel(definition.getWorkbasket());
|
||||
for (WorkbasketDefinitionRepresentationModel definition : definitions) {
|
||||
Workbasket importedWb = workbasketDefinitionAssembler
|
||||
.toEntityModel(definition.getWorkbasket());
|
||||
String newId;
|
||||
WorkbasketImpl wbWithoutId = (WorkbasketImpl) removeId(importedWb);
|
||||
if (systemIds.containsKey(logicalId(importedWb))) {
|
||||
|
|
@ -179,7 +182,7 @@ public class WorkbasketDefinitionController {
|
|||
|
||||
// STEP 2: update distribution targets
|
||||
// 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<>();
|
||||
for (String oldId : definition.getDistributionTargets()) {
|
||||
if (idConversion.containsKey(oldId)) {
|
||||
|
|
@ -204,17 +207,17 @@ public class WorkbasketDefinitionController {
|
|||
}
|
||||
|
||||
private Workbasket removeId(Workbasket importedWb) {
|
||||
WorkbasketResource wbRes = new WorkbasketResource(importedWb);
|
||||
WorkbasketRepresentationModel wbRes = new WorkbasketRepresentationModel(importedWb);
|
||||
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<>();
|
||||
Set<String> duplicates = new HashSet<>();
|
||||
for (WorkbasketDefinitionResource definition : definitions) {
|
||||
for (WorkbasketDefinitionRepresentationModel definition : definitions) {
|
||||
String identifier =
|
||||
logicalId(workbasketDefinitionAssembler.toModel(definition.getWorkbasket()));
|
||||
logicalId(workbasketDefinitionAssembler.toEntityModel(definition.getWorkbasket()));
|
||||
if (identifiers.contains(identifier)) {
|
||||
duplicates.add(identifier);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package pro.taskana.rest.resource;
|
|||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedModel.PageMetadata;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
|
||||
|
|
@ -41,7 +42,7 @@ public abstract class AbstractRessourcesAssembler {
|
|||
}
|
||||
|
||||
protected PagedResources<?> addPageLinks(
|
||||
PagedResources<?> pagedResources, PagedResources.PageMetadata pageMetadata) {
|
||||
PagedResources<?> pagedResources, PageMetadata pageMetadata) {
|
||||
UriComponentsBuilder original = getBuilderForOriginalUri();
|
||||
pagedResources.add(
|
||||
(new Link(original.replaceQueryParam("page", 1).toUriString())).withRel("first"));
|
||||
|
|
@ -51,7 +52,7 @@ public abstract class AbstractRessourcesAssembler {
|
|||
if (pageMetadata.getNumber() > 1L) {
|
||||
pagedResources.add(
|
||||
(new Link(
|
||||
original.replaceQueryParam("page", pageMetadata.getNumber() - 1L).toUriString()))
|
||||
original.replaceQueryParam("page", pageMetadata.getNumber() - 1L).toUriString()))
|
||||
.withRel("prev"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ package pro.taskana.rest.resource;
|
|||
*
|
||||
* @author bbr
|
||||
*/
|
||||
public class AccessIdResource {
|
||||
public class AccessIdRepresentationModel {
|
||||
|
||||
private String name;
|
||||
private String accessId;
|
||||
|
||||
public AccessIdResource() {}
|
||||
public AccessIdRepresentationModel() {}
|
||||
|
||||
public AccessIdResource(String name, String accessId) {
|
||||
public AccessIdRepresentationModel(String name, String accessId) {
|
||||
this.accessId = accessId;
|
||||
this.name = name;
|
||||
}
|
||||
|
|
@ -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
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
@ -5,29 +5,33 @@ import org.springframework.hateoas.RepresentationModel;
|
|||
import pro.taskana.task.api.models.AttachmentSummary;
|
||||
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;
|
||||
private String taskId;
|
||||
private String created;
|
||||
private String modified;
|
||||
private ClassificationSummaryResource classificationSummaryResource;
|
||||
private ObjectReference objectReference;
|
||||
private String channel;
|
||||
private String received;
|
||||
protected String attachmentId;
|
||||
protected String taskId;
|
||||
protected String created;
|
||||
protected String modified;
|
||||
protected ClassificationSummaryRepresentationModel classificationSummary;
|
||||
protected ObjectReference objectReference;
|
||||
protected String channel;
|
||||
protected String received;
|
||||
|
||||
AttachmentSummaryResource() {}
|
||||
AttachmentSummaryRepresentationModel() {
|
||||
}
|
||||
|
||||
public AttachmentSummaryResource(AttachmentSummary attachmentSummary) {
|
||||
public AttachmentSummaryRepresentationModel(AttachmentSummary attachmentSummary) {
|
||||
this.attachmentId = attachmentSummary.getId();
|
||||
this.taskId = attachmentSummary.getTaskId();
|
||||
this.created =
|
||||
attachmentSummary.getCreated() != null ? attachmentSummary.getCreated().toString() : null;
|
||||
this.modified =
|
||||
attachmentSummary.getModified() != null ? attachmentSummary.getModified().toString() : null;
|
||||
this.classificationSummaryResource =
|
||||
new ClassificationSummaryResource(attachmentSummary.getClassificationSummary());
|
||||
this.classificationSummary =
|
||||
new ClassificationSummaryRepresentationModel(attachmentSummary.getClassificationSummary());
|
||||
this.objectReference = attachmentSummary.getObjectReference();
|
||||
this.channel = attachmentSummary.getChannel();
|
||||
this.received =
|
||||
|
|
@ -66,13 +70,13 @@ public class AttachmentSummaryResource extends RepresentationModel<AttachmentSum
|
|||
this.modified = modified;
|
||||
}
|
||||
|
||||
public ClassificationSummaryResource getClassificationSummary() {
|
||||
return classificationSummaryResource;
|
||||
public ClassificationSummaryRepresentationModel getClassificationSummary() {
|
||||
return classificationSummary;
|
||||
}
|
||||
|
||||
public void setClassificationSummary(
|
||||
ClassificationSummaryResource classificationSummaryResource) {
|
||||
this.classificationSummaryResource = classificationSummaryResource;
|
||||
ClassificationSummaryRepresentationModel classificationSummary) {
|
||||
this.classificationSummary = classificationSummary;
|
||||
}
|
||||
|
||||
public ObjectReference getObjectReference() {
|
||||
|
|
@ -102,22 +106,22 @@ public class AttachmentSummaryResource extends RepresentationModel<AttachmentSum
|
|||
@Override
|
||||
public String toString() {
|
||||
return "AttachmentSummaryResource ["
|
||||
+ "attachmentId= "
|
||||
+ this.attachmentId
|
||||
+ "taskId= "
|
||||
+ this.taskId
|
||||
+ "created= "
|
||||
+ this.created
|
||||
+ "modified= "
|
||||
+ this.modified
|
||||
+ "classificationSummaryResource= "
|
||||
+ this.classificationSummaryResource
|
||||
+ "objectReference= "
|
||||
+ this.objectReference
|
||||
+ "channel= "
|
||||
+ this.channel
|
||||
+ "received= "
|
||||
+ this.received
|
||||
+ "]";
|
||||
+ "attachmentId= "
|
||||
+ this.attachmentId
|
||||
+ "taskId= "
|
||||
+ this.taskId
|
||||
+ "created= "
|
||||
+ this.created
|
||||
+ "modified= "
|
||||
+ this.modified
|
||||
+ "classificationSummaryResource= "
|
||||
+ this.classificationSummary
|
||||
+ "objectReference= "
|
||||
+ this.objectReference
|
||||
+ "channel= "
|
||||
+ this.channel
|
||||
+ "received= "
|
||||
+ this.received
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -4,33 +4,36 @@ import org.springframework.hateoas.RepresentationModel;
|
|||
|
||||
import pro.taskana.classification.api.models.ClassificationSummary;
|
||||
|
||||
/** EntityModel class for {@link ClassificationSummary}. */
|
||||
public class ClassificationSummaryResource
|
||||
extends RepresentationModel<ClassificationSummaryResource> {
|
||||
/**
|
||||
* EntityModel class for {@link ClassificationSummary}.
|
||||
*/
|
||||
public class ClassificationSummaryRepresentationModel
|
||||
extends RepresentationModel<ClassificationSummaryRepresentationModel> {
|
||||
|
||||
private String classificationId;
|
||||
private String applicationEntryPoint;
|
||||
private String category;
|
||||
private String domain;
|
||||
private String key;
|
||||
private String name;
|
||||
private String parentId;
|
||||
private String parentKey;
|
||||
private int priority;
|
||||
private String serviceLevel;
|
||||
private String type;
|
||||
private String custom1;
|
||||
private String custom2;
|
||||
private String custom3;
|
||||
private String custom4;
|
||||
private String custom5;
|
||||
private String custom6;
|
||||
private String custom7;
|
||||
private String custom8;
|
||||
protected String classificationId;
|
||||
protected String key;
|
||||
protected String applicationEntryPoint;
|
||||
protected String category;
|
||||
protected String domain;
|
||||
protected String name;
|
||||
protected String parentId;
|
||||
protected String parentKey;
|
||||
protected int priority;
|
||||
protected String serviceLevel;
|
||||
protected String type;
|
||||
protected String custom1;
|
||||
protected String custom2;
|
||||
protected String custom3;
|
||||
protected String custom4;
|
||||
protected String custom5;
|
||||
protected String custom6;
|
||||
protected String custom7;
|
||||
protected String custom8;
|
||||
|
||||
public ClassificationSummaryResource() {}
|
||||
public ClassificationSummaryRepresentationModel() {
|
||||
}
|
||||
|
||||
public ClassificationSummaryResource(ClassificationSummary classification) {
|
||||
public ClassificationSummaryRepresentationModel(ClassificationSummary classification) {
|
||||
classificationId = classification.getId();
|
||||
applicationEntryPoint = classification.getApplicationEntryPoint();
|
||||
category = classification.getCategory();
|
||||
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,10 +6,9 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedModel.PageMetadata;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Base Class for CollectionModel with pagination.
|
||||
|
|
@ -78,135 +77,4 @@ public class PagedResources<T> extends RepresentationModel<PagedResources<T>> {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import pro.taskana.monitor.api.reports.Report;
|
|||
import pro.taskana.monitor.api.reports.row.SingleRow;
|
||||
|
||||
/** EntityModel class for {@link Report}. */
|
||||
public class ReportResource extends RepresentationModel<ReportResource> {
|
||||
public class ReportRepresentationModel extends RepresentationModel<ReportRepresentationModel> {
|
||||
|
||||
private MetaInformation meta;
|
||||
|
||||
|
|
@ -16,7 +16,8 @@ public class ReportResource extends RepresentationModel<ReportResource> {
|
|||
|
||||
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.rows = rows;
|
||||
this.sumRow = sumRow;
|
||||
|
|
@ -10,6 +10,7 @@ import java.util.Comparator;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
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.task.api.TaskState;
|
||||
|
||||
/** Transforms any {@link Report} into its {@link ReportResource}. */
|
||||
/** Transforms any {@link Report} into its {@link ReportRepresentationModel}. */
|
||||
@Component
|
||||
public class ReportResourceAssembler {
|
||||
public class ReportRepresentationModelAssembler {
|
||||
|
||||
public ReportResource toModel(
|
||||
TaskStatusReport report, List<String> domains, List<TaskState> states)
|
||||
@NonNull
|
||||
public ReportRepresentationModel toModel(
|
||||
@NonNull TaskStatusReport report, @NonNull List<String> domains,
|
||||
@NonNull List<TaskState> states)
|
||||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
ReportResource resource = toReportResource(report);
|
||||
ReportRepresentationModel resource = toReportResource(report);
|
||||
resource.add(
|
||||
linkTo(methodOn(MonitorController.class).getTasksStatusReport(domains, states))
|
||||
.withSelfRel()
|
||||
|
|
@ -42,9 +45,10 @@ public class ReportResourceAssembler {
|
|||
return resource;
|
||||
}
|
||||
|
||||
public ReportResource toModel(ClassificationReport report)
|
||||
@NonNull
|
||||
public ReportRepresentationModel toModel(@NonNull ClassificationReport report)
|
||||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
ReportResource resource = toReportResource(report);
|
||||
ReportRepresentationModel resource = toReportResource(report);
|
||||
resource.add(
|
||||
linkTo(methodOn(MonitorController.class).getTasksClassificationReport())
|
||||
.withSelfRel()
|
||||
|
|
@ -52,9 +56,11 @@ public class ReportResourceAssembler {
|
|||
return resource;
|
||||
}
|
||||
|
||||
public ReportResource toModel(WorkbasketReport report, List<TaskState> states)
|
||||
@NonNull
|
||||
public ReportRepresentationModel toModel(@NonNull WorkbasketReport report,
|
||||
@NonNull List<TaskState> states)
|
||||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
ReportResource resource = toReportResource(report);
|
||||
ReportRepresentationModel resource = toReportResource(report);
|
||||
resource.add(
|
||||
linkTo(methodOn(MonitorController.class).getTasksWorkbasketReport(states))
|
||||
.withSelfRel()
|
||||
|
|
@ -62,41 +68,44 @@ public class ReportResourceAssembler {
|
|||
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 {
|
||||
ReportResource resource = toReportResource(report);
|
||||
ReportRepresentationModel resource = toReportResource(report);
|
||||
resource.add(
|
||||
linkTo(
|
||||
methodOn(MonitorController.class)
|
||||
.getTasksWorkbasketPlannedDateReport(daysInPast, states))
|
||||
methodOn(MonitorController.class)
|
||||
.getTasksWorkbasketPlannedDateReport(daysInPast, states))
|
||||
.withSelfRel()
|
||||
.expand());
|
||||
return resource;
|
||||
}
|
||||
|
||||
public ReportResource toModel(TimestampReport report)
|
||||
@NonNull
|
||||
public ReportRepresentationModel toModel(@NonNull TimestampReport report)
|
||||
throws NotAuthorizedException, InvalidArgumentException {
|
||||
ReportResource resource = toReportResource(report);
|
||||
ReportRepresentationModel resource = toReportResource(report);
|
||||
resource.add(
|
||||
linkTo(methodOn(MonitorController.class).getDailyEntryExitReport()).withSelfRel().expand());
|
||||
return resource;
|
||||
}
|
||||
|
||||
<I extends QueryItem, H extends ColumnHeader<? super I>> ReportResource toReportResource(
|
||||
Report<I, H> report) {
|
||||
<I extends QueryItem, H extends ColumnHeader<? super I>>
|
||||
ReportRepresentationModel toReportResource(Report<I, H> report) {
|
||||
return toReportResource(report, Instant.now());
|
||||
}
|
||||
|
||||
<I extends QueryItem, H extends ColumnHeader<? super I>> ReportResource toReportResource(
|
||||
Report<I, H> report, Instant time) {
|
||||
<I extends QueryItem, H extends ColumnHeader<? super I>>
|
||||
ReportRepresentationModel toReportResource(Report<I, H> report, Instant time) {
|
||||
String[] header =
|
||||
report.getColumnHeaders().stream().map(H::getDisplayName).toArray(String[]::new);
|
||||
ReportResource.MetaInformation meta =
|
||||
new ReportResource.MetaInformation(
|
||||
ReportRepresentationModel.MetaInformation meta =
|
||||
new ReportRepresentationModel.MetaInformation(
|
||||
report.getClass().getSimpleName(), time.toString(), header, report.getRowDesc());
|
||||
|
||||
// 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()
|
||||
.sorted(Comparator.comparing(e -> e.getKey().toLowerCase()))
|
||||
.map(
|
||||
|
|
@ -106,14 +115,14 @@ public class ReportResourceAssembler {
|
|||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<ReportResource.RowResource> sumRow =
|
||||
List<ReportRepresentationModel.RowResource> sumRow =
|
||||
transformRow(
|
||||
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) {
|
||||
// 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
|
||||
|
|
@ -126,20 +135,20 @@ public class ReportResourceAssembler {
|
|||
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) {
|
||||
String[] rowDesc = new String[previousRowDesc.length];
|
||||
System.arraycopy(previousRowDesc, 0, rowDesc, 0, depth);
|
||||
rowDesc[depth] = currentDesc;
|
||||
return new ReportResource.RowResource(
|
||||
return new ReportRepresentationModel.RowResource(
|
||||
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) {
|
||||
ReportResource.RowResource baseRow =
|
||||
ReportRepresentationModel.RowResource baseRow =
|
||||
transformSingleRow(row, currentDesc, previousRowDesc, depth);
|
||||
List<ReportResource.RowResource> rowList = new LinkedList<>();
|
||||
List<ReportRepresentationModel.RowResource> rowList = new LinkedList<>();
|
||||
rowList.add(baseRow);
|
||||
row.getFoldableRowKeySet().stream()
|
||||
.sorted(String.CASE_INSENSITIVE_ORDER)
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,8 @@ import org.springframework.hateoas.RepresentationModel;
|
|||
import pro.taskana.task.api.models.TaskComment;
|
||||
|
||||
/** EntityModel class for {@link TaskComment}. */
|
||||
public class TaskCommentResource extends RepresentationModel<TaskCommentResource> {
|
||||
public class TaskCommentRepresentationModel
|
||||
extends RepresentationModel<TaskCommentRepresentationModel> {
|
||||
|
||||
private String taskCommentId;
|
||||
private String taskId;
|
||||
|
|
@ -14,9 +15,9 @@ public class TaskCommentResource extends RepresentationModel<TaskCommentResource
|
|||
private String created;
|
||||
private String modified;
|
||||
|
||||
public TaskCommentResource() {}
|
||||
public TaskCommentRepresentationModel() {}
|
||||
|
||||
public TaskCommentResource(TaskComment taskComment) {
|
||||
public TaskCommentRepresentationModel(TaskComment taskComment) {
|
||||
this.taskCommentId = taskComment.getId();
|
||||
this.taskId = taskComment.getTaskId();
|
||||
this.textField = taskComment.getTextField();
|
||||
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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 + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,47 +9,55 @@ 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.lang.NonNull;
|
||||
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.TaskController;
|
||||
import pro.taskana.rest.resource.TaskRepresentationModel.CustomAttribute;
|
||||
import pro.taskana.task.api.TaskService;
|
||||
import pro.taskana.task.api.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
import pro.taskana.task.internal.models.TaskImpl;
|
||||
|
||||
/** EntityModel assembler for {@link TaskResource}. */
|
||||
/**
|
||||
* EntityModel assembler for {@link TaskRepresentationModel}.
|
||||
*/
|
||||
@Component
|
||||
public class TaskResourceAssembler extends RepresentationModelAssemblerSupport<Task, TaskResource> {
|
||||
public class TaskRepresentationModelAssembler
|
||||
extends RepresentationModelAssemblerSupport<Task, TaskRepresentationModel> {
|
||||
|
||||
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
|
||||
public TaskResourceAssembler(
|
||||
public TaskRepresentationModelAssembler(
|
||||
TaskService taskService,
|
||||
ClassificationSummaryResourceAssembler classificationAssembler,
|
||||
WorkbasketSummaryResourceAssembler workbasketAssembler,
|
||||
AttachmentResourceAssembler attachmentAssembler) {
|
||||
super(TaskController.class, TaskResource.class);
|
||||
ClassificationSummaryRepresentationModelAssembler classificationAssembler,
|
||||
WorkbasketSummaryRepresentationModelAssembler workbasketSummaryRepresentationModelAssembler,
|
||||
AttachmentRepresentationModelAssembler attachmentAssembler) {
|
||||
super(TaskController.class, TaskRepresentationModel.class);
|
||||
this.taskService = taskService;
|
||||
this.classificationAssembler = classificationAssembler;
|
||||
this.workbasketAssembler = workbasketAssembler;
|
||||
this.workbasketSummaryRepresentationModelAssembler
|
||||
= workbasketSummaryRepresentationModelAssembler;
|
||||
this.attachmentAssembler = attachmentAssembler;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public TaskResource toModel(Task task) {
|
||||
TaskResource resource;
|
||||
public TaskRepresentationModel toModel(@NonNull Task task) {
|
||||
TaskRepresentationModel resource;
|
||||
try {
|
||||
resource = new TaskResource(task);
|
||||
resource = new TaskRepresentationModel(task);
|
||||
resource.add(linkTo(methodOn(TaskController.class).getTask(task.getId())).withSelfRel());
|
||||
} catch (InvalidArgumentException | TaskNotFoundException | NotAuthorizedException e) {
|
||||
throw new SystemException("caught unexpected Exception.", e.getCause());
|
||||
|
|
@ -57,10 +65,12 @@ public class TaskResourceAssembler extends RepresentationModelAssemblerSupport<T
|
|||
return resource;
|
||||
}
|
||||
|
||||
public Task toModel(TaskResource resource) throws InvalidArgumentException {
|
||||
public Task toEntityModel(TaskRepresentationModel resource) throws InvalidArgumentException {
|
||||
validateTaskResource(resource);
|
||||
TaskImpl task =
|
||||
(TaskImpl) taskService.newTask(resource.getWorkbasketSummaryResource().getWorkbasketId());
|
||||
(TaskImpl)
|
||||
taskService.newTask(
|
||||
resource.getWorkbasketSummary().getWorkbasketId());
|
||||
task.setId(resource.getTaskId());
|
||||
task.setExternalId(resource.getExternalId());
|
||||
BeanUtils.copyProperties(resource, task);
|
||||
|
|
@ -83,35 +93,35 @@ public class TaskResourceAssembler extends RepresentationModelAssemblerSupport<T
|
|||
task.setPlanned(Instant.parse(resource.getPlanned()));
|
||||
}
|
||||
task.setClassificationSummary(
|
||||
classificationAssembler.toModel(resource.getClassificationSummaryResource()));
|
||||
task.setWorkbasketSummary(workbasketAssembler.toModel(resource.getWorkbasketSummaryResource()));
|
||||
task.setAttachments(attachmentAssembler.toModel(resource.getAttachments()));
|
||||
classificationAssembler.toEntityModel(
|
||||
resource.getClassificationSummary()));
|
||||
task.setWorkbasketSummary(
|
||||
workbasketSummaryRepresentationModelAssembler
|
||||
.toEntityModel(resource.getWorkbasketSummary()));
|
||||
task.setAttachments(attachmentAssembler.toAttachmentList(resource.getAttachments()));
|
||||
task.setCustomAttributes(
|
||||
resource.getCustomAttributes().stream()
|
||||
.filter(e -> Objects.nonNull(e.getKey()) && !e.getKey().isEmpty())
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
TaskResource.CustomAttribute::getKey, TaskResource.CustomAttribute::getValue)));
|
||||
.collect(Collectors.toMap(CustomAttribute::getKey, CustomAttribute::getValue)));
|
||||
task.setCallbackInfo(
|
||||
resource.getCallbackInfo().stream()
|
||||
.filter(e -> Objects.nonNull(e.getKey()) && !e.getKey().isEmpty())
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
TaskResource.CustomAttribute::getKey, TaskResource.CustomAttribute::getValue)));
|
||||
.collect(Collectors.toMap(CustomAttribute::getKey, CustomAttribute::getValue)));
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
private void validateTaskResource(TaskResource resource) throws InvalidArgumentException {
|
||||
if (resource.getWorkbasketSummaryResource() == null
|
||||
|| resource.getWorkbasketSummaryResource().getWorkbasketId() == null
|
||||
|| resource.getWorkbasketSummaryResource().getWorkbasketId().isEmpty()) {
|
||||
private void validateTaskResource(TaskRepresentationModel resource)
|
||||
throws InvalidArgumentException {
|
||||
if (resource.getWorkbasketSummary() == null
|
||||
|| resource.getWorkbasketSummary().getWorkbasketId() == null
|
||||
|| resource.getWorkbasketSummary().getWorkbasketId().isEmpty()) {
|
||||
throw new InvalidArgumentException(
|
||||
"TaskResource must have a workbasket summary with a valid workbasketId.");
|
||||
}
|
||||
if (resource.getClassificationSummaryResource() == null
|
||||
|| resource.getClassificationSummaryResource().getKey() == null
|
||||
|| resource.getClassificationSummaryResource().getKey().isEmpty()) {
|
||||
if (resource.getClassificationSummary() == null
|
||||
|| resource.getClassificationSummary().getKey() == null
|
||||
|| resource.getClassificationSummary().getKey().isEmpty()) {
|
||||
throw new InvalidArgumentException(
|
||||
"TaskResource must have a classification summary with a valid classification key.");
|
||||
}
|
||||
|
|
@ -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 + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
import org.springframework.hateoas.server.core.Relation;
|
||||
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
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.workbasket.api.models.WorkbasketSummary;
|
||||
|
||||
/** EntityModel class for {@link WorkbasketSummary}. */
|
||||
@Relation(collectionRelation = "tasks")
|
||||
public class TaskSummaryResource extends RepresentationModel<TaskSummaryResource> {
|
||||
/**
|
||||
* EntityModel class for {@link WorkbasketSummary}.
|
||||
*/
|
||||
public class TaskSummaryRepresentationModel
|
||||
extends RepresentationModel<TaskSummaryRepresentationModel> {
|
||||
|
||||
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 note;
|
||||
private String description;
|
||||
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;
|
||||
private List<AttachmentSummaryResource> attachmentSummaryResources = 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;
|
||||
protected String taskId;
|
||||
protected String externalId;
|
||||
protected String created; // ISO-8601
|
||||
protected String claimed; // ISO-8601
|
||||
protected String completed; // ISO-8601
|
||||
protected String modified; // ISO-8601
|
||||
protected String planned; // ISO-8601
|
||||
protected String due; // ISO-8601
|
||||
protected String name;
|
||||
protected String creator;
|
||||
protected String note;
|
||||
protected String description;
|
||||
protected int priority;
|
||||
protected TaskState state;
|
||||
protected ClassificationSummaryRepresentationModel classificationSummary;
|
||||
protected WorkbasketSummaryRepresentationModel workbasketSummary;
|
||||
protected String businessProcessId;
|
||||
protected String parentBusinessProcessId;
|
||||
protected String owner;
|
||||
protected ObjectReference primaryObjRef;
|
||||
protected boolean isRead;
|
||||
protected boolean isTransferred;
|
||||
protected String custom1;
|
||||
protected String custom2;
|
||||
protected String custom3;
|
||||
protected String custom4;
|
||||
protected String custom5;
|
||||
protected String custom6;
|
||||
protected String custom7;
|
||||
protected String custom8;
|
||||
protected String custom9;
|
||||
protected String custom10;
|
||||
protected String custom11;
|
||||
protected String custom12;
|
||||
protected String custom13;
|
||||
protected String custom14;
|
||||
protected String custom15;
|
||||
protected 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.externalId = taskSummary.getExternalId();
|
||||
created = taskSummary.getCreated() != null ? taskSummary.getCreated().toString() : null;
|
||||
|
|
@ -73,19 +76,19 @@ public class TaskSummaryResource extends RepresentationModel<TaskSummaryResource
|
|||
this.description = taskSummary.getDescription();
|
||||
this.priority = taskSummary.getPriority();
|
||||
this.state = taskSummary.getState();
|
||||
this.classificationSummaryResource =
|
||||
new ClassificationSummaryResource(taskSummary.getClassificationSummary());
|
||||
this.workbasketSummaryResource =
|
||||
new WorkbasketSummaryResource(taskSummary.getWorkbasketSummary());
|
||||
this.classificationSummary =
|
||||
new ClassificationSummaryRepresentationModel(taskSummary.getClassificationSummary());
|
||||
this.workbasketSummary =
|
||||
new WorkbasketSummaryRepresentationModel(taskSummary.getWorkbasketSummary());
|
||||
this.businessProcessId = taskSummary.getBusinessProcessId();
|
||||
this.parentBusinessProcessId = taskSummary.getParentBusinessProcessId();
|
||||
this.owner = taskSummary.getOwner();
|
||||
this.primaryObjRef = taskSummary.getPrimaryObjRef();
|
||||
this.isRead = taskSummary.isRead();
|
||||
this.isTransferred = taskSummary.isTransferred();
|
||||
this.attachmentSummaryResources =
|
||||
this.attachmentSummaries =
|
||||
taskSummary.getAttachmentSummaries().stream()
|
||||
.map(AttachmentSummaryResource::new)
|
||||
.map(AttachmentSummaryRepresentationModel::new)
|
||||
.collect(Collectors.toList());
|
||||
this.custom1 = taskSummary.getCustomAttribute("1");
|
||||
this.custom2 = taskSummary.getCustomAttribute("2");
|
||||
|
|
@ -217,21 +220,22 @@ public class TaskSummaryResource extends RepresentationModel<TaskSummaryResource
|
|||
this.state = state;
|
||||
}
|
||||
|
||||
public ClassificationSummaryResource getClassificationSummaryResource() {
|
||||
return classificationSummaryResource;
|
||||
public ClassificationSummaryRepresentationModel getClassificationSummary() {
|
||||
return classificationSummary;
|
||||
}
|
||||
|
||||
public void setClassificationSummaryResource(
|
||||
ClassificationSummaryResource classificationSummaryResource) {
|
||||
this.classificationSummaryResource = classificationSummaryResource;
|
||||
public void setClassificationSummary(
|
||||
ClassificationSummaryRepresentationModel classificationSummary) {
|
||||
this.classificationSummary = classificationSummary;
|
||||
}
|
||||
|
||||
public WorkbasketSummaryResource getWorkbasketSummaryResource() {
|
||||
return workbasketSummaryResource;
|
||||
public WorkbasketSummaryRepresentationModel getWorkbasketSummary() {
|
||||
return workbasketSummary;
|
||||
}
|
||||
|
||||
public void setWorkbasketSummaryResource(WorkbasketSummaryResource workbasketSummaryResource) {
|
||||
this.workbasketSummaryResource = workbasketSummaryResource;
|
||||
public void setWorkbasketSummary(
|
||||
WorkbasketSummaryRepresentationModel workbasketSummary) {
|
||||
this.workbasketSummary = workbasketSummary;
|
||||
}
|
||||
|
||||
public String getBusinessProcessId() {
|
||||
|
|
@ -282,12 +286,13 @@ public class TaskSummaryResource extends RepresentationModel<TaskSummaryResource
|
|||
this.isTransferred = isTransferred;
|
||||
}
|
||||
|
||||
public List<AttachmentSummaryResource> getAttachmentSummaries() {
|
||||
return attachmentSummaryResources;
|
||||
public List<AttachmentSummaryRepresentationModel> getAttachmentSummaries() {
|
||||
return attachmentSummaries;
|
||||
}
|
||||
|
||||
public void setAttachmentSummaries(List<AttachmentSummaryResource> attachmentSummaryResources) {
|
||||
this.attachmentSummaryResources = attachmentSummaryResources;
|
||||
public void setAttachmentSummaries(
|
||||
List<AttachmentSummaryRepresentationModel> attachmentSummaries) {
|
||||
this.attachmentSummaries = attachmentSummaries;
|
||||
}
|
||||
|
||||
public String getCustom1() {
|
||||
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,8 @@ import pro.taskana.common.api.LoggerUtils;
|
|||
import pro.taskana.common.api.TaskanaRole;
|
||||
|
||||
/** EntityModel class for user information. */
|
||||
public class TaskanaUserInfoResource extends RepresentationModel<TaskanaUserInfoResource> {
|
||||
public class TaskanaUserInfoRepresentationModel
|
||||
extends RepresentationModel<TaskanaUserInfoRepresentationModel> {
|
||||
|
||||
private String userId;
|
||||
private List<String> groupIds = new ArrayList<>();
|
||||
|
|
@ -40,7 +41,7 @@ public class TaskanaUserInfoResource extends RepresentationModel<TaskanaUserInfo
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TaskanaUserInfoResource ["
|
||||
return "TaskanaUserInfoRepresentationModel ["
|
||||
+ "userId= "
|
||||
+ this.userId
|
||||
+ "groupIds= "
|
||||
|
|
@ -3,7 +3,7 @@ package pro.taskana.rest.resource;
|
|||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
/** EntityModel class for version information. */
|
||||
public class VersionResource extends RepresentationModel<VersionResource> {
|
||||
public class VersionRepresentationModel extends RepresentationModel<VersionRepresentationModel> {
|
||||
|
||||
private String version;
|
||||
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +1,20 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
import org.springframework.hateoas.server.core.Relation;
|
||||
|
||||
import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
|
||||
|
||||
/** EntityModel class for {@link WorkbasketAccessItem}. */
|
||||
@Relation(collectionRelation = "accessItems")
|
||||
public class WorkbasketAccessItemResource
|
||||
extends RepresentationModel<WorkbasketAccessItemResource> {
|
||||
/**
|
||||
* EntityModel class for {@link WorkbasketAccessItem}.
|
||||
*/
|
||||
public class WorkbasketAccessItemRepresentationModel
|
||||
extends RepresentationModel<WorkbasketAccessItemRepresentationModel> {
|
||||
|
||||
private String accessItemId;
|
||||
|
||||
@NotNull private String workbasketId;
|
||||
|
||||
@NotNull private String workbasketKey;
|
||||
|
||||
@NotNull private String accessId;
|
||||
|
||||
private String workbasketId;
|
||||
private String workbasketKey;
|
||||
private String accessId;
|
||||
private String accessName;
|
||||
|
||||
private boolean permRead;
|
||||
private boolean permOpen;
|
||||
private boolean permAppend;
|
||||
|
|
@ -39,9 +33,9 @@ public class WorkbasketAccessItemResource
|
|||
private boolean permCustom11;
|
||||
private boolean permCustom12;
|
||||
|
||||
public WorkbasketAccessItemResource() {}
|
||||
public WorkbasketAccessItemRepresentationModel() {}
|
||||
|
||||
public WorkbasketAccessItemResource(WorkbasketAccessItem workbasketAccessItem) {
|
||||
public WorkbasketAccessItemRepresentationModel(WorkbasketAccessItem workbasketAccessItem) {
|
||||
this.accessItemId = workbasketAccessItem.getId();
|
||||
this.workbasketId = workbasketAccessItem.getWorkbasketId();
|
||||
this.workbasketKey = workbasketAccessItem.getWorkbasketKey();
|
||||
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,23 +2,25 @@ package pro.taskana.rest.resource;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import pro.taskana.common.api.LoggerUtils;
|
||||
import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl;
|
||||
|
||||
/** 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 List<WorkbasketAccessItemImpl> authorizations;
|
||||
private WorkbasketResourceWithoutLinks workbasket;
|
||||
private WorkbasketRepresentationModelWithoutLinks workbasket;
|
||||
|
||||
public WorkbasketDefinitionResource() {
|
||||
public WorkbasketDefinitionRepresentationModel() {
|
||||
// necessary for de-serializing
|
||||
}
|
||||
|
||||
public WorkbasketDefinitionResource(
|
||||
WorkbasketResourceWithoutLinks workbasket,
|
||||
public WorkbasketDefinitionRepresentationModel(
|
||||
WorkbasketRepresentationModelWithoutLinks workbasket,
|
||||
Set<String> distributionTargets,
|
||||
List<WorkbasketAccessItemImpl> authorizations) {
|
||||
super();
|
||||
|
|
@ -43,11 +45,11 @@ public class WorkbasketDefinitionResource {
|
|||
this.authorizations = authorizations;
|
||||
}
|
||||
|
||||
public WorkbasketResourceWithoutLinks getWorkbasket() {
|
||||
public WorkbasketRepresentationModelWithoutLinks getWorkbasket() {
|
||||
return workbasket;
|
||||
}
|
||||
|
||||
public void setWorkbasket(WorkbasketResourceWithoutLinks workbasket) {
|
||||
public void setWorkbasket(WorkbasketRepresentationModelWithoutLinks workbasket) {
|
||||
this.workbasket = workbasket;
|
||||
}
|
||||
|
||||
|
|
@ -7,6 +7,7 @@ import java.util.Set;
|
|||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Transforms {@link Workbasket} into a {@link WorkbasketDefinitionResource} containing all
|
||||
* additional information about that workbasket.
|
||||
* Transforms {@link Workbasket} into a {@link WorkbasketDefinitionRepresentationModel} containing
|
||||
* all additional information about that workbasket.
|
||||
*/
|
||||
@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.
|
||||
*
|
||||
* @param workbasket {@link Workbasket} which will be converted
|
||||
* @return a {@link WorkbasketDefinitionResource}, containing the {@code basket}, its distribution
|
||||
* targets and its authorizations
|
||||
* @return a {@link WorkbasketDefinitionRepresentationModel}, containing the {@code basket}, its
|
||||
* distribution targets and its authorizations
|
||||
* @throws NotAuthorizedException if the user is not authorized
|
||||
* @throws WorkbasketNotFoundException if {@code basket} is an unknown workbasket
|
||||
*/
|
||||
public WorkbasketDefinitionResource toModel(Workbasket workbasket)
|
||||
@NonNull
|
||||
public WorkbasketDefinitionRepresentationModel toEntityModel(Workbasket workbasket)
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
|
||||
WorkbasketResourceWithoutLinks basket = new WorkbasketResourceWithoutLinks(workbasket);
|
||||
WorkbasketRepresentationModelWithoutLinks basket =
|
||||
new WorkbasketRepresentationModelWithoutLinks(workbasket);
|
||||
|
||||
List<WorkbasketAccessItemImpl> authorizations = new ArrayList<>();
|
||||
for (WorkbasketAccessItem accessItem :
|
||||
|
|
@ -50,10 +59,10 @@ public class WorkbasketDefinitionResourceAssembler {
|
|||
workbasketService.getDistributionTargets(workbasket.getId()).stream()
|
||||
.map(WorkbasketSummary::getId)
|
||||
.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)
|
||||
workbasketService.newWorkbasket(wbResource.getKey(), wbResource.getDomain());
|
||||
|
|
@ -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
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,8 @@ 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.hateoas.server.RepresentationModelAssembler;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
|
||||
|
|
@ -20,31 +21,33 @@ import pro.taskana.workbasket.api.models.Workbasket;
|
|||
import pro.taskana.workbasket.internal.models.WorkbasketImpl;
|
||||
|
||||
/**
|
||||
* Transforms {@link Workbasket} to its resource counterpart {@link WorkbasketResource} and vice
|
||||
* versa.
|
||||
* Transforms {@link Workbasket} to its resource counterpart {@link WorkbasketRepresentationModel}
|
||||
* and vice versa.
|
||||
*/
|
||||
@Component
|
||||
public class WorkbasketResourceAssembler
|
||||
extends RepresentationModelAssemblerSupport<Workbasket, WorkbasketResource> {
|
||||
public class WorkbasketRepresentationModelAssembler
|
||||
implements RepresentationModelAssembler<Workbasket, WorkbasketRepresentationModel> {
|
||||
|
||||
private final WorkbasketService workbasketService;
|
||||
|
||||
@Autowired
|
||||
public WorkbasketResourceAssembler(WorkbasketService workbasketService) {
|
||||
super(WorkbasketController.class, WorkbasketResource.class);
|
||||
public WorkbasketRepresentationModelAssembler(
|
||||
WorkbasketService workbasketService) {
|
||||
this.workbasketService = workbasketService;
|
||||
}
|
||||
|
||||
public WorkbasketResource toModel(Workbasket wb) {
|
||||
@NonNull
|
||||
@Override
|
||||
public WorkbasketRepresentationModel toModel(@NonNull Workbasket wb) {
|
||||
try {
|
||||
WorkbasketResource resource = new WorkbasketResource(wb);
|
||||
WorkbasketRepresentationModel resource = new WorkbasketRepresentationModel(wb);
|
||||
return addLinks(resource, wb);
|
||||
} catch (Exception e) {
|
||||
throw new SystemException("caught unexpected Exception.", e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
public Workbasket toModel(WorkbasketResource wbResource) {
|
||||
public Workbasket toEntityModel(WorkbasketRepresentationModel wbResource) {
|
||||
String wbKey = wbResource.getKey();
|
||||
String wbDomain = wbResource.getDomain();
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket(wbKey, wbDomain);
|
||||
|
|
@ -60,7 +63,8 @@ public class WorkbasketResourceAssembler
|
|||
return workbasket;
|
||||
}
|
||||
|
||||
private WorkbasketResource addLinks(WorkbasketResource resource, Workbasket wb)
|
||||
private WorkbasketRepresentationModel addLinks(
|
||||
WorkbasketRepresentationModel resource, Workbasket wb)
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidArgumentException {
|
||||
resource.add(
|
||||
linkTo(methodOn(WorkbasketController.class).getWorkbasket(wb.getId())).withSelfRel());
|
||||
|
|
@ -6,11 +6,11 @@ import pro.taskana.workbasket.api.models.Workbasket;
|
|||
|
||||
/** EntityModel class for {@link Workbasket} but without links property. */
|
||||
@JsonIgnoreProperties(value = {"links"})
|
||||
public class WorkbasketResourceWithoutLinks extends WorkbasketResource {
|
||||
public class WorkbasketRepresentationModelWithoutLinks extends WorkbasketRepresentationModel {
|
||||
|
||||
WorkbasketResourceWithoutLinks() {}
|
||||
WorkbasketRepresentationModelWithoutLinks() {}
|
||||
|
||||
WorkbasketResourceWithoutLinks(Workbasket workbasket) {
|
||||
WorkbasketRepresentationModelWithoutLinks(Workbasket workbasket) {
|
||||
super(workbasket);
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +1,37 @@
|
|||
package pro.taskana.rest.resource;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
import org.springframework.hateoas.server.core.Relation;
|
||||
|
||||
import pro.taskana.workbasket.api.WorkbasketType;
|
||||
import pro.taskana.workbasket.api.models.WorkbasketSummary;
|
||||
|
||||
/** EntityModel class for {@link WorkbasketSummary}. */
|
||||
@Relation(collectionRelation = "workbaskets")
|
||||
public class WorkbasketSummaryResource extends RepresentationModel<WorkbasketSummaryResource> {
|
||||
/**
|
||||
* EntityModel class for {@link WorkbasketSummary}.
|
||||
*/
|
||||
public class WorkbasketSummaryRepresentationModel
|
||||
extends RepresentationModel<WorkbasketSummaryRepresentationModel> {
|
||||
|
||||
private String workbasketId;
|
||||
|
||||
@NotNull private String key;
|
||||
|
||||
@NotNull private String name;
|
||||
|
||||
@NotNull private String domain;
|
||||
|
||||
@NotNull private WorkbasketType type;
|
||||
|
||||
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;
|
||||
protected String workbasketId;
|
||||
protected String key;
|
||||
protected String name;
|
||||
protected String domain;
|
||||
protected WorkbasketType type;
|
||||
protected String description;
|
||||
protected String owner;
|
||||
protected String custom1;
|
||||
protected String custom2;
|
||||
protected String custom3;
|
||||
protected String custom4;
|
||||
protected String orgLevel1;
|
||||
protected String orgLevel2;
|
||||
protected String orgLevel3;
|
||||
protected String orgLevel4;
|
||||
private boolean markedForDeletion;
|
||||
|
||||
public WorkbasketSummaryResource() {}
|
||||
public WorkbasketSummaryRepresentationModel() {
|
||||
}
|
||||
|
||||
public WorkbasketSummaryResource(WorkbasketSummary workbasketSummary) {
|
||||
public WorkbasketSummaryRepresentationModel(WorkbasketSummary workbasketSummary) {
|
||||
this.workbasketId = workbasketSummary.getId();
|
||||
this.key = workbasketSummary.getKey();
|
||||
this.name = workbasketSummary.getName();
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -13,13 +13,12 @@ import org.aspectj.lang.reflect.MethodSignature;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.PagedModel.PageMetadata;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
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.
|
||||
*/
|
||||
|
|
@ -39,8 +38,10 @@ public class PageLinksAspect {
|
|||
String relativeUrl = pageLinks.value();
|
||||
UriComponentsBuilder original = originalUri(relativeUrl, request);
|
||||
RepresentationModel<T> resourceSupport = (RepresentationModel<T>) joinPoint.proceed();
|
||||
resourceSupport.add(new Link(original.toUriString()).withSelfRel());
|
||||
if (page != null) {
|
||||
resourceSupport.add(
|
||||
new Link(original.replaceQueryParam("page", page.getNumber()).toUriString())
|
||||
.withSelfRel());
|
||||
resourceSupport.add(
|
||||
new Link(original.replaceQueryParam("page", 1).toUriString())
|
||||
.withRel(IanaLinkRelations.FIRST));
|
||||
|
|
@ -57,6 +58,8 @@ public class PageLinksAspect {
|
|||
new Link(original.replaceQueryParam("page", page.getNumber() + 1).toUriString())
|
||||
.withRel(IanaLinkRelations.NEXT));
|
||||
}
|
||||
} else {
|
||||
resourceSupport.add(new Link(original.toUriString()).withSelfRel());
|
||||
}
|
||||
return resourceSupport;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import pro.taskana.rest.Mapping;
|
|||
/** Generate Rest Docu for AbstractPagingController. */
|
||||
class AbstractPagingControllerRestDocumentation extends BaseRestDocumentation {
|
||||
|
||||
private HashMap<String, String> pagingFieldDescriptionsMap = new HashMap<String, String>();
|
||||
private final HashMap<String, String> pagingFieldDescriptionsMap = new HashMap<>();
|
||||
|
||||
private FieldDescriptor[] pagingFieldDescriptors;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,11 +22,13 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
|||
|
||||
import pro.taskana.rest.Mapping;
|
||||
|
||||
/** Generate REST Dokumentation for ClassificationController. */
|
||||
/**
|
||||
* Generate REST Dokumentation for ClassificationController.
|
||||
*/
|
||||
class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
|
||||
|
||||
private HashMap<String, String> classificationFieldDescriptionsMap =
|
||||
new HashMap<String, String>();
|
||||
private final HashMap<String, String> classificationFieldDescriptionsMap =
|
||||
new HashMap<>();
|
||||
|
||||
private FieldDescriptor[] allClassificationsFieldDescriptors;
|
||||
private FieldDescriptor[] classificationFieldDescriptors;
|
||||
|
|
@ -87,11 +89,6 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
|
|||
subsectionWithPath("classifications")
|
||||
.description("An Array of <<classification-subset, Classification-Subsets>>"),
|
||||
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 =
|
||||
|
|
@ -256,7 +253,7 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
|
|||
this.mockMvc
|
||||
.perform(
|
||||
RestDocumentationRequestBuilders.get(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?domain=DOMAIN_B")
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?domain=DOMAIN_B")
|
||||
.accept("application/hal+json")
|
||||
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
|
|
@ -337,14 +334,13 @@ class ClassificationControllerRestDocumentation extends BaseRestDocumentation {
|
|||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), UTF_8));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
StringBuilder content = new StringBuilder();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
String originalTask = content.toString();
|
||||
String modifiedTask = originalTask;
|
||||
String modifiedTask = content.toString();
|
||||
|
||||
this.mockMvc
|
||||
.perform(
|
||||
|
|
|
|||
|
|
@ -22,10 +22,11 @@ import org.springframework.test.web.servlet.MvcResult;
|
|||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
|
||||
import pro.taskana.rest.Mapping;
|
||||
import pro.taskana.rest.resource.TaskanaPagedModelKeys;
|
||||
|
||||
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[] taskCommentFieldDescriptors;
|
||||
|
|
@ -81,8 +82,10 @@ public class TaskCommentControllerRestDocumentation extends BaseRestDocumentatio
|
|||
};
|
||||
|
||||
allTaskCommentsFieldDescriptors =
|
||||
new FieldDescriptor[] {
|
||||
subsectionWithPath("task comments").description("An Array of task comments")
|
||||
new FieldDescriptor[]{
|
||||
subsectionWithPath(TaskanaPagedModelKeys.TASK_COMMENTS.getPropertyName()).description(
|
||||
"An Array of task comments"),
|
||||
fieldWithPath("_links.self.href").ignored()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import pro.taskana.rest.Mapping;
|
|||
/** Generate REST Documentation for the TaskController. */
|
||||
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[] taskFieldDescriptors;
|
||||
|
|
@ -60,10 +60,11 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
|
|||
taskFieldDescriptionsMap.put("priority", "The priority of the task");
|
||||
taskFieldDescriptionsMap.put("state", "he state of the task. See (...)");
|
||||
taskFieldDescriptionsMap.put(
|
||||
"classificationSummaryResource",
|
||||
"classificationSummary",
|
||||
"The <<classification-subset, Classification>> of the task");
|
||||
taskFieldDescriptionsMap.put(
|
||||
"workbasketSummaryResource", "The <<workbasket-subset, Workbasket>> of the task");
|
||||
"workbasketSummary",
|
||||
"The <<workbasket-subset, Workbasket>> of the task");
|
||||
taskFieldDescriptionsMap.put("businessProcessId", "");
|
||||
taskFieldDescriptionsMap.put("parentBusinessProcessId", "");
|
||||
taskFieldDescriptionsMap.put(
|
||||
|
|
@ -112,11 +113,6 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
|
|||
fieldWithPath("_links").ignored(),
|
||||
fieldWithPath("_links.self").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 =
|
||||
|
|
@ -137,28 +133,30 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
|
|||
.description(taskFieldDescriptionsMap.get("planned"))
|
||||
.type("String"),
|
||||
fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"),
|
||||
fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")),
|
||||
fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")),
|
||||
fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")),
|
||||
fieldWithPath("note")
|
||||
.description(taskFieldDescriptionsMap.get("note"))
|
||||
.description("Some custom Note"),
|
||||
fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")),
|
||||
fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")),
|
||||
subsectionWithPath("classificationSummaryResource")
|
||||
.description(taskFieldDescriptionsMap.get("classificationSummaryResource")),
|
||||
subsectionWithPath("workbasketSummaryResource")
|
||||
.description(taskFieldDescriptionsMap.get("workbasketSummaryResource")),
|
||||
fieldWithPath("businessProcessId")
|
||||
.description(taskFieldDescriptionsMap.get("businessProcessId")),
|
||||
fieldWithPath("parentBusinessProcessId")
|
||||
.description(taskFieldDescriptionsMap.get("parentBusinessProcessId")),
|
||||
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String"),
|
||||
fieldWithPath("primaryObjRef.id")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.id"))
|
||||
.type("String"),
|
||||
fieldWithPath("primaryObjRef.company")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
|
||||
fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")),
|
||||
fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")),
|
||||
fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")),
|
||||
fieldWithPath("note")
|
||||
.description(taskFieldDescriptionsMap.get("note"))
|
||||
.description("Some custom Note"),
|
||||
fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")),
|
||||
fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")),
|
||||
subsectionWithPath("classificationSummary")
|
||||
.description(
|
||||
taskFieldDescriptionsMap.get("classificationSummary")),
|
||||
subsectionWithPath("workbasketSummary")
|
||||
.description(taskFieldDescriptionsMap.get("workbasketSummary")),
|
||||
fieldWithPath("businessProcessId")
|
||||
.description(taskFieldDescriptionsMap.get("businessProcessId")),
|
||||
fieldWithPath("parentBusinessProcessId")
|
||||
.description(taskFieldDescriptionsMap.get("parentBusinessProcessId")),
|
||||
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type(
|
||||
"String"),
|
||||
fieldWithPath("primaryObjRef.id")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.id"))
|
||||
.type("String"),
|
||||
fieldWithPath("primaryObjRef.company")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
|
||||
fieldWithPath("primaryObjRef.system")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
|
||||
fieldWithPath("primaryObjRef.systemInstance")
|
||||
|
|
@ -240,28 +238,29 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
|
|||
.description(taskFieldDescriptionsMap.get("planned"))
|
||||
.type("String"),
|
||||
fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"),
|
||||
fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")),
|
||||
fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")),
|
||||
fieldWithPath("description").ignored(),
|
||||
fieldWithPath("note")
|
||||
.description(taskFieldDescriptionsMap.get("note"))
|
||||
.description("Some custom Note"),
|
||||
fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")),
|
||||
fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")),
|
||||
subsectionWithPath("classificationSummaryResource")
|
||||
.description(taskFieldDescriptionsMap.get("classificationSummaryResource")),
|
||||
subsectionWithPath("workbasketSummaryResource")
|
||||
.description(taskFieldDescriptionsMap.get("workbasketSummaryResource")),
|
||||
fieldWithPath("businessProcessId")
|
||||
.description(taskFieldDescriptionsMap.get("businessProcessId")),
|
||||
fieldWithPath("parentBusinessProcessId")
|
||||
.description(taskFieldDescriptionsMap.get("parentBusinessProcessId")),
|
||||
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")),
|
||||
fieldWithPath("primaryObjRef.id")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.id"))
|
||||
.type("String"),
|
||||
fieldWithPath("primaryObjRef.company")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
|
||||
fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")),
|
||||
fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")),
|
||||
fieldWithPath("description").ignored(),
|
||||
fieldWithPath("note")
|
||||
.description(taskFieldDescriptionsMap.get("note"))
|
||||
.description("Some custom Note"),
|
||||
fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")),
|
||||
fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")),
|
||||
subsectionWithPath("classificationSummary")
|
||||
.description(
|
||||
taskFieldDescriptionsMap.get("classificationSummary")),
|
||||
subsectionWithPath("workbasketSummary")
|
||||
.description(taskFieldDescriptionsMap.get("workbasketSummary")),
|
||||
fieldWithPath("businessProcessId")
|
||||
.description(taskFieldDescriptionsMap.get("businessProcessId")),
|
||||
fieldWithPath("parentBusinessProcessId")
|
||||
.description(taskFieldDescriptionsMap.get("parentBusinessProcessId")),
|
||||
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")),
|
||||
fieldWithPath("primaryObjRef.id")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.id"))
|
||||
.type("String"),
|
||||
fieldWithPath("primaryObjRef.company")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
|
||||
fieldWithPath("primaryObjRef.system")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
|
||||
fieldWithPath("primaryObjRef.systemInstance")
|
||||
|
|
@ -295,21 +294,21 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
|
|||
};
|
||||
|
||||
createTaskFieldDescriptors =
|
||||
new FieldDescriptor[] {
|
||||
subsectionWithPath("classificationSummaryResource")
|
||||
.description("The new classificationSummaryResource for the task"),
|
||||
subsectionWithPath("workbasketSummaryResource")
|
||||
.description("The new workbasketSummaryResource for the task"),
|
||||
fieldWithPath("externalId")
|
||||
.description(taskFieldDescriptionsMap.get("externalId"))
|
||||
.type("String")
|
||||
.optional(),
|
||||
fieldWithPath("primaryObjRef.company")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
|
||||
fieldWithPath("primaryObjRef.system")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
|
||||
fieldWithPath("primaryObjRef.systemInstance")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")),
|
||||
new FieldDescriptor[]{
|
||||
subsectionWithPath("classificationSummary")
|
||||
.description("The new classificationSummary for the task"),
|
||||
subsectionWithPath("workbasketSummary")
|
||||
.description("The new workbasketSummary for the task"),
|
||||
fieldWithPath("externalId")
|
||||
.description(taskFieldDescriptionsMap.get("externalId"))
|
||||
.type("String")
|
||||
.optional(),
|
||||
fieldWithPath("primaryObjRef.company")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
|
||||
fieldWithPath("primaryObjRef.system")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
|
||||
fieldWithPath("primaryObjRef.systemInstance")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")),
|
||||
fieldWithPath("primaryObjRef.type")
|
||||
.description(taskFieldDescriptionsMap.get("primaryObjRef.type")),
|
||||
fieldWithPath("primaryObjRef.value")
|
||||
|
|
@ -554,8 +553,8 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
|
|||
RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_TASKS))
|
||||
.contentType("application/hal+json")
|
||||
.content(
|
||||
"{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
|
||||
+ "\"workbasketSummaryResource\":"
|
||||
"{\"classificationSummary\":{\"key\":\"L11010\"},"
|
||||
+ "\"workbasketSummary\":"
|
||||
+ "{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
|
||||
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\","
|
||||
+ "\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\","
|
||||
|
|
@ -589,8 +588,8 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
|
|||
RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_TASKS))
|
||||
.contentType("application/hal+json")
|
||||
.content(
|
||||
"{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
|
||||
+ "\"workbasketSummaryResource\":"
|
||||
"{\"classificationSummary\":{\"key\":\"L11010\"},"
|
||||
+ "\"workbasketSummary\":"
|
||||
+ "{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
|
||||
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\","
|
||||
+ "\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\","
|
||||
|
|
@ -625,8 +624,8 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
|
|||
RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_TASKS))
|
||||
.contentType("application/hal+json")
|
||||
.content(
|
||||
"{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
|
||||
+ "\"workbasketSummaryResource\":"
|
||||
"{\"classificationSummary\":{\"key\":\"L11010\"},"
|
||||
+ "\"workbasketSummary\":"
|
||||
+ "{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
|
||||
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\","
|
||||
+ "\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\","
|
||||
|
|
@ -660,8 +659,8 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
|
|||
RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_TASKS))
|
||||
.contentType("application/hal+json")
|
||||
.content(
|
||||
"{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
|
||||
+ "\"workbasketSummaryResource\":"
|
||||
"{\"classificationSummary\":{\"key\":\"L11010\"},"
|
||||
+ "\"workbasketSummary\":"
|
||||
+ "{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
|
||||
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\","
|
||||
+ "\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\","
|
||||
|
|
@ -673,7 +672,6 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
|
|||
|
||||
String content = result.getResponse().getContentAsString();
|
||||
String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40);
|
||||
|
||||
this.mockMvc
|
||||
.perform(
|
||||
RestDocumentationRequestBuilders.post(
|
||||
|
|
@ -695,8 +693,8 @@ class TaskControllerRestDocumentation extends BaseRestDocumentation {
|
|||
RestDocumentationRequestBuilders.post(restHelper.toUrl(Mapping.URL_TASKS))
|
||||
.contentType("application/hal+json")
|
||||
.content(
|
||||
"{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
|
||||
+ "\"workbasketSummaryResource\":"
|
||||
"{\"classificationSummary\":{\"key\":\"L11010\"},"
|
||||
+ "\"workbasketSummary\":"
|
||||
+ "{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
|
||||
+ "\"primaryObjRef\":{\"company\":\"MyCompany1\","
|
||||
+ "\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\","
|
||||
|
|
|
|||
|
|
@ -105,10 +105,6 @@ class WorkbasketAccessItemControllerRestDocumentation extends BaseRestDocumentat
|
|||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom12")),
|
||||
fieldWithPath("_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()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,13 +20,15 @@ import org.springframework.restdocs.payload.FieldDescriptor;
|
|||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
|
||||
import pro.taskana.rest.Mapping;
|
||||
import pro.taskana.rest.resource.TaskanaPagedModelKeys;
|
||||
|
||||
/** Generate REST Documentatioon for the WorkbasketController. */
|
||||
class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
|
||||
|
||||
public static final String PROPERTY_NAME = TaskanaPagedModelKeys.ACCESSITEMS.getPropertyName();
|
||||
// HashMaps to store the field descriptions centrally for multiple uses
|
||||
private HashMap<String, String> workbasketFieldDescriptionsMap = new HashMap<String, String>();
|
||||
private HashMap<String, String> accessItemFieldDescriptionsMap = new HashMap<String, String>();
|
||||
private final HashMap<String, String> workbasketFieldDescriptionsMap = new HashMap<>();
|
||||
private final HashMap<String, String> accessItemFieldDescriptionsMap = new HashMap<>();
|
||||
|
||||
private FieldDescriptor[] allWorkbasketsFieldDescriptors;
|
||||
private FieldDescriptor[] workbasketFieldDescriptors;
|
||||
|
|
@ -52,12 +54,13 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
|
|||
workbasketFieldDescriptionsMap.put(
|
||||
"orgLevel1",
|
||||
"The first Org Level (the top one)\nThe Org Level is an association with an org "
|
||||
+ "hierarchie level in the organization. The values are used for monitoring "
|
||||
+ "hierarchy level in the organization. The values are used for monitoring "
|
||||
+ "and statistical purposes and should reflect the responsibility of the "
|
||||
+ "tasks in the workbasket.");
|
||||
workbasketFieldDescriptionsMap.put("orgLevel2", "The second Org Level");
|
||||
workbasketFieldDescriptionsMap.put("orgLevel3", "The third Org Level");
|
||||
workbasketFieldDescriptionsMap.put("orgLevel4", "The fourth Org Level (the lowest one).");
|
||||
workbasketFieldDescriptionsMap.put("markedForDeletion", "can this be deleted");
|
||||
workbasketFieldDescriptionsMap.put(
|
||||
"created", "The creation timestamp of the workbasket in the system.");
|
||||
workbasketFieldDescriptionsMap.put(
|
||||
|
|
@ -72,55 +75,52 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
|
|||
"_links.removeDistributionTargets.href",
|
||||
"Link to remove all distribution-targets from the workbasket");
|
||||
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");
|
||||
|
||||
accessItemFieldDescriptionsMap.put("accessItems.accessItemId", "Unique ID");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.workbasketId", "The workbasket");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.workbasketKey", "The workbasket key");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".accessItemId", "Unique ID");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".workbasketId", "The workbasket");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".workbasketKey", "The workbasket key");
|
||||
accessItemFieldDescriptionsMap.put(
|
||||
"accessItems.accessId",
|
||||
PROPERTY_NAME + ".accessId",
|
||||
"The access id, this ACL entry refers to. This could be either a userid or a "
|
||||
+ "full qualified group id (both lower case)");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.accessName", "");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".accessName", "");
|
||||
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(
|
||||
"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(
|
||||
"accessItems.permAppend",
|
||||
PROPERTY_NAME + ".permAppend",
|
||||
"The permission to add tasks to the workbasket (required for creation "
|
||||
+ "and transferring of tasks)");
|
||||
accessItemFieldDescriptionsMap.put(
|
||||
"accessItems.permTransfer",
|
||||
PROPERTY_NAME + ".permTransfer",
|
||||
"The permission to transfer tasks (out of the current workbasket)");
|
||||
accessItemFieldDescriptionsMap.put(
|
||||
"accessItems.permDistribute", "The permission to distribute tasks from the workbasket");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom1", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom2", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom3", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom4", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom5", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom6", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom7", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom8", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom9", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom10", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom11", "");
|
||||
accessItemFieldDescriptionsMap.put("accessItems.permCustom12", "");
|
||||
PROPERTY_NAME + ".permDistribute",
|
||||
"The permission to distribute tasks from the workbasket");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom1", "");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom2", "");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom3", "");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom4", "");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom5", "");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom6", "");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom7", "");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom8", "");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom9", "");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom10", "");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom11", "");
|
||||
accessItemFieldDescriptionsMap.put(PROPERTY_NAME + ".permCustom12", "");
|
||||
accessItemFieldDescriptionsMap.put(
|
||||
"accessItems._links.workbasket.href", "Link to the workbasket");
|
||||
PROPERTY_NAME + "._links.workbasket.href", "Link to the workbasket");
|
||||
|
||||
allWorkbasketsFieldDescriptors =
|
||||
new FieldDescriptor[] {
|
||||
subsectionWithPath("workbaskets")
|
||||
.description("An Array of <<workbasket-subset, Workbasket-Subsets>>"),
|
||||
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 =
|
||||
|
|
@ -144,13 +144,15 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
|
|||
fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")),
|
||||
fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")),
|
||||
fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")),
|
||||
fieldWithPath("markedForDeletion").description(
|
||||
workbasketFieldDescriptionsMap.get("markedForDeletion")),
|
||||
fieldWithPath("_links.distributionTargets.href")
|
||||
.description(workbasketFieldDescriptionsMap.get("_links.distributionTargets.href")),
|
||||
fieldWithPath("_links.removeDistributionTargets.href")
|
||||
.description(
|
||||
workbasketFieldDescriptionsMap.get("_links.removeDistributionTargets.href")),
|
||||
fieldWithPath("_links.accessItems.href")
|
||||
.description(workbasketFieldDescriptionsMap.get("_links.accessItems.href")),
|
||||
fieldWithPath("_links." + PROPERTY_NAME + ".href")
|
||||
.description(workbasketFieldDescriptionsMap.get("_links." + PROPERTY_NAME + ".href")),
|
||||
fieldWithPath("_links.allWorkbaskets.href")
|
||||
.description(workbasketFieldDescriptionsMap.get("_links.allWorkbaskets.href")),
|
||||
fieldWithPath("_links.self.href").ignored()
|
||||
|
|
@ -165,88 +167,81 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
|
|||
fieldWithPath("description")
|
||||
.description(workbasketFieldDescriptionsMap.get("description")),
|
||||
fieldWithPath("owner").description(workbasketFieldDescriptionsMap.get("owner")),
|
||||
fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")),
|
||||
fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")),
|
||||
fieldWithPath("custom1").description(workbasketFieldDescriptionsMap.get("custom1")),
|
||||
fieldWithPath("custom2").description(workbasketFieldDescriptionsMap.get("custom2")),
|
||||
fieldWithPath("custom3").description(workbasketFieldDescriptionsMap.get("custom3")),
|
||||
fieldWithPath("custom4").description(workbasketFieldDescriptionsMap.get("custom4")),
|
||||
fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1")),
|
||||
fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")),
|
||||
fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")),
|
||||
fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")),
|
||||
fieldWithPath("created").ignored(),
|
||||
fieldWithPath("modified").ignored(),
|
||||
fieldWithPath("_links.distributionTargets.href").ignored(),
|
||||
fieldWithPath("_links.removeDistributionTargets.href").ignored(),
|
||||
fieldWithPath("_links.accessItems.href").ignored(),
|
||||
fieldWithPath("_links.allWorkbaskets.href").ignored(),
|
||||
fieldWithPath("_links.self.href").ignored()
|
||||
fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")),
|
||||
fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")),
|
||||
fieldWithPath("custom1").description(workbasketFieldDescriptionsMap.get("custom1")),
|
||||
fieldWithPath("custom2").description(workbasketFieldDescriptionsMap.get("custom2")),
|
||||
fieldWithPath("custom3").description(workbasketFieldDescriptionsMap.get("custom3")),
|
||||
fieldWithPath("custom4").description(workbasketFieldDescriptionsMap.get("custom4")),
|
||||
fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1")),
|
||||
fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")),
|
||||
fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")),
|
||||
fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")),
|
||||
fieldWithPath("markedForDeletion").description(
|
||||
workbasketFieldDescriptionsMap.get("markedForDeletion")),
|
||||
fieldWithPath("created").ignored(),
|
||||
fieldWithPath("modified").ignored(),
|
||||
fieldWithPath("_links.distributionTargets.href").ignored(),
|
||||
fieldWithPath("_links.removeDistributionTargets.href").ignored(),
|
||||
fieldWithPath("_links." + PROPERTY_NAME + ".href").ignored(),
|
||||
fieldWithPath("_links.allWorkbaskets.href").ignored(),
|
||||
fieldWithPath("_links.self.href").ignored()
|
||||
};
|
||||
|
||||
accessItemFieldDescriptors =
|
||||
new FieldDescriptor[] {
|
||||
fieldWithPath("accessItems[].accessItemId")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.accessItemId")),
|
||||
fieldWithPath("accessItems[].workbasketId")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.workbasketId")),
|
||||
fieldWithPath("accessItems[].workbasketKey")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.workbasketKey")),
|
||||
fieldWithPath("accessItems[].accessId")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.accessId")),
|
||||
fieldWithPath("accessItems[].accessName")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.accessName")),
|
||||
fieldWithPath("accessItems[].permRead")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permRead")),
|
||||
fieldWithPath("accessItems[].permOpen")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permOpen")),
|
||||
fieldWithPath("accessItems[].permAppend")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permAppend")),
|
||||
fieldWithPath("accessItems[].permTransfer")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permTransfer")),
|
||||
fieldWithPath("accessItems[].permDistribute")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permDistribute")),
|
||||
fieldWithPath("accessItems[].permCustom1")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom1")),
|
||||
fieldWithPath("accessItems[].permCustom2")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom2")),
|
||||
fieldWithPath("accessItems[].permCustom3")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom3")),
|
||||
fieldWithPath("accessItems[].permCustom4")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom4")),
|
||||
fieldWithPath("accessItems[].permCustom5")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom5")),
|
||||
fieldWithPath("accessItems[].permCustom6")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom6")),
|
||||
fieldWithPath("accessItems[].permCustom7")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom7")),
|
||||
fieldWithPath("accessItems[].permCustom8")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom8")),
|
||||
fieldWithPath("accessItems[].permCustom9")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom9")),
|
||||
fieldWithPath("accessItems[].permCustom10")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom10")),
|
||||
fieldWithPath("accessItems[].permCustom11")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom11")),
|
||||
fieldWithPath("accessItems[].permCustom12")
|
||||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom12")),
|
||||
fieldWithPath("page.size").ignored(),
|
||||
fieldWithPath("page.totalElements").ignored(),
|
||||
fieldWithPath("page.totalPages").ignored(),
|
||||
fieldWithPath("page.number").ignored(),
|
||||
fieldWithPath(PROPERTY_NAME + "[].accessItemId")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".accessItemId")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].workbasketId")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".workbasketId")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].workbasketKey")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".workbasketKey")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].accessId")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".accessId")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].accessName")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".accessName")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permRead")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permRead")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permOpen")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permOpen")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permAppend")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permAppend")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permTransfer")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permTransfer")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permDistribute")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permDistribute")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permCustom1")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom1")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permCustom2")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom2")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permCustom3")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom3")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permCustom4")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom4")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permCustom5")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom5")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permCustom6")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom6")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permCustom7")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom7")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permCustom8")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom8")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permCustom9")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom9")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permCustom10")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom10")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permCustom11")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom11")),
|
||||
fieldWithPath(PROPERTY_NAME + "[].permCustom12")
|
||||
.description(accessItemFieldDescriptionsMap.get(PROPERTY_NAME + ".permCustom12")),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
fieldWithPath("_links.workbasket.href").ignored()
|
||||
};
|
||||
|
||||
allWorkbasketAccessItemsFieldDescriptors =
|
||||
new FieldDescriptor[] {
|
||||
subsectionWithPath("accessItems")
|
||||
subsectionWithPath(PROPERTY_NAME)
|
||||
.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.workbasket.href").ignored()
|
||||
};
|
||||
|
|
@ -256,7 +251,6 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
|
|||
subsectionWithPath("distributionTargets")
|
||||
.description("An array of <<workbasket-subset, workbasket subsets>>"),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
fieldWithPath("_links.workbasket.href").ignored()
|
||||
};
|
||||
|
||||
createWorkbasketFieldDescriptors =
|
||||
|
|
@ -322,8 +316,8 @@ class WorkbasketControllerRestDocumentation extends BaseRestDocumentation {
|
|||
workbasketFieldDescriptionsMap.get("_links.removeDistributionTargets.href"))
|
||||
.type("String")
|
||||
.optional(),
|
||||
fieldWithPath("_links.accessItems.href")
|
||||
.description(workbasketFieldDescriptionsMap.get("_links.accessItems.href"))
|
||||
fieldWithPath("_links." + PROPERTY_NAME + ".href")
|
||||
.description(workbasketFieldDescriptionsMap.get("_links." + PROPERTY_NAME + ".href"))
|
||||
.type("String")
|
||||
.optional(),
|
||||
fieldWithPath("_links.allWorkbaskets.href")
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import pro.taskana.rest.resource.AccessIdResource;
|
||||
import pro.taskana.rest.resource.AccessIdRepresentationModel;
|
||||
|
||||
/**
|
||||
* Implementation of LdapCache used for Unit tests.
|
||||
|
|
@ -16,284 +16,292 @@ import pro.taskana.rest.resource.AccessIdResource;
|
|||
*/
|
||||
public class LdapCacheTestImpl implements LdapCache {
|
||||
|
||||
/**
|
||||
* 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 =
|
||||
private final List<AccessIdRepresentationModel> accessIds =
|
||||
new ArrayList<>(
|
||||
Arrays.asList(
|
||||
new AccessIdResource("Martin, Rojas Miguel Angel", "user_1_1"),
|
||||
new AccessIdResource("Zorgati, Mustapha", "user_2_1"),
|
||||
new AccessIdResource("Behrendt, Maximilian", "max"),
|
||||
new AccessIdResource("Bert, Ali", "teamlead_5"),
|
||||
new AccessIdResource("Hagen, Holger", "teamlead_3"),
|
||||
new AccessIdResource("Breier, Bernd", "user_2_2"),
|
||||
new AccessIdResource("Fielmalz, Anke", "user017"),
|
||||
new AccessIdResource("Mente, Maximilian", "max_mente"),
|
||||
new AccessIdResource("Theke, Bernd", "user_2_3"),
|
||||
new AccessIdResource("Ferrante, Elena", "elena"),
|
||||
new AccessIdResource("Mueller, Simone", "simone"),
|
||||
new AccessIdResource("Sirup, Aaron", "user001"),
|
||||
new AccessIdResource("Nacho, recuerda", "user_1_2"),
|
||||
new AccessIdResource("Lass, Ada", "user003"),
|
||||
new AccessIdResource("Tion, Addi", "user004"),
|
||||
new AccessIdResource("Lette, Adi", "user005"),
|
||||
new AccessIdResource("Admin", "teamlead_2"),
|
||||
new AccessIdResource("Native, Alter", "user006"),
|
||||
new AccessIdResource("Herum, Albert", "user007"),
|
||||
new AccessIdResource("Meyer, Dominik", "teamlead_1"),
|
||||
new AccessIdResource("Mente, Ali", "user009"),
|
||||
new AccessIdResource("Nach, Alma", "user011"),
|
||||
new AccessIdResource("Gehzauch, Anders", "user012"),
|
||||
new AccessIdResource("Theke, Andi", "user013"),
|
||||
new AccessIdResource("Kreuz, Andreas", "user014"),
|
||||
new AccessIdResource("Tiefsee, Anka", "user016"),
|
||||
new AccessIdResource("Fassen, Ann", "user018"),
|
||||
new AccessIdResource("Probe, Ann", "user019"),
|
||||
new AccessIdResource("Bolika, Anna", "user020"),
|
||||
new AccessIdResource("Ecke, Anna", "user021"),
|
||||
new AccessIdResource("Hosi, Anna", "user022"),
|
||||
new AccessIdResource("Kronis-Tisch, Anna", "user023"),
|
||||
new AccessIdResource("Logie, Anna", "user024"),
|
||||
new AccessIdResource("Luehse, Anna", "user025"),
|
||||
new AccessIdResource("Nass, Anna", "user026"),
|
||||
new AccessIdResource("Thalb, Anna", "user027"),
|
||||
new AccessIdResource("Tomie, Anna", "user028"),
|
||||
new AccessIdResource("Donnich, Anne", "user029"),
|
||||
new AccessIdResource("Kaffek, Anne", "user030"),
|
||||
new AccessIdResource("Thek, Anne", "user031"),
|
||||
new AccessIdResource("Matoer, Anni", "user032"),
|
||||
new AccessIdResource("Ragentor, Ansgar", "user033"),
|
||||
new AccessIdResource("Stoteles, Ari", "user034"),
|
||||
new AccessIdResource("Thmetik, Ari", "user035"),
|
||||
new AccessIdResource("Nuehm, Arno", "user036"),
|
||||
new AccessIdResource("Schocke, Artie", "user037"),
|
||||
new AccessIdResource("Stoppel, Bart", "user038"),
|
||||
new AccessIdResource("Beitung, Bea", "user039"),
|
||||
new AccessIdResource("Ildich, Bea", "user040"),
|
||||
new AccessIdResource("Vista, Bella", "user041"),
|
||||
new AccessIdResource("Utzer, Ben", "user042"),
|
||||
new AccessIdResource("Zien, Ben", "user043"),
|
||||
new AccessIdResource("Stein, Bernd", "user044"),
|
||||
new AccessIdResource("Deramen, Bill", "user045"),
|
||||
new AccessIdResource("Honig, Bine", "user046"),
|
||||
new AccessIdResource("Densatz, Bo", "user047"),
|
||||
new AccessIdResource("Densee, Bo", "user048"),
|
||||
new AccessIdResource("Lerwagen, Bo", "user049"),
|
||||
new AccessIdResource("Tail, Bob", "user050"),
|
||||
new AccessIdResource("Ketta, Bruce", "user051"),
|
||||
new AccessIdResource("Terrie, Bud", "user052"),
|
||||
new AccessIdResource("Biener-Haken, Cara", "user053"),
|
||||
new AccessIdResource("Ass, Caro", "user054"),
|
||||
new AccessIdResource("Kaffee, Caro", "user055"),
|
||||
new AccessIdResource("Linger, Caro", "user056"),
|
||||
new AccessIdResource("tenSaft, Caro", "user057"),
|
||||
new AccessIdResource("Antheme, Chris", "user058"),
|
||||
new AccessIdResource("Baum, Chris", "user059"),
|
||||
new AccessIdResource("Tall, Chris", "user060"),
|
||||
new AccessIdResource("Reiniger, Claas", "user061"),
|
||||
new AccessIdResource("Grube, Claire", "user062"),
|
||||
new AccessIdResource("Fall, Clara", "user063"),
|
||||
new AccessIdResource("Korn, Clara", "user064"),
|
||||
new AccessIdResource("Lenriff, Cora", "user065"),
|
||||
new AccessIdResource("Schiert, Cora", "user066"),
|
||||
new AccessIdResource("Hose, Cord", "user067"),
|
||||
new AccessIdResource("Onbleu, Cord", "user068"),
|
||||
new AccessIdResource("Umkleide, Damon", "user069"),
|
||||
new AccessIdResource("Affier, Dean", "user070"),
|
||||
new AccessIdResource("Orm, Dean", "user071"),
|
||||
new AccessIdResource("Platz, Dennis", "user072"),
|
||||
new AccessIdResource("Milch, Dick", "user073"),
|
||||
new AccessIdResource("Mow, Dina", "user074"),
|
||||
new AccessIdResource("Keil, Donna", "user075"),
|
||||
new AccessIdResource("Littchen, Donna", "user076"),
|
||||
new AccessIdResource("Wetter, Donna", "user077"),
|
||||
new AccessIdResource("Was, Ed", "user078"),
|
||||
new AccessIdResource("Khar, Ede", "user079"),
|
||||
new AccessIdResource("Nut, Ella", "user080"),
|
||||
new AccessIdResource("Stisch, Ella", "user081"),
|
||||
new AccessIdResource("Diel, Emma", "user082"),
|
||||
new AccessIdResource("Herdamit, Emma", "user083"),
|
||||
new AccessIdResource("Mitter-Uhe, Emma", "user084"),
|
||||
new AccessIdResource("Tatt, Erich", "user085"),
|
||||
new AccessIdResource("Drigend, Ernie", "user086"),
|
||||
new AccessIdResource("Poly, Esther", "user087"),
|
||||
new AccessIdResource("Trautz, Eugen", "user088"),
|
||||
new AccessIdResource("Quiert, Eva", "user089"),
|
||||
new AccessIdResource("Inurlaub, Fatma", "user090"),
|
||||
new AccessIdResource("Land, Finn", "user091"),
|
||||
new AccessIdResource("Sternis, Finn", "user092"),
|
||||
new AccessIdResource("Furt, Frank", "user093"),
|
||||
new AccessIdResource("Reich, Frank", "user094"),
|
||||
new AccessIdResource("Iskaner, Franz", "user095"),
|
||||
new AccessIdResource("Nerr, Franziska", "user096"),
|
||||
new AccessIdResource("Zafen, Friedrich", "user097"),
|
||||
new AccessIdResource("Pomm, Fritz", "user098"),
|
||||
new AccessIdResource("deWegs, Gera", "user099"),
|
||||
new AccessIdResource("Staebe, Gitta", "user100"),
|
||||
new AccessIdResource("Zend, Glenn", "user101"),
|
||||
new AccessIdResource("Fisch, Grete", "user102"),
|
||||
new AccessIdResource("Zucker, Gus", "user103"),
|
||||
new AccessIdResource("Muhn, Hanni", "user104"),
|
||||
new AccessIdResource("Fermesse, Hanno", "user105"),
|
||||
new AccessIdResource("Aplast, Hans", "user106"),
|
||||
new AccessIdResource("Eart, Hans", "user107"),
|
||||
new AccessIdResource("Back, Hardy", "user108"),
|
||||
new AccessIdResource("Beau, Harry", "user109"),
|
||||
new AccessIdResource("Kraut, Heide", "user110"),
|
||||
new AccessIdResource("Witzka, Heide", "user111"),
|
||||
new AccessIdResource("Buchen, Hein", "user112"),
|
||||
new AccessIdResource("Lichkeit, Hein", "user113"),
|
||||
new AccessIdResource("Suchung, Hein", "user114"),
|
||||
new AccessIdResource("Ellmann, Heinz", "user115"),
|
||||
new AccessIdResource("Ketchup, Heinz", "user116"),
|
||||
new AccessIdResource("Zeim, Hilde", "user117"),
|
||||
new AccessIdResource("Bilien, Immo", "user118"),
|
||||
new AccessIdResource("Her, Inge", "user119"),
|
||||
new AccessIdResource("Wahrsam, Inge", "user120"),
|
||||
new AccessIdResource("Flamm, Ingo", "user121"),
|
||||
new AccessIdResource("Enzien, Ingrid", "user122"),
|
||||
new AccessIdResource("Rohsch, Inken", "user123"),
|
||||
new AccessIdResource("Ihr, Insa", "user124"),
|
||||
new AccessIdResource("Nerda, Iska", "user125"),
|
||||
new AccessIdResource("Eitz, Jens", "user126"),
|
||||
new AccessIdResource("Nastik, Jim", "user127"),
|
||||
new AccessIdResource("Gurt, Jo", "user128"),
|
||||
new AccessIdResource("Kurrth, Jo", "user129"),
|
||||
new AccessIdResource("Kolade, Joe", "user130"),
|
||||
new AccessIdResource("Iter, Johann", "user131"),
|
||||
new AccessIdResource("Tick, Joyce", "user132"),
|
||||
new AccessIdResource("Case, Justin", "user133"),
|
||||
new AccessIdResource("Time, Justin", "user134"),
|
||||
new AccessIdResource("Komp, Jutta", "user135"),
|
||||
new AccessIdResource("Mauer, Kai", "user136"),
|
||||
new AccessIdResource("Pirinja, Kai", "user137"),
|
||||
new AccessIdResource("Serpfalz, Kai", "user138"),
|
||||
new AccessIdResource("Auer, Karl", "user139"),
|
||||
new AccessIdResource("Ielauge, Karl", "user140"),
|
||||
new AccessIdResource("Ifornjen, Karl", "user141"),
|
||||
new AccessIdResource("Radi, Karl", "user142"),
|
||||
new AccessIdResource("Verti, Karl", "user143"),
|
||||
new AccessIdResource("Sery, Karo", "user144"),
|
||||
new AccessIdResource("Lisator, Katha", "user145"),
|
||||
new AccessIdResource("Flo, Kati", "user146"),
|
||||
new AccessIdResource("Schenn, Knut", "user147"),
|
||||
new AccessIdResource("Achse, Kurt", "user148"),
|
||||
new AccessIdResource("Zepause, Kurt", "user149"),
|
||||
new AccessIdResource("Zerr, Kurt", "user150"),
|
||||
new AccessIdResource("Reden, Lasse", "user151"),
|
||||
new AccessIdResource("Metten, Lee", "user152"),
|
||||
new AccessIdResource("Arm, Lene", "user153"),
|
||||
new AccessIdResource("Thur, Linnea", "user154"),
|
||||
new AccessIdResource("Bonn, Lisa", "user155"),
|
||||
new AccessIdResource("Sembourg, Luc", "user156"),
|
||||
new AccessIdResource("Rung, Lucky", "user157"),
|
||||
new AccessIdResource("Zafen, Ludwig", "user158"),
|
||||
new AccessIdResource("Hauden, Lukas", "user159"),
|
||||
new AccessIdResource("Hose, Lutz", "user160"),
|
||||
new AccessIdResource("Tablette, Lutz", "user161"),
|
||||
new AccessIdResource("Fehr, Luzie", "user162"),
|
||||
new AccessIdResource("Nalyse, Magda", "user163"),
|
||||
new AccessIdResource("Ehfer, Maik", "user164"),
|
||||
new AccessIdResource("Sehr, Malte", "user165"),
|
||||
new AccessIdResource("Thon, Mara", "user166"),
|
||||
new AccessIdResource("Quark, Marga", "user167"),
|
||||
new AccessIdResource("Nade, Marie", "user168"),
|
||||
new AccessIdResource("Niert, Marie", "user169"),
|
||||
new AccessIdResource("Neese, Mario", "user170"),
|
||||
new AccessIdResource("Nette, Marion", "user171"),
|
||||
new AccessIdResource("Nesium, Mark", "user172"),
|
||||
new AccessIdResource("Thalle, Mark", "user173"),
|
||||
new AccessIdResource("Diven, Marle", "user174"),
|
||||
new AccessIdResource("Fitz, Marle", "user175"),
|
||||
new AccessIdResource("Pfahl, Marta", "user176"),
|
||||
new AccessIdResource("Zorn, Martin", "user177"),
|
||||
new AccessIdResource("Krissmes, Mary", "user178"),
|
||||
new AccessIdResource("Jess, Matt", "user179"),
|
||||
new AccessIdResource("Strammer, Max", "user180"),
|
||||
new AccessIdResource("Mumm, Maxi", "user181"),
|
||||
new AccessIdResource("Morphose, Meta", "user182"),
|
||||
new AccessIdResource("Uh, Mia", "user183"),
|
||||
new AccessIdResource("Rofon, Mike", "user184"),
|
||||
new AccessIdResource("Rosoft, Mike", "user185"),
|
||||
new AccessIdResource("Liter, Milli", "user186"),
|
||||
new AccessIdResource("Thär, Milli", "user187"),
|
||||
new AccessIdResource("Welle, Mirko", "user188"),
|
||||
new AccessIdResource("Thorat, Mo", "user189"),
|
||||
new AccessIdResource("Thor, Moni", "user190"),
|
||||
new AccessIdResource("Kinolta, Monika", "user191"),
|
||||
new AccessIdResource("Mundhaar, Monika", "user192"),
|
||||
new AccessIdResource("Munter, Monika", "user193"),
|
||||
new AccessIdResource("Zwerg, Nat", "user194"),
|
||||
new AccessIdResource("Elmine, Nick", "user195"),
|
||||
new AccessIdResource("Thien, Niko", "user196"),
|
||||
new AccessIdResource("Pferd, Nils", "user197"),
|
||||
new AccessIdResource("Lerweise, Norma", "user198"),
|
||||
new AccessIdResource("Motor, Otto", "user199"),
|
||||
new AccessIdResource("Totol, Otto", "user200"),
|
||||
new AccessIdResource("Nerr, Paula", "user201"),
|
||||
new AccessIdResource("Imeter, Peer", "user202"),
|
||||
new AccessIdResource("Serkatze, Peer", "user203"),
|
||||
new AccessIdResource("Gogisch, Peter", "user204"),
|
||||
new AccessIdResource("Silje, Peter", "user205"),
|
||||
new AccessIdResource("Harmonie, Phil", "user206"),
|
||||
new AccessIdResource("Ihnen, Philip", "user207"),
|
||||
new AccessIdResource("Uto, Pia", "user208"),
|
||||
new AccessIdResource("Kothek, Pina", "user209"),
|
||||
new AccessIdResource("Zar, Pit", "user210"),
|
||||
new AccessIdResource("Zeih, Polly", "user211"),
|
||||
new AccessIdResource("Tswan, Puh", "user212"),
|
||||
new AccessIdResource("Zufall, Rainer", "user213"),
|
||||
new AccessIdResource("Lien, Rita", "user214"),
|
||||
new AccessIdResource("Held, Roman", "user215"),
|
||||
new AccessIdResource("Haar, Ross", "user216"),
|
||||
new AccessIdResource("Dick, Roy", "user217"),
|
||||
new AccessIdResource("Enplaner, Ruth", "user218"),
|
||||
new AccessIdResource("Kommen, Ryan", "user219"),
|
||||
new AccessIdResource("Philo, Sophie", "user220"),
|
||||
new AccessIdResource("Matisier, Stig", "user221"),
|
||||
new AccessIdResource("Loniki, Tessa", "user222"),
|
||||
new AccessIdResource("Tralisch, Thea", "user223"),
|
||||
new AccessIdResource("Logie, Theo", "user224"),
|
||||
new AccessIdResource("Ister, Thorn", "user225"),
|
||||
new AccessIdResource("Buktu, Tim", "user226"),
|
||||
new AccessIdResource("Ate, Tom", "user227"),
|
||||
new AccessIdResource("Pie, Udo", "user228"),
|
||||
new AccessIdResource("Aloe, Vera", "user229"),
|
||||
new AccessIdResource("Hausver, Walter", "user230"),
|
||||
new AccessIdResource("Schuh, Wanda", "user231"),
|
||||
new AccessIdResource("Rahm, Wolf", "user232"),
|
||||
new AccessIdResource("businessadmin", "cn=businessadmin,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("UsersGroup", "cn=usersgroup,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("DevelopersGroup", "cn=developersgroup,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("businessadmin", "cn=customersgroup,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("user_domain_A", "cn=user_domain_a,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("monitor", "cn=monitor,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("user_domain_C", "cn=user_domain_c,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("user_domain_D", "cn=user_domain_d,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("admin", "cn=admin,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource(
|
||||
new AccessIdRepresentationModel("Martin, Rojas Miguel Angel", "user_1_1"),
|
||||
new AccessIdRepresentationModel("Zorgati, Mustapha", "user_2_1"),
|
||||
new AccessIdRepresentationModel("Behrendt, Maximilian", "max"),
|
||||
new AccessIdRepresentationModel("Bert, Ali", "teamlead_5"),
|
||||
new AccessIdRepresentationModel("Hagen, Holger", "teamlead_3"),
|
||||
new AccessIdRepresentationModel("Breier, Bernd", "user_2_2"),
|
||||
new AccessIdRepresentationModel("Fielmalz, Anke", "user017"),
|
||||
new AccessIdRepresentationModel("Mente, Maximilian", "max_mente"),
|
||||
new AccessIdRepresentationModel("Theke, Bernd", "user_2_3"),
|
||||
new AccessIdRepresentationModel("Ferrante, Elena", "elena"),
|
||||
new AccessIdRepresentationModel("Mueller, Simone", "simone"),
|
||||
new AccessIdRepresentationModel("Sirup, Aaron", "user001"),
|
||||
new AccessIdRepresentationModel("Nacho, recuerda", "user_1_2"),
|
||||
new AccessIdRepresentationModel("Lass, Ada", "user003"),
|
||||
new AccessIdRepresentationModel("Tion, Addi", "user004"),
|
||||
new AccessIdRepresentationModel("Lette, Adi", "user005"),
|
||||
new AccessIdRepresentationModel("Admin", "teamlead_2"),
|
||||
new AccessIdRepresentationModel("Native, Alter", "user006"),
|
||||
new AccessIdRepresentationModel("Herum, Albert", "user007"),
|
||||
new AccessIdRepresentationModel("Meyer, Dominik", "teamlead_1"),
|
||||
new AccessIdRepresentationModel("Mente, Ali", "user009"),
|
||||
new AccessIdRepresentationModel("Nach, Alma", "user011"),
|
||||
new AccessIdRepresentationModel("Gehzauch, Anders", "user012"),
|
||||
new AccessIdRepresentationModel("Theke, Andi", "user013"),
|
||||
new AccessIdRepresentationModel("Kreuz, Andreas", "user014"),
|
||||
new AccessIdRepresentationModel("Tiefsee, Anka", "user016"),
|
||||
new AccessIdRepresentationModel("Fassen, Ann", "user018"),
|
||||
new AccessIdRepresentationModel("Probe, Ann", "user019"),
|
||||
new AccessIdRepresentationModel("Bolika, Anna", "user020"),
|
||||
new AccessIdRepresentationModel("Ecke, Anna", "user021"),
|
||||
new AccessIdRepresentationModel("Hosi, Anna", "user022"),
|
||||
new AccessIdRepresentationModel("Kronis-Tisch, Anna", "user023"),
|
||||
new AccessIdRepresentationModel("Logie, Anna", "user024"),
|
||||
new AccessIdRepresentationModel("Luehse, Anna", "user025"),
|
||||
new AccessIdRepresentationModel("Nass, Anna", "user026"),
|
||||
new AccessIdRepresentationModel("Thalb, Anna", "user027"),
|
||||
new AccessIdRepresentationModel("Tomie, Anna", "user028"),
|
||||
new AccessIdRepresentationModel("Donnich, Anne", "user029"),
|
||||
new AccessIdRepresentationModel("Kaffek, Anne", "user030"),
|
||||
new AccessIdRepresentationModel("Thek, Anne", "user031"),
|
||||
new AccessIdRepresentationModel("Matoer, Anni", "user032"),
|
||||
new AccessIdRepresentationModel("Ragentor, Ansgar", "user033"),
|
||||
new AccessIdRepresentationModel("Stoteles, Ari", "user034"),
|
||||
new AccessIdRepresentationModel("Thmetik, Ari", "user035"),
|
||||
new AccessIdRepresentationModel("Nuehm, Arno", "user036"),
|
||||
new AccessIdRepresentationModel("Schocke, Artie", "user037"),
|
||||
new AccessIdRepresentationModel("Stoppel, Bart", "user038"),
|
||||
new AccessIdRepresentationModel("Beitung, Bea", "user039"),
|
||||
new AccessIdRepresentationModel("Ildich, Bea", "user040"),
|
||||
new AccessIdRepresentationModel("Vista, Bella", "user041"),
|
||||
new AccessIdRepresentationModel("Utzer, Ben", "user042"),
|
||||
new AccessIdRepresentationModel("Zien, Ben", "user043"),
|
||||
new AccessIdRepresentationModel("Stein, Bernd", "user044"),
|
||||
new AccessIdRepresentationModel("Deramen, Bill", "user045"),
|
||||
new AccessIdRepresentationModel("Honig, Bine", "user046"),
|
||||
new AccessIdRepresentationModel("Densatz, Bo", "user047"),
|
||||
new AccessIdRepresentationModel("Densee, Bo", "user048"),
|
||||
new AccessIdRepresentationModel("Lerwagen, Bo", "user049"),
|
||||
new AccessIdRepresentationModel("Tail, Bob", "user050"),
|
||||
new AccessIdRepresentationModel("Ketta, Bruce", "user051"),
|
||||
new AccessIdRepresentationModel("Terrie, Bud", "user052"),
|
||||
new AccessIdRepresentationModel("Biener-Haken, Cara", "user053"),
|
||||
new AccessIdRepresentationModel("Ass, Caro", "user054"),
|
||||
new AccessIdRepresentationModel("Kaffee, Caro", "user055"),
|
||||
new AccessIdRepresentationModel("Linger, Caro", "user056"),
|
||||
new AccessIdRepresentationModel("tenSaft, Caro", "user057"),
|
||||
new AccessIdRepresentationModel("Antheme, Chris", "user058"),
|
||||
new AccessIdRepresentationModel("Baum, Chris", "user059"),
|
||||
new AccessIdRepresentationModel("Tall, Chris", "user060"),
|
||||
new AccessIdRepresentationModel("Reiniger, Claas", "user061"),
|
||||
new AccessIdRepresentationModel("Grube, Claire", "user062"),
|
||||
new AccessIdRepresentationModel("Fall, Clara", "user063"),
|
||||
new AccessIdRepresentationModel("Korn, Clara", "user064"),
|
||||
new AccessIdRepresentationModel("Lenriff, Cora", "user065"),
|
||||
new AccessIdRepresentationModel("Schiert, Cora", "user066"),
|
||||
new AccessIdRepresentationModel("Hose, Cord", "user067"),
|
||||
new AccessIdRepresentationModel("Onbleu, Cord", "user068"),
|
||||
new AccessIdRepresentationModel("Umkleide, Damon", "user069"),
|
||||
new AccessIdRepresentationModel("Affier, Dean", "user070"),
|
||||
new AccessIdRepresentationModel("Orm, Dean", "user071"),
|
||||
new AccessIdRepresentationModel("Platz, Dennis", "user072"),
|
||||
new AccessIdRepresentationModel("Milch, Dick", "user073"),
|
||||
new AccessIdRepresentationModel("Mow, Dina", "user074"),
|
||||
new AccessIdRepresentationModel("Keil, Donna", "user075"),
|
||||
new AccessIdRepresentationModel("Littchen, Donna", "user076"),
|
||||
new AccessIdRepresentationModel("Wetter, Donna", "user077"),
|
||||
new AccessIdRepresentationModel("Was, Ed", "user078"),
|
||||
new AccessIdRepresentationModel("Khar, Ede", "user079"),
|
||||
new AccessIdRepresentationModel("Nut, Ella", "user080"),
|
||||
new AccessIdRepresentationModel("Stisch, Ella", "user081"),
|
||||
new AccessIdRepresentationModel("Diel, Emma", "user082"),
|
||||
new AccessIdRepresentationModel("Herdamit, Emma", "user083"),
|
||||
new AccessIdRepresentationModel("Mitter-Uhe, Emma", "user084"),
|
||||
new AccessIdRepresentationModel("Tatt, Erich", "user085"),
|
||||
new AccessIdRepresentationModel("Drigend, Ernie", "user086"),
|
||||
new AccessIdRepresentationModel("Poly, Esther", "user087"),
|
||||
new AccessIdRepresentationModel("Trautz, Eugen", "user088"),
|
||||
new AccessIdRepresentationModel("Quiert, Eva", "user089"),
|
||||
new AccessIdRepresentationModel("Inurlaub, Fatma", "user090"),
|
||||
new AccessIdRepresentationModel("Land, Finn", "user091"),
|
||||
new AccessIdRepresentationModel("Sternis, Finn", "user092"),
|
||||
new AccessIdRepresentationModel("Furt, Frank", "user093"),
|
||||
new AccessIdRepresentationModel("Reich, Frank", "user094"),
|
||||
new AccessIdRepresentationModel("Iskaner, Franz", "user095"),
|
||||
new AccessIdRepresentationModel("Nerr, Franziska", "user096"),
|
||||
new AccessIdRepresentationModel("Zafen, Friedrich", "user097"),
|
||||
new AccessIdRepresentationModel("Pomm, Fritz", "user098"),
|
||||
new AccessIdRepresentationModel("deWegs, Gera", "user099"),
|
||||
new AccessIdRepresentationModel("Staebe, Gitta", "user100"),
|
||||
new AccessIdRepresentationModel("Zend, Glenn", "user101"),
|
||||
new AccessIdRepresentationModel("Fisch, Grete", "user102"),
|
||||
new AccessIdRepresentationModel("Zucker, Gus", "user103"),
|
||||
new AccessIdRepresentationModel("Muhn, Hanni", "user104"),
|
||||
new AccessIdRepresentationModel("Fermesse, Hanno", "user105"),
|
||||
new AccessIdRepresentationModel("Aplast, Hans", "user106"),
|
||||
new AccessIdRepresentationModel("Eart, Hans", "user107"),
|
||||
new AccessIdRepresentationModel("Back, Hardy", "user108"),
|
||||
new AccessIdRepresentationModel("Beau, Harry", "user109"),
|
||||
new AccessIdRepresentationModel("Kraut, Heide", "user110"),
|
||||
new AccessIdRepresentationModel("Witzka, Heide", "user111"),
|
||||
new AccessIdRepresentationModel("Buchen, Hein", "user112"),
|
||||
new AccessIdRepresentationModel("Lichkeit, Hein", "user113"),
|
||||
new AccessIdRepresentationModel("Suchung, Hein", "user114"),
|
||||
new AccessIdRepresentationModel("Ellmann, Heinz", "user115"),
|
||||
new AccessIdRepresentationModel("Ketchup, Heinz", "user116"),
|
||||
new AccessIdRepresentationModel("Zeim, Hilde", "user117"),
|
||||
new AccessIdRepresentationModel("Bilien, Immo", "user118"),
|
||||
new AccessIdRepresentationModel("Her, Inge", "user119"),
|
||||
new AccessIdRepresentationModel("Wahrsam, Inge", "user120"),
|
||||
new AccessIdRepresentationModel("Flamm, Ingo", "user121"),
|
||||
new AccessIdRepresentationModel("Enzien, Ingrid", "user122"),
|
||||
new AccessIdRepresentationModel("Rohsch, Inken", "user123"),
|
||||
new AccessIdRepresentationModel("Ihr, Insa", "user124"),
|
||||
new AccessIdRepresentationModel("Nerda, Iska", "user125"),
|
||||
new AccessIdRepresentationModel("Eitz, Jens", "user126"),
|
||||
new AccessIdRepresentationModel("Nastik, Jim", "user127"),
|
||||
new AccessIdRepresentationModel("Gurt, Jo", "user128"),
|
||||
new AccessIdRepresentationModel("Kurrth, Jo", "user129"),
|
||||
new AccessIdRepresentationModel("Kolade, Joe", "user130"),
|
||||
new AccessIdRepresentationModel("Iter, Johann", "user131"),
|
||||
new AccessIdRepresentationModel("Tick, Joyce", "user132"),
|
||||
new AccessIdRepresentationModel("Case, Justin", "user133"),
|
||||
new AccessIdRepresentationModel("Time, Justin", "user134"),
|
||||
new AccessIdRepresentationModel("Komp, Jutta", "user135"),
|
||||
new AccessIdRepresentationModel("Mauer, Kai", "user136"),
|
||||
new AccessIdRepresentationModel("Pirinja, Kai", "user137"),
|
||||
new AccessIdRepresentationModel("Serpfalz, Kai", "user138"),
|
||||
new AccessIdRepresentationModel("Auer, Karl", "user139"),
|
||||
new AccessIdRepresentationModel("Ielauge, Karl", "user140"),
|
||||
new AccessIdRepresentationModel("Ifornjen, Karl", "user141"),
|
||||
new AccessIdRepresentationModel("Radi, Karl", "user142"),
|
||||
new AccessIdRepresentationModel("Verti, Karl", "user143"),
|
||||
new AccessIdRepresentationModel("Sery, Karo", "user144"),
|
||||
new AccessIdRepresentationModel("Lisator, Katha", "user145"),
|
||||
new AccessIdRepresentationModel("Flo, Kati", "user146"),
|
||||
new AccessIdRepresentationModel("Schenn, Knut", "user147"),
|
||||
new AccessIdRepresentationModel("Achse, Kurt", "user148"),
|
||||
new AccessIdRepresentationModel("Zepause, Kurt", "user149"),
|
||||
new AccessIdRepresentationModel("Zerr, Kurt", "user150"),
|
||||
new AccessIdRepresentationModel("Reden, Lasse", "user151"),
|
||||
new AccessIdRepresentationModel("Metten, Lee", "user152"),
|
||||
new AccessIdRepresentationModel("Arm, Lene", "user153"),
|
||||
new AccessIdRepresentationModel("Thur, Linnea", "user154"),
|
||||
new AccessIdRepresentationModel("Bonn, Lisa", "user155"),
|
||||
new AccessIdRepresentationModel("Sembourg, Luc", "user156"),
|
||||
new AccessIdRepresentationModel("Rung, Lucky", "user157"),
|
||||
new AccessIdRepresentationModel("Zafen, Ludwig", "user158"),
|
||||
new AccessIdRepresentationModel("Hauden, Lukas", "user159"),
|
||||
new AccessIdRepresentationModel("Hose, Lutz", "user160"),
|
||||
new AccessIdRepresentationModel("Tablette, Lutz", "user161"),
|
||||
new AccessIdRepresentationModel("Fehr, Luzie", "user162"),
|
||||
new AccessIdRepresentationModel("Nalyse, Magda", "user163"),
|
||||
new AccessIdRepresentationModel("Ehfer, Maik", "user164"),
|
||||
new AccessIdRepresentationModel("Sehr, Malte", "user165"),
|
||||
new AccessIdRepresentationModel("Thon, Mara", "user166"),
|
||||
new AccessIdRepresentationModel("Quark, Marga", "user167"),
|
||||
new AccessIdRepresentationModel("Nade, Marie", "user168"),
|
||||
new AccessIdRepresentationModel("Niert, Marie", "user169"),
|
||||
new AccessIdRepresentationModel("Neese, Mario", "user170"),
|
||||
new AccessIdRepresentationModel("Nette, Marion", "user171"),
|
||||
new AccessIdRepresentationModel("Nesium, Mark", "user172"),
|
||||
new AccessIdRepresentationModel("Thalle, Mark", "user173"),
|
||||
new AccessIdRepresentationModel("Diven, Marle", "user174"),
|
||||
new AccessIdRepresentationModel("Fitz, Marle", "user175"),
|
||||
new AccessIdRepresentationModel("Pfahl, Marta", "user176"),
|
||||
new AccessIdRepresentationModel("Zorn, Martin", "user177"),
|
||||
new AccessIdRepresentationModel("Krissmes, Mary", "user178"),
|
||||
new AccessIdRepresentationModel("Jess, Matt", "user179"),
|
||||
new AccessIdRepresentationModel("Strammer, Max", "user180"),
|
||||
new AccessIdRepresentationModel("Mumm, Maxi", "user181"),
|
||||
new AccessIdRepresentationModel("Morphose, Meta", "user182"),
|
||||
new AccessIdRepresentationModel("Uh, Mia", "user183"),
|
||||
new AccessIdRepresentationModel("Rofon, Mike", "user184"),
|
||||
new AccessIdRepresentationModel("Rosoft, Mike", "user185"),
|
||||
new AccessIdRepresentationModel("Liter, Milli", "user186"),
|
||||
new AccessIdRepresentationModel("Thär, Milli", "user187"),
|
||||
new AccessIdRepresentationModel("Welle, Mirko", "user188"),
|
||||
new AccessIdRepresentationModel("Thorat, Mo", "user189"),
|
||||
new AccessIdRepresentationModel("Thor, Moni", "user190"),
|
||||
new AccessIdRepresentationModel("Kinolta, Monika", "user191"),
|
||||
new AccessIdRepresentationModel("Mundhaar, Monika", "user192"),
|
||||
new AccessIdRepresentationModel("Munter, Monika", "user193"),
|
||||
new AccessIdRepresentationModel("Zwerg, Nat", "user194"),
|
||||
new AccessIdRepresentationModel("Elmine, Nick", "user195"),
|
||||
new AccessIdRepresentationModel("Thien, Niko", "user196"),
|
||||
new AccessIdRepresentationModel("Pferd, Nils", "user197"),
|
||||
new AccessIdRepresentationModel("Lerweise, Norma", "user198"),
|
||||
new AccessIdRepresentationModel("Motor, Otto", "user199"),
|
||||
new AccessIdRepresentationModel("Totol, Otto", "user200"),
|
||||
new AccessIdRepresentationModel("Nerr, Paula", "user201"),
|
||||
new AccessIdRepresentationModel("Imeter, Peer", "user202"),
|
||||
new AccessIdRepresentationModel("Serkatze, Peer", "user203"),
|
||||
new AccessIdRepresentationModel("Gogisch, Peter", "user204"),
|
||||
new AccessIdRepresentationModel("Silje, Peter", "user205"),
|
||||
new AccessIdRepresentationModel("Harmonie, Phil", "user206"),
|
||||
new AccessIdRepresentationModel("Ihnen, Philip", "user207"),
|
||||
new AccessIdRepresentationModel("Uto, Pia", "user208"),
|
||||
new AccessIdRepresentationModel("Kothek, Pina", "user209"),
|
||||
new AccessIdRepresentationModel("Zar, Pit", "user210"),
|
||||
new AccessIdRepresentationModel("Zeih, Polly", "user211"),
|
||||
new AccessIdRepresentationModel("Tswan, Puh", "user212"),
|
||||
new AccessIdRepresentationModel("Zufall, Rainer", "user213"),
|
||||
new AccessIdRepresentationModel("Lien, Rita", "user214"),
|
||||
new AccessIdRepresentationModel("Held, Roman", "user215"),
|
||||
new AccessIdRepresentationModel("Haar, Ross", "user216"),
|
||||
new AccessIdRepresentationModel("Dick, Roy", "user217"),
|
||||
new AccessIdRepresentationModel("Enplaner, Ruth", "user218"),
|
||||
new AccessIdRepresentationModel("Kommen, Ryan", "user219"),
|
||||
new AccessIdRepresentationModel("Philo, Sophie", "user220"),
|
||||
new AccessIdRepresentationModel("Matisier, Stig", "user221"),
|
||||
new AccessIdRepresentationModel("Loniki, Tessa", "user222"),
|
||||
new AccessIdRepresentationModel("Tralisch, Thea", "user223"),
|
||||
new AccessIdRepresentationModel("Logie, Theo", "user224"),
|
||||
new AccessIdRepresentationModel("Ister, Thorn", "user225"),
|
||||
new AccessIdRepresentationModel("Buktu, Tim", "user226"),
|
||||
new AccessIdRepresentationModel("Ate, Tom", "user227"),
|
||||
new AccessIdRepresentationModel("Pie, Udo", "user228"),
|
||||
new AccessIdRepresentationModel("Aloe, Vera", "user229"),
|
||||
new AccessIdRepresentationModel("Hausver, Walter", "user230"),
|
||||
new AccessIdRepresentationModel("Schuh, Wanda", "user231"),
|
||||
new AccessIdRepresentationModel("Rahm, Wolf", "user232"),
|
||||
new AccessIdRepresentationModel(
|
||||
"businessadmin", "cn=businessadmin,ou=groups,o=taskanatest"),
|
||||
new AccessIdRepresentationModel(
|
||||
"UsersGroup", "cn=usersgroup,ou=groups,o=taskanatest"),
|
||||
new AccessIdRepresentationModel(
|
||||
"DevelopersGroup", "cn=developersgroup,ou=groups,o=taskanatest"),
|
||||
new AccessIdRepresentationModel(
|
||||
"businessadmin", "cn=customersgroup,ou=groups,o=taskanatest"),
|
||||
new AccessIdRepresentationModel(
|
||||
"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"),
|
||||
new AccessIdResource(
|
||||
new AccessIdRepresentationModel(
|
||||
"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"),
|
||||
new AccessIdResource("teamlead_2", "cn=teamlead_2" + ",ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("teamlead_4", "cn=teamlead_4" + ",ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("team_3", "cn=team_3" + ",ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("team_4", "cn=team_4" + ",ou=groups,o=taskanatest")));
|
||||
new AccessIdRepresentationModel(
|
||||
"teamlead_2", "cn=teamlead_2" + ",ou=groups,o=taskanatest"),
|
||||
new AccessIdRepresentationModel(
|
||||
"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
|
||||
public List<AccessIdResource> findMatchingAccessId(
|
||||
public List<AccessIdRepresentationModel> findMatchingAccessId(
|
||||
String searchFor, int maxNumberOfReturnedAccessIds) {
|
||||
return findAcessIdResource(searchFor, maxNumberOfReturnedAccessIds, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccessIdResource> findGroupsOfUser(
|
||||
public List<AccessIdRepresentationModel> findGroupsOfUser(
|
||||
String searchFor, int maxNumberOfReturnedAccessIds) {
|
||||
if (users == null) {
|
||||
addUsersToGroups();
|
||||
|
|
@ -302,15 +310,15 @@ public class LdapCacheTestImpl implements LdapCache {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<AccessIdResource> validateAccessId(String accessId) {
|
||||
public List<AccessIdRepresentationModel> validateAccessId(String accessId) {
|
||||
return accessIds.stream()
|
||||
.filter(t -> (t.getAccessId().equalsIgnoreCase(accessId.toLowerCase())))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<AccessIdResource> findAcessIdResource(
|
||||
private List<AccessIdRepresentationModel> findAcessIdResource(
|
||||
String searchFor, int maxNumberOfReturnedAccessIds, boolean groupMember) {
|
||||
List<AccessIdResource> usersAndGroups =
|
||||
List<AccessIdRepresentationModel> usersAndGroups =
|
||||
accessIds.stream()
|
||||
.filter(
|
||||
t ->
|
||||
|
|
@ -318,7 +326,7 @@ public class LdapCacheTestImpl implements LdapCache {
|
|||
|| t.getAccessId().toLowerCase().contains(searchFor.toLowerCase())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<AccessIdResource> usersAndGroupsAux = new ArrayList<>(usersAndGroups);
|
||||
List<AccessIdRepresentationModel> usersAndGroupsAux = new ArrayList<>(usersAndGroups);
|
||||
if (groupMember) {
|
||||
usersAndGroupsAux.forEach(
|
||||
item -> {
|
||||
|
|
@ -329,18 +337,15 @@ public class LdapCacheTestImpl implements LdapCache {
|
|||
}
|
||||
|
||||
usersAndGroups.sort(
|
||||
(AccessIdResource a, AccessIdResource b) -> {
|
||||
return a.getAccessId().compareToIgnoreCase(b.getAccessId());
|
||||
});
|
||||
(AccessIdRepresentationModel a, AccessIdRepresentationModel b) -> a.getAccessId()
|
||||
.compareToIgnoreCase(
|
||||
b.getAccessId()));
|
||||
|
||||
List<AccessIdResource> result =
|
||||
usersAndGroups.subList(0, Math.min(usersAndGroups.size(), maxNumberOfReturnedAccessIds));
|
||||
|
||||
return result;
|
||||
return usersAndGroups.subList(0, Math.min(usersAndGroups.size(), maxNumberOfReturnedAccessIds));
|
||||
}
|
||||
|
||||
private void addUsersToGroups() {
|
||||
List<AccessIdResource> groups = new ArrayList<>();
|
||||
List<AccessIdRepresentationModel> groups = new ArrayList<>();
|
||||
users = new HashMap<>();
|
||||
|
||||
accessIds.forEach(
|
||||
|
|
@ -353,12 +358,12 @@ public class LdapCacheTestImpl implements LdapCache {
|
|||
});
|
||||
|
||||
int groupNumber = 0;
|
||||
List<AccessIdResource> group0 = new ArrayList<>();
|
||||
List<AccessIdResource> group1 = new ArrayList<>();
|
||||
List<AccessIdResource> group2 = new ArrayList<>();
|
||||
List<AccessIdResource> group3 = new ArrayList<>();
|
||||
List<AccessIdRepresentationModel> group0 = new ArrayList<>();
|
||||
List<AccessIdRepresentationModel> group1 = new ArrayList<>();
|
||||
List<AccessIdRepresentationModel> group2 = new ArrayList<>();
|
||||
List<AccessIdRepresentationModel> group3 = new ArrayList<>();
|
||||
|
||||
for (AccessIdResource group : groups) {
|
||||
for (AccessIdRepresentationModel group : groups) {
|
||||
switch (groupNumber) {
|
||||
case 0:
|
||||
group0.add(group);
|
||||
|
|
@ -379,7 +384,7 @@ public class LdapCacheTestImpl implements LdapCache {
|
|||
}
|
||||
|
||||
int countUser = 0;
|
||||
for (AccessIdResource item : accessIds) {
|
||||
for (AccessIdRepresentationModel item : accessIds) {
|
||||
if (!item.getAccessId().contains("ou=groups")) {
|
||||
switch (countUser) {
|
||||
case 0:
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import org.springframework.ldap.core.LdapTemplate;
|
|||
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.common.api.exceptions.SystemException;
|
||||
import pro.taskana.rest.resource.AccessIdResource;
|
||||
import pro.taskana.rest.resource.AccessIdRepresentationModel;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class LdapClientTest {
|
||||
|
|
@ -56,8 +56,8 @@ class LdapClientTest {
|
|||
setUpEnvMock();
|
||||
cut.init();
|
||||
|
||||
AccessIdResource group = new AccessIdResource("testG", "testGId");
|
||||
AccessIdResource user = new AccessIdResource("testU", "testUId");
|
||||
AccessIdRepresentationModel group = new AccessIdRepresentationModel("testG", "testGId");
|
||||
AccessIdRepresentationModel user = new AccessIdRepresentationModel("testU", "testUId");
|
||||
|
||||
when(ldapTemplate.search(
|
||||
any(String.class), any(), anyInt(), any(), any(LdapClient.GroupContextMapper.class)))
|
||||
|
|
@ -89,9 +89,9 @@ class LdapClientTest {
|
|||
setUpEnvMock();
|
||||
cut.init();
|
||||
|
||||
List<AccessIdResource> result =
|
||||
List<AccessIdRepresentationModel> result =
|
||||
IntStream.range(0, 100)
|
||||
.mapToObj(i -> new AccessIdResource("" + i, "" + i))
|
||||
.mapToObj(i -> new AccessIdRepresentationModel("" + i, "" + i))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
assertThat(cut.getFirstPageOfaResultList(result))
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import org.springframework.web.client.RestTemplate;
|
|||
|
||||
import pro.taskana.RestHelper;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.rest.resource.AccessIdResource;
|
||||
import pro.taskana.rest.resource.AccessIdRepresentationModel;
|
||||
|
||||
@TaskanaSpringBootTest
|
||||
@ActiveProfiles({"test", "ldap"})
|
||||
|
|
@ -63,18 +63,18 @@ class AccessIdControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testGetMatches() {
|
||||
ResponseEntity<List<AccessIdResource>> response =
|
||||
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=rig",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(AccessIdListResource.class));
|
||||
|
||||
List<AccessIdResource> body = response.getBody();
|
||||
List<AccessIdRepresentationModel> body = response.getBody();
|
||||
assertThat(body).isNotNull();
|
||||
assertThat(body).hasSize(2);
|
||||
assertThat(body)
|
||||
.extracting(AccessIdResource::getName)
|
||||
.extracting(AccessIdRepresentationModel::getName)
|
||||
.containsExactlyInAnyOrder("Schläfrig, Tim", "Eifrig, Elena");
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ class AccessIdControllerIntTest {
|
|||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
static class AccessIdListResource extends ArrayList<AccessIdResource> {
|
||||
static class AccessIdListResource extends ArrayList<AccessIdRepresentationModel> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ import org.springframework.web.client.RestTemplate;
|
|||
|
||||
import pro.taskana.RestHelper;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.rest.resource.ClassificationResource;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryListResource;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryResource;
|
||||
import pro.taskana.rest.resource.ClassificationRepresentationModel;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryRepresentationModel;
|
||||
import pro.taskana.rest.resource.TaskanaPagedModel;
|
||||
|
||||
/**
|
||||
* Test ClassificationController.
|
||||
|
|
@ -31,18 +31,23 @@ import pro.taskana.rest.resource.ClassificationSummaryResource;
|
|||
@TaskanaSpringBootTest
|
||||
class ClassificationControllerIntTest {
|
||||
|
||||
private static final ParameterizedTypeReference<
|
||||
TaskanaPagedModel<ClassificationSummaryRepresentationModel>>
|
||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE =
|
||||
new ParameterizedTypeReference<
|
||||
TaskanaPagedModel<ClassificationSummaryRepresentationModel>>() {};
|
||||
static RestTemplate template = RestHelper.TEMPLATE;
|
||||
@Autowired RestHelper restHelper;
|
||||
|
||||
@Test
|
||||
void testGetClassification() {
|
||||
ResponseEntity<ClassificationResource> response =
|
||||
ResponseEntity<ClassificationRepresentationModel> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(
|
||||
Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000002"),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationResource.class));
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getHeaders().getContentType().toString())
|
||||
.isEqualTo(MediaTypes.HAL_JSON_VALUE);
|
||||
|
|
@ -50,36 +55,36 @@ class ClassificationControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testGetAllClassifications() {
|
||||
ResponseEntity<ClassificationSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetAllClassificationsFilterByCustomAttribute() {
|
||||
ResponseEntity<ClassificationSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?domain=DOMAIN_A&custom-1-like=RVNR",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(13);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetAllClassificationsKeepingFilters() {
|
||||
ResponseEntity<ClassificationSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS)
|
||||
+ "?domain=DOMAIN_A&sort-by=key&order=asc",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
|
|
@ -94,13 +99,13 @@ class ClassificationControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testGetSecondPageSortedByKey() {
|
||||
ResponseEntity<ClassificationSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS)
|
||||
+ "?domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody().getContent()).hasSize(5);
|
||||
assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("L1050");
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
|
|
@ -111,7 +116,7 @@ class ClassificationControllerIntTest {
|
|||
.getHref()
|
||||
.endsWith(
|
||||
"/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();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull();
|
||||
|
|
@ -127,12 +132,12 @@ class ClassificationControllerIntTest {
|
|||
+ "\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\","
|
||||
+ "\"name\":\"new classification\",\"type\":\"TASK\"}";
|
||||
|
||||
ResponseEntity<ClassificationResource> responseEntity =
|
||||
ResponseEntity<ClassificationRepresentationModel> responseEntity =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(newClassification, restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(ClassificationResource.class));
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode());
|
||||
|
|
@ -147,7 +152,7 @@ class ClassificationControllerIntTest {
|
|||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(newClassification, restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(ClassificationResource.class));
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
|
||||
assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode());
|
||||
}
|
||||
|
|
@ -161,12 +166,12 @@ class ClassificationControllerIntTest {
|
|||
+ "\"name\":\"new classification\",\"type\":\"TASK\","
|
||||
+ "\"parentId\":\"CLI:200000000000000000000000000000000015\"}";
|
||||
|
||||
ResponseEntity<ClassificationResource> responseEntity =
|
||||
ResponseEntity<ClassificationRepresentationModel> responseEntity =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(newClassification, restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(ClassificationResource.class));
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode());
|
||||
|
|
@ -181,12 +186,12 @@ class ClassificationControllerIntTest {
|
|||
+ "\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\","
|
||||
+ "\"type\":\"TASK\",\"parentKey\":\"T2100\"}";
|
||||
|
||||
ResponseEntity<ClassificationResource> responseEntity =
|
||||
ResponseEntity<ClassificationRepresentationModel> responseEntity =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(newClassification, restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(ClassificationResource.class));
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode());
|
||||
|
|
@ -200,25 +205,26 @@ class ClassificationControllerIntTest {
|
|||
+ "\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\","
|
||||
+ "\"type\":\"TASK\",\"parentKey\":\"T2100\"}";
|
||||
|
||||
ResponseEntity<ClassificationResource> responseEntity =
|
||||
ResponseEntity<ClassificationRepresentationModel> responseEntity =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(newClassification, restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(ClassificationResource.class));
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode());
|
||||
|
||||
ResponseEntity<ClassificationSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
boolean foundClassificationCreated = false;
|
||||
for (ClassificationSummaryResource classification : response.getBody().getContent()) {
|
||||
for (ClassificationSummaryRepresentationModel classification :
|
||||
response.getBody().getContent()) {
|
||||
if ("NEW_CLASS_P2".equals(classification.getKey())
|
||||
&& "".equals(classification.getDomain())
|
||||
&& "T2100".equals(classification.getParentKey())) {
|
||||
|
|
@ -245,7 +251,7 @@ class ClassificationControllerIntTest {
|
|||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(newClassification, restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(ClassificationResource.class));
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
};
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
|
|
@ -267,7 +273,7 @@ class ClassificationControllerIntTest {
|
|||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(newClassification, restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(ClassificationResource.class));
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
};
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
|
|
@ -279,13 +285,13 @@ class ClassificationControllerIntTest {
|
|||
void testGetClassificationWithSpecialCharacter() {
|
||||
|
||||
HttpEntity<String> request = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
ResponseEntity<ClassificationSummaryResource> response =
|
||||
ResponseEntity<ClassificationSummaryRepresentationModel> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(
|
||||
Mapping.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009"),
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryResource.class));
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryRepresentationModel.class));
|
||||
assertThat(response.getBody().getName()).isEqualTo("Zustimmungserklärung");
|
||||
}
|
||||
|
||||
|
|
@ -294,13 +300,13 @@ class ClassificationControllerIntTest {
|
|||
void testDeleteClassification() {
|
||||
HttpEntity<String> request = new HttpEntity<>(restHelper.getHeaders());
|
||||
|
||||
ResponseEntity<ClassificationSummaryResource> response =
|
||||
ResponseEntity<ClassificationSummaryRepresentationModel> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(
|
||||
Mapping.URL_CLASSIFICATIONS_ID, "CLI:200000000000000000000000000000000004"),
|
||||
HttpMethod.DELETE,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryResource.class));
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryRepresentationModel.class));
|
||||
assertThat(HttpStatus.NO_CONTENT).isEqualTo(response.getStatusCode());
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
|
||||
|
|
@ -311,7 +317,7 @@ class ClassificationControllerIntTest {
|
|||
Mapping.URL_CLASSIFICATIONS_ID, "CLI:200000000000000000000000000000000004"),
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryResource.class));
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryRepresentationModel.class));
|
||||
};
|
||||
assertThatThrownBy(httpCall).isInstanceOf(HttpClientErrorException.class);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,14 +31,19 @@ import org.springframework.web.client.RestTemplate;
|
|||
|
||||
import pro.taskana.RestHelper;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.rest.resource.ClassificationResource;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryListResource;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryResource;
|
||||
import pro.taskana.rest.resource.ClassificationRepresentationModel;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryRepresentationModel;
|
||||
import pro.taskana.rest.resource.TaskanaPagedModel;
|
||||
|
||||
/** Test classification definitions. */
|
||||
@TaskanaSpringBootTest
|
||||
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 RestTemplate template;
|
||||
@Autowired RestHelper restHelper;
|
||||
|
|
@ -51,32 +56,32 @@ class ClassificationDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testExportClassifications() {
|
||||
ResponseEntity<ClassificationResource[]> response =
|
||||
ResponseEntity<ClassificationRepresentationModel[]> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONDEFINITION) + "?domain=DOMAIN_B",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationResource[].class));
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel[].class));
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(response.getBody().length >= 5).isTrue();
|
||||
assertThat(response.getBody().length <= 7).isTrue();
|
||||
assertThat(response.getBody()[0]).isInstanceOf(ClassificationResource.class);
|
||||
assertThat(response.getBody()[0]).isInstanceOf(ClassificationRepresentationModel.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExportClassificationsFromWrongDomain() {
|
||||
ResponseEntity<ClassificationResource[]> response =
|
||||
ResponseEntity<ClassificationRepresentationModel[]> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONDEFINITION) + "?domain=ADdfe",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationResource[].class));
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel[].class));
|
||||
assertThat(response.getBody()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testImportFilledClassification() throws IOException {
|
||||
ClassificationResource classification = new ClassificationResource();
|
||||
ClassificationRepresentationModel classification = new ClassificationRepresentationModel();
|
||||
classification.setClassificationId("classificationId_");
|
||||
classification.setKey("key drelf");
|
||||
classification.setParentId("CLI:100000000000000000000000000000000016");
|
||||
|
|
@ -110,7 +115,7 @@ class ClassificationDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testFailureWhenKeyIsMissing() throws IOException {
|
||||
ClassificationResource classification = new ClassificationResource();
|
||||
ClassificationRepresentationModel classification = new ClassificationRepresentationModel();
|
||||
classification.setDomain("DOMAIN_A");
|
||||
List<String> clList = new ArrayList<>();
|
||||
clList.add(objMapper.writeValueAsString(classification));
|
||||
|
|
@ -124,7 +129,7 @@ class ClassificationDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testFailureWhenDomainIsMissing() throws IOException {
|
||||
ClassificationResource classification = new ClassificationResource();
|
||||
ClassificationRepresentationModel classification = new ClassificationRepresentationModel();
|
||||
classification.setKey("one");
|
||||
List<String> clList = new ArrayList<>();
|
||||
clList.add(objMapper.writeValueAsString(classification));
|
||||
|
|
@ -138,7 +143,7 @@ class ClassificationDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testFailureWhenUpdatingTypeOfExistingClassification() throws IOException {
|
||||
ClassificationSummaryResource classification =
|
||||
ClassificationSummaryRepresentationModel classification =
|
||||
this.getClassificationWithKeyAndDomain("T6310", "");
|
||||
classification.setType("DOCUMENT");
|
||||
List<String> clList = new ArrayList<>();
|
||||
|
|
@ -153,11 +158,11 @@ class ClassificationDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testImportMultipleClassifications() throws IOException {
|
||||
ClassificationResource classification1 =
|
||||
ClassificationRepresentationModel classification1 =
|
||||
this.createClassification("id1", "ImportKey1", "DOMAIN_A", null, null);
|
||||
final String c1 = objMapper.writeValueAsString(classification1);
|
||||
|
||||
ClassificationResource classification2 =
|
||||
ClassificationRepresentationModel classification2 =
|
||||
this.createClassification(
|
||||
"id2", "ImportKey2", "DOMAIN_A", "CLI:100000000000000000000000000000000016", "T2000");
|
||||
classification2.setCategory("MANUAL");
|
||||
|
|
@ -182,7 +187,7 @@ class ClassificationDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testImportDuplicateClassification() throws IOException {
|
||||
ClassificationResource classification1 = new ClassificationResource();
|
||||
ClassificationRepresentationModel classification1 = new ClassificationRepresentationModel();
|
||||
classification1.setClassificationId("id1");
|
||||
classification1.setKey("ImportKey3");
|
||||
classification1.setDomain("DOMAIN_A");
|
||||
|
|
@ -201,7 +206,7 @@ class ClassificationDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testInsertExistingClassificationWithOlderTimestamp() throws IOException {
|
||||
ClassificationSummaryResource existingClassification =
|
||||
ClassificationSummaryRepresentationModel existingClassification =
|
||||
getClassificationWithKeyAndDomain("L110107", "DOMAIN_A");
|
||||
existingClassification.setName("first new Name");
|
||||
List<String> clList = new ArrayList<>();
|
||||
|
|
@ -217,16 +222,16 @@ class ClassificationDefinitionControllerIntTest {
|
|||
response = importRequest(clList);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
|
||||
ClassificationSummaryResource testClassification =
|
||||
ClassificationSummaryRepresentationModel testClassification =
|
||||
this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A");
|
||||
assertThat(testClassification.getName()).isEqualTo("second new Name");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHookExistingChildToNewParent() throws IOException {
|
||||
final ClassificationResource newClassification =
|
||||
final ClassificationRepresentationModel newClassification =
|
||||
createClassification("new Classification", "newClass", "DOMAIN_A", null, "L11010");
|
||||
ClassificationSummaryResource existingClassification =
|
||||
ClassificationSummaryRepresentationModel existingClassification =
|
||||
getClassificationWithKeyAndDomain("L110102", "DOMAIN_A");
|
||||
existingClassification.setParentId("new Classification");
|
||||
existingClassification.setParentKey("newClass");
|
||||
|
|
@ -238,11 +243,11 @@ class ClassificationDefinitionControllerIntTest {
|
|||
ResponseEntity<Void> response = importRequest(clList);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
|
||||
ClassificationSummaryResource parentCl =
|
||||
ClassificationSummaryRepresentationModel parentCl =
|
||||
getClassificationWithKeyAndDomain("L11010", "DOMAIN_A");
|
||||
ClassificationSummaryResource testNewCl =
|
||||
ClassificationSummaryRepresentationModel testNewCl =
|
||||
getClassificationWithKeyAndDomain("newClass", "DOMAIN_A");
|
||||
ClassificationSummaryResource testExistingCl =
|
||||
ClassificationSummaryRepresentationModel testExistingCl =
|
||||
getClassificationWithKeyAndDomain("L110102", "DOMAIN_A");
|
||||
|
||||
assertThat(parentCl).isNotNull();
|
||||
|
|
@ -254,18 +259,18 @@ class ClassificationDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testImportParentAndChildClassification() throws IOException {
|
||||
ClassificationResource classification1 =
|
||||
ClassificationRepresentationModel classification1 =
|
||||
this.createClassification("parentId", "ImportKey6", "DOMAIN_A", null, null);
|
||||
final String c1 = objMapper.writeValueAsString(classification1);
|
||||
|
||||
ClassificationResource classification2 =
|
||||
ClassificationRepresentationModel classification2 =
|
||||
this.createClassification("childId1", "ImportKey7", "DOMAIN_A", null, "ImportKey6");
|
||||
final String c21 = objMapper.writeValueAsString(classification2);
|
||||
classification2 =
|
||||
this.createClassification("childId2", "ImportKey8", "DOMAIN_A", "parentId", null);
|
||||
final String c22 = objMapper.writeValueAsString(classification2);
|
||||
|
||||
ClassificationResource classification3 =
|
||||
ClassificationRepresentationModel classification3 =
|
||||
this.createClassification(
|
||||
"grandchildId1", "ImportKey9", "DOMAIN_A", "childId1", "ImportKey7");
|
||||
final String c31 = objMapper.writeValueAsString(classification3);
|
||||
|
|
@ -283,11 +288,11 @@ class ClassificationDefinitionControllerIntTest {
|
|||
ResponseEntity<Void> response = importRequest(clList);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
|
||||
ClassificationSummaryResource parentCl =
|
||||
ClassificationSummaryRepresentationModel parentCl =
|
||||
getClassificationWithKeyAndDomain("ImportKey6", "DOMAIN_A");
|
||||
ClassificationSummaryResource childCl =
|
||||
ClassificationSummaryRepresentationModel childCl =
|
||||
getClassificationWithKeyAndDomain("ImportKey7", "DOMAIN_A");
|
||||
ClassificationSummaryResource grandchildCl =
|
||||
ClassificationSummaryRepresentationModel grandchildCl =
|
||||
getClassificationWithKeyAndDomain("ImportKey9", "DOMAIN_A");
|
||||
|
||||
assertThat(parentCl).isNotNull();
|
||||
|
|
@ -299,14 +304,14 @@ class ClassificationDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testImportParentAndChildClassificationWithKey() throws IOException {
|
||||
ClassificationResource classification1 =
|
||||
ClassificationRepresentationModel classification1 =
|
||||
createClassification("parent", "ImportKey11", "DOMAIN_A", null, null);
|
||||
classification1.setCustom1("parent is correct");
|
||||
String parent = objMapper.writeValueAsString(classification1);
|
||||
ClassificationResource classification2 =
|
||||
ClassificationRepresentationModel classification2 =
|
||||
createClassification("wrongParent", "ImportKey11", "DOMAIN_B", null, null);
|
||||
String wrongParent = objMapper.writeValueAsString(classification2);
|
||||
ClassificationResource classification3 =
|
||||
ClassificationRepresentationModel classification3 =
|
||||
createClassification("child", "ImportKey13", "DOMAIN_A", null, "ImportKey11");
|
||||
String child = objMapper.writeValueAsString(classification3);
|
||||
|
||||
|
|
@ -318,11 +323,11 @@ class ClassificationDefinitionControllerIntTest {
|
|||
ResponseEntity<Void> response = importRequest(clList);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
|
||||
ClassificationSummaryResource rightParentCl =
|
||||
ClassificationSummaryRepresentationModel rightParentCl =
|
||||
getClassificationWithKeyAndDomain("ImportKey11", "DOMAIN_A");
|
||||
ClassificationSummaryResource wrongParentCl =
|
||||
ClassificationSummaryRepresentationModel wrongParentCl =
|
||||
getClassificationWithKeyAndDomain("ImportKey11", "DOMAIN_B");
|
||||
ClassificationSummaryResource childCl =
|
||||
ClassificationSummaryRepresentationModel childCl =
|
||||
getClassificationWithKeyAndDomain("ImportKey13", "DOMAIN_A");
|
||||
|
||||
assertThat(rightParentCl).isNotNull();
|
||||
|
|
@ -335,14 +340,14 @@ class ClassificationDefinitionControllerIntTest {
|
|||
@Test
|
||||
void testChangeParentByImportingExistingClassification()
|
||||
throws IOException, InterruptedException {
|
||||
ClassificationSummaryResource child1 =
|
||||
ClassificationSummaryRepresentationModel child1 =
|
||||
this.getClassificationWithKeyAndDomain("L110105", "DOMAIN_A");
|
||||
assertThat(child1.getParentKey()).isEqualTo("L11010");
|
||||
child1.setParentId("CLI:100000000000000000000000000000000002");
|
||||
child1.setParentKey("L10303");
|
||||
final String withNewParent = objMapper.writeValueAsString(child1);
|
||||
|
||||
ClassificationSummaryResource child2 =
|
||||
ClassificationSummaryRepresentationModel child2 =
|
||||
this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A");
|
||||
assertThat(child2.getParentKey()).isEqualTo("L11010");
|
||||
child2.setParentId("");
|
||||
|
|
@ -358,11 +363,11 @@ class ClassificationDefinitionControllerIntTest {
|
|||
Thread.sleep(10);
|
||||
LOGGER.debug("Wait 10 ms to give the system a chance to update");
|
||||
|
||||
ClassificationSummaryResource childWithNewParent =
|
||||
ClassificationSummaryRepresentationModel childWithNewParent =
|
||||
this.getClassificationWithKeyAndDomain("L110105", "DOMAIN_A");
|
||||
assertThat(childWithNewParent.getParentKey()).isEqualTo(child1.getParentKey());
|
||||
|
||||
ClassificationSummaryResource childWithoutParent =
|
||||
ClassificationSummaryRepresentationModel childWithoutParent =
|
||||
this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A");
|
||||
assertThat(childWithoutParent.getParentId()).isEqualTo(child2.getParentId());
|
||||
assertThat(childWithoutParent.getParentKey()).isEqualTo(child2.getParentKey());
|
||||
|
|
@ -370,7 +375,7 @@ class ClassificationDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testFailOnImportDuplicates() throws IOException {
|
||||
ClassificationSummaryResource classification =
|
||||
ClassificationSummaryRepresentationModel classification =
|
||||
this.getClassificationWithKeyAndDomain("L110105", "DOMAIN_A");
|
||||
String classificationString = objMapper.writeValueAsString(classification);
|
||||
|
||||
|
|
@ -384,28 +389,32 @@ class ClassificationDefinitionControllerIntTest {
|
|||
.isEqualTo(HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
private ClassificationResource createClassification(
|
||||
private ClassificationRepresentationModel createClassification(
|
||||
String id, String key, String domain, String parentId, String parentKey) {
|
||||
ClassificationResource classificationResource = new ClassificationResource();
|
||||
classificationResource.setClassificationId(id);
|
||||
classificationResource.setKey(key);
|
||||
classificationResource.setDomain(domain);
|
||||
classificationResource.setParentId(parentId);
|
||||
classificationResource.setParentKey(parentKey);
|
||||
return classificationResource;
|
||||
ClassificationRepresentationModel classificationRepresentationModel =
|
||||
new ClassificationRepresentationModel();
|
||||
classificationRepresentationModel.setClassificationId(id);
|
||||
classificationRepresentationModel.setKey(key);
|
||||
classificationRepresentationModel.setDomain(domain);
|
||||
classificationRepresentationModel.setParentId(parentId);
|
||||
classificationRepresentationModel.setParentKey(parentKey);
|
||||
return classificationRepresentationModel;
|
||||
}
|
||||
|
||||
private ClassificationSummaryResource getClassificationWithKeyAndDomain(
|
||||
private ClassificationSummaryRepresentationModel getClassificationWithKeyAndDomain(
|
||||
String key, String domain) {
|
||||
LOGGER.debug("Request classification with key={} in domain={}", key, domain);
|
||||
HttpEntity<String> request = new HttpEntity<>(restHelper.getHeaders());
|
||||
ResponseEntity<ClassificationSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<ClassificationSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?key=" + key + "&domain=" + domain,
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
return response.getBody().getContent().toArray(new ClassificationSummaryResource[1])[0];
|
||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||
return response
|
||||
.getBody()
|
||||
.getContent()
|
||||
.toArray(new ClassificationSummaryRepresentationModel[1])[0];
|
||||
}
|
||||
|
||||
private ResponseEntity<Void> importRequest(List<String> clList) throws IOException {
|
||||
|
|
|
|||
|
|
@ -13,12 +13,18 @@ import org.springframework.web.client.RestTemplate;
|
|||
|
||||
import pro.taskana.RestHelper;
|
||||
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. */
|
||||
@TaskanaSpringBootTest
|
||||
class GeneralExceptionHandlingTest {
|
||||
|
||||
private static final ParameterizedTypeReference<
|
||||
TaskanaPagedModel<ClassificationSummaryRepresentationModel>>
|
||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE =
|
||||
new ParameterizedTypeReference<
|
||||
TaskanaPagedModel<ClassificationSummaryRepresentationModel>>() {};
|
||||
private static RestTemplate template;
|
||||
@Autowired RestHelper restHelper;
|
||||
|
||||
|
|
@ -35,7 +41,7 @@ class GeneralExceptionHandlingTest {
|
|||
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS_ID, "non-existing-id"),
|
||||
HttpMethod.DELETE,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
|
||||
CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||
};
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
|
|
|
|||
|
|
@ -22,13 +22,16 @@ import org.springframework.web.client.RestTemplate;
|
|||
|
||||
import pro.taskana.RestHelper;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.rest.resource.TaskCommentListResource;
|
||||
import pro.taskana.rest.resource.TaskCommentResource;
|
||||
import pro.taskana.rest.resource.TaskCommentRepresentationModel;
|
||||
import pro.taskana.rest.resource.TaskanaPagedModel;
|
||||
|
||||
/** Test TaskCommentController. */
|
||||
@TaskanaSpringBootTest
|
||||
class TaskCommentControllerIntTest {
|
||||
|
||||
private static final ParameterizedTypeReference<TaskanaPagedModel<TaskCommentRepresentationModel>>
|
||||
TASK_COMMENT_PAGE_MODEL_TYPE =
|
||||
new ParameterizedTypeReference<TaskanaPagedModel<TaskCommentRepresentationModel>>() {};
|
||||
private static RestTemplate template;
|
||||
|
||||
@Value("${taskana.schemaName:TASKANA}")
|
||||
|
|
@ -53,7 +56,7 @@ class TaskCommentControllerIntTest {
|
|||
urlToNonExistingTaskComment,
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeadersAdmin()),
|
||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||
ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
|
||||
};
|
||||
assertThatThrownBy(httpCall)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
|
|
@ -73,7 +76,7 @@ class TaskCommentControllerIntTest {
|
|||
urlToNotVisibleTask,
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeadersUser_1_1()),
|
||||
ParameterizedTypeReference.forType(TaskCommentListResource.class));
|
||||
TASK_COMMENT_PAGE_MODEL_TYPE);
|
||||
};
|
||||
assertThatThrownBy(httpCall)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
|
|
@ -93,7 +96,7 @@ class TaskCommentControllerIntTest {
|
|||
urlToNotVisibleTask,
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeadersUser_1_2()),
|
||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||
ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
|
||||
};
|
||||
assertThatThrownBy(httpCall)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
|
|
@ -104,9 +107,10 @@ class TaskCommentControllerIntTest {
|
|||
@Test
|
||||
void should_FailToCreateTaskComment_When_TaskIsNotVisible() {
|
||||
|
||||
TaskCommentResource taskCommentResourceToCreate = new TaskCommentResource();
|
||||
taskCommentResourceToCreate.setTaskId("TKI:000000000000000000000000000000000000");
|
||||
taskCommentResourceToCreate.setTextField("newly created task comment");
|
||||
TaskCommentRepresentationModel taskCommentRepresentationModelToCreate =
|
||||
new TaskCommentRepresentationModel();
|
||||
taskCommentRepresentationModelToCreate.setTaskId("TKI:000000000000000000000000000000000000");
|
||||
taskCommentRepresentationModelToCreate.setTextField("newly created task comment");
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
|
@ -114,8 +118,9 @@ class TaskCommentControllerIntTest {
|
|||
restHelper.toUrl(
|
||||
Mapping.URL_TASK_GET_POST_COMMENTS, "TKI:000000000000000000000000000000000000"),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(taskCommentResourceToCreate, restHelper.getHeadersUser_1_1()),
|
||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||
new HttpEntity<>(
|
||||
taskCommentRepresentationModelToCreate, restHelper.getHeadersUser_1_1()),
|
||||
ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
|
||||
};
|
||||
assertThatThrownBy(httpCall)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
|
|
@ -125,17 +130,19 @@ class TaskCommentControllerIntTest {
|
|||
@Test
|
||||
void should_FailToCreateTaskComment_When_TaskIdIsNonExisting() {
|
||||
|
||||
TaskCommentResource taskCommentResourceToCreate = new TaskCommentResource();
|
||||
taskCommentResourceToCreate.setTaskId("DefinatelyNotExistingId");
|
||||
taskCommentResourceToCreate.setTextField("newly created task comment");
|
||||
TaskCommentRepresentationModel taskCommentRepresentationModelToCreate =
|
||||
new TaskCommentRepresentationModel();
|
||||
taskCommentRepresentationModelToCreate.setTaskId("DefinatelyNotExistingId");
|
||||
taskCommentRepresentationModelToCreate.setTextField("newly created task comment");
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASK_GET_POST_COMMENTS, "DefinatelyNotExistingId"),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(taskCommentResourceToCreate, restHelper.getHeadersAdmin()),
|
||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||
new HttpEntity<>(
|
||||
taskCommentRepresentationModelToCreate, restHelper.getHeadersAdmin()),
|
||||
ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
|
||||
};
|
||||
assertThatThrownBy(httpCall)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
|
|
@ -150,18 +157,19 @@ class TaskCommentControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000");
|
||||
|
||||
ResponseEntity<TaskCommentResource> getTaskCommentResponse =
|
||||
ResponseEntity<TaskCommentRepresentationModel> getTaskCommentResponse =
|
||||
template.exchange(
|
||||
url,
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeadersAdmin()),
|
||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||
ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
|
||||
assertThat(getTaskCommentResponse.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(getTaskCommentResponse.getBody().getCreator()).isEqualTo("user_1_1");
|
||||
assertThat(getTaskCommentResponse.getBody().getTextField()).isEqualTo("some text in textfield");
|
||||
|
||||
TaskCommentResource taskCommentResourceToUpdate = getTaskCommentResponse.getBody();
|
||||
taskCommentResourceToUpdate.setModified(Instant.now().toString());
|
||||
TaskCommentRepresentationModel taskCommentRepresentationModelToUpdate =
|
||||
getTaskCommentResponse.getBody();
|
||||
taskCommentRepresentationModelToUpdate.setModified(Instant.now().toString());
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
|
@ -169,9 +177,9 @@ class TaskCommentControllerIntTest {
|
|||
url,
|
||||
HttpMethod.PUT,
|
||||
new HttpEntity<>(
|
||||
mapper.writeValueAsString(taskCommentResourceToUpdate),
|
||||
mapper.writeValueAsString(taskCommentRepresentationModelToUpdate),
|
||||
restHelper.getHeadersUser_1_1()),
|
||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||
ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
|
||||
};
|
||||
assertThatThrownBy(httpCall)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
|
|
@ -187,18 +195,19 @@ class TaskCommentControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000");
|
||||
|
||||
ResponseEntity<TaskCommentResource> getTaskCommentResponse =
|
||||
ResponseEntity<TaskCommentRepresentationModel> getTaskCommentResponse =
|
||||
template.exchange(
|
||||
url,
|
||||
HttpMethod.GET,
|
||||
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().getCreator()).isEqualTo("user_1_1");
|
||||
assertThat(getTaskCommentResponse.getBody().getTextField()).isEqualTo("some text in textfield");
|
||||
|
||||
TaskCommentResource taskCommentResourceToUpdate = getTaskCommentResponse.getBody();
|
||||
taskCommentResourceToUpdate.setTextField("updated textfield");
|
||||
TaskCommentRepresentationModel taskCommentRepresentationModelToUpdate =
|
||||
getTaskCommentResponse.getBody();
|
||||
taskCommentRepresentationModelToUpdate.setTextField("updated textfield");
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
|
@ -206,15 +215,15 @@ class TaskCommentControllerIntTest {
|
|||
url,
|
||||
HttpMethod.PUT,
|
||||
new HttpEntity<>(
|
||||
mapper.writeValueAsString(taskCommentResourceToUpdate),
|
||||
mapper.writeValueAsString(taskCommentRepresentationModelToUpdate),
|
||||
restHelper.getHeadersUser_1_2()),
|
||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||
ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
|
||||
};
|
||||
assertThatThrownBy(httpCall)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.isEqualTo(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void should_FailToUpdateTaskComment_When_TaskCommentIdInResourceDoesNotMatchPathVariable() {
|
||||
|
||||
|
|
@ -223,19 +232,20 @@ class TaskCommentControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(Mapping.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000");
|
||||
|
||||
ResponseEntity<TaskCommentResource> getTaskCommentResponse =
|
||||
ResponseEntity<TaskCommentRepresentationModel> getTaskCommentResponse =
|
||||
template.exchange(
|
||||
url,
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeadersAdmin()),
|
||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||
ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
|
||||
assertThat(getTaskCommentResponse.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(getTaskCommentResponse.getBody().getCreator()).isEqualTo("user_1_1");
|
||||
assertThat(getTaskCommentResponse.getBody().getTextField()).isEqualTo("some text in textfield");
|
||||
|
||||
TaskCommentResource taskCommentResourceToUpdate = getTaskCommentResponse.getBody();
|
||||
taskCommentResourceToUpdate.setTextField("updated text");
|
||||
taskCommentResourceToUpdate.setTaskCommentId("DifferentTaskCommentId");
|
||||
TaskCommentRepresentationModel taskCommentRepresentationModelToUpdate =
|
||||
getTaskCommentResponse.getBody();
|
||||
taskCommentRepresentationModelToUpdate.setTextField("updated text");
|
||||
taskCommentRepresentationModelToUpdate.setTaskCommentId("DifferentTaskCommentId");
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
|
@ -243,9 +253,9 @@ class TaskCommentControllerIntTest {
|
|||
url,
|
||||
HttpMethod.PUT,
|
||||
new HttpEntity<>(
|
||||
mapper.writeValueAsString(taskCommentResourceToUpdate),
|
||||
mapper.writeValueAsString(taskCommentRepresentationModelToUpdate),
|
||||
restHelper.getHeadersUser_1_1()),
|
||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||
ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
|
||||
};
|
||||
assertThatThrownBy(httpCall)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
|
|
@ -256,12 +266,14 @@ class TaskCommentControllerIntTest {
|
|||
@Test
|
||||
void should_FailToDeleteTaskComment_When_UserHasNoAuthorization() {
|
||||
|
||||
ResponseEntity<TaskCommentListResource> getTaskCommentsBeforeDeleteionResponse =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000001"),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeadersAdmin()),
|
||||
ParameterizedTypeReference.forType(TaskCommentListResource.class));
|
||||
ResponseEntity<TaskanaPagedModel<TaskCommentRepresentationModel>>
|
||||
getTaskCommentsBeforeDeleteionResponse =
|
||||
template.exchange(
|
||||
restHelper.toUrl(
|
||||
Mapping.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000001"),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeadersAdmin()),
|
||||
TASK_COMMENT_PAGE_MODEL_TYPE);
|
||||
assertThat(getTaskCommentsBeforeDeleteionResponse.getBody().getContent()).hasSize(2);
|
||||
|
||||
String url =
|
||||
|
|
@ -273,7 +285,7 @@ class TaskCommentControllerIntTest {
|
|||
url,
|
||||
HttpMethod.DELETE,
|
||||
new HttpEntity<String>(restHelper.getHeadersUser_1_2()),
|
||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||
ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
|
||||
};
|
||||
assertThatThrownBy(httpCall)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
|
|
@ -291,7 +303,7 @@ class TaskCommentControllerIntTest {
|
|||
url,
|
||||
HttpMethod.DELETE,
|
||||
new HttpEntity<String>(restHelper.getHeadersAdmin()),
|
||||
ParameterizedTypeReference.forType(TaskCommentResource.class));
|
||||
ParameterizedTypeReference.forType(TaskCommentRepresentationModel.class));
|
||||
};
|
||||
assertThatThrownBy(httpCall)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
|
|
|
|||
|
|
@ -34,10 +34,11 @@ import org.springframework.web.client.RestTemplate;
|
|||
|
||||
import pro.taskana.RestHelper;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryResource;
|
||||
import pro.taskana.rest.resource.TaskResource;
|
||||
import pro.taskana.rest.resource.TaskSummaryListResource;
|
||||
import pro.taskana.rest.resource.WorkbasketSummaryResource;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryRepresentationModel;
|
||||
import pro.taskana.rest.resource.TaskRepresentationModel;
|
||||
import pro.taskana.rest.resource.TaskSummaryRepresentationModel;
|
||||
import pro.taskana.rest.resource.TaskanaPagedModel;
|
||||
import pro.taskana.rest.resource.WorkbasketSummaryRepresentationModel;
|
||||
import pro.taskana.sampledata.SampleDataGenerator;
|
||||
import pro.taskana.task.api.TaskState;
|
||||
import pro.taskana.task.api.models.ObjectReference;
|
||||
|
|
@ -46,6 +47,9 @@ import pro.taskana.task.api.models.ObjectReference;
|
|||
@TaskanaSpringBootTest
|
||||
class TaskControllerIntTest {
|
||||
|
||||
private static final ParameterizedTypeReference<TaskanaPagedModel<TaskSummaryRepresentationModel>>
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE =
|
||||
new ParameterizedTypeReference<TaskanaPagedModel<TaskSummaryRepresentationModel>>() {};
|
||||
private static RestTemplate template;
|
||||
|
||||
@Value("${taskana.schemaName:TASKANA}")
|
||||
|
|
@ -67,26 +71,30 @@ class TaskControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testGetAllTasks() {
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
|
||||
.isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(25);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetAllTasksByWorkbasketId() {
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?workbasket-id=WBI:100000000000000000000000000000000001",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
|
||||
.isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(22);
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +106,7 @@ class TaskControllerIntTest {
|
|||
Instant thirdInstant = Instant.now().minus(10, ChronoUnit.DAYS);
|
||||
Instant fourthInstant = Instant.now().minus(11, ChronoUnit.DAYS);
|
||||
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
|
||||
|
|
@ -114,8 +122,10 @@ class TaskControllerIntTest {
|
|||
+ "&sort-by=planned",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
|
||||
.isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(6);
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +135,7 @@ class TaskControllerIntTest {
|
|||
Instant plannedFromInstant = Instant.now().minus(6, ChronoUnit.DAYS);
|
||||
Instant plannedToInstant = Instant.now().minus(3, ChronoUnit.DAYS);
|
||||
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
|
||||
|
|
@ -136,8 +146,10 @@ class TaskControllerIntTest {
|
|||
+ "&sort-by=planned",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
|
||||
.isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(3);
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +158,7 @@ class TaskControllerIntTest {
|
|||
|
||||
Instant plannedFromInstant = Instant.now().minus(6, ChronoUnit.DAYS);
|
||||
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
|
||||
|
|
@ -155,27 +167,27 @@ class TaskControllerIntTest {
|
|||
+ "&sort-by=planned",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
|
||||
.isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetAllTasksByWorkbasketIdWithInvalidPlannedParamsCombination() {
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
|
||||
+ "&planned=2020-01-22T09:44:47.453Z,,"
|
||||
+ "2020-01-19T07:44:47.453Z,2020-01-19T19:44:47.453Z,"
|
||||
+ ",2020-01-18T09:44:47.453Z"
|
||||
+ "&planned-from=2020-01-19T07:44:47.453Z"
|
||||
+ "&sort-by=planned",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
};
|
||||
() -> template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
|
||||
+ "&planned=2020-01-22T09:44:47.453Z,,"
|
||||
+ "2020-01-19T07:44:47.453Z,2020-01-19T19:44:47.453Z,"
|
||||
+ ",2020-01-18T09:44:47.453Z"
|
||||
+ "&planned-from=2020-01-19T07:44:47.453Z"
|
||||
+ "&sort-by=planned",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("400");
|
||||
|
|
@ -189,7 +201,7 @@ class TaskControllerIntTest {
|
|||
Instant thirdInstant = Instant.now().minus(10, ChronoUnit.DAYS);
|
||||
Instant fourthInstant = Instant.now().minus(11, ChronoUnit.DAYS);
|
||||
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
|
||||
|
|
@ -205,22 +217,26 @@ class TaskControllerIntTest {
|
|||
+ "&sort-by=due",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
|
||||
.isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(6);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_ReturnAllTasksByWildcardSearch_For_ProvidedSearchValue() {
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?wildcard-search-value=%99%"
|
||||
+ "&wildcard-search-fields=NAME,custom_3,CuStOM_4",
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeadersAdmin()),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
|
||||
.isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(4);
|
||||
}
|
||||
|
||||
|
|
@ -228,13 +244,11 @@ class TaskControllerIntTest {
|
|||
void should_ThrowException_When_ProvidingInvalidWildcardSearchParameters() {
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS) + "?wildcard-search-value=%rt%",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
};
|
||||
() -> template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS) + "?wildcard-search-value=%rt%",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("400")
|
||||
|
|
@ -242,14 +256,12 @@ class TaskControllerIntTest {
|
|||
.isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
|
||||
ThrowingCallable httpCall2 =
|
||||
() -> {
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?wildcard-search-fields=NAME,CUSTOM_3,CUSTOM_4",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
};
|
||||
() -> template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?wildcard-search-fields=NAME,CUSTOM_3,CUSTOM_4",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall2)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("400")
|
||||
|
|
@ -263,7 +275,7 @@ class TaskControllerIntTest {
|
|||
Instant dueFromInstant = Instant.now().minus(8, ChronoUnit.DAYS);
|
||||
Instant dueToInstant = Instant.now().minus(3, ChronoUnit.DAYS);
|
||||
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
|
||||
|
|
@ -274,8 +286,10 @@ class TaskControllerIntTest {
|
|||
+ "&sort-by=due",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
|
||||
.isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(9);
|
||||
}
|
||||
|
||||
|
|
@ -284,7 +298,7 @@ class TaskControllerIntTest {
|
|||
|
||||
Instant dueToInstant = Instant.now().minus(1, ChronoUnit.DAYS);
|
||||
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
|
||||
|
|
@ -293,27 +307,27 @@ class TaskControllerIntTest {
|
|||
+ "&sort-by=due",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
|
||||
.isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(6);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetAllTasksByWorkbasketIdWithInvalidDueParamsCombination() {
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
|
||||
+ "&due=2020-01-22T09:44:47.453Z,,"
|
||||
+ "2020-01-19T07:44:47.453Z,2020-01-19T19:44:47.453Z,"
|
||||
+ ",2020-01-18T09:44:47.453Z"
|
||||
+ "&due-from=2020-01-19T07:44:47.453Z"
|
||||
+ "&sort-by=planned",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
};
|
||||
() -> template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
|
||||
+ "&due=2020-01-22T09:44:47.453Z,,"
|
||||
+ "2020-01-19T07:44:47.453Z,2020-01-19T19:44:47.453Z,"
|
||||
+ ",2020-01-18T09:44:47.453Z"
|
||||
+ "&due-from=2020-01-19T07:44:47.453Z"
|
||||
+ "&sort-by=planned",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("400");
|
||||
|
|
@ -324,27 +338,31 @@ class TaskControllerIntTest {
|
|||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", "Basic dXNlcl8xXzI6dXNlcl8xXzI="); // user_1_2
|
||||
HttpEntity<String> request = new HttpEntity<>(headers);
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-key=USER_1_2&domain=DOMAIN_A",
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
|
||||
.isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(20);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetAllTasksByExternalId() {
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?external-id=ETI:000000000000000000000000000000000003,"
|
||||
+ "ETI:000000000000000000000000000000000004",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
|
||||
.isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(2);
|
||||
}
|
||||
|
||||
|
|
@ -356,13 +374,11 @@ class TaskControllerIntTest {
|
|||
HttpEntity<String> request = new HttpEntity<>(headers);
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-key=USER_1_2",
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
};
|
||||
() -> template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-key=USER_1_2",
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("400");
|
||||
|
|
@ -370,46 +386,48 @@ class TaskControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testGetAllTasksWithAdminRole() {
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersAdmin()),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
|
||||
.isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(73);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetAllTasksKeepingFilters() {
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?por.type=VNR&por.value=22334455&sort-by=por.value&order=desc",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getLink(IanaLinkRelations.SELF))
|
||||
.isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(
|
||||
"/api/v1/tasks?por.type=VNR&por.value=22334455&sort-by=por.value&order=desc"))
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(
|
||||
"/api/v1/tasks?por.type=VNR&por.value=22334455&sort-by=por.value&order=desc"))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testThrowsExceptionIfInvalidFilterIsUsed() {
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS) + "?invalid=VNR",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
};
|
||||
() -> template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS) + "?invalid=VNR",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("[invalid]")
|
||||
|
|
@ -421,20 +439,21 @@ class TaskControllerIntTest {
|
|||
void testGetLastPageSortedByPorValue() {
|
||||
|
||||
HttpEntity<String> request = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
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,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getContent()).hasSize(1);
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getContent()).hasSize(1);
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.LAST)
|
||||
.getHref()
|
||||
.contains("page=14"))
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.LAST)
|
||||
.getHref()
|
||||
.contains("page=14"))
|
||||
.isTrue();
|
||||
assertThat("TKI:100000000000000000000000000000000000")
|
||||
.isEqualTo(response.getBody().getContent().iterator().next().getTaskId());
|
||||
|
|
@ -447,7 +466,7 @@ class TaskControllerIntTest {
|
|||
.getHref()
|
||||
.endsWith(
|
||||
"/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();
|
||||
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
|
||||
|
|
@ -466,34 +485,36 @@ class TaskControllerIntTest {
|
|||
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
HttpEntity<String> request = new HttpEntity<>(headers);
|
||||
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS) + "?sort-by=due&order=desc",
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getContent()).hasSize(25);
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getContent()).hasSize(25);
|
||||
|
||||
response =
|
||||
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,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getContent()).hasSize(5);
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat((response.getBody()).getContent()).hasSize(5);
|
||||
assertThat(
|
||||
response.getBody().getRequiredLink(IanaLinkRelations.LAST).getHref().contains("page=5"))
|
||||
response.getBody().getRequiredLink(IanaLinkRelations.LAST).getHref().contains("page=5"))
|
||||
.isTrue();
|
||||
assertThat("TKI:000000000000000000000000000000000023")
|
||||
.isEqualTo(response.getBody().getContent().iterator().next().getTaskId());
|
||||
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith("/api/v1/tasks?sort-by=due&order=desc&page=5&page-size=5"))
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith("/api/v1/tasks?sort-by=due&order=desc&page-size=5&page=5"))
|
||||
.isTrue();
|
||||
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
|
||||
|
|
@ -510,30 +531,31 @@ class TaskControllerIntTest {
|
|||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
HttpEntity<String> request = new HttpEntity<>(headers);
|
||||
ResponseEntity<TaskSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<TaskSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS)
|
||||
+ "?por.company=00&por.system=PASystem&por.instance=00&"
|
||||
+ "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,
|
||||
request,
|
||||
ParameterizedTypeReference.forType(TaskSummaryListResource.class));
|
||||
assertThat(response.getBody().getContent()).hasSize(1);
|
||||
assertThat("TKI:000000000000000000000000000000000013")
|
||||
.isEqualTo(response.getBody().getContent().iterator().next().getTaskId());
|
||||
TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getContent())
|
||||
.extracting(TaskSummaryRepresentationModel::getTaskId)
|
||||
.containsOnly("TKI:000000000000000000000000000000000013");
|
||||
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(
|
||||
"/api/v1/tasks?por.company=00&por.system=PASystem&por.instance=00&"
|
||||
+ "por.type=VNR&por.value=22334455&sort-by=por.type&order=asc&"
|
||||
+ "page=2&page-size=5"))
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(
|
||||
"/api/v1/tasks?por.company=00&por.system=PASystem&por.instance=00&"
|
||||
+ "por.type=VNR&por.value=22334455&sort-by=por.type&order=asc&"
|
||||
+ "page-size=5&page=2"))
|
||||
.isTrue();
|
||||
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.FIRST)).isNotNull();
|
||||
|
|
@ -553,7 +575,7 @@ class TaskControllerIntTest {
|
|||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), UTF_8));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
StringBuilder content = new StringBuilder();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
|
|
@ -613,8 +635,10 @@ class TaskControllerIntTest {
|
|||
String updatedTask = content.toString();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
TaskResource originalTaskObject = mapper.readValue(originalTask, TaskResource.class);
|
||||
TaskResource updatedTaskObject = mapper.readValue(updatedTask, TaskResource.class);
|
||||
TaskRepresentationModel originalTaskObject =
|
||||
mapper.readValue(originalTask, TaskRepresentationModel.class);
|
||||
TaskRepresentationModel updatedTaskObject =
|
||||
mapper.readValue(updatedTask, TaskRepresentationModel.class);
|
||||
|
||||
assertThat(updatedTaskObject.getModified()).isNotEqualTo(originalTaskObject.getModified());
|
||||
}
|
||||
|
|
@ -622,13 +646,13 @@ class TaskControllerIntTest {
|
|||
@Test
|
||||
void testCreateAndDeleteTask() {
|
||||
|
||||
TaskResource taskResource = getTaskResourceSample();
|
||||
ResponseEntity<TaskResource> responseCreate =
|
||||
TaskRepresentationModel taskRepresentationModel = getTaskResourceSample();
|
||||
ResponseEntity<TaskRepresentationModel> responseCreate =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(taskResource, restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(TaskResource.class));
|
||||
new HttpEntity<>(taskRepresentationModel, restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(TaskRepresentationModel.class));
|
||||
assertThat(HttpStatus.CREATED).isEqualTo(responseCreate.getStatusCode());
|
||||
assertThat(responseCreate.getBody()).isNotNull();
|
||||
|
||||
|
|
@ -637,7 +661,7 @@ class TaskControllerIntTest {
|
|||
assertThat(taskIdOfCreatedTask).isNotNull();
|
||||
assertThat(taskIdOfCreatedTask.startsWith("TKI:")).isTrue();
|
||||
|
||||
ResponseEntity<TaskResource> responseDeleted =
|
||||
ResponseEntity<TaskRepresentationModel> responseDeleted =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS_ID, taskIdOfCreatedTask),
|
||||
HttpMethod.DELETE,
|
||||
|
|
@ -653,19 +677,17 @@ class TaskControllerIntTest {
|
|||
*/
|
||||
@Test
|
||||
void testCreateWithPlannedAndDueDate() {
|
||||
TaskResource taskResource = getTaskResourceSample();
|
||||
TaskRepresentationModel taskRepresentationModel = getTaskResourceSample();
|
||||
Instant now = Instant.now();
|
||||
taskResource.setPlanned(now.toString());
|
||||
taskResource.setDue(now.toString());
|
||||
taskRepresentationModel.setPlanned(now.toString());
|
||||
taskRepresentationModel.setDue(now.toString());
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(taskResource, restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(TaskResource.class));
|
||||
};
|
||||
() -> template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(taskRepresentationModel, restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(TaskRepresentationModel.class));
|
||||
assertThatThrownBy(httpCall).isInstanceOf(HttpClientErrorException.class);
|
||||
}
|
||||
|
||||
|
|
@ -720,34 +742,34 @@ class TaskControllerIntTest {
|
|||
final String user_id_of_claimed_task = "user_1_2";
|
||||
|
||||
// retrieve task from Rest Api
|
||||
ResponseEntity<TaskResource> getTaskResponse =
|
||||
ResponseEntity<TaskRepresentationModel> getTaskResponse =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS_ID, claimed_task_id),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersUser_1_2()),
|
||||
ParameterizedTypeReference.forType(TaskResource.class));
|
||||
ParameterizedTypeReference.forType(TaskRepresentationModel.class));
|
||||
|
||||
assertThat(getTaskResponse.getBody()).isNotNull();
|
||||
|
||||
TaskResource claimedTaskResource = getTaskResponse.getBody();
|
||||
assertThat(claimedTaskResource.getState()).isEqualTo(TaskState.CLAIMED);
|
||||
assertThat(claimedTaskResource.getOwner()).isEqualTo(user_id_of_claimed_task);
|
||||
TaskRepresentationModel claimedTaskRepresentationModel = getTaskResponse.getBody();
|
||||
assertThat(claimedTaskRepresentationModel.getState()).isEqualTo(TaskState.CLAIMED);
|
||||
assertThat(claimedTaskRepresentationModel.getOwner()).isEqualTo(user_id_of_claimed_task);
|
||||
|
||||
// cancel claim
|
||||
ResponseEntity<TaskResource> cancelClaimResponse =
|
||||
ResponseEntity<TaskRepresentationModel> cancelClaimResponse =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS_ID_CLAIM, claimed_task_id),
|
||||
HttpMethod.DELETE,
|
||||
new HttpEntity<>(restHelper.getHeadersUser_1_2()),
|
||||
ParameterizedTypeReference.forType(TaskResource.class));
|
||||
ParameterizedTypeReference.forType(TaskRepresentationModel.class));
|
||||
|
||||
assertThat(cancelClaimResponse.getBody()).isNotNull();
|
||||
assertThat(cancelClaimResponse.getStatusCode().is2xxSuccessful());
|
||||
|
||||
TaskResource cancelClaimedtaskResource = cancelClaimResponse.getBody();
|
||||
assertThat(cancelClaimedtaskResource.getOwner()).isNull();
|
||||
assertThat(cancelClaimedtaskResource.getClaimed()).isNull();
|
||||
assertThat(cancelClaimedtaskResource.getState()).isEqualTo(TaskState.READY);
|
||||
TaskRepresentationModel cancelClaimedtaskRepresentationModel = cancelClaimResponse.getBody();
|
||||
assertThat(cancelClaimedtaskRepresentationModel.getOwner()).isNull();
|
||||
assertThat(cancelClaimedtaskRepresentationModel.getClaimed()).isNull();
|
||||
assertThat(cancelClaimedtaskRepresentationModel.getState()).isEqualTo(TaskState.READY);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -757,27 +779,25 @@ class TaskControllerIntTest {
|
|||
final String user_id_of_claimed_task = "user_1_1";
|
||||
|
||||
// retrieve task from Rest Api
|
||||
ResponseEntity<TaskResource> responseGet =
|
||||
ResponseEntity<TaskRepresentationModel> responseGet =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS_ID, claimed_task_id),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersUser_1_2()),
|
||||
ParameterizedTypeReference.forType(TaskResource.class));
|
||||
ParameterizedTypeReference.forType(TaskRepresentationModel.class));
|
||||
|
||||
assertThat(responseGet.getBody()).isNotNull();
|
||||
TaskResource theTaskResource = responseGet.getBody();
|
||||
assertThat(theTaskResource.getState()).isEqualTo(TaskState.CLAIMED);
|
||||
assertThat(theTaskResource.getOwner()).isEqualTo(user_id_of_claimed_task);
|
||||
TaskRepresentationModel theTaskRepresentationModel = responseGet.getBody();
|
||||
assertThat(theTaskRepresentationModel.getState()).isEqualTo(TaskState.CLAIMED);
|
||||
assertThat(theTaskRepresentationModel.getOwner()).isEqualTo(user_id_of_claimed_task);
|
||||
|
||||
// try to cancel claim
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS_ID_CLAIM, claimed_task_id),
|
||||
HttpMethod.DELETE,
|
||||
new HttpEntity<>(restHelper.getHeadersUser_1_2()),
|
||||
ParameterizedTypeReference.forType(TaskResource.class));
|
||||
};
|
||||
() -> template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_TASKS_ID_CLAIM, claimed_task_id),
|
||||
HttpMethod.DELETE,
|
||||
new HttpEntity<>(restHelper.getHeadersUser_1_2()),
|
||||
ParameterizedTypeReference.forType(TaskRepresentationModel.class));
|
||||
assertThatThrownBy(httpCall)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.isEqualTo(HttpStatus.CONFLICT);
|
||||
|
|
@ -790,33 +810,33 @@ class TaskControllerIntTest {
|
|||
restHelper.toUrl("/api/v1/tasks/TKI:000000000000000000000000000000000025");
|
||||
|
||||
// retrieve task from Rest Api
|
||||
ResponseEntity<TaskResource> responseGet =
|
||||
ResponseEntity<TaskRepresentationModel> responseGet =
|
||||
template.exchange(
|
||||
taskUrlString,
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersUser_1_2()),
|
||||
ParameterizedTypeReference.forType(TaskResource.class));
|
||||
ParameterizedTypeReference.forType(TaskRepresentationModel.class));
|
||||
|
||||
assertThat(responseGet.getBody()).isNotNull();
|
||||
TaskResource theTaskResource = responseGet.getBody();
|
||||
assertThat(theTaskResource.getState()).isEqualTo(TaskState.READY);
|
||||
assertThat(theTaskResource.getOwner() == null);
|
||||
TaskRepresentationModel theTaskRepresentationModel = responseGet.getBody();
|
||||
assertThat(theTaskRepresentationModel.getState()).isEqualTo(TaskState.READY);
|
||||
assertThat(theTaskRepresentationModel.getOwner()).isNull();
|
||||
|
||||
// set Owner and update Task
|
||||
|
||||
final String anyUserName = "dummyUser";
|
||||
theTaskResource.setOwner(anyUserName);
|
||||
ResponseEntity<TaskResource> responseUpdate =
|
||||
theTaskRepresentationModel.setOwner(anyUserName);
|
||||
ResponseEntity<TaskRepresentationModel> responseUpdate =
|
||||
template.exchange(
|
||||
taskUrlString,
|
||||
HttpMethod.PUT,
|
||||
new HttpEntity<>(theTaskResource, restHelper.getHeadersUser_1_2()),
|
||||
ParameterizedTypeReference.forType(TaskResource.class));
|
||||
new HttpEntity<>(theTaskRepresentationModel, restHelper.getHeadersUser_1_2()),
|
||||
ParameterizedTypeReference.forType(TaskRepresentationModel.class));
|
||||
|
||||
assertThat(responseUpdate.getBody()).isNotNull();
|
||||
TaskResource theUpdatedTaskResource = responseUpdate.getBody();
|
||||
assertThat(theUpdatedTaskResource.getState()).isEqualTo(TaskState.READY);
|
||||
assertThat(theUpdatedTaskResource.getOwner()).isEqualTo(anyUserName);
|
||||
TaskRepresentationModel theUpdatedTaskRepresentationModel = responseUpdate.getBody();
|
||||
assertThat(theUpdatedTaskRepresentationModel.getState()).isEqualTo(TaskState.READY);
|
||||
assertThat(theUpdatedTaskRepresentationModel.getOwner()).isEqualTo(anyUserName);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -826,41 +846,42 @@ class TaskControllerIntTest {
|
|||
restHelper.toUrl("/api/v1/tasks/TKI:000000000000000000000000000000000026");
|
||||
|
||||
// retrieve task from Rest Api
|
||||
ResponseEntity<TaskResource> responseGet =
|
||||
ResponseEntity<TaskRepresentationModel> responseGet =
|
||||
template.exchange(
|
||||
taskUrlString,
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersUser_1_2()),
|
||||
ParameterizedTypeReference.forType(TaskResource.class));
|
||||
ParameterizedTypeReference.forType(TaskRepresentationModel.class));
|
||||
|
||||
assertThat(responseGet.getBody()).isNotNull();
|
||||
TaskResource theTaskResource = responseGet.getBody();
|
||||
assertThat(theTaskResource.getState()).isEqualTo(TaskState.CLAIMED);
|
||||
assertThat(theTaskResource.getOwner()).isEqualTo("user_1_1");
|
||||
TaskRepresentationModel theTaskRepresentationModel = responseGet.getBody();
|
||||
assertThat(theTaskRepresentationModel.getState()).isEqualTo(TaskState.CLAIMED);
|
||||
assertThat(theTaskRepresentationModel.getOwner()).isEqualTo("user_1_1");
|
||||
|
||||
// set Owner and update Task
|
||||
|
||||
final String anyUserName = "dummyuser";
|
||||
theTaskResource.setOwner(anyUserName);
|
||||
theTaskRepresentationModel.setOwner(anyUserName);
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
template.exchange(
|
||||
taskUrlString,
|
||||
HttpMethod.PUT,
|
||||
new HttpEntity<>(theTaskResource, restHelper.getHeadersUser_1_2()),
|
||||
ParameterizedTypeReference.forType(TaskResource.class));
|
||||
};
|
||||
() -> template.exchange(
|
||||
taskUrlString,
|
||||
HttpMethod.PUT,
|
||||
new HttpEntity<>(theTaskRepresentationModel, restHelper.getHeadersUser_1_2()),
|
||||
ParameterizedTypeReference.forType(TaskRepresentationModel.class));
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("409");
|
||||
}
|
||||
|
||||
private TaskResource getTaskResourceSample() {
|
||||
ClassificationSummaryResource classificationResource = new ClassificationSummaryResource();
|
||||
private TaskRepresentationModel getTaskResourceSample() {
|
||||
ClassificationSummaryRepresentationModel classificationResource =
|
||||
new ClassificationSummaryRepresentationModel();
|
||||
classificationResource.setKey("L11010");
|
||||
WorkbasketSummaryResource workbasketSummaryResource = new WorkbasketSummaryResource();
|
||||
workbasketSummaryResource.setWorkbasketId("WBI:100000000000000000000000000000000004");
|
||||
WorkbasketSummaryRepresentationModel workbasketSummary =
|
||||
new WorkbasketSummaryRepresentationModel();
|
||||
workbasketSummary.setWorkbasketId(
|
||||
"WBI:100000000000000000000000000000000004");
|
||||
|
||||
ObjectReference objectReference = new ObjectReference();
|
||||
objectReference.setCompany("MyCompany1");
|
||||
|
|
@ -869,10 +890,11 @@ class TaskControllerIntTest {
|
|||
objectReference.setType("MyType1");
|
||||
objectReference.setValue("00000001");
|
||||
|
||||
TaskResource taskResource = new TaskResource();
|
||||
taskResource.setClassificationSummaryResource(classificationResource);
|
||||
taskResource.setWorkbasketSummaryResource(workbasketSummaryResource);
|
||||
taskResource.setPrimaryObjRef(objectReference);
|
||||
return taskResource;
|
||||
TaskRepresentationModel taskRepresentationModel = new TaskRepresentationModel();
|
||||
taskRepresentationModel.setClassificationSummary(classificationResource);
|
||||
taskRepresentationModel.setWorkbasketSummary(
|
||||
workbasketSummary);
|
||||
taskRepresentationModel.setPrimaryObjRef(objectReference);
|
||||
return taskRepresentationModel;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import org.springframework.web.client.RestTemplate;
|
|||
import pro.taskana.RestHelper;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.common.api.TaskanaRole;
|
||||
import pro.taskana.rest.resource.TaskanaUserInfoResource;
|
||||
import pro.taskana.rest.resource.TaskanaUserInfoRepresentationModel;
|
||||
|
||||
/** Test TaskanaEngineController. */
|
||||
@TaskanaSpringBootTest
|
||||
|
|
@ -63,12 +63,12 @@ class TaskanaEngineControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testGetCurrentUserInfo() {
|
||||
ResponseEntity<TaskanaUserInfoResource> response =
|
||||
ResponseEntity<TaskanaUserInfoRepresentationModel> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_CURRENT_USER),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(TaskanaUserInfoResource.class));
|
||||
ParameterizedTypeReference.forType(TaskanaUserInfoRepresentationModel.class));
|
||||
assertThat(response.getBody().getUserId()).isEqualTo("teamlead_1");
|
||||
assertThat(response.getBody().getGroupIds()).contains("businessadmin");
|
||||
assertThat(response.getBody().getRoles()).contains(TaskanaRole.BUSINESS_ADMIN);
|
||||
|
|
|
|||
|
|
@ -19,13 +19,19 @@ import org.springframework.web.client.RestTemplate;
|
|||
|
||||
import pro.taskana.RestHelper;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemListResource;
|
||||
import pro.taskana.rest.resource.TaskanaPagedModel;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemRepresentationModel;
|
||||
|
||||
/** Test WorkbasketAccessItemController. */
|
||||
@TestMethodOrder(MethodOrderer.Alphanumeric.class)
|
||||
@TaskanaSpringBootTest
|
||||
class WorkbasketAccessItemControllerIntTest {
|
||||
|
||||
private static final ParameterizedTypeReference<
|
||||
TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>>
|
||||
WORKBASKET_ACCESS_ITEM_PAGE_MODEL_TYPE =
|
||||
new ParameterizedTypeReference<
|
||||
TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>>() {};
|
||||
private static RestTemplate template;
|
||||
@Autowired RestHelper restHelper;
|
||||
|
||||
|
|
@ -36,24 +42,26 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testGetAllWorkbasketAccessItems() {
|
||||
ResponseEntity<WorkbasketAccessItemListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class));
|
||||
WORKBASKET_ACCESS_ITEM_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetWorkbasketAccessItemsKeepingFilters() {
|
||||
String parameters = "?sort-by=workbasket-key&order=asc&page=1&page-size=9&access-ids=user_1_1";
|
||||
ResponseEntity<WorkbasketAccessItemListResource> response =
|
||||
String parameters = "?sort-by=workbasket-key&order=asc&page-size=9&access-ids=user_1_1&page=1";
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS) + parameters,
|
||||
HttpMethod.GET,
|
||||
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
|
||||
|
|
@ -67,14 +75,12 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
@Test
|
||||
void testThrowsExceptionIfInvalidFilterIsUsed() {
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS)
|
||||
+ "?sort-by=workbasket-key&order=asc&page=1&page-size=9&invalid=user_1_1",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class));
|
||||
};
|
||||
() -> template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS)
|
||||
+ "?sort-by=workbasket-key&order=asc&page=1&page-size=9&invalid=user_1_1",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
WORKBASKET_ACCESS_ITEM_PAGE_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("[invalid]")
|
||||
|
|
@ -84,13 +90,14 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testGetSecondPageSortedByWorkbasketKey() {
|
||||
String parameters = "?sort-by=workbasket-key&order=asc&page=2&page-size=9&access-ids=user_1_1";
|
||||
ResponseEntity<WorkbasketAccessItemListResource> response =
|
||||
String parameters = "?sort-by=workbasket-key&order=asc&page-size=9&access-ids=user_1_1&page=1";
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS) + parameters,
|
||||
HttpMethod.GET,
|
||||
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().iterator().next().getAccessId())
|
||||
.isEqualTo("user_1_1");
|
||||
|
|
@ -128,13 +135,11 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
void testGetBadRequestIfTryingToDeleteAccessItemsForGroup() {
|
||||
String parameters = "?access-id=cn=DevelopersGroup,ou=groups,o=TaskanaTest";
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS) + parameters,
|
||||
HttpMethod.DELETE,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(Void.class));
|
||||
};
|
||||
() -> template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKETACCESSITEMS) + parameters,
|
||||
HttpMethod.DELETE,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(Void.class));
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
|
|
|
|||
|
|
@ -21,17 +21,26 @@ import org.springframework.web.client.RestTemplate;
|
|||
|
||||
import pro.taskana.RestHelper;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.rest.resource.DistributionTargetListResource;
|
||||
import pro.taskana.rest.resource.DistributionTargetResource;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemListResource;
|
||||
import pro.taskana.rest.resource.WorkbasketResource;
|
||||
import pro.taskana.rest.resource.WorkbasketSummaryListResource;
|
||||
import pro.taskana.rest.resource.TaskanaPagedModel;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemRepresentationModel;
|
||||
import pro.taskana.rest.resource.WorkbasketRepresentationModel;
|
||||
import pro.taskana.rest.resource.WorkbasketSummaryRepresentationModel;
|
||||
import pro.taskana.workbasket.api.WorkbasketType;
|
||||
|
||||
/** Test WorkbasketController. */
|
||||
@TaskanaSpringBootTest
|
||||
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;
|
||||
@Autowired RestHelper restHelper;
|
||||
|
||||
|
|
@ -42,12 +51,12 @@ class WorkbasketControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testGetWorkbasket() {
|
||||
ResponseEntity<WorkbasketResource> response =
|
||||
ResponseEntity<WorkbasketRepresentationModel> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, "WBI:100000000000000000000000000000000006"),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketResource.class));
|
||||
ParameterizedTypeReference.forType(WorkbasketRepresentationModel.class));
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getHeaders().getContentType().toString())
|
||||
.isEqualTo(MediaTypes.HAL_JSON_VALUE);
|
||||
|
|
@ -55,23 +64,23 @@ class WorkbasketControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testGetAllWorkbaskets() {
|
||||
ResponseEntity<WorkbasketSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKET),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetAllWorkbasketsBusinessAdminHasOpenPermission() {
|
||||
ResponseEntity<WorkbasketSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKET) + "?required-permission=OPEN",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody().getRequiredLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(3);
|
||||
}
|
||||
|
|
@ -79,12 +88,12 @@ class WorkbasketControllerIntTest {
|
|||
@Test
|
||||
void testGetAllWorkbasketsKeepingFilters() {
|
||||
String parameters = "?type=PERSONAL&sort-by=key&order=desc";
|
||||
ResponseEntity<WorkbasketSummaryListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKET) + parameters,
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
|
|
@ -98,13 +107,11 @@ class WorkbasketControllerIntTest {
|
|||
@Test
|
||||
void testThrowsExceptionIfInvalidFilterIsUsed() {
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKET) + "?invalid=PERSONAL",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||
};
|
||||
() -> template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKET) + "?invalid=PERSONAL",
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.hasMessageContaining("[invalid]")
|
||||
|
|
@ -119,21 +126,22 @@ class WorkbasketControllerIntTest {
|
|||
|
||||
final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
ResponseEntity<WorkbasketResource> initialWorkbasketResourceRequestResponse =
|
||||
ResponseEntity<WorkbasketRepresentationModel> initialWorkbasketResourceRequestResponse =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId),
|
||||
HttpMethod.GET,
|
||||
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");
|
||||
workbasketResource.setDomain("DOMAIN_A");
|
||||
workbasketResource.setType(WorkbasketType.PERSONAL);
|
||||
workbasketResource.setName("was auch immer");
|
||||
workbasketResource.setOwner("Joerg");
|
||||
workbasketResource.setModified(String.valueOf(Instant.now()));
|
||||
workbasketRepresentationModel.setKey("GPK_KSC");
|
||||
workbasketRepresentationModel.setDomain("DOMAIN_A");
|
||||
workbasketRepresentationModel.setType(WorkbasketType.PERSONAL);
|
||||
workbasketRepresentationModel.setName("was auch immer");
|
||||
workbasketRepresentationModel.setOwner("Joerg");
|
||||
workbasketRepresentationModel.setModified(String.valueOf(Instant.now()));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
|
@ -141,8 +149,9 @@ class WorkbasketControllerIntTest {
|
|||
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId),
|
||||
HttpMethod.PUT,
|
||||
new HttpEntity<>(
|
||||
mapper.writeValueAsString(workbasketResource), restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(WorkbasketResource.class));
|
||||
mapper.writeValueAsString(workbasketRepresentationModel),
|
||||
restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(WorkbasketRepresentationModel.class));
|
||||
};
|
||||
assertThatThrownBy(httpCall)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
|
|
@ -160,7 +169,7 @@ class WorkbasketControllerIntTest {
|
|||
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketId),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<String>(restHelper.getHeaders()),
|
||||
ParameterizedTypeReference.forType(WorkbasketResource.class));
|
||||
ParameterizedTypeReference.forType(WorkbasketRepresentationModel.class));
|
||||
};
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
|
|
@ -171,13 +180,13 @@ class WorkbasketControllerIntTest {
|
|||
@Test
|
||||
void testGetSecondPageSortedByKey() {
|
||||
|
||||
String parameters = "?sort-by=key&order=desc&page=2&page-size=5";
|
||||
ResponseEntity<WorkbasketSummaryListResource> response =
|
||||
String parameters = "?sort-by=key&order=desc&page-size=5&page=2";
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKET) + parameters,
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketSummaryListResource.class));
|
||||
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody().getContent()).hasSize(5);
|
||||
assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("USER_1_1");
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
|
|
@ -236,30 +245,30 @@ class WorkbasketControllerIntTest {
|
|||
Void.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
|
||||
ResponseEntity<DistributionTargetListResource> response2 =
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response2 =
|
||||
template.exchange(
|
||||
restHelper.toUrl(
|
||||
Mapping.URL_WORKBASKET_ID_DISTRIBUTION, "WBI:100000000000000000000000000000000002"),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(DistributionTargetListResource.class));
|
||||
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response2.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(
|
||||
response2.getBody().getContent().stream()
|
||||
.map(DistributionTargetResource::getWorkbasketId)
|
||||
.map(WorkbasketSummaryRepresentationModel::getWorkbasketId)
|
||||
.noneMatch("WBI:100000000000000000000000000000000007"::equals))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetWorkbasketAccessItems() {
|
||||
ResponseEntity<WorkbasketAccessItemListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketAccessItemRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(
|
||||
Mapping.URL_WORKBASKET_ID_ACCESSITEMS, "WBI:100000000000000000000000000000000005"),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(WorkbasketAccessItemListResource.class));
|
||||
WORKBASKET_ACCESS_ITEM_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getHeaders().getContentType().toString())
|
||||
.isEqualTo(MediaTypes.HAL_JSON_VALUE);
|
||||
|
|
@ -268,13 +277,13 @@ class WorkbasketControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testGetWorkbasketDistributionTargets() {
|
||||
ResponseEntity<DistributionTargetListResource> response =
|
||||
ResponseEntity<TaskanaPagedModel<WorkbasketSummaryRepresentationModel>> response =
|
||||
template.exchange(
|
||||
restHelper.toUrl(
|
||||
Mapping.URL_WORKBASKET_ID_DISTRIBUTION, "WBI:100000000000000000000000000000000001"),
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(DistributionTargetListResource.class));
|
||||
WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(response.getHeaders().getContentType().toString())
|
||||
.isEqualTo(MediaTypes.HAL_JSON_VALUE);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import org.springframework.web.client.RestTemplate;
|
|||
|
||||
import pro.taskana.RestHelper;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.rest.resource.WorkbasketDefinitionResource;
|
||||
import pro.taskana.rest.resource.WorkbasketDefinitionRepresentationModel;
|
||||
import pro.taskana.sampledata.SampleDataGenerator;
|
||||
|
||||
/** Integration tests for WorkbasketDefinitionController. */
|
||||
|
|
@ -69,16 +69,17 @@ class WorkbasketDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testExportWorkbasketFromDomain() {
|
||||
ResponseEntity<List<WorkbasketDefinitionResource>> response =
|
||||
ResponseEntity<List<WorkbasketDefinitionRepresentationModel>> response =
|
||||
executeExportRequestForDomain("DOMAIN_A");
|
||||
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
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 allDistributionTargetsAreEmpty = true;
|
||||
for (WorkbasketDefinitionResource workbasketDefinition : response.getBody()) {
|
||||
for (WorkbasketDefinitionRepresentationModel workbasketDefinition : response.getBody()) {
|
||||
if (allAuthorizationsAreEmpty && !workbasketDefinition.getAuthorizations().isEmpty()) {
|
||||
allAuthorizationsAreEmpty = false;
|
||||
}
|
||||
|
|
@ -96,22 +97,24 @@ class WorkbasketDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testExportWorkbasketsFromWrongDomain() {
|
||||
ResponseEntity<List<WorkbasketDefinitionResource>> response =
|
||||
ResponseEntity<List<WorkbasketDefinitionRepresentationModel>> response =
|
||||
executeExportRequestForDomain("wrongDomain");
|
||||
assertThat(response.getBody()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testImportEveryWorkbasketFromDomainA() throws IOException {
|
||||
List<WorkbasketDefinitionResource> wbList = executeExportRequestForDomain("DOMAIN_A").getBody();
|
||||
for (WorkbasketDefinitionResource w : wbList) {
|
||||
List<WorkbasketDefinitionRepresentationModel> wbList =
|
||||
executeExportRequestForDomain("DOMAIN_A").getBody();
|
||||
for (WorkbasketDefinitionRepresentationModel w : wbList) {
|
||||
expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.NO_CONTENT, w);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testImportWorkbasketWithoutDistributionTargets() throws IOException {
|
||||
WorkbasketDefinitionResource w = executeExportRequestForDomain("DOMAIN_A").getBody().get(0);
|
||||
WorkbasketDefinitionRepresentationModel w =
|
||||
executeExportRequestForDomain("DOMAIN_A").getBody().get(0);
|
||||
w.setDistributionTargets(new HashSet<>());
|
||||
|
||||
this.expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.NO_CONTENT, w);
|
||||
|
|
@ -123,12 +126,13 @@ class WorkbasketDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
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<>());
|
||||
String letMeBeYourDistributionTarget = w.getWorkbasket().getWorkbasketId();
|
||||
WorkbasketDefinitionResource w2 = wbList.get(1);
|
||||
WorkbasketDefinitionRepresentationModel w2 = wbList.get(1);
|
||||
w2.setDistributionTargets(Collections.singleton(letMeBeYourDistributionTarget));
|
||||
expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.NO_CONTENT, w, w2);
|
||||
|
||||
|
|
@ -145,10 +149,11 @@ class WorkbasketDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testImportWorkbasketWithDistributionTargetsInSystem() throws IOException {
|
||||
List<WorkbasketDefinitionResource> wbList = executeExportRequestForDomain("DOMAIN_A").getBody();
|
||||
List<WorkbasketDefinitionRepresentationModel> wbList =
|
||||
executeExportRequestForDomain("DOMAIN_A").getBody();
|
||||
|
||||
wbList.removeIf(definition -> definition.getDistributionTargets().isEmpty());
|
||||
WorkbasketDefinitionResource w = wbList.get(0);
|
||||
WorkbasketDefinitionRepresentationModel w = wbList.get(0);
|
||||
expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.NO_CONTENT, w);
|
||||
|
||||
changeWorkbasketIdOrKey(w, null, "new");
|
||||
|
|
@ -157,9 +162,10 @@ class WorkbasketDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
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"));
|
||||
try {
|
||||
expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.BAD_REQUEST, w);
|
||||
|
|
@ -179,7 +185,8 @@ class WorkbasketDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testFailOnImportDuplicates() throws IOException {
|
||||
WorkbasketDefinitionResource w = executeExportRequestForDomain("DOMAIN_A").getBody().get(0);
|
||||
WorkbasketDefinitionRepresentationModel w =
|
||||
executeExportRequestForDomain("DOMAIN_A").getBody().get(0);
|
||||
try {
|
||||
expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.CONFLICT, w, w);
|
||||
fail("Expected http-Status 409");
|
||||
|
|
@ -190,14 +197,15 @@ class WorkbasketDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testNoErrorWhenImportWithSameIdButDifferentKeyAndDomain() throws IOException {
|
||||
List<WorkbasketDefinitionResource> wbList = executeExportRequestForDomain("DOMAIN_A").getBody();
|
||||
List<WorkbasketDefinitionRepresentationModel> wbList =
|
||||
executeExportRequestForDomain("DOMAIN_A").getBody();
|
||||
|
||||
WorkbasketDefinitionResource w = wbList.get(0);
|
||||
WorkbasketDefinitionResource differentLogicalId = wbList.get(1);
|
||||
WorkbasketDefinitionRepresentationModel w = wbList.get(0);
|
||||
WorkbasketDefinitionRepresentationModel differentLogicalId = wbList.get(1);
|
||||
this.changeWorkbasketIdOrKey(differentLogicalId, w.getWorkbasket().getWorkbasketId(), null);
|
||||
|
||||
// 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(
|
||||
Collections.singleton(differentLogicalId.getWorkbasket().getWorkbasketId()));
|
||||
|
||||
|
|
@ -207,7 +215,8 @@ class WorkbasketDefinitionControllerIntTest {
|
|||
|
||||
@Test
|
||||
void testErrorWhenImportWithSameAccessIdAndWorkbasket() {
|
||||
WorkbasketDefinitionResource w = executeExportRequestForDomain("DOMAIN_A").getBody().get(0);
|
||||
WorkbasketDefinitionRepresentationModel w =
|
||||
executeExportRequestForDomain("DOMAIN_A").getBody().get(0);
|
||||
|
||||
String w1String = workbasketToString(w);
|
||||
w.getWorkbasket().setKey("new Key for this WB");
|
||||
|
|
@ -221,7 +230,7 @@ class WorkbasketDefinitionControllerIntTest {
|
|||
}
|
||||
|
||||
private void changeWorkbasketIdOrKey(
|
||||
WorkbasketDefinitionResource w, String newId, String newKey) {
|
||||
WorkbasketDefinitionRepresentationModel w, String newId, String newKey) {
|
||||
if (newId != null && !newId.isEmpty()) {
|
||||
w.getWorkbasket().setWorkbasketId(newId);
|
||||
w.getAuthorizations().forEach(auth -> auth.setWorkbasketId(newId));
|
||||
|
|
@ -232,17 +241,18 @@ class WorkbasketDefinitionControllerIntTest {
|
|||
}
|
||||
}
|
||||
|
||||
private ResponseEntity<List<WorkbasketDefinitionResource>> executeExportRequestForDomain(
|
||||
String domain) {
|
||||
private ResponseEntity<List<WorkbasketDefinitionRepresentationModel>>
|
||||
executeExportRequestForDomain(String domain) {
|
||||
return template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_WORKBASKETDEFIITIONS) + "?domain=" + domain,
|
||||
HttpMethod.GET,
|
||||
restHelper.defaultRequest(),
|
||||
new ParameterizedTypeReference<List<WorkbasketDefinitionResource>>() {});
|
||||
new ParameterizedTypeReference<List<WorkbasketDefinitionRepresentationModel>>() {});
|
||||
}
|
||||
|
||||
private void expectStatusWhenExecutingImportRequestOfWorkbaskets(
|
||||
HttpStatus expectedStatus, WorkbasketDefinitionResource... workbaskets) throws IOException {
|
||||
HttpStatus expectedStatus, WorkbasketDefinitionRepresentationModel... workbaskets)
|
||||
throws IOException {
|
||||
List<String> workbasketStrings =
|
||||
Arrays.stream(workbaskets).map(this::workbasketToString).collect(Collectors.toList());
|
||||
expectStatusWhenExecutingImportRequestOfWorkbaskets(expectedStatus, workbasketStrings);
|
||||
|
|
@ -268,9 +278,10 @@ class WorkbasketDefinitionControllerIntTest {
|
|||
assertThat(responseImport.getStatusCode()).isEqualTo(expectedStatus);
|
||||
}
|
||||
|
||||
private String workbasketToString(WorkbasketDefinitionResource workbasketDefinitionResource) {
|
||||
private String workbasketToString(
|
||||
WorkbasketDefinitionRepresentationModel workbasketDefinitionRepresentationModel) {
|
||||
try {
|
||||
return objMapper.writeValueAsString(workbasketDefinitionResource);
|
||||
return objMapper.writeValueAsString(workbasketDefinitionRepresentationModel);
|
||||
} catch (JsonProcessingException e) {
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ import pro.taskana.classification.api.models.Classification;
|
|||
import pro.taskana.classification.internal.models.ClassificationImpl;
|
||||
import pro.taskana.rest.Mapping;
|
||||
|
||||
/** Test for {@link ClassificationResourceAssembler}. */
|
||||
/** Test for {@link ClassificationRepresentationModelAssembler}. */
|
||||
@TaskanaSpringBootTest
|
||||
class ClassificationAssemblerTest {
|
||||
|
||||
@Autowired ClassificationResourceAssembler classificationResourceAssembler;
|
||||
@Autowired ClassificationRepresentationModelAssembler classificationRepresentationModelAssembler;
|
||||
|
||||
@Autowired ClassificationService classificationService;
|
||||
|
||||
|
|
@ -46,11 +46,11 @@ class ClassificationAssemblerTest {
|
|||
classification.setCreated(Instant.parse("2010-01-01T12:00:00Z"));
|
||||
classification.setModified(Instant.parse("2011-11-11T11:00:00Z"));
|
||||
// when
|
||||
ClassificationResource classificationResource =
|
||||
classificationResourceAssembler.toModel(classification);
|
||||
ClassificationRepresentationModel classificationRepresentationModel =
|
||||
classificationRepresentationModelAssembler.toModel(classification);
|
||||
// then
|
||||
testEquality(classification, classificationResource);
|
||||
testLinks(classificationResource);
|
||||
testEquality(classification, classificationRepresentationModel);
|
||||
testLinks(classificationRepresentationModel);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -80,48 +80,68 @@ class ClassificationAssemblerTest {
|
|||
classification.setDescription("Test");
|
||||
classification.setIsValidInDomain(true);
|
||||
|
||||
ClassificationResource classificationResource = new ClassificationResource(classification);
|
||||
ClassificationRepresentationModel classificationRepresentationModel =
|
||||
new ClassificationRepresentationModel(classification);
|
||||
|
||||
// when
|
||||
classification =
|
||||
(ClassificationImpl) classificationResourceAssembler.toModel(classificationResource);
|
||||
(ClassificationImpl)
|
||||
classificationRepresentationModelAssembler
|
||||
.toEntityModel(classificationRepresentationModel);
|
||||
// then
|
||||
testEquality(classification, classificationResource);
|
||||
testEquality(classification, classificationRepresentationModel);
|
||||
}
|
||||
|
||||
private void testLinks(ClassificationResource resource) {
|
||||
private void testLinks(ClassificationRepresentationModel resource) {
|
||||
assertThat(resource.getLinks()).hasSize(1);
|
||||
assertThat(Mapping.URL_CLASSIFICATIONS_ID.replaceAll("\\{.*}", resource.getClassificationId()))
|
||||
.isEqualTo(resource.getRequiredLink("self").getHref());
|
||||
}
|
||||
|
||||
private void testEquality(
|
||||
Classification classification, ClassificationResource classificationResource) {
|
||||
Classification classification,
|
||||
ClassificationRepresentationModel classificationRepresentationModel) {
|
||||
assertThat(classification.getApplicationEntryPoint())
|
||||
.isEqualTo(classificationResource.getApplicationEntryPoint());
|
||||
assertThat(classification.getKey()).isEqualTo(classificationResource.getKey());
|
||||
assertThat(classification.getDomain()).isEqualTo(classificationResource.getDomain());
|
||||
assertThat(classification.getId()).isEqualTo(classificationResource.getClassificationId());
|
||||
assertThat(classification.getDescription()).isEqualTo(classificationResource.getDescription());
|
||||
assertThat(classification.getName()).isEqualTo(classificationResource.getName());
|
||||
.isEqualTo(classificationRepresentationModel.getApplicationEntryPoint());
|
||||
assertThat(classification.getKey()).isEqualTo(classificationRepresentationModel.getKey());
|
||||
assertThat(classification.getDomain()).isEqualTo(classificationRepresentationModel.getDomain());
|
||||
assertThat(classification.getId())
|
||||
.isEqualTo(classificationRepresentationModel.getClassificationId());
|
||||
assertThat(classification.getDescription())
|
||||
.isEqualTo(classificationRepresentationModel.getDescription());
|
||||
assertThat(classification.getName()).isEqualTo(classificationRepresentationModel.getName());
|
||||
assertThat(classification.getServiceLevel())
|
||||
.isEqualTo(classificationResource.getServiceLevel());
|
||||
assertThat(classification.getCategory()).isEqualTo(classificationResource.getCategory());
|
||||
assertThat(classification.getCustom1()).isEqualTo(classificationResource.getCustom1());
|
||||
assertThat(classification.getCustom2()).isEqualTo(classificationResource.getCustom2());
|
||||
assertThat(classification.getCustom3()).isEqualTo(classificationResource.getCustom3());
|
||||
assertThat(classification.getCustom4()).isEqualTo(classificationResource.getCustom4());
|
||||
assertThat(classification.getCustom5()).isEqualTo(classificationResource.getCustom5());
|
||||
assertThat(classification.getCustom6()).isEqualTo(classificationResource.getCustom6());
|
||||
assertThat(classification.getCustom7()).isEqualTo(classificationResource.getCustom7());
|
||||
assertThat(classification.getCustom8()).isEqualTo(classificationResource.getCustom8());
|
||||
assertThat(classification.getParentId()).isEqualTo(classificationResource.getParentId());
|
||||
assertThat(classification.getParentKey()).isEqualTo(classificationResource.getParentKey());
|
||||
assertThat(classification.getType()).isEqualTo(classificationResource.getType());
|
||||
assertThat(classification.getPriority()).isEqualTo(classificationResource.getPriority());
|
||||
.isEqualTo(classificationRepresentationModel.getServiceLevel());
|
||||
assertThat(classification.getCategory())
|
||||
.isEqualTo(classificationRepresentationModel.getCategory());
|
||||
assertThat(classification.getCustom1())
|
||||
.isEqualTo(classificationRepresentationModel.getCustom1());
|
||||
assertThat(classification.getCustom2())
|
||||
.isEqualTo(classificationRepresentationModel.getCustom2());
|
||||
assertThat(classification.getCustom3())
|
||||
.isEqualTo(classificationRepresentationModel.getCustom3());
|
||||
assertThat(classification.getCustom4())
|
||||
.isEqualTo(classificationRepresentationModel.getCustom4());
|
||||
assertThat(classification.getCustom5())
|
||||
.isEqualTo(classificationRepresentationModel.getCustom5());
|
||||
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())
|
||||
.isEqualTo(classificationResource.getIsValidInDomain());
|
||||
assertThat(classification.getCreated()).isEqualTo(classificationResource.getCreated());
|
||||
assertThat(classification.getModified()).isEqualTo(classificationResource.getModified());
|
||||
.isEqualTo(classificationRepresentationModel.getIsValidInDomain());
|
||||
assertThat(classification.getCreated())
|
||||
.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
Loading…
Reference in New Issue