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.ExpenditureInfo;
7   import org.kuali.student.r2.lum.clu.infc.Expenditure;
8   
9   import javax.persistence.*;
10  import java.util.Set;
11  
12  @Entity
13  @Table(name = "KSEN_LUI_EXPENDITURE")
14  public class LuiExpenditureEntity extends MetaEntity implements AttributeOwner<LuiExpenditureAttributeEntity> {
15  
16      @ManyToOne
17      @JoinColumn(name = "LUI_ID")
18      private LuiEntity lui;
19  
20      @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner", fetch = FetchType.EAGER)
21      private Set<LuiExpenditureAttributeEntity> attributes;
22  
23      public LuiExpenditureEntity() {}
24  
25      public LuiExpenditureEntity(Expenditure expenditure) {
26          super(expenditure);
27          this.setId(expenditure.getId());
28  
29          // Attributes
30          TransformUtility.mergeToEntityAttributes(LuiExpenditureAttributeEntity.class, expenditure, this);
31      }
32  
33      public ExpenditureInfo toDto() {
34          ExpenditureInfo obj = new ExpenditureInfo();
35          obj.setId(this.getId());
36  
37          // Attributes
38          obj.setAttributes(TransformUtility.toAttributeInfoList(this));
39          
40          obj.setMeta(super.toDTO());
41  
42          return obj;
43  
44      }
45      
46      public LuiEntity getLui() {
47          return lui;
48      }
49  
50      public void setLui(LuiEntity lui) {
51          this.lui = lui;
52      }
53  
54      @Override
55      public void setAttributes(Set<LuiExpenditureAttributeEntity> attributes) {
56          this.attributes = attributes;
57      }
58  
59      @Override
60      public Set<LuiExpenditureAttributeEntity> getAttributes() {
61          return attributes;
62      }
63  }