Mercurial > hg > ismi-richfaces
annotate src/main/java/de/mpiwg/itgroup/ismi/utils/templates/WitnessTemplate.java @ 71:38dc1f0e2451
show instance name on public (publicCodex, publicWitness) pages.
author | casties |
---|---|
date | Thu, 17 Dec 2015 17:31:07 +0100 |
parents | 2e7447712fd1 |
children | 985dcecba904 |
rev | line source |
---|---|
1 | 1 package de.mpiwg.itgroup.ismi.utils.templates; |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.Collection; | |
5 import java.util.HashMap; | |
6 import java.util.List; | |
7 import java.util.Map; | |
8 | |
9 import org.apache.commons.lang.StringUtils; | |
10 import org.apache.log4j.Logger; | |
11 import org.mpi.openmind.cache.WrapperService; | |
12 import org.mpi.openmind.repository.bo.Attribute; | |
13 import org.mpi.openmind.repository.bo.Entity; | |
14 import org.mpi.openmind.repository.bo.Relation; | |
15 import org.mpi.openmind.repository.utils.RomanizationLoC; | |
16 | |
17 import de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean; | |
18 import de.mpiwg.itgroup.ismi.entry.beans.ApplicationBean; | |
19 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; | |
20 import de.mpiwg.itgroup.ismi.utils.NaturalOrderComparator; | |
21 | |
22 public class WitnessTemplate extends AbstractTemplate implements | |
23 Comparable<WitnessTemplate> { | |
24 | |
25 private static final long serialVersionUID = -8829977715724255324L; | |
26 | |
27 private static Logger logger = Logger.getLogger(WitnessTemplate.class); | |
28 | |
29 public String privacity; | |
30 public Long id; | |
31 public String ov; | |
32 public String title; | |
33 public Long titleId; | |
34 public String startPage; | |
35 public String endPage; | |
36 public String status; | |
37 public String tableOfContents; | |
38 public String notesOnTitleAuthor; | |
39 public String notesOnCollationAndCorrections; | |
40 public String notesOnOwnership; | |
41 public String notes; | |
42 public String codex; | |
43 public String collection; | |
44 public String repository; | |
45 public String city; | |
46 public String country; | |
47 public String folios; | |
48 public String ahlwardtNo; | |
49 public String colophon; | |
52
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
50 |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
51 /** scans attribute */ |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
52 public String scans; |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
53 /** public scan viewer URL */ |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
54 public String scanViewer; |
1 | 55 |
56 public String incipit; | |
57 public String explicit; | |
58 public String subject; | |
59 | |
16
0d0a3b757981
fixes for bibliographic reference display (by dwinter).
casties
parents:
8
diff
changeset
|
60 public List<String> referenceList; |
1 | 61 public Map<String, String> ownedByMap; |
62 public Map<String, String> readByMap; | |
63 | |
64 //extras fields used by the json interface | |
65 public String titleAsWrittenInWitness; | |
66 public String authorAsWrittenInWitness; | |
67 public String copyist; | |
68 public String placeOfCopying; | |
21
176a21acd008
fixed merge errors in WitnessTemplate. fixed non-resolved reference in codex info in publicCodex and publicWitness.
casties
parents:
20
diff
changeset
|
69 public Map<String,String> referenceEndnoteIdList; |
1 | 70 public String page_dimensions; |
71 public String written_area_dimensions; | |
72 public String lines_per_page; | |
73 public String page_layout; | |
74 public String script; | |
75 public String writing_surface; | |
76 public List<String> wasStudiedByList; | |
77 public String fullTitle; | |
78 public String fullTitleTranslit; | |
79 public String authorName; | |
80 public String authorNameTranslit; | |
81 public String creationDate; | |
82 | |
83 public boolean useRomanization = false; | |
84 | |
85 public boolean isUnknown() { | |
86 return StringUtils.equals("UNKNOWN", this.title); | |
87 } | |
88 | |
89 public WitnessTemplate(Entity witness, WrapperService om, boolean useRomanization) { | |
90 this.init(witness, om, false, useRomanization); | |
91 } | |
92 | |
93 public WitnessTemplate(Entity witness, WrapperService om, boolean extended, boolean useRomanization) { | |
94 this.init(witness, om, extended, useRomanization); | |
95 } | |
96 | |
97 private void init(Entity witness, WrapperService om, boolean extended, boolean useRomanization) { | |
98 // this.referenceList = new ArrayList<String>(); | |
99 this.ownedByMap = new HashMap<String, String>(); | |
100 this.readByMap = new HashMap<String, String>(); | |
101 this.wasStudiedByList = new ArrayList<String>(); | |
102 | |
103 this.useRomanization = useRomanization; | |
104 | |
105 try { | |
106 if (witness != null) { | |
107 this.privacity = witness.getPrivacity(); | |
108 | |
109 this.id = witness.getId(); | |
110 this.ov = (useRomanization) ? RomanizationLoC.convert(witness.getOwnValue()) : witness.getOwnValue(); | |
111 | |
112 if (StringUtils.isEmpty(witness.getStatus())) { | |
113 this.status = ApplicationBean.STATUS_NOT_CHECKED; | |
114 } else { | |
115 this.status = witness.getStatus(); | |
116 } | |
117 | |
118 | |
8 | 119 this.startPage = om.getAttributeOVByName(id, "start_page", false); |
120 this.endPage = om.getAttributeOVByName(id, "end_page", false); | |
1 | 121 |
8 | 122 |
123 this.folios = om.getAttributeOVByName(id, "folios", useRomanization); | |
124 this.ahlwardtNo = om.getAttributeOVByName(id, "ahlwardt_no", useRomanization); | |
125 this.colophon = om.getAttributeOVByName(id, "colophon", useRomanization); | |
126 this.page_dimensions = om.getAttributeOVByName(id, "page_dimensions", useRomanization); | |
127 this.written_area_dimensions = om.getAttributeOVByName(id, "written_area_dimensions", useRomanization); | |
128 this.lines_per_page = om.getAttributeOVByName(id, "lines_per_page", useRomanization); | |
129 this.page_layout = om.getAttributeOVByName(id, "page_layout", useRomanization); | |
130 this.script = om.getAttributeOVByName(id, "script", useRomanization); | |
131 this.writing_surface = om.getAttributeOVByName(id, "writing_surface", useRomanization); | |
1 | 132 |
52
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
133 this.scans = om.getAttributeOVByName(id, "scans", useRomanization); |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
134 |
8 | 135 Attribute att0 = om.getAttributeByName(witness.getId(), "creation_date"); |
1 | 136 Calendar creationDate0 = AbstractISMIBean.updateCalendar(att0); |
137 this.creationDate = creationDate0.getCalendarAsHtml(); | |
138 | |
139 if(extended){ | |
8 | 140 this.incipit = om.getAttributeOVByName(id, "incipit", useRomanization); |
141 this.explicit = om.getAttributeOVByName(id, "explicit", useRomanization); | |
1 | 142 } |
143 | |
8 | 144 this.tableOfContents = om.getAttributeOVByName(id, "table_of_contents", useRomanization); |
145 this.notesOnTitleAuthor = om.getAttributeOVByName(id, "notes_on_title_author", useRomanization); | |
146 this.notesOnCollationAndCorrections = om.getAttributeOVByName(id, "notes_on_collation_and_corrections", useRomanization); | |
147 this.notesOnOwnership = om.getAttributeOVByName(id, "notes_on_ownership", useRomanization); | |
148 this.notes = om.getAttributeOVByName(id, "notes", useRomanization); | |
1 | 149 |
150 List<Entity> list0 = om.getTargetsForSourceRelation(witness.getId(), "is_exemplar_of", "TEXT", 1); | |
151 if (list0.size() > 0) { | |
152 this.title = (useRomanization) ? RomanizationLoC.convert(list0.get(0).getOwnValue()) : list0.get(0).getOwnValue(); | |
153 this.titleId = list0.get(0).getId(); | |
154 att0 = om.getAttributeByName(titleId, "full_title"); | |
155 this.fullTitle = (att0 != null) ? att0.getOwnValue() : null; | |
156 this.fullTitle = (useRomanization) ? RomanizationLoC.convert(fullTitle) : fullTitle; | |
157 | |
158 att0 = om.getAttributeByName(titleId, "full_title_translit"); | |
159 if(att0 != null){ | |
160 this.fullTitleTranslit = (useRomanization) ? RomanizationLoC.convert(att0.getOwnValue()) : att0.getOwnValue(); | |
161 } | |
162 | |
163 List<Entity> list1 = om.getTargetsForSourceRelation(this.titleId, "was_created_by", "PERSON", 1); | |
164 if(list1.size() > 0){ | |
165 Entity author = list1.get(0); | |
166 att0 = om.getAttributeByName(author.getId(), "name"); | |
167 this.authorName = (att0 == null) ? null : att0.getValue(); | |
168 this.authorName = (useRomanization) ? RomanizationLoC.convert(authorName) : authorName; | |
169 att0 = om.getAttributeByName(author.getId(), "name_translit"); | |
170 if(att0 != null){ | |
171 this.authorNameTranslit = (useRomanization) ? RomanizationLoC.convert(att0.getValue()) : att0.getValue(); | |
172 } | |
173 } | |
174 | |
175 if(extended){ | |
176 //Attribute subject = om.getAttributeByName(witness.getId(), "subject"); | |
177 list0 = om.getTargetsForSourceRelation(this.titleId, "has_subject", "SUBJECT", 1); | |
178 this.subject = (!list0.isEmpty()) ? list0.get(0).getOwnValue() : null; | |
8 | 179 this.subject = (useRomanization) ? RomanizationLoC.convert(subject) : subject; |
1 | 180 |
181 } | |
182 } | |
183 | |
184 list0 = om.getTargetsForSourceRelation(witness, "has_author_written_as", "ALIAS", 1); | |
185 if(list0.size() > 0){ | |
186 this.authorAsWrittenInWitness = (useRomanization) ? RomanizationLoC.convert(list0.get(0).getOwnValue()) : list0.get(0).getOwnValue(); | |
187 } | |
188 | |
189 list0 = om.getTargetsForSourceRelation(witness, "has_title_written_as", "ALIAS", 1); | |
190 if(list0.size() > 0){ | |
191 this.titleAsWrittenInWitness = (useRomanization) ? RomanizationLoC.convert(list0.get(0).getOwnValue()) : list0.get(0).getOwnValue(); | |
192 } | |
193 | |
194 list0 = om.getTargetsForSourceRelation(witness, "was_copied_by", "PERSON", 1); | |
195 if(list0.size() > 0){ | |
196 this.copyist = (useRomanization) ? RomanizationLoC.convert(list0.get(0).getOwnValue()) : list0.get(0).getOwnValue(); | |
197 } | |
198 | |
199 list0 = om.getTargetsForSourceRelation(witness, "was_copied_in", "PLACE", 1); | |
200 this.placeOfCopying = (list0.size() > 0) ? list0.get(0).getOwnValue() : null; | |
201 | |
202 | |
203 list0 = om.getTargetsForSourceRelation(witness, "was_studied_by", "PERSON", 1); | |
204 for(Entity ent : list0){ | |
205 this.wasStudiedByList.add((useRomanization) ? RomanizationLoC.convert(ent.getOwnValue()) : ent.getOwnValue()); | |
206 } | |
207 | |
8 | 208 //**** Getting the Codices |
209 List<Entity> list = | |
210 om.getTargetsForSourceRelation(witness.getId(), "is_part_of", "CODEX", 1); | |
1 | 211 if (list.size() > 0) { |
212 Entity codex = list.get(0); | |
213 | |
52
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
214 Attribute att = om.getAttributeByName(codex.getId(), "identifier"); |
1 | 215 if (att != null && StringUtils.isNotEmpty(att.getValue())) { |
216 this.codex = att.getValue(); | |
217 } | |
52
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
218 |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
219 /* |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
220 * add scan viewer URL if codex is public |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
221 */ |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
222 // TODO: use scans attribute if available? |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
223 Attribute pub = om.getAttributeByName(codex.getId(), "public"); |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
224 if (pub != null && pub.getValue().equals("true")) { |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
225 // FIXME: make viewer URL configurable |
54 | 226 this.scanViewer = "/public/publicWitness.jsp?eid=" + this.id; |
52
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
227 } |
1 | 228 |
8 | 229 for (Relation rel : om.getSourceRelations(codex, "owned_by", "PERSON", -1)) { |
1 | 230 String date = (rel.getAttributeByName("date") != null) ? new Calendar( |
231 rel.getAttributeByName("date").getOwnValue()) | |
232 .getCalendarAsHtml() : ""; | |
8 | 233 String ov = om.getEntityById(rel.getTargetId()).getOwnValue(); |
1 | 234 String ownedLabel = (useRomanization) ? RomanizationLoC.convert(ov) : ov; |
235 this.ownedByMap.put(ownedLabel, date); | |
236 } | |
237 | |
238 for (Relation rel : om.getSourceRelations(codex, "read_by", | |
239 "PERSON", -1)) { | |
240 String date = (rel.getAttributeByName("date") != null) ? new Calendar( | |
241 rel.getAttributeByName("date").getOwnValue()) | |
242 .getCalendarAsHtml() : ""; | |
243 String ov = om.getEntityById(rel.getTargetId()).getOwnValue(); | |
244 String readerLabel = (useRomanization) ? RomanizationLoC.convert(ov) : ov; | |
245 this.readByMap.put(readerLabel, date); | |
246 } | |
247 | |
248 list = om.getTargetsForSourceRelation(codex.getId(), | |
249 "is_part_of", "COLLECTION", 1); | |
250 if (list.size() > 0) { | |
251 Entity collection = list.get(0); | |
252 this.collection = collection.getOwnValue(); | |
253 | |
254 list = om.getTargetsForSourceRelation( | |
255 collection.getId(), "is_part_of", "REPOSITORY", | |
256 1); | |
257 | |
258 if (list.size() > 0) { | |
259 Entity repository = list.get(0); | |
260 this.repository = repository.getOwnValue(); | |
261 | |
262 list = om.getTargetsForSourceRelation( | |
263 repository.getId(), "is_in", "PLACE", 1); | |
264 | |
265 if (list.size() > 0) { | |
266 Entity city = list.get(0); | |
267 this.city = city.getOwnValue(); | |
268 | |
269 list = om.getTargetsForSourceRelation( | |
270 city.getId(), "is_part_of", "PLACE", 1); | |
271 if (list.size() > 0) { | |
272 Entity country = list.get(0); | |
273 this.country = country.getOwnValue(); | |
274 } | |
275 } | |
276 } | |
277 } | |
278 } | |
279 | |
280 list0 = om.getSourcesForTargetRelation(witness, | |
281 "is_reference_of", "REFERENCE", -1); | |
282 for (Entity ref : list0) { | |
20 | 283 //System.out.println("### REF= " + ref.getId()); |
1 | 284 this.refEntityList.add(om.getEntityContent(ref)); |
285 } | |
286 } | |
287 | |
288 this.loadRefernces(); | |
21
176a21acd008
fixed merge errors in WitnessTemplate. fixed non-resolved reference in codex info in publicCodex and publicWitness.
casties
parents:
20
diff
changeset
|
289 this.referenceEndnoteIdList = new HashMap<String,String>(); |
20 | 290 |
291 for (ReferenceTemplate refTempl : this.getReferenceList()){ | |
292 this.referenceEndnoteIdList.put(refTempl.getEndnoteId(),refTempl.getAdditionalInf()); | |
21
176a21acd008
fixed merge errors in WitnessTemplate. fixed non-resolved reference in codex info in publicCodex and publicWitness.
casties
parents:
20
diff
changeset
|
293 } |
1 | 294 } catch (Exception e) { |
295 logger.error(e.getMessage(), e); | |
296 } | |
297 } | |
298 | |
299 public String getPrivacity() { | |
300 return privacity; | |
301 } | |
302 | |
303 public String getStatus() { | |
304 return status; | |
305 } | |
306 | |
307 public String getTableOfContents() { | |
308 return tableOfContents; | |
309 } | |
310 | |
311 public String getNotesOnTitleAuthor() { | |
312 return notesOnTitleAuthor; | |
313 } | |
314 | |
315 public String getNotesOnCollationAndCorrections() { | |
316 return notesOnCollationAndCorrections; | |
317 } | |
318 | |
319 public String getNotesOnOwnership() { | |
320 return notesOnOwnership; | |
321 } | |
322 | |
323 public String getNotes() { | |
324 return notes; | |
325 } | |
326 | |
327 public String getCodex() { | |
328 return codex; | |
329 } | |
330 | |
331 public String getCollection() { | |
332 return collection; | |
333 } | |
334 | |
335 public String getRepository() { | |
336 return repository; | |
337 } | |
338 | |
339 public String getCity() { | |
340 return city; | |
341 } | |
342 | |
343 public String getCountry() { | |
344 return country; | |
345 } | |
346 | |
347 public Map<String, String> getOwnedByMap() { | |
348 return ownedByMap; | |
349 } | |
350 | |
351 public Map<String, String> getReadByMap() { | |
352 return readByMap; | |
353 } | |
354 | |
355 public Collection<String> getOwnedByList() { | |
356 return ownedByMap.keySet(); | |
357 } | |
358 | |
359 public Collection<String> getReadByList() { | |
360 return readByMap.keySet(); | |
361 } | |
362 | |
363 public static Logger getLogger() { | |
364 return logger; | |
365 } | |
366 | |
367 public String getStartPage() { | |
368 return startPage; | |
369 } | |
370 | |
371 public String getEndPage() { | |
372 return endPage; | |
373 } | |
374 | |
375 public Long getId() { | |
376 return id; | |
377 } | |
378 | |
379 public String getOv() { | |
380 return ov; | |
381 } | |
382 | |
383 public String getTitle() { | |
384 return this.title; | |
385 } | |
386 | |
387 public Long getTitleId() { | |
388 return this.titleId; | |
389 } | |
390 | |
391 public String getFolios() { | |
392 return this.folios; | |
393 } | |
394 | |
395 public boolean hasTitle(){ | |
396 return this.titleId != null; | |
397 } | |
398 | |
52
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
399 public String getScans() { |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
400 return this.scans; |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
401 } |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
402 |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
403 public String getScanViewer() { |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
404 return this.scanViewer; |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
405 } |
4ee8d47e1e34
hide simple search when not logged in. add scan viewer link to displayAuthor when codex is public.
casties
parents:
21
diff
changeset
|
406 |
1 | 407 // 40b-49b |
408 // 104b-111b | |
409 public int compareTo(WitnessTemplate other) { | |
410 // return this.empId - o.empId ; | |
411 | |
412 if (other == null) | |
413 return -1; | |
414 if (StringUtils.isEmpty(this.folios) | |
415 && StringUtils.isEmpty(other.folios)) | |
416 return this.title.compareTo(other.title); | |
417 if (StringUtils.isEmpty(this.folios)) | |
418 return 1; | |
419 if (StringUtils.isEmpty(other.folios)) | |
420 return -1; | |
421 | |
422 try { | |
423 return NaturalOrderComparator.compare(this.folios, other.folios); | |
424 } catch (Exception e) { | |
425 logger.error(e.getMessage(), e); | |
426 } | |
427 | |
428 return 0; | |
429 } | |
430 | |
431 } |