From b1784ee0f7673691473779b15bbcd335396579e1 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 2 Oct 2023 09:56:44 +0200 Subject: [PATCH 01/26] Datastructure for Tasks --- .../timemanager/tasks/TaskEntityInfo.java | 66 ++++++++++++++++ .../timemanager/tasks/TaskFieldInfo.java | 48 ++++++++++++ .../java/core/entities/timemanager/Task.java | 76 +++++++++++++++++++ .../core/entities/timemanager/Taskgroup.java | 3 + .../timemanager/TaskRepository.java | 9 +++ .../main/java/core/services/TaskService.java | 15 ++++ 6 files changed, 217 insertions(+) create mode 100644 backend/src/main/java/core/api/models/timemanager/tasks/TaskEntityInfo.java create mode 100644 backend/src/main/java/core/api/models/timemanager/tasks/TaskFieldInfo.java create mode 100644 backend/src/main/java/core/entities/timemanager/Task.java create mode 100644 backend/src/main/java/core/repositories/timemanager/TaskRepository.java create mode 100644 backend/src/main/java/core/services/TaskService.java diff --git a/backend/src/main/java/core/api/models/timemanager/tasks/TaskEntityInfo.java b/backend/src/main/java/core/api/models/timemanager/tasks/TaskEntityInfo.java new file mode 100644 index 0000000..f052ba1 --- /dev/null +++ b/backend/src/main/java/core/api/models/timemanager/tasks/TaskEntityInfo.java @@ -0,0 +1,66 @@ +package core.api.models.timemanager.tasks; + +import core.api.models.timemanager.taskgroup.TaskgroupEntityInfo; +import core.entities.timemanager.Task; + +import java.time.LocalDate; + +public class TaskEntityInfo { + + private long taskID; + private String taskName; + + private int eta; + + private LocalDate startDate; + + private LocalDate deadline; + + public TaskEntityInfo(Task task) { + this.taskID = task.getTaskID(); + this.taskName = task.getTaskName(); + this.eta = task.getEta(); + this.startDate = task.getStartDate(); + this.deadline = task.getDeadline(); + } + + public long getTaskID() { + return taskID; + } + + public void setTaskID(long taskID) { + this.taskID = taskID; + } + + public String getTaskName() { + return taskName; + } + + public void setTaskName(String taskName) { + this.taskName = taskName; + } + + public int getEta() { + return eta; + } + + public void setEta(int eta) { + this.eta = eta; + } + + public LocalDate getStartDate() { + return startDate; + } + + public void setStartDate(LocalDate startDate) { + this.startDate = startDate; + } + + public LocalDate getDeadline() { + return deadline; + } + + public void setDeadline(LocalDate deadline) { + this.deadline = deadline; + } +} diff --git a/backend/src/main/java/core/api/models/timemanager/tasks/TaskFieldInfo.java b/backend/src/main/java/core/api/models/timemanager/tasks/TaskFieldInfo.java new file mode 100644 index 0000000..9d2eb31 --- /dev/null +++ b/backend/src/main/java/core/api/models/timemanager/tasks/TaskFieldInfo.java @@ -0,0 +1,48 @@ +package core.api.models.timemanager.tasks; + +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.time.LocalDate; + +public class TaskFieldInfo { + + @NotBlank + @Length(max = 255) + private String taskName; + private int eta; + private LocalDate startDate; + private LocalDate deadline; + + public String getTaskName() { + return taskName; + } + + public void setTaskName(String taskName) { + this.taskName = taskName; + } + + public int getEta() { + return eta; + } + + public void setEta(int eta) { + this.eta = eta; + } + + public LocalDate getStartDate() { + return startDate; + } + + public void setStartDate(LocalDate startDate) { + this.startDate = startDate; + } + + public LocalDate getDeadline() { + return deadline; + } + + public void setDeadline(LocalDate deadline) { + this.deadline = deadline; + } +} diff --git a/backend/src/main/java/core/entities/timemanager/Task.java b/backend/src/main/java/core/entities/timemanager/Task.java new file mode 100644 index 0000000..2621424 --- /dev/null +++ b/backend/src/main/java/core/entities/timemanager/Task.java @@ -0,0 +1,76 @@ +package core.entities.timemanager; + +import javax.persistence.*; +import java.time.LocalDate; + +@Entity +@Table(name = "tasks") +public class Task { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long taskID; + + @ManyToOne + @JoinColumn(name = "taskgroup_id") + private Taskgroup taskgroup; + private String taskName; + + private LocalDate startDate; + + private LocalDate deadline; + + private int eta; + + public Task(Taskgroup taskgroup, String taskName) { + this.taskgroup = taskgroup; + this.taskName = taskName; + } + + public Task() { + } + + public long getTaskID() { + return taskID; + } + + public Taskgroup getTaskgroup() { + return taskgroup; + } + + public void setTaskgroup(Taskgroup taskgroup) { + this.taskgroup = taskgroup; + } + + public String getTaskName() { + return taskName; + } + + public void setTaskName(String taskName) { + this.taskName = taskName; + } + + public LocalDate getStartDate() { + return startDate; + } + + public void setStartDate(LocalDate startDate) { + this.startDate = startDate; + } + + public LocalDate getDeadline() { + return deadline; + } + + public void setDeadline(LocalDate deadline) { + this.deadline = deadline; + } + + public int getEta() { + return eta; + } + + public void setEta(int eta) { + this.eta = eta; + } +} diff --git a/backend/src/main/java/core/entities/timemanager/Taskgroup.java b/backend/src/main/java/core/entities/timemanager/Taskgroup.java index aca1666..7278502 100644 --- a/backend/src/main/java/core/entities/timemanager/Taskgroup.java +++ b/backend/src/main/java/core/entities/timemanager/Taskgroup.java @@ -29,6 +29,9 @@ public class Taskgroup { @JoinColumn(name = "parent_id") private Taskgroup parent; + @OneToMany(mappedBy = "taskgroup", cascade = CascadeType.ALL, fetch = FetchType.EAGER) + private Set tasks; + public Taskgroup(String taskgroupName, User user) { this.taskgroupName = taskgroupName; this.user = user; diff --git a/backend/src/main/java/core/repositories/timemanager/TaskRepository.java b/backend/src/main/java/core/repositories/timemanager/TaskRepository.java new file mode 100644 index 0000000..8feb765 --- /dev/null +++ b/backend/src/main/java/core/repositories/timemanager/TaskRepository.java @@ -0,0 +1,9 @@ +package core.repositories.timemanager; + +import core.entities.timemanager.Task; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface TaskRepository extends CrudRepository { +} diff --git a/backend/src/main/java/core/services/TaskService.java b/backend/src/main/java/core/services/TaskService.java new file mode 100644 index 0000000..eff16dc --- /dev/null +++ b/backend/src/main/java/core/services/TaskService.java @@ -0,0 +1,15 @@ +package core.services; + +import core.repositories.timemanager.TaskRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class TaskService { + + private final TaskRepository taskRepository; + + public TaskService(@Autowired TaskRepository taskRepository) { + this.taskRepository = taskRepository; + } +} From 5082fbcb499b06abcbfe61364767504033f14d40 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 2 Oct 2023 10:34:13 +0200 Subject: [PATCH 02/26] Fix Import --- .../taskgroup-creation/taskgroup-creation.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/app/taskgroups/taskgroup-creation/taskgroup-creation.component.ts b/frontend/src/app/taskgroups/taskgroup-creation/taskgroup-creation.component.ts index 595f7a6..e14946e 100644 --- a/frontend/src/app/taskgroups/taskgroup-creation/taskgroup-creation.component.ts +++ b/frontend/src/app/taskgroups/taskgroup-creation/taskgroup-creation.component.ts @@ -7,6 +7,7 @@ import {MatSnackBar} from "@angular/material/snack-bar"; import {ActivatedRoute} from "@angular/router"; import {TaskgroupCreationData} from "./TaskgroupCreationData"; + @Component({ selector: 'app-taskgroup-creation', templateUrl: './taskgroup-creation.component.html', From a7229d1d9d4bfcfb6d14ddad81885122ed57cbad Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 2 Oct 2023 10:35:02 +0200 Subject: [PATCH 03/26] Create and simple listing of all tasks --- backend/.idea/workspace.xml | 76 ++++--- .../core/api/controller/TaskController.java | 72 +++++++ .../timemanager/tasks/TaskEntityInfo.java | 11 + .../java/core/entities/timemanager/Task.java | 5 +- .../core/entities/timemanager/Taskgroup.java | 8 + .../main/java/core/services/TaskService.java | 28 +++ openapi.yaml | 202 +++++++++++++++++- 7 files changed, 376 insertions(+), 26 deletions(-) create mode 100644 backend/src/main/java/core/api/controller/TaskController.java diff --git a/backend/.idea/workspace.xml b/backend/.idea/workspace.xml index fe49c14..76f6eff 100644 --- a/backend/.idea/workspace.xml +++ b/backend/.idea/workspace.xml @@ -4,17 +4,34 @@ -