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