comparison 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
comparison
equal deleted inserted replaced
32:9c54842f5e86 33:e52f593f9e0d
1 package org.mpi.openmind.repository.bo; 1 package org.mpi.openmind.repository.bo;
2 2
3 import java.io.Serializable; 3 import java.io.Serializable;
4 import java.io.UnsupportedEncodingException;
4 import java.util.ArrayList; 5 import java.util.ArrayList;
5 import java.util.List; 6 import java.util.List;
6 7
7 import javax.persistence.Column; 8 import javax.persistence.Column;
8 import javax.persistence.DiscriminatorValue; 9 import javax.persistence.DiscriminatorValue;
9 import javax.persistence.Transient; 10 import javax.persistence.Transient;
10 11
12 import org.apache.commons.codec.binary.Base64;
11 import org.apache.commons.lang.StringUtils; 13 import org.apache.commons.lang.StringUtils;
12 import org.hibernate.annotations.Cache; 14 import org.hibernate.annotations.Cache;
13 import org.hibernate.annotations.CacheConcurrencyStrategy; 15 import org.hibernate.annotations.CacheConcurrencyStrategy;
14 import org.mpi.openmind.cache.WrapperService; 16 import org.mpi.openmind.cache.WrapperService;
15 import org.mpi.openmind.repository.utils.OMUtils; 17 import org.mpi.openmind.repository.utils.OMUtils;
255 "id=" + getId() +", " + 257 "id=" + getId() +", " +
256 "ownValue=" + getOwnValue() + source + target + ", " + 258 "ownValue=" + getOwnValue() + source + target + ", " +
257 "sysStatus=" + this.getSystemStatus() + "]"; 259 "sysStatus=" + this.getSystemStatus() + "]";
258 } 260 }
259 261
260 @Override 262 /**
263 * Returns a String representation with base64-encoded own-value.
264 *
265 * To be used for the transaction log.
266 *
267 * @return
268 */
269 public String toEncString() {
270 try {
271 String es = "RELATION["
272 + "id=\"" + this.getId() + "\", "
273 + "row-id=\"" + this.getRowId() + "\", "
274 + "object_class=\"" + this.getObjectClass() + "\", "
275 + "source-id=\"" + this.getSourceId() + "\", "
276 + "source-mtime=\"" + this.getSourceModif() + "\", "
277 + "source-oc=\"" + this.getSourceObjectClass() + "\", "
278 + "target-id=\"" + this.getTargetId() + "\", "
279 + "target-mtime=\"" + this.getTargetModif() + "\", "
280 + "target-oc=\"" + this.getTargetObjectClass() + "\", "
281 + "mtime=\"" + this.getModificationTime() + "\", "
282 + "version=\"" + this.getVersion() + "\", "
283 + "user=\"" + this.getUser() + "\", "
284 + "public=\"" + this.getIsPublic() + "\", "
285 + "b64-value=\"" + ((this.getOwnValue() != null) ? Base64.encodeBase64String(this.getOwnValue().getBytes("UTF-8")) : "") + "\"]";
286 return es;
287 } catch (UnsupportedEncodingException e) {
288 // this shouldn't happen
289 e.printStackTrace();
290 }
291 return "!!!ENCODING-ERROR!!!";
292 }
293
294
295 @Override
261 public int compareTo(Relation e) { 296 public int compareTo(Relation e) {
262 if(e == null) 297 if(e == null)
263 return 1; 298 return 1;
264 if(StringUtils.isNotEmpty(this.getOwnValue())) 299 if(StringUtils.isNotEmpty(this.getOwnValue()))
265 return this.getOwnValue().compareTo(e.getOwnValue()); 300 return this.getOwnValue().compareTo(e.getOwnValue());