Mercurial > hg > openmind
changeset 34:5737ab564b94
more transaction logging. logs more attributes and logs nodes.
author | casties |
---|---|
date | Fri, 26 Aug 2016 19:09:57 +0200 |
parents | e52f593f9e0d |
children | 1cd9d9a67cad |
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/services/AbstractPersistenceService.java |
diffstat | 5 files changed, 60 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/org/mpi/openmind/repository/bo/Attribute.java Fri Aug 26 11:42:41 2016 +0200 +++ b/src/main/java/org/mpi/openmind/repository/bo/Attribute.java Fri Aug 26 19:09:57 2016 +0200 @@ -235,6 +235,9 @@ + "version=\"" + this.getVersion() + "\", " + "user=\"" + this.getUser() + "\", " + "public=\"" + this.getIsPublic() + "\", " + + "system-status=\"" + this.getSystemStatus() + "\", " + + "status=\"" + this.getStatus() + "\", " + + "type=\"" + this.getType() + "\", " + "b64-value=\"" + ((this.getOwnValue() != null) ? Base64.encodeBase64String(this.getOwnValue().getBytes("UTF-8")) : "") + "\"]"; return es; } catch (UnsupportedEncodingException e) {
--- a/src/main/java/org/mpi/openmind/repository/bo/Entity.java Fri Aug 26 11:42:41 2016 +0200 +++ b/src/main/java/org/mpi/openmind/repository/bo/Entity.java Fri Aug 26 19:09:57 2016 +0200 @@ -1002,6 +1002,9 @@ + "version=\"" + this.getVersion() + "\", " + "user=\"" + this.getUser() + "\", " + "public=\"" + this.getIsPublic() + "\", " + + "system-status=\"" + this.getSystemStatus() + "\", " + + "status=\"" + this.getStatus() + "\", " + + "type=\"" + this.getType() + "\", " + "b64-value=\"" + ((this.getOwnValue() != null) ? Base64.encodeBase64String(this.getOwnValue().getBytes("UTF-8")) : "") + "\"]"; return es; } catch (UnsupportedEncodingException e) {
--- a/src/main/java/org/mpi/openmind/repository/bo/Node.java Fri Aug 26 11:42:41 2016 +0200 +++ b/src/main/java/org/mpi/openmind/repository/bo/Node.java Fri Aug 26 19:09:57 2016 +0200 @@ -1,6 +1,7 @@ package org.mpi.openmind.repository.bo; import java.io.Serializable; +import java.io.UnsupportedEncodingException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -20,6 +21,7 @@ import javax.persistence.Table; import javax.persistence.Transient; +import org.apache.commons.codec.binary.Base64; import org.mpi.openmind.repository.utils.ArabicNormalizerUtils; import org.mpi.openmind.repository.utils.NormalizerUtils; import org.mpi.openmind.repository.utils.RomanizationLoC; @@ -367,4 +369,35 @@ return "Node[" + rowIdString + idString + "name=" + this.getObjectClass() + ", ownValue=" + this.getOwnValue() + ", sysStatus=" + this.getSystemStatus() + "]"; } + + /** + * Returns a String representation with base64-encoded own-value. + * + * To be used for the transaction log. + * + * @return + */ + public String toEncString() { + try { + String es = "NODE[" + + "id=\"" + this.getId() + "\", " + + "row-id=\"" + this.getRowId() + "\", " + + "object-class=\"" + this.getObjectClass() + "\", " + + "mtime=\"" + this.getModificationTime() + "\", " + + "version=\"" + this.getVersion() + "\", " + + "user=\"" + this.getUser() + "\", " + + "public=\"" + this.getIsPublic() + "\", " + + "system-status=\"" + this.getSystemStatus() + "\", " + + "status=\"" + this.getStatus() + "\", " + + "type=\"" + this.getType() + "\", " + + "content-type=\"" + this.getContentType() + "\", " + + "b64-value=\"" + ((this.getOwnValue() != null) ? Base64.encodeBase64String(this.getOwnValue().getBytes("UTF-8")) : "") + "\"]"; + return es; + } catch (UnsupportedEncodingException e) { + // this shouldn't happen + e.printStackTrace(); + } + return "!!!ENCODING-ERROR!!!"; + } + }
--- a/src/main/java/org/mpi/openmind/repository/bo/Relation.java Fri Aug 26 11:42:41 2016 +0200 +++ b/src/main/java/org/mpi/openmind/repository/bo/Relation.java Fri Aug 26 19:09:57 2016 +0200 @@ -282,6 +282,9 @@ + "version=\"" + this.getVersion() + "\", " + "user=\"" + this.getUser() + "\", " + "public=\"" + this.getIsPublic() + "\", " + + "system-status=\"" + this.getSystemStatus() + "\", " + + "status=\"" + this.getStatus() + "\", " + + "type=\"" + this.getType() + "\", " + "b64-value=\"" + ((this.getOwnValue() != null) ? Base64.encodeBase64String(this.getOwnValue().getBytes("UTF-8")) : "") + "\"]"; return es; } catch (UnsupportedEncodingException e) {
--- a/src/main/java/org/mpi/openmind/repository/services/AbstractPersistenceService.java Fri Aug 26 11:42:41 2016 +0200 +++ b/src/main/java/org/mpi/openmind/repository/services/AbstractPersistenceService.java Fri Aug 26 19:09:57 2016 +0200 @@ -146,8 +146,11 @@ } if (node.getRowId() == null){ + logger.debug("Save node: "+node.toString()); + txLog.info("save node: "+node.toEncString()); session.save(node); }else{ + txLog.info("merge node: "+node.toEncString()); session.merge(node); } @@ -287,10 +290,15 @@ if (node.getId() == null) node.setId(idSequence.generateId()); - if (node.getRowId() == null) - session.save(node); - else - session.merge(node); + if (node.getRowId() == null) { + logger.debug("Save node from EntityListAsNode: "+node); + txLog.info("save node: "+node.toEncString()); + session.save(node); + } else { + txLog.info("merge node: "+node.toEncString()); + session.merge(node); + + } double percent = ((double) counter / (double) nodeList.size()) * 100.0; long diff = System.currentTimeMillis() - start; @@ -359,10 +367,14 @@ node.autoNormalize(); if (node.getId() == null) node.setId(idSequence.generateId()); - if (node.getRowId() == null) + if (node.getRowId() == null) { + logger.debug("Saving node from EntityListAsNodeWithoutContent: "+node); + txLog.info("save node: "+node.toEncString()); session.save(node); - else + } else { + txLog.info("merge node: "+node.toEncString()); session.merge(node); + } double percent = ((double) counter / (double) nodeList.size()) * 100.0; long diff = System.currentTimeMillis() - start; double min = (double) diff / (double) (60 * 1000);