1
2
3
4 package de.tivsource.page.entity.namingitem;
5
6 import java.util.Date;
7 import java.util.Map;
8
9 import javax.persistence.Basic;
10 import javax.persistence.CascadeType;
11 import javax.persistence.Column;
12 import javax.persistence.Entity;
13 import javax.persistence.FetchType;
14 import javax.persistence.Id;
15 import javax.persistence.Inheritance;
16 import javax.persistence.InheritanceType;
17 import javax.persistence.MapKey;
18 import javax.persistence.OneToMany;
19 import javax.persistence.Temporal;
20
21 import org.hibernate.envers.Audited;
22 import org.hibernate.search.annotations.DocumentId;
23
24 import de.tivsource.page.entity.enumeration.Language;
25
26
27
28
29
30
31
32 @Audited
33 @Entity
34 @Inheritance(strategy = InheritanceType.JOINED)
35 public class NamingItem {
36
37
38
39
40
41
42 @Id
43 @DocumentId
44 @Column(name="uuid", unique=true, length=42)
45 private String uuid;
46
47
48
49
50 @OneToMany(mappedBy = "namingItem", cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
51 @MapKey(name = "language")
52 private Map<Language, Description> descriptionMap;
53
54 @Column(unique = true)
55 private String technical;
56
57 @Basic
58 @org.hibernate.annotations.Type(type = "yes_no")
59 private Boolean visible;
60
61 @Temporal(javax.persistence.TemporalType.TIMESTAMP)
62 private Date created;
63
64 @Temporal(javax.persistence.TemporalType.TIMESTAMP)
65 private Date modified;
66
67 private String modifiedBy;
68
69 private String modifiedAddress;
70
71 public String getUuid() {
72 return uuid;
73 }
74
75 public void setUuid(String uuid) {
76 this.uuid = uuid;
77 }
78
79 public Map<Language, Description> getDescriptionMap() {
80 return descriptionMap;
81 }
82
83 public void setDescriptionMap(Map<Language, Description> descriptionMap) {
84 this.descriptionMap = descriptionMap;
85 }
86
87
88
89
90 public String getTechnical() {
91 return technical;
92 }
93
94
95
96
97 public void setTechnical(String technical) {
98 this.technical = technical;
99 }
100
101 public Boolean getVisible() {
102 return visible;
103 }
104
105 public void setVisible(Boolean visible) {
106 this.visible = visible;
107 }
108
109 public Date getCreated() {
110 return created;
111 }
112
113 public void setCreated(Date created) {
114 this.created = created;
115 }
116
117 public Date getModified() {
118 return modified;
119 }
120
121 public void setModified(Date modified) {
122 this.modified = modified;
123 }
124
125 public String getModifiedBy() {
126 return modifiedBy;
127 }
128
129 public void setModifiedBy(String modifiedBy) {
130 this.modifiedBy = modifiedBy;
131 }
132
133 public String getModifiedAddress() {
134 return modifiedAddress;
135 }
136
137 public void setModifiedAddress(String modifiedAddress) {
138 this.modifiedAddress = modifiedAddress;
139 }
140
141
142
143
144
145
146
147
148
149 public String getName(String language) {
150 String result = descriptionMap.get(Language.DE).getName();
151 String tmpResult = descriptionMap.get(Language.DE).getName();
152 try {
153 tmpResult = descriptionMap.get(
154 Language.valueOf(language.toUpperCase())).getName();
155 } catch (IllegalArgumentException e) {
156 return result;
157 } catch (NullPointerException e) {
158 return result;
159 }
160 return tmpResult;
161 }
162
163 public String getShortName(String language) {
164 String result = descriptionMap.get(Language.DE).getName();
165 String tmpResult = descriptionMap.get(Language.DE).getName();
166 try {
167 tmpResult = descriptionMap.get(
168 Language.valueOf(language.toUpperCase())).getName();
169 } catch (IllegalArgumentException e) {
170 return result;
171 } catch (NullPointerException e) {
172 return result;
173 }
174
175 if (tmpResult.length() > 35) {
176 return tmpResult.substring(0, 35) + "...";
177 } else {
178 return tmpResult;
179 }
180 }
181
182 public String getName(Language language) {
183 String result = descriptionMap.get(Language.DE).getName();
184 String tmpResult = descriptionMap.get(Language.DE).getName();
185
186 try {
187 tmpResult = descriptionMap.get(language).getName();
188 } catch (IllegalArgumentException e) {
189 return result;
190 } catch (NullPointerException e) {
191 return result;
192 }
193 return tmpResult;
194 }
195
196 public String getDescription(String language) {
197 String result = descriptionMap.get(Language.DE).getDescription();
198 String tmpResult = descriptionMap.get(Language.DE).getDescription();
199 try {
200 tmpResult = descriptionMap.get(
201 Language.valueOf(language.toUpperCase())).getDescription();
202 } catch (IllegalArgumentException e) {
203 return result;
204 } catch (NullPointerException e) {
205 return result;
206 }
207 return tmpResult;
208 }
209
210 public Description getDescriptionObject(Language language) {
211 Description result = descriptionMap.get(Language.DE);
212 Description tmpResult = descriptionMap.get(Language.DE);
213 try {
214 tmpResult = descriptionMap.get(language);
215 } catch (IllegalArgumentException e) {
216 return result;
217 } catch (NullPointerException e) {
218 return result;
219 }
220 return tmpResult;
221 }
222
223 public String getShortDescription(String language) {
224 String result = descriptionMap.get(Language.DE).getDescription();
225 String tmpResult = descriptionMap.get(Language.DE).getDescription();
226 try {
227 tmpResult = descriptionMap.get(
228 Language.valueOf(language.toUpperCase())).getDescription();
229 } catch (IllegalArgumentException e) {
230 return result;
231 } catch (NullPointerException e) {
232 return result;
233 }
234
235 if (tmpResult.length() > 266) {
236 return tmpResult.substring(0, 266) + "...";
237 } else {
238 return tmpResult;
239 }
240 }
241
242 public String getOverviewDescription(String language) {
243 String result = descriptionMap.get(Language.DE).getDescription();
244 String tmpResult = descriptionMap.get(Language.DE).getDescription();
245 try {
246 tmpResult = descriptionMap.get(
247 Language.valueOf(language.toUpperCase())).getDescription();
248 } catch (IllegalArgumentException e) {
249 return result;
250 } catch (NullPointerException e) {
251 return result;
252 }
253
254 if (tmpResult.length() > 588) {
255 return tmpResult.substring(0, 588) + "...";
256 } else {
257 return tmpResult;
258 }
259 }
260
261 public String getDescription(Language language) {
262 String result = descriptionMap.get(Language.DE).getDescription();
263 String tmpResult = descriptionMap.get(Language.DE).getDescription();
264
265 try {
266 tmpResult = descriptionMap.get(language).getDescription();
267 } catch (IllegalArgumentException e) {
268 return result;
269 } catch (NullPointerException e) {
270 return result;
271 }
272 return tmpResult;
273 }
274
275 public String getKeywords(String language) {
276 String result = descriptionMap.get(Language.DE).getKeywords();
277 String tmpResult = descriptionMap.get(Language.DE).getKeywords();
278 try {
279 tmpResult = descriptionMap.get(
280 Language.valueOf(language.toUpperCase())).getKeywords();
281 } catch (IllegalArgumentException e) {
282 return result;
283 } catch (NullPointerException e) {
284 return result;
285 }
286 return tmpResult;
287 }
288
289 public String getKeywords(Language language) {
290 String result = descriptionMap.get(Language.DE).getKeywords();
291 String tmpResult = descriptionMap.get(Language.DE).getKeywords();
292
293 try {
294 tmpResult = descriptionMap.get(language).getKeywords();
295 } catch (IllegalArgumentException e) {
296 return result;
297 } catch (NullPointerException e) {
298 return result;
299 }
300 return tmpResult;
301 }
302
303 }