Check if there is another active schedule when starting task now

This commit is contained in:
Sebastian 2023-10-29 07:13:08 +01:00
parent 5ed66b911b
commit 99880522df
2 changed files with 14 additions and 3 deletions

View File

@ -6,7 +6,7 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Load worked minutes when reloading dashboard"> <list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Load worked minutes when reloading dashboard">
<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/tasks/TaskEntityInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/tasks/TaskEntityInfo.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" />
</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" />
@ -105,7 +105,7 @@
<workItem from="1698474363766" duration="3686000" /> <workItem from="1698474363766" duration="3686000" />
<workItem from="1698499063683" duration="8312000" /> <workItem from="1698499063683" duration="8312000" />
<workItem from="1698557538577" duration="18000" /> <workItem from="1698557538577" duration="18000" />
<workItem from="1698557567325" duration="862000" /> <workItem from="1698557567325" duration="1724000" />
</task> </task>
<task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies"> <task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies">
<option name="closed" value="true" /> <option name="closed" value="true" />
@ -269,6 +269,16 @@
<line>52</line> <line>52</line>
<option name="timeStamp" value="1" /> <option name="timeStamp" value="1" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java</url>
<line>86</line>
<option name="timeStamp" value="5" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java</url>
<line>93</line>
<option name="timeStamp" value="6" />
</line-breakpoint>
</breakpoints> </breakpoints>
</breakpoint-manager> </breakpoint-manager>
</component> </component>

View File

@ -82,7 +82,8 @@ public class TaskScheduleService {
public ServiceResult<BasicTaskSchedule> scheduleTaskNow(Task task) { public ServiceResult<BasicTaskSchedule> scheduleTaskNow(Task task) {
//Check if task has already an active schedule //Check if task has already an active schedule
if(task.hasActiveSchedule()) { ServiceResult<BasicTaskSchedule> activeSchedule = getActiveSchedule(task.getTaskgroup().getUser().getUsername());
if(task.hasActiveSchedule() || activeSchedule.getExitCode() != ServiceExitCode.MISSING_ENTITY) {
return new ServiceResult<>(ServiceExitCode.ENTITY_ALREADY_EXIST); return new ServiceResult<>(ServiceExitCode.ENTITY_ALREADY_EXIST);
} else { } else {
BasicTaskSchedule basicTaskSchedule = new BasicTaskSchedule(task, LocalDate.now()); BasicTaskSchedule basicTaskSchedule = new BasicTaskSchedule(task, LocalDate.now());