Commit b57fda7f authored by Cristian Aguirre's avatar Cristian Aguirre

SchedulerTask

parent 8b0856db
......@@ -23,9 +23,9 @@ public class SchedulerTaskBean implements Serializable {
@Expose
private String stringParameters;
@Expose
private String calendar;
private String calendarID;
@Expose
private String calendarName;
@Expose
private int idEtl;
// @Expose
// private int idEtl;
}
......@@ -9,7 +9,7 @@ import org.hibernate.envers.Audited;
import javax.persistence.*;
import java.io.Serializable;
@Audited
//@Audited
@Entity
@Table(name = "avb_process_etl")
@NamedQuery(name = "ProcessETL.findByPK", query = "Select u from ProcessETL u where u.id = ?1")
......
......@@ -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,15 +47,19 @@ public class SchedulerTask implements Serializable {
@Column(name = "SHTA_PARAM")
private String stringParameters;
@Column(name= "cale_id")
private String calendarID;
@ManyToOne(optional = false)
@NotFound(action = NotFoundAction.IGNORE)
@JoinColumn(name = "CALE_ID", referencedColumnName = "CALE_ID", nullable = false)
private Calendar calendar;
/*@ManyToOne(optional = false)
@JoinColumn(name = "ETL_ID", referencedColumnName = "ETL_ID", nullable = false)
private ProcessETL processETL;*/
@Column(name = "ETL_ID")
private int processETL;
@Column(name = "etl_id")
private Integer processETL;
}
......@@ -41,7 +41,7 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas
if (bean.getCalendarID() == null) {
throw new NotFoundException("Calendar can not be null");
}
bean.setCalendarID(bean.getCalendarID().trim());
Optional<Calendar> calendarOptional = this.calendarRepository.findById(bean.getCalendarID());
if (!calendarOptional.isPresent()) {
throw new NotFoundException("Calendar not found " + bean.getCalendarID());
......@@ -56,12 +56,14 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas
SchedulerTaskBean bean = new SchedulerTaskBean();
BeanUtils.copyProperties(model, bean);
bean.setInternals(model.getInternals().booleanValue() ? "Y" : "N");
bean.setCalendarID(bean.getCalendarID().trim());
CalendarBean found = this.CalendarService.getById(bean.getCalendarID().trim());
if(found != null){
bean.setCalendarName(found.getName());
// CalendarBean found = this.CalendarService.getById(bean.getCalendarID());
Optional<Calendar> calendarOptional = this.calendarRepository.findById(bean.getCalendarID());
if (!calendarOptional.isPresent()) {
throw new NotFoundException("Calendar not found " + bean.getCalendarID());
}
bean.setCalendarName(calendarOptional.get().getName());
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