View Javadoc

1   package org.kuali.student.enrollment.class1.lui.model;
2   
3   import org.kuali.student.r2.common.assembler.TransformUtility;
4   import org.kuali.student.r2.common.entity.AttributeOwner;
5   import org.kuali.student.r2.common.entity.MetaEntity;
6   import org.kuali.student.r2.lum.clu.dto.AffiliatedOrgInfo;
7   import org.kuali.student.r2.lum.clu.infc.AffiliatedOrg;
8   
9   import javax.persistence.*;
10  import java.util.ArrayList;
11  import java.util.Date;
12  import java.util.List;
13  import java.util.Set;
14  
15  @Entity
16  @Table(name = "KSEN_LUI_AFFILIATED_ORG")
17  public class LuiAffiliatedOrgEntity extends MetaEntity implements AttributeOwner<LuiAffiliatedOrgAttributeEntity>{
18  
19      @Column(name = "AFFILIATED_ORG_TYPE", nullable = false)
20      private String type;
21  
22      @Column(name = "AFFILIATED_ORG_STATE", nullable = false)
23      private String state;
24      
25      @Temporal(TemporalType.TIMESTAMP)
26      @Column(name = "EFF_DT")
27      private Date effectiveDate;
28  
29      @Temporal(TemporalType.TIMESTAMP)
30      @Column(name = "EXPIR_DT")
31      private Date expirationDate;
32      
33      @Column(name = "PERCENTAGE")
34      private Long percentage;
35      
36      @Column(name = "ORG_ID", nullable = false)
37      private String orgId;
38      
39      @Column(name = "EXPENDITURE_ID")
40      private String expenditureId;
41      
42      @Column(name = "REVENUE_ID")
43      private String revenueId;
44  
45      @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner", fetch = FetchType.EAGER)
46      private Set<LuiAffiliatedOrgAttributeEntity> attributes;
47      
48      public LuiAffiliatedOrgEntity() {}
49  
50      public LuiAffiliatedOrgEntity(AffiliatedOrg affiliatedOrg) {
51          super(affiliatedOrg);
52  
53          List<Object> orphansToDelete = new ArrayList<Object>();
54  
55          this.setId(affiliatedOrg.getId());
56          this.setType(affiliatedOrg.getTypeKey());
57          this.setState(affiliatedOrg.getStateKey());
58          this.setEffectiveDate(affiliatedOrg.getEffectiveDate());
59          this.setExpirationDate(affiliatedOrg.getExpirationDate());
60          
61          this.setOrgId(affiliatedOrg.getOrgId());
62          this.setPercentage(affiliatedOrg.getPercentage());
63          //this.setExpenditureId();
64          //this.setRevenueId();
65  
66          // Merge attributes into entity
67          TransformUtility.mergeToEntityAttributes(LuiAffiliatedOrgAttributeEntity.class, affiliatedOrg, this);
68      }
69      
70      public AffiliatedOrgInfo toDto() {
71          
72          AffiliatedOrgInfo obj = new AffiliatedOrgInfo();
73          obj.setId(this.getId());
74          obj.setTypeKey(this.getType());
75          obj.setStateKey(this.getState());
76          obj.setEffectiveDate(this.getEffectiveDate());
77          obj.setExpirationDate(this.getExpirationDate());
78          
79          obj.setOrgId(this.getOrgId());
80          obj.setPercentage(this.getPercentage());
81          //obj.setExpenditureId
82          //obj.setRevenueId
83  
84          obj.setAttributes(TransformUtility.toAttributeInfoList(this));
85          
86          obj.setMeta(super.toDTO());
87  
88          return obj;
89  
90      }
91      
92      public String getType() {
93          return type;
94      }
95  
96      public void setType(String type) {
97          this.type = type;
98      }
99  
100     public String getState() {
101         return state;
102     }
103 
104     public void setState(String state) {
105         this.state = state;
106     }
107 
108     public Date getEffectiveDate() {
109         return effectiveDate;
110     }
111 
112     public void setEffectiveDate(Date effectiveDate) {
113         this.effectiveDate = effectiveDate;
114     }
115 
116     public Date getExpirationDate() {
117         return expirationDate;
118     }
119 
120     public void setExpirationDate(Date expirationDate) {
121         this.expirationDate = expirationDate;
122     }
123 
124     public Long getPercentage() {
125         return percentage;
126     }
127 
128     public void setPercentage(Long percentage) {
129         this.percentage = percentage;
130     }
131 
132     public String getOrgId() {
133         return orgId;
134     }
135 
136     public void setOrgId(String orgId) {
137         this.orgId = orgId;
138     }
139 
140     public String getExpenditureId() {
141         return expenditureId;
142     }
143 
144     public void setExpenditureId(String expenditureId) {
145         this.expenditureId = expenditureId;
146     }
147 
148     public String getRevenueId() {
149         return revenueId;
150     }
151 
152     public void setRevenueId(String revenueId) {
153         this.revenueId = revenueId;
154     }
155 
156     @Override
157     public void setAttributes(Set<LuiAffiliatedOrgAttributeEntity> attributes) {
158         this.attributes = attributes;
159     }
160 
161     @Override
162     public Set<LuiAffiliatedOrgAttributeEntity> getAttributes() {
163         return attributes;
164     }
165 
166 }