Mercurial > hg > openmind
diff src/main/java/org/mpi/openmind/repository/bo/Entity.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 | 5e24413d355b |
children | 5737ab564b94 |
line wrap: on
line diff
--- a/src/main/java/org/mpi/openmind/repository/bo/Entity.java Thu Aug 25 11:29:47 2016 +0200 +++ b/src/main/java/org/mpi/openmind/repository/bo/Entity.java Fri Aug 26 11:42:41 2016 +0200 @@ -1,12 +1,14 @@ package org.mpi.openmind.repository.bo; import java.io.Serializable; +import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; import javax.persistence.DiscriminatorValue; import javax.persistence.Transient; +import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.hibernate.annotations.Cache; @@ -783,6 +785,9 @@ } } + /** + * Sets the ID of the entity and its attributes and relations to null. + */ public void resetId() { this.setId(null); for (Attribute att : this.attributes) { @@ -921,6 +926,9 @@ } } + /** + * Set the system_status of this Entity and its attributes and relations. + */ @Override public void setSystemStatus(String status) { super.setSystemStatus(status); @@ -977,6 +985,32 @@ ", type=" + this.getType() + " att.size=" + this.attributes.size() + "]"; } + /** + * Returns a String representation with base64-encoded own-value. + * + * To be used for the transaction log. + * + * @return + */ + public String toEncString() { + try { + String es = "ENTITY[" + + "id=\"" + this.getId() + "\", " + + "row-id=\"" + this.getRowId() + "\", " + + "object-class=\"" + this.getObjectClass() + "\", " + + "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!!!"; + } + public String getShortString(){ return "[" + this.getId() + "] " + this.getOwnValue(); }