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.Column; |
8 | |
import javax.persistence.Entity; |
9 | |
import javax.persistence.JoinColumn; |
10 | |
import javax.persistence.ManyToOne; |
11 | |
import javax.persistence.OneToMany; |
12 | |
import javax.persistence.Table; |
13 | |
|
14 | |
import org.kuali.student.enrollment.lui.dto.LuiIdentifierInfo; |
15 | |
import org.kuali.student.enrollment.lui.infc.LuiIdentifier; |
16 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
17 | |
import org.kuali.student.r2.common.entity.MetaEntity; |
18 | |
import org.kuali.student.r2.common.infc.Attribute; |
19 | |
|
20 | |
@Entity |
21 | |
@Table(name = "KSEN_LUI_IDENT") |
22 | |
public class LuiIdentifierEntity extends MetaEntity { |
23 | |
|
24 | |
@Column(name = "LUI_CD") |
25 | |
private String code; |
26 | |
@Column(name = "SHRT_NAME") |
27 | |
private String shortName; |
28 | |
@Column(name = "LNG_NAME") |
29 | |
private String longName; |
30 | |
@Column(name = "DIVISION") |
31 | |
private String division; |
32 | |
@Column(name = "VARTN") |
33 | |
private String variation; |
34 | |
@Column(name = "SUFX_CD") |
35 | |
private String suffixCode; |
36 | |
@Column(name = "LUI_ID_TYPE") |
37 | |
private String type; |
38 | |
@Column(name = "LUI_ID_STATE") |
39 | |
private String state; |
40 | |
@ManyToOne |
41 | |
@JoinColumn(name = "LUI_ID") |
42 | |
private LuiEntity lui; |
43 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
44 | |
private List<LuiIdentifierAttributeEntity> attributes; |
45 | |
|
46 | 0 | public LuiIdentifierEntity() { |
47 | 0 | } |
48 | |
|
49 | |
public LuiIdentifierEntity(LuiIdentifier luiIdentifier) { |
50 | 0 | super(luiIdentifier); |
51 | 0 | this.setId(luiIdentifier.getId()); |
52 | 0 | this.setState(luiIdentifier.getStateKey()); |
53 | 0 | this.setType(luiIdentifier.getTypeKey()); |
54 | 0 | fromDto(luiIdentifier); |
55 | 0 | } |
56 | |
|
57 | |
public void fromDto(LuiIdentifier luiIdentifier) { |
58 | 0 | this.setCode(luiIdentifier.getCode()); |
59 | 0 | this.setDivision(luiIdentifier.getDivision()); |
60 | 0 | this.setLongName(luiIdentifier.getLongName()); |
61 | 0 | this.setShortName(luiIdentifier.getShortName()); |
62 | 0 | this.setSuffixCode(luiIdentifier.getSuffixCode()); |
63 | 0 | this.setVariation(luiIdentifier.getVariation()); |
64 | 0 | this.setAttributes(new ArrayList<LuiIdentifierAttributeEntity>()); |
65 | 0 | for (Attribute att : luiIdentifier.getAttributes()) { |
66 | 0 | LuiIdentifierAttributeEntity attEntity = new LuiIdentifierAttributeEntity(att); |
67 | 0 | this.getAttributes().add(attEntity); |
68 | 0 | } |
69 | 0 | } |
70 | |
|
71 | |
public LuiIdentifierInfo toDto() { |
72 | 0 | LuiIdentifierInfo info = new LuiIdentifierInfo(); |
73 | 0 | info.setId(getId()); |
74 | 0 | info.setCode(code); |
75 | 0 | info.setDivision(division); |
76 | 0 | info.setLongName(longName); |
77 | 0 | info.setShortName(shortName); |
78 | 0 | info.setStateKey(state); |
79 | 0 | info.setSuffixCode(suffixCode); |
80 | 0 | info.setTypeKey(type); |
81 | 0 | info.setVariation(variation); |
82 | 0 | info.setMeta(super.toDTO()); |
83 | |
|
84 | 0 | for (LuiIdentifierAttributeEntity att : getAttributes()) { |
85 | 0 | AttributeInfo attInfo = att.toDto(); |
86 | 0 | info.getAttributes().add(attInfo); |
87 | 0 | } |
88 | 0 | return info; |
89 | |
} |
90 | |
|
91 | |
public String getCode() { |
92 | 0 | return code; |
93 | |
} |
94 | |
|
95 | |
public void setCode(String code) { |
96 | 0 | this.code = code; |
97 | 0 | } |
98 | |
|
99 | |
public String getShortName() { |
100 | 0 | return shortName; |
101 | |
} |
102 | |
|
103 | |
public void setShortName(String shortName) { |
104 | 0 | this.shortName = shortName; |
105 | 0 | } |
106 | |
|
107 | |
public String getLongName() { |
108 | 0 | return longName; |
109 | |
} |
110 | |
|
111 | |
public void setLongName(String longName) { |
112 | 0 | this.longName = longName; |
113 | 0 | } |
114 | |
|
115 | |
public String getDivision() { |
116 | 0 | return division; |
117 | |
} |
118 | |
|
119 | |
public void setDivision(String division) { |
120 | 0 | this.division = division; |
121 | 0 | } |
122 | |
|
123 | |
public String getVariation() { |
124 | 0 | return variation; |
125 | |
} |
126 | |
|
127 | |
public void setVariation(String variation) { |
128 | 0 | this.variation = variation; |
129 | 0 | } |
130 | |
|
131 | |
public String getSuffixCode() { |
132 | 0 | return suffixCode; |
133 | |
} |
134 | |
|
135 | |
public void setSuffixCode(String suffixCode) { |
136 | 0 | this.suffixCode = suffixCode; |
137 | 0 | } |
138 | |
|
139 | |
public String getType() { |
140 | 0 | return type; |
141 | |
} |
142 | |
|
143 | |
public void setType(String type) { |
144 | 0 | this.type = type; |
145 | 0 | } |
146 | |
|
147 | |
public String getState() { |
148 | 0 | return state; |
149 | |
} |
150 | |
|
151 | |
public void setState(String state) { |
152 | 0 | this.state = state; |
153 | 0 | } |
154 | |
|
155 | |
public void setAttributes(List<LuiIdentifierAttributeEntity> attributes) { |
156 | 0 | this.attributes = attributes; |
157 | |
|
158 | 0 | } |
159 | |
|
160 | |
public List<LuiIdentifierAttributeEntity> getAttributes() { |
161 | |
|
162 | 0 | if(this.attributes!= null) |
163 | 0 | return attributes; |
164 | |
|
165 | 0 | return new ArrayList<LuiIdentifierAttributeEntity>() ; |
166 | |
} |
167 | |
|
168 | |
public LuiEntity getLui() { |
169 | 0 | return lui; |
170 | |
} |
171 | |
|
172 | |
public void setLui(LuiEntity lui) { |
173 | 0 | this.lui = lui; |
174 | 0 | } |
175 | |
} |