Mercurial > hg > ismi-richfaces
comparison src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentWitnessBean.java @ 120:71638720fe2f
working on MISIDENTIFICATION for witnesses.
author | casties |
---|---|
date | Fri, 06 Jan 2017 20:41:35 +0100 |
parents | 4aa8c425685d |
children | 6f0e9a333c15 |
comparison
equal
deleted
inserted
replaced
119:4aa8c425685d | 120:71638720fe2f |
---|---|
21 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; | 21 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; |
22 import de.mpiwg.itgroup.ismi.auxObjects.lo.WitnessAuthorLO; | 22 import de.mpiwg.itgroup.ismi.auxObjects.lo.WitnessAuthorLO; |
23 import de.mpiwg.itgroup.ismi.auxObjects.lo.WitnessTextLO; | 23 import de.mpiwg.itgroup.ismi.auxObjects.lo.WitnessTextLO; |
24 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; | 24 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; |
25 import de.mpiwg.itgroup.ismi.util.guiComponents.EntityList; | 25 import de.mpiwg.itgroup.ismi.util.guiComponents.EntityList; |
26 import de.mpiwg.itgroup.ismi.util.guiComponents.Misidentification; | |
27 import de.mpiwg.itgroup.ismi.util.guiComponents.MisidentificationTable; | |
26 import de.mpiwg.itgroup.ismi.util.guiComponents.StatusImage; | 28 import de.mpiwg.itgroup.ismi.util.guiComponents.StatusImage; |
27 | 29 |
28 public class CurrentWitnessBean extends CodexEditorTemplate implements Serializable{ | 30 public class CurrentWitnessBean extends CodexEditorTemplate implements Serializable{ |
29 | 31 |
30 private static final long serialVersionUID = -7645136722251494419L; | 32 private static final long serialVersionUID = -7645136722251494419L; |
92 //private IslamicCalendar islamicCalCopyDate; | 94 //private IslamicCalendar islamicCalCopyDate; |
93 private transient Calendar copyDate; | 95 private transient Calendar copyDate; |
94 | 96 |
95 private EntityList studiedByList; | 97 private EntityList studiedByList; |
96 private EntityList possibleExamplerOfList; | 98 private EntityList possibleExamplerOfList; |
99 | |
100 private MisidentificationTable misidentTable; | |
97 | 101 |
98 public CurrentWitnessBean() { | 102 public CurrentWitnessBean() { |
99 super(); | 103 super(); |
100 this.entity = new Entity(Node.TYPE_ABOX, WITNESS, false); | 104 this.entity = new Entity(Node.TYPE_ABOX, WITNESS, false); |
101 setDefObjectClass(WITNESS); | 105 setDefObjectClass(WITNESS); |
169 | 173 |
170 this.newIdentifier = ""; | 174 this.newIdentifier = ""; |
171 | 175 |
172 //this.islamicCalCopyDate = new IslamicCalendar(); | 176 //this.islamicCalCopyDate = new IslamicCalendar(); |
173 this.copyDate = new Calendar(); | 177 this.copyDate = new Calendar(); |
178 | |
179 this.misidentTable = new MisidentificationTable(); | |
174 } | 180 } |
175 | 181 |
176 @Override | 182 @Override |
177 public String save() { | 183 public String save() { |
178 super.save(); | 184 super.save(); |
226 | 232 |
227 // WITNESS -> had_patron -> PERSON | 233 // WITNESS -> had_patron -> PERSON |
228 this.entity.replaceSourceRelation(this.patronageLo.entity, PERSON, rel_had_patron); | 234 this.entity.replaceSourceRelation(this.patronageLo.entity, PERSON, rel_had_patron); |
229 | 235 |
230 | 236 |
237 /* | |
238 * save misattributions | |
239 */ | |
240 this.entity = this.misidentTable.saveMisidentifications(this.entity); | |
241 | |
231 // WITNESS -> is_exemplar_of -> TEXT | 242 // WITNESS -> is_exemplar_of -> TEXT |
232 this.entity.replaceSourceRelation(this.titleLo.entity, TEXT, is_exemplar_of); | 243 this.entity.replaceSourceRelation(this.titleLo.entity, TEXT, is_exemplar_of); |
233 | 244 |
234 this.entity.removeAllSourceRelationsByName(is_possible_exemplar_of); | 245 this.entity.removeAllSourceRelationsByName(is_possible_exemplar_of); |
235 this.entity.removeAllSourceRelations(rel_has_title_written_as, ALIAS); | 246 this.entity.removeAllSourceRelations(rel_has_title_written_as, ALIAS); |
256 this.printSuccessSavingEntity(); | 267 this.printSuccessSavingEntity(); |
257 | 268 |
258 this.setSelectedSaveAsNew(false); | 269 this.setSelectedSaveAsNew(false); |
259 } catch (Exception e) { | 270 } catch (Exception e) { |
260 logger.error(e.getMessage(), e); | 271 logger.error(e.getMessage(), e); |
261 e.printStackTrace(); | |
262 this.printInternalError(e); | 272 this.printInternalError(e); |
263 } | 273 } |
264 | 274 |
265 saveEnd(); | 275 saveEnd(); |
266 return PAGE_EDITOR; | 276 return PAGE_EDITOR; |
288 | 298 |
289 if(alias == null){ | 299 if(alias == null){ |
290 alias = new Entity(Node.TYPE_ABOX, ALIAS, false); | 300 alias = new Entity(Node.TYPE_ABOX, ALIAS, false); |
291 alias.addAttribute(new Attribute(ALIAS, "text", valueTextWritten)); | 301 alias.addAttribute(new Attribute(ALIAS, "text", valueTextWritten)); |
292 alias = getWrapper().saveEntity(alias, user.getEmail()); | 302 alias = getWrapper().saveEntity(alias, user.getEmail()); |
293 Relation rel = new Relation(alias, this.titleLo.getEntity(), "is_alias_title_of"); | 303 new Relation(alias, this.titleLo.getEntity(), "is_alias_title_of"); |
294 alias = getWrapper().saveEntity(alias, user.getEmail()); | 304 alias = getWrapper().saveEntity(alias, user.getEmail()); |
295 } | 305 } |
296 if(alias.isLightweight()){ | 306 if(alias.isLightweight()){ |
297 alias = getWrapper().getEntityByIdWithContent(alias.getId()); | 307 alias = getWrapper().getEntityByIdWithContent(alias.getId()); |
298 } | 308 } |
317 | 327 |
318 if(alias == null){ | 328 if(alias == null){ |
319 alias = new Entity(Node.TYPE_ABOX, ALIAS, false); | 329 alias = new Entity(Node.TYPE_ABOX, ALIAS, false); |
320 alias.addAttribute(new Attribute(ALIAS, "text", valueAuthorWritten)); | 330 alias.addAttribute(new Attribute(ALIAS, "text", valueAuthorWritten)); |
321 alias = getWrapper().saveEntity(alias, user.getEmail()); | 331 alias = getWrapper().saveEntity(alias, user.getEmail()); |
322 Relation rel = new Relation(alias, this.authorLo.getEntity(), "is_alias_name_of"); | 332 new Relation(alias, this.authorLo.getEntity(), "is_alias_name_of"); |
323 alias = getWrapper().saveEntity(alias, user.getEmail()); | 333 alias = getWrapper().saveEntity(alias, user.getEmail()); |
324 } | 334 } |
325 if(alias.isLightweight()){ | 335 if(alias.isLightweight()){ |
326 alias = getWrapper().getEntityByIdWithContent(alias.getId()); | 336 alias = getWrapper().getEntityByIdWithContent(alias.getId()); |
327 } | 337 } |
451 | 461 |
452 // Loading the relations | 462 // Loading the relations |
453 // TODO loading target's relations | 463 // TODO loading target's relations |
454 for (Relation rel : witness.getSourceRelations()) { | 464 for (Relation rel : witness.getSourceRelations()) { |
455 Entity target = null; | 465 Entity target = null; |
456 if (rel.getOwnValue().equals(is_exemplar_of)) { | 466 String relName = rel.getOwnValue(); |
467 if (relName.equals(is_exemplar_of)) { | |
457 // WITNESS -> is_exemplar_of -> TEXT | 468 // WITNESS -> is_exemplar_of -> TEXT |
458 target = getTargetRelation(rel); | 469 target = getTargetRelation(rel); |
459 titleLo.setEntityAndAttribute(target); | 470 titleLo.setEntityAndAttribute(target); |
460 this.updateTitle(); | 471 this.updateTitle(); |
461 } else if (rel.getOwnValue().equals(is_possible_exemplar_of)) { | 472 } else if (relName.equals(is_possible_exemplar_of)) { |
462 // WITNESS -> is_possible_exemplar_of -> TEXT | 473 // WITNESS -> is_possible_exemplar_of -> TEXT |
463 target = getTargetRelation(rel); | 474 target = getTargetRelation(rel); |
464 possibleExamplerOfList.add(target); | 475 possibleExamplerOfList.add(target); |
465 } else if (rel.getOwnValue().equals(rel_was_studied_by)) { | 476 } else if (relName.equals(rel_was_studied_by)) { |
466 target = getTargetRelation(rel); | 477 target = getTargetRelation(rel); |
467 studiedByList.add(target); | 478 studiedByList.add(target); |
468 } else if (rel.getOwnValue().equals(rel_was_copied_by)) { | 479 } else if (relName.equals(rel_was_copied_by)) { |
469 // WITENSS -> was_copied_by -> PERSON | 480 // WITENSS -> was_copied_by -> PERSON |
470 target = getTargetRelation(rel); | 481 target = getTargetRelation(rel); |
471 copyistLo.setEntityAndAttribute(target); | 482 copyistLo.setEntityAndAttribute(target); |
472 } else if (rel.getOwnValue().equals("was_copied_in")) { | 483 } else if (relName.equals("was_copied_in")) { |
473 // WITENSS -> was_copied_in -> PLACE | 484 // WITENSS -> was_copied_in -> PLACE |
474 target = getTargetRelation(rel); | 485 target = getTargetRelation(rel); |
475 // don't use place if there is an alias | 486 // don't use place if there is an alias |
476 copyPlaceLo.setEntityAndAttributeIfEmpty(target); | 487 copyPlaceLo.setEntityAndAttributeIfEmpty(target); |
477 } else if (rel.getOwnValue().equals("was_copied_in_as")) { | 488 } else if (relName.equals("was_copied_in_as")) { |
478 // WITENSS -> was_copied_in_as -> ALIAS | 489 // WITENSS -> was_copied_in_as -> ALIAS |
479 target = getTargetRelation(rel); | 490 target = getTargetRelation(rel); |
480 copyPlaceLo.setEntityAndAttribute(target); | 491 copyPlaceLo.setEntityAndAttribute(target); |
481 } else if (rel.getOwnValue().equals(rel_had_patron)) { | 492 } else if (relName.equals(rel_had_patron)) { |
482 // WITNESS -> had_patron -> PERSON | 493 // WITNESS -> had_patron -> PERSON |
483 target = getTargetRelation(rel); | 494 target = getTargetRelation(rel); |
484 patronageLo.setEntityAndAttributeName(target, name_translit); | 495 patronageLo.setEntityAndAttributeName(target, name_translit); |
485 } else if (rel.getOwnValue().equals(is_part_of)) { | 496 } else if (relName.equals(is_part_of)) { |
486 // WITNESS -> is_part_of -> CODEX | 497 // WITNESS -> is_part_of -> CODEX |
487 if (rel.getTargetObjectClass().equals(CODEX)) { | 498 if (rel.getTargetObjectClass().equals(CODEX)) { |
488 target = getTargetRelation(rel); | 499 target = getTargetRelation(rel); |
489 this.setCodex(target); | 500 this.setCodex(target); |
490 } | 501 } |
491 } else if (rel.getOwnValue().equals(rel_has_author_written_as)) { | 502 } else if (relName.equals(Misidentification.HAS_MISIDENT)) { |
503 // WITNESS -> has_misidentification -> MISIDENTIFICATION | |
504 target = getTargetRelation(rel); | |
505 this.misidentTable.load(target); | |
506 | |
507 } else if (relName.equals(rel_has_author_written_as)) { | |
492 //TODO this relation is no in the definitions | 508 //TODO this relation is no in the definitions |
493 Entity target2 = getTargetRelation(rel); | 509 Entity target2 = getTargetRelation(rel); |
494 Attribute alias = getTargetAttribute(target2, "alias"); | 510 Attribute alias = getTargetAttribute(target2, "alias"); |
495 this.valueAuthorWritten = (alias != null) ? alias.getValue() : null; | 511 this.valueAuthorWritten = (alias != null) ? alias.getValue() : null; |
496 | 512 |
497 } else if (rel.getOwnValue().equals(rel_has_title_written_as)) { | 513 } else if (relName.equals(rel_has_title_written_as)) { |
498 //TODO this relation is no in the definitions | 514 //TODO this relation is no in the definitions |
499 target = getTargetRelation(rel); | 515 target = getTargetRelation(rel); |
500 //this.textWritten = target; | 516 //this.textWritten = target; |
501 Attribute alias = getTargetAttribute(target, "alias"); | 517 Attribute alias = getTargetAttribute(target, "alias"); |
502 this.valueTextWritten = (alias != null) ? alias.getValue() : null; | 518 this.valueTextWritten = (alias != null) ? alias.getValue() : null; |
1096 } | 1112 } |
1097 | 1113 |
1098 public void setPossibleExamplerOfList(EntityList possibleExamplerOfList) { | 1114 public void setPossibleExamplerOfList(EntityList possibleExamplerOfList) { |
1099 this.possibleExamplerOfList = possibleExamplerOfList; | 1115 this.possibleExamplerOfList = possibleExamplerOfList; |
1100 } | 1116 } |
1117 | |
1118 public MisidentificationTable getMisidentTable() { | |
1119 return misidentTable; | |
1120 } | |
1121 | |
1122 public void setMisidentTable(MisidentificationTable misidentTable) { | |
1123 this.misidentTable = misidentTable; | |
1124 } | |
1101 | 1125 |
1102 } | 1126 } |
1103 | 1127 |