Commit b57fda7f authored by Cristian Aguirre's avatar Cristian Aguirre

SchedulerTask

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