Commit 5085570f authored by jgomez's avatar jgomez

SchedulerTask

Cambios en Service
parent 89a0552e
......@@ -23,7 +23,7 @@ public class SchedulerTaskBean implements Serializable {
@Expose
String stringParameters;
@Expose
String calendar;
String calendarID;
@Expose
String calendarName;
}
......@@ -17,7 +17,7 @@ import java.math.BigInteger;
@Inheritance(
strategy = InheritanceType.SINGLE_TABLE
)
@DiscriminatorColumn(name="CAEX_FRECU", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorColumn(name="CALE_EXC_FRECU", discriminatorType = DiscriminatorType.STRING)
@Table(name = "AVB_CALENDAR_EXCEPTION")
@Getter
@Setter
......
......@@ -5,6 +5,8 @@ import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.envers.Audited;
import javax.persistence.*;
......@@ -14,7 +16,7 @@ import java.math.BigInteger;
@Audited
@Entity
@Table(name = "AVB_SCHEDULER_TASK")
@NamedQuery(name = "SchedulerTasks.findByPK", query = "Select u from SchedulerTask u where u.id = ?1")
@NamedQuery(name = "SchedulerTask.findByPK", query = "Select u from SchedulerTask u where u.id = ?1")
@Getter
@Setter
@EqualsAndHashCode
......@@ -45,8 +47,12 @@ public class SchedulerTask implements Serializable {
@Column(name = "SHTA_PARAM")
private String stringParameters;
@Column(name = "CALE_ID")
private String calendarID;
@ManyToOne(optional = false)
@JoinColumn(name = "CALE_ID", referencedColumnName = "CALE_ID", nullable = false)
@NotFound(action = NotFoundAction.IGNORE)
@JoinColumn(name = "cale_id", referencedColumnName = "cale_id", nullable = false)
private Calendar calendar;
}
......@@ -62,7 +62,7 @@ public class CalendarService extends XDFService<Calendar, CalendarBean, String>
protected CalendarBean toBean(Calendar model) {
CalendarBean bean = new CalendarBean();
BeanUtils.copyProperties(model, bean);
bean.setWeekSchedulerBeanList(this.weekSchedulerService.getWeekSchedulerByCalId(model.getId()));
//bean.setWeekSchedulerBeanList(this.weekSchedulerService.getWeekSchedulerByCalId(model.getId()));
return bean;
}
......
......@@ -41,14 +41,18 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas
BeanUtils.copyProperties(bean, model);
model.setInternals("Y".equals(bean.getInternals()));
if (bean.getCalendar() == null) {
if (bean.getCalendarID() == null) {
throw new NotFoundException("Calendar can not be null");
}
Optional<Calendar> calendarOptional = this.calendarRepository.findById(bean.getCalendar());
Optional<Calendar> calendarOptional = this.calendarRepository.findById(bean.getCalendarID());
if (!calendarOptional.isPresent()) {
throw new NotFoundException("Calendar not found " + bean.getCalendar());
throw new NotFoundException("Calendar not found " + bean.getCalendarID());
}
model.setCalendar(calendarOptional.get());
return model;
}
......@@ -57,8 +61,15 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas
SchedulerTaskBean bean = new SchedulerTaskBean();
BeanUtils.copyProperties(model, bean);
bean.setInternals(model.getInternals().booleanValue() ? "Y" : "N");
bean.setCalendar(model.getCalendar().getId());
bean.setCalendarName(model.getCalendar().getName());
// bean.setCalendar(model.getCalendar().getId());
Optional<Calendar> found = this.calendarRepository.findById(bean.getCalendarID());
// Optional<Calendar> calendarModel = this.calendarRepository.findCalendarById("C-MSG");
if (found.isPresent()){
bean.setCalendarName(found.get().getName());
}else{
bean.setCalendarName("Sigue intenetando");
}
return bean;
}
......
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