Skip to content

Commit

Permalink
Closes Taskana#2542 - Fix code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
MM1277 committed Apr 4, 2024
1 parent d5a6c6d commit 33fb554
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2255,10 +2255,6 @@ private boolean checkEditTasksPerm(TaskSummary task) {
String workbasketId = task.getWorkbasketSummary().getId();
WorkbasketSummary workbasket =
query.idIn(workbasketId).callerHasPermissions(WorkbasketPermission.EDITTASKS).single();
if (workbasket == null) {
return false;
} else {
return true;
}
return workbasket != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,7 @@ private String[] addNullToOwnerIn() {
if (this.ownerIn == null) {
return new String[]{null};
}
List<String> ownerInAsList = new ArrayList(Arrays.asList(this.ownerIn));
List<String> ownerInAsList = new ArrayList<>(Arrays.asList(this.ownerIn));
ownerInAsList.add(null);
return ownerInAsList.toArray(new String[ownerInAsList.size()]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,22 @@ public TaskRepresentationModel toModel(Task task) {
repModel.setSecondaryObjectReferences(
task.getSecondaryObjectReferences().stream()
.map(objectReferenceAssembler::toModel)
.collect(Collectors.toList()));
.toList());
repModel.setRead(task.isRead());
repModel.setTransferred(task.isTransferred());
repModel.setGroupByCount(task.getGroupByCount());
repModel.setAttachments(
task.getAttachments().stream()
.map(attachmentAssembler::toModel)
.collect(Collectors.toList()));
.toList());
repModel.setCustomAttributes(
task.getCustomAttributeMap().entrySet().stream()
.map(CustomAttribute::of)
.collect(Collectors.toList()));
.toList());
repModel.setCallbackInfo(
task.getCallbackInfo().entrySet().stream()
.map(CustomAttribute::of)
.collect(Collectors.toList()));
.toList());
repModel.setCustom1(task.getCustomField(TaskCustomField.CUSTOM_1));
repModel.setCustom2(task.getCustomField(TaskCustomField.CUSTOM_2));
repModel.setCustom3(task.getCustomField(TaskCustomField.CUSTOM_3));
Expand Down Expand Up @@ -190,11 +190,11 @@ public Task toEntityModel(TaskRepresentationModel repModel) throws InvalidArgume
task.setAttachments(
repModel.getAttachments().stream()
.map(attachmentAssembler::toEntityModel)
.collect(Collectors.toList()));
.toList());
task.setSecondaryObjectReferences(
repModel.getSecondaryObjectReferences().stream()
.map(objectReferenceAssembler::toEntity)
.collect(Collectors.toList()));
.toList());
task.setCustomAttributeMap(
repModel.getCustomAttributes().stream()
.collect(Collectors.toMap(CustomAttribute::getKey, CustomAttribute::getValue)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -80,14 +79,14 @@ public TaskSummaryRepresentationModel toModel(@NonNull TaskSummary taskSummary)
repModel.setSecondaryObjectReferences(
taskSummary.getSecondaryObjectReferences().stream()
.map(objectReferenceAssembler::toModel)
.collect(Collectors.toList()));
.toList());
repModel.setRead(taskSummary.isRead());
repModel.setTransferred(taskSummary.isTransferred());
repModel.setGroupByCount(taskSummary.getGroupByCount());
repModel.setAttachmentSummaries(
taskSummary.getAttachmentSummaries().stream()
.map(attachmentAssembler::toModel)
.collect(Collectors.toList()));
.toList());
repModel.setCustom1(taskSummary.getCustomField(TaskCustomField.CUSTOM_1));
repModel.setCustom2(taskSummary.getCustomField(TaskCustomField.CUSTOM_2));
repModel.setCustom3(taskSummary.getCustomField(TaskCustomField.CUSTOM_3));
Expand Down Expand Up @@ -148,14 +147,14 @@ public TaskSummary toEntityModel(TaskSummaryRepresentationModel repModel) {
taskSummary.setSecondaryObjectReferences(
repModel.getSecondaryObjectReferences().stream()
.map(objectReferenceAssembler::toEntity)
.collect(Collectors.toList()));
.toList());
taskSummary.setRead(repModel.isRead());
taskSummary.setTransferred(repModel.isTransferred());
taskSummary.setGroupByCount(repModel.getGroupByCount());
taskSummary.setAttachmentSummaries(
repModel.getAttachmentSummaries().stream()
.map(attachmentAssembler::toEntityModel)
.collect(Collectors.toList()));
.toList());
taskSummary.setCustom1(repModel.getCustom1());
taskSummary.setCustom2(repModel.getCustom2());
taskSummary.setCustom3(repModel.getCustom3());
Expand Down

0 comments on commit 33fb554

Please sign in to comment.