changeset 87:545e47659e1f

Merging references works now.
author casties
date Thu, 06 Oct 2016 18:01:59 +0200
parents 017f8ff46e50
children 8d93f3a0108f
files src/main/java/de/mpiwg/itgroup/ismi/merge/ReferenceMerge.java src/main/webapp/merge/referenceMerge.xhtml
diffstat 2 files changed, 139 insertions(+), 697 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/merge/ReferenceMerge.java	Wed Oct 05 15:36:46 2016 +0200
+++ b/src/main/java/de/mpiwg/itgroup/ismi/merge/ReferenceMerge.java	Thu Oct 06 18:01:59 2016 +0200
@@ -7,9 +7,7 @@
 import java.util.Map;
 
 import javax.faces.event.ActionEvent;
-import javax.faces.model.SelectItem;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.mpi.openmind.repository.bo.Attribute;
 import org.mpi.openmind.repository.bo.Entity;
@@ -23,46 +21,31 @@
 	private static Logger logger = Logger.getLogger(ReferenceMerge.class);
 	
 	private static final long serialVersionUID = 1L;
-	public static String FIRST_VALUE = "first value";
-	public static String SECOND_VALUE = "second value";
-	public static String IGNORE = "ignore";
-	public static String TAKE = "take";	
-
-	private boolean showAttributeMapping = false;
-	private boolean showSrcRelationMapping = false;
-	private boolean showTarRelationMapping = false;
 
 	private boolean entitiesLoaded = false;
 
-	private Map<String, String> firstAttMap = new HashMap<String, String>();
-	private Map<String, String> secondAttMap = new HashMap<String, String>();
-
 	private Entity firstEntity;
 	private String firstBibId;
+	private String firstEndnoteContent;
+	
 	private Entity secondEntity;
     private String secondBibId;
 	
 	private Map<Entity, Attribute> firstEntityMap;
     private Map<Entity, Attribute> secondEntityMap;
 	
+    private List<Map<String, String>> previewResults;
+    
 	private String firstId;
 	private String secondId;
 	
-	private Entity entResult;
-	private List<Attribute> resultAtts;
-	private List<Relation> resultSrcRels;
-	private List<Relation> resultTarRels;
-	
-	private List<String> attLabels;
-	private Map<String, String> selectedAtts;
-
-	Map<Long, String> selectedFirstSrcRelations;
-	Map<Long, String> selectedSecondSrcRelations;
-	Map<Long, String> selectedFirstTarRelations;
-	Map<Long, String> selectedSecondTarRelations;
-	
-	public ReferenceMerge(){}
-	
+	/**
+	 * Load the first reference by its endnote-id.
+	 * 
+	 * Start the merge preview if the second reference has already been loaded.
+	 * 
+	 * @param event
+	 */
 	public void loadFirstEntity(ActionEvent event){
 		reset();
 		try{
@@ -82,7 +65,7 @@
                 
                 if(this.secondEntityMap != null && ! this.secondEntityMap.isEmpty()){
                     // continue merge
-                    this.deployDifferences();
+                    this.previewDifferences();
                 }
 			}
 		} catch(Exception e) {
@@ -90,6 +73,13 @@
 		}
 	}
 	
+    /**
+     * Load the second reference by its endnote-id.
+     * 
+     * Start the merge preview if the first reference has already been loaded.
+     * 
+     * @param event
+     */
 	public void loadSecondEntity(ActionEvent event){
 		reset();
 		try{
@@ -109,7 +99,7 @@
 
                 if(this.firstEntityMap != null && ! this.firstEntityMap.isEmpty()){
                     // continue merge
-                    this.deployDifferences();
+                    this.previewDifferences();
                 }
             }
 		}catch(Exception e){
@@ -118,19 +108,9 @@
 	}
 	
 	@Override
-	public void reset(){
-		this.attLabels = new ArrayList<String>();
-		this.selectedAtts = new HashMap<String, String>();
-		this.selectedFirstSrcRelations = new HashMap<Long, String>();
-		this.selectedSecondSrcRelations = new HashMap<Long, String>();
-		this.selectedFirstTarRelations = new HashMap<Long, String>();
-		this.selectedSecondTarRelations = new HashMap<Long, String>();
-		this.entResult = null;
-		
+	public void reset(){		
 		this.entitiesLoaded = false;
-		this.showAttributeMapping = false;
-		this.showSrcRelationMapping = false;
-		this.showTarRelationMapping = false;
+		this.previewResults = null;
 	}
 
 	public void listenerExecuteMerge(){
@@ -138,312 +118,108 @@
 		getAppBean().getSimpleSearchCache().setMapDirty(true);
 	}
 	
-	private void deployDifferences(){
-		this.showAttributeMapping = true;
-		this.showSrcRelationMapping = true;
-		this.showTarRelationMapping = true;
+	/**
+	 * Creates preview result list of the changes in the references.
+	 */
+	private void previewDifferences() {
 		this.entitiesLoaded = true;
+
 		if(this.firstEntity != null && this.secondEntity != null){
 		    
-            this.attLabels = new ArrayList<String>();
+            this.previewResults = new ArrayList<Map<String, String>>();
+            
+            if (firstEntity.isLightweight()) {
+                firstEntity = getWrapper().getEntityContent(firstEntity);
+            }
+            Attribute ecAtt = firstEntity.getAttributeByName("endnote-content");
+            firstEndnoteContent = (ecAtt != null) ? ecAtt.getValue() : "";
 
             for (Entity ent : this.secondEntityMap.keySet()) {
 
+                HashMap<String, String> preview = new HashMap<String,String>();
+                
+                // insert content from first entity
+                preview.put("new-bib-id", firstBibId);
+                preview.put("new-endnote-content", firstEndnoteContent);
+                
+                // fetch content for second entity
                 if (ent.isLightweight()) {
                     ent = getWrapper().getEntityContent(ent);
                 }
                 String id = ent.getId().toString();
-                attLabels.add(id);
-                firstAttMap.put(id, firstEntity.getAttributeByName("endnote-id").getValue());
-                secondAttMap.put(id, ent.getAttributeByName("endnote-id").getValue());
+                preview.put("id", id);                
+                Attribute bibidAtt = ent.getAttributeByName("endnote-id");
+                preview.put("old-bib-id", bibidAtt.getValue());
+                Attribute aiAtt = ent.getAttributeByName("additional_information");
+                if (aiAtt != null) {
+                    preview.put("additional-information", aiAtt.getValue());
+                }
+                
+                // get relations
+                String relatedEnts = "";
+                for (Relation rel : ent.getSourceRelations()) {
+                    relatedEnts += rel.getObjectClass() + " ";
+                    Entity relEnt = getWrapper().getEntityById(rel.getTargetId());
+                    relatedEnts += "[" + relEnt.getObjectClass() + "] ";
+                    relatedEnts += relEnt.getOwnValue() + " ";
+                    relatedEnts += "[" + relEnt.getId() + "] ";
+                }
+                preview.put("related-entities", relatedEnts);
+                
+                previewResults.add(preview);
             }
             
-            /*
-			if(secondEntity.isLightweight()){
-				this.secondEntity = getWrapper().getEntityContent(this.secondEntity);
-			}			
-			
-			this.firstEntity = (Entity)firstEntity.clone();
-			this.secondEntity = (Entity) secondEntity.clone();
-			
-			//attributes
-			this.attLabels = new ArrayList<String>();
-			this.selectedAtts = new HashMap<String, String>();
-			this.firstAttMap = new HashMap<String, String>();
-			this.secondAttMap = new HashMap<String, String>();
-			
-			for(Attribute att : this.firstEntity.getAttributes()){
-				firstAttMap.put(att.getName(), att.getValue());
-				if(!attLabels.contains(att.getName())){
-					attLabels.add(att.getName());
-					selectedAtts.put(att.getName(), FIRST_VALUE);
-				}
-			}
-			
-			for(Attribute att : this.secondEntity.getAttributes()){
-				secondAttMap.put(att.getName(), att.getValue());
-				if(!attLabels.contains(att.getName())){
-					attLabels.add(att.getName());
-					selectedAtts.put(att.getName(), FIRST_VALUE);
-				}
-			}			
-			
-			//source relations
-			this.selectedFirstSrcRelations = new HashMap<Long, String>();
-			this.selectedSecondSrcRelations = new HashMap<Long, String>();
-			
-			for(Relation rel : this.firstEntity.getSourceRelations()){
-				rel.setTarget(getWrapper().getEntityById(rel.getTargetId()));
-				selectedFirstSrcRelations.put(rel.getId(), TAKE);
-			}
-			
-			
-			for(Relation rel : this.secondEntity.getSourceRelations()){
-				rel.setTarget(getWrapper().getEntityById(rel.getTargetId()));
-				selectedSecondSrcRelations.put(rel.getId(), TAKE);
-			}
-			
-			//target relations
-			this.selectedFirstTarRelations = new HashMap<Long, String>();
-			this.selectedSecondTarRelations = new HashMap<Long, String>();
-			
-			for(Relation rel : this.firstEntity.getTargetRelations()){
-				rel.setSource(getWrapper().getEntityById(rel.getSourceId()));
-				selectedFirstTarRelations.put(rel.getId(), TAKE);
-			}
-			
-			for(Relation rel : this.secondEntity.getTargetRelations()){
-				rel.setSource(getWrapper().getEntityById(rel.getSourceId()));
-				selectedSecondTarRelations.put(rel.getId(), TAKE);
-			}
-			
-			*/
 		}
 	}
 	
-	public void preview(ActionEvent event){
-		this.generateResultEntity();
-	}
-	
-	private void executeMerge(){
+	/**
+	 * Execute the changes in the references.
+	 * 
+	 * Replaces the endnote-id and endnote-content attributes of the secondEntityMap
+	 * with the values of the firstEntity.
+	 */
+	private void executeMerge() {
 		
-		logger.info("Starting merge execution " + firstEntity.getObjectClass() 
+		logger.info("Starting reference merge execution " + firstEntity.getObjectClass() 
 				+ " ["+ getUserName() +"]"
 				+ "[firstEntity=" + firstEntity.getId() 
 				+ ", secondEntity=" + secondEntity.getId() + "]");
-		
 		try {
-			this.generateResultEntity();
-			if(this.entResult != null){
-				
-				this.printMergeInfo(entResult);
-				
-				this.getWrapper().saveEntity(this.entResult, getSessionUser().getEmail() + "_merge");
-				
-				this.getWrapper().removeCurrentVersionEntity(this.firstEntity);
-				this.getWrapper().removeCurrentVersionEntity(this.secondEntity);
-				
-				//the old relations should be removed, before...
-				this.generateSecundaryOW(this.entResult, getSessionUser().getEmail() + "_merge");
-				
-				this.printMergeInfo(entResult);
-				
-				logger.info("Merge execution 'successful' "  + 
-						firstEntity.getObjectClass() + 
-						" ["+ getUserName() +"]"
-						+ "[firstEntity=" + firstEntity.getId() 
-						+ ", secondEntity=" + secondEntity.getId() 
-						+ ", generatedEntity=" + entResult.getId() + "]");
-				
-				this.firstEntity = null;
-				this.secondEntity = null;
-				
-				addGeneralMsg("The entities were merged successfully");
-				addGeneralMsg("The new entity has the id " + this.entResult.getId());
-				this.reset();
-			}	
+		    
+		    for (Entity ent : secondEntityMap.keySet()) {
+		        // fetch content (should not be necessary)
+                if (ent.isLightweight()) {
+                    ent = getWrapper().getEntityContent(ent);
+                }
+		        
+                // replace endnote-id
+                Attribute bibidAtt = ent.getAttributeByName("endnote-id");
+                if (firstBibId != null) {
+                    bibidAtt.setOwnValue(firstBibId);
+                } else {
+                    throw new NullPointerException("Missing endnote-id to replace!");
+                }
+                // replace endnote-content
+                Attribute ecAtt = ent.getAttributeByName("endnote-content");
+                if (firstEndnoteContent != null) {
+                    ecAtt.setOwnValue(firstEndnoteContent);
+                } else {
+                    ecAtt.setOwnValue("");
+                }
+                
+                // save entity
+                this.getWrapper().saveEntity(ent, getSessionUser().getEmail() + "_merge");
+		    }
+
+		    addGeneralMsg(secondEntityMap.size() + " references were changed successfully");
+            this.reset();
+		    
 		} catch (Exception e) {
 			printInternalError(e);
 			logger.error("["+ getUserName() +"] " + e.getMessage(), e);			
 		}
 	}
 	
-	private void printMergeInfo(Entity ent){
-		StringBuilder sb = new StringBuilder("\n\n");
-		
-		sb.append("-------------------------------------------");
-		sb.append("-----------------------------------------\n");
-		sb.append("Merging result [" + getUserName() + "]\n");
-		sb.append(ent.toString() + "\n");
-		sb.append("Attributes:\n");
-		for(Attribute att : ent.getAttributes()){
-			sb.append("\t" + att.toString() + "\n");
-		}
-		
-		sb.append("Src Relations:\n");
-		for(Relation src : ent.getSourceRelations()){
-			sb.append("\t" + src.toString() + "\n");
-		}
-		
-		sb.append("Tar Relations:\n");
-		for(Relation tar : ent.getTargetRelations()){
-			sb.append("\t" + tar.toString() + "\n");
-		}
-		
-		sb.append("-------------------------------------------");
-		sb.append("-----------------------------------------\n");
-		logger.info(sb.toString());
-	}
-	
-	public void actionShowTarRelationMapping(ActionEvent event){
-		this.showTarRelationMapping = true;
-	}
-	
-	public void actionHideTarRelationMapping(ActionEvent event){
-		this.showTarRelationMapping = false;
-	}
-	
-	public void actionShowSrcRelationMapping(ActionEvent event){
-		this.showSrcRelationMapping = true;
-	}
-	
-	public void actionHideSrcRelationMapping(ActionEvent event){
-		this.showSrcRelationMapping = false;
-	}
-	
-	public void actionShowAttributeMapping(ActionEvent event){
-		this.showAttributeMapping = true;
-	}
-	
-	public void actionHideAttributeMapping(ActionEvent event){
-		this.showAttributeMapping = false;
-	}
-	
-	private void generateResultEntity(){
-		this.entResult = new Entity();
-		this.entResult.setLightweight(false);
-		this.entResult.setObjectClass(this.firstEntity.getObjectClass());
-		
-		//generating attributes
-		try{
-			for(String attName : this.selectedAtts.keySet()){
-				String selected = this.selectedAtts.get(attName);
-				String value = "";
-				if(selected.equals(FIRST_VALUE)){
-					value = (firstEntity.getAttributeByName(attName) == null) ? "" : firstEntity.getAttributeByName(attName).getOwnValue();
-				}else if(selected.equals(SECOND_VALUE)){
-					value = (secondEntity.getAttributeByName(attName) == null) ? "" : secondEntity.getAttributeByName(attName).getOwnValue();
-				}
-				this.entResult.addAttribute(new Attribute(attName, "text", value));
-			}
-		}catch(Exception e){
-			e.printStackTrace();
-			addErrorMsg("Please inform support of this exception: " + e.getMessage());
-		}
-
-		
-		//generating source relations
-		for(Relation rel : firstEntity.getSourceRelations()){
-			String selectedValue = this.selectedFirstSrcRelations.get(rel.getId());
-			if(StringUtils.isNotEmpty(selectedValue) && selectedValue.equals(TAKE)){
-				if(!this.entResult.containsSourceRelation(rel.getOwnValue(), rel.getTargetId())){
-					this.entResult.addSourceRelation(generateSrcRelation(rel));	
-				}
-			}
-		}
-		
-		for(Relation rel : secondEntity.getSourceRelations()){
-			String selectedValue = this.selectedSecondSrcRelations.get(rel.getId());
-			if(StringUtils.isNotEmpty(selectedValue) && selectedValue.equals(TAKE)){
-				if(!this.entResult.containsSourceRelation(rel.getOwnValue(), rel.getTargetId())){
-					this.entResult.addSourceRelation(generateSrcRelation(rel));
-				}
-			}
-		}
-		
-		//generating target relations
-		for(Relation rel : firstEntity.getTargetRelations()){
-			String selectedValue = this.selectedFirstTarRelations.get(rel.getId());
-			if(StringUtils.isNotEmpty(selectedValue) && selectedValue.equals(TAKE)){
-				//ensuring that there is no two equals relations.
-				if(!this.entResult.containsTargetRelation(rel.getOwnValue(), rel.getSourceId())){
-					this.entResult.addTargetRelation(generateTarRelation(rel));
-				}
-			}
-		}
-		
-		for(Relation rel : secondEntity.getTargetRelations()){
-			String selectedValue = this.selectedSecondTarRelations.get(rel.getId());
-			if(StringUtils.isNotEmpty(selectedValue) && selectedValue.equals(TAKE)){
-				if(!this.entResult.containsTargetRelation(rel.getOwnValue(), rel.getSourceId())){
-					this.entResult.addTargetRelation(generateTarRelation(rel));
-				}
-			}
-		}
-	}
-	
-	private Relation generateSrcRelation(Relation rel){
-		
-		Relation newRel = new Relation();
-		newRel.setOwnValue(rel.getOwnValue());
-		newRel.setTarget(getWrapper().getEntityById(rel.getTargetId()));
-		
-		return newRel;
-	}
-	
-	private Relation generateTarRelation(Relation rel){
-		Relation newRel = new Relation();
-		newRel.setOwnValue(rel.getOwnValue());
-		newRel.setSource(getWrapper().getEntityById(rel.getSourceId()));
-		return newRel;
-	}
-
-    public List<SelectItem> getAttSelectItems() {
-        List<SelectItem> items = new ArrayList<SelectItem>();
-        items.add(new SelectItem(FIRST_VALUE));
-        items.add(new SelectItem(SECOND_VALUE));
-        items.add(new SelectItem(IGNORE));
-        return items;
-    }
-    
-    public List<SelectItem> getRelSelectItems(){
-        List<SelectItem> items = new ArrayList<SelectItem>();
-        items.add(new SelectItem(TAKE));
-        items.add(new SelectItem(IGNORE));
-        return items;
-    }
-    
-	public Entity getEntResult() {
-		return entResult;
-	}
-
-	public void setEntResult(Entity entResult) {
-		this.entResult = entResult;
-	}
-
-	public List<Attribute> getResultAtts() {
-		return resultAtts;
-	}
-
-	public void setResultAtts(List<Attribute> resultAtts) {
-		this.resultAtts = resultAtts;
-	}
-
-	public List<Relation> getResultSrcRels() {
-		return resultSrcRels;
-	}
-
-	public void setResultSrcRels(List<Relation> resultSrcRels) {
-		this.resultSrcRels = resultSrcRels;
-	}
-
-	public List<Relation> getResultTarRels() {
-		return resultTarRels;
-	}
-
-	public void setResultTarRels(List<Relation> resultTarRels) {
-		this.resultTarRels = resultTarRels;
-	}
 	
 	public Entity getFirstEntity() {
 		return firstEntity;
@@ -477,46 +253,6 @@
 		this.secondId = secondId;
 	}
 	
-	public List<String> getAttLabels() {
-		return attLabels;
-	}
-
-	public void setAttLabels(List<String> attLabels) {
-		this.attLabels = attLabels;
-	}
-	
-	public Map<String, String> getFirstAttMap() {
-		return firstAttMap;
-	}
-
-	public void setFirstAttMap(Map<String, String> firstAttMap) {
-		this.firstAttMap = firstAttMap;
-	}
-
-	public Map<String, String> getSecondAttMap() {
-		return secondAttMap;
-	}
-
-	public void setSecondAttMap(Map<String, String> secondAttMap) {
-		this.secondAttMap = secondAttMap;
-	}
-
-	public Map<String, String> getSelectedAtts() {
-		return selectedAtts;
-	}
-
-	public void setSelectedAtts(Map<String, String> selectedAtts) {
-		this.selectedAtts = selectedAtts;
-	}
-	
-	public boolean isShowAttributeMapping() {
-		return showAttributeMapping;
-	}
-
-	public void setShowAttributeMapping(boolean showAttributeMapping) {
-		this.showAttributeMapping = showAttributeMapping;
-	}
-
 	public boolean isEntitiesLoaded() {
 		return entitiesLoaded;
 	}
@@ -525,90 +261,6 @@
 		this.entitiesLoaded = entitiesLoaded;
 	}
 	
-	public Map<Long, String> getSelectedFirstSrcRelations() {
-		return selectedFirstSrcRelations;
-	}
-
-	public void setSelectedFirstSrcRelations(
-			Map<Long, String> selectedFirstSrcRelations) {
-		this.selectedFirstSrcRelations = selectedFirstSrcRelations;
-	}
-
-	public Map<Long, String> getSelectedSecondSrcRelations() {
-		return selectedSecondSrcRelations;
-	}
-
-	public void setSelectedSecondSrcRelations(
-			Map<Long, String> selectedSecondSrcRelations) {
-		this.selectedSecondSrcRelations = selectedSecondSrcRelations;
-	}
-	public boolean isShowSrcRelationMapping() {
-		return showSrcRelationMapping;
-	}
-
-	public void setShowSrcRelationMapping(boolean showSrcRelationMapping) {
-		this.showSrcRelationMapping = showSrcRelationMapping;
-	}
-
-
-	public boolean isShowTarRelationMapping() {
-		return showTarRelationMapping;
-	}
-
-	public void setShowTarRelationMapping(boolean showTarRelationMapping) {
-		this.showTarRelationMapping = showTarRelationMapping;
-	}
-
-	public Map<Long, String> getSelectedFirstTarRelations() {
-		return selectedFirstTarRelations;
-	}
-
-	public void setSelectedFirstTarRelations(
-			Map<Long, String> selectedFirstTarRelations) {
-		this.selectedFirstTarRelations = selectedFirstTarRelations;
-	}
-
-	public Map<Long, String> getSelectedSecondTarRelations() {
-		return selectedSecondTarRelations;
-	}
-
-	public void setSelectedSecondTarRelations(
-			Map<Long, String> selectedSecondTarRelations) {
-		this.selectedSecondTarRelations = selectedSecondTarRelations;
-	}
-	/*
-	public String getMsg() {
-		return msg;
-	}
-
-	public void setMsg(String msg) {
-		this.msg = msg;
-	}
-
-	public boolean isShowMsgPopup() {
-		return showMsgPopup;
-	}
-
-	public void setShowMsgPopup(boolean showMsgPopup) {
-		this.showMsgPopup = showMsgPopup;
-	}
-
-	public String getConfirmMsg() {
-		return confirmMsg;
-	}
-
-	public void setConfirmMsg(String confirmMsg) {
-		this.confirmMsg = confirmMsg;
-	}
-
-	public boolean isShowConfirmPopup() {
-		return showConfirmPopup;
-	}
-
-	public void setShowConfirmPopup(boolean showConfirmPopup) {
-		this.showConfirmPopup = showConfirmPopup;
-	}
-	*/
 
     /**
      * @return the firstBibId
@@ -623,4 +275,11 @@
     public String getSecondBibId() {
         return secondBibId;
     }
+
+    /**
+     * @return the previewResults
+     */
+    public List<Map<String, String>> getPreviewResults() {
+        return previewResults;
+    }
 }
\ No newline at end of file
--- a/src/main/webapp/merge/referenceMerge.xhtml	Wed Oct 05 15:36:46 2016 +0200
+++ b/src/main/webapp/merge/referenceMerge.xhtml	Thu Oct 06 18:01:59 2016 +0200
@@ -13,7 +13,7 @@
 		<ui:define name="privateContent">
 			
 			<div id="pageTitle">
-				<h:outputText value="Join References" />
+				<h:outputText value="Join References (source overwrites target)" />
 			</div>
 
             <!-- TODO: fix this! -->
@@ -27,7 +27,7 @@
 				<h:panelGrid columns="2" styleClass="createPanel"
 					columnClasses="createPanelFirstColumn" id="loadingPanel">
 
-					<h:outputText value="Load Entities" />
+					<h:outputText value="Load References" />
 
 					<h:panelGrid columns="4">
 
@@ -81,7 +81,7 @@
 
 				<h:panelGrid columns="1" id="mergingPanel">
 
-					<h:outputText value="Merge Mapping"
+					<h:outputText value="Preview changed references"
 						rendered="#{Session.referenceMerge.entitiesLoaded}"
 						styleClass="titlePanel"/>
 
@@ -90,191 +90,58 @@
 						rendered="#{Session.referenceMerge.entitiesLoaded}">
 
 
-						<h:outputText value="Attributes" />
-						<rich:dataTable var="attName"
-							value="#{Session.referenceMerge.attLabels}"
-							rendered="#{!empty Session.referenceMerge.attLabels}">
+						<h:outputText value="References" />
+						<rich:dataTable var="result"
+							value="#{Session.referenceMerge.previewResults}"
+							rendered="#{!empty Session.referenceMerge.previewResults}">
 							<h:column>
 								<f:facet name="header">
-									<h:outputText value="Attribute Name" />
+									<h:outputText value="ID" />
 								</f:facet>
-								<h:outputText value="#{attName}" />
+								<h:outputText value="#{result['id']}" />
 							</h:column>
 							<h:column>
 								<f:facet name="header">
-									<h:outputText value="Value First Entity" />
+									<h:outputText value="Old biblio ID" />
 								</f:facet>
 								<h:outputText
-									value="#{Session.referenceMerge.firstAttMap[attName]}" />
+									value="#{result['old-bib-id']}" />
 							</h:column>
 							<h:column>
 								<f:facet name="header">
-									<h:outputText value="Value Second Entity" />
+									<h:outputText value="New biblio ID" />
 								</f:facet>
 								<h:outputText
-									value="#{Session.referenceMerge.secondAttMap[attName]}" />
+									value="#{result['new-bib-id']}" />
 							</h:column>
-							<h:column style="width:300px;">
-								<f:facet name="header">
-									<h:outputText value="Select Value" />
-								</f:facet>
-								<h:selectOneRadio
-									value="#{Session.referenceMerge.selectedAtts[attName]}">
-									<f:selectItems value="#{Session.referenceMerge.attSelectItems}" />
-								</h:selectOneRadio>
-							</h:column>
+                            <h:column>
+                                <f:facet name="header">
+                                    <h:outputText value="New biblio label" />
+                                </f:facet>
+                                <h:outputText
+                                    value="#{result['new-endnote-content']}" />
+                            </h:column>
+                            <h:column>
+                                <f:facet name="header">
+                                    <h:outputText value="Additional information" />
+                                </f:facet>
+                                <h:outputText
+                                    value="#{result['additional-information']}" />
+                            </h:column>
+                            <h:column>
+                                <f:facet name="header">
+                                    <h:outputText value="Relations" />
+                                </f:facet>
+                                <h:outputText
+                                    value="#{result['related-entities']}" />
+                            </h:column>
 						</rich:dataTable>
-						<h:outputText />
-
-						<h:outputText value="Source Relations" />
-
-						<h:panelGrid columns="1">
-							<rich:dataTable var="srcRelation"
-								rendered="#{!empty Session.referenceMerge.firstEntity.sourceRelations}"
-								value="#{Session.referenceMerge.firstEntity.sourceRelations}">
-
-								<h:column>
-									<f:facet name="header">
-										<h:outputText value="Relation Name" />
-									</f:facet>
-									<h:outputText value="#{srcRelation.ownValue}" />
-								</h:column>
-								<h:column>
-									<f:facet name="header">
-										<h:outputText value="linked to this" />
-									</f:facet>
-									<h:outputText
-										value="#{srcRelation.target.ownValue} [#{srcRelation.target.objectClass}-#{srcRelation.targetId}]" />
-								</h:column>
-
-								<h:column>
-									<h:selectOneRadio
-										value="#{Session.referenceMerge.selectedFirstSrcRelations[srcRelation.id]}">
-										<f:selectItems value="#{Session.referenceMerge.relSelectItems}" />
-									</h:selectOneRadio>
-								</h:column>
-
-							</rich:dataTable>
-
-							<h:outputText
-								value="the first entity does not have source relations"
-								rendered="#{empty Session.referenceMerge.firstEntity.sourceRelations}" />
-						</h:panelGrid>
-
-						<h:panelGrid columns="1">
 
-							<rich:dataTable var="srcRelation"
-								rendered="#{!empty Session.referenceMerge.secondEntity.sourceRelations}"
-								value="#{Session.referenceMerge.secondEntity.sourceRelations}">
-								<h:column>
-									<f:facet name="header">
-										<h:outputText value="Relation Name" />
-									</f:facet>
-									<h:outputText value="#{srcRelation.ownValue}" />
-								</h:column>
-								<h:column>
-									<f:facet name="header">
-										<h:outputText value="linked to this" />
-									</f:facet>
-									<h:outputText
-										value="#{srcRelation.target.ownValue} [#{srcRelation.target.objectClass}-#{srcRelation.targetId}]" />
-								</h:column>
-								<h:column>
-									<h:selectOneRadio
-										value="#{Session.referenceMerge.selectedSecondSrcRelations[srcRelation.id]}">
-										<f:selectItems value="#{Session.referenceMerge.relSelectItems}" />
-									</h:selectOneRadio>
-								</h:column>
-							</rich:dataTable>
-							
-							<h:outputText
-								value="The second entity does not have source relations"
-								rendered="#{empty Session.referenceMerge.secondEntity.sourceRelations}" />
-
-						</h:panelGrid>
-
-
-						<h:outputText value="Target Relations" />
-
-						<h:panelGrid columns="1">
-							<rich:dataTable var="tarRelation"
-								rendered="#{!empty Session.referenceMerge.firstEntity.targetRelations}"
-								value="#{Session.referenceMerge.firstEntity.targetRelations}"
-								style="width:60%;">
-
-								<h:column>
-									<f:facet name="header">
-										<h:outputText value="linked from this" />
-									</f:facet>
-									<h:outputText
-										value="#{tarRelation.source.ownValue} [#{tarRelation.source.objectClass}-#{tarRelation.sourceId}]" />
-								</h:column>
-
-								<h:column>
-									<f:facet name="header">
-										<h:outputText value="Relation Name" />
-									</f:facet>
-									<h:outputText value="#{tarRelation.ownValue}" />
-								</h:column>
-
-								<h:column>
-									<h:selectOneRadio
-										value="#{Session.referenceMerge.selectedFirstTarRelations[tarRelation.id]}">
-										<f:selectItems value="#{Session.referenceMerge.relSelectItems}" />
-									</h:selectOneRadio>
-								</h:column>
-							</rich:dataTable>
-							<h:outputText
-								value="the first entity does not have target relations."
-								rendered="#{empty Session.referenceMerge.firstEntity.targetRelations}" />
-						</h:panelGrid>
-
-						<h:panelGrid columns="1">
-
-							<rich:dataTable var="tarRelation"
-								rendered="#{!empty Session.referenceMerge.secondEntity.targetRelations}"
-								value="#{Session.referenceMerge.secondEntity.targetRelations}"
-								style="width:60%;">
-
-								<h:column>
-									<f:facet name="header">
-										<h:outputText value="linked from this" />
-									</f:facet>
-									<h:outputText
-										value="#{tarRelation.source.ownValue} [#{tarRelation.source.objectClass}-#{tarRelation.sourceId}]" />
-								</h:column>
-
-								<h:column>
-									<f:facet name="header">
-										<h:outputText value="Relation Name" />
-									</f:facet>
-									<h:outputText value="#{tarRelation.ownValue}" />
-								</h:column>
-
-								<h:column>
-									<h:selectOneRadio
-										value="#{Session.referenceMerge.selectedSecondTarRelations[tarRelation.id]}">
-										<f:selectItems value="#{Session.referenceMerge.relSelectItems}" />
-									</h:selectOneRadio>
-								</h:column>
-
-							</rich:dataTable>
-
-							<h:outputText
-								value="The second entity does not have target relations"
-								rendered="#{empty Session.referenceMerge.secondEntity.targetRelations}" />
-
-						</h:panelGrid>
 					</h:panelGrid>
 
 					<h:panelGrid columns="2" styleClass="controlPanel"
 						rendered="#{Session.referenceMerge.entitiesLoaded}">
 
-						<a4j:commandButton value="Preview"
-							actionListener="#{Session.referenceMerge.preview}"
-							rendered="#{Session.referenceMerge.entitiesLoaded}"
-							render="mergingPanel" />
-
 						<a4j:commandButton value="Execute Merge"
 							actionListener="#{Session.referenceMerge.listenerExecuteMerge }"
 							rendered="#{Session.referenceMerge.entitiesLoaded}"
@@ -284,90 +151,6 @@
 					</h:panelGrid>
 
 
-					<h:outputText value="Entity Preview"
-						rendered="#{!empty Session.referenceMerge.entResult}"
-						styleClass="titlePanel"/>
-					<h:panelGrid columns="2" styleClass="createPanel"
-						columnClasses="createPanelFirstColumn"
-						rendered="#{!empty Session.referenceMerge.entResult}">
-
-
-						<h:outputText value="Attributes" />
-						<rich:dataTable
-							value="#{Session.referenceMerge.entResult.attributes}"
-							var="attribute" border="1">
-							<h:column>
-								<f:facet name="header">
-									<h:outputText value="Name" />
-								</f:facet>
-								<h:outputText value="#{attribute.objectClass}" />
-							</h:column>
-							<h:column>
-								<f:facet name="header">
-									<h:outputText value="Value" />
-								</f:facet>
-								<h:outputText value="#{attribute.ownValue}" />
-							</h:column>
-						</rich:dataTable>
-
-
-						<h:outputText value="Source Relations" />
-						<rich:dataTable
-							value="#{Session.referenceMerge.entResult.sourceRelations}"
-							var="srcRelation" border="1">
-
-							<h:column>
-								<f:facet name="header">
-									<h:outputText value="linked from this" />
-								</f:facet>
-								<h:outputText value="#{'x'}" />
-							</h:column>
-
-							<h:column>
-								<f:facet name="header">
-									<h:outputText value="Relation Name" />
-								</f:facet>
-								<h:outputText value="#{srcRelation.ownValue}" />
-							</h:column>
-							<h:column>
-								<f:facet name="header">
-									<h:outputText value="linked to this" />
-								</f:facet>
-								<h:outputText
-									value="#{srcRelation.target.ownValue} [#{srcRelation.target.objectClass}]" />
-							</h:column>
-						</rich:dataTable>
-
-						<h:outputText value="Target Relations" />
-						<rich:dataTable
-							value="#{Session.referenceMerge.entResult.targetRelations}"
-							var="tarRelation" border="1">
-							<h:column>
-								<f:facet name="header">
-									<h:outputText value="linked from this" />
-								</f:facet>
-								<h:outputText
-									value="#{tarRelation.source.ownValue} [#{tarRelation.source.objectClass}]" />
-							</h:column>
-							<h:column>
-								<f:facet name="header">
-									<h:outputText value="Relation Name" />
-								</f:facet>
-								<h:outputText value="#{tarRelation.ownValue}" />
-							</h:column>
-							<h:column>
-								<f:facet name="header">
-									<h:outputText value="linked to this" />
-								</f:facet>
-								<h:outputText value="#{'x'}" />
-							</h:column>
-						</rich:dataTable>
-
-
-					</h:panelGrid>
-
-
-
 				</h:panelGrid>