Coverage Report - org.kuali.student.r2.core.class1.scheduling.model.ScheduleRequestEntity
 
Classes in this File Line Coverage Branch Coverage Complexity
ScheduleRequestEntity
0%
0/60
0%
0/14
1.318
 
 1  
 package org.kuali.student.r2.core.class1.scheduling.model;
 2  
 
 3  
 import org.kuali.student.common.entity.KSEntityConstants;
 4  
 import org.kuali.student.r2.common.entity.MetaEntity;
 5  
 import org.kuali.student.r2.common.infc.Attribute;
 6  
 import org.kuali.student.r2.core.scheduling.dto.ScheduleRequestInfo;
 7  
 import org.kuali.student.r2.core.scheduling.infc.ScheduleRequest;
 8  
 import org.kuali.student.r2.core.scheduling.infc.ScheduleRequestComponent;
 9  
 
 10  
 import javax.persistence.CascadeType;
 11  
 import javax.persistence.Column;
 12  
 import javax.persistence.Entity;
 13  
 import javax.persistence.FetchType;
 14  
 import javax.persistence.OneToMany;
 15  
 import javax.persistence.Table;
 16  
 import java.util.ArrayList;
 17  
 import java.util.List;
 18  
 
 19  
 /**
 20  
  * @Version 2.0
 21  
  * @Author Sri komandur@uw.edu
 22  
  */
 23  
 @Entity
 24  
 @Table(name = "KSEN_SCHED_RQST")
 25  
 public class ScheduleRequestEntity extends MetaEntity {
 26  
 
 27  
     @Column(name = "REF_OBJECT_ID")
 28  
     private String refObjectId;
 29  
 
 30  
     @Column(name = "REF_OBJECT_TYPE")
 31  
     private String refObjectTypeKey;
 32  
 
 33  
     @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "owner")
 34  
     private List<ScheduleRequestComponentEntity> scheduleRequestComponentEntities;
 35  
 
 36  
     // IdEntity fields follow
 37  
     @Column(name = "NAME")
 38  
     private String name;
 39  
 
 40  
     @Column(name = "DESCR_PLAIN", length = KSEntityConstants.EXTRA_LONG_TEXT_LENGTH)
 41  
     private String plain;
 42  
 
 43  
     @Column(name = "DESCR_FORMATTED", length = KSEntityConstants.EXTRA_LONG_TEXT_LENGTH)
 44  
     private String formatted;
 45  
 
 46  
     @Column(name = "SCHED_RQST_TYPE")
 47  
     private String schedReqType;
 48  
 
 49  
     @Column(name = "SCHED_RQST_STATE")
 50  
     private String schedReqState;
 51  
 
 52  0
     @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
 53  
     private List<ScheduleRequestAttributeEntity> attributes = new ArrayList<ScheduleRequestAttributeEntity>();
 54  
 
 55  0
     public ScheduleRequestEntity() {
 56  0
     }
 57  
 
 58  
     public ScheduleRequestEntity(String scheduleRequestTypeKey, ScheduleRequest scheduleRequest) {
 59  0
         super(scheduleRequest);
 60  0
         this.setId(scheduleRequest.getId());
 61  0
         this.setRefObjectId(scheduleRequest.getRefObjectId());
 62  0
         this.setRefObjectTypeKey(scheduleRequest.getRefObjectTypeKey());
 63  0
         this.setSchedReqType(scheduleRequest.getTypeKey());
 64  0
         this.fromDto(scheduleRequest);
 65  0
     }
 66  
 
 67  
     public void fromDto(ScheduleRequest scheduleRequest) {
 68  0
         this.setSchedReqState(scheduleRequest.getStateKey());
 69  0
         this.setScheduleRequestComponentEntities(new ArrayList<ScheduleRequestComponentEntity>());
 70  0
         for (ScheduleRequestComponent component : scheduleRequest.getScheduleRequestComponents()) {
 71  0
             this.getScheduleRequestComponentEntities().add(new ScheduleRequestComponentEntity(component));
 72  
         }
 73  0
         this.setAttributes(new ArrayList<ScheduleRequestAttributeEntity>());
 74  0
         if (null != scheduleRequest.getAttributes()) {
 75  0
             for (Attribute att : scheduleRequest.getAttributes()) {
 76  0
                 this.getAttributes().add(new ScheduleRequestAttributeEntity(att, this));
 77  
             }
 78  
         }
 79  0
     }
 80  
 
 81  
     public ScheduleRequestInfo toDto() {
 82  0
         ScheduleRequestInfo scheduleRequestInfo = new ScheduleRequestInfo();
 83  0
         scheduleRequestInfo.setRefObjectId(this.getRefObjectId());
 84  0
         scheduleRequestInfo.setRefObjectTypeKey(this.getRefObjectTypeKey());
 85  0
         if (null != this.scheduleRequestComponentEntities) {
 86  0
             for (ScheduleRequestComponentEntity entity : this.scheduleRequestComponentEntities) {
 87  0
                 scheduleRequestInfo.getScheduleRequestComponents().add(entity.toDto());
 88  
             }
 89  
         }
 90  
         // -------------------------------------------------
 91  
         // Stuff that is updated for nearly all entities
 92  0
         scheduleRequestInfo.setId(this.getId()); // id is assumed not null
 93  0
         scheduleRequestInfo.setTypeKey(this.getSchedReqType()); // type is assumed not null
 94  0
         scheduleRequestInfo.setStateKey(this.getSchedReqState()); // state is assumed not null
 95  0
         scheduleRequestInfo.setMeta(super.toDTO());
 96  0
         if (getAttributes() != null) {
 97  0
             for (ScheduleRequestAttributeEntity att : getAttributes()) {
 98  0
                 scheduleRequestInfo.getAttributes().add(att.toDto());
 99  
             }
 100  
         }
 101  0
         return scheduleRequestInfo;
 102  
     }
 103  
 
 104  
     public String getRefObjectId() {
 105  0
         return refObjectId;
 106  
     }
 107  
 
 108  
     public void setRefObjectId(String refObjectId) {
 109  0
         this.refObjectId = refObjectId;
 110  0
     }
 111  
 
 112  
     public String getRefObjectTypeKey() {
 113  0
         return refObjectTypeKey;
 114  
     }
 115  
 
 116  
     public void setRefObjectTypeKey(String refObjectTypeKey) {
 117  0
         this.refObjectTypeKey = refObjectTypeKey;
 118  0
     }
 119  
 
 120  
     public List<ScheduleRequestComponentEntity> getScheduleRequestComponentEntities() {
 121  0
         return scheduleRequestComponentEntities;
 122  
     }
 123  
 
 124  
     public void setScheduleRequestComponentEntities(List<ScheduleRequestComponentEntity> scheduleRequestComponentEntities) {
 125  0
         this.scheduleRequestComponentEntities = scheduleRequestComponentEntities;
 126  0
     }
 127  
 
 128  
     public String getName() {
 129  0
         return name;
 130  
     }
 131  
 
 132  
     public void setName(String name) {
 133  0
         this.name = name;
 134  0
     }
 135  
 
 136  
     public String getPlain() {
 137  0
         return plain;
 138  
     }
 139  
 
 140  
     public void setPlain(String plain) {
 141  0
         this.plain = plain;
 142  0
     }
 143  
 
 144  
     public String getFormatted() {
 145  0
         return formatted;
 146  
     }
 147  
 
 148  
     public void setFormatted(String formatted) {
 149  0
         this.formatted = formatted;
 150  0
     }
 151  
 
 152  
     public String getSchedReqType() {
 153  0
         return schedReqType;
 154  
     }
 155  
 
 156  
     public void setSchedReqType(String schedReqType) {
 157  0
         this.schedReqType = schedReqType;
 158  0
     }
 159  
 
 160  
     public String getSchedReqState() {
 161  0
         return schedReqState;
 162  
     }
 163  
 
 164  
     public void setSchedReqState(String schedReqState) {
 165  0
         this.schedReqState = schedReqState;
 166  0
     }
 167  
 
 168  
     public List<ScheduleRequestAttributeEntity> getAttributes() {
 169  0
         return attributes;
 170  
     }
 171  
 
 172  
     public void setAttributes(List<ScheduleRequestAttributeEntity> attributes) {
 173  0
         this.attributes = attributes;
 174  0
     }
 175  
 }