# HG changeset patch # User casties # Date 1481207966 -3600 # Node ID e08f3dd127a51620abc204539ad68e8937fc3321 # Parent 467843399e707de05d9a3d413ba5297c318d7782 cleanup of new methods. diff -r 467843399e70 -r e08f3dd127a5 src/main/java/org/mpi/openmind/repository/services/AbstractPersistenceService.java --- a/src/main/java/org/mpi/openmind/repository/services/AbstractPersistenceService.java Mon Nov 28 14:26:10 2016 +0100 +++ b/src/main/java/org/mpi/openmind/repository/services/AbstractPersistenceService.java Thu Dec 08 15:39:26 2016 +0100 @@ -65,7 +65,7 @@ return ownValue; } - /** + /* * Performs the actual disabling of the Hibernate second-level cache. */ /* @@ -641,7 +641,7 @@ */ private void saveCurrentEntity(Session session, Entity entity, Sequence idSequence) throws Exception { Long time = System.currentTimeMillis(); - refreshEntity(session, entity); + refreshEntityRelations(session, entity); entity.setSystemStatus(Node.SYS_STATUS_CURRENT_VERSION); entity.resetRowId(); entity.increaseVersion(); @@ -656,26 +656,40 @@ } /** + * Updates the endpoints of the relations of this entity. + * * This class must be called, * because sometimes the current entity is related to other entities that * have been changed in parallel to the edition of this entity. * For this reason, some relations of the current entity can have old information of the related entities (like the modification time). - * This method updates the relations of the current entities getting the actual information of the related entities directly from the DB + * This method updates the relations of the current entities getting the actual information of the related entities directly from the DB. + * + * @author jurzua + * * @param session * @param entity * @throws Exception */ - private void refreshEntity(Session session, Entity entity) throws Exception{ + private void refreshEntityRelations(Session session, Entity entity) throws Exception { for(Relation rel : entity.getSourceRelations()){ - refreshTarget(session, rel); + refreshRelationTarget(session, rel); } for(Relation rel : entity.getTargetRelations()){ - refreshSource(session, rel); + refreshRelationSource(session, rel); } } - private void refreshTarget(Session session, Relation rel) throws Exception{ + /** + * Update the target of the relation. + * + * @author jurzua + * + * @param session + * @param rel + * @throws Exception + */ + private void refreshRelationTarget(Session session, Relation rel) throws Exception { long targetModifOld = rel.getTargetModif(); StringBuilder sb = new StringBuilder("refreshTarget\n" + rel.toString() + "\n"); sb.append(rel.printTarget() + "\n"); @@ -686,13 +700,22 @@ Entity target = entityList.get(0); rel.setTarget(target); sb.append(rel.printTarget() + "\n"); - // the refresh is printed in the standard output only if we detect a difference between the relation and the target entity. + // the refresh is logged only if we detect a difference between the relation and the target entity. if(targetModifOld != rel.getTargetModif()){ - logger.info(sb.toString()); + logger.warn(sb.toString()); } } - private void refreshSource(Session session, Relation rel) throws Exception{ + /** + * Update the source of the relation. + * + * @author jurzua + * + * @param session + * @param rel + * @throws Exception + */ + private void refreshRelationSource(Session session, Relation rel) throws Exception { long sourceModifOld = rel.getSourceModif(); StringBuilder sb = new StringBuilder("refreshSource\n" + rel.toString() + "\n"); sb.append(rel.printSource() + "\n"); @@ -703,9 +726,9 @@ Entity source = entityList.get(0); rel.setSource(source); sb.append(rel.printSource() + "\n"); - // the refresh is printed in the standard output only if we detect a difference between the relation and the source entity. + // the refresh is logged only if we detect a difference between the relation and the source entity. if(sourceModifOld != rel.getSourceModif()){ - logger.info(sb.toString()); + logger.warn(sb.toString()); } }