changeset 91:d172201d24ad

more comments and refactorings.
author casties
date Wed, 12 Oct 2016 20:50:30 +0200
parents 72b877076f43
children be377d5f9cc4
files src/main/java/de/mpiwg/itgroup/ismi/entry/beans/AbstractISMIBean.java src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCityBean.java src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCodexBean.java src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCollectionBean.java src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentRepositoryBean.java src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentTextBean.java src/main/java/de/mpiwg/itgroup/ismi/merge/GeneralMerge.java src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/EndNoteMisattribution.java src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/EndNoteMisattributionTable.java src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/Misattribution.java src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/MisattributionTable.java
diffstat 11 files changed, 499 insertions(+), 643 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/AbstractISMIBean.java	Wed Oct 12 15:34:49 2016 +0200
+++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/AbstractISMIBean.java	Wed Oct 12 20:50:30 2016 +0200
@@ -23,6 +23,7 @@
 
 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject;
 import de.mpiwg.itgroup.ismi.entry.dataBeans.SimpleSearchCache;
+import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar;
 import de.mpiwg.itgroup.ismi.util.guiComponents.Reference;
 import de.mpiwg.itgroup.ismi.util.guiComponents.ReferenceTable;
 import de.mpiwg.itgroup.ismi.util.guiComponents.StatusChecker;
@@ -93,7 +94,7 @@
 	
 	protected boolean selectedSaveAsNew = false;
 	
-	private HashSet<StatusChecker> statusChecker = new HashSet<StatusChecker>();
+	private HashSet<StatusChecker> statusCheckers = new HashSet<StatusChecker>();
 	private boolean warning = false;
 	private String warningMessage = "";
 	private boolean displayWarning = false;
@@ -119,12 +120,22 @@
 	
 	protected long start;
 	
+	/**
+	 * Save current entity.
+	 * 
+	 * @return
+	 */
 	public String save(){
 		logger.info("*************** START Saving "+ this.defObjectClass + " [ID=" + entity.getId() +", user"+ getUserName() +"] *********************");
 		this.start = System.currentTimeMillis();
 		return null;
 	}
 	
+	/**
+	 * End saving current entity.
+	 * 
+	 * To be called at the end of save().
+	 */
 	protected void saveEnd(){
 		logger.info("*************** END Saving "+ this.defObjectClass + " [ID=" + entity.getId() +", user"+ getUserName() +"] *********************\n");
 	}
@@ -139,7 +150,10 @@
 		return entity;
 	}
 
-	protected void printSuccessSavingEntity(){
+	/**
+	 * Add save confirmation to message.
+	 */
+	protected void printSuccessSavingEntity() {
 		this.addGeneralMsg("The entity was successfully saved!");
 		this.addGeneralMsg("Its ID is " + this.entity.getId());
 	}
@@ -254,14 +268,18 @@
 	}
 		
 	
+	/**
+	 * Save references and set relations.
+	 *  
+	 * @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){
+		for (SelectableObject<Reference> so : this.endNoteRefTable.list) {
 			Reference ref = so.getObj();
-
 			Entity entRef = ref.getEnt();
-			getWrapper().saveAssertion(entRef, getUserName());
+			getWrapper().saveEntity(entRef, getUserName());
 			//entity can be no persistent, therefore the assignment of the relation should be done after the save
 			entRef.addSourceRelation(rel_is_reference_of, entity);
 			//new Relation(entRef, entity, rel_is_reference_of);
@@ -269,12 +287,12 @@
 	}
 	
 
-	public static de.mpiwg.itgroup.ismi.util.guiComponents.Calendar updateCalendar(Attribute att){
-		de.mpiwg.itgroup.ismi.util.guiComponents.Calendar calendar = null;
+	public static Calendar updateCalendar(Attribute att){
+		Calendar calendar = null;
 		if(att != null && StringUtils.isNotEmpty(att.getOwnValue())){
-			calendar = new de.mpiwg.itgroup.ismi.util.guiComponents.Calendar(att.getOwnValue()); 
+			calendar = new Calendar(att.getOwnValue()); 
 		}else{
-			calendar = new de.mpiwg.itgroup.ismi.util.guiComponents.Calendar();
+			calendar = new Calendar();
 		}
 		return calendar;
 	}
@@ -314,40 +332,38 @@
 	}
 
 	/**
-	 * <p>
-	 * "Entity -> CurrentEntity"
-	 * </p>
-	 * <p>
-	 * This method updates the attributes of the given entity with the
+	 * Update the defined attributes of the given entity with the
 	 * attributes of the attributes Map<String, String>.
-	 * </p>
 	 * 
-	 * @return the input's entity with updated attributes.
+	 * @return the entity with updated attributes.
 	 */
-	public Entity updateEntityAttributes(Entity entity) {
-		if (entity == null) {
-			entity = new Entity(Node.TYPE_ABOX, false);
-			//entity.setObjectClass(getDefinition().getOwnValue());
-			entity.setObjectClass(this.defObjectClass);
-		}
-		//for (Attribute defAtt : getDefinition(entity).getAttributes()) {
-		for (Attribute defAtt : getWrapper().getDefAttributes(this.defObjectClass)) {
-			Attribute att = entity.getAttributeByName(defAtt.getOwnValue());
-			if (StringUtils.isNotEmpty(this.attributes
-					.get(defAtt.getOwnValue()))) {
-				if (att == null) {
-					att = new Attribute(defAtt);
-					entity.addAttribute(att);
-				}
-				att.setOwnValue(this.attributes.get(defAtt.getOwnValue()));
-				att.setObjectClass(defAtt.getOwnValue());
-			} else if (att != null) {
-				// the attribute must be deleted.
-				entity.getAttributes().remove(att);
-			}
-		}
-		return entity;
-	}
+    public Entity updateEntityAttributes(Entity entity) {
+        // create entity if it doesn't exist
+        if (entity == null) {
+            entity = new Entity(Node.TYPE_ABOX, false);
+            entity.setObjectClass(this.defObjectClass);
+        }
+        // update all defined attributes
+        for (Attribute defAtt : getWrapper().getDefAttributes(this.defObjectClass)) {
+            String attName = defAtt.getOwnValue();
+            Attribute att = entity.getAttributeByName(attName);
+            if (StringUtils.isNotEmpty(this.attributes.get(attName))) {
+                // there is an attribute to update
+                if (att == null) {
+                    // attribute is new
+                    att = new Attribute(defAtt);
+                    entity.addAttribute(att);
+                }
+                // update value
+                att.setOwnValue(this.attributes.get(attName));
+                att.setObjectClass(attName);
+            } else if (att != null) {
+                // there is no attribute to update - delete attribute
+                entity.getAttributes().remove(att);
+            }
+        }
+        return entity;
+    }
 
 	protected List<SelectItem> updateSuggestedPersonByRole(String searchWord, String objClass, String attName, String role){
 		List<Attribute> attList = getWrapper().getAttributesByDefByAttName(objClass, attName, searchWord.toString(), -1);
@@ -637,7 +653,7 @@
 	}
 
 	public void registerChecker(StatusChecker sc) {
-		statusChecker.add(sc);
+		statusCheckers.add(sc);
 	}
 
 	public void registerChecker(ListenerObject lo, String message) {
@@ -647,7 +663,7 @@
 
 	public void registerChecker(StatusChecker sc, String message) {
 		sc.setMessage(message);
-		statusChecker.add(sc);
+		statusCheckers.add(sc);
 	}
 
 	class CheckResults {
@@ -658,10 +674,15 @@
 
 	}
 
+	/**
+	 * Get the result from all StatusCheckers.
+	 * 
+	 * @return
+	 */
 	public CheckResults getCheckResults() {
 		CheckResults cr = new CheckResults();
 
-		for (StatusChecker sc : statusChecker) {
+		for (StatusChecker sc : statusCheckers) {
 			if (sc.getStatus().equals("false")) {
 				cr.hasErrors = true;
 				cr.errors.add(sc.getMessage());
@@ -842,41 +863,40 @@
 		return lo;
 	}
 	
-	protected void generateSecundaryOW(Entity entity, String user) throws Exception{
-		List<Entity> nodeList = new ArrayList<Entity>();
-		
-		long start = System.currentTimeMillis();
-		if(entity.getObjectClass().equals(PLACE)){
-			this.generateOW4City(entity, nodeList, user);
-			long medium  = System.currentTimeMillis();
-			System.out.println("nodeList.size(): " + nodeList.size() + " time: " + (medium - start));
-			getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user);
-			System.out.println("Save time: " + (System.currentTimeMillis() - medium));
-		}else if(entity.getObjectClass().equals(REPOSITORY)){
-			this.generateOW4Repository(entity, nodeList, new HashMap<String, String>(), user);
-			long medium  = System.currentTimeMillis();
-			System.out.println("nodeList.size(): " + nodeList.size() + " time: " + (medium - start));
-			getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user);
-			System.out.println("Save time: " + (System.currentTimeMillis() - medium));
-		}else if(entity.getObjectClass().equals(COLLECTION)){
-			this.generateOW4Collection(entity, nodeList, new HashMap<String, String>(), user);
-			long medium  = System.currentTimeMillis();
-			System.out.println("nodeList.size(): " + nodeList.size() + " time: " + (medium - start));
-			getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user);
-			System.out.println("Save time: " + (System.currentTimeMillis() - medium));
-		}else if(entity.getObjectClass().equals(CODEX)){
-			this.generateOW4Codex(entity, nodeList, new HashMap<String, String>(), user);
-			long medium  = System.currentTimeMillis();
-			System.out.println("nodeList.size(): " + nodeList.size() + " time: " + (medium - start));
-			getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user);
-			System.out.println("Save time: " + (System.currentTimeMillis() - medium));
-		}else if(entity.getObjectClass().equals(TEXT)){
-			generateOW4Text(entity, user);
-			long medium  = System.currentTimeMillis();
-			System.out.println("Saving witnessList time: " + (medium - start));
-		}
-		//TODO PERSON and TEXT
-	}
+	/**
+	 * Update the ownvalues of entities that are related to the given entity.
+	 * 
+	 * @param entity
+	 * @param user
+	 * @throws Exception
+	 */
+    protected void updateRelatedOW(Entity entity, String user) throws Exception {
+        List<Entity> nodeList = new ArrayList<Entity>();
+
+        /*
+         * run updates depending on type
+         */
+        if (entity.getObjectClass().equals(PLACE)) {
+            this.generateOW4City(entity, nodeList, user);
+            getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user);
+
+        } else if (entity.getObjectClass().equals(REPOSITORY)) {
+            this.generateOW4Repository(entity, nodeList, new HashMap<String, String>(), user);
+            getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user);
+
+        } else if (entity.getObjectClass().equals(COLLECTION)) {
+            this.generateOW4Collection(entity, nodeList, new HashMap<String, String>(), user);
+            getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user);
+
+        } else if (entity.getObjectClass().equals(CODEX)) {
+            this.generateOW4Codex(entity, nodeList, new HashMap<String, String>(), user);
+            getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user);
+
+        } else if (entity.getObjectClass().equals(TEXT)) {
+            generateOW4Text(entity, user);
+        }
+        // TODO PERSON and TEXT
+    }
 	
 	private void generateOW4City(Entity city, List<Entity> nodeList, String user){
 		Map<String, String> map = new HashMap<String, String>();
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCityBean.java	Wed Oct 12 15:34:49 2016 +0200
+++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCityBean.java	Wed Oct 12 20:50:30 2016 +0200
@@ -159,7 +159,7 @@
 				//lastAction = "Save place";
 			}
 			//setActionInfo(lastAction);
-			this.generateSecundaryOW(this.entity, getSessionUser().getEmail());
+			this.updateRelatedOW(this.entity, getSessionUser().getEmail());
 			this.setCurrentId(this.entity.getId().toString());
 			
 			logger.info("Entity saved - Time = " + (System.currentTimeMillis() - start) + ", " + entity);
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCodexBean.java	Wed Oct 12 15:34:49 2016 +0200
+++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCodexBean.java	Wed Oct 12 20:50:30 2016 +0200
@@ -266,7 +266,7 @@
 				this.entity = getWrapper().saveEntity(this.entity, getSessionUser().getEmail());
 			}
 
-			this.generateSecundaryOW(this.entity, getSessionUser().getEmail());
+			this.updateRelatedOW(this.entity, getSessionUser().getEmail());
 			getSessionBean().setEditFormCurrentEntId(this.entity.getId());
 			
 			logger.info("Entity saved - Time = " + (System.currentTimeMillis() - start) + ", " + entity);
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCollectionBean.java	Wed Oct 12 15:34:49 2016 +0200
+++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCollectionBean.java	Wed Oct 12 20:50:30 2016 +0200
@@ -154,7 +154,7 @@
 						getSessionUser().getEmail());
 			}
 
-			this.generateSecundaryOW(this.entity, getSessionUser().getEmail());
+			this.updateRelatedOW(this.entity, getSessionUser().getEmail());
 			this.setCurrentId(this.entity.getId().toString());
 
 			logger.info("Entity saved - Time = "
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentRepositoryBean.java	Wed Oct 12 15:34:49 2016 +0200
+++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentRepositoryBean.java	Wed Oct 12 20:50:30 2016 +0200
@@ -104,7 +104,7 @@
 				this.entity = getWrapper().saveEntity(this.entity, getSessionUser().getEmail());
 			}
 			
-			this.generateSecundaryOW(this.entity, getSessionUser().getEmail());
+			this.updateRelatedOW(this.entity, getSessionUser().getEmail());
 			getSessionBean().setEditFormCurrentEntId(this.entity.getId());
 						
 			logger.info("Entity saved - Time = " + (System.currentTimeMillis() - start) + ", " + entity);
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentTextBean.java	Wed Oct 12 15:34:49 2016 +0200
+++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentTextBean.java	Wed Oct 12 20:50:30 2016 +0200
@@ -24,8 +24,8 @@
 
 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject;
 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar;
-import de.mpiwg.itgroup.ismi.util.guiComponents.EndNoteMisattribution;
-import de.mpiwg.itgroup.ismi.util.guiComponents.EndNoteMisattributionTable;
+import de.mpiwg.itgroup.ismi.util.guiComponents.Misattribution;
+import de.mpiwg.itgroup.ismi.util.guiComponents.MisattributionTable;
 import de.mpiwg.itgroup.ismi.util.guiComponents.EntityList;
 
 public class CurrentTextBean extends AbstractISMIBean implements Serializable{
@@ -106,7 +106,7 @@
 	private EntityList explicitAliasList;
 
 	//private MisattributionDataTable misattDataTable;
-	private transient EndNoteMisattributionTable misattTable;
+	private transient MisattributionTable misattTable;
 	
 	public CurrentTextBean() {
 		this.reset();
@@ -122,7 +122,7 @@
 		this.incipitAliasList = new EntityList(ALIAS, "alias", getWrapper(), getUserName());
 		this.explicitAliasList = new EntityList(ALIAS, "alias", getWrapper(), getUserName());
 		//this.misattDataTable = new MisattributionDataTable(PERSON, "name_translit");
-		this.misattTable = new EndNoteMisattributionTable();
+		this.misattTable = new MisattributionTable();
 		
 		this.selectPersonRendered = false;
 		this.selectedPersonId = null;
@@ -198,13 +198,20 @@
 	}
 
 	/**
-	 * Source's Relations # TEXT is_commentary_on TEXT # TEXT is_translation_of
-	 * TEXT # TEXT is_version_of TEXT # TEXT was_created_by PERSON # TEXT
-	 * was_created_in PLACE # TEXT was_dedicated_to PERSON # TEXT has_subject
-	 * SUBJECT
+	 * Set entity and process attributes and relations.
 	 * 
-	 * Target's Relations # ALIAS is_alias_title_of TEXT # ALIAS
-	 * is_alias_incipit_of TEXT
+	 * Source Relations: 
+	 * TEXT is_commentary_on TEXT, 
+	 * TEXT is_translation_of TEXT, 
+	 * TEXT is_version_of TEXT, 
+	 * TEXT was_created_by PERSON,
+	 * TEXT was_created_in PLACE,
+	 * TEXT was_dedicated_to PERSON,
+	 * TEXT has_subject SUBJECT
+	 * 
+	 * Target Relations:
+	 * ALIAS is_alias_title_of TEXT,
+	 * ALIAS is_alias_incipit_of TEXT
 	 * 
 	 * @param text
 	 */
@@ -212,120 +219,105 @@
 	public void setEntity(Entity text) {
 		this.reset();
 		this.entity = text;
-		if(this.entity.isPersistent()){
+		if (this.entity.isPersistent()) {
+		    // set id
 			setCurrentId(this.entity.getId().toString());
+
+			// load content
 			if (text.isLightweight()) {
 				this.entity = getWrapper().getEntityContent(this.entity);
 				this.entity.setLightweight(false);
 			}
 			
+			// set creation date
 			Attribute attCreationDate = this.entity.getAttributeByName("creation_date");
-			if(attCreationDate != null && StringUtils.isNotEmpty(attCreationDate.getOwnValue())){
+			if(attCreationDate != null && StringUtils.isNotEmpty(attCreationDate.getOwnValue())) {
 				this.creationDate = new Calendar(attCreationDate.getOwnValue()); 
-			}else{
+			} else {
 				this.creationDate = new Calendar();
 			}
 			
+			/*
+			 * set attributes
+			 */
 			this.loadAttributes(this.entity);//, getDefinition(this.entity));
 			
+			/*
+			 * set source relations
+			 */
 			for (Relation rel : text.getSourceRelations()) {
 				Entity target = null;
-				if( rel.getOwnValue().equals(has_subject)){
+				String relName = rel.getOwnValue();
+                if(relName.equals(has_subject)) {
 					this.subject = getTargetRelation(rel);
 					this.idSubject = subject.getId();
-				} else if (rel.getOwnValue().equals("is_commentary_on")) {
+					
+				} else if (relName.equals("is_commentary_on")) {
 					target = getTargetRelation(rel);
 					this.commentaryLo.setEntityAndAttribute0(target);
-				} else if (rel.getOwnValue().equals("is_translation_of")) {
+					
+				} else if (relName.equals("is_translation_of")) {
 					target = getTargetRelation(rel);
 					this.translationLo.setEntityAndAttribute0(target);
-				} else if (rel.getOwnValue().equals("is_version_of")) {
+					
+				} else if (relName.equals("is_version_of")) {
 					target = getTargetRelation(rel);
 					this.versionLo.setEntityAndAttribute0(target);
-				} else if (rel.getOwnValue().equals("was_created_by")) {
+					
+				} else if (relName.equals("was_created_by")) {
 					target = getTargetRelation(rel);
 					this.authorLo.setEntityAndAttribute0(target);
 					
-					if(this.authorLo.attribute != null){
+					if (this.authorLo.attribute != null) {
 						this.textAuthorNameTranslit = this.authorLo.attribute.getValue();
 					}
 					
-				} else if (rel.getOwnValue().equals("was_dedicated_to")) {
+				} else if (relName.equals("was_dedicated_to")) {
 					target = getTargetRelation(rel);
 					this.dedicatedPersonLo.setEntityAndAttribute0(target); 
 						
-				} else if (rel.getOwnValue().equals("was_created_in")) {
+				} else if (relName.equals("was_created_in")) {
 					target = getTargetRelation(rel);
-					//rich this.placeLo.setEntityAndAttribute(target, "name");
 					this.placeLo.setEntityAndAttribute0(target);					
-				//} else if (rel.getOwnValue().equals(misattributed_to)) {
-				} else if (rel.getOwnValue().equals("has_author_misattribution")) {
+					
+				} else if (relName.equals("has_author_misattribution")) {
 					target = getTargetRelation(rel);
-					//String refId = (rel.getAttributeByName("reference_id") != null) ? rel.getAttributeByName("reference_id").getValue() : null;
-					//String notes = (rel.getAttributeByName("notes") != null) ? rel.getAttributeByName("notes").getValue() : null;
-					//target=person
-					//this.misattDataTable.add(target, refId, notes);
-					//this.misattTable.add(target, ref, rel);
 					this.misattTable.load(target);
 				}
-
 			}
+			
+			/*
+			 * set target relations
+			 */
 			for (Relation rel : text.getTargetRelations()) {
-
-				if (rel.getOwnValue().equals("is_alias_title_of")) {
+				String relName = rel.getOwnValue();
+                if (relName.equals("is_alias_title_of")) {
 					Entity alias = getWrapper().getEntityByIdWithContent(rel.getSourceId());
-					this.aliasList.add(alias); 
-				} else if (rel.getOwnValue().equals("is_alias_incipit_of")) {
+					this.aliasList.add(alias);
+					
+				} else if (relName.equals("is_alias_incipit_of")) {
 					Entity alias = getWrapper().getEntityByIdWithContent(rel.getSourceId());
 					this.incipitAliasList.add(alias);
-				} else if (rel.getOwnValue().equals("is_alias_explicit_of")) {
+					
+				} else if (relName.equals("is_alias_explicit_of")) {
 					Entity alias = getWrapper().getEntityByIdWithContent(rel.getSourceId());
 					this.explicitAliasList.add(alias);
-				} else if (rel.getOwnValue().equals("is_prime_alias_title_of")) {
+					
+				} else if (relName.equals("is_prime_alias_title_of")) {
 					Entity alias = getWrapper().getEntityByIdWithContent(rel.getSourceId());
 					this.shortTitleAlias = alias;
 					this.valueShortTitle = alias.getAttributeByName("alias").getValue();
 				}
 			}
 			
+			/*
+			 * set references
+			 */
 			this.loadEndNoteRefs();
 			this.displayUrl = generateDisplayUrl(authorLo.entity, text, null, getAppBean().getRoot());
 		}
 	}
 
-	/**
-	 * Added by DW it is no used anymore
-	 * 
-	 * @param event
-	 */
-	public void translitTitleChangeListener(ValueChangeEvent event) {
-		try {
-			if (event.getNewValue() == null) {
-				return;
-			}
-			if (event.getNewValue().equals(event.getOldValue())) {
-				return;
-			}
-
-			String newName = (String) event.getNewValue();
-
-			if (translitTitleAlias == null) {
-				translitTitleAlias = new Entity(Node.TYPE_ABOX, "ALIAS", false);
-			}
-
-			Attribute attr = this.translitTitleAlias
-					.getAttributeByName("alias");
-			if (attr == null) {
-				this.translitTitleAlias.addAttribute(new Attribute("alias",
-						TEXT, newName));
-			} else
-				attr.setValue(newName);
-
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
-
 	public String translitTitleAction() {
 		String pn = getAttributes().get("full_title");
 
@@ -501,6 +493,13 @@
 		this.setSelectPersonRendered(false);
 	}
 	
+	/**
+	 * Check mandatory parts.
+	 * 
+	 * In this case the author has to be set.
+	 * 
+	 * @return
+	 */
 	public boolean mandatoryEntriesOK(){
 		boolean ok = true;
 		if(this.authorLo.entity == null || !this.authorLo.entity.isPersistent()){
@@ -510,18 +509,21 @@
 		return ok;
 	}
 
+	/* (non-Javadoc)
+	 * @see de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean#save()
+	 */
 	@Override
 	public String save() {
 		super.save();
 		try {
 			
-			if(!mandatoryEntriesOK()){
+		    /*
+		     * check input
+		     */
+			if (!mandatoryEntriesOK()) {
 				addGeneralMsg("The entity could not be saved.");
 				return PAGE_EDITOR;
-			}
-			
-			User user = getSessionUser();
-
+			}			
 			CheckResults cr = getCheckResults();
 			if (cr.hasErrors) {
 				getSessionBean().setErrorMessages(cr);
@@ -529,12 +531,17 @@
 				return PAGE_EDITOR;
 			}
 
+			User user = getSessionUser();
 			
-			
+			// add creation date
 			getAttributes().put("creation_date", this.creationDate.toJSONString());
 			
+			// update all attributes
 			this.entity = updateEntityAttributes(this.entity);
 			
+			/*
+			 * set relations
+			 */
 			this.entity.replaceSourceRelation(commentaryLo.entity, TEXT, "is_commentary_on");
 			
 			this.entity.replaceSourceRelation(translationLo.entity, TEXT, "is_translation_of");
@@ -548,103 +555,97 @@
 			this.entity.replaceSourceRelation(placeLo.entity, PLACE, "was_created_in");
 			
 			this.entity.removeAllSourceRelations(has_subject, SUBJECT);
-			if(getIdSubject() != null){
+			if (getIdSubject() != null) {
 				this.subject = getWrapper().getEntityByIdWithContent(getIdSubject());
 				this.entity.replaceSourceRelation(subject, SUBJECT, has_subject);
 			}
-
 			
-			//is_prime_alias_title_of
-			if(!StringUtils.isEmpty(valueShortTitle)){
+			/*
+			 * set short title (is_prime_alias_title_of)
+			 */
+			if (!StringUtils.isEmpty(valueShortTitle)) {
 				this.entity.removeAllTargetRelations("is_prime_alias_title_of", ALIAS);
 			
-				if(this.shortTitleAlias == null){
+				if (this.shortTitleAlias == null) {
 					//1)create  alias, 2) update value of alias3) save alias, and 4) add to this text.
 					shortTitleAlias = new Entity(Node.TYPE_ABOX, ALIAS, false);
 					shortTitleAlias.addAttribute(new Attribute("alias", "text", this.valueShortTitle));
 					getWrapper().saveEntity(shortTitleAlias, getUserName());					
-				}else{
+				} else {
 					//1) update value, 2) re-save alias
 					this.shortTitleAlias.getAttributeByName("alias").setOwnValue(this.valueShortTitle);
 					this.shortTitleAlias.removeAllSourceRelations("is_prime_alias_title_of", TEXT);
 					getWrapper().saveEntity(shortTitleAlias, getUserName());
 				}
-				Relation aliasRel = new Relation(shortTitleAlias, this.entity, "is_prime_alias_title_of");
+				new Relation(shortTitleAlias, this.entity, "is_prime_alias_title_of");
 			}
 			
 			/*
-			if (this.shortTitleAlias == null
-					|| (shortTitleAlias.getAttributeByName("alias") != null && StringUtils
-							.isEmpty(shortTitleAlias
-									.getAttributeByName("alias").getOwnValue()))) {
-				this.entity.removeAllTargetRelations("is_prime_alias_title_of",
-						ALIAS);
-			} else if (this.shortTitleAlias != null) {
-				shortTitleAlias = getWrapper().saveEntity(shortTitleAlias, user.getEmail());
-				this.entity.setAsUniqueTargetRelation("is_prime_alias_title_of",
-						this.shortTitleAlias);
-			}
-			*/
-			
-			//ALIAS -> is_alias_title_of -> TEXT
+			 * set alias title (ALIAS -> is_alias_title_of -> TEXT)
+			 */
 			this.entity.removeAllTargetRelationsByName("is_alias_title_of");
 			for(Entity alias : this.aliasList.getEntities()){
 				Entity alias0 = getWrapper().getEntityByIdWithContent(alias.getId());
-				Relation aliasRel = new Relation(alias0, this.entity, "is_alias_title_of");
+				new Relation(alias0, this.entity, "is_alias_title_of");
 			}
 			
-			//saveAliases2(incipitAliases, deletedIncipitAliases,
-			//		"is_alias_incipit_of");
-			//deletedIncipitAliases = refreshAliasMap(incipitAliases, deletedIncipitAliases);
+			/*
+			 * set alias incipit
+			 */
 			this.entity.removeAllTargetRelationsByName("is_alias_incipit_of");
 			for(Entity alias : this.incipitAliasList.getEntities()){
 				Entity alias0 = getWrapper().getEntityByIdWithContent(alias.getId());
-				Relation aliasRel = new Relation(alias0, this.entity, "is_alias_incipit_of");
+				new Relation(alias0, this.entity, "is_alias_incipit_of");
 			}
 			
 			/*
-			saveAliases2(explicitAliases, deletedExplicitAliases,
-					"is_alias_explicit_of");
-			deletedExplicitAliases = refreshAliasMap(explicitAliases, deletedExplicitAliases);
-			*/
+			 * save alias explicit
+			 */
 			this.entity.removeAllTargetRelationsByName("is_alias_explicit_of");
 			for(Entity alias : this.explicitAliasList.getEntities()){
 				Entity alias0 = getWrapper().getEntityByIdWithContent(alias.getId());
-				Relation aliasRel = new Relation(alias0, this.entity, "is_alias_explicit_of");
+				new Relation(alias0, this.entity, "is_alias_explicit_of");
 			}
 			
-			//String lastAction = "";
-			
-			//REFERENCE -> is_reference_of -> THIS
-			//this.entity = this.prepareReferencesToSave(this.entity);
+			// set references
 			this.prepareEndNoteRefs2Save();
 			
-			this.entity.removeAllSourceRelations(EndNoteMisattribution.HAS_AUTHOR_MISATT, EndNoteMisattribution.MISATT);
+			/*
+			 * set misattribution
+			 */
+			this.entity.removeAllSourceRelations(Misattribution.HAS_AUTHOR_MISATT, Misattribution.MISATT);
 			
+			/*
+			 * save entity
+			 */
 			this.entity = getWrapper().saveEntity(this.entity, user.getEmail());
 			this.getAppBean().setAllTextsAsDirty();
 			getAppBean().getSimpleSearchCache().setMapDirty(true);
 			
+			/*
+			 * save misattributions
+			 */
 			this.entity = this.misattTable.saveMisattributions(this.entity);
 			
+			// re-set entity
 			this.setEntity(this.entity);
-			//lastAction = "save text";
-
-
-			this.generateSecundaryOW(this.entity, getSessionUser().getEmail());
+			
+			// update related own values
+			this.updateRelatedOW(this.entity, getSessionUser().getEmail());
 
 			logger.info("Entity saved - Time = " + (System.currentTimeMillis() - start) + ", " + entity);
+			
+			// print success
 			this.printSuccessSavingEntity();
 
-			//setActionInfo(lastAction);
-
-			
 		} catch (Exception e) {
 			logger.error(e.getMessage(), e);
-			e.printStackTrace();
 			this.printInternalError(e);
 		}
+		
+		// end saving
 		saveEnd();
+		// stay on edit page
 		return PAGE_EDITOR;
 	}
 
@@ -656,105 +657,6 @@
 		this.incipitAliasList = incipitAliasList;
 	}
 
-	/**
-	 * This method saves the text as new entity, and its related alias and
-	 * witness.
-	 * 
-	 * @return
-	 */
-	public String saveAsNewEntity() {
-		
-		try {
-			User user = getSessionUser();
-
-			CheckResults cr = getCheckResults();
-			if (cr.hasErrors) {
-				getSessionBean().setErrorMessages(cr);
-				getSessionBean().setDisplayError(true);
-				return "SAVE_ERROR";
-			}
-
-			
-			this.entity = updateEntityAttributes(this.entity);
-			//text.setOwnValue(createOwnValue());
-			
-			//text.removeSourceRelation("is_commentary_of", commentaryLo.entity);
-			//replaceSourceRelation(text, commentaryLo.entity, TEXT, "is_commentary_on");
-			this.entity.replaceSourceRelation(commentaryLo.entity, TEXT, "is_commentary_on");
-
-			//text.removeSourceRelation("is_translation_of", translationLo.entity);
-			//replaceSourceRelation(text, translationLo.entity, TEXT, "is_translation_of");
-			this.entity.replaceSourceRelation(translationLo.entity, TEXT, "is_translation_of");
-			
-			//text.removeSourceRelation("is_version_of", versionLo.entity);
-			//replaceSourceRelation(text, versionLo.entity, TEXT, "is_version_of");
-			this.entity.replaceSourceRelation(versionLo.entity, TEXT, "is_version_of");
-			
-			//text.removeSourceRelation("was_created_by", authorLo.entity);
-			//replaceSourceRelation(text, authorLo.entity, PERSON, "was_created_by");
-			this.entity.replaceSourceRelation(authorLo.entity, PERSON, "was_created_by");
-			
-			//text.removeSourceRelation("was_dedicated_to", dedicatedPersonLo.entity);
-			//replaceSourceRelation(text, dedicatedPersonLo.entity, PERSON,
-			//		"was_dedicated_to");
-			this.entity.replaceSourceRelation(dedicatedPersonLo.entity, PERSON, "was_dedicated_to");
-			
-			//text.removeSourceRelation("was_created_in", placeLo.entity);
-			//replaceSourceRelation(text, placeLo.entity, PLACE, "was_created_in");
-			this.entity.replaceSourceRelation(placeLo.entity, PLACE, "was_created_in");
-			
-			//String lastAction = "";
-
-			// removing transiently the target relation, 
-			// because they should not be saved as new
-			this.entity.removeAllTargetRelations("is_exemplar_of", "WITNESS");
-			this.entity.removeAllTargetRelations("is_prime_alias_title_of", "ALIAS");
-			this.entity.removeAllTargetRelations("is_alias_title_of", "ALIAS");
-			this.entity.removeAllTargetRelations("is_alias_incipit_of", "ALIAS");
-			this.entity.removeAllTargetRelations("is_alias_explicit_of", "ALIAS");
-
-			
-			this.entity = getWrapper().saveEntityAsNew(this.entity, user.getEmail());
-			//((AllTextsBean) this.getSessionBean("AllTexts")).setAllTextsAsDirty();
-			this.getAppBean().setAllTextsAsDirty();
-			getAppBean().getSimpleSearchCache().setMapDirty(true);
-
-			//lastAction = "save text as new entity";
-			getSessionBean().setEditFormCurrentEntId(this.entity.getId());
-
-			logger.info("The entity was saved successfully!!!" + this.entity);
-			//this.saveAsNew = false;
-
-			//setActionInfo(lastAction);
-
-			
-		} catch (Exception e) {
-			logger.error(e.getMessage(), e);
-			e.printStackTrace();
-			this.printInternalError(e);
-		}
-		return PAGE_EDITOR;
-	}
-
-	/**
-	 * Refresh aliasMap: delete the tuples, which are ticked to be deleted.
-	 * 
-	 * @param map
-	 * @return
-	 */
-	private Map<Long, Boolean> refreshAliasMap(List<Entity> list, Map<Long, Boolean> aliasesMap){
-		for(Long id : aliasesMap.keySet()){
-			if(aliasesMap.get(id)){
-				aliasesMap.remove(id);
-				Entity alias = getEntityById(list, id);
-				if(alias != null){
-					list.remove(alias);
-				}
-			}
-		}	
-		return aliasesMap;
-	}
-
 	public Attribute getAttTitleAlias() {
 		return attTitleAlias;
 	}
@@ -819,82 +721,6 @@
 		return newTitleAlias;
 	}
 
-	/**
-	 * <p>This method saves transiently the aliases as new Entities, which are not marked to be deleted 
-	 * in aliasesMap.</p>
-	 * 
-	 * @param aliases list of aliases showing in the interface.
-	 * @param aliasesMap map id - boolean, which indicates if the alias[id] should be deleted(true).
-	 * @param aliasRelationName name of the relation which links this text whith the given alias list.
-	 * @param user
-	 */
-	/*
-	private void saveAliasesAsNew(List<Entity> aliases,
-			Map<Long, Boolean> aliasesMap, String aliasRelationName, String user) {
-		
-		//first step: save the alias, if it is ticked as 'no delete'
-		for(Long aliasId : aliasesMap.keySet()){
-			if(!aliasesMap.get(aliasId)){
-				Entity alias = getEntityById(aliases, new Long(aliasId));
-				if(alias != null){
-					alias.removeAllSourceRelations(aliasRelationName, TEXT);
-					Relation rel = new Relation(alias, this.entity, aliasRelationName);
-					getWrapper().saveEntityAsNew(alias, user);	
-				}	
-			}
-		}
-	}*/
-	
-	/**
-	 * <p>This method removes transiently the aliases, which are marked to be deleted
-	 * and insert to the text the alias, which are not yet contained.</p> 
-	 * 
-	 * @param aliases list of aliases showing in the interface.
-	 * @param aliasesMap map id - boolean, which indicates if the alias[id] should be deleted(true).
-	 * @param aliasRelationName name of the relation which links this text whith the given alias list.
-	 */
-	/*
-	private void saveAliases2(List<Entity> aliases,
-			Map<Long, Boolean> aliasesMap, String aliasRelationName) {
-		
-		List<Relation> aliasRelList = this.entity.getTargetRelations(aliasRelationName, "ALIAS");
-		
-		//first step: delete aliases, which are ticked to be deleted and are contained by the current text
-		for(Relation aliasRel : aliasRelList){
-			//if the alias Map does not contain the 'relation source' or it is marked to be deleted, 
-			//the relation should be removed from the text
-			if(!aliasesMap.containsKey(aliasRel.getSourceId()) || aliasesMap.get(aliasRel.getSourceId())){
-				text.removeTargetRelation(aliasRel);
-			}
-		}
-		
-		//second step: insert alias (as relation) to the text, 
-		//if the alias is not contained by the text
-		for(Long aliasId : aliasesMap.keySet()){
-			if(!aliasesMap.get(aliasId)){
-				if(!text.containsTargetRelation(aliasRelationName, new Long(aliasId))){
-					Entity alias = getEntityById(aliases, new Long(aliasId));
-					if(alias != null){
-						Relation rel = new Relation(alias, this.entity, aliasRelationName);
-					}
-				}	
-			}
-		}
-	}*/
-	
-	/**
-	 * TODO move this method to some util's package
-	 * @return
-	 */
-	private Entity getEntityById(List<Entity> list, Long id){
-		for(Entity e : list){
-			if(e.getId().compareTo(id) == 0){
-				return e;
-			}
-		}		
-		return null;
-	}
-
 	public Map<Long, Boolean> getDeletedIncipitAliases() {
 		return deletedIncipitAliases;
 	}
@@ -1097,11 +923,11 @@
 		this.selectedPersonId = selectedPersonId;
 	}
 
-	public EndNoteMisattributionTable getMisattTable() {
+	public MisattributionTable getMisattTable() {
 		return misattTable;
 	}
 
-	public void setMisattTable(EndNoteMisattributionTable misattTable) {
+	public void setMisattTable(MisattributionTable misattTable) {
 		this.misattTable = misattTable;
 	}
 
--- a/src/main/java/de/mpiwg/itgroup/ismi/merge/GeneralMerge.java	Wed Oct 12 15:34:49 2016 +0200
+++ b/src/main/java/de/mpiwg/itgroup/ismi/merge/GeneralMerge.java	Wed Oct 12 20:50:30 2016 +0200
@@ -219,7 +219,7 @@
 				this.getWrapper().removeCurrentVersionEntity(this.secondEntity);
 				
 				//the old relations should be removed, before...
-				this.generateSecundaryOW(this.entResult, getSessionUser().getEmail() + "_merge");
+				this.updateRelatedOW(this.entResult, getSessionUser().getEmail() + "_merge");
 				
 				this.printMergeInfo(entResult);
 				
--- a/src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/EndNoteMisattribution.java	Wed Oct 12 15:34:49 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-package de.mpiwg.itgroup.ismi.util.guiComponents;
-
-import java.io.Serializable;
-import java.util.List;
-
-import org.mpi.openmind.cache.WrapperService;
-import org.mpi.openmind.repository.bo.Entity;
-import org.mpi.openmind.repository.bo.Node;
-import org.mpi.openmind.repository.bo.Relation;
-
-public class EndNoteMisattribution implements Serializable {
-	private static final long serialVersionUID = -1840193000833171154L;
-
-	public static String MISATT = "MISATTRIBUTION";
-	public static String MISATTRIBUTED_TO = "misattributed_to";
-	public static String IS_REFERENCE_OF = "is_reference_of";
-	public static String HAS_AUTHOR_MISATT = "has_author_misattribution"; 
-	
-	private Entity misatt;
-	private Entity person;
-	private Reference ref;
-	private WrapperService ot;
-	private String userName;
-	
-	public EndNoteMisattribution(WrapperService ot, String userName){
-		this.ot = ot;
-		this.userName = userName;
-	}
-	
-	public Entity saveAndGetMisattribution(Entity text) throws Exception{
-		
-		if(misatt == null){
-			misatt = new Entity(Node.TYPE_ABOX, MISATT, false);
-		}
-		
-		Entity entityRef = this.ref.getEnt();
-		ot.saveAssertion(entityRef, userName);
-		
-		this.misatt.removeAllSourceRelations(MISATTRIBUTED_TO, "PERSON");
-		Relation rel0 = new Relation(misatt, person, MISATTRIBUTED_TO);
-		
-		this.misatt.removeAllTargetRelations(IS_REFERENCE_OF, "REFERENCE");
-		Relation rel1 = new Relation(entityRef, misatt, IS_REFERENCE_OF);
-		
-		this.misatt.removeAllTargetRelations(HAS_AUTHOR_MISATT, "TEXT");
-		Relation rel2 = new Relation(text, misatt, HAS_AUTHOR_MISATT);
-		
-		
-		ot.saveAssertion(misatt, userName);
-		
-		return text;
-	}
-	
-	public static EndNoteMisattribution create(Entity person, WrapperService ot, String userName) {
-		EndNoteMisattribution obj = new EndNoteMisattribution(ot, userName);
-		
-		obj.setPerson(person);
-		obj.setRef(new Reference(null));
-		
-		return obj;
-	}
-	
-	public static EndNoteMisattribution load(Entity misatt, WrapperService ot, String userName) throws Exception{
-		
-		EndNoteMisattribution obj = new EndNoteMisattribution(ot, userName); 
-		
-		if(misatt.isLightweight()){
-			obj.setMisatt(ot.getEntityByIdWithContent(misatt.getId()));
-		}
-		//loading person. Person can be Light Weight
-		List<Entity> tmpList = ot.getTargetsForSourceRelation(misatt, MISATTRIBUTED_TO, "PERSON", -1);
-		if(tmpList.size() > 1){
-			throw new Exception("Misattribution (entity) can not has more than one person associated. " + misatt.toString());
-		}else if(tmpList.size() > 0){
-			obj.setPerson(tmpList.get(0));
-		}		
-		
-		tmpList = ot.getSourcesForTargetRelation(misatt, IS_REFERENCE_OF, "REFERENCE", -1);
-		if(tmpList.size() > 0){
-			Entity ref = tmpList.get(0);
-			if(ref.isLightweight()){
-				ref = ot.getEntityByIdWithContent(ref.getId());
-			}
-			obj.setRef(new Reference(ref));
-		}		
-		
-		//this.person = person;
-		//this.ref = new Reference(ref);
-		return obj;
-	}
-	
-	public Entity getPerson() {
-		return person;
-	}
-	public void setPerson(Entity person) {
-		this.person = person;
-	}
-	public Reference getRef() {
-		return ref;
-	}
-	public void setRef(Reference ref) {
-		this.ref = ref;
-	}
-	public Entity getMisatt() {
-		return misatt;
-	}
-	public void setMisatt(Entity misatt) {
-		this.misatt = misatt;
-	}
-	
-}
--- a/src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/EndNoteMisattributionTable.java	Wed Oct 12 15:34:49 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-package de.mpiwg.itgroup.ismi.util.guiComponents;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.faces.event.ActionEvent;
-import javax.faces.event.ValueChangeEvent;
-
-import org.mpi.openmind.repository.bo.Entity;
-import org.mpi.openmind.repository.bo.Relation;
-
-import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject;
-import de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean;
-import de.mpiwg.itgroup.ismi.utils.SelectableObject;
-
-public class EndNoteMisattributionTable extends AbstractISMIBean{
-	private static final long serialVersionUID = -2756216426560705499L;
-
-	private List<SelectableObject<EndNoteMisattribution>> list = new ArrayList<SelectableObject<EndNoteMisattribution>>();
-	
-	private EndNoteMisattribution misatt;
-	
-	private ListenerObject lo = new ListenerObject(PERSON, "name_translit");
-	//private String attName;
-	//private String oc;
-	
-	public EndNoteMisattributionTable(){
-		/*
-		this.attName = attName;
-		this.oc = oc;
-		*/
-	}
-	
-	public void listenerRemove(ActionEvent event){		
-		List<SelectableObject<EndNoteMisattribution>> toDelete = new ArrayList<SelectableObject<EndNoteMisattribution>>();
-		
-		for(SelectableObject<EndNoteMisattribution> so : this.list){
-			if(so.isSelected()){
-				toDelete.add(so);
-			}
-		}
-		for(SelectableObject<EndNoteMisattribution> so : toDelete){
-			this.list.remove(so);
-		}
-	}
-	
-	public void listenerEditRef(ActionEvent event){
-		SelectableObject<EndNoteMisattribution> so = 
-			(SelectableObject<EndNoteMisattribution>)getRequestBean("item");
-		if(so != null){
-			this.misatt = so.getObj();
-		}
-	}
-	
-	public void listenerSaveRef(ActionEvent event){
-		this.misatt = null;
-	}
-	
-	public void listenerCancel(ActionEvent event){
-		//@TODO
-	}
-	
-	public void listenerCreate(ActionEvent event){
-		if(this.lo.entity != null & this.lo.entity.isPersistent()){
-			this.create(this.lo.entity);	
-		}
-	}
-	
-	public void load(Entity misattEntity){
-		if(!containsEntity(misattEntity)){
-			//TODO sort
-			//Collections.sort(this.misattList);
-			try {
-				this.list.add(new SelectableObject<EndNoteMisattribution>(EndNoteMisattribution.load(misattEntity, getWrapper(), getUserName())));
-			} catch (Exception e) {
-				addErrorMsg(e.getMessage());
-				e.printStackTrace();
-			}
-		}else{
-			addGeneralMsg("This entity has been already inserted!");
-		}
-	}
-	
-	public void create(Entity person){
-		try {
-			this.list.add(new SelectableObject<EndNoteMisattribution>(EndNoteMisattribution.create(person, getWrapper(), getUserName())));
-		} catch (Exception e) {
-			addErrorMsg(e.getMessage());
-			e.printStackTrace();
-		}
-	}
-	
-	private boolean containsEntity(Entity ent){
-		for(SelectableObject<EndNoteMisattribution> so : this.list){
-			if(so.getObj().getPerson() != null && so.getObj().getPerson().getId().equals(ent.getId())){
-				return true;
-			}
-		}
-		return false;
-	}
-	
-	/*
-	public void listenerChanged(ValueChangeEvent event) {
-		this.lo = changeListener(event, lo, this.oc, this.attName);
-		if(lo.entity != null && lo.entity.isPersistent()){
-			lo.statusImage.setStatus(StatusImage.STATUS_OK);
-		}else{
-			lo.statusImage.setStatus(StatusImage.STATUS_UNSET);
-		}
-	}
-	*/
-
-	
-	public Entity saveMisattributions(Entity text) throws Exception{
-		for(EndNoteMisattribution misatt : this.getMisattList()){
-			text = misatt.saveAndGetMisattribution(text);
-		}
-		return text;
-	}
-	
-	
-	private List<EndNoteMisattribution> getMisattList(){
-		List<EndNoteMisattribution> list = new ArrayList<EndNoteMisattribution>();
-		for(SelectableObject<EndNoteMisattribution> so : this.list){
-			list.add(so.getObj());
-		}
-		return list;
-	}
-	
-	public List<SelectableObject<EndNoteMisattribution>> getList() {
-		return list;
-	}
-
-	public void setList(List<SelectableObject<EndNoteMisattribution>> list) {
-		this.list = list;
-	}
-
-	public EndNoteMisattribution getMisatt() {
-		return misatt;
-	}
-
-	public void setMisatt(EndNoteMisattribution misatt) {
-		this.misatt = misatt;
-	}
-
-	public ListenerObject getLo() {
-		return lo;
-	}
-
-	public void setLo(ListenerObject lo) {
-		this.lo = lo;
-	}
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/Misattribution.java	Wed Oct 12 20:50:30 2016 +0200
@@ -0,0 +1,116 @@
+package de.mpiwg.itgroup.ismi.util.guiComponents;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.mpi.openmind.cache.WrapperService;
+import org.mpi.openmind.repository.bo.Entity;
+import org.mpi.openmind.repository.bo.Node;
+import org.mpi.openmind.repository.bo.Relation;
+
+public class Misattribution implements Serializable {
+	private static final long serialVersionUID = -1840193000833171154L;
+
+	public static String MISATT = "MISATTRIBUTION";
+	public static String MISATTRIBUTED_TO = "misattributed_to";
+	public static String IS_REFERENCE_OF = "is_reference_of";
+	public static String HAS_AUTHOR_MISATT = "has_author_misattribution"; 
+	
+	private Entity misatt;
+	private Entity person;
+	private Reference ref;
+	private WrapperService ot;
+	private String userName;
+	
+	public Misattribution(WrapperService ot, String userName){
+		this.ot = ot;
+		this.userName = userName;
+	}
+	
+	public Entity saveAndGetMisattribution(Entity text) throws Exception{
+
+	    // create misattribution if necessary
+		if(misatt == null){
+			misatt = new Entity(Node.TYPE_ABOX, MISATT, false);
+		}
+		
+		// save reference
+		Entity entityRef = this.ref.getEnt();
+		ot.saveEntity(entityRef, userName);
+
+		// set person relation to misattribution
+		this.misatt.removeAllSourceRelations(MISATTRIBUTED_TO, "PERSON");
+		new Relation(misatt, person, MISATTRIBUTED_TO);
+		
+		// set reference relation to misattribution
+		this.misatt.removeAllTargetRelations(IS_REFERENCE_OF, "REFERENCE");
+		new Relation(entityRef, misatt, IS_REFERENCE_OF);
+		
+		// set text relation to misattribution
+		this.misatt.removeAllTargetRelations(HAS_AUTHOR_MISATT, "TEXT");
+		new Relation(text, misatt, HAS_AUTHOR_MISATT);
+		
+		// save misattribution
+		ot.saveEntity(misatt, userName);
+		
+		return text;
+	}
+	
+	public static Misattribution create(Entity person, WrapperService ot, String userName) {
+		Misattribution obj = new Misattribution(ot, userName);
+		
+		obj.setPerson(person);
+		obj.setRef(new Reference(null));
+		
+		return obj;
+	}
+	
+	public static Misattribution load(Entity misatt, WrapperService ot, String userName) throws Exception{
+		
+		Misattribution obj = new Misattribution(ot, userName); 
+		
+		if(misatt.isLightweight()){
+			obj.setMisatt(ot.getEntityByIdWithContent(misatt.getId()));
+		}
+		//loading person. Person can be Light Weight
+		List<Entity> tmpList = ot.getTargetsForSourceRelation(misatt, MISATTRIBUTED_TO, "PERSON", -1);
+		if(tmpList.size() > 1){
+			throw new Exception("Misattribution (entity) can not has more than one person associated. " + misatt.toString());
+		}else if(tmpList.size() > 0){
+			obj.setPerson(tmpList.get(0));
+		}		
+		
+		tmpList = ot.getSourcesForTargetRelation(misatt, IS_REFERENCE_OF, "REFERENCE", -1);
+		if(tmpList.size() > 0){
+			Entity ref = tmpList.get(0);
+			if(ref.isLightweight()){
+				ref = ot.getEntityByIdWithContent(ref.getId());
+			}
+			obj.setRef(new Reference(ref));
+		}		
+		
+		//this.person = person;
+		//this.ref = new Reference(ref);
+		return obj;
+	}
+	
+	public Entity getPerson() {
+		return person;
+	}
+	public void setPerson(Entity person) {
+		this.person = person;
+	}
+	public Reference getRef() {
+		return ref;
+	}
+	public void setRef(Reference ref) {
+		this.ref = ref;
+	}
+	public Entity getMisatt() {
+		return misatt;
+	}
+	public void setMisatt(Entity misatt) {
+		this.misatt = misatt;
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/MisattributionTable.java	Wed Oct 12 20:50:30 2016 +0200
@@ -0,0 +1,158 @@
+package de.mpiwg.itgroup.ismi.util.guiComponents;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.event.ActionEvent;
+
+import org.mpi.openmind.repository.bo.Entity;
+
+import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject;
+import de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean;
+import de.mpiwg.itgroup.ismi.utils.SelectableObject;
+
+public class MisattributionTable extends AbstractISMIBean{
+	private static final long serialVersionUID = -2756216426560705499L;
+
+	private List<SelectableObject<Misattribution>> list = new ArrayList<SelectableObject<Misattribution>>();
+	
+	private Misattribution misatt;
+	
+	private ListenerObject lo = new ListenerObject(PERSON, "name_translit");
+	//private String attName;
+	//private String oc;
+	
+	public MisattributionTable(){
+		/*
+		this.attName = attName;
+		this.oc = oc;
+		*/
+	}
+	
+	public void listenerRemove(ActionEvent event){		
+		List<SelectableObject<Misattribution>> toDelete = new ArrayList<SelectableObject<Misattribution>>();
+		
+		for(SelectableObject<Misattribution> so : this.list){
+			if(so.isSelected()){
+				toDelete.add(so);
+			}
+		}
+		for(SelectableObject<Misattribution> so : toDelete){
+			this.list.remove(so);
+		}
+	}
+	
+	public void listenerEditRef(ActionEvent event){
+		SelectableObject<Misattribution> so = 
+			(SelectableObject<Misattribution>)getRequestBean("item");
+		if(so != null){
+			this.misatt = so.getObj();
+		}
+	}
+	
+	public void listenerSaveRef(ActionEvent event){
+		this.misatt = null;
+	}
+	
+	public void listenerCancel(ActionEvent event){
+		//@TODO
+	}
+	
+	public void listenerCreate(ActionEvent event){
+		if(this.lo.entity != null & this.lo.entity.isPersistent()){
+			this.create(this.lo.entity);	
+		}
+	}
+	
+	public void load(Entity misattEntity){
+		if(!containsEntity(misattEntity)){
+			//TODO sort
+			//Collections.sort(this.misattList);
+			try {
+				this.list.add(new SelectableObject<Misattribution>(Misattribution.load(misattEntity, getWrapper(), getUserName())));
+			} catch (Exception e) {
+				addErrorMsg(e.getMessage());
+				e.printStackTrace();
+			}
+		}else{
+			addGeneralMsg("This entity has been already inserted!");
+		}
+	}
+	
+	public void create(Entity person){
+		try {
+			this.list.add(new SelectableObject<Misattribution>(Misattribution.create(person, getWrapper(), getUserName())));
+		} catch (Exception e) {
+			addErrorMsg(e.getMessage());
+			e.printStackTrace();
+		}
+	}
+	
+	private boolean containsEntity(Entity ent){
+		for(SelectableObject<Misattribution> so : this.list){
+			if(so.getObj().getPerson() != null && so.getObj().getPerson().getId().equals(ent.getId())){
+				return true;
+			}
+		}
+		return false;
+	}
+	
+	/*
+	public void listenerChanged(ValueChangeEvent event) {
+		this.lo = changeListener(event, lo, this.oc, this.attName);
+		if(lo.entity != null && lo.entity.isPersistent()){
+			lo.statusImage.setStatus(StatusImage.STATUS_OK);
+		}else{
+			lo.statusImage.setStatus(StatusImage.STATUS_UNSET);
+		}
+	}
+	*/
+
+	
+	/**
+	 * Save all misattributions.
+	 * 
+	 * @param text
+	 * @return
+	 * @throws Exception
+	 */
+	public Entity saveMisattributions(Entity text) throws Exception{
+		for(Misattribution misatt : this.getMisattList()){
+			text = misatt.saveAndGetMisattribution(text);
+		}
+		return text;
+	}
+	
+	
+	private List<Misattribution> getMisattList(){
+		List<Misattribution> list = new ArrayList<Misattribution>();
+		for(SelectableObject<Misattribution> so : this.list){
+			list.add(so.getObj());
+		}
+		return list;
+	}
+	
+	public List<SelectableObject<Misattribution>> getList() {
+		return list;
+	}
+
+	public void setList(List<SelectableObject<Misattribution>> list) {
+		this.list = list;
+	}
+
+	public Misattribution getMisatt() {
+		return misatt;
+	}
+
+	public void setMisatt(Misattribution misatt) {
+		this.misatt = misatt;
+	}
+
+	public ListenerObject getLo() {
+		return lo;
+	}
+
+	public void setLo(ListenerObject lo) {
+		this.lo = lo;
+	}
+}