# HG changeset patch # User casties # Date 1477671606 -7200 # Node ID 5bf964077567df858c29ba708197eceb19977788 # Parent 2d669fdd0a8be652440289539f4dc92b25325f5e small cleanup. diff -r 2d669fdd0a8b -r 5bf964077567 src/main/java/org/mpi/openmind/repository/bo/Entity.java --- a/src/main/java/org/mpi/openmind/repository/bo/Entity.java Thu Oct 27 20:21:19 2016 +0200 +++ b/src/main/java/org/mpi/openmind/repository/bo/Entity.java Fri Oct 28 18:20:06 2016 +0200 @@ -376,52 +376,44 @@ } public void addSourceRelation(Relation srcRel) { - //@TODO - /* big problem definition: - * example TEXT is_version_of TEXT - * the relation is_version_of is saved twice in the DB - */ - Relation oldRel = this.containsSrcRel(srcRel); - if(oldRel != null){ - - Exception ex = new Exception( - "This entity has already this (source) relation [\n" + - toString() + "\n" + - "NewRel=" + srcRel + "\n" + - "OldRel=" + oldRel + "]"); - logger.error(ex.getMessage(), ex); - //logger.error(ex.getMessage()); - this.removeSourceRelation(srcRel.getOwnValue(), srcRel.getTargetId()); - } - srcRel.setType(getType()); + // @TODO + /* + * big problem definition: example TEXT is_version_of TEXT the relation + * is_version_of is saved twice in the DB + */ + Relation oldRel = this.containsSrcRel(srcRel); + if (oldRel != null) { + logger.error("This entity has already this (source) relation [\n" + toString() + "\n" + + "NewRel=" + srcRel + "\n" + "OldRel=" + oldRel + "]"); + // remove new relation(?) + this.removeSourceRelation(srcRel.getOwnValue(), srcRel.getTargetId()); + } + srcRel.setType(getType()); this.sourceRelations.add(srcRel); } public void addTargetRelation(Relation tarRel) { - Relation oldRel = this.containsTarRel(tarRel); - if(oldRel != null){ - Exception ex = new Exception( - "This entity has already this (target) relation [\n" + - toString() + "\n" + - "NewRel=" + tarRel + "\n" + - "OldRel=" + oldRel + "]"); - logger.error(ex.getMessage(), ex); - //logger.error(ex.getMessage()); - this.removeTargetRelation(tarRel.getOwnValue(), tarRel.getSourceId()); - } - tarRel.setType(this.getType()); + Relation oldRel = this.containsTarRel(tarRel); + if (oldRel != null) { + logger.error("This entity has already this (target) relation [\n" + toString() + "\n" + "NewRel=" + tarRel + + "\n" + "OldRel=" + oldRel + "]"); + this.removeTargetRelation(tarRel.getOwnValue(), tarRel.getSourceId()); + } + tarRel.setType(this.getType()); this.targetRelations.add(tarRel); - } - private void testLightweightState(){ - try { - if (this.lightweight) { - throw new IllegalAccessException("This Entity is lightweight, so its relations and attributes were not loaded from the DB. " + this.toString()); - } - }catch (Exception e) { - logger.error(e.getMessage(), e); - } + private void testLightweightState() { + // FIXME: should this just be a logger call? + try { + if (this.lightweight) { + throw new IllegalAccessException( + "This Entity is lightweight, so its relations and attributes were not loaded from the DB. " + + this.toString()); + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } } public List getSourceRelations() {