Mercurial > hg > ismi-richfaces
comparison src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentWitnessBean.java @ 111:22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
author | casties |
---|---|
date | Fri, 09 Dec 2016 21:18:27 +0100 |
parents | 2e911857a759 |
children | 59f26a5ef2b3 |
comparison
equal
deleted
inserted
replaced
110:e5d4443a1bc5 | 111:22a18bfc66b0 |
---|---|
15 import org.mpi.openmind.repository.bo.Entity; | 15 import org.mpi.openmind.repository.bo.Entity; |
16 import org.mpi.openmind.repository.bo.Node; | 16 import org.mpi.openmind.repository.bo.Node; |
17 import org.mpi.openmind.repository.bo.Relation; | 17 import org.mpi.openmind.repository.bo.Relation; |
18 import org.mpi.openmind.security.bo.User; | 18 import org.mpi.openmind.security.bo.User; |
19 | 19 |
20 import de.mpiwg.itgroup.ismi.auxObjects.AliasListenerObject; | |
20 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; | 21 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; |
21 import de.mpiwg.itgroup.ismi.auxObjects.lo.WitnessAuthorLO; | 22 import de.mpiwg.itgroup.ismi.auxObjects.lo.WitnessAuthorLO; |
22 import de.mpiwg.itgroup.ismi.auxObjects.lo.WitnessTextLO; | 23 import de.mpiwg.itgroup.ismi.auxObjects.lo.WitnessTextLO; |
23 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; | 24 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; |
24 import de.mpiwg.itgroup.ismi.util.guiComponents.EntityList; | 25 import de.mpiwg.itgroup.ismi.util.guiComponents.EntityList; |
69 | 70 |
70 // WITENSS -> was_copied_by -> PERSON | 71 // WITENSS -> was_copied_by -> PERSON |
71 private ListenerObject copyistLo = new ListenerObject(PERSON, name_translit); | 72 private ListenerObject copyistLo = new ListenerObject(PERSON, name_translit); |
72 | 73 |
73 // WITENSS -> was_copied_at -> PLACE | 74 // WITENSS -> was_copied_at -> PLACE |
74 private ListenerObject copyPlaceLo = new ListenerObject(PLACE, name); | 75 private ListenerObject copyPlaceLo = new AliasListenerObject(PLACE, name, "is_alias_name_of"); |
75 | 76 |
76 // WITNESS -> xx -> PERSON | 77 // WITNESS -> xx -> PERSON |
77 private ListenerObject patronageLo = new ListenerObject(PERSON, name_translit); | 78 private ListenerObject patronageLo = new ListenerObject(PERSON, name_translit); |
78 | 79 |
79 //private List<SelectItem> citiesWithRepositories; | 80 //private List<SelectItem> citiesWithRepositories; |
207 //replaceSourceRelation(this.entity, this.author, PERSON, was_created_by); | 208 //replaceSourceRelation(this.entity, this.author, PERSON, was_created_by); |
208 | 209 |
209 // WITENSS -> was_copied_by -> PERSON | 210 // WITENSS -> was_copied_by -> PERSON |
210 this.entity.replaceSourceRelation(this.copyistLo.entity, PERSON, rel_was_copied_by); | 211 this.entity.replaceSourceRelation(this.copyistLo.entity, PERSON, rel_was_copied_by); |
211 | 212 |
212 //WITENSS -> was_copied_in -> PLACE | 213 // WITNESS -> was_copied_in -> PLACE |
213 this.entity.replaceSourceRelation(this.copyPlaceLo.entity, PLACE, "was_copied_in"); | 214 Entity copyPlace = this.copyPlaceLo.entity; |
215 if (copyPlace != null && copyPlace.getObjectClass().equals(PLACE)) { | |
216 // regular PLACE | |
217 this.entity.replaceSourceRelation(copyPlace, PLACE, "was_copied_in"); | |
218 } else if (copyPlace != null && copyPlace.getObjectClass().equals("ALIAS")) { | |
219 // WITNESS -> was_copied_in_as -> ALIAS | |
220 this.entity.replaceSourceRelation(copyPlace, "ALIAS", "was_copied_in_as"); | |
221 // ALIAS -> is_alias_name_of -> PLACE | |
222 List<Entity> places = getWrapper().getTargetsForSourceRelation(copyPlace, "is_alias_name_of", "PLACE", 1); | |
223 if (! places.isEmpty()) { | |
224 // WITNESS -> was_copied_in -> PLACE | |
225 this.entity.replaceSourceRelation(places.get(0), PLACE, "was_copied_in"); | |
226 } | |
227 } | |
214 | 228 |
215 //REFERENCE -> is_reference_of -> WITNESS | 229 //REFERENCE -> is_reference_of -> WITNESS |
216 //this.entity = this.prepareReferencesToSave(this.entity); | 230 //this.entity = this.prepareReferencesToSave(this.entity); |
217 this.prepareEndNoteRefs2Save(); | 231 this.prepareEndNoteRefs2Save(); |
218 | 232 |
354 | 368 |
355 this.textUnknown = UNKNOWN.equals(titleLo.entity.getOwnValue()); | 369 this.textUnknown = UNKNOWN.equals(titleLo.entity.getOwnValue()); |
356 | 370 |
357 List<Entity> targets = getWrapper().getTargetsForSourceRelation(titleLo.getEntity(), rel_was_created_by, PERSON, 1); | 371 List<Entity> targets = getWrapper().getTargetsForSourceRelation(titleLo.getEntity(), rel_was_created_by, PERSON, 1); |
358 if(targets.size() > 0){ | 372 if(targets.size() > 0){ |
359 this.authorLo.setEntityAndAttribute0(targets.get(0)); | 373 this.authorLo.setEntityAndAttribute(targets.get(0)); |
360 | 374 |
361 }else{ | 375 }else{ |
362 this.authorLo.reset(); | 376 this.authorLo.reset(); |
363 /* rich | 377 /* rich |
364 this.authorLo.setEntityAndAttribute(null, name_translit); | 378 this.authorLo.setEntityAndAttribute(null, name_translit); |
451 // Loading the relations | 465 // Loading the relations |
452 // TODO loading target's relations | 466 // TODO loading target's relations |
453 for (Relation rel : witness.getSourceRelations()) { | 467 for (Relation rel : witness.getSourceRelations()) { |
454 Entity target = null; | 468 Entity target = null; |
455 if (rel.getOwnValue().equals(is_exemplar_of)) { | 469 if (rel.getOwnValue().equals(is_exemplar_of)) { |
456 | |
457 // WITNESS -> is_exemplar_of -> TEXT | 470 // WITNESS -> is_exemplar_of -> TEXT |
458 target = getTargetRelation(rel); | 471 target = getTargetRelation(rel); |
459 titleLo.setEntityAndAttribute0(target); | 472 titleLo.setEntityAndAttribute(target); |
460 this.updateTitle(); | 473 this.updateTitle(); |
461 | |
462 } else if (rel.getOwnValue().equals(is_possible_exemplar_of)) { | 474 } else if (rel.getOwnValue().equals(is_possible_exemplar_of)) { |
463 // WITNESS -> is_possible_exemplar_of -> TEXT | 475 // WITNESS -> is_possible_exemplar_of -> TEXT |
464 target = getTargetRelation(rel); | 476 target = getTargetRelation(rel); |
465 possibleExamplerOfList.add(target); | 477 possibleExamplerOfList.add(target); |
466 } else if (rel.getOwnValue().equals(rel_was_studied_by)) { | 478 } else if (rel.getOwnValue().equals(rel_was_studied_by)) { |
467 target = getTargetRelation(rel); | 479 target = getTargetRelation(rel); |
468 studiedByList.add(target); | 480 studiedByList.add(target); |
469 } else if (rel.getOwnValue().equals(rel_was_copied_by)) { | 481 } else if (rel.getOwnValue().equals(rel_was_copied_by)) { |
470 // WITENSS -> was_copied_by -> PERSON | 482 // WITENSS -> was_copied_by -> PERSON |
471 target = getTargetRelation(rel); | 483 target = getTargetRelation(rel); |
472 copyistLo.setEntityAndAttribute0(target); | 484 copyistLo.setEntityAndAttribute(target); |
473 } else if (rel.getOwnValue().equals("was_copied_in")) { | 485 } else if (rel.getOwnValue().equals("was_copied_in")) { |
474 // WITENSS -> was_copied_in -> PLACE | 486 // WITENSS -> was_copied_in -> PLACE |
475 target = getTargetRelation(rel); | 487 target = getTargetRelation(rel); |
476 copyPlaceLo.setEntityAndAttribute0(target); | 488 // don't use place if there is an alias |
489 if (copyPlaceLo.getEntity().getObjectClass() == null) { | |
490 copyPlaceLo.setEntityAndAttribute(target); | |
491 } | |
492 } else if (rel.getOwnValue().equals("was_copied_in_as")) { | |
493 // WITENSS -> was_copied_in_as -> ALIAS | |
494 target = getTargetRelation(rel); | |
495 copyPlaceLo.setEntityAndAttribute(target); | |
477 } else if (rel.getOwnValue().equals(rel_had_patron)) { | 496 } else if (rel.getOwnValue().equals(rel_had_patron)) { |
478 // WITNESS -> had_patron -> PERSON | 497 // WITNESS -> had_patron -> PERSON |
479 target = getTargetRelation(rel); | 498 target = getTargetRelation(rel); |
480 patronageLo.setEntityAndAttribute(target, name_translit); | 499 patronageLo.setEntityAndAttributeName(target, name_translit); |
481 } else if (rel.getOwnValue().equals(is_part_of)) { | 500 } else if (rel.getOwnValue().equals(is_part_of)) { |
482 // WITNESS -> had_patron -> PERSON | 501 // WITNESS -> is_part_of -> CODEX |
483 if(rel.getTargetObjectClass().equals(CODEX)){ | 502 if (rel.getTargetObjectClass().equals(CODEX)) { |
484 target = getTargetRelation(rel); | 503 target = getTargetRelation(rel); |
485 this.setCodex(target); | 504 this.setCodex(target); |
486 } | 505 } |
487 } else if (rel.getOwnValue().equals(rel_has_author_written_as)) { | 506 } else if (rel.getOwnValue().equals(rel_has_author_written_as)) { |
488 //TODO this relation is no in the definitions | 507 //TODO this relation is no in the definitions |
512 /** | 531 /** |
513 * Loads the given codex without reset of the variables, which could cause problem in CurrentWitness Class | 532 * Loads the given codex without reset of the variables, which could cause problem in CurrentWitness Class |
514 * @param codex | 533 * @param codex |
515 */ | 534 */ |
516 public void setCodex(Entity codex){ | 535 public void setCodex(Entity codex){ |
517 this.getCodexLo().setEntityAndAttribute(codex, "identifier"); | 536 this.getCodexLo().setEntityAndAttributeName(codex, "identifier"); |
518 | 537 |
519 if(this.getCodexLo().entity != null && this.getCodexLo().entity.isPersistent()){ | 538 if(this.getCodexLo().entity != null && this.getCodexLo().entity.isPersistent()){ |
520 | 539 |
521 List<Entity> list = getWrapper().getTargetsForSourceRelation(codex, is_part_of, COLLECTION, 1); | 540 List<Entity> list = getWrapper().getTargetsForSourceRelation(codex, is_part_of, COLLECTION, 1); |
522 if(list.size() > 0){ | 541 if(list.size() > 0){ |
682 | 701 |
683 public void listenerSelectTitle(ActionEvent event){ | 702 public void listenerSelectTitle(ActionEvent event){ |
684 if(this.selectedTitleId != null){ | 703 if(this.selectedTitleId != null){ |
685 Entity title = getWrapper().getEntityById(this.selectedTitleId); | 704 Entity title = getWrapper().getEntityById(this.selectedTitleId); |
686 if(title != null){ | 705 if(title != null){ |
687 this.titleLo.setEntityAndAttribute0(title); | 706 this.titleLo.setEntityAndAttribute(title); |
688 this.updateTitle(); | 707 this.updateTitle(); |
689 setSelectTitleRendered(false); | 708 setSelectTitleRendered(false); |
690 } | 709 } |
691 } | 710 } |
692 } | 711 } |
769 String role = getSelectPersonType(); | 788 String role = getSelectPersonType(); |
770 if(this.selectedPersonId != null){ | 789 if(this.selectedPersonId != null){ |
771 Entity selectedPerson = getWrapper().getEntityByIdWithContent(selectedPersonId); | 790 Entity selectedPerson = getWrapper().getEntityByIdWithContent(selectedPersonId); |
772 if(selectedPerson != null){ | 791 if(selectedPerson != null){ |
773 if (role.equals("Copyist")) { | 792 if (role.equals("Copyist")) { |
774 copyistLo.setEntityAndAttribute0(selectedPerson); | 793 copyistLo.setEntityAndAttribute(selectedPerson); |
775 } else if (role.equals("Patron")) { | 794 } else if (role.equals("Patron")) { |
776 patronageLo.setEntityAndAttribute0(selectedPerson); | 795 patronageLo.setEntityAndAttribute(selectedPerson); |
777 } else if (role.equals("Author")) { | 796 } else if (role.equals("Author")) { |
778 authorLo.setEntityAndAttribute0(selectedPerson); | 797 authorLo.setEntityAndAttribute(selectedPerson); |
779 this.updateAuthor(); | 798 this.updateAuthor(); |
780 } | 799 } |
781 setSelectPersonRendered(false); | 800 setSelectPersonRendered(false); |
782 } | 801 } |
783 } | 802 } |
877 is_part_of, CODEX, -1); | 896 is_part_of, CODEX, -1); |
878 for(Entity possibleCodex : codexListOfCollection){ | 897 for(Entity possibleCodex : codexListOfCollection){ |
879 //juc Attribute att = getWrapper().getAttributeByName(possibleCodex, "identifier"); | 898 //juc Attribute att = getWrapper().getAttributeByName(possibleCodex, "identifier"); |
880 Attribute att = getWrapper().getAttributeByName(possibleCodex.getId(), "identifier"); | 899 Attribute att = getWrapper().getAttributeByName(possibleCodex.getId(), "identifier"); |
881 if(att != null && identifier.equals(att.getValue())){ | 900 if(att != null && identifier.equals(att.getValue())){ |
882 getCodexLo().setEntityAndAttribute(possibleCodex, "identifier"); | 901 getCodexLo().setEntityAndAttributeName(possibleCodex, "identifier"); |
883 return true; | 902 return true; |
884 } | 903 } |
885 } | 904 } |
886 } | 905 } |
887 } | 906 } |
890 Entity newCodex = new Entity(Node.TYPE_ABOX, CODEX, false); | 909 Entity newCodex = new Entity(Node.TYPE_ABOX, CODEX, false); |
891 newCodex.addAttribute(new Attribute("identifier", TEXT, identifier)); | 910 newCodex.addAttribute(new Attribute("identifier", TEXT, identifier)); |
892 getWrapper().saveEntity(newCodex, user); | 911 getWrapper().saveEntity(newCodex, user); |
893 Relation isPartOf = new Relation(newCodex, getCollectionLo().getEntity(), is_part_of); | 912 Relation isPartOf = new Relation(newCodex, getCollectionLo().getEntity(), is_part_of); |
894 getWrapper().saveRelationAsNode(isPartOf, user); | 913 getWrapper().saveRelationAsNode(isPartOf, user); |
895 getCodexLo().setEntityAndAttribute(newCodex, "identifier"); | 914 getCodexLo().setEntityAndAttributeName(newCodex, "identifier"); |
896 | 915 |
897 } catch (Exception e) { | 916 } catch (Exception e) { |
898 logger.error(e.getMessage(), e); | 917 logger.error(e.getMessage(), e); |
899 return false; | 918 return false; |
900 } | 919 } |