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; + } +}