Datastructure for Tasks

This commit is contained in:
Sebastian 2023-10-02 09:56:44 +02:00
parent 6d56b323da
commit b1784ee0f7
6 changed files with 217 additions and 0 deletions

View File

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

View File

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

View File

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

View File

@ -29,6 +29,9 @@ public class Taskgroup {
@JoinColumn(name = "parent_id") @JoinColumn(name = "parent_id")
private Taskgroup parent; private Taskgroup parent;
@OneToMany(mappedBy = "taskgroup", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private Set<Task> tasks;
public Taskgroup(String taskgroupName, User user) { public Taskgroup(String taskgroupName, User user) {
this.taskgroupName = taskgroupName; this.taskgroupName = taskgroupName;
this.user = user; this.user = user;

View File

@ -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<Task, Long> {
}

View File

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