Commit a0d2f14c authored by Roberto Loayza's avatar Roberto Loayza

SchedulerTaskService actualización

parent e7e53f02
...@@ -6,6 +6,7 @@ import com.bytesw.bytebot.model.Calendar; ...@@ -6,6 +6,7 @@ import com.bytesw.bytebot.model.Calendar;
import com.bytesw.bytebot.model.SchedulerTask; import com.bytesw.bytebot.model.SchedulerTask;
import com.bytesw.bytebot.repository.CalendarRepository; import com.bytesw.bytebot.repository.CalendarRepository;
import com.bytesw.bytebot.repository.SchedulerTaskRepository; import com.bytesw.bytebot.repository.SchedulerTaskRepository;
import com.bytesw.xdf.exception.AlreadyExistsException;
import com.bytesw.xdf.exception.NotFoundException; import com.bytesw.xdf.exception.NotFoundException;
import com.bytesw.xdf.service.XDFService; import com.bytesw.xdf.service.XDFService;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -26,6 +27,9 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas ...@@ -26,6 +27,9 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas
@Autowired @Autowired
private CalendarRepository calendarRepository; private CalendarRepository calendarRepository;
@Autowired
private SchedulerTaskRepository schedulerTaskRepository;
protected SchedulerTaskService(SchedulerTaskRepository repository) { protected SchedulerTaskService(SchedulerTaskRepository repository) {
super(repository); super(repository);
} }
...@@ -73,4 +77,35 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas ...@@ -73,4 +77,35 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas
initialData.put("calendarList", calendarBeanList); initialData.put("calendarList", calendarBeanList);
return initialData; return initialData;
} }
@Override
public SchedulerTaskBean create(SchedulerTaskBean schedulerTaskBean) {
SchedulerTask schedulerTask = new SchedulerTask();
schedulerTask = toModel(schedulerTask, schedulerTaskBean);
schedulerTask = schedulerTaskRepository.save(schedulerTask);
System.out.println(schedulerTask);
return toBean(schedulerTask);
}
@Override
public SchedulerTaskBean update(SchedulerTaskBean bean, BigInteger id) {
Optional<SchedulerTask> model = schedulerTaskRepository.findById(id);
if (!model.isPresent()) {
throw new NotFoundException();
}
SchedulerTask schedulerTask = new SchedulerTask();
schedulerTask = toModel(schedulerTask, bean);
schedulerTask = schedulerTaskRepository.save(schedulerTask);
return toBean(schedulerTask);
}
@Override
public void delete (BigInteger id) {
Optional<SchedulerTask> model = schedulerTaskRepository.findById(id);
if (!model.isPresent()) {
throw new NotFoundException();
}
schedulerTaskRepository.deleteById(id);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment