issue-18 #28
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user