issue-57 #71
@ -208,4 +208,8 @@ public class TaskScheduleService {
|
||||
}
|
||||
return activatedSchedules;
|
||||
}
|
||||
|
||||
public void deleteSchedules(List<AbstractSchedule> taskSchedules) {
|
||||
scheduleRepository.deleteAll(taskSchedules);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package core.services;
|
||||
|
||||
import core.api.models.timemanager.tasks.TaskFieldInfo;
|
||||
import core.api.models.timemanager.tasks.TaskScope;
|
||||
import core.entities.timemanager.AbstractSchedule;
|
||||
import core.entities.timemanager.Task;
|
||||
import core.entities.timemanager.Taskgroup;
|
||||
import core.repositories.timemanager.TaskRepository;
|
||||
@ -103,21 +104,20 @@ public class TaskService {
|
||||
task.finish();
|
||||
taskRepository.save(task);
|
||||
|
||||
/*List<BasicTaskSchedule> removedBasicTaskSchedules = new LinkedList<>();
|
||||
for(BasicTaskSchedule basicTaskSchedule : task.getBasicTaskSchedules()) {
|
||||
|
||||
List<AbstractSchedule> removedBasicTaskSchedules = new LinkedList<>();
|
||||
for(AbstractSchedule basicTaskSchedule : task.getBasicTaskSchedules()) {
|
||||
if(basicTaskSchedule.getStartTime() == null) {
|
||||
removedBasicTaskSchedules.add(basicTaskSchedule);
|
||||
} else if(basicTaskSchedule.getFinishedTime() == null) {
|
||||
} else if(basicTaskSchedule.getStopTime() == null) {
|
||||
ServiceResult<?> result = taskScheduleService.stopSchedule(basicTaskSchedule, true);
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
|
||||
for(BasicTaskSchedule deletedTaskSchedule: removedBasicTaskSchedules) {
|
||||
task.getBasicTaskSchedules().remove(deletedTaskSchedule);
|
||||
taskRepository.save(task);
|
||||
taskScheduleService.deleteBasicSchedule(deletedTaskSchedule);
|
||||
}*/
|
||||
task.getBasicTaskSchedules().removeAll(removedBasicTaskSchedules);
|
||||
taskRepository.save(task);
|
||||
taskScheduleService.deleteSchedules(removedBasicTaskSchedules);
|
||||
}
|
||||
|
||||
public List<Task> loadAllTasks(String username, TaskScope scope) {
|
||||
|
@ -2,6 +2,7 @@ package core.tasks;
|
||||
|
||||
import core.api.models.timemanager.tasks.TaskFieldInfo;
|
||||
import core.api.models.timemanager.tasks.TaskScope;
|
||||
import core.entities.timemanager.BasicTaskSchedule;
|
||||
import core.entities.timemanager.Task;
|
||||
import core.entities.timemanager.Taskgroup;
|
||||
import core.repositories.timemanager.TaskRepository;
|
||||
@ -43,7 +44,8 @@ public class TaskServiceTest {
|
||||
@Test
|
||||
@SqlGroup({
|
||||
@Sql("classpath:taskgroupRepositoryTestEntries.sql"),
|
||||
@Sql("classpath:taskRepositoryEntries.sql")
|
||||
@Sql("classpath:taskRepositoryEntries.sql"),
|
||||
@Sql("classpath:basicScheduleEntries.sql")
|
||||
})
|
||||
void createTask() {
|
||||
//Situation 1: Task with that name already exists in a taskgroup
|
||||
@ -85,7 +87,8 @@ public class TaskServiceTest {
|
||||
@Test
|
||||
@SqlGroup({
|
||||
@Sql("classpath:taskgroupRepositoryTestEntries.sql"),
|
||||
@Sql("classpath:taskRepositoryEntries.sql")
|
||||
@Sql("classpath:taskRepositoryEntries.sql"),
|
||||
@Sql("classpath:basicScheduleEntries.sql")
|
||||
})
|
||||
void getTaskPermissions() {
|
||||
//Situation 1: correct task and username
|
||||
@ -110,7 +113,8 @@ public class TaskServiceTest {
|
||||
@Test
|
||||
@SqlGroup({
|
||||
@Sql("classpath:taskgroupRepositoryTestEntries.sql"),
|
||||
@Sql("classpath:taskRepositoryEntries.sql")
|
||||
@Sql("classpath:taskRepositoryEntries.sql"),
|
||||
@Sql("classpath:basicScheduleEntries.sql")
|
||||
})
|
||||
void editTask() {
|
||||
//Situation 1: Nothing is updated
|
||||
@ -182,7 +186,8 @@ public class TaskServiceTest {
|
||||
@Test
|
||||
@SqlGroup({
|
||||
@Sql("classpath:taskgroupRepositoryTestEntries.sql"),
|
||||
@Sql("classpath:taskRepositoryEntries.sql")
|
||||
@Sql("classpath:taskRepositoryEntries.sql"),
|
||||
@Sql("classpath:basicScheduleEntries.sql")
|
||||
})
|
||||
void deleteTask() {
|
||||
for(long i=1; i<=15; i++) {
|
||||
@ -194,7 +199,8 @@ public class TaskServiceTest {
|
||||
@Test
|
||||
@SqlGroup({
|
||||
@Sql("classpath:taskgroupRepositoryTestEntries.sql"),
|
||||
@Sql("classpath:taskRepositoryEntries.sql")
|
||||
@Sql("classpath:taskRepositoryEntries.sql"),
|
||||
@Sql("classpath:basicScheduleEntries.sql")
|
||||
})
|
||||
void clearTasks() {
|
||||
//Situation 1: Delete from taskgroup with no tasks
|
||||
@ -212,7 +218,8 @@ public class TaskServiceTest {
|
||||
@Test
|
||||
@SqlGroup({
|
||||
@Sql("classpath:taskgroupRepositoryTestEntries.sql"),
|
||||
@Sql("classpath:taskRepositoryEntries.sql")
|
||||
@Sql("classpath:taskRepositoryEntries.sql"),
|
||||
@Sql("classpath:basicScheduleEntries.sql")
|
||||
})
|
||||
void finishTask() {
|
||||
taskService.finishTask(entityManager.find(Task.class, 1L));
|
||||
@ -220,12 +227,14 @@ public class TaskServiceTest {
|
||||
|
||||
taskService.finishTask(entityManager.find(Task.class, 2L));
|
||||
assertTrue(entityManager.find(Task.class, 1L).isFinished());
|
||||
assertThat(entityManager.find(BasicTaskSchedule.class, 2L)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SqlGroup({
|
||||
@Sql("classpath:taskgroupRepositoryTestEntries.sql"),
|
||||
@Sql("classpath:taskRepositoryEntries.sql")
|
||||
@Sql("classpath:taskRepositoryEntries.sql"),
|
||||
@Sql("classpath:basicScheduleEntries.sql")
|
||||
})
|
||||
void loadAllTasks() {
|
||||
//Situation 1: No tasks existing
|
||||
|
Loading…
Reference in New Issue
Block a user