1 | |
package org.kuali.student.enrollment.class1.lui.model; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.List; |
5 | |
|
6 | |
import javax.persistence.CascadeType; |
7 | |
import javax.persistence.Entity; |
8 | |
import javax.persistence.JoinColumn; |
9 | |
import javax.persistence.ManyToOne; |
10 | |
import javax.persistence.OneToMany; |
11 | |
import javax.persistence.Table; |
12 | |
|
13 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
14 | |
import org.kuali.student.r2.common.entity.AttributeOwner; |
15 | |
import org.kuali.student.r2.common.entity.MetaEntity; |
16 | |
import org.kuali.student.r2.common.infc.Attribute; |
17 | |
import org.kuali.student.r2.lum.clu.dto.ExpenditureInfo; |
18 | |
import org.kuali.student.r2.lum.clu.infc.Expenditure; |
19 | |
|
20 | |
@Entity |
21 | |
@Table(name = "KSEN_LUI_EXPENDITURE") |
22 | |
public class LuiExpenditureEntity extends MetaEntity implements AttributeOwner<LuiExpenditureAttributeEntity> { |
23 | |
|
24 | |
@ManyToOne |
25 | |
@JoinColumn(name = "LUI_ID") |
26 | |
private LuiEntity lui; |
27 | |
|
28 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
29 | |
private List<LuiExpenditureAttributeEntity> attributes; |
30 | |
|
31 | 0 | public LuiExpenditureEntity() {} |
32 | |
|
33 | |
public LuiExpenditureEntity(Expenditure expenditure) { |
34 | 0 | super(expenditure); |
35 | 0 | this.setId(expenditure.getId()); |
36 | |
|
37 | |
|
38 | 0 | this.setAttributes(new ArrayList<LuiExpenditureAttributeEntity>()); |
39 | 0 | if (null != expenditure.getAttributes()) { |
40 | 0 | for (Attribute att : expenditure.getAttributes()) { |
41 | 0 | LuiExpenditureAttributeEntity attEntity = new LuiExpenditureAttributeEntity(att); |
42 | 0 | this.getAttributes().add(attEntity); |
43 | 0 | } |
44 | |
} |
45 | 0 | } |
46 | |
|
47 | |
public ExpenditureInfo toDto() { |
48 | 0 | ExpenditureInfo obj = new ExpenditureInfo(); |
49 | 0 | obj.setId(this.getId()); |
50 | |
|
51 | |
|
52 | 0 | List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); |
53 | 0 | for (LuiExpenditureAttributeEntity att : getAttributes()) { |
54 | 0 | AttributeInfo attInfo = att.toDto(); |
55 | 0 | atts.add(attInfo); |
56 | 0 | } |
57 | 0 | obj.setAttributes(atts); |
58 | |
|
59 | 0 | obj.setMeta(super.toDTO()); |
60 | |
|
61 | 0 | return obj; |
62 | |
|
63 | |
} |
64 | |
|
65 | |
public LuiEntity getLui() { |
66 | 0 | return lui; |
67 | |
} |
68 | |
|
69 | |
public void setLui(LuiEntity lui) { |
70 | 0 | this.lui = lui; |
71 | 0 | } |
72 | |
|
73 | |
@Override |
74 | |
public void setAttributes(List<LuiExpenditureAttributeEntity> attributes) { |
75 | 0 | this.attributes = attributes; |
76 | 0 | } |
77 | |
|
78 | |
@Override |
79 | |
public List<LuiExpenditureAttributeEntity> getAttributes() { |
80 | 0 | return attributes; |
81 | |
} |
82 | |
} |