# HG changeset patch # User casties # Date 1481652285 -3600 # Node ID 59f26a5ef2b31293ce97c23b5c2a923216ed212b # Parent 22a18bfc66b08c04f0712e69d3ad53889a37b319 AliasListenerObject adds aliases to ListenerObject. Change all forms to enable ALIAS for (historical) PLACE fields. Remove REPOSITORY from event forms. diff -r 22a18bfc66b0 -r 59f26a5ef2b3 src/main/java/de/mpiwg/itgroup/ismi/auxObjects/AliasListenerObject.java --- a/src/main/java/de/mpiwg/itgroup/ismi/auxObjects/AliasListenerObject.java Fri Dec 09 21:18:27 2016 +0100 +++ b/src/main/java/de/mpiwg/itgroup/ismi/auxObjects/AliasListenerObject.java Tue Dec 13 19:04:45 2016 +0100 @@ -10,7 +10,7 @@ import org.mpi.openmind.repository.bo.Entity; /** - * ListenerObject that searches in Entity Attributes and ALIASes with a given Relation. + * ListenerObject that searches in Entity Attributes and ALIASes connected by a given Relation. * * @author casties * @@ -22,6 +22,10 @@ public String aliasRelName; /** + * ListenerObject that searches in Entity Attributes and also in ALIASes connected by a given Relation. + * + * Uses relation ALIAS - aliasRelName -> ENTITY (usually "is_alias_name_of"). + * * @param classObj * @param attName * @param aliasRelName @@ -31,6 +35,18 @@ this.aliasRelName = aliasRelName; } + /** + * Sets the current entity and displays the selected attribute if it is not already set. + * This is meant not to overwrite an entity already set by an alias. + * + * @see de.mpiwg.itgroup.ismi.auxObjects.ListenerObject#setEntityAndAttribute(org.mpi.openmind.repository.bo.Entity) + */ + public void setEntityAndAttributeIfEmpty(Entity ent) { + if ((this.entity == null) || (this.entity.getObjectClass() == null)) { + super.setEntityAndAttribute(ent); + } + } + /* (non-Javadoc) * @see de.mpiwg.itgroup.ismi.auxObjects.AbstractListenerObject#updateSuggestedItems(java.lang.String, java.lang.String, java.lang.String) */ diff -r 22a18bfc66b0 -r 59f26a5ef2b3 src/main/java/de/mpiwg/itgroup/ismi/auxObjects/ListenerObject.java --- a/src/main/java/de/mpiwg/itgroup/ismi/auxObjects/ListenerObject.java Fri Dec 09 21:18:27 2016 +0100 +++ b/src/main/java/de/mpiwg/itgroup/ismi/auxObjects/ListenerObject.java Tue Dec 13 19:04:45 2016 +0100 @@ -146,6 +146,11 @@ return statusImage.getStatus(); } + /** + * Set the currently selected entity and display the attribute this.attName. + * + * @param ent + */ public void setEntityAndAttribute(Entity ent){ this.setEntity(ent); if(ent != null && ent.isPersistent()){ @@ -158,6 +163,11 @@ } } + /** + * Set the currently selected entity and display the given attribute. + * + * @param ent + */ public void setEntityAndAttributeName(Entity ent, String attName){ this.attName = attName; this.setEntityAndAttribute(ent); diff -r 22a18bfc66b0 -r 59f26a5ef2b3 src/main/java/de/mpiwg/itgroup/ismi/entry/beans/AbstractISMIBean.java --- 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 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 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); + } + } + } } diff -r 22a18bfc66b0 -r 59f26a5ef2b3 src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentPersonBean.java --- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentPersonBean.java Fri Dec 09 21:18:27 2016 +0100 +++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentPersonBean.java Tue Dec 13 19:04:45 2016 +0100 @@ -2,6 +2,7 @@ import java.io.Serializable; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.faces.convert.Converter; @@ -17,17 +18,19 @@ import org.mpi.openmind.repository.utils.RomanizationLoC; import org.mpi.openmind.repository.utils.TransliterationUtil; +import de.mpiwg.itgroup.ismi.auxObjects.AliasListenerObject; /* rich import com.icesoft.faces.async.render.SessionRenderer; import com.icesoft.faces.component.ext.HtmlCommandButton; import com.icesoft.faces.component.ext.HtmlInputHidden; */ import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; +import de.mpiwg.itgroup.ismi.util.guiComponents.AliasEntityList; import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; import de.mpiwg.itgroup.ismi.util.guiComponents.EntityList; public class CurrentPersonBean extends AbstractISMIBean implements Serializable{ - private static final long serialVersionUID = -3366510497089165294L; + private static final long serialVersionUID = -3366510497089165294L; private static Logger logger = Logger.getLogger(CurrentPersonBean.class); @@ -39,8 +42,8 @@ public static String birth_date = "birth_date"; public static String death_date = "death_date"; - private ListenerObject birthPlaceLo = new ListenerObject(PLACE, name); - private ListenerObject deathPlaceLo = new ListenerObject(PLACE, name); + private AliasListenerObject birthPlaceLo = new AliasListenerObject(PLACE, name, "is_alias_name_of"); + private AliasListenerObject deathPlaceLo = new AliasListenerObject(PLACE, name, "is_alias_name_of"); private String valueShortName; private Entity shortNameAlias; // is now an alias of type "prime" @@ -63,7 +66,7 @@ this.newAlias = new String(); - this.livedInPlaces = new EntityList(PLACE, name, true); + this.livedInPlaces = new AliasEntityList(PLACE, name, "is_alias_name_of", true); this.aliasList = new EntityList(ALIAS, "alias", getWrapper(), getUserName()); this.roleList = new EntityList(ROLE, "name", getWrapper(), getUserName()); this.studentOfList = new EntityList(PERSON, "name_translit", "Student of"); @@ -181,19 +184,25 @@ this.loadAttributes(this.entity); for (Relation rel : this.entity.getSourceRelations()) { + String relName = rel.getOwnValue(); Entity target = getWrapper().getEntityById(rel.getTargetId()); - if (rel.getOwnValue().equals("was_born_in")) { - this.birthPlaceLo.setEntityAndAttribute(target); - //this.personWasBornInName = (target == null) ? "" : target.getOwnValue(); - } else if (rel.getOwnValue().equals(lived_in)) { + if (relName.equals("was_born_in")) { + this.birthPlaceLo.setEntityAndAttributeIfEmpty(target); + } else if (relName.equals("was_born_in_as")) { + this.birthPlaceLo.setEntityAndAttribute(target); + } else if (relName.equals("died_in")) { + this.deathPlaceLo.setEntityAndAttributeIfEmpty(target); + } else if (relName.equals("died_in_as")) { + this.deathPlaceLo.setEntityAndAttribute(target); + } else if (relName.equals(lived_in)) { this.livedInPlaces.add(target, rel.getAttributeByName("date")); - } else if (rel.getOwnValue().equals(was_student_of)) { + } else if (relName.equals(lived_in_as)) { + this.livedInPlaces.add(target, rel.getAttributeByName("date")); + } else if (relName.equals(was_student_of)) { this.studentOfList.add(target); - } else if (rel.getOwnValue().equals(has_role)) { + } else if (relName.equals(has_role)) { this.roleList.add(target); - } else if (rel.getOwnValue().equals("died_in")) { - this.deathPlaceLo.setEntityAndAttribute(target); - } else if (rel.getOwnValue().equals("has_floruit_date")) { + } else if (relName.equals("has_floruit_date")) { Attribute calAtt = getWrapper().getAttributeByName(target.getId(), "date"); this.floruitList.add(target, calAtt); } @@ -241,13 +250,15 @@ getAttributes().put(birth_date, this.calBirthDate.toJSONString()); getAttributes().put(death_date, this.calDeathDate.toJSONString()); - this.entity = updateEntityAttributes(this.entity); - this.entity.replaceSourceRelation(birthPlaceLo.entity, PLACE, "was_born_in"); - this.entity.replaceSourceRelation(deathPlaceLo.entity, PLACE, "died_in"); + // PERSON -> was_born_in -> PLACE + replaceAliasSourceRelation(this.entity, birthPlaceLo, PLACE, "was_born_in", "was_born_in_as"); + + // PERSON -> was_died_in -> PLACE + replaceAliasSourceRelation(this.entity, deathPlaceLo, PLACE, "died_in", "died_in_as"); - //ALIAS -> is_prime_alias_name_of -> PERSON + // ALIAS -> is_prime_alias_name_of -> PERSON this.entity.removeAllTargetRelationsByName(is_prime_alias_name_of); if (shortNameAlias != null) { shortNameAlias.setObjectClass(ALIAS); @@ -255,23 +266,43 @@ new Relation(shortNameAlias, this.entity, is_alias_name_of); } - //ALIAS -> is_alias_name_of -> PERSON + // ALIAS -> is_alias_name_of -> PERSON this.entity.removeAllTargetRelationsByName(is_alias_name_of); for(Entity alias : this.aliasList.getEntities()){ Entity alias0 = getWrapper().getEntityByIdWithContent(alias.getId()); new Relation(alias0, this.entity, is_alias_name_of); } - // PERSON -> lived_in manyToMany -> PLACE + // PERSON -> lived_in -> PLACE (manyToMany) this.entity.removeAllSourceRelationsByName(lived_in); - for(Entity place : this.livedInPlaces.getEntities()){ - //loadRelation(this.person, place, PLACE, lived_in); - Entity place0 = getWrapper().getEntityByIdWithContent(place.getId()); - Relation livedIn = new Relation(this.entity, place0, lived_in); - Calendar cal = livedInPlaces.getCalendar(place.getId()); - if(cal != null){ - livedIn.addAttribute(new Attribute("date", "date", cal.toJSONString())); - } + this.entity.removeAllSourceRelationsByName(lived_in_as); + for(Entity place : this.livedInPlaces.getEntities()) { + Entity placeEnt = getWrapper().getEntityByIdWithContent(place.getId()); + if (placeEnt.getObjectClass().equals(PLACE)) { + // PERSON -> lived_in -> PLACE + Relation livedIn = new Relation(this.entity, placeEnt, lived_in); + Calendar cal = livedInPlaces.getCalendar(place.getId()); + if(cal != null){ + livedIn.addAttribute(new Attribute("date", "date", cal.toJSONString())); + } + } else if (placeEnt.getObjectClass().equals(ALIAS)) { + // PERSON -> lived_in_as -> ALIAS + Relation livedInAs = new Relation(this.entity, placeEnt, lived_in_as); + Calendar cal = livedInPlaces.getCalendar(place.getId()); + if (cal != null) { + livedInAs.addAttribute(new Attribute("date", "date", cal.toJSONString())); + } + // ALIAS -> is_alias_name_of -> PLACE + List places = getWrapper().getTargetsForSourceRelation(placeEnt, is_alias_name_of, PLACE, 1); + if (! places.isEmpty()) { + // PERSON -> lived_in -> PLACE + Entity realPlace = places.get(0); + Relation livedIn = new Relation(this.entity, realPlace, lived_in); + if (cal != null) { + livedIn.addAttribute(new Attribute("date", "date", cal.toJSONString())); + } + } + } } // Person -> has_floruit_date -> FLORUIT DATE @@ -399,7 +430,7 @@ return ""; } - public void setBirthPlaceLo(ListenerObject birthPlaceLo) { + public void setBirthPlaceLo(AliasListenerObject birthPlaceLo) { this.birthPlaceLo = birthPlaceLo; } @@ -411,7 +442,7 @@ return deathPlaceLo; } - public void setDeathPlaceLo(ListenerObject deathPlaceLo) { + public void setDeathPlaceLo(AliasListenerObject deathPlaceLo) { this.deathPlaceLo = deathPlaceLo; } diff -r 22a18bfc66b0 -r 59f26a5ef2b3 src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentTextBean.java --- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentTextBean.java Fri Dec 09 21:18:27 2016 +0100 +++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentTextBean.java Tue Dec 13 19:04:45 2016 +0100 @@ -22,6 +22,7 @@ import org.mpi.openmind.repository.utils.TransliterationUtil; 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.util.guiComponents.Calendar; import de.mpiwg.itgroup.ismi.util.guiComponents.Misattribution; @@ -44,7 +45,7 @@ private ListenerObject authorLo = new ListenerObject(PERSON, "name_translit"); //private String authorInfo; - private ListenerObject placeLo = new ListenerObject(PLACE, "name"); + private AliasListenerObject placeLo = new AliasListenerObject(PLACE, "name", is_alias_name_of); private ListenerObject dedicatedPersonLo = new ListenerObject(PERSON, "name_translit"); @@ -552,7 +553,7 @@ this.entity.replaceSourceRelation(dedicatedPersonLo.entity, PERSON, "was_dedicated_to"); - this.entity.replaceSourceRelation(placeLo.entity, PLACE, "was_created_in"); + replaceAliasSourceRelation(this.entity, this.placeLo, PLACE, "was_created_in", "was_created_in_as"); this.entity.removeAllSourceRelations(has_subject, SUBJECT); if (getIdSubject() != null) { @@ -649,7 +650,7 @@ return PAGE_EDITOR; } - public EntityList getIncipitAliasList() { + public EntityList getIncipitAliasList() { return incipitAliasList; } @@ -806,7 +807,7 @@ return placeLo; } - public void setPlaceLo(ListenerObject placeLo) { + public void setPlaceLo(AliasListenerObject placeLo) { this.placeLo = placeLo; } diff -r 22a18bfc66b0 -r 59f26a5ef2b3 src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentWitnessBean.java --- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentWitnessBean.java Fri Dec 09 21:18:27 2016 +0100 +++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentWitnessBean.java Tue Dec 13 19:04:45 2016 +0100 @@ -72,7 +72,7 @@ private ListenerObject copyistLo = new ListenerObject(PERSON, name_translit); // WITENSS -> was_copied_at -> PLACE - private ListenerObject copyPlaceLo = new AliasListenerObject(PLACE, name, "is_alias_name_of"); + private AliasListenerObject copyPlaceLo = new AliasListenerObject(PLACE, name, "is_alias_name_of"); // WITNESS -> xx -> PERSON private ListenerObject patronageLo = new ListenerObject(PERSON, name_translit); @@ -211,20 +211,7 @@ this.entity.replaceSourceRelation(this.copyistLo.entity, PERSON, rel_was_copied_by); // WITNESS -> was_copied_in -> PLACE - Entity copyPlace = this.copyPlaceLo.entity; - if (copyPlace != null && copyPlace.getObjectClass().equals(PLACE)) { - // regular PLACE - this.entity.replaceSourceRelation(copyPlace, PLACE, "was_copied_in"); - } else if (copyPlace != null && copyPlace.getObjectClass().equals("ALIAS")) { - // WITNESS -> was_copied_in_as -> ALIAS - this.entity.replaceSourceRelation(copyPlace, "ALIAS", "was_copied_in_as"); - // ALIAS -> is_alias_name_of -> PLACE - List places = getWrapper().getTargetsForSourceRelation(copyPlace, "is_alias_name_of", "PLACE", 1); - if (! places.isEmpty()) { - // WITNESS -> was_copied_in -> PLACE - this.entity.replaceSourceRelation(places.get(0), PLACE, "was_copied_in"); - } - } + replaceAliasSourceRelation(this.entity, this.copyPlaceLo, PLACE, "was_copied_in", "was_copied_in_as"); //REFERENCE -> is_reference_of -> WITNESS //this.entity = this.prepareReferencesToSave(this.entity); @@ -234,7 +221,7 @@ this.entity.removeAllSourceRelationsByName(rel_was_studied_by); for(Entity target : this.studiedByList.getEntities()){ Entity target0 = getWrapper().getEntityByIdWithContent(target.getId()); - Relation wasStudiedBy = new Relation(this.entity, target0, rel_was_studied_by); + new Relation(this.entity, target0, rel_was_studied_by); } // WITNESS -> had_patron -> PERSON @@ -251,7 +238,7 @@ if(textUnknown){ for(Entity target : this.possibleExamplerOfList.getEntities()){ Entity target0 = getWrapper().getEntityByIdWithContent(target.getId()); - Relation tmp = new Relation(this.entity, target0, is_possible_exemplar_of); + new Relation(this.entity, target0, is_possible_exemplar_of); } }else{ this.saveIndirectedAliases(); @@ -486,9 +473,7 @@ // WITENSS -> was_copied_in -> PLACE target = getTargetRelation(rel); // don't use place if there is an alias - if (copyPlaceLo.getEntity().getObjectClass() == null) { - copyPlaceLo.setEntityAndAttribute(target); - } + copyPlaceLo.setEntityAndAttributeIfEmpty(target); } else if (rel.getOwnValue().equals("was_copied_in_as")) { // WITENSS -> was_copied_in_as -> ALIAS target = getTargetRelation(rel); @@ -1008,7 +993,7 @@ return copyPlaceLo; } - public void setCopyPlaceLo(ListenerObject copyPlaceLo) { + public void setCopyPlaceLo(AliasListenerObject copyPlaceLo) { this.copyPlaceLo = copyPlaceLo; } diff -r 22a18bfc66b0 -r 59f26a5ef2b3 src/main/java/de/mpiwg/itgroup/ismi/event/beans/AbstractEvent.java --- a/src/main/java/de/mpiwg/itgroup/ismi/event/beans/AbstractEvent.java Fri Dec 09 21:18:27 2016 +0100 +++ b/src/main/java/de/mpiwg/itgroup/ismi/event/beans/AbstractEvent.java Tue Dec 13 19:04:45 2016 +0100 @@ -11,6 +11,7 @@ import org.apache.log4j.Logger; import org.mpi.openmind.repository.bo.Entity; +import de.mpiwg.itgroup.ismi.auxObjects.AliasListenerObject; import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; import de.mpiwg.itgroup.ismi.auxObjects.lo.EventTextLO; import de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean; @@ -29,44 +30,57 @@ public static String was_studied_by = "was_studied_by"; public static String was_studied_in = "was_studied_in"; + public static String was_studied_in_as = "was_studied_in_as"; public static String is_a_study_of = "is_a_study_of"; public static String was_advised_by = "was_advised_by"; public static String was_copied_for = "was_copied_for"; public static String has_person_copying_text = "has_person_copying_text"; - public static String was_copied_in = "was_copied_in"; + public static String was_copied_in = "was_copied_in"; + public static String was_copied_in_as = "was_copied_in_as"; public static String is_a_copy_of = "is_a_copy_of"; public static String is_a_transfer_of = "is_a_transfer_of"; public static String was_transferred_from = "was_transferred_from"; public static String was_transferred_to = "was_transferred_to"; public static String has_original_location = "has_original_location"; - public static String has_new_location = "has_new_location"; + public static String has_original_location_as = "has_original_location_as"; + public static String has_new_location = "has_new_location"; + public static String has_new_location_as = "has_new_location_as"; public static String was_transferred_in = "was_transferred_in"; + public static String was_transferred_in_as = "was_transferred_in_as"; - protected EventTextLO textLo = new EventTextLO(TEXT, full_title_translit, this); + protected EventTextLO textLo; protected Entity witness; protected Long witnessId; protected List witnessList; protected Calendar date; - protected ListenerObject placeLo = new ListenerObject(PLACE, name); + protected AliasListenerObject placeLo; + protected Entity event; + public AbstractEvent(Entity event){ this.setEvent(event); } - protected Entity event; - /* - public void listenerChangeText(ValueChangeEvent event) { - this.text = changeListener(event, text, TEXT, full_title_translit); - this.witness = null; - if(text.entity != null && text.entity.isPersistent()){ - refreshWitnesses(text.entity); - }else{ - this.witnessList = new ArrayList(); - } - }*/ + /* (non-Javadoc) + * @see de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean#reset() + */ + @Override + public void reset() { + super.reset(); + if (textLo != null) { + textLo.reset(); + } else { + textLo = new EventTextLO(TEXT, full_title_translit, this); + } + if (placeLo != null) { + placeLo.reset(); + } else { + placeLo = new AliasListenerObject(PLACE, name, is_alias_name_of); + } + } - public void refreshWitnesses(Entity text){ + public void refreshWitnesses(Entity text){ this.witnessList = new ArrayList(); List list = getWrapper().getSourcesForTargetRelation(text, is_exemplar_of, WITNESS, -1); System.out.println("Found " + list.size() + " witnesses"); @@ -169,7 +183,7 @@ return placeLo; } - public void setPlaceLo(ListenerObject placeLo) { + public void setPlaceLo(AliasListenerObject placeLo) { this.placeLo = placeLo; } diff -r 22a18bfc66b0 -r 59f26a5ef2b3 src/main/java/de/mpiwg/itgroup/ismi/event/beans/CopyEvent.java --- a/src/main/java/de/mpiwg/itgroup/ismi/event/beans/CopyEvent.java Fri Dec 09 21:18:27 2016 +0100 +++ b/src/main/java/de/mpiwg/itgroup/ismi/event/beans/CopyEvent.java Tue Dec 13 19:04:45 2016 +0100 @@ -4,13 +4,13 @@ import java.util.ArrayList; import javax.faces.event.ActionEvent; -import javax.faces.event.ValueChangeEvent; import javax.faces.model.SelectItem; import org.mpi.openmind.repository.bo.Entity; import org.mpi.openmind.repository.bo.Node; import org.mpi.openmind.repository.bo.Relation; +import de.mpiwg.itgroup.ismi.auxObjects.AliasListenerObject; import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; import de.mpiwg.itgroup.ismi.auxObjects.lo.EventTextLO; import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; @@ -24,9 +24,8 @@ public static String OC = "COPY_EVENT"; - private ListenerObject personCopiedForLo = new ListenerObject(PERSON, name_translit); - private ListenerObject personCopyingTextLo = new ListenerObject(PERSON, name_translit); - private ListenerObject repositoryLo = new ListenerObject(REPOSITORY, name); + private ListenerObject personCopiedForLo; + private ListenerObject personCopyingTextLo; private Calendar date; @@ -52,23 +51,21 @@ //EVENT has_person_copying_text PERSON target = getTargetRelation(rel); personCopyingTextLo.setEntityAndAttribute(target); - } else if (rel.getOwnValue().equals(was_copied_in)) { + // EVENT was_copied_in PLACE target = getTargetRelation(rel); - if(target.getObjectClass().equals(PLACE)){ - //EVENT was_copied_in PLACE - placeLo.setEntityAndAttribute(target); - }else if(target.getObjectClass().equals(REPOSITORY)){ - //EVENT was_copied_in REPOSITORY - repositoryLo.setEntityAndAttribute(target); - } + placeLo.setEntityAndAttributeIfEmpty(target); + } else if (rel.getOwnValue().equals(was_copied_in_as)) { + // EVENT was_copied_in_as ALIAS + target = getTargetRelation(rel); + placeLo.setEntityAndAttribute(target); } else if (rel.getOwnValue().equals(is_a_copy_of)) { - //EVENT is_a_copy_of WITNESS - //WITNESS is_exemplar_of TEXT + // EVENT is_a_copy_of WITNESS this.witness = getTargetRelation(rel); if(witness != null && witness.isPersistent()){ witnessId = witness.getId(); - this.textLo.setEntityAndAttribute( getTextOfWitness(witness)); + // WITNESS is_exemplar_of TEXT + this.textLo.setEntityAndAttribute(getTextOfWitness(witness)); refreshWitnesses(textLo.entity); } } @@ -78,45 +75,36 @@ @Override public void reset(){ - super.reset(); - this.defObjectClass = OC; - - if(textLo != null){ - textLo.reset(); - }else{ - textLo = new EventTextLO(TEXT, full_title_translit, this); - } - - if(personCopiedForLo != null){ - personCopiedForLo.reset(); - }else{ - personCopiedForLo = new ListenerObject(PERSON, name_translit); - } - - if(personCopyingTextLo != null){ - personCopyingTextLo.reset(); - }else{ - personCopyingTextLo = new ListenerObject(PERSON, name_translit); - } - - if(placeLo != null){ - placeLo.reset(); - }else{ - placeLo = new ListenerObject(PLACE, name); - } - - - if(repositoryLo != null){ - repositoryLo.reset(); - }else{ - repositoryLo = new ListenerObject(REPOSITORY, name); - } - + super.reset(); + this.defObjectClass = OC; + + if (textLo != null) { + textLo.reset(); + } else { + textLo = new EventTextLO(TEXT, full_title_translit, this); + } + + if (personCopiedForLo != null) { + personCopiedForLo.reset(); + } else { + personCopiedForLo = new ListenerObject(PERSON, name_translit); + } - - this.date = new Calendar(); - this.witnessList = new ArrayList(); - } + if (personCopyingTextLo != null) { + personCopyingTextLo.reset(); + } else { + personCopyingTextLo = new ListenerObject(PERSON, name_translit); + } + + if (placeLo != null) { + placeLo.reset(); + } else { + placeLo = new AliasListenerObject(PLACE, name, is_alias_name_of); + } + + this.date = new Calendar(); + this.witnessList = new ArrayList(); + } /* public void listenerChangePersonCopyingText(ValueChangeEvent event) { @@ -158,11 +146,8 @@ // EVENT -> has_person_copying_text -> PERSON event.replaceSourceRelation(personCopyingTextLo.entity, PERSON, has_person_copying_text); - // EVENT -> was_copied_in -> REPOSITORY - event.replaceSourceRelation(repositoryLo.entity, REPOSITORY, was_copied_in); - // EVENT -> was_copied_in -> PLACE - event.replaceSourceRelation(placeLo.entity, PLACE, was_copied_in); + replaceAliasSourceRelation(event, placeLo, PLACE, was_copied_in, was_copied_in_as); // EVENT -> is_a_copy_of -> WITNESS if(witness.isLightweight()){ @@ -185,7 +170,6 @@ public boolean checkConsistency(){ if(this.witness == null || this.textLo.entity == null || - this.repositoryLo.entity == null || this.personCopiedForLo.entity == null || this.personCopyingTextLo.entity == null){ return false; @@ -217,14 +201,6 @@ this.personCopyingTextLo = personCopyingTextLo; } - public ListenerObject getRepositoryLo() { - return repositoryLo; - } - - public void setRepositoryLo(ListenerObject repositoryLo) { - this.repositoryLo = repositoryLo; - } - public Calendar getDate() { return date; } diff -r 22a18bfc66b0 -r 59f26a5ef2b3 src/main/java/de/mpiwg/itgroup/ismi/event/beans/StudyEvent.java --- a/src/main/java/de/mpiwg/itgroup/ismi/event/beans/StudyEvent.java Fri Dec 09 21:18:27 2016 +0100 +++ b/src/main/java/de/mpiwg/itgroup/ismi/event/beans/StudyEvent.java Tue Dec 13 19:04:45 2016 +0100 @@ -5,7 +5,6 @@ import java.util.List; import javax.faces.event.ActionEvent; -import javax.faces.event.ValueChangeEvent; import javax.faces.model.SelectItem; import org.mpi.openmind.repository.bo.Attribute; @@ -13,6 +12,7 @@ import org.mpi.openmind.repository.bo.Node; import org.mpi.openmind.repository.bo.Relation; +import de.mpiwg.itgroup.ismi.auxObjects.AliasListenerObject; import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; import de.mpiwg.itgroup.ismi.auxObjects.lo.EventTextLO; import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; @@ -26,36 +26,35 @@ public static String OC = "STUDY_EVENT"; - private ListenerObject personLo = new ListenerObject(PERSON, name_translit); - private ListenerObject advisorLo = new ListenerObject(PERSON, name_translit); - private ListenerObject repositoryLo = new ListenerObject(REPOSITORY, name); + private ListenerObject personLo; + private ListenerObject advisorLo; private List suggestedEngagementOptions = new ArrayList(); - public StudyEvent(){ - super(new Entity(Node.TYPE_ABOX, OC, false)); - refreshEngagementOptions(); - } - - public StudyEvent(Entity event){ - super(event); - refreshEngagementOptions(); - } - - public void listenerRefreshEngagementOptions(ActionEvent event){ - this.refreshEngagementOptions(); - } - - private void refreshEngagementOptions(){ - this.suggestedEngagementOptions = new ArrayList(); - suggestedEngagementOptions.add(new SelectItem(null, "--choose--")); - Attribute binding = getWrapper().getDefAttributeByOwnValue(OC, "options_for_engagement"); - if(binding != null){ - for(String s : binding.getPossibleValuesList()){ - this.suggestedEngagementOptions.add(new SelectItem(s)); - } - } - } + public StudyEvent() { + super(new Entity(Node.TYPE_ABOX, OC, false)); + refreshEngagementOptions(); + } + + public StudyEvent(Entity event) { + super(event); + refreshEngagementOptions(); + } + + public void listenerRefreshEngagementOptions(ActionEvent event) { + this.refreshEngagementOptions(); + } + + private void refreshEngagementOptions() { + this.suggestedEngagementOptions = new ArrayList(); + suggestedEngagementOptions.add(new SelectItem(null, "--choose--")); + Attribute binding = getWrapper().getDefAttributeByOwnValue(OC, "options_for_engagement"); + if (binding != null) { + for (String s : binding.getPossibleValuesList()) { + this.suggestedEngagementOptions.add(new SelectItem(s)); + } + } + } @Override public void setEvent(Entity ev){ @@ -70,34 +69,29 @@ this.date = updateCalendar(this.event.getAttributeByName("date")); for (Relation rel : event.getSourceRelations()) { - Entity target = null; - if (rel.getOwnValue().equals(was_studied_by)) { + Entity target = getTargetRelation(rel); + String relName = rel.getOwnValue(); + if (relName.equals(was_studied_by)) { //EVENT was_studied_by PERSON - target = getTargetRelation(rel); personLo.setEntityAndAttribute(target); - }else if (rel.getOwnValue().equals(was_advised_by)) { + } else if (relName.equals(was_advised_by)) { //EVENT was_advised_by PERSON - target = getTargetRelation(rel); advisorLo.setEntityAndAttribute(target); - - } else if (rel.getOwnValue().equals(was_studied_in)) { - target = getTargetRelation(rel); - if(target.getObjectClass().equals(PLACE)){ - //EVENT was_studied_in PLACE - placeLo.setEntityAndAttribute(target); - }else if(target.getObjectClass().equals(REPOSITORY)){ - //EVENT was_studied_in REPOSITORY - repositoryLo.setEntityAndAttribute(target); - } - } else if (rel.getOwnValue().equals(is_a_study_of)) { + } else if (relName.equals(was_studied_in)) { + //EVENT was_studied_in PLACE + placeLo.setEntityAndAttributeIfEmpty(target); + } else if (relName.equals(was_studied_in_as)) { + //EVENT was_studied_in_as ALIAS + placeLo.setEntityAndAttribute(target); + } else if (relName.equals(is_a_study_of)) { //EVENT study_of WITNESS //WITNESS is_exemplar_of TEXT - this.witness = getTargetRelation(rel); - if(witness != null && witness.isPersistent()){ - witnessId = witness.getId(); - this.textLo.setEntityAndAttribute( getTextOfWitness(witness)); - refreshWitnesses(textLo.entity); - } + this.witness = target; + if (witness != null && witness.isPersistent()) { + witnessId = witness.getId(); + this.textLo.setEntityAndAttribute(getTextOfWitness(witness)); + refreshWitnesses(textLo.entity); + } } } } @@ -126,14 +120,10 @@ // EVENT -> was_advised_by -> PERSON event.replaceSourceRelation(advisorLo.entity, PERSON, was_advised_by); - // EVENT -> was_studied_in -> REPOSITORY - event.replaceSourceRelation(repositoryLo.entity, REPOSITORY, was_studied_in); - //event.replaceSourceRelation(getRepositoryLo().entity, REPOSITORY, was_studied_in); - // EVENT -> was_studied_in -> PLACE - event.replaceSourceRelation(placeLo.entity, PLACE, was_studied_in); + replaceAliasSourceRelation(event, placeLo, PLACE, was_studied_in, was_studied_in_as); - // EVENT -> was_studied_by -> WITNESS + // EVENT -> is_a_study_of -> WITNESS if(witness.isLightweight()){ witness = getWrapper().getEntityByIdWithContent(witness.getId()); } @@ -165,45 +155,40 @@ } */ @Override - public void reset(){ - super.reset(); - this.defObjectClass = OC; - if(personLo != null){ - personLo.reset(); - }else{ - personLo = new ListenerObject(PERSON, name_translit); - } - - if(advisorLo != null){ - advisorLo.reset(); - }else{ - advisorLo = new ListenerObject(PERSON, name_translit); - } - - if(textLo != null){ - textLo.reset(); - }else{ - textLo = new EventTextLO(TEXT, full_title_translit, this); - } - if(placeLo != null){ - placeLo.reset(); - }else{ - placeLo = new ListenerObject(PLACE, name); - } - - if(repositoryLo != null){ - repositoryLo.reset(); - }else{ - repositoryLo = new ListenerObject(REPOSITORY, name); - } - - this.date = new Calendar(); - this.witnessList = new ArrayList(); - this.refreshEngagementOptions(); - } + public void reset() { + super.reset(); + this.defObjectClass = OC; + + if (personLo != null) { + personLo.reset(); + } else { + personLo = new ListenerObject(PERSON, name_translit); + } + + if (advisorLo != null) { + advisorLo.reset(); + } else { + advisorLo = new ListenerObject(PERSON, name_translit); + } + + if (textLo != null) { + textLo.reset(); + } else { + textLo = new EventTextLO(TEXT, full_title_translit, this); + } + if (placeLo != null) { + placeLo.reset(); + } else { + placeLo = new AliasListenerObject(PLACE, name, is_alias_name_of); + } + + this.date = new Calendar(); + this.witnessList = new ArrayList(); + this.refreshEngagementOptions(); + } public boolean checkConsistency(){ - if(this.witness == null || this.textLo.entity == null || this.repositoryLo.entity == null || this.personLo.entity == null){ + if(this.witness == null || this.textLo.entity == null || this.placeLo.entity == null || this.personLo.entity == null){ return false; } return true; @@ -225,14 +210,6 @@ this.advisorLo = advisorLo; } - public ListenerObject getRepositoryLo() { - return repositoryLo; - } - - public void setRepositoryLo(ListenerObject repositoryLo) { - this.repositoryLo = repositoryLo; - } - public List getSuggestedEngagementOptions() { return suggestedEngagementOptions; } diff -r 22a18bfc66b0 -r 59f26a5ef2b3 src/main/java/de/mpiwg/itgroup/ismi/event/beans/TransferEvent.java --- a/src/main/java/de/mpiwg/itgroup/ismi/event/beans/TransferEvent.java Fri Dec 09 21:18:27 2016 +0100 +++ b/src/main/java/de/mpiwg/itgroup/ismi/event/beans/TransferEvent.java Tue Dec 13 19:04:45 2016 +0100 @@ -12,6 +12,7 @@ import org.mpi.openmind.repository.bo.Node; import org.mpi.openmind.repository.bo.Relation; +import de.mpiwg.itgroup.ismi.auxObjects.AliasListenerObject; import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; import de.mpiwg.itgroup.ismi.auxObjects.lo.EventTextLO; import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; @@ -22,21 +23,13 @@ public static String OC = "TRANSFER_EVENT"; - private boolean selectedPersonFrom; - private ListenerObject personFromLo = new ListenerObject(PERSON, name_translit); - private ListenerObject repositoryFromLo = new ListenerObject(REPOSITORY, name); + private ListenerObject personFromLo; - private boolean selectedPersonTo; - private ListenerObject personToLo = new ListenerObject(PERSON, name_translit); - private ListenerObject repositoryToLo = new ListenerObject(REPOSITORY, name); + private ListenerObject personToLo; - private boolean selectedPlaceOriginalLocation; - private ListenerObject placeOriginalLocationLo = new ListenerObject(PLACE, name); - private ListenerObject repositoryOriginalLocationLo = new ListenerObject(REPOSITORY, name); + private AliasListenerObject placeOriginalLocationLo; - private boolean selectedPlaceNewLocation; - private ListenerObject placeNewLocationLo = new ListenerObject(PLACE, name); - private ListenerObject repositoryNewLocationLo = new ListenerObject(REPOSITORY, name); + private AliasListenerObject placeNewLocationLo; private List suggestedTransferOptions = new ArrayList(); @@ -62,157 +55,78 @@ this.loadAttributes(this.event); this.date = updateCalendar(this.event.getAttributeByName("date")); - for (Relation rel : event.getSourceRelations()) { - Entity target = null; - if (rel.getOwnValue().equals(was_transferred_from)) { - // EVENT -> was_transferred_from -> PERSON/REPOSITORY - target = getTargetRelation(rel); - if(target.getObjectClass().equals(PERSON)){ - personFromLo.setEntityAndAttribute(target); - selectedPersonFrom = true; - }else{ - repositoryFromLo.setEntityAndAttribute(target); - selectedPersonFrom = false; - } - - }else if (rel.getOwnValue().equals(was_transferred_to)) { - // EVENT -> was_transferred_to -> PERSON/REPOSITORY - target = getTargetRelation(rel); - if(target.getObjectClass().equals(PERSON)){ - personToLo.setEntityAndAttribute(target); - selectedPersonTo = true; - }else{ - repositoryToLo.setEntityAndAttribute(target); - selectedPersonTo = false; - } - } else if (rel.getOwnValue().equals(has_original_location)) { - // EVENT -> has_original_location -> PLACE/REPOSITORY - target = getTargetRelation(rel); - if(target.getObjectClass().equals(PLACE)){ - placeOriginalLocationLo.setEntityAndAttribute(target); - selectedPlaceOriginalLocation = true; - }else{ - repositoryOriginalLocationLo.setEntityAndAttribute(target); - selectedPlaceOriginalLocation = false; - } - } else if (rel.getOwnValue().equals(has_new_location)) { - // EVENT -> has_new_location -> PLACE/REPOSITORY - target = getTargetRelation(rel); - if(target.getObjectClass().equals(PLACE)){ - placeNewLocationLo.setEntityAndAttribute(target); - selectedPlaceNewLocation = true; - }else{ - repositoryNewLocationLo.setEntityAndAttribute(target); - selectedPlaceNewLocation = false; - } - } else if (rel.getOwnValue().equals(is_a_transfer_of)) { - //EVENT study_of WITNESS - //WITNESS is_exemplar_of TEXT - this.witness = getTargetRelation(rel); - if(witness != null && witness.isPersistent()){ - witnessId = witness.getId(); - this.textLo.setEntityAndAttribute( getTextOfWitness(witness)); - refreshWitnesses(textLo.entity); - } - } else if (rel.getOwnValue().equals(was_transferred_in)) { - target = getTargetRelation(rel); - this.placeLo.setEntityAndAttribute(target); - } - } + for (Relation rel : event.getSourceRelations()) { + Entity target = getTargetRelation(rel); + if (rel.getOwnValue().equals(was_transferred_from)) { + // EVENT -> was_transferred_from -> PERSON + personFromLo.setEntityAndAttribute(target); + } else if (rel.getOwnValue().equals(was_transferred_to)) { + // EVENT -> was_transferred_to -> PERSON + personToLo.setEntityAndAttribute(target); + } else if (rel.getOwnValue().equals(has_original_location)) { + // EVENT -> has_original_location -> PLACE + placeOriginalLocationLo.setEntityAndAttributeIfEmpty(target); + } else if (rel.getOwnValue().equals(has_original_location_as)) { + // EVENT -> has_original_location_as -> ALIAS + placeOriginalLocationLo.setEntityAndAttribute(target); + } else if (rel.getOwnValue().equals(has_new_location)) { + // EVENT -> has_new_location -> PLACE + placeNewLocationLo.setEntityAndAttributeIfEmpty(target); + } else if (rel.getOwnValue().equals(has_new_location_as)) { + // EVENT -> has_new_location_as -> ALIAS + placeNewLocationLo.setEntityAndAttribute(target); + } else if (rel.getOwnValue().equals(is_a_transfer_of)) { + // EVENT study_of WITNESS + // WITNESS is_exemplar_of TEXT + this.witness = target; + if (witness != null && witness.isPersistent()) { + witnessId = witness.getId(); + this.textLo.setEntityAndAttribute(getTextOfWitness(witness)); + refreshWitnesses(textLo.entity); + } + } else if (rel.getOwnValue().equals(was_transferred_in)) { + this.placeLo.setEntityAndAttributeIfEmpty(target); + } else if (rel.getOwnValue().equals(was_transferred_in_as)) { + this.placeLo.setEntityAndAttribute(target); + } + } } } - /* - public void listenerChangePersonFrom(ValueChangeEvent event) { - this.personFrom = changeListener(event, personFrom, PERSON, name_translit); - } - - public void listenerChangePersonTo(ValueChangeEvent event) { - this.personTo = changeListener(event, personTo, PERSON, name_translit); - } - - public void listenerChangeRepositoryFrom(ValueChangeEvent event) { - this.repositoryFrom = changeListener(event, repositoryFrom, REPOSITORY, name); - } - - public void listenerChangeRepositoryTo(ValueChangeEvent event) { - this.repositoryTo = changeListener(event, repositoryTo, REPOSITORY, name); - }*/ - - public void listenerChangeSelectionFrom(ActionEvent event){ - this.selectedPersonFrom = !selectedPersonFrom; - } - - public void listenerChangeSelectionTo(ActionEvent event){ - this.selectedPersonTo = !selectedPersonTo; - } - /* - public void listenerChangePlaceOriginalLocation(ValueChangeEvent event){ - this.placeOriginalLocation = changeListener(event, placeOriginalLocation, PLACE, name); - } - - public void listenerChangePlaceNewLocation(ValueChangeEvent event){ - this.placeNewLocation = changeListener(event, placeNewLocation, PLACE, name); - } - - public void listenerChangeRepositoryOriginalLocation(ValueChangeEvent event){ - this.repositoryOriginalLocation = changeListener(event, repositoryOriginalLocation, REPOSITORY, name); - } - - public void listenerChangeRepositoryNewLocation(ValueChangeEvent event){ - this.repositoryNewLocation = changeListener(event, repositoryNewLocation, REPOSITORY, name); - } - */ - public void listenerChangeSelectionNewLocation(ActionEvent event){ - this.selectedPlaceNewLocation = !selectedPlaceNewLocation; - } - - public void listenerChangeSelectionOriginalLocation(ActionEvent event){ - this.selectedPlaceOriginalLocation = !selectedPlaceOriginalLocation; - } - @Override public void reset(){ super.reset(); - this.selectedPersonFrom = true; - this.selectedPersonTo = true; - this.selectedPlaceOriginalLocation = true; - this.selectedPlaceNewLocation = true; this.defObjectClass = OC; - this.personFromLo = new ListenerObject(PERSON, name_translit); - this.repositoryFromLo = new ListenerObject(REPOSITORY, name); - this.personToLo = new ListenerObject(PERSON, name_translit); - this.repositoryToLo = new ListenerObject(REPOSITORY, name); - - if(textLo != null){ - textLo.reset(); - }else{ - textLo = new EventTextLO(TEXT, full_title_translit, this); + if (personFromLo != null) { + personFromLo.reset(); + } else { + personFromLo = new ListenerObject(PERSON, name_translit); } - if(placeLo != null){ - placeLo.reset(); - }else{ - placeLo = new ListenerObject(PLACE, name); - } + if (personToLo != null) { + personToLo.reset(); + } else { + personToLo = new ListenerObject(PERSON, name_translit); + } + if (textLo != null) { + textLo.reset(); + } else { + textLo = new EventTextLO(TEXT, full_title_translit, this); + } + + if (placeLo != null) { + placeLo.reset(); + } else { + placeLo = new AliasListenerObject(PLACE, name, is_alias_name_of); + } this.date = new Calendar(); this.witnessList = new ArrayList(); - this.placeNewLocationLo = new ListenerObject(PLACE, name); - this.repositoryNewLocationLo = new ListenerObject(REPOSITORY, name); - this.placeOriginalLocationLo = new ListenerObject(PLACE, name); - this.repositoryOriginalLocationLo = new ListenerObject(REPOSITORY, name); - /* - this.repositoryFromLo.reset(); - this.repositoryToLo.reset(); - this.placeNewLocationLo.reset(); - this.placeOriginalLocationLo.reset(); - this.repositoryNewLocationLo.reset(); - this.repositoryOriginalLocationLo.reset(); - */ + this.placeNewLocationLo = new AliasListenerObject(PLACE, name, is_alias_name_of); + this.placeOriginalLocationLo = new AliasListenerObject(PLACE, name, is_alias_name_of); } @@ -223,9 +137,9 @@ private void refreshTransferOptions(){ this.suggestedTransferOptions = new ArrayList(); suggestedTransferOptions.add(new SelectItem(null, "--choose--")); - Attribute binding = getWrapper().getDefAttributeByOwnValue(OC, "options_for_transfer"); - if(binding != null){ - for(String s : binding.getPossibleValuesList()){ + Attribute options = getWrapper().getDefAttributeByOwnValue(OC, "options_for_transfer"); + if(options != null){ + for(String s : options.getPossibleValuesList()){ this.suggestedTransferOptions.add(new SelectItem(s)); } } @@ -255,40 +169,16 @@ event.replaceSourceRelation(witness, WITNESS, is_a_transfer_of); // EVENT -> was_transferred_from -> PERSON/REPOSITORY - if(isSelectedPersonFrom()){ - event.replaceSourceRelation(personFromLo.entity, PERSON, was_transferred_from); - event.removeAllSourceRelations(was_transferred_from, REPOSITORY); - }else{ - event.replaceSourceRelation(repositoryFromLo.entity, REPOSITORY, was_transferred_from); - event.removeAllSourceRelations(was_transferred_from, PERSON); - } + event.replaceSourceRelation(personFromLo.entity, PERSON, was_transferred_from); // EVENT -> was_transferred_to -> PERSON/REPOSITORY - if(isSelectedPersonTo()){ - event.replaceSourceRelation(personToLo.entity, PERSON, was_transferred_to); - event.removeAllSourceRelations(was_transferred_to, REPOSITORY); - }else{ - event.replaceSourceRelation(repositoryToLo.entity, REPOSITORY, was_transferred_to); - event.removeAllSourceRelations(was_transferred_to, PERSON); - } + event.replaceSourceRelation(personToLo.entity, PERSON, was_transferred_to); // EVENT -> has_original_location -> PLACE/REPOSITORY - if(isSelectedPlaceOriginalLocation()){ - event.replaceSourceRelation(placeOriginalLocationLo.entity, PLACE, has_original_location); - event.removeAllSourceRelations(has_original_location, REPOSITORY); - }else{ - event.replaceSourceRelation(repositoryOriginalLocationLo.entity, REPOSITORY, has_original_location); - event.removeAllSourceRelations(has_original_location, PLACE); - } + event.replaceSourceRelation(placeOriginalLocationLo.entity, PLACE, has_original_location); // EVENT -> has_new_location -> PLACE/REPOSITORY - if(isSelectedPlaceNewLocation()){ - event.replaceSourceRelation(placeNewLocationLo.entity, PLACE, has_new_location); - event.removeAllSourceRelations(has_new_location, REPOSITORY); - }else{ - event.replaceSourceRelation(repositoryNewLocationLo.entity, REPOSITORY, has_new_location); - event.removeAllSourceRelations(has_new_location, PLACE); - } + event.replaceSourceRelation(placeNewLocationLo.entity, PLACE, has_new_location); // EVENT -> was_transferred_in -> PLACE event.replaceSourceRelation(placeLo.entity, PLACE, was_transferred_in); @@ -315,14 +205,6 @@ - public boolean isSelectedPersonFrom() { - return selectedPersonFrom; - } - - public boolean isSelectedPersonTo() { - return selectedPersonTo; - } - public List getSuggestedTransferOptions() { return suggestedTransferOptions; } @@ -332,16 +214,6 @@ this.suggestedTransferOptions = suggestedTransferOptions; } - public boolean isSelectedPlaceOriginalLocation() { - return selectedPlaceOriginalLocation; - } - - - - public boolean isSelectedPlaceNewLocation() { - return selectedPlaceNewLocation; - } - public ListenerObject getPersonFromLo() { return personFromLo; } @@ -350,14 +222,6 @@ this.personFromLo = personFromLo; } - public ListenerObject getRepositoryFromLo() { - return repositoryFromLo; - } - - public void setRepositoryFromLo(ListenerObject repositoryFromLo) { - this.repositoryFromLo = repositoryFromLo; - } - public ListenerObject getPersonToLo() { return personToLo; } @@ -366,64 +230,20 @@ this.personToLo = personToLo; } - public ListenerObject getRepositoryToLo() { - return repositoryToLo; - } - - public void setRepositoryToLo(ListenerObject repositoryToLo) { - this.repositoryToLo = repositoryToLo; - } - public ListenerObject getPlaceOriginalLocationLo() { return placeOriginalLocationLo; } - public void setPlaceOriginalLocationLo(ListenerObject placeOriginalLocationLo) { + public void setPlaceOriginalLocationLo(AliasListenerObject placeOriginalLocationLo) { this.placeOriginalLocationLo = placeOriginalLocationLo; } - public ListenerObject getRepositoryOriginalLocationLo() { - return repositoryOriginalLocationLo; - } - - public void setRepositoryOriginalLocationLo( - ListenerObject repositoryOriginalLocationLo) { - this.repositoryOriginalLocationLo = repositoryOriginalLocationLo; - } - public ListenerObject getPlaceNewLocationLo() { return placeNewLocationLo; } - public void setPlaceNewLocationLo(ListenerObject placeNewLocationLo) { + public void setPlaceNewLocationLo(AliasListenerObject placeNewLocationLo) { this.placeNewLocationLo = placeNewLocationLo; } - public ListenerObject getRepositoryNewLocationLo() { - return repositoryNewLocationLo; - } - - public void setRepositoryNewLocationLo(ListenerObject repositoryNewLocationLo) { - this.repositoryNewLocationLo = repositoryNewLocationLo; - } - - public void setSelectedPersonFrom(boolean selectedPersonFrom) { - this.selectedPersonFrom = selectedPersonFrom; - } - - public void setSelectedPersonTo(boolean selectedPersonTo) { - this.selectedPersonTo = selectedPersonTo; - } - - public void setSelectedPlaceOriginalLocation( - boolean selectedPlaceOriginalLocation) { - this.selectedPlaceOriginalLocation = selectedPlaceOriginalLocation; - } - - public void setSelectedPlaceNewLocation(boolean selectedPlaceNewLocation) { - this.selectedPlaceNewLocation = selectedPlaceNewLocation; - } - - - } diff -r 22a18bfc66b0 -r 59f26a5ef2b3 src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/AliasEntityList.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/AliasEntityList.java Tue Dec 13 19:04:45 2016 +0100 @@ -0,0 +1,72 @@ +package de.mpiwg.itgroup.ismi.util.guiComponents; + +import java.util.HashMap; +import java.util.List; + +import org.mpi.openmind.repository.bo.Attribute; +import org.mpi.openmind.repository.bo.Entity; + +import de.mpiwg.itgroup.ismi.auxObjects.AliasListenerObject; + +/** + * EntityList that also takes ALIASes related to the Entities. + * + * @author casties + * + */ +public class AliasEntityList extends EntityList { + + private static final long serialVersionUID = 6671675804993282617L; + + protected String aliasRelName; + protected String entityClass; + + /** + * EntityList that searches in Entity Attributes and also in ALIASes connected by a given Relation. + * + * Uses relation ALIAS - aliasRelName -> ENTITY (usually "is_alias_name_of"). + * + * @param oc + * @param attName + * @param alistRelName + * @param useCalendar + */ + public AliasEntityList(String oc, String attName, String aliasRelName, boolean useCalendar) { + this.aliasRelName = aliasRelName; + this.entityClass = oc; + this.lo = new AliasListenerObject(oc, attName, aliasRelName); + this.useCalendar = useCalendar; + this.calendarMap = new HashMap(); + } + + /* (non-Javadoc) + * @see de.mpiwg.itgroup.ismi.util.guiComponents.EntityList#add(org.mpi.openmind.repository.bo.Entity, org.mpi.openmind.repository.bo.Attribute) + */ + @Override + public void add(Entity e, Attribute calendarAtt) { + // check if we add an alias + if (e.getObjectClass().equals(ALIAS)) { + // get original object + List ents = getWrapper().getTargetsForSourceRelation(e, aliasRelName, entityClass, 1); + Entity ent = ents.get(0); + if (entities.contains(ent)) { + // original is in the List -- remove it + super.remove(ent.getId()); + } + } else { + // get alias + List ents = getWrapper().getSourcesForTargetRelation(e, aliasRelName, ALIAS, 0); + if (!ents.isEmpty()) { + for (Entity ent : ents) { + if (entities.contains(ent)) { + // alias is in the List -- leave it + return; + } + } + } + } + super.add(e, calendarAtt); + } + + +} diff -r 22a18bfc66b0 -r 59f26a5ef2b3 src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/EntityList.java --- a/src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/EntityList.java Fri Dec 09 21:18:27 2016 +0100 +++ b/src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/EntityList.java Tue Dec 13 19:04:45 2016 +0100 @@ -18,28 +18,32 @@ import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; import de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean; -public class EntityList extends AbstractISMIBean{ +public class EntityList extends AbstractISMIBean { - private static final long serialVersionUID = -3339006604248018647L; + protected static final long serialVersionUID = -3339006604248018647L; - private static Logger logger = Logger.getLogger(EntityList.class); + protected static Logger logger = Logger.getLogger(EntityList.class); - private List entities = new ArrayList(); - private Map selections = new HashMap(); - private String title; + protected List entities = new ArrayList(); + protected Map selections = new HashMap(); + protected String title; //some relations have an attribute date - private boolean useCalendar; - private Map calendarMap; + protected boolean useCalendar; + protected Map calendarMap; - private ListenerObject lo; + protected ListenerObject lo; + + protected String input; + protected Long id; - private String input; - private Long id; + protected WrapperService otg; + protected String user; + + public EntityList() { + // empty default constructor + } - private WrapperService otg; - private String user; - public EntityList(String oc, String attName, String title){ this.lo = new ListenerObject(oc, attName); this.title = title; @@ -146,6 +150,11 @@ } } + /** + * Add an Entity to the list. + * + * @param e + */ public void add(Entity e){ if(e != null && e.isPersistent()){ if(!selections.containsKey(e.getId())){ @@ -160,6 +169,12 @@ } } + /** + * Add an Entity with a calendar Attribute to the list. + * + * @param e + * @param calendarAtt + */ public void add(Entity e, Attribute calendarAtt){ if(e != null && e.isPersistent()){ if(!selections.containsKey(e.getId())){ diff -r 22a18bfc66b0 -r 59f26a5ef2b3 src/main/webapp/events/copyEvent.xhtml --- a/src/main/webapp/events/copyEvent.xhtml Fri Dec 09 21:18:27 2016 +0100 +++ b/src/main/webapp/events/copyEvent.xhtml Tue Dec 13 19:04:45 2016 +0100 @@ -58,9 +58,6 @@ - - - diff -r 22a18bfc66b0 -r 59f26a5ef2b3 src/main/webapp/events/studyEvent.xhtml --- a/src/main/webapp/events/studyEvent.xhtml Fri Dec 09 21:18:27 2016 +0100 +++ b/src/main/webapp/events/studyEvent.xhtml Tue Dec 13 19:04:45 2016 +0100 @@ -67,9 +67,6 @@ - - - diff -r 22a18bfc66b0 -r 59f26a5ef2b3 src/main/webapp/events/transferEvent.xhtml --- a/src/main/webapp/events/transferEvent.xhtml Fri Dec 09 21:18:27 2016 +0100 +++ b/src/main/webapp/events/transferEvent.xhtml Tue Dec 13 19:04:45 2016 +0100 @@ -34,7 +34,7 @@ - + @@ -45,112 +45,31 @@ - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - + + + - + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - + -