issue-25 #27

Merged
sebastian merged 32 commits from issue-25 into issue-18 2023-10-28 19:33:06 +02:00
2 changed files with 20 additions and 4 deletions
Showing only changes of commit 1dd01d0249 - Show all commits

View File

@ -3,6 +3,7 @@ package core.entities.timemanager;
import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Objects;
@Entity
@Table(name = "basic_schedules")
@ -79,4 +80,17 @@ public class BasicTaskSchedule {
public boolean isActivateAble() {
return startTime == null;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BasicTaskSchedule that = (BasicTaskSchedule) o;
return scheduleID == that.scheduleID;
}
@Override
public int hashCode() {
return Objects.hash(scheduleID);
}
}

View File

@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
@ -61,14 +62,15 @@ public class TaskScheduleService {
}
List<BasicTaskSchedule> basicTaskSchedules = basicTaskScheduleRepository.findAllByUserAndDate(user.get(), LocalDate.now());
List<BasicTaskSchedule> activatableSchedules = new LinkedList<>();
if(onlyActivateable) {
for(int i=0; i<basicTaskSchedules.size(); i++) {
if(!basicTaskSchedules.get(i).isActivateAble()) {
basicTaskSchedules.remove(i);
for (BasicTaskSchedule basicTaskSchedule : basicTaskSchedules) {
if (basicTaskSchedule.isActivateAble()) {
activatableSchedules.add(basicTaskSchedule);
}
}
}
return new ServiceResult<>(basicTaskSchedules);
return new ServiceResult<>(activatableSchedules);
}
public ServiceResult<List<BasicTaskSchedule>> loadSchedules(String username) {