issue-47 #60
@ -4,10 +4,13 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Fix deleting tasks">
|
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Fix parsing datetime">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.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/models/timemanager/taskSchedule/scheduleInfos/AdvancedScheduleFieldInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskSchedule/scheduleInfos/AdvancedScheduleFieldInfo.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskSchedule/scheduleInfos/AdvancedScheduleFieldInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskSchedule/scheduleInfos/AdvancedScheduleFieldInfo.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/core/repositories/timemanager/TaskgroupRepository.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/repositories/timemanager/TaskgroupRepository.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/main/java/core/services/TaskgroupService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/services/TaskgroupService.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/test/java/core/taskgroups/TaskgroupRepsitoryTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/core/taskgroups/TaskgroupRepsitoryTest.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/../frontend/src/app/schedules/advanced-scheduler/advanced-scheduler.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/schedules/advanced-scheduler/advanced-scheduler.component.ts" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -567,14 +570,21 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1699805283751</updated>
|
<updated>1699805283751</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="44" />
|
<task id="LOCAL-00044" summary="Fix parsing datetime">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1699806194258</created>
|
||||||
|
<option name="number" value="00044" />
|
||||||
|
<option name="presentableId" value="LOCAL-00044" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1699806194258</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="45" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
<option name="version" value="3" />
|
<option name="version" value="3" />
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value="Fix marking finished task as overdue" />
|
|
||||||
<MESSAGE value="Write simple Testcase for ci/cd" />
|
<MESSAGE value="Write simple Testcase for ci/cd" />
|
||||||
<MESSAGE value="Deactivate Overall System test (temporarly)" />
|
<MESSAGE value="Deactivate Overall System test (temporarly)" />
|
||||||
<MESSAGE value="Fix failing test case" />
|
<MESSAGE value="Fix failing test case" />
|
||||||
@ -599,7 +609,8 @@
|
|||||||
<MESSAGE value="Fix wrong date" />
|
<MESSAGE value="Fix wrong date" />
|
||||||
<MESSAGE value="Deploy on docker (not productive yet!)" />
|
<MESSAGE value="Deploy on docker (not productive yet!)" />
|
||||||
<MESSAGE value="Fix deleting tasks" />
|
<MESSAGE value="Fix deleting tasks" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Fix deleting tasks" />
|
<MESSAGE value="Fix parsing datetime" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="Fix parsing datetime" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
<breakpoint-manager>
|
||||||
|
@ -6,40 +6,39 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
|
|
||||||
public class AdvancedScheduleFieldInfo extends ScheduleFieldInfo {
|
public class AdvancedScheduleFieldInfo extends ScheduleFieldInfo {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
|
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
|
||||||
private ZonedDateTime scheduleStartTime;
|
private LocalDateTime scheduleStartTime;
|
||||||
@NotNull
|
@NotNull
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
|
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
|
||||||
private ZonedDateTime scheduleStopTime;
|
private LocalDateTime scheduleStopTime;
|
||||||
|
|
||||||
public AdvancedScheduleFieldInfo(LocalDateTime scheduleStartTime, LocalDateTime scheduleStopTime) {
|
public AdvancedScheduleFieldInfo(LocalDateTime scheduleStartTime, LocalDateTime scheduleStopTime) {
|
||||||
this.scheduleStartTime = ZonedDateTime.from(scheduleStartTime);
|
this.scheduleStartTime = scheduleStartTime;
|
||||||
this.scheduleStopTime = ZonedDateTime.from(scheduleStopTime);
|
this.scheduleStopTime = scheduleStopTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdvancedScheduleFieldInfo() {
|
public AdvancedScheduleFieldInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZonedDateTime getScheduleStartTime() {
|
public LocalDateTime getScheduleStartTime() {
|
||||||
return scheduleStartTime;
|
return scheduleStartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScheduleStartTime(ZonedDateTime scheduleStartTime) {
|
public void setScheduleStartTime(LocalDateTime scheduleStartTime) {
|
||||||
this.scheduleStartTime = scheduleStartTime;
|
this.scheduleStartTime = scheduleStartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZonedDateTime getScheduleStopTime() {
|
public LocalDateTime getScheduleStopTime() {
|
||||||
return scheduleStopTime;
|
return scheduleStopTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScheduleStopTime(ZonedDateTime scheduleStopTime) {
|
public void setScheduleStopTime(LocalDateTime scheduleStopTime) {
|
||||||
this.scheduleStopTime = scheduleStopTime;
|
this.scheduleStopTime = scheduleStopTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,6 @@ import java.util.List;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface TaskgroupRepository extends CrudRepository<Taskgroup, Long> {
|
public interface TaskgroupRepository extends CrudRepository<Taskgroup, Long> {
|
||||||
|
|
||||||
boolean existsByTaskgroupNameAndUser(String name, User user);
|
|
||||||
|
|
||||||
@Query("SELECT tg FROM Taskgroup tg WHERE tg.user.username = ?1")
|
@Query("SELECT tg FROM Taskgroup tg WHERE tg.user.username = ?1")
|
||||||
List<Taskgroup> findAllByUser(String username);
|
List<Taskgroup> findAllByUser(String username);
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public class TaskScheduleService {
|
|||||||
return new ServiceResult<>(ServiceExitCode.INVALID_PARAMETER);
|
return new ServiceResult<>(ServiceExitCode.INVALID_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
AdvancedTaskSchedule advancedTaskSchedule = new AdvancedTaskSchedule(task, scheduleFieldInfo.getScheduleStartTime().toLocalDateTime(), scheduleFieldInfo.getScheduleStopTime().toLocalDateTime());
|
AdvancedTaskSchedule advancedTaskSchedule = new AdvancedTaskSchedule(task, scheduleFieldInfo.getScheduleStartTime(), scheduleFieldInfo.getScheduleStopTime());
|
||||||
scheduleRepository.save(advancedTaskSchedule);
|
scheduleRepository.save(advancedTaskSchedule);
|
||||||
|
|
||||||
return new ServiceResult<>(advancedTaskSchedule);
|
return new ServiceResult<>(advancedTaskSchedule);
|
||||||
@ -89,8 +89,8 @@ public class TaskScheduleService {
|
|||||||
return new ServiceResult<>(ServiceExitCode.INVALID_PARAMETER);
|
return new ServiceResult<>(ServiceExitCode.INVALID_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
schedule.setScheduleStart(scheduleFieldInfo.getScheduleStartTime().toLocalDateTime());
|
schedule.setScheduleStart(scheduleFieldInfo.getScheduleStartTime());
|
||||||
schedule.setScheduleEnd(scheduleFieldInfo.getScheduleStopTime().toLocalDateTime());
|
schedule.setScheduleEnd(scheduleFieldInfo.getScheduleStopTime());
|
||||||
scheduleRepository.save(schedule);
|
scheduleRepository.save(schedule);
|
||||||
return new ServiceResult<>(schedule);
|
return new ServiceResult<>(schedule);
|
||||||
}
|
}
|
||||||
|
@ -39,32 +39,34 @@ public class TaskgroupService {
|
|||||||
throw new NoSuchElementException();
|
throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!taskgroupRepository.existsByTaskgroupNameAndUser(taskData.getName(), user.get())) {
|
Taskgroup taskgroup;
|
||||||
Taskgroup taskgroup;
|
if(taskData.getParentID() < 0) {
|
||||||
if(taskData.getParentID() < 0) {
|
if(existTaskgroupOnTaskgroupLevel(null, taskData.getName(), username)) {
|
||||||
taskgroup = new Taskgroup(taskData.getName(), user.get());
|
return new ServiceResult<>(ServiceExitCode.ENTITY_ALREADY_EXIST);
|
||||||
} else {
|
} else {
|
||||||
Optional<Taskgroup> parentTaskgroup = taskgroupRepository.findById(taskData.getParentID());
|
taskgroup = new Taskgroup(taskData.getName(), user.get());
|
||||||
if(parentTaskgroup.isEmpty()) {
|
|
||||||
return new ServiceResult<>(ServiceExitCode.MISSING_ENTITY);
|
|
||||||
} else {
|
|
||||||
taskgroup = new Taskgroup(taskData.getName(), user.get());
|
|
||||||
taskgroup.setParent(parentTaskgroup.get());
|
|
||||||
parentTaskgroup.get().getChildren().add(taskgroup);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
taskgroupRepository.save(taskgroup);
|
} else{
|
||||||
return new ServiceResult<>(taskgroup);
|
Optional<Taskgroup> parentTaskgroup = taskgroupRepository.findById(taskData.getParentID());
|
||||||
} else {
|
if(parentTaskgroup.isEmpty()) {
|
||||||
return new ServiceResult<>(ServiceExitCode.ENTITY_ALREADY_EXIST);
|
return new ServiceResult<>(ServiceExitCode.MISSING_ENTITY);
|
||||||
|
} else if(existTaskgroupOnTaskgroupLevel(parentTaskgroup.get(), taskData.getName(), username)) {
|
||||||
|
return new ServiceResult<>(ServiceExitCode.ENTITY_ALREADY_EXIST);
|
||||||
|
} else {
|
||||||
|
taskgroup = new Taskgroup(taskData.getName(), user.get());
|
||||||
|
taskgroup.setParent(parentTaskgroup.get());
|
||||||
|
parentTaskgroup.get().getChildren().add(taskgroup);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
taskgroupRepository.save(taskgroup);
|
||||||
|
return new ServiceResult<>(taskgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceExitCode editTaskgroup(Taskgroup taskgroup, TaskgroupFieldInfo taskgroupFieldInfo) {
|
public ServiceExitCode editTaskgroup(Taskgroup taskgroup, TaskgroupFieldInfo taskgroupFieldInfo) {
|
||||||
if(!taskgroup.getTaskgroupName().equals(taskgroupFieldInfo.getName())) {
|
if(!taskgroup.getTaskgroupName().equals(taskgroupFieldInfo.getName())) {
|
||||||
//Check if another taskgroup with the new name is already existent for the user of the taskgroup
|
//Check if another taskgroup with the new name is already existent for the user of the taskgroup
|
||||||
if(!taskgroupRepository.existsByTaskgroupNameAndUser(taskgroupFieldInfo.getName(), taskgroup.getUser())) {
|
if(!existTaskgroupOnTaskgroupLevel(taskgroup.getParent(), taskgroupFieldInfo.getName(), taskgroup.getUser().getUsername())) {
|
||||||
taskgroup.setTaskgroupName(taskgroupFieldInfo.getName());
|
taskgroup.setTaskgroupName(taskgroupFieldInfo.getName());
|
||||||
taskgroupRepository.save(taskgroup);
|
taskgroupRepository.save(taskgroup);
|
||||||
return ServiceExitCode.OK;
|
return ServiceExitCode.OK;
|
||||||
@ -76,6 +78,24 @@ public class TaskgroupService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean existTaskgroupOnTaskgroupLevel(Taskgroup taskgroup, String taskgroupName, String username) {
|
||||||
|
if(taskgroup == null) {
|
||||||
|
List<Taskgroup> topTaskgroups = getTopTaskgroupsByUser(username);
|
||||||
|
for(Taskgroup taskgroup1 : topTaskgroups) {
|
||||||
|
if(taskgroup1.getTaskgroupName().equals(taskgroupName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(Taskgroup sibling : taskgroup.getChildren()) {
|
||||||
|
if(sibling.getTaskgroupName().equals(taskgroupName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void deleteTaskgroup(Taskgroup taskgroup) {
|
public void deleteTaskgroup(Taskgroup taskgroup) {
|
||||||
taskgroupRepository.delete(taskgroup);
|
taskgroupRepository.delete(taskgroup);
|
||||||
}
|
}
|
||||||
|
@ -37,25 +37,6 @@ public class TaskgroupRepsitoryTest {
|
|||||||
assertEquals(8, result_user1.size());
|
assertEquals(8, result_user1.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Sql("classpath:taskgroupRepositoryTestEntries.sql")
|
|
||||||
void existsByTaskgroupNameAndUser() {
|
|
||||||
User testUser1 = testEntityManager.find(User.class, 1L);
|
|
||||||
User testUser2 = testEntityManager.find(User.class, 2L);
|
|
||||||
|
|
||||||
//Situation 1: Taskgroup exists but within another user
|
|
||||||
assertFalse(taskgroupRepository.existsByTaskgroupNameAndUser("No children", testUser2));
|
|
||||||
|
|
||||||
//Situation 2: Taskgroup exists not
|
|
||||||
assertFalse(taskgroupRepository.existsByTaskgroupNameAndUser("ada", testUser1));
|
|
||||||
|
|
||||||
//Situation 3: Taskgroup (top) exists on user
|
|
||||||
assertTrue(taskgroupRepository.existsByTaskgroupNameAndUser("No children", testUser1));
|
|
||||||
|
|
||||||
//Situation 4: Taskgroup exists on user but not on top level
|
|
||||||
assertTrue(taskgroupRepository.existsByTaskgroupNameAndUser("Taskgroup 1.1", testUser1));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Sql("classpath:taskgroupRepositoryTestEntries.sql")
|
@Sql("classpath:taskgroupRepositoryTestEntries.sql")
|
||||||
void findAllTopTaskgroupsByUser() {
|
void findAllTopTaskgroupsByUser() {
|
||||||
|
@ -132,6 +132,8 @@ export class AdvancedSchedulerComponent implements OnInit, OnChanges{
|
|||||||
|
|
||||||
schedule() {
|
schedule() {
|
||||||
if(this.scheduleInfo == undefined) {
|
if(this.scheduleInfo == undefined) {
|
||||||
|
console.log("Direct Date" + this.selectedStartTime!.toString())
|
||||||
|
console.log("Moment Format" + moment(this.selectedStartTime!).format('YYYY-MM-DDTHH:mm:ss.SSSZ'))
|
||||||
this.scheduleService.schedulesTaskIDAdvancedPut(this.task!.taskID, {
|
this.scheduleService.schedulesTaskIDAdvancedPut(this.task!.taskID, {
|
||||||
scheduleStartTime: moment(this.selectedStartTime!).format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
|
scheduleStartTime: moment(this.selectedStartTime!).format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
|
||||||
scheduleStopTime: moment(this.selectedStopTime!).format('YYYY-MM-DDTHH:mm:ss.SSSZ')
|
scheduleStopTime: moment(this.selectedStopTime!).format('YYYY-MM-DDTHH:mm:ss.SSSZ')
|
||||||
@ -141,6 +143,8 @@ export class AdvancedSchedulerComponent implements OnInit, OnChanges{
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
console.log("Direct Date" + this.selectedStartTime!.toString())
|
||||||
|
console.log("Moment Format" + moment(this.selectedStartTime!).format('YYYY-MM-DDTHH:mm:ss.SSSZ'))
|
||||||
this.scheduleService.schedulesScheduleIDAdvancedPost(this.scheduleInfo.scheduleID!, {
|
this.scheduleService.schedulesScheduleIDAdvancedPost(this.scheduleInfo.scheduleID!, {
|
||||||
scheduleStartTime: moment(this.selectedStartTime!).format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
|
scheduleStartTime: moment(this.selectedStartTime!).format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
|
||||||
scheduleStopTime: moment(this.selectedStopTime!).format('YYYY-MM-DDTHH:mm:ss.SSSZ')
|
scheduleStopTime: moment(this.selectedStopTime!).format('YYYY-MM-DDTHH:mm:ss.SSSZ')
|
||||||
|
Loading…
Reference in New Issue
Block a user