Mercurial > hg > openmind
diff src/main/java/org/mpi/openmind/repository/bo/Relation.java @ 33:e52f593f9e0d
new transaction logger "openmind.transactionlog" logging entity save actions and their data.
more comments in code.
author | casties |
---|---|
date | Fri, 26 Aug 2016 11:42:41 +0200 |
parents | c23ae718fdd3 |
children | 5737ab564b94 |
line wrap: on
line diff
--- a/src/main/java/org/mpi/openmind/repository/bo/Relation.java Thu Aug 25 11:29:47 2016 +0200 +++ b/src/main/java/org/mpi/openmind/repository/bo/Relation.java Fri Aug 26 11:42:41 2016 +0200 @@ -1,6 +1,7 @@ package org.mpi.openmind.repository.bo; import java.io.Serializable; +import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; @@ -8,6 +9,7 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Transient; +import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang.StringUtils; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; @@ -257,7 +259,40 @@ "sysStatus=" + this.getSystemStatus() + "]"; } - @Override + /** + * Returns a String representation with base64-encoded own-value. + * + * To be used for the transaction log. + * + * @return + */ + public String toEncString() { + try { + String es = "RELATION[" + + "id=\"" + this.getId() + "\", " + + "row-id=\"" + this.getRowId() + "\", " + + "object_class=\"" + this.getObjectClass() + "\", " + + "source-id=\"" + this.getSourceId() + "\", " + + "source-mtime=\"" + this.getSourceModif() + "\", " + + "source-oc=\"" + this.getSourceObjectClass() + "\", " + + "target-id=\"" + this.getTargetId() + "\", " + + "target-mtime=\"" + this.getTargetModif() + "\", " + + "target-oc=\"" + this.getTargetObjectClass() + "\", " + + "mtime=\"" + this.getModificationTime() + "\", " + + "version=\"" + this.getVersion() + "\", " + + "user=\"" + this.getUser() + "\", " + + "public=\"" + this.getIsPublic() + "\", " + + "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!!!"; + } + + + @Override public int compareTo(Relation e) { if(e == null) return 1;