1 | |
package org.kuali.student.enrollment.lpr.model.usinginfc; |
2 | |
|
3 | |
import java.io.Serializable; |
4 | |
import java.util.ArrayList; |
5 | |
import java.util.Date; |
6 | |
import java.util.List; |
7 | |
|
8 | |
import javax.persistence.Entity; |
9 | |
import javax.persistence.GeneratedValue; |
10 | |
import javax.persistence.Id; |
11 | |
import javax.persistence.JoinColumn; |
12 | |
import javax.persistence.OneToMany; |
13 | |
import javax.persistence.Temporal; |
14 | |
import javax.persistence.TemporalType; |
15 | |
|
16 | |
import org.kuali.student.common.dto.AttributeInfo; |
17 | |
import org.kuali.student.common.infc.AttributeInfc; |
18 | |
import org.kuali.student.common.infc.MetaInfc; |
19 | |
import org.kuali.student.enrollment.lpr.dto.LuiPersonRelationInfo; |
20 | |
import org.kuali.student.enrollment.lpr.infc.LuiPersonRelationInfc; |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
@Entity |
26 | |
public class LuiPersonRelationEntity implements LuiPersonRelationInfc, Serializable { |
27 | |
|
28 | |
private static final long serialVersionUID = -8711908979901134064L; |
29 | |
@Id |
30 | |
@GeneratedValue |
31 | |
private Long id; |
32 | |
private String personId; |
33 | |
private String luiId; |
34 | |
@Temporal(TemporalType.DATE) |
35 | |
private Date effectiveDate; |
36 | |
@Temporal(TemporalType.DATE) |
37 | |
private Date expirationDate; |
38 | |
@OneToMany |
39 | |
@JoinColumn(name = "lui_person_relation_id") |
40 | |
private List<AttributeInfc> attributes; |
41 | |
private String type; |
42 | |
private String state; |
43 | |
|
44 | 0 | public LuiPersonRelationEntity(LuiPersonRelationInfc lprInfo) { |
45 | 0 | this.id = Long.valueOf(lprInfo.getId()); |
46 | 0 | this.personId = lprInfo.getPersonId(); |
47 | 0 | this.luiId = lprInfo.getLuiId(); |
48 | 0 | this.effectiveDate = new Date(lprInfo.getEffectiveDate().getTime()); |
49 | 0 | this.expirationDate = new Date(lprInfo.getExpirationDate().getTime()); |
50 | 0 | this.attributes = new ArrayList<AttributeInfc>(lprInfo.getAttributes()); |
51 | 0 | this.type = lprInfo.getType(); |
52 | 0 | this.state = lprInfo.getState(); |
53 | 0 | } |
54 | |
|
55 | 0 | public LuiPersonRelationEntity() { |
56 | 0 | } |
57 | |
|
58 | |
public LuiPersonRelationInfc toDto() { |
59 | 0 | return new LuiPersonRelationInfo.Builder(this).build(); |
60 | |
} |
61 | |
|
62 | |
public static LuiPersonRelationEntity fromDto(LuiPersonRelationInfc lprInfo) { |
63 | 0 | return new LuiPersonRelationEntity(lprInfo); |
64 | |
} |
65 | |
|
66 | |
@Override |
67 | |
public String getId() { |
68 | 0 | return "" + id; |
69 | |
} |
70 | |
|
71 | |
@Override |
72 | |
public String getPersonId() { |
73 | 0 | return personId; |
74 | |
} |
75 | |
|
76 | |
@Override |
77 | |
public String getLuiId() { |
78 | 0 | return luiId; |
79 | |
} |
80 | |
|
81 | |
@Override |
82 | |
public Date getEffectiveDate() { |
83 | 0 | return effectiveDate; |
84 | |
} |
85 | |
|
86 | |
@Override |
87 | |
public Date getExpirationDate() { |
88 | 0 | return expirationDate; |
89 | |
} |
90 | |
|
91 | |
@Override |
92 | |
public String getType() { |
93 | 0 | return type; |
94 | |
} |
95 | |
|
96 | |
@Override |
97 | |
public String getState() { |
98 | 0 | return this.state; |
99 | |
} |
100 | |
|
101 | |
@Override |
102 | |
public List<AttributeInfc> getAttributes() { |
103 | 0 | if (this.attributes == null) { |
104 | 0 | return null; |
105 | |
} |
106 | 0 | List<AttributeInfc> list = new ArrayList<AttributeInfc>(attributes.size()); |
107 | 0 | for (AttributeInfc dae : this.attributes) { |
108 | 0 | list.add(new AttributeInfo.Builder().id(dae.getId()).key(dae.getKey()).value(dae.getValue()).build()); |
109 | |
} |
110 | 0 | return list; |
111 | |
} |
112 | |
|
113 | |
@Override |
114 | |
public MetaInfc getMetaInfo() { |
115 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
116 | |
} |
117 | |
|
118 | |
public void setId(Long id) { |
119 | 0 | this.id = id; |
120 | 0 | } |
121 | |
|
122 | |
public void setPersonId(String personId) { |
123 | 0 | this.personId = personId; |
124 | 0 | } |
125 | |
|
126 | |
public void setLuiId(String luiId) { |
127 | 0 | this.luiId = luiId; |
128 | 0 | } |
129 | |
|
130 | |
public void setEffectiveDate(Date effectiveDate) { |
131 | 0 | this.effectiveDate = effectiveDate; |
132 | 0 | } |
133 | |
|
134 | |
public void setExpirationDate(Date expirationDate) { |
135 | 0 | this.expirationDate = expirationDate; |
136 | 0 | } |
137 | |
|
138 | |
public void setAttributes(List<AttributeInfc> attributes) { |
139 | 0 | this.attributes = attributes; |
140 | 0 | } |
141 | |
|
142 | |
public void setType(String type) { |
143 | 0 | this.type = type; |
144 | 0 | } |
145 | |
|
146 | |
public void setState(String state) { |
147 | 0 | this.state = state; |
148 | 0 | } |
149 | |
} |