diff src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentWitnessBean.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 4aa8c425685d
line wrap: on
line diff
--- 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<Entity> 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;
 	}