Mercurial > hg > ismi-richfaces
diff src/main/java/de/mpiwg/itgroup/ismi/entry/beans/AbstractISMIBean.java @ 112:59f26a5ef2b3
AliasListenerObject adds aliases to ListenerObject. Change all forms to enable ALIAS for (historical) PLACE fields. Remove REPOSITORY from event forms.
author | casties |
---|---|
date | Tue, 13 Dec 2016 19:04:45 +0100 |
parents | 22a18bfc66b0 |
children | 8e3f1f81acfb 363ff8844b23 |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/AbstractISMIBean.java Fri Dec 09 21:18:27 2016 +0100 +++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/AbstractISMIBean.java Tue Dec 13 19:04:45 2016 +0100 @@ -22,6 +22,7 @@ import org.mpi.openmind.security.SecurityService; import org.mpi.openmind.security.bo.User; +import de.mpiwg.itgroup.ismi.auxObjects.AliasListenerObject; import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; import de.mpiwg.itgroup.ismi.entry.dataBeans.SimpleSearchCache; import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; @@ -62,6 +63,7 @@ public static String has_subject = "has_subject"; public static String misattributed_to = "misattributed_to"; public static String lived_in = "lived_in"; + public static final String lived_in_as = "lived_in_as"; public static String owned_by = "owned_by"; public static String has_role = "has_role"; public static String was_student_of = "was_student_of"; @@ -290,7 +292,7 @@ * * @throws Exception */ - protected void prepareEndNoteRefs2Save() throws Exception{ + protected void prepareEndNoteRefs2Save() throws Exception { //REFERENCE -> is_reference_of -> WITNESS this.entity.removeAllTargetRelationsByName(rel_is_reference_of); for (SelectableObject<Reference> so : this.endNoteRefTable.list) { @@ -1067,4 +1069,35 @@ public void setDefObjectClass(String defObjectClass) { this.defObjectClass = defObjectClass; } + + /** + * Replace the given source relations on the given entity by the contents of the AliasListenerObject (type entClass) + * using the given relName and aliasRelName. + * + * ent - relName -> targetClass, + * ent - aliasRelName -> ALIAS + * + * @param ent + * @param lo + * @param targetClass + * @param relName + * @param aliasRelName + */ + protected void replaceAliasSourceRelation(Entity ent, AliasListenerObject lo, String targetClass, String relName, String aliasRelName) { + Entity target = lo.entity; + if (target != null && target.getObjectClass().equals(targetClass)) { + // regular target entity e.g. PLACE + ent.replaceSourceRelation(target, targetClass, relName); + ent.removeAllSourceRelationsByName(aliasRelName); + } else if (target != null && target.getObjectClass().equals(ALIAS)) { + // e.g. WITNESS -> was_created_in_as -> ALIAS + ent.replaceSourceRelation(target, ALIAS, aliasRelName); + // ALIAS -> is_alias_name_of -> PLACE + List<Entity> places = getWrapper().getTargetsForSourceRelation(target, is_alias_name_of, targetClass, 1); + if (! places.isEmpty()) { + // e.g. WITNESS -> was_created_in -> PLACE + ent.replaceSourceRelation(places.get(0), targetClass, relName); + } + } + } }