1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.r2.common.entity; |
17 | |
|
18 | |
import java.util.ArrayList; |
19 | |
import java.util.List; |
20 | |
|
21 | |
import javax.persistence.CascadeType; |
22 | |
import javax.persistence.Column; |
23 | |
import javax.persistence.MappedSuperclass; |
24 | |
import javax.persistence.OneToMany; |
25 | |
|
26 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
27 | |
import org.kuali.student.r2.common.dto.TypeInfo; |
28 | |
|
29 | |
|
30 | |
@MappedSuperclass |
31 | 0 | public abstract class TypeEntity<T extends BaseAttributeEntity<?>> extends BaseTypeEntity implements AttributeOwner<T> { |
32 | |
|
33 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
34 | |
private List<T> attributes; |
35 | |
|
36 | |
@Column(name = "REF_OBJECT_URI") |
37 | |
private String refObjectURI; |
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
@Override |
45 | |
public void setAttributes(List<T> attributes) { |
46 | 0 | this.attributes = attributes; |
47 | 0 | } |
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
@Override |
55 | |
public List<T> getAttributes() { |
56 | 0 | return attributes; |
57 | |
} |
58 | |
|
59 | |
public void setRefObjectURI(String refObjectURI) { |
60 | 0 | this.refObjectURI = refObjectURI; |
61 | 0 | } |
62 | |
|
63 | |
public String getRefObjectURI() { |
64 | 0 | return refObjectURI; |
65 | |
} |
66 | |
|
67 | |
public TypeInfo toDto() { |
68 | 0 | TypeInfo typeInfo = new TypeInfo(); |
69 | 0 | typeInfo.setName(this.getName()); |
70 | 0 | typeInfo.setKey(this.getId()); |
71 | 0 | typeInfo.setRefObjectURI(getRefObjectURI()); |
72 | 0 | typeInfo.setDescr(this.getDescr()); |
73 | 0 | typeInfo.setEffectiveDate(this.getEffectiveDate()); |
74 | 0 | typeInfo.setExpirationDate(this.getExpirationDate()); |
75 | 0 | typeInfo.setAttributes(new ArrayList<AttributeInfo>()); |
76 | |
|
77 | |
|
78 | 0 | List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); |
79 | 0 | for (BaseAttributeEntity<?> att : this.getAttributes()) { |
80 | 0 | atts.add(att.toDto()); |
81 | |
} |
82 | |
|
83 | 0 | typeInfo.setAttributes(atts); |
84 | |
|
85 | 0 | return typeInfo; |
86 | |
} |
87 | |
} |