TSK-1265: Removal of constructors from the representationModels

This commit is contained in:
Mustapha Zorgati 2020-05-26 10:35:13 +02:00
parent deb5c52107
commit 2fc38a2b85
30 changed files with 575 additions and 570 deletions

View File

@ -41,16 +41,18 @@ import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl;
import pro.taskana.workbasket.internal.models.WorkbasketImpl;
import pro.taskana.workbasket.internal.models.WorkbasketSummaryImpl;
/** This is the implementation of WorkbasketService. */
/**
* This is the implementation of WorkbasketService.
*/
public class WorkbasketServiceImpl implements WorkbasketService {
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketServiceImpl.class);
private static final String ID_PREFIX_WORKBASKET = "WBI";
private static final String ID_PREFIX_WORKBASKET_AUTHORIZATION = "WAI";
private InternalTaskanaEngine taskanaEngine;
private WorkbasketMapper workbasketMapper;
private DistributionTargetMapper distributionTargetMapper;
private WorkbasketAccessMapper workbasketAccessMapper;
private final InternalTaskanaEngine taskanaEngine;
private final WorkbasketMapper workbasketMapper;
private final DistributionTargetMapper distributionTargetMapper;
private final WorkbasketAccessMapper workbasketAccessMapper;
public WorkbasketServiceImpl(
InternalTaskanaEngine taskanaEngine,
@ -117,7 +119,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
public Workbasket createWorkbasket(Workbasket newWorkbasket)
throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException,
DomainNotFoundException {
LOGGER.debug("entry to createtWorkbasket(workbasket)", newWorkbasket);
LOGGER.debug("entry to createWorkbasket(workbasket) with Workbasket {}", newWorkbasket);
taskanaEngine.getEngine().checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
WorkbasketImpl workbasket = (WorkbasketImpl) newWorkbasket;
@ -869,7 +871,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
* @param oldWorkbasket the old workbasket in the system
* @param workbasketImplToUpdate the workbasket to update
* @throws ConcurrencyException if the workbasket has been modified by some other process.
* @throws WorkbasketNotFoundException if the given workbasket does not exist.
*/
void checkModifiedHasNotChanged(Workbasket oldWorkbasket, WorkbasketImpl workbasketImplToUpdate)
throws ConcurrencyException {
@ -920,7 +921,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
return true;
}
if (Arrays.stream(requestedPermissions).anyMatch(WorkbasketPermission.READ::equals)) {
if (Arrays.asList(requestedPermissions).contains(WorkbasketPermission.READ)) {
if (taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN)) {
LOGGER.debug("Skipping read permissions check since user is in role ADMIN");

View File

@ -69,7 +69,7 @@ public class ClassificationDefinitionController {
@GetMapping(path = Mapping.URL_CLASSIFICATIONDEFINITION)
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskanaPagedModel<ClassificationRepresentationModel>> exportClassifications(
@RequestParam(required = false) String domain) throws ClassificationNotFoundException {
@RequestParam(required = false) String domain) {
LOGGER.debug("Entry to exportClassifications(domain= {})", domain);
ClassificationQuery query = classificationService.createClassificationQuery();

View File

@ -2,7 +2,6 @@ package pro.taskana.classification.rest.assembler;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder;
import org.springframework.lang.NonNull;
@ -36,18 +35,41 @@ public class ClassificationRepresentationModelAssembler
@NonNull
@Override
public ClassificationRepresentationModel toModel(@NonNull Classification classification) {
ClassificationRepresentationModel resource =
new ClassificationRepresentationModel(classification);
ClassificationRepresentationModel repModel =
new ClassificationRepresentationModel();
try {
resource.add(
repModel.add(
WebMvcLinkBuilder.linkTo(
methodOn(ClassificationController.class)
.getClassification(classification.getId()))
methodOn(ClassificationController.class)
.getClassification(classification.getId()))
.withSelfRel());
} catch (ClassificationNotFoundException e) {
throw new SystemException("caught unexpected Exception.", e.getCause());
}
return resource;
repModel.setClassificationId(classification.getId());
repModel.setApplicationEntryPoint(classification.getApplicationEntryPoint());
repModel.setCategory(classification.getCategory());
repModel.setDomain(classification.getDomain());
repModel.setKey(classification.getKey());
repModel.setName(classification.getName());
repModel.setParentId(classification.getParentId());
repModel.setParentKey(classification.getParentKey());
repModel.setPriority(classification.getPriority());
repModel.setServiceLevel(classification.getServiceLevel());
repModel.setType(classification.getType());
repModel.setCustom1(classification.getCustom1());
repModel.setCustom2(classification.getCustom2());
repModel.setCustom3(classification.getCustom3());
repModel.setCustom4(classification.getCustom4());
repModel.setCustom5(classification.getCustom5());
repModel.setCustom6(classification.getCustom6());
repModel.setCustom7(classification.getCustom7());
repModel.setCustom8(classification.getCustom8());
repModel.setIsValidInDomain(classification.getIsValidInDomain());
repModel.setCreated(classification.getCreated());
repModel.setModified(classification.getModified());
repModel.setDescription(classification.getDescription());
return repModel;
}
@Override
@ -56,18 +78,34 @@ public class ClassificationRepresentationModelAssembler
}
public Classification toEntityModel(
ClassificationRepresentationModel classificationRepresentationModel) {
ClassificationRepresentationModel repModel) {
ClassificationImpl classification =
(ClassificationImpl)
classificationService.newClassification(
classificationRepresentationModel.getKey(),
classificationRepresentationModel.getDomain(),
classificationRepresentationModel.getType());
BeanUtils.copyProperties(classificationRepresentationModel, classification);
repModel.getKey(),
repModel.getDomain(),
repModel.getType());
classification.setId(classificationRepresentationModel.getClassificationId());
classification.setCreated(classificationRepresentationModel.getCreated());
classification.setModified(classificationRepresentationModel.getModified());
classification.setApplicationEntryPoint(repModel.getApplicationEntryPoint());
classification.setCategory(repModel.getCategory());
classification.setName(repModel.getName());
classification.setParentId(repModel.getParentId());
classification.setParentKey(repModel.getParentKey());
classification.setPriority(repModel.getPriority());
classification.setServiceLevel(repModel.getServiceLevel());
classification.setCustom1(repModel.getCustom1());
classification.setCustom2(repModel.getCustom2());
classification.setCustom3(repModel.getCustom3());
classification.setCustom4(repModel.getCustom4());
classification.setCustom5(repModel.getCustom5());
classification.setCustom6(repModel.getCustom6());
classification.setCustom7(repModel.getCustom7());
classification.setCustom8(repModel.getCustom8());
classification.setIsValidInDomain(repModel.getIsValidInDomain());
classification.setDescription(repModel.getDescription());
classification.setId(repModel.getClassificationId());
classification.setCreated(repModel.getCreated());
classification.setModified(repModel.getModified());
return classification;
}
}

View File

@ -2,7 +2,6 @@ package pro.taskana.classification.rest.assembler;
import static pro.taskana.common.rest.models.TaskanaPagedModelKeys.CLASSIFICATIONS;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.lang.NonNull;
@ -36,17 +35,52 @@ public class ClassificationSummaryRepresentationModelAssembler
@Override
public ClassificationSummaryRepresentationModel toModel(
@NonNull ClassificationSummary classificationSummary) {
return new ClassificationSummaryRepresentationModel(classificationSummary);
ClassificationSummaryRepresentationModel repModel
= new ClassificationSummaryRepresentationModel();
repModel.setClassificationId(classificationSummary.getId());
repModel.setApplicationEntryPoint(classificationSummary.getApplicationEntryPoint());
repModel.setCategory(classificationSummary.getCategory());
repModel.setDomain(classificationSummary.getDomain());
repModel.setKey(classificationSummary.getKey());
repModel.setName(classificationSummary.getName());
repModel.setParentId(classificationSummary.getParentId());
repModel.setParentKey(classificationSummary.getParentKey());
repModel.setPriority(classificationSummary.getPriority());
repModel.setServiceLevel(classificationSummary.getServiceLevel());
repModel.setType(classificationSummary.getType());
repModel.setCustom1(classificationSummary.getCustom1());
repModel.setCustom2(classificationSummary.getCustom2());
repModel.setCustom3(classificationSummary.getCustom3());
repModel.setCustom4(classificationSummary.getCustom4());
repModel.setCustom5(classificationSummary.getCustom5());
repModel.setCustom6(classificationSummary.getCustom6());
repModel.setCustom7(classificationSummary.getCustom7());
repModel.setCustom8(classificationSummary.getCustom8());
return repModel;
}
public ClassificationSummary toEntityModel(ClassificationSummaryRepresentationModel resource) {
public ClassificationSummary toEntityModel(ClassificationSummaryRepresentationModel repModel) {
ClassificationImpl classification =
(ClassificationImpl)
classificationService.newClassification(
resource.getKey(), resource.getDomain(), resource.getType());
classification.setId(resource.getClassificationId());
BeanUtils.copyProperties(resource, classification);
return classification.asSummary();
classificationService
.newClassification(repModel.getKey(), repModel.getDomain(), repModel.getType());
classification.setId(repModel.getClassificationId());
classification.setApplicationEntryPoint(repModel.getApplicationEntryPoint());
classification.setCategory(repModel.getCategory());
classification.setName(repModel.getName());
classification.setParentId(repModel.getParentId());
classification.setParentKey(repModel.getParentKey());
classification.setPriority(repModel.getPriority());
classification.setServiceLevel(repModel.getServiceLevel());
classification.setCustom1(repModel.getCustom1());
classification.setCustom2(repModel.getCustom2());
classification.setCustom3(repModel.getCustom3());
classification.setCustom4(repModel.getCustom4());
classification.setCustom5(repModel.getCustom5());
classification.setCustom6(repModel.getCustom6());
classification.setCustom7(repModel.getCustom7());
classification.setCustom8(repModel.getCustom8());
return classification;
}
@Override

View File

@ -13,16 +13,6 @@ public class ClassificationRepresentationModel extends ClassificationSummaryRepr
private Instant modified; // ISO-8601
private String description;
public ClassificationRepresentationModel() {}
public ClassificationRepresentationModel(Classification classification) {
super(classification);
this.isValidInDomain = classification.getIsValidInDomain();
this.created = classification.getCreated();
this.modified = classification.getModified();
this.description = classification.getDescription();
}
public Boolean getIsValidInDomain() {
return isValidInDomain;
}

View File

@ -30,31 +30,6 @@ public class ClassificationSummaryRepresentationModel
protected String custom7;
protected String custom8;
public ClassificationSummaryRepresentationModel() {
}
public ClassificationSummaryRepresentationModel(ClassificationSummary classification) {
classificationId = classification.getId();
applicationEntryPoint = classification.getApplicationEntryPoint();
category = classification.getCategory();
domain = classification.getDomain();
key = classification.getKey();
name = classification.getName();
parentId = classification.getParentId();
parentKey = classification.getParentKey();
priority = classification.getPriority();
serviceLevel = classification.getServiceLevel();
type = classification.getType();
custom1 = classification.getCustom1();
custom2 = classification.getCustom2();
custom3 = classification.getCustom3();
custom4 = classification.getCustom4();
custom5 = classification.getCustom5();
custom6 = classification.getCustom6();
custom7 = classification.getCustom7();
custom8 = classification.getCustom8();
}
public String getClassificationId() {
return classificationId;
}
@ -206,48 +181,4 @@ public class ClassificationSummaryRepresentationModel
public void setCustom8(String custom8) {
this.custom8 = custom8;
}
@Override
public String toString() {
return "ClassificationSummaryResource ["
+ "classificationId="
+ this.classificationId
+ ", applicationEntryPoint="
+ this.applicationEntryPoint
+ ", category="
+ this.category
+ ", domain="
+ this.domain
+ ", key="
+ this.key
+ ", name="
+ this.name
+ ", parentId="
+ this.parentId
+ ", parentKey="
+ this.parentKey
+ ", priority="
+ this.priority
+ ", serviceLevel="
+ this.serviceLevel
+ ", type="
+ this.type
+ ", custom1="
+ this.custom1
+ ", custom2="
+ this.custom2
+ ", custom3="
+ this.custom3
+ ", custom4="
+ this.custom4
+ ", custom5="
+ this.custom5
+ ", custom6="
+ this.custom6
+ ", custom7="
+ this.custom7
+ ", custom8="
+ this.custom8
+ "]";
}
}

View File

@ -43,7 +43,7 @@ public final class Mapping {
URL_WORKBASKET_ID + "/workbasketAccessItems";
public static final String URL_WORKBASKET_ID_DISTRIBUTION =
URL_WORKBASKET_ID + "/distribution-targets";
public static final String URL_WORKBASKETDEFIITIONS = PRE + "workbasket-definitions";
public static final String URL_WORKBASKETDEFINITIONS = PRE + "workbasket-definitions";
private Mapping() {}
}

View File

@ -4,7 +4,6 @@ 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;
@ -26,21 +25,32 @@ public class AttachmentRepresentationModelAssembler
private final TaskService taskService;
private final ClassificationSummaryRepresentationModelAssembler classificationAssembler;
private final ClassificationSummaryRepresentationModelAssembler classificationSummaryAssembler;
@Autowired
public AttachmentRepresentationModelAssembler(TaskService taskService,
ClassificationSummaryRepresentationModelAssembler classificationAssembler) {
public AttachmentRepresentationModelAssembler(
TaskService taskService,
ClassificationSummaryRepresentationModelAssembler classificationSummaryAssembler) {
this.taskService = taskService;
this.classificationAssembler = classificationAssembler;
this.classificationSummaryAssembler = classificationSummaryAssembler;
}
@NonNull
@Override
public AttachmentRepresentationModel toModel(@NonNull Attachment attachment) {
AttachmentRepresentationModel resource = new AttachmentRepresentationModel(attachment);
resource.add(linkTo(AttachmentController.class).slash(attachment.getId()).withSelfRel());
return resource;
AttachmentRepresentationModel repModel = new AttachmentRepresentationModel();
repModel.setAttachmentId(attachment.getId());
repModel.setTaskId(attachment.getTaskId());
repModel.setCreated(attachment.getCreated());
repModel.setModified(attachment.getModified());
repModel.setReceived(attachment.getReceived());
repModel.setClassificationSummary(
classificationSummaryAssembler.toModel(attachment.getClassificationSummary()));
repModel.setObjectReference(attachment.getObjectReference());
repModel.setChannel(attachment.getChannel());
repModel.setCustomAttributes(attachment.getCustomAttributes());
repModel.add(linkTo(AttachmentController.class).slash(attachment.getId()).withSelfRel());
return repModel;
}
public List<Attachment> toAttachmentList(List<AttachmentRepresentationModel> resources) {
@ -50,10 +60,18 @@ public class AttachmentRepresentationModelAssembler
private AttachmentImpl toEntityModel(
AttachmentRepresentationModel attachmentRepresentationModel) {
AttachmentImpl attachment = (AttachmentImpl) taskService.newAttachment();
BeanUtils.copyProperties(attachmentRepresentationModel, attachment);
attachment.setId(attachmentRepresentationModel.getAttachmentId());
attachment.setClassificationSummary(classificationAssembler.toEntityModel(
attachmentRepresentationModel.getClassificationSummary()));
attachment.setTaskId(attachmentRepresentationModel.getTaskId());
attachment.setCreated(attachmentRepresentationModel.getCreated());
attachment.setModified(attachmentRepresentationModel.getModified());
attachment.setReceived(attachmentRepresentationModel.getReceived());
attachment.setClassificationSummary(
classificationSummaryAssembler.toEntityModel(
attachmentRepresentationModel.getClassificationSummary()));
attachment.setObjectReference(attachmentRepresentationModel.getObjectReference());
attachment.setChannel(attachmentRepresentationModel.getChannel());
attachment.setCustomAttributes(attachmentRepresentationModel.getCustomAttributes());
return attachment;
}
}

View File

@ -7,7 +7,6 @@ import static pro.taskana.common.rest.models.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;
@ -39,34 +38,37 @@ public class TaskCommentRepresentationModelAssembler
@NonNull
@Override
public TaskCommentRepresentationModel toModel(@NonNull TaskComment taskComment) {
TaskCommentRepresentationModel taskCommentRepresentationModel =
new TaskCommentRepresentationModel(taskComment);
TaskCommentRepresentationModel repModel =
new TaskCommentRepresentationModel();
repModel.setTaskCommentId(taskComment.getId());
repModel.setTaskId(taskComment.getTaskId());
repModel.setTextField(taskComment.getTextField());
repModel.setCreator(taskComment.getCreator());
repModel.setCreated(taskComment.getCreated().toString());
repModel.setModified(taskComment.getModified().toString());
try {
taskCommentRepresentationModel.add(
repModel.add(
linkTo(methodOn(TaskCommentController.class).getTaskComment(taskComment.getId()))
.withSelfRel());
} catch (Exception e) {
throw new SystemException("caught unexpected Exception.", e.getCause());
}
return taskCommentRepresentationModel;
return repModel;
}
public TaskComment toEntityModel(TaskCommentRepresentationModel taskCommentRepresentationModel) {
public TaskComment toEntityModel(TaskCommentRepresentationModel repModel) {
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()));
(TaskCommentImpl) taskService.newTaskComment(repModel.getTaskId());
taskComment.setId(repModel.getTaskCommentId());
taskComment.setTextField(repModel.getTextField());
taskComment.setCreator(repModel.getCreator());
if (repModel.getCreated() != null) {
taskComment.setCreated(Instant.parse(repModel.getCreated()));
}
if (taskCommentRepresentationModel.getModified() != null) {
taskComment.setModified(Instant.parse(taskCommentRepresentationModel.getModified()));
if (repModel.getModified() != null) {
taskComment.setModified(Instant.parse(repModel.getModified()));
}
return taskComment;
}

View File

@ -5,7 +5,6 @@ import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import java.util.Objects;
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;
@ -36,7 +35,7 @@ public class TaskRepresentationModelAssembler
private final ClassificationSummaryRepresentationModelAssembler classificationAssembler;
private final WorkbasketSummaryRepresentationModelAssembler
workbasketSummaryRepresentationModelAssembler;
workbasketAssembler;
private final AttachmentRepresentationModelAssembler attachmentAssembler;
@ -44,53 +43,130 @@ public class TaskRepresentationModelAssembler
public TaskRepresentationModelAssembler(
TaskService taskService,
ClassificationSummaryRepresentationModelAssembler classificationAssembler,
WorkbasketSummaryRepresentationModelAssembler workbasketSummaryRepresentationModelAssembler,
WorkbasketSummaryRepresentationModelAssembler workbasketAssembler,
AttachmentRepresentationModelAssembler attachmentAssembler) {
this.taskService = taskService;
this.classificationAssembler = classificationAssembler;
this.workbasketSummaryRepresentationModelAssembler
= workbasketSummaryRepresentationModelAssembler;
this.workbasketAssembler
= workbasketAssembler;
this.attachmentAssembler = attachmentAssembler;
}
@NonNull
@Override
public TaskRepresentationModel toModel(@NonNull Task task) {
TaskRepresentationModel resource;
TaskRepresentationModel repModel = new TaskRepresentationModel();
repModel.setTaskId(task.getId());
repModel.setExternalId(task.getExternalId());
repModel.setCreated(task.getCreated());
repModel.setClaimed(task.getClaimed());
repModel.setCompleted(task.getCompleted());
repModel.setModified(task.getModified());
repModel.setPlanned(task.getPlanned());
repModel.setDue(task.getDue());
repModel.setName(task.getName());
repModel.setCreator(task.getCreator());
repModel.setNote(task.getNote());
repModel.setDescription(task.getDescription());
repModel.setPriority(task.getPriority());
repModel.setState(task.getState());
repModel.setClassificationSummary(
classificationAssembler.toModel(task.getClassificationSummary()));
repModel.setWorkbasketSummary(workbasketAssembler.toModel(task.getWorkbasketSummary()));
repModel.setBusinessProcessId(task.getBusinessProcessId());
repModel.setParentBusinessProcessId(task.getParentBusinessProcessId());
repModel.setOwner(task.getOwner());
repModel.setPrimaryObjRef(task.getPrimaryObjRef());
repModel.setRead(task.isRead());
repModel.setTransferred(task.isTransferred());
repModel.setAttachments(
task.getAttachments().stream()
.map(attachmentAssembler::toModel)
.collect(Collectors.toList()));
repModel.setCustomAttributes(
task.getCustomAttributes().entrySet().stream()
.map(e -> new TaskRepresentationModel.CustomAttribute(e.getKey(), e.getValue()))
.collect(Collectors.toList()));
repModel.setCallbackInfo(
task.getCallbackInfo().entrySet().stream()
.map(e -> new TaskRepresentationModel.CustomAttribute(e.getKey(), e.getValue()))
.collect(Collectors.toList()));
try {
resource = new TaskRepresentationModel(task);
resource.add(linkTo(methodOn(TaskController.class).getTask(task.getId())).withSelfRel());
repModel.add(linkTo(methodOn(TaskController.class).getTask(task.getId())).withSelfRel());
repModel.setCustom1(task.getCustomAttribute("1"));
repModel.setCustom2(task.getCustomAttribute("2"));
repModel.setCustom3(task.getCustomAttribute("3"));
repModel.setCustom4(task.getCustomAttribute("4"));
repModel.setCustom5(task.getCustomAttribute("5"));
repModel.setCustom6(task.getCustomAttribute("6"));
repModel.setCustom7(task.getCustomAttribute("7"));
repModel.setCustom8(task.getCustomAttribute("8"));
repModel.setCustom9(task.getCustomAttribute("9"));
repModel.setCustom10(task.getCustomAttribute("10"));
repModel.setCustom11(task.getCustomAttribute("11"));
repModel.setCustom12(task.getCustomAttribute("12"));
repModel.setCustom13(task.getCustomAttribute("13"));
repModel.setCustom14(task.getCustomAttribute("14"));
repModel.setCustom15(task.getCustomAttribute("15"));
repModel.setCustom16(task.getCustomAttribute("16"));
} catch (InvalidArgumentException | TaskNotFoundException | NotAuthorizedException e) {
throw new SystemException("caught unexpected Exception.", e.getCause());
}
return resource;
return repModel;
}
public Task toEntityModel(TaskRepresentationModel resource) {
TaskImpl task =
(TaskImpl)
taskService.newTask(
resource.getWorkbasketSummary().getWorkbasketId());
task.setId(resource.getTaskId());
task.setExternalId(resource.getExternalId());
BeanUtils.copyProperties(resource, task);
public Task toEntityModel(TaskRepresentationModel repModel) {
TaskImpl task = (TaskImpl) taskService
.newTask(repModel.getWorkbasketSummary().getWorkbasketId());
task.setId(repModel.getTaskId());
task.setExternalId(repModel.getExternalId());
task.setCreated(repModel.getCreated());
task.setClaimed(repModel.getClaimed());
task.setCompleted(repModel.getCompleted());
task.setModified(repModel.getModified());
task.setPlanned(repModel.getPlanned());
task.setDue(repModel.getDue());
task.setName(repModel.getName());
task.setCreator(repModel.getCreator());
task.setNote(repModel.getNote());
task.setDescription(repModel.getDescription());
task.setPriority(repModel.getPriority());
task.setState(repModel.getState());
task.setClassificationSummary(
classificationAssembler.toEntityModel(
resource.getClassificationSummary()));
task.setWorkbasketSummary(
workbasketSummaryRepresentationModelAssembler
.toEntityModel(resource.getWorkbasketSummary()));
task.setAttachments(attachmentAssembler.toAttachmentList(resource.getAttachments()));
classificationAssembler.toEntityModel(repModel.getClassificationSummary()));
task
.setWorkbasketSummary(workbasketAssembler.toEntityModel(repModel.getWorkbasketSummary()));
task.setBusinessProcessId(repModel.getBusinessProcessId());
task.setParentBusinessProcessId(repModel.getParentBusinessProcessId());
task.setOwner(repModel.getOwner());
task.setPrimaryObjRef(repModel.getPrimaryObjRef());
task.setRead(repModel.isRead());
task.setTransferred(repModel.isTransferred());
task.setCustom1(repModel.getCustom1());
task.setCustom2(repModel.getCustom2());
task.setCustom3(repModel.getCustom3());
task.setCustom4(repModel.getCustom4());
task.setCustom5(repModel.getCustom5());
task.setCustom6(repModel.getCustom6());
task.setCustom7(repModel.getCustom7());
task.setCustom8(repModel.getCustom8());
task.setCustom9(repModel.getCustom9());
task.setCustom10(repModel.getCustom10());
task.setCustom11(repModel.getCustom11());
task.setCustom12(repModel.getCustom12());
task.setCustom13(repModel.getCustom13());
task.setCustom14(repModel.getCustom14());
task.setCustom15(repModel.getCustom15());
task.setCustom16(repModel.getCustom16());
task.setAttachments(attachmentAssembler.toAttachmentList(repModel.getAttachments()));
task.setCustomAttributes(
resource.getCustomAttributes().stream()
repModel.getCustomAttributes().stream()
.filter(e -> Objects.nonNull(e.getKey()) && !e.getKey().isEmpty())
.collect(Collectors.toMap(CustomAttribute::getKey, CustomAttribute::getValue)));
task.setCallbackInfo(
resource.getCallbackInfo().stream()
repModel.getCallbackInfo().stream()
.filter(e -> Objects.nonNull(e.getKey()) && !e.getKey().isEmpty())
.collect(Collectors.toMap(CustomAttribute::getKey, CustomAttribute::getValue)));
return task;
}
}

View File

@ -4,43 +4,159 @@ import static pro.taskana.common.rest.models.TaskanaPagedModelKeys.TASKS;
import java.util.List;
import java.util.stream.Collectors;
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.rest.assembler.ClassificationSummaryRepresentationModelAssembler;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.SystemException;
import pro.taskana.common.rest.Mapping;
import pro.taskana.common.rest.models.TaskanaPagedModel;
import pro.taskana.resource.rest.PageLinks;
import pro.taskana.task.api.TaskService;
import pro.taskana.task.api.models.TaskSummary;
import pro.taskana.task.internal.models.TaskImpl;
import pro.taskana.task.rest.models.TaskSummaryRepresentationModel;
import pro.taskana.workbasket.rest.assembler.WorkbasketSummaryRepresentationModelAssembler;
/** EntityModel assembler for {@link TaskSummaryRepresentationModel}. */
/**
* EntityModel assembler for {@link TaskSummaryRepresentationModel}.
*/
@Component
public class TaskSummaryRepresentationModelAssembler
implements RepresentationModelAssembler<TaskSummary, TaskSummaryRepresentationModel> {
private final ClassificationSummaryRepresentationModelAssembler classificationAssembler;
private final WorkbasketSummaryRepresentationModelAssembler workbasketAssembler;
private final AttachmentSummaryRepresentationModelAssembler attachmentAssembler;
private final TaskService taskService;
@Autowired
public TaskSummaryRepresentationModelAssembler(
ClassificationSummaryRepresentationModelAssembler classificationAssembler,
WorkbasketSummaryRepresentationModelAssembler workbasketAssembler,
AttachmentSummaryRepresentationModelAssembler attachmentAssembler,
TaskService taskService) {
this.classificationAssembler = classificationAssembler;
this.workbasketAssembler = workbasketAssembler;
this.attachmentAssembler = attachmentAssembler;
this.taskService = taskService;
}
@NonNull
@Override
public TaskSummaryRepresentationModel toModel(@NonNull TaskSummary taskSummary) {
TaskSummaryRepresentationModel resource;
TaskSummaryRepresentationModel repModel = new TaskSummaryRepresentationModel();
repModel.setTaskId(taskSummary.getId());
repModel.setExternalId(taskSummary.getExternalId());
repModel.setCreated(taskSummary.getCreated());
repModel.setClaimed(taskSummary.getClaimed());
repModel.setCompleted(taskSummary.getCompleted());
repModel.setModified(taskSummary.getModified());
repModel.setPlanned(taskSummary.getPlanned());
repModel.setDue(taskSummary.getDue());
repModel.setName(taskSummary.getName());
repModel.setCreator(taskSummary.getCreator());
repModel.setNote(taskSummary.getNote());
repModel.setDescription(taskSummary.getDescription());
repModel.setPriority(taskSummary.getPriority());
repModel.setState(taskSummary.getState());
repModel.setClassificationSummary(
classificationAssembler.toModel(taskSummary.getClassificationSummary()));
repModel.setWorkbasketSummary(workbasketAssembler.toModel(taskSummary.getWorkbasketSummary()));
repModel.setBusinessProcessId(taskSummary.getBusinessProcessId());
repModel.setParentBusinessProcessId(taskSummary.getParentBusinessProcessId());
repModel.setOwner(taskSummary.getOwner());
repModel.setPrimaryObjRef(taskSummary.getPrimaryObjRef());
repModel.setRead(taskSummary.isRead());
repModel.setTransferred(taskSummary.isTransferred());
repModel.setAttachmentSummaries(
taskSummary.getAttachmentSummaries().stream()
.map(attachmentAssembler::toModel)
.collect(Collectors.toList()));
try {
resource = new TaskSummaryRepresentationModel(taskSummary);
return resource;
repModel.setCustom1(taskSummary.getCustomAttribute("1"));
repModel.setCustom2(taskSummary.getCustomAttribute("2"));
repModel.setCustom3(taskSummary.getCustomAttribute("3"));
repModel.setCustom4(taskSummary.getCustomAttribute("4"));
repModel.setCustom5(taskSummary.getCustomAttribute("5"));
repModel.setCustom6(taskSummary.getCustomAttribute("6"));
repModel.setCustom7(taskSummary.getCustomAttribute("7"));
repModel.setCustom8(taskSummary.getCustomAttribute("8"));
repModel.setCustom9(taskSummary.getCustomAttribute("9"));
repModel.setCustom10(taskSummary.getCustomAttribute("10"));
repModel.setCustom11(taskSummary.getCustomAttribute("11"));
repModel.setCustom12(taskSummary.getCustomAttribute("12"));
repModel.setCustom13(taskSummary.getCustomAttribute("13"));
repModel.setCustom14(taskSummary.getCustomAttribute("14"));
repModel.setCustom15(taskSummary.getCustomAttribute("15"));
repModel.setCustom16(taskSummary.getCustomAttribute("16"));
} catch (InvalidArgumentException e) {
throw new SystemException("caught unexpected Exception.", e.getCause());
}
return repModel;
}
public TaskSummary toEntityModel(TaskSummaryRepresentationModel repModel) {
TaskImpl taskSummary = (TaskImpl) taskService.newTask();
taskSummary.setId(repModel.getTaskId());
taskSummary.setExternalId(repModel.getExternalId());
taskSummary.setCreated(repModel.getCreated());
taskSummary.setClaimed(repModel.getClaimed());
taskSummary.setCompleted(repModel.getCompleted());
taskSummary.setModified(repModel.getModified());
taskSummary.setPlanned(repModel.getPlanned());
taskSummary.setDue(repModel.getDue());
taskSummary.setName(repModel.getName());
taskSummary.setCreator(repModel.getCreator());
taskSummary.setNote(repModel.getNote());
taskSummary.setDescription(repModel.getDescription());
taskSummary.setPriority(repModel.getPriority());
taskSummary.setState(repModel.getState());
taskSummary.setClassificationSummary(
classificationAssembler.toEntityModel(repModel.getClassificationSummary()));
taskSummary
.setWorkbasketSummary(workbasketAssembler.toEntityModel(repModel.getWorkbasketSummary()));
taskSummary.setBusinessProcessId(repModel.getBusinessProcessId());
taskSummary.setParentBusinessProcessId(repModel.getParentBusinessProcessId());
taskSummary.setOwner(repModel.getOwner());
taskSummary.setPrimaryObjRef(repModel.getPrimaryObjRef());
taskSummary.setRead(repModel.isRead());
taskSummary.setTransferred(repModel.isTransferred());
taskSummary.setAttachmentSummaries(
repModel.getAttachmentSummaries().stream()
.map(attachmentAssembler::toEntityModel)
.collect(Collectors.toList()));
taskSummary.setCustom1(repModel.getCustom1());
taskSummary.setCustom2(repModel.getCustom2());
taskSummary.setCustom3(repModel.getCustom3());
taskSummary.setCustom4(repModel.getCustom4());
taskSummary.setCustom5(repModel.getCustom5());
taskSummary.setCustom6(repModel.getCustom6());
taskSummary.setCustom7(repModel.getCustom7());
taskSummary.setCustom8(repModel.getCustom8());
taskSummary.setCustom9(repModel.getCustom9());
taskSummary.setCustom10(repModel.getCustom10());
taskSummary.setCustom11(repModel.getCustom11());
taskSummary.setCustom12(repModel.getCustom12());
taskSummary.setCustom13(repModel.getCustom13());
taskSummary.setCustom14(repModel.getCustom14());
taskSummary.setCustom15(repModel.getCustom15());
taskSummary.setCustom16(repModel.getCustom16());
return taskSummary;
}
@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)));
.map(this::toModel)
.collect(
Collectors.collectingAndThen(
Collectors.toList(),
list -> new TaskanaPagedModel<>(TASKS, list, pageMetadata)));
}
}

View File

@ -13,14 +13,6 @@ public class AttachmentRepresentationModel
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;
}
@ -28,27 +20,4 @@ public class AttachmentRepresentationModel
public void setCustomAttributes(Map<String, String> customAttributes) {
this.customAttributes = customAttributes;
}
@Override
public String toString() {
return "AttachmentRepresentationModel [customAttributes="
+ customAttributes
+ ", attachmentId="
+ attachmentId
+ ", taskId="
+ taskId
+ ", created="
+ created
+ ", modified="
+ modified
+ ", classificationSummaryRepresentationModel="
+ classificationSummary
+ ", objectReference="
+ objectReference
+ ", channel="
+ channel
+ ", received="
+ received
+ "]";
}
}

View File

@ -20,22 +20,6 @@ public class AttachmentSummaryRepresentationModel
protected ObjectReference objectReference;
protected String channel;
// TODO: remove this constructor
public AttachmentSummaryRepresentationModel() {}
// TODO: remove this constructor
public AttachmentSummaryRepresentationModel(AttachmentSummary attachmentSummary) {
this.attachmentId = attachmentSummary.getId();
this.taskId = attachmentSummary.getTaskId();
this.created = attachmentSummary.getCreated();
this.modified = attachmentSummary.getModified();
this.received = attachmentSummary.getReceived();
this.classificationSummary =
new ClassificationSummaryRepresentationModel(attachmentSummary.getClassificationSummary());
this.objectReference = attachmentSummary.getObjectReference();
this.channel = attachmentSummary.getChannel();
}
public String getAttachmentId() {
return attachmentId;
}

View File

@ -15,17 +15,6 @@ public class TaskCommentRepresentationModel
private String created;
private String modified;
public TaskCommentRepresentationModel() {}
public TaskCommentRepresentationModel(TaskComment taskComment) {
this.taskCommentId = taskComment.getId();
this.taskId = taskComment.getTaskId();
this.textField = taskComment.getTextField();
this.creator = taskComment.getCreator();
this.created = taskComment.getCreated().toString();
this.modified = taskComment.getModified().toString();
}
public String getTaskCommentId() {
return taskCommentId;
}
@ -74,20 +63,4 @@ public class TaskCommentRepresentationModel
this.modified = modified;
}
@Override
public String toString() {
return "TaskCommentResource [taskCommentId="
+ taskCommentId
+ ", taskId="
+ taskId
+ ", textField="
+ textField
+ ", creator="
+ creator
+ ", created="
+ created
+ ", modified="
+ modified
+ "]";
}
}

View File

@ -4,10 +4,9 @@ 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;
import pro.taskana.task.rest.assembler.AttachmentRepresentationModelAssembler;
/**
* EntityModel class for {@link Task}.
@ -16,31 +15,12 @@ import pro.taskana.task.api.models.Task;
public class TaskRepresentationModel extends TaskSummaryRepresentationModel {
protected AttachmentRepresentationModelAssembler attachmentAssembler;
// 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;
}
@ -65,38 +45,6 @@ public class TaskRepresentationModel extends TaskSummaryRepresentationModel {
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()}.
@ -125,9 +73,5 @@ public class TaskRepresentationModel extends TaskSummaryRepresentationModel {
return value;
}
@Override
public String toString() {
return "CustomAttribute [" + "key= " + this.key + "value= " + this.value + "]";
}
}
}

View File

@ -3,14 +3,11 @@ package pro.taskana.task.rest.models;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.hateoas.RepresentationModel;
import pro.taskana.classification.rest.models.ClassificationSummaryRepresentationModel;
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.TaskSummary;
import pro.taskana.workbasket.api.models.WorkbasketSummary;
import pro.taskana.workbasket.rest.models.WorkbasketSummaryRepresentationModel;
@ -61,56 +58,6 @@ public class TaskSummaryRepresentationModel
private List<AttachmentSummaryRepresentationModel> attachmentSummaries =
new ArrayList<>();
TaskSummaryRepresentationModel() {
}
public TaskSummaryRepresentationModel(TaskSummary taskSummary) throws InvalidArgumentException {
this.taskId = taskSummary.getId();
this.externalId = taskSummary.getExternalId();
created = taskSummary.getCreated();
claimed = taskSummary.getClaimed();
completed = taskSummary.getCompleted();
modified = taskSummary.getModified();
planned = taskSummary.getPlanned();
due = taskSummary.getDue();
this.name = taskSummary.getName();
this.creator = taskSummary.getCreator();
this.note = taskSummary.getNote();
this.description = taskSummary.getDescription();
this.priority = taskSummary.getPriority();
this.state = taskSummary.getState();
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.attachmentSummaries =
taskSummary.getAttachmentSummaries().stream()
.map(AttachmentSummaryRepresentationModel::new)
.collect(Collectors.toList());
this.custom1 = taskSummary.getCustomAttribute("1");
this.custom2 = taskSummary.getCustomAttribute("2");
this.custom3 = taskSummary.getCustomAttribute("3");
this.custom4 = taskSummary.getCustomAttribute("4");
this.custom5 = taskSummary.getCustomAttribute("5");
this.custom6 = taskSummary.getCustomAttribute("6");
this.custom7 = taskSummary.getCustomAttribute("7");
this.custom8 = taskSummary.getCustomAttribute("8");
this.custom9 = taskSummary.getCustomAttribute("9");
this.custom10 = taskSummary.getCustomAttribute("10");
this.custom11 = taskSummary.getCustomAttribute("11");
this.custom12 = taskSummary.getCustomAttribute("12");
this.custom13 = taskSummary.getCustomAttribute("13");
this.custom14 = taskSummary.getCustomAttribute("14");
this.custom15 = taskSummary.getCustomAttribute("15");
this.custom16 = taskSummary.getCustomAttribute("16");
}
public String getTaskId() {
return taskId;
}
@ -426,33 +373,5 @@ public class TaskSummaryRepresentationModel
this.custom16 = custom16;
}
@Override
public String toString() {
return "TaskSummaryResource ["
+ "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
+ "priority= "
+ this.priority
+ "owner= "
+ this.owner
+ "]";
}
}

View File

@ -44,6 +44,7 @@ import pro.taskana.workbasket.api.models.WorkbasketSummary;
import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl;
import pro.taskana.workbasket.internal.models.WorkbasketImpl;
import pro.taskana.workbasket.rest.assembler.WorkbasketDefinitionRepresentationModelAssembler;
import pro.taskana.workbasket.rest.assembler.WorkbasketRepresentationModelAssembler;
import pro.taskana.workbasket.rest.models.WorkbasketDefinitionRepresentationModel;
import pro.taskana.workbasket.rest.models.WorkbasketRepresentationModel;
@ -57,19 +58,22 @@ public class WorkbasketDefinitionController {
private final WorkbasketService workbasketService;
private final WorkbasketDefinitionRepresentationModelAssembler workbasketDefinitionAssembler;
private final WorkbasketRepresentationModelAssembler workbasketAssembler;
private final ObjectMapper mapper;
@Autowired
WorkbasketDefinitionController(
WorkbasketService workbasketService,
WorkbasketDefinitionRepresentationModelAssembler workbasketDefinitionAssembler,
WorkbasketRepresentationModelAssembler workbasketAssembler,
ObjectMapper mapper) {
this.workbasketService = workbasketService;
this.workbasketDefinitionAssembler = workbasketDefinitionAssembler;
this.workbasketAssembler = workbasketAssembler;
this.mapper = mapper;
}
@GetMapping(path = Mapping.URL_WORKBASKETDEFIITIONS)
@GetMapping(path = Mapping.URL_WORKBASKETDEFINITIONS)
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskanaPagedModel<WorkbasketDefinitionRepresentationModel>>
exportWorkbaskets(@RequestParam(required = false) String domain) {
@ -118,7 +122,7 @@ public class WorkbasketDefinitionController {
* workbasket and access_id already exists.
* @throws ConcurrencyException if workbasket was updated by an other user
*/
@PostMapping(path = Mapping.URL_WORKBASKETDEFIITIONS)
@PostMapping(path = Mapping.URL_WORKBASKETDEFINITIONS)
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<Void> importWorkbaskets(@RequestParam("file") MultipartFile file)
throws IOException, NotAuthorizedException, DomainNotFoundException,
@ -212,7 +216,7 @@ public class WorkbasketDefinitionController {
}
private Workbasket removeId(Workbasket importedWb) {
WorkbasketRepresentationModel wbRes = new WorkbasketRepresentationModel(importedWb);
WorkbasketRepresentationModel wbRes = workbasketAssembler.toModel(importedWb);
wbRes.setWorkbasketId(null);
return workbasketDefinitionAssembler.toEntityModel(wbRes);
}

View File

@ -6,7 +6,6 @@ import static pro.taskana.common.rest.models.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;
@ -44,17 +43,59 @@ public class WorkbasketAccessItemRepresentationModelAssembler
@NonNull
@Override
public WorkbasketAccessItemRepresentationModel toModel(@NonNull WorkbasketAccessItem wbAccItem) {
return new WorkbasketAccessItemRepresentationModel(wbAccItem);
WorkbasketAccessItemRepresentationModel repModel
= new WorkbasketAccessItemRepresentationModel();
repModel.setAccessId(wbAccItem.getAccessId());
repModel.setWorkbasketId(wbAccItem.getWorkbasketId());
repModel.setWorkbasketKey(wbAccItem.getWorkbasketKey());
repModel.setAccessItemId(wbAccItem.getId());
repModel.setAccessName(wbAccItem.getAccessName());
repModel.setPermRead(wbAccItem.isPermRead());
repModel.setPermOpen(wbAccItem.isPermOpen());
repModel.setPermAppend(wbAccItem.isPermAppend());
repModel.setPermTransfer(wbAccItem.isPermTransfer());
repModel.setPermDistribute(wbAccItem.isPermDistribute());
repModel.setPermCustom1(wbAccItem.isPermCustom1());
repModel.setPermCustom2(wbAccItem.isPermCustom2());
repModel.setPermCustom3(wbAccItem.isPermCustom3());
repModel.setPermCustom4(wbAccItem.isPermCustom4());
repModel.setPermCustom5(wbAccItem.isPermCustom5());
repModel.setPermCustom6(wbAccItem.isPermCustom6());
repModel.setPermCustom7(wbAccItem.isPermCustom7());
repModel.setPermCustom8(wbAccItem.isPermCustom8());
repModel.setPermCustom9(wbAccItem.isPermCustom9());
repModel.setPermCustom10(wbAccItem.isPermCustom10());
repModel.setPermCustom11(wbAccItem.isPermCustom11());
repModel.setPermCustom12(wbAccItem.isPermCustom12());
return repModel;
}
public WorkbasketAccessItem toEntityModel(
WorkbasketAccessItemRepresentationModel wbAccItemResource) {
WorkbasketAccessItemRepresentationModel repModel) {
WorkbasketAccessItemImpl wbAccItemModel =
(WorkbasketAccessItemImpl)
workbasketService.newWorkbasketAccessItem(
wbAccItemResource.getWorkbasketId(), wbAccItemResource.getAccessId());
BeanUtils.copyProperties(wbAccItemResource, wbAccItemModel);
wbAccItemModel.setId(wbAccItemResource.getAccessItemId());
repModel.getWorkbasketId(), repModel.getAccessId());
wbAccItemModel.setWorkbasketKey(repModel.getWorkbasketKey());
wbAccItemModel.setAccessName(repModel.getAccessName());
wbAccItemModel.setPermRead(repModel.isPermRead());
wbAccItemModel.setPermOpen(repModel.isPermOpen());
wbAccItemModel.setPermAppend(repModel.isPermAppend());
wbAccItemModel.setPermTransfer(repModel.isPermTransfer());
wbAccItemModel.setPermDistribute(repModel.isPermDistribute());
wbAccItemModel.setPermCustom1(repModel.isPermCustom1());
wbAccItemModel.setPermCustom2(repModel.isPermCustom2());
wbAccItemModel.setPermCustom3(repModel.isPermCustom3());
wbAccItemModel.setPermCustom4(repModel.isPermCustom4());
wbAccItemModel.setPermCustom5(repModel.isPermCustom5());
wbAccItemModel.setPermCustom6(repModel.isPermCustom6());
wbAccItemModel.setPermCustom7(repModel.isPermCustom7());
wbAccItemModel.setPermCustom8(repModel.isPermCustom8());
wbAccItemModel.setPermCustom9(repModel.isPermCustom9());
wbAccItemModel.setPermCustom10(repModel.isPermCustom10());
wbAccItemModel.setPermCustom11(repModel.isPermCustom11());
wbAccItemModel.setPermCustom12(repModel.isPermCustom12());
wbAccItemModel.setId(repModel.getAccessItemId());
return wbAccItemModel;
}

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List;
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;
@ -35,27 +34,42 @@ public class WorkbasketDefinitionRepresentationModelAssembler
private final WorkbasketService workbasketService;
@Autowired
public WorkbasketDefinitionRepresentationModelAssembler(WorkbasketService workbasketService) {
public WorkbasketDefinitionRepresentationModelAssembler(WorkbasketService workbasketService,
WorkbasketRepresentationModelAssembler workbasketAssembler
) {
this.workbasketService = workbasketService;
}
@NonNull
public WorkbasketDefinitionRepresentationModel toModel(@NonNull Workbasket workbasket) {
WorkbasketRepresentationModelWithoutLinks basket
= new WorkbasketRepresentationModelWithoutLinks();
WorkbasketRepresentationModelWithoutLinks basket =
new WorkbasketRepresentationModelWithoutLinks(workbasket);
basket.setKey(workbasket.getKey());
basket.setModified(workbasket.getModified());
basket.setCreated(workbasket.getModified());
basket.setWorkbasketId(workbasket.getId());
basket.setDescription(workbasket.getDescription());
basket.setDomain(workbasket.getDomain());
basket.setName(workbasket.getName());
basket.setType(workbasket.getType());
basket.setOwner(workbasket.getOwner());
basket.setCustom1(workbasket.getCustom1());
basket.setCustom2(workbasket.getCustom2());
basket.setCustom3(workbasket.getCustom3());
basket.setCustom4(workbasket.getCustom4());
basket.setOrgLevel1(workbasket.getOrgLevel1());
basket.setOrgLevel2(workbasket.getOrgLevel2());
basket.setOrgLevel3(workbasket.getOrgLevel3());
basket.setOrgLevel4(workbasket.getOrgLevel4());
List<WorkbasketAccessItemImpl> authorizations = new ArrayList<>();
Set<String> distroTargets = null;
try {
for (WorkbasketAccessItem accessItem :
workbasketService.getWorkbasketAccessItems(basket.getWorkbasketId())) {
authorizations.add((WorkbasketAccessItemImpl) accessItem);
}
} catch (NotAuthorizedException e) {
throw new SystemException("Caught Exception", e);
}
Set<String> distroTargets = null;
try {
distroTargets =
workbasketService.getDistributionTargets(workbasket.getId()).stream()
.map(WorkbasketSummary::getId)
@ -63,18 +77,36 @@ public class WorkbasketDefinitionRepresentationModelAssembler
} catch (NotAuthorizedException | WorkbasketNotFoundException e) {
throw new SystemException("Caught Exception", e);
}
return new WorkbasketDefinitionRepresentationModel(basket, distroTargets, authorizations);
WorkbasketDefinitionRepresentationModel repModel
= new WorkbasketDefinitionRepresentationModel();
repModel.setWorkbasket(basket);
repModel.setAuthorizations(authorizations);
repModel.setDistributionTargets(distroTargets);
return repModel;
}
public Workbasket toEntityModel(WorkbasketRepresentationModel wbResource) {
public Workbasket toEntityModel(WorkbasketRepresentationModel repModel) {
WorkbasketImpl workbasket =
(WorkbasketImpl)
workbasketService.newWorkbasket(wbResource.getKey(), wbResource.getDomain());
BeanUtils.copyProperties(wbResource, workbasket);
workbasket.setId(wbResource.getWorkbasketId());
workbasket.setModified(wbResource.getModified());
workbasket.setCreated(wbResource.getCreated());
workbasketService.newWorkbasket(repModel.getKey(), repModel.getDomain());
workbasket.setId(repModel.getWorkbasketId());
workbasket.setName(repModel.getName());
workbasket.setType(repModel.getType());
workbasket.setDescription(repModel.getDescription());
workbasket.setOwner(repModel.getOwner());
workbasket.setMarkedForDeletion(repModel.getMarkedForDeletion());
workbasket.setCustom1(repModel.getCustom1());
workbasket.setCustom2(repModel.getCustom2());
workbasket.setCustom3(repModel.getCustom3());
workbasket.setCustom4(repModel.getCustom4());
workbasket.setOrgLevel1(repModel.getOrgLevel1());
workbasket.setOrgLevel2(repModel.getOrgLevel2());
workbasket.setOrgLevel3(repModel.getOrgLevel3());
workbasket.setOrgLevel4(repModel.getOrgLevel4());
workbasket.setCreated(repModel.getCreated());
workbasket.setModified(repModel.getModified());
return workbasket;
}

View File

@ -3,7 +3,6 @@ package pro.taskana.workbasket.rest.assembler;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.server.RepresentationModelAssembler;
import org.springframework.lang.NonNull;
@ -37,24 +36,52 @@ public class WorkbasketRepresentationModelAssembler
@NonNull
@Override
public WorkbasketRepresentationModel toModel(@NonNull Workbasket wb) {
public WorkbasketRepresentationModel toModel(@NonNull Workbasket workbasket) {
WorkbasketRepresentationModel repModel = new WorkbasketRepresentationModel();
repModel.setWorkbasketId(workbasket.getId());
repModel.setKey(workbasket.getKey());
repModel.setName(workbasket.getName());
repModel.setDomain(workbasket.getDomain());
repModel.setType(workbasket.getType());
repModel.setDescription(workbasket.getDescription());
repModel.setOwner(workbasket.getOwner());
repModel.setMarkedForDeletion(workbasket.isMarkedForDeletion());
repModel.setCustom1(workbasket.getCustom1());
repModel.setCustom2(workbasket.getCustom2());
repModel.setCustom3(workbasket.getCustom3());
repModel.setCustom4(workbasket.getCustom4());
repModel.setOrgLevel1(workbasket.getOrgLevel1());
repModel.setOrgLevel2(workbasket.getOrgLevel2());
repModel.setOrgLevel3(workbasket.getOrgLevel3());
repModel.setOrgLevel4(workbasket.getOrgLevel4());
repModel.setCreated(workbasket.getCreated());
repModel.setModified(workbasket.getModified());
try {
WorkbasketRepresentationModel resource = new WorkbasketRepresentationModel(wb);
return addLinks(resource, wb);
return addLinks(repModel, workbasket);
} catch (Exception e) {
throw new SystemException("caught unexpected Exception.", e.getCause());
}
}
public Workbasket toEntityModel(WorkbasketRepresentationModel wbResource) {
String wbKey = wbResource.getKey();
String wbDomain = wbResource.getDomain();
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket(wbKey, wbDomain);
BeanUtils.copyProperties(wbResource, workbasket);
workbasket.setId(wbResource.getWorkbasketId());
workbasket.setModified(wbResource.getModified());
workbasket.setCreated(wbResource.getCreated());
public Workbasket toEntityModel(WorkbasketRepresentationModel repModel) {
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket(repModel.getKey(),
repModel.getDomain());
workbasket.setId(repModel.getWorkbasketId());
workbasket.setName(repModel.getName());
workbasket.setType(repModel.getType());
workbasket.setDescription(repModel.getDescription());
workbasket.setOwner(repModel.getOwner());
workbasket.setMarkedForDeletion(repModel.getMarkedForDeletion());
workbasket.setCustom1(repModel.getCustom1());
workbasket.setCustom2(repModel.getCustom2());
workbasket.setCustom3(repModel.getCustom3());
workbasket.setCustom4(repModel.getCustom4());
workbasket.setOrgLevel1(repModel.getOrgLevel1());
workbasket.setOrgLevel2(repModel.getOrgLevel2());
workbasket.setOrgLevel3(repModel.getOrgLevel3());
workbasket.setOrgLevel4(repModel.getOrgLevel4());
workbasket.setCreated(repModel.getCreated());
workbasket.setModified(repModel.getModified());
return workbasket;
}

View File

@ -5,7 +5,6 @@ import static pro.taskana.common.rest.models.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;
@ -41,15 +40,44 @@ public class WorkbasketSummaryRepresentationModelAssembler implements
@Override
public WorkbasketSummaryRepresentationModel toModel(
@NonNull WorkbasketSummary workbasketSummary) {
return new WorkbasketSummaryRepresentationModel(workbasketSummary);
WorkbasketSummaryRepresentationModel repModel = new WorkbasketSummaryRepresentationModel();
repModel.setWorkbasketId(workbasketSummary.getId());
repModel.setKey(workbasketSummary.getKey());
repModel.setName(workbasketSummary.getName());
repModel.setDomain(workbasketSummary.getDomain());
repModel.setType(workbasketSummary.getType());
repModel.setDescription(workbasketSummary.getDescription());
repModel.setOwner(workbasketSummary.getOwner());
repModel.setMarkedForDeletion(workbasketSummary.isMarkedForDeletion());
repModel.setCustom1(workbasketSummary.getCustom1());
repModel.setCustom2(workbasketSummary.getCustom2());
repModel.setCustom3(workbasketSummary.getCustom3());
repModel.setCustom4(workbasketSummary.getCustom4());
repModel.setOrgLevel1(workbasketSummary.getOrgLevel1());
repModel.setOrgLevel2(workbasketSummary.getOrgLevel2());
repModel.setOrgLevel3(workbasketSummary.getOrgLevel3());
repModel.setOrgLevel4(workbasketSummary.getOrgLevel4());
return repModel;
}
public WorkbasketSummary toEntityModel(WorkbasketSummaryRepresentationModel resource) {
public WorkbasketSummary toEntityModel(WorkbasketSummaryRepresentationModel repModel) {
WorkbasketImpl workbasket =
(WorkbasketImpl) workbasketService.newWorkbasket(resource.getKey(), resource.getDomain());
workbasket.setId(resource.getWorkbasketId());
BeanUtils.copyProperties(resource, workbasket);
return workbasket.asSummary();
(WorkbasketImpl) workbasketService.newWorkbasket(repModel.getKey(), repModel.getDomain());
workbasket.setId(repModel.getWorkbasketId());
workbasket.setName(repModel.getName());
workbasket.setType(repModel.getType());
workbasket.setDescription(repModel.getDescription());
workbasket.setOwner(repModel.getOwner());
workbasket.setMarkedForDeletion(repModel.getMarkedForDeletion());
workbasket.setCustom1(repModel.getCustom1());
workbasket.setCustom2(repModel.getCustom2());
workbasket.setCustom3(repModel.getCustom3());
workbasket.setCustom4(repModel.getCustom4());
workbasket.setOrgLevel1(repModel.getOrgLevel1());
workbasket.setOrgLevel2(repModel.getOrgLevel2());
workbasket.setOrgLevel3(repModel.getOrgLevel3());
workbasket.setOrgLevel4(repModel.getOrgLevel4());
return workbasket;
}
@PageLinks(Mapping.URL_WORKBASKET)

View File

@ -33,33 +33,6 @@ public class WorkbasketAccessItemRepresentationModel
private boolean permCustom11;
private boolean permCustom12;
public WorkbasketAccessItemRepresentationModel() {}
public WorkbasketAccessItemRepresentationModel(WorkbasketAccessItem workbasketAccessItem) {
this.accessItemId = workbasketAccessItem.getId();
this.workbasketId = workbasketAccessItem.getWorkbasketId();
this.workbasketKey = workbasketAccessItem.getWorkbasketKey();
this.accessId = workbasketAccessItem.getAccessId();
this.accessName = workbasketAccessItem.getAccessName();
this.permRead = workbasketAccessItem.isPermRead();
this.permOpen = workbasketAccessItem.isPermOpen();
this.permAppend = workbasketAccessItem.isPermAppend();
this.permTransfer = workbasketAccessItem.isPermTransfer();
this.permDistribute = workbasketAccessItem.isPermDistribute();
this.permCustom1 = workbasketAccessItem.isPermCustom1();
this.permCustom2 = workbasketAccessItem.isPermCustom2();
this.permCustom3 = workbasketAccessItem.isPermCustom3();
this.permCustom4 = workbasketAccessItem.isPermCustom4();
this.permCustom5 = workbasketAccessItem.isPermCustom5();
this.permCustom6 = workbasketAccessItem.isPermCustom6();
this.permCustom7 = workbasketAccessItem.isPermCustom7();
this.permCustom8 = workbasketAccessItem.isPermCustom8();
this.permCustom9 = workbasketAccessItem.isPermCustom9();
this.permCustom10 = workbasketAccessItem.isPermCustom10();
this.permCustom11 = workbasketAccessItem.isPermCustom11();
this.permCustom12 = workbasketAccessItem.isPermCustom12();
}
public String getAccessItemId() {
return accessItemId;
}
@ -235,20 +208,5 @@ public class WorkbasketAccessItemRepresentationModel
public void setPermCustom12(boolean permCustom12) {
this.permCustom12 = permCustom12;
}
@Override
public String toString() {
return "WorkbasketAccessItemResource ["
+ "accessItemId= "
+ this.accessItemId
+ "workbasketId= "
+ this.workbasketId
+ "workbasketKey= "
+ this.workbasketKey
+ "accessId= "
+ this.accessId
+ "accessName= "
+ this.accessName
+ "]";
}
}

View File

@ -4,7 +4,6 @@ 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. */
@ -15,20 +14,6 @@ public class WorkbasketDefinitionRepresentationModel
private List<WorkbasketAccessItemImpl> authorizations;
private WorkbasketRepresentationModelWithoutLinks workbasket;
public WorkbasketDefinitionRepresentationModel() {
// necessary for de-serializing
}
public WorkbasketDefinitionRepresentationModel(
WorkbasketRepresentationModelWithoutLinks workbasket,
Set<String> distributionTargets,
List<WorkbasketAccessItemImpl> authorizations) {
super();
this.workbasket = workbasket;
this.distributionTargets = distributionTargets;
this.authorizations = authorizations;
}
public Set<String> getDistributionTargets() {
return distributionTargets;
}
@ -52,16 +37,4 @@ public class WorkbasketDefinitionRepresentationModel
public void setWorkbasket(WorkbasketRepresentationModelWithoutLinks workbasket) {
this.workbasket = workbasket;
}
@Override
public String toString() {
return "WorkbasketDefinitionResource ["
+ "distributionTargets= "
+ LoggerUtils.setToString(this.distributionTargets)
+ "authorizations= "
+ LoggerUtils.listToString(this.authorizations)
+ "workbasket= "
+ this.workbasket
+ "]";
}
}

View File

@ -10,19 +10,9 @@ import pro.taskana.workbasket.api.models.Workbasket;
public class WorkbasketRepresentationModel
extends WorkbasketSummaryRepresentationModel {
private Instant created; // ISO-8601
private Instant modified; // ISO-8601
public WorkbasketRepresentationModel() {
}
public WorkbasketRepresentationModel(Workbasket workbasket) {
super(workbasket);
this.created = workbasket.getCreated();
this.modified = workbasket.getModified();
}
public Instant getCreated() {
return created;
}

View File

@ -4,13 +4,10 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import pro.taskana.workbasket.api.models.Workbasket;
/** EntityModel class for {@link Workbasket} but without links property. */
/**
* EntityModel class for {@link Workbasket} but without links property.
*/
@JsonIgnoreProperties(value = {"links"})
public class WorkbasketRepresentationModelWithoutLinks extends WorkbasketRepresentationModel {
WorkbasketRepresentationModelWithoutLinks() {}
public WorkbasketRepresentationModelWithoutLinks(Workbasket workbasket) {
super(workbasket);
}
}

View File

@ -28,28 +28,6 @@ public class WorkbasketSummaryRepresentationModel
protected String orgLevel4;
private boolean markedForDeletion;
public WorkbasketSummaryRepresentationModel() {
}
public WorkbasketSummaryRepresentationModel(WorkbasketSummary workbasketSummary) {
this.workbasketId = workbasketSummary.getId();
this.key = workbasketSummary.getKey();
this.name = workbasketSummary.getName();
this.domain = workbasketSummary.getDomain();
this.type = workbasketSummary.getType();
this.description = workbasketSummary.getDescription();
this.owner = workbasketSummary.getOwner();
this.markedForDeletion = workbasketSummary.isMarkedForDeletion();
this.custom1 = workbasketSummary.getCustom1();
this.custom2 = workbasketSummary.getCustom2();
this.custom3 = workbasketSummary.getCustom3();
this.custom4 = workbasketSummary.getCustom4();
this.orgLevel1 = workbasketSummary.getOrgLevel1();
this.orgLevel2 = workbasketSummary.getOrgLevel2();
this.orgLevel3 = workbasketSummary.getOrgLevel3();
this.orgLevel4 = workbasketSummary.getOrgLevel4();
}
public String getWorkbasketId() {
return workbasketId;
}
@ -178,21 +156,4 @@ public class WorkbasketSummaryRepresentationModel
this.markedForDeletion = markedForDeletion;
}
@Override
public String toString() {
return "WorkbasketSummaryResource ["
+ "workbasketId= "
+ this.workbasketId
+ "key= "
+ this.key
+ "name= "
+ this.name
+ "domain= "
+ this.domain
+ "type= "
+ this.type
+ "owner= "
+ this.owner
+ "]";
}
}

View File

@ -82,7 +82,7 @@ class ClassificationAssemblerTest {
classification.setIsValidInDomain(true);
ClassificationRepresentationModel classificationRepresentationModel =
new ClassificationRepresentationModel(classification);
classificationRepresentationModelAssembler.toModel(classification);
// when
classification =

View File

@ -38,7 +38,8 @@ class WorkbasketDefinitionControllerRestDocumentation extends BaseRestDocumentat
void exportAllWorkbasketDefinitions() throws Exception {
this.mockMvc
.perform(
RestDocumentationRequestBuilders.get(restHelper.toUrl(Mapping.URL_WORKBASKETDEFIITIONS))
RestDocumentationRequestBuilders
.get(restHelper.toUrl(Mapping.URL_WORKBASKETDEFINITIONS))
.accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
@ -63,7 +64,7 @@ class WorkbasketDefinitionControllerRestDocumentation extends BaseRestDocumentat
this.mockMvc
.perform(
multipart(restHelper.toUrl(Mapping.URL_WORKBASKETDEFIITIONS))
multipart(restHelper.toUrl(Mapping.URL_WORKBASKETDEFINITIONS))
.file("file", definitionString.getBytes(UTF_8))
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isNoContent())

View File

@ -123,9 +123,7 @@ class WorkbasketDefinitionControllerIntTest {
assertThat(pagedModel).isNotNull();
WorkbasketDefinitionRepresentationModel w = pagedModel.getContent().iterator().next();
w.setDistributionTargets(new HashSet<>());
this.expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.NO_CONTENT, w);
w.getWorkbasket().setKey("newKey");
w.getAuthorizations().forEach(authorization -> authorization.setWorkbasketKey("newKey"));
expectStatusWhenExecutingImportRequestOfWorkbaskets(HttpStatus.NO_CONTENT, w);
@ -263,11 +261,12 @@ class WorkbasketDefinitionControllerIntTest {
private ResponseEntity<TaskanaPagedModel<WorkbasketDefinitionRepresentationModel>>
executeExportRequestForDomain(String domain) {
return TEMPLATE.exchange(
restHelper.toUrl(Mapping.URL_WORKBASKETDEFIITIONS) + "?domain=" + domain,
restHelper.toUrl(Mapping.URL_WORKBASKETDEFINITIONS) + "?domain=" + domain,
HttpMethod.GET,
restHelper.defaultRequest(),
new ParameterizedTypeReference<
TaskanaPagedModel<WorkbasketDefinitionRepresentationModel>>() {});
new ParameterizedTypeReference<TaskanaPagedModel<WorkbasketDefinitionRepresentationModel>>(
) {
});
}
private void expectStatusWhenExecutingImportRequestOfWorkbaskets(
@ -293,7 +292,7 @@ class WorkbasketDefinitionControllerIntTest {
body.add("file", new FileSystemResource(tmpFile));
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers);
String serverUrl = restHelper.toUrl(Mapping.URL_WORKBASKETDEFIITIONS);
String serverUrl = restHelper.toUrl(Mapping.URL_WORKBASKETDEFINITIONS);
ResponseEntity<Void> responseImport =
TEMPLATE.postForEntity(serverUrl, requestEntity, Void.class);