View Javadoc
1   package org.kuali.student.enrollment.class1.lui.model;
2   
3   import org.kuali.student.r2.common.dto.AttributeInfo;
4   import org.kuali.student.r2.common.entity.AttributeOwner;
5   import org.kuali.student.r2.common.entity.MetaEntity;
6   import org.kuali.student.r2.common.infc.Attribute;
7   import org.kuali.student.r2.lum.clu.dto.RevenueInfo;
8   import org.kuali.student.r2.lum.clu.infc.Revenue;
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.JoinColumn;
15  import javax.persistence.ManyToOne;
16  import javax.persistence.OneToMany;
17  import javax.persistence.Table;
18  import java.util.ArrayList;
19  import java.util.HashSet;
20  import java.util.List;
21  import java.util.Set;
22  
23  @Entity
24  @Table(name = "KSEN_LUI_REVENUE")
25  public class LuiRevenueEntity extends MetaEntity implements AttributeOwner<LuiRevenueAttributeEntity> {
26  
27      @Column(name = "FEE_TYPE")
28      private String feeType;
29  
30      @ManyToOne
31      @JoinColumn(name = "LUI_ID")
32      private LuiEntity lui;
33  
34      @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner", fetch = FetchType.EAGER)
35      private Set<LuiRevenueAttributeEntity> attributes;
36  
37      public LuiRevenueEntity() {}
38  
39      public LuiRevenueEntity(Revenue revenue) {
40          super(revenue);
41          this.setId(revenue.getId());
42          this.setFeeType(revenue.getFeeType());
43  
44          // Attributes
45          this.setAttributes(new HashSet<LuiRevenueAttributeEntity>());
46          if (null != revenue.getAttributes()) {
47              for (Attribute att : revenue.getAttributes()) {
48                  LuiRevenueAttributeEntity attEntity = new LuiRevenueAttributeEntity(att, this);
49                  this.getAttributes().add(attEntity);
50              }
51          }
52      }
53  
54      public RevenueInfo toDto() {
55          RevenueInfo obj = new RevenueInfo();
56          obj.setId(this.getId());
57          obj.setFeeType(this.getFeeType());
58  
59          // Attributes
60          List<AttributeInfo> atts = new ArrayList<AttributeInfo>();
61          for (LuiRevenueAttributeEntity att : getAttributes()) {
62              AttributeInfo attInfo = att.toDto();
63              atts.add(attInfo);
64          }
65          obj.setAttributes(atts);
66          
67          obj.setMeta(super.toDTO());
68  
69          return obj;
70  
71      }
72  
73      public String getFeeType() {
74          return feeType;
75      }
76  
77      public void setFeeType(String feeType) {
78          this.feeType = feeType;
79      }
80  
81      public LuiEntity getLui() {
82          return lui;
83      }
84  
85      public void setLui(LuiEntity lui) {
86          this.lui = lui;
87      }
88  
89      @Override
90      public void setAttributes(Set<LuiRevenueAttributeEntity> attributes) {
91          this.attributes = attributes;
92      }
93  
94      @Override
95      public Set<LuiRevenueAttributeEntity> getAttributes() {
96          return attributes;
97      }
98  
99  }