From 958614d3e1c83ee5fc8b65bf0ad285bf3ef99125 Mon Sep 17 00:00:00 2001 From: gakin <gakin> Date: Mon, 23 Jan 2017 14:29:12 +0000 Subject: [PATCH] SSDM-4675 : Fix failing tests + minor refactoring SVN: 37610 --- .../business/bo/EntityTypePropertyTypeBO.java | 8 +------- .../server/dataaccess/IEntityPropertyTypeDAO.java | 3 +-- .../dataaccess/db/EntityPropertyTypeDAO.java | 14 ++++++++++---- .../business/bo/EntityTypePropertyTypeBOTest.java | 1 + 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/EntityTypePropertyTypeBO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/EntityTypePropertyTypeBO.java index c27e8af2025..1271faa227c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/EntityTypePropertyTypeBO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/EntityTypePropertyTypeBO.java @@ -161,12 +161,6 @@ public class EntityTypePropertyTypeBO extends AbstractBusinessObject implements } } - private void updateEntityModificationTimestamps(List<Long> entityIds) - { - IEntityPropertyTypeDAO entityPropertyTypeDAO = getEntityPropertyTypeDAO(entityKind); - entityPropertyTypeDAO.updateEntityModificationTimestamps(entityIds, getTransactionTimeStamp()); - } - private ScriptPE tryFindScript(NewETPTAssignment newAssignment) { if (newAssignment.getScriptName() == null) @@ -211,7 +205,7 @@ public class EntityTypePropertyTypeBO extends AbstractBusinessObject implements registrator, validatedValue); entityPropertyTypeDAO.createProperties(property, entityIds); - updateEntityModificationTimestamps(entityIds); + entityPropertyTypeDAO.updateEntityModificationTimestamps(entityIds); } if (operationLog.isDebugEnabled()) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IEntityPropertyTypeDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IEntityPropertyTypeDAO.java index 409247eceff..22bc33d7a3e 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IEntityPropertyTypeDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IEntityPropertyTypeDAO.java @@ -16,7 +16,6 @@ package ch.systemsx.cisd.openbis.generic.server.dataaccess; -import java.util.Date; import java.util.List; import org.springframework.dao.DataAccessException; @@ -127,5 +126,5 @@ public interface IEntityPropertyTypeDAO * the entity type and existing entities need to be updated with a default value for the mandatory property 2. If a property is unassigned from an * entity type. */ - public void updateEntityModificationTimestamps(final List<Long> entityIds, final Date timestamp); + public void updateEntityModificationTimestamps(final List<Long> entityIds); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EntityPropertyTypeDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EntityPropertyTypeDAO.java index 584e9e1908d..0e57286be1d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EntityPropertyTypeDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EntityPropertyTypeDAO.java @@ -18,7 +18,6 @@ package ch.systemsx.cisd.openbis.generic.server.dataaccess.db; import java.io.Serializable; import java.util.ArrayList; -import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -247,8 +246,15 @@ final class EntityPropertyTypeDAO extends AbstractDAO implements IEntityProperty } @SuppressWarnings({ "unchecked", "rawtypes" }) - public void updateEntityModificationTimestamps(final List<Long> entityIds, final Date timestamp) + public void updateEntityModificationTimestamps(final List<Long> entityIds) { + assert entityIds != null : "Null entityId list."; + + if (entityIds.isEmpty()) + { + return; + } + getHibernateTemplate().execute(new HibernateCallback() { @Override @@ -276,7 +282,7 @@ final class EntityPropertyTypeDAO extends AbstractDAO implements IEntityProperty SQLQuery clearQuery = session.createSQLQuery( "update " + entityTableName + " set modification_timestamp = :timestamp where id in :entityIds "); - clearQuery.setTimestamp("timestamp", timestamp); + clearQuery.setTimestamp("timestamp", getTransactionTimeStamp()); clearQuery.setParameterList("entityIds", entityIds); clearQuery.executeUpdate(); return null; @@ -551,7 +557,7 @@ final class EntityPropertyTypeDAO extends AbstractDAO implements IEntityProperty template.clear(); template.delete(assignment); - updateEntityModificationTimestamps(entityIds, getTransactionTimeStamp()); + updateEntityModificationTimestamps(entityIds); scheduleDynamicPropertiesEvaluation(entityIds); if (operationLog.isInfoEnabled()) diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/EntityTypePropertyTypeBOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/EntityTypePropertyTypeBOTest.java index b78e25dc229..1f240634f1e 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/EntityTypePropertyTypeBOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/EntityTypePropertyTypeBOTest.java @@ -137,6 +137,7 @@ public final class EntityTypePropertyTypeBOTest extends AbstractBOTest with(any(PersonPE.class)), with(validatedValue)); will(returnValue(property)); + allowing(entityPropertyTypeDAO).updateEntityModificationTimestamps(with(experimentIds)); one(entityPropertyTypeDAO).createProperties(property, experimentIds); } }); -- GitLab