Define Entity BasicTaskSchedule and Taskcontroller

This commit is contained in:
Sebastian 2023-10-22 14:05:12 +02:00
parent 4cab32fae3
commit 3fbafa0784
6 changed files with 126 additions and 14 deletions

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">

View File

@ -5,20 +5,11 @@
</component>
<component name="ChangeListManager">
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Delete and clear Tasks (Frontend)">
<change afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskgroup/TaskgroupDetailInfo.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskgroup/TaskgroupShortInfo.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/core/api/controller/ScheduleController.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/BasicTaskSchedule.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/api/controller/TaskgroupController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/controller/TaskgroupController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskgroup/TaskgroupEntityInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskgroup/TaskgroupEntityInfo.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/Taskgroup.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/Taskgroup.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/api/.openapi-generator/FILES" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/api/.openapi-generator/FILES" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/api/api/taskgroup.service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/api/api/taskgroup.service.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/api/model/models.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/api/model/models.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/app/app.module.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/app.module.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-dashboard/taskgroup-dashboard.component.css" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-dashboard/taskgroup-dashboard.component.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-dashboard/taskgroup-dashboard.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-dashboard/taskgroup-dashboard.component.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-dashboard/taskgroup-dashboard.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/taskgroups/taskgroup-dashboard/taskgroup-dashboard.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../openapi.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../openapi.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/Task.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/Task.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -103,6 +94,7 @@
<workItem from="1697923629354" duration="3164000" />
<workItem from="1697958018921" duration="91000" />
<workItem from="1697958118995" duration="5749000" />
<workItem from="1697969480767" duration="6039000" />
</task>
<task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies">
<option name="closed" value="true" />

View File

@ -0,0 +1,31 @@
package core.api.controller;
import core.entities.timemanager.ScheduleType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/api")
public class ScheduleController {
@GetMapping("/schedules/{taskID}/{scheduleType}")
public ResponseEntity<?> loadSchedulesOfTask(@PathVariable long taskID, @PathVariable ScheduleType scheduleType) {
return null;
}
@PutMapping("/schedules/{taskID}")
public ResponseEntity<?> scheduleTask(@PathVariable long taskID) {
return null;
}
@PostMapping("/schedules/{scheduleID}/{scheduleType}")
public ResponseEntity<?> editScheduledTask(@PathVariable long scheduleID, @PathVariable ScheduleType scheduleType) {
return null;
}
@PostMapping("/schedules/{scheduleID}/{scheduleType}")
public ResponseEntity<?> deleteScheduledTask(@PathVariable long scheduleID, @PathVariable ScheduleType scheduleType) {
return null;
}
}

View File

@ -0,0 +1,78 @@
package core.entities.timemanager;
import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Entity
@Table(name = "basic_schedules")
public class BasicTaskSchedule {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long scheduleID;
@ManyToOne
@JoinColumn(referencedColumnName = "taskID", name = "task")
private Task task;
private LocalDate scheduleDate;
private LocalDateTime startTime;
private LocalDateTime finishedTime;
public BasicTaskSchedule(Task task, LocalDate scheduleDate) {
this.task = task;
this.scheduleDate = scheduleDate;
}
public BasicTaskSchedule() {
}
public void start() {
this.startTime = LocalDateTime.now();
}
public void end() {
this.finishedTime = LocalDateTime.now();
}
public long getScheduleID() {
return scheduleID;
}
public void setScheduleID(long scheduleID) {
this.scheduleID = scheduleID;
}
public Task getTask() {
return task;
}
public void setTask(Task task) {
this.task = task;
}
public LocalDate getScheduleDate() {
return scheduleDate;
}
public void setScheduleDate(LocalDate scheduleDate) {
this.scheduleDate = scheduleDate;
}
public LocalDateTime getStartTime() {
return startTime;
}
public void setStartTime(LocalDateTime startTime) {
this.startTime = startTime;
}
public LocalDateTime getFinishedTime() {
return finishedTime;
}
public void setFinishedTime(LocalDateTime finishedTime) {
this.finishedTime = finishedTime;
}
}

View File

@ -0,0 +1,8 @@
package core.entities.timemanager;
public enum ScheduleType {
BASIC,
MODERATE,
ADVANCED;
}

View File

@ -3,6 +3,7 @@ package core.entities.timemanager;
import javax.persistence.*;
import java.time.LocalDate;
import java.util.Objects;
import java.util.Set;
@Entity
@Table(name = "tasks")
@ -25,6 +26,9 @@ public class Task {
private boolean finished;
@OneToMany(mappedBy = "task", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private Set<BasicTaskSchedule> basicTaskSchedules;
public Task(Taskgroup taskgroup, String taskName, LocalDate startDate, LocalDate deadline, int eta) {
this.taskgroup = taskgroup;
this.taskName = taskName;