changeset 25:c23ae718fdd3

clean up and more logging when saving attributes.
author Robert Casties <casties@mpiwg-berlin.mpg.de>
date Thu, 04 Aug 2016 21:16:08 +0200
parents 1c034e2f7367
children 5e24413d355b
files src/main/java/org/mpi/openmind/repository/bo/Attribute.java src/main/java/org/mpi/openmind/repository/bo/Entity.java src/main/java/org/mpi/openmind/repository/bo/Node.java src/main/java/org/mpi/openmind/repository/bo/Relation.java src/main/java/org/mpi/openmind/repository/bo/ViewerAttribute.java src/main/java/org/mpi/openmind/repository/bo/ViewerPage.java src/main/java/org/mpi/openmind/repository/services/AbstractPersistenceService.java
diffstat 7 files changed, 27 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/org/mpi/openmind/repository/bo/Attribute.java	Thu Aug 04 21:15:33 2016 +0200
+++ b/src/main/java/org/mpi/openmind/repository/bo/Attribute.java	Thu Aug 04 21:16:08 2016 +0200
@@ -205,8 +205,8 @@
 	}
     @Override
     public String toString() {
-        String rowIdString = (this.getRowId() == null) ? "" : "rowId= " + this.getRowId() + ", ";
-        String idString = (this.getId() == null) ? "" : "id= " + getId() + ", ";
+        String rowIdString = (this.getRowId() == null) ? "" : "rowId=" + this.getRowId() + ", ";
+        String idString = (this.getId() == null) ? "" : "id=" + getId() + ", ";
 
         return "Attribute[" + rowIdString + idString + "source=" + this.getSourceId() + ", name=" + this.getObjectClass() + ", ownValue=" + this.getOwnValue() + ", sysStatus=" + this.getSystemStatus() + "]";
     }
--- a/src/main/java/org/mpi/openmind/repository/bo/Entity.java	Thu Aug 04 21:15:33 2016 +0200
+++ b/src/main/java/org/mpi/openmind/repository/bo/Entity.java	Thu Aug 04 21:16:08 2016 +0200
@@ -960,21 +960,21 @@
     }
 
     public String toSmallString() {
-        String rowIdString = (this.getRowId() == null) ? "" : "rowId= " + this.getRowId() + ", ";
-        String idString = (this.getId() == null) ? "" : "id= " + getId() + ", ";
+        String rowIdString = (this.getRowId() == null) ? "" : "rowId=" + this.getRowId() + ", ";
+        String idString = (this.getId() == null) ? "" : "id=" + getId() + ", ";
 
-        return "Entity[" + rowIdString + idString + "objClass= " + this.getObjectClass() +  ", ownValue= " + this.getOwnValue() + "]";
+        return "Entity[" + rowIdString + idString + "objClass=" + this.getObjectClass() +  ", ownValue=" + this.getOwnValue() + "]";
     }
     
     @Override
     public String toString() {
-        String rowIdString = (this.getRowId() == null) ? "" : "rowId= " + this.getRowId() + ", ";
-        String idString = (this.getId() == null) ? "" : "id= " + getId() + ", ";
+        String rowIdString = (this.getRowId() == null) ? "" : "rowId=" + this.getRowId() + ", ";
+        String idString = (this.getId() == null) ? "" : "id=" + getId() + ", ";
 
         
         
         return "Entity[" + rowIdString + idString + "oc=" + this.getObjectClass() +  ", ov=" + this.getOwnValue() + ", user=" + getUser() +  ", sysStatus=" + this.getSystemStatus() +
-                ", type= " + this.getType() + " att.size= " + this.attributes.size() + "]";
+                ", type=" + this.getType() + " att.size=" + this.attributes.size() + "]";
     }
 
     public String getShortString(){
--- a/src/main/java/org/mpi/openmind/repository/bo/Node.java	Thu Aug 04 21:15:33 2016 +0200
+++ b/src/main/java/org/mpi/openmind/repository/bo/Node.java	Thu Aug 04 21:16:08 2016 +0200
@@ -2,9 +2,7 @@
 
 import java.io.Serializable;
 import java.text.DateFormat;
-import java.text.Normalizer;
 import java.text.SimpleDateFormat;
-import java.text.Normalizer.Form;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -22,7 +20,6 @@
 import javax.persistence.Table;
 import javax.persistence.Transient;
 
-import org.hibernate.annotations.Type;
 import org.mpi.openmind.repository.utils.ArabicNormalizerUtils;
 import org.mpi.openmind.repository.utils.NormalizerUtils;
 import org.mpi.openmind.repository.utils.RomanizationLoC;
@@ -360,9 +357,9 @@
 
     @Override
     public String toString() {
-    	String rowIdString = (this.getRowId() == null) ? "" : "rowId= " + this.getRowId() + ", ";
-    	String idString = (this.getId() == null) ? "" : "id= " + getId() + ", ";
+    	String rowIdString = (this.getRowId() == null) ? "" : "rowId=" + this.getRowId() + ", ";
+    	String idString = (this.getId() == null) ? "" : "id=" + getId() + ", ";
     	
-        return "Node[" + rowIdString + idString + "name= " + this.getObjectClass() + ", ownValue= " + this.getOwnValue() + ", sysStatus= " + this.getSystemStatus() + "]";
+        return "Node[" + rowIdString + idString + "name=" + this.getObjectClass() + ", ownValue=" + this.getOwnValue() + ", sysStatus=" + this.getSystemStatus() + "]";
     }
 }
--- a/src/main/java/org/mpi/openmind/repository/bo/Relation.java	Thu Aug 04 21:15:33 2016 +0200
+++ b/src/main/java/org/mpi/openmind/repository/bo/Relation.java	Thu Aug 04 21:16:08 2016 +0200
@@ -11,7 +11,6 @@
 import org.apache.commons.lang.StringUtils;
 import org.hibernate.annotations.Cache;
 import org.hibernate.annotations.CacheConcurrencyStrategy;
-import org.hibernate.event.def.OnUpdateVisitor;
 import org.mpi.openmind.cache.WrapperService;
 import org.mpi.openmind.repository.utils.OMUtils;
 
--- a/src/main/java/org/mpi/openmind/repository/bo/ViewerAttribute.java	Thu Aug 04 21:15:33 2016 +0200
+++ b/src/main/java/org/mpi/openmind/repository/bo/ViewerAttribute.java	Thu Aug 04 21:16:08 2016 +0200
@@ -12,7 +12,6 @@
 import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
-import javax.persistence.Transient;
 
 import cl.maps.duplex.DuplexKey;
 
--- a/src/main/java/org/mpi/openmind/repository/bo/ViewerPage.java	Thu Aug 04 21:15:33 2016 +0200
+++ b/src/main/java/org/mpi/openmind/repository/bo/ViewerPage.java	Thu Aug 04 21:16:08 2016 +0200
@@ -1,7 +1,6 @@
 package org.mpi.openmind.repository.bo;
 
 import java.util.Date;
-import java.util.List;
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
@@ -13,7 +12,6 @@
 import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
-import javax.persistence.Transient;
 
 
 @Entity
--- a/src/main/java/org/mpi/openmind/repository/services/AbstractPersistenceService.java	Thu Aug 04 21:15:33 2016 +0200
+++ b/src/main/java/org/mpi/openmind/repository/services/AbstractPersistenceService.java	Thu Aug 04 21:16:08 2016 +0200
@@ -2,7 +2,6 @@
 
 import java.text.DecimalFormat;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
@@ -10,7 +9,6 @@
 import org.apache.log4j.Logger;
 import org.hibernate.Query;
 import org.hibernate.Session;
-import org.hibernate.impl.SessionFactoryImpl;
 import org.mpi.openmind.configuration.ConfigurationService;
 import org.mpi.openmind.repository.bo.Attribute;
 import org.mpi.openmind.repository.bo.Entity;
@@ -18,9 +16,7 @@
 import org.mpi.openmind.repository.bo.Relation;
 import org.mpi.openmind.repository.bo.View;
 import org.mpi.openmind.repository.bo.utils.Sequence;
-import org.mpi.openmind.repository.utils.ArabicNormalizerUtils;
 import org.mpi.openmind.repository.utils.HibernateUtil;
-import org.mpi.openmind.repository.utils.NormalizerUtils;
 import org.mpi.openmind.repository.utils.OwnValueGenerator;
 
 /**
@@ -686,6 +682,7 @@
 				else
 					att.setId(idSequence.generateId());
 			}
+			logger.debug("setting att source to entity: "+entity);
 			att.setSourceId(entity.getId());
 			att.setSourceModif(entity.getModificationTime());
 			att.setSourceObjectClass(entity.getObjectClass());
@@ -718,6 +715,7 @@
 					else
 						att.setId(idSequence.generateId());
 				}
+	            logger.debug("setting att source to (source)relation: "+rel);
 				att.setSourceId(rel.getId());
 				att.setSourceModif(rel.getModificationTime());
 				// TODO this should be analyzed
@@ -750,6 +748,7 @@
 					else
 						att.setId(idSequence.generateId());
 				}
+                logger.debug("setting att source to (target)relation: "+rel);
 				att.setSourceId(rel.getId());
 				att.setSourceModif(rel.getModificationTime());
 				// TODO this should be analyzed
@@ -782,16 +781,22 @@
 		entity.setSystemStatus(Node.SYS_STATUS_PREVIOUS_VERSION);
 		session.save(entity);
 		for (Attribute attribute : entity.getAttributes()) {
+            logger.debug("  saving prev entity attribute: "+attribute);
 			session.save(attribute);
 		}
 		for (Relation rel : entity.getSourceRelations()) {
 			session.save(rel);
 			for (Attribute att : rel.getAttributes()) {
+	            logger.debug("  saving prev (source)relation attribute: "+rel);
 				session.save(att);
 			}
 		}
 		for (Relation rel : entity.getTargetRelations()) {
 			session.save(rel);
+            for (Attribute att : rel.getAttributes()) {
+                logger.debug("  saving prev (target)relation attribute: "+rel);
+                session.save(att);
+            }
 		}
 		for (View view : entity.getViews()) {
 			session.save(view);
@@ -802,6 +807,7 @@
 		logger.info("Saving current entity: " + entity);
 		session.save(entity);
 		for (Attribute attribute : entity.getAttributes()) {
+		    logger.debug("  saving entity attribute: "+attribute);
 			session.save(attribute);
 		}
 		for (Relation rel : entity.getSourceRelations()) {
@@ -813,6 +819,7 @@
 			}
 			session.save(rel);
 			for (Attribute att : rel.getAttributes()) {
+	            logger.debug("  saving (source)relation attribute: "+att);
 				session.save(att);
 			}
 		}
@@ -820,10 +827,14 @@
 			rel.setTarget(entity);
 			if (rel.getSourceId() == null || rel.getTargetId() == null) {
 				throw new IllegalStateException(
-						"Either the sourceId or the targetId was not initialized to the source relation: "
+						"Either the sourceId or the targetId was not initialized to the target relation: "
 								+ rel.getOwnValue());
 			}
 			session.save(rel);
+            for (Attribute att : rel.getAttributes()) {
+                logger.debug("  saving (target)relation attribute: "+att);
+                session.save(att);
+            }
 		}
 
 		// Call of ownValue Generator.