1 | |
package org.kuali.student.enrollment.class1.lrr.model; |
2 | |
|
3 | |
import org.kuali.student.enrollment.lrr.dto.ResultSourceInfo; |
4 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
5 | |
import org.kuali.student.r2.common.entity.AttributeOwner; |
6 | |
import org.kuali.student.r2.common.entity.MetaEntity; |
7 | |
import org.kuali.student.r2.common.infc.Attribute; |
8 | |
|
9 | |
import javax.persistence.*; |
10 | |
import java.util.ArrayList; |
11 | |
import java.util.List; |
12 | |
|
13 | |
@Entity |
14 | |
@Table(name = "KSEN_LRR_RES_SOURCE") |
15 | |
public class ResultSourceEntity extends MetaEntity implements AttributeOwner<ResultSourceAttributeEntity> { |
16 | |
|
17 | |
@Column(name = "NAME") |
18 | |
private String name; |
19 | |
|
20 | |
@ManyToOne(cascade = CascadeType.ALL) |
21 | |
@JoinColumn(name = "RT_DESCR_ID") |
22 | |
private ResultSourceRichTextEntity descr; |
23 | |
|
24 | |
@Column(name = "TYPE_ID") |
25 | |
private String type; |
26 | |
|
27 | |
@Column(name = "ARTICULATE_ID") |
28 | |
private String articulationId; |
29 | |
|
30 | |
@Column(name = "RES_TRANS_ID") |
31 | |
private String resultTransformationId; |
32 | |
|
33 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
34 | |
private List<ResultSourceAttributeEntity> attributes; |
35 | |
|
36 | 0 | public ResultSourceEntity(){ |
37 | |
|
38 | 0 | } |
39 | |
|
40 | |
public ResultSourceEntity(ResultSourceInfo dto){ |
41 | 0 | super(dto); |
42 | 0 | setName(dto.getName()); |
43 | 0 | setId(dto.getId()); |
44 | 0 | setArticulationId(dto.getArticulationId()); |
45 | 0 | setResultTransformationId(dto.getResultTransformationId()); |
46 | 0 | if(dto.getDescr() != null){ |
47 | 0 | this.setDescr(new ResultSourceRichTextEntity(dto.getDescr())); |
48 | |
} |
49 | |
|
50 | 0 | this.setAttributes(new ArrayList<ResultSourceAttributeEntity>()); |
51 | 0 | if (null != dto.getAttributes()) { |
52 | 0 | for (Attribute att : dto.getAttributes()) { |
53 | 0 | this.getAttributes().add(new ResultSourceAttributeEntity(att)); |
54 | |
} |
55 | |
} |
56 | |
|
57 | 0 | } |
58 | |
|
59 | |
public String getName() { |
60 | 0 | return name; |
61 | |
} |
62 | |
|
63 | |
public void setName(String name) { |
64 | 0 | this.name = name; |
65 | 0 | } |
66 | |
|
67 | |
public ResultSourceRichTextEntity getDescr() { |
68 | 0 | return descr; |
69 | |
} |
70 | |
|
71 | |
public void setDescr(ResultSourceRichTextEntity descr) { |
72 | 0 | this.descr = descr; |
73 | 0 | } |
74 | |
|
75 | |
public String getType() { |
76 | 0 | return type; |
77 | |
} |
78 | |
|
79 | |
public void setType(String type) { |
80 | 0 | this.type = type; |
81 | 0 | } |
82 | |
|
83 | |
public String getArticulationId() { |
84 | 0 | return articulationId; |
85 | |
} |
86 | |
|
87 | |
public void setArticulationId(String articulationId) { |
88 | 0 | this.articulationId = articulationId; |
89 | 0 | } |
90 | |
|
91 | |
public String getResultTransformationId() { |
92 | 0 | return resultTransformationId; |
93 | |
} |
94 | |
|
95 | |
public void setResultTransformationId(String resultTransformationId) { |
96 | 0 | this.resultTransformationId = resultTransformationId; |
97 | 0 | } |
98 | |
|
99 | |
@Override |
100 | |
public void setAttributes(List<ResultSourceAttributeEntity> attributes) { |
101 | 0 | this.attributes = attributes; |
102 | 0 | } |
103 | |
|
104 | |
@Override |
105 | |
public List<ResultSourceAttributeEntity> getAttributes() { |
106 | 0 | return attributes; |
107 | |
} |
108 | |
|
109 | |
public ResultSourceInfo toDto() { |
110 | 0 | ResultSourceInfo dto = new ResultSourceInfo(); |
111 | 0 | dto.setId(getId()); |
112 | 0 | dto.setName(getName()); |
113 | |
|
114 | 0 | dto.setArticulationId(getArticulationId()); |
115 | 0 | dto.setResultTransformationId(getResultTransformationId()); |
116 | |
|
117 | 0 | if (getDescr() != null){ |
118 | 0 | dto.setDescr(getDescr().toDto()); |
119 | |
} |
120 | |
|
121 | 0 | if (getType() != null){ |
122 | 0 | dto.setTypeKey(getType()); |
123 | |
} |
124 | |
|
125 | 0 | List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); |
126 | 0 | for (ResultSourceAttributeEntity att : getAttributes()) { |
127 | 0 | AttributeInfo attInfo = att.toDto(); |
128 | 0 | atts.add(attInfo); |
129 | 0 | } |
130 | 0 | dto.setAttributes(atts); |
131 | 0 | dto.setMeta(super.toDTO()); |
132 | |
|
133 | 0 | return dto; |
134 | |
} |
135 | |
} |