diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java index c58184e8557e7a5dccf7c5c46b3fcbe2a6db1188..d1a4b50782032d09f33f941c47d6b550b656a2ab 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java @@ -32,9 +32,7 @@ import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.spring.AbstractServiceWithLogger; import ch.systemsx.cisd.openbis.generic.server.business.IPropertiesBatchManager; import ch.systemsx.cisd.openbis.generic.server.business.PropertiesBatchManager; -import ch.systemsx.cisd.openbis.generic.server.dataaccess.DynamicPropertyEvaluationOperation; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; -import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDynamicPropertyEvaluationScheduler; import ch.systemsx.cisd.openbis.generic.server.plugin.DataSetServerPluginRegistry; import ch.systemsx.cisd.openbis.generic.server.plugin.IDataSetTypeSlaveServerPlugin; import ch.systemsx.cisd.openbis.generic.server.plugin.ISampleTypeSlaveServerPlugin; @@ -55,7 +53,6 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.DataStorePE; import ch.systemsx.cisd.openbis.generic.shared.dto.GridCustomColumnPE; import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSession; -import ch.systemsx.cisd.openbis.generic.shared.dto.IEntityInformationWithPropertiesHolder; import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; import ch.systemsx.cisd.openbis.generic.shared.dto.RoleAssignmentPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleTypePE; @@ -122,7 +119,7 @@ public abstract class AbstractServer<T> extends AbstractServiceWithLogger<T> imp this.sampleTypeSlaveServerPlugin = sampleTypeSlaveServerPlugin; this.dataSetTypeSlaveServerPlugin = dataSetTypeSlaveServerPlugin; } - + protected IPropertiesBatchManager getPropertiesBatchManager() { if (propertiesBatchManager == null) @@ -470,18 +467,4 @@ public abstract class AbstractServer<T> extends AbstractServiceWithLogger<T> imp registratorOrNull); } - /** - * Schedules evaluation of dynamic properties on specified entities. After evaluation is done - * the entities will be indexed. - */ - protected static <T extends IEntityInformationWithPropertiesHolder> void scheduleDynamicPropertiesEvaluation( - IDynamicPropertyEvaluationScheduler scheduler, Class<T> entityClass, List<T> entities) - { - List<Long> ids = new ArrayList<Long>(); - for (IEntityInformationWithPropertiesHolder entity : entities) - { - ids.add(entity.getId()); - } - scheduler.scheduleUpdate(DynamicPropertyEvaluationOperation.evaluate(entityClass, ids)); - } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java index f066962da5423dad8f58727d97c19c74e6647b43..53ad60a3948d12b0ba9db181a9082de090c60cd8 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java @@ -164,7 +164,6 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.FileFormatTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.GridCustomFilterPE; import ch.systemsx.cisd.openbis.generic.shared.dto.IEntityInformationHolderDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.IEntityInformationWithPropertiesHolder; -import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialPE; import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.NewRoleAssignment; import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; @@ -172,7 +171,6 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectUpdatesDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.PropertyTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.RoleAssignmentPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.ScriptPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SearchableEntity; @@ -2253,9 +2251,6 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt experimentBO.updateManagedProperty(managedProperty); experimentBO.save(); - scheduleDynamicPropertiesEvaluation(getDAOFactory() - .getDynamicPropertyEvaluationScheduler(), ExperimentPE.class, - Arrays.asList(experimentBO.getExperiment())); } catch (final DataAccessException ex) { throw createUserFailureException(ex); @@ -2280,9 +2275,6 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt sampleBO.updateManagedProperty(managedProperty); sampleBO.save(); - scheduleDynamicPropertiesEvaluation(getDAOFactory() - .getDynamicPropertyEvaluationScheduler(), SamplePE.class, - Arrays.asList(sampleBO.getSample())); } catch (final DataAccessException ex) { throw createUserFailureException(ex); @@ -2308,9 +2300,6 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt dataSetBO.updateManagedProperty(managedProperty); dataSetBO.save(); - scheduleDynamicPropertiesEvaluation(getDAOFactory() - .getDynamicPropertyEvaluationScheduler(), ExternalDataPE.class, - Arrays.asList(dataSetBO.getExternalData())); } catch (final DataAccessException ex) { throw createUserFailureException(ex); @@ -2335,9 +2324,6 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt materialBO.updateManagedProperty(managedProperty); materialBO.save(); - scheduleDynamicPropertiesEvaluation(getDAOFactory() - .getDynamicPropertyEvaluationScheduler(), MaterialPE.class, - Arrays.asList(materialBO.getMaterial())); } catch (final DataAccessException ex) { throw createUserFailureException(ex); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java index 9ce4680c661c7ef9e6f1aeb497df4b277551d3f8..43ef9fe50dd9c083e9e5aac5cb1ad57ce7427405 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java @@ -17,7 +17,6 @@ package ch.systemsx.cisd.openbis.generic.server; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -138,14 +137,14 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET ETLService(IAuthenticationService authenticationService, ISessionManager<Session> sessionManager, IDAOFactory daoFactory, - IPropertiesBatchManager propertiesBatchManager, - ICommonBusinessObjectFactory boFactory, IDataStoreServiceFactory dssFactory) + IPropertiesBatchManager propertiesBatchManager, ICommonBusinessObjectFactory boFactory, + IDataStoreServiceFactory dssFactory) { super(authenticationService, sessionManager, daoFactory, propertiesBatchManager, boFactory); this.daoFactory = daoFactory; this.dssFactory = dssFactory; } - + public IETLService createLogger(IInvocationLoggerContext context) { return new ETLServiceLogger(getSessionManager(), context); @@ -511,19 +510,18 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET return EntityPropertyTranslator.translate(properties.toArray(new SamplePropertyPE[0]), new HashMap<PropertyTypePE, PropertyType>()); } - public void registerEntities(String sessionToken, EntityCollectionForCreationOrUpdate collection) throws UserFailureException { checkSession(sessionToken); - + List<NewExperiment> experiments = collection.getNewExperiments(); for (NewExperiment experiment : experiments) { registerExperiment(sessionToken, experiment); } - + List<NewExternalData> dataSets = collection.getNewDataSets(); for (NewExternalData dataSet : dataSets) { @@ -534,7 +532,7 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET } } // TODO Auto-generated method stub - + } public long registerExperiment(String sessionToken, NewExperiment experiment) @@ -879,10 +877,6 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET sampleBO.update(updates); sampleBO.save(); - scheduleDynamicPropertiesEvaluation( - getDAOFactory().getDynamicPropertyEvaluationScheduler(), SamplePE.class, - Arrays.asList(sampleBO.getSample())); - return sampleBO; } @@ -925,10 +919,6 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET } sampleBO.save(); SamplePE samplePE = sampleBO.getSample(); - scheduleDynamicPropertiesEvaluation( - getDAOFactory().getDynamicPropertyEvaluationScheduler(), SamplePE.class, - Arrays.asList(samplePE)); - return samplePE; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentBO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentBO.java index 23c72183351368e9da81781c87a1f18f99670580..cd16c283ad9157c7dd4b775e8dc0d90006350de0 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentBO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentBO.java @@ -333,7 +333,7 @@ public final class ExperimentBO extends AbstractBusinessObject implements IExper { try { - getExperimentDAO().createExperiment(experiment); + getExperimentDAO().createOrUpdateExperiment(experiment); } catch (final DataAccessException ex) { final String projectCode = experiment.getProject().getCode(); @@ -581,6 +581,8 @@ public final class ExperimentBO extends AbstractBusinessObject implements IExper final PersonPE registrator = findRegistrator(); experiment.setProperties(propertiesConverter.updateManagedProperty(existingProperties, type, managedProperty, registrator)); + + dataChanged = true; } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentTable.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentTable.java index 2225e3616dc8b649b1fcfb8c647ace75b701123f..b74f29c61ab3a4364fcb15bae29f3e0205406f66 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentTable.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentTable.java @@ -323,7 +323,7 @@ public final class ExperimentTable extends AbstractBusinessObject implements IEx try { checkBusinessRules(); - getExperimentDAO().createExperiments(experiments); + getExperimentDAO().createOrUpdateExperiments(experiments); } catch (final DataAccessException ex) { throwException(ex, String.format("One of experiments")); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/MaterialBO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/MaterialBO.java index f138a6f14a4b7b80e49f88b2bafc73ac40787113..4ebe1b7a5eef35006f981ea6b20d96c2900affb0 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/MaterialBO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/MaterialBO.java @@ -16,7 +16,7 @@ package ch.systemsx.cisd.openbis.generic.server.business.bo; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -73,9 +73,7 @@ public final class MaterialBO extends AbstractMaterialBusinessObject implements assert dataChanged : "Data not changed"; try { - final ArrayList<MaterialPE> materials = new ArrayList<MaterialPE>(); - materials.add(material); - getMaterialDAO().createMaterials(materials); + getMaterialDAO().createOrUpdateMaterials(Collections.singletonList(material)); } catch (final DataAccessException ex) { throwException(ex, String.format("Material '%s'", material.getCode())); @@ -154,5 +152,6 @@ public final class MaterialBO extends AbstractMaterialBusinessObject implements final PersonPE registrator = findRegistrator(); material.setProperties(entityPropertiesConverter.updateManagedProperty(existingProperties, type, managedProperty, registrator)); + dataChanged = true; } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/MaterialTable.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/MaterialTable.java index 90d9ae510570292717b74340a64850773fa25ead..43e68b271d37678325fb00ddbb09db87351b5a3f 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/MaterialTable.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/MaterialTable.java @@ -93,7 +93,7 @@ public final class MaterialTable extends AbstractMaterialBusinessObject implemen assert dataChanged == true : "Data not changed"; try { - getMaterialDAO().createMaterials(materials); + getMaterialDAO().createOrUpdateMaterials(materials); checkBusinessRules(); } catch (final DataAccessException ex) { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java index 9459f1f9e4c4718ffd3295f96083804786a657ee..14552d48efeacb10357bc043653c5262451d00ea 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java @@ -158,7 +158,7 @@ public final class SampleBO extends AbstractSampleBusinessObject implements ISam { try { - getSampleDAO().createSample(sample); + getSampleDAO().createOrUpdateSample(sample); } catch (final DataIntegrityViolationException ex) { // needed because we throw an exception in DAO instead of relying on DB constraint @@ -370,6 +370,8 @@ public final class SampleBO extends AbstractSampleBusinessObject implements ISam final PersonPE registrator = findRegistrator(); sample.setProperties(entityPropertiesConverter.updateManagedProperty(existingProperties, type, managedProperty, registrator)); + + dataChanged = true; } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleTable.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleTable.java index f11bb37cd46e3c8ef30519281d764c0edf1c73d0..3dd9d8cd38e184ea96f52f75924e778303401b3f 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleTable.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleTable.java @@ -207,7 +207,7 @@ public final class SampleTable extends AbstractSampleBusinessObject implements I { checkAllBusinessRules(); } - getSampleDAO().createSamples(samples); + getSampleDAO().createOrUpdateSamples(samples); } catch (final DataAccessException ex) { throwException(ex, String.format("One of samples")); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IExperimentDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IExperimentDAO.java index b739a7663cf51277048ab4bbf85f2a87f456cd4e..a70722e2d01d8cf0bc12db5210825c69484bfbfe 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IExperimentDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IExperimentDAO.java @@ -42,11 +42,11 @@ public interface IExperimentDAO extends IGenericDAO<ExperimentPE> throws DataAccessException; /** - * Lists experiments with specified ids. Fetches also properties. + * Lists experiments with specified ids. Fetches also properties. */ public List<ExperimentPE> listExperimentsWithProperties(final Collection<Long> experimentIDs) throws DataAccessException; - + /** * Lists experiments of specified type and specified project. Fetches also properties. * @@ -73,9 +73,9 @@ public interface IExperimentDAO extends IGenericDAO<ExperimentPE> final String propertyValue, final ProjectPE project) throws DataAccessException; /** - * Inserts given {@link ExperimentPE} into the database. + * Inserts given {@link ExperimentPE} into the database or updates it if it already exists. */ - public void createExperiment(ExperimentPE experiment) throws DataAccessException; + public void createOrUpdateExperiment(ExperimentPE experiment) throws DataAccessException; /** * Deletes all datasets that are connected to given {@link ExperimentPE} and are supposed to be @@ -96,8 +96,8 @@ public interface IExperimentDAO extends IGenericDAO<ExperimentPE> public List<ExperimentPE> listByPermID(Set<String> permId); /** - * Saves given given experiments in the database. + * Saves or updates given given experiments in the database. */ - public void createExperiments(List<ExperimentPE> experiments); + public void createOrUpdateExperiments(List<ExperimentPE> experiments); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IMaterialDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IMaterialDAO.java index e3a1f4c96fe4406adcd7db6e1aecd3173c80c141..9bbba1a29cf96e6be32762ebb1da7a2b1e48236d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IMaterialDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IMaterialDAO.java @@ -42,8 +42,8 @@ public interface IMaterialDAO extends IGenericDAO<MaterialPE> @Deprecated public List<MaterialPE> listMaterialsWithProperties(MaterialTypePE type); - /** Inserts given {@link MaterialPE}s into the database. */ - public void createMaterials(List<MaterialPE> materials); + /** Inserts or updates given {@link MaterialPE}s into the database. */ + public void createOrUpdateMaterials(List<MaterialPE> materials); /** @return material with the given identifier or null if it is not found. */ public MaterialPE tryFindMaterial(MaterialIdentifier identifier); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/ISampleDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/ISampleDAO.java index 89603e761d18eca3e1af2e3ebcf85296d0ea8b43..c6eeea87ef205d2abd136cf3f243d2519a9048ef 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/ISampleDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/ISampleDAO.java @@ -24,9 +24,9 @@ import org.springframework.dao.DataAccessException; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.dto.DatabaseInstancePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; /** * An interface that contains all data access operations on {@link SamplePE}s. @@ -36,9 +36,9 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; public interface ISampleDAO extends IGenericDAO<SamplePE> { /** - * Inserts given {@link SamplePE} into the database. + * Inserts given {@link SamplePE} into the database or updates it if it already exists. */ - void createSample(final SamplePE sample) throws DataAccessException; + void createOrUpdateSample(final SamplePE sample) throws DataAccessException; /** * Tries to find a sample by its permanent ID. Returns <code>null</code> if not found. @@ -77,9 +77,9 @@ public interface ISampleDAO extends IGenericDAO<SamplePE> final SpacePE space); /** - * Inserts given list of {@link SamplePE} into the database in one go. + * Inserts or updates given list of {@link SamplePE} into the database in one go. */ - void createSamples(List<SamplePE> samples) throws DataAccessException; + void createOrUpdateSamples(List<SamplePE> samples) throws DataAccessException; /** * Updates given <var>sample</var>. diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExperimentDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExperimentDAO.java index 46822fea49c9c987f368936e4bc8a7d3766fcd97..8df5e208f7bd2291f5f198b5eb6b6864d503c193 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExperimentDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExperimentDAO.java @@ -18,6 +18,7 @@ package ch.systemsx.cisd.openbis.generic.server.dataaccess.db; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -140,13 +141,6 @@ public class ExperimentDAO extends AbstractGenericEntityWithPropertiesDAO<Experi return experiment; } - public void createExperiment(ExperimentPE experiment) - { - HibernateTemplate template = getHibernateTemplate(); - internalCreateExperiment(experiment, template); - template.flush(); - } - public List<ExperimentPE> listExperimentsByProjectAndProperty(String propertyCode, String propertyValue, ProjectPE project) throws DataAccessException { @@ -245,14 +239,23 @@ public class ExperimentDAO extends AbstractGenericEntityWithPropertiesDAO<Experi return list; } - public void createExperiments(List<ExperimentPE> experiments) + public void createOrUpdateExperiment(ExperimentPE experiment) + { + HibernateTemplate template = getHibernateTemplate(); + internalCreateOrUpdateExperiment(experiment, template); + template.flush(); + + scheduleDynamicPropertiesEvaluation(Collections.singletonList(experiment)); + } + + public void createOrUpdateExperiments(List<ExperimentPE> experiments) { assert experiments != null && experiments.size() > 0 : "Unspecified or empty experiments."; final HibernateTemplate hibernateTemplate = getHibernateTemplate(); for (final ExperimentPE experiment : experiments) { - internalCreateExperiment(experiment, hibernateTemplate); + internalCreateOrUpdateExperiment(experiment, hibernateTemplate); } hibernateTemplate.flush(); @@ -261,7 +264,7 @@ public class ExperimentDAO extends AbstractGenericEntityWithPropertiesDAO<Experi scheduleDynamicPropertiesEvaluation(experiments); } - private void internalCreateExperiment(ExperimentPE experiment, + private void internalCreateOrUpdateExperiment(ExperimentPE experiment, HibernateTemplate hibernateTemplate) { assert experiment != null : "Missing experiment."; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExternalDataDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExternalDataDAO.java index c12f158902c93a5f1620af6e288802404d8235c4..351e5cf3ee1a3a1301a7f0ade4c346bf7f1bd7d3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExternalDataDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExternalDataDAO.java @@ -334,7 +334,7 @@ final class ExternalDataDAO extends AbstractGenericEntityWithPropertiesDAO<Exter if (dataset instanceof ExternalDataPE) { - scheduleDynamicPropertiesEvaluation(Arrays.asList((ExternalDataPE) dataset)); + scheduleDynamicPropertiesEvaluation(Collections.singletonList((ExternalDataPE) dataset)); } if (operationLog.isInfoEnabled()) @@ -369,7 +369,7 @@ final class ExternalDataDAO extends AbstractGenericEntityWithPropertiesDAO<Exter } hibernateTemplate.update(externalData); hibernateTemplate.flush(); - scheduleDynamicPropertiesEvaluation(Arrays.asList(externalData)); + scheduleDynamicPropertiesEvaluation(Collections.singletonList(externalData)); if (operationLog.isInfoEnabled()) { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/MaterialDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/MaterialDAO.java index f7989d66b938892f5ea9c5da2644e991f4d95f90..7e9eecf062d20c98f9609bd155f31ab5841a87ed 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/MaterialDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/MaterialDAO.java @@ -85,7 +85,7 @@ public class MaterialDAO extends AbstractGenericEntityWithPropertiesDAO<Material return list; } - public void createMaterials(List<MaterialPE> materials) + public void createOrUpdateMaterials(List<MaterialPE> materials) { assert materials != null && materials.size() > 0 : "Unspecified or empty materials."; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAO.java index 06d649a816381160112afc3b1c6d01d570bca656..c4f7f97e4b31890444253fdb705b386f332c9324 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAO.java @@ -17,8 +17,8 @@ package ch.systemsx.cisd.openbis.generic.server.dataaccess.db; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -77,7 +77,7 @@ public class SampleDAO extends AbstractGenericEntityWithPropertiesDAO<SamplePE> } // LockSampleModificationsInterceptor automatically obtains lock - private final void internalCreateSample(final SamplePE sample, + private final void internalCreateOrUpdateSample(final SamplePE sample, final HibernateTemplate hibernateTemplate, final boolean doLog) { validatePE(sample); @@ -94,15 +94,17 @@ public class SampleDAO extends AbstractGenericEntityWithPropertiesDAO<SamplePE> // ISampleDAO // - public final void createSample(final SamplePE sample) throws DataAccessException + public final void createOrUpdateSample(final SamplePE sample) throws DataAccessException { assert sample != null : "Unspecified sample"; final HibernateTemplate hibernateTemplate = getHibernateTemplate(); - internalCreateSample(sample, hibernateTemplate, true); + internalCreateOrUpdateSample(sample, hibernateTemplate, true); + // need to deal with exception thrown by trigger checking code uniqueness flushWithSqlExceptionHandling(hibernateTemplate); + scheduleDynamicPropertiesEvaluation(Collections.singletonList(sample)); } public final List<SamplePE> listSamplesByGeneratedFrom(final SamplePE sample) @@ -322,7 +324,8 @@ public class SampleDAO extends AbstractGenericEntityWithPropertiesDAO<SamplePE> } } - public final void createSamples(final List<SamplePE> samples) throws DataAccessException + public final void createOrUpdateSamples(final List<SamplePE> samples) + throws DataAccessException { assert samples != null && samples.size() > 0 : "Unspecified or empty samples."; @@ -330,7 +333,7 @@ public class SampleDAO extends AbstractGenericEntityWithPropertiesDAO<SamplePE> for (final SamplePE samplePE : samples) { - internalCreateSample(samplePE, hibernateTemplate, false); + internalCreateOrUpdateSample(samplePE, hibernateTemplate, false); } if (operationLog.isInfoEnabled()) { @@ -352,7 +355,7 @@ public class SampleDAO extends AbstractGenericEntityWithPropertiesDAO<SamplePE> // need to deal with exception thrown by trigger checking code uniqueness flushWithSqlExceptionHandling(getHibernateTemplate()); - scheduleDynamicPropertiesEvaluation(Arrays.asList(sample)); + scheduleDynamicPropertiesEvaluation(Collections.singletonList(sample)); if (operationLog.isInfoEnabled()) { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java index 51452c9d3ce5b8213a1011a836b10455eeb126f2..6b4bcdfe74ad6c68fdf4b72ff43f6bdf6db00d71 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java @@ -215,9 +215,6 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen sampleBO.addAttachment(AttachmentTranslator.translate(attachment)); } sampleBO.save(); - AbstractServer.scheduleDynamicPropertiesEvaluation(getDAOFactory() - .getDynamicPropertyEvaluationScheduler(), SamplePE.class, Arrays.asList(sampleBO - .getSample())); } public Experiment getExperimentInfo(final String sessionToken, @@ -536,9 +533,6 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen sampleBO.setExperiment(experiment); } } - AbstractServer.scheduleDynamicPropertiesEvaluation(getDAOFactory() - .getDynamicPropertyEvaluationScheduler(), ExperimentPE.class, Arrays - .asList(experimentBO.getExperiment())); } public void registerMaterials(String sessionToken, String materialTypeCode, @@ -709,9 +703,6 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen ExperimentPE experiment = experimentBO.getExperiment(); result.setModificationDate(experiment.getModificationDate()); result.setSamples(Code.extractCodes(experiment.getSamples())); - scheduleDynamicPropertiesEvaluation( - getDAOFactory().getDynamicPropertyEvaluationScheduler(), ExperimentPE.class, - Arrays.asList(experimentBO.getExperiment())); return result; } @@ -737,9 +728,6 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen List<String> parents = IdentifierExtractor.extract(sample.getParents()); Collections.sort(parents); result.setParents(parents); - AbstractServer.scheduleDynamicPropertiesEvaluation(getDAOFactory() - .getDynamicPropertyEvaluationScheduler(), SamplePE.class, Arrays.asList(sampleBO - .getSample())); return result; } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/ETLServiceTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/ETLServiceTest.java index c37197ed752b775912f155dcf51340de59c10945..dce550ad4eea58a7105027c024eb627c87360ba1 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/ETLServiceTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/ETLServiceTest.java @@ -38,7 +38,6 @@ import ch.systemsx.cisd.common.exceptions.ConfigurationFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.openbis.generic.server.business.IDataStoreServiceFactory; import ch.systemsx.cisd.openbis.generic.server.business.bo.ICommonBusinessObjectFactory; -import ch.systemsx.cisd.openbis.generic.server.dataaccess.DynamicPropertyEvaluationOperation; import ch.systemsx.cisd.openbis.generic.shared.AbstractServerTestCase; import ch.systemsx.cisd.openbis.generic.shared.CommonTestUtils; import ch.systemsx.cisd.openbis.generic.shared.IDataStoreService; @@ -510,8 +509,6 @@ public class ETLServiceTest extends AbstractServerTestCase one(sampleBO).define(sample); one(sampleBO).save(); - one(evaluator).scheduleUpdate( - with(any(DynamicPropertyEvaluationOperation.class))); exactly(1).of(sampleBO).getSample(); SamplePE samplePE = new SamplePE(); samplePE.setId(id); @@ -538,8 +535,6 @@ public class ETLServiceTest extends AbstractServerTestCase one(sampleBO).define(sample); one(sampleBO).save(); - one(evaluator).scheduleUpdate( - with(any(DynamicPropertyEvaluationOperation.class))); exactly(2).of(sampleBO).getSample(); SamplePE samplePE = new SamplePE(); samplePE.setId(id); @@ -571,8 +566,6 @@ public class ETLServiceTest extends AbstractServerTestCase one(sampleBO).define(sample); one(sampleBO).save(); - one(evaluator).scheduleUpdate( - with(any(DynamicPropertyEvaluationOperation.class))); exactly(2).of(sampleBO).getSample(); SamplePE samplePE = new SamplePE(); samplePE.setId(id); @@ -728,8 +721,6 @@ public class ETLServiceTest extends AbstractServerTestCase one(sampleBO).define(sample); one(sampleBO).save(); - one(evaluator).scheduleUpdate( - with(any(DynamicPropertyEvaluationOperation.class))); exactly(2).of(sampleBO).getSample(); will(returnValue(samplePE)); @@ -758,7 +749,7 @@ public class ETLServiceTest extends AbstractServerTestCase context.assertIsSatisfied(); } - @Test() + @Test public void testUpdateSampleAndRegisterDataSet() { prepareGetSession(); @@ -786,9 +777,7 @@ public class ETLServiceTest extends AbstractServerTestCase one(sampleBO).update(sample); one(sampleBO).save(); - one(evaluator).scheduleUpdate( - with(any(DynamicPropertyEvaluationOperation.class))); - exactly(2).of(sampleBO).getSample(); + one(sampleBO).getSample(); will(returnValue(samplePE)); one(boFactory).createExternalDataBO(SESSION); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentBOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentBOTest.java index 087c7077b25531903d9d729b7b9389de958aa362..1578ac12e0d4cf574146d4381fe8d1ec53efbcb2 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentBOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentBOTest.java @@ -223,7 +223,7 @@ public final class ExperimentBOTest extends AbstractBOTest one(permIdDAO).createPermId(); will(returnValue("2009010112341234-1")); - one(experimentDAO).createExperiment(experiment); + one(experimentDAO).createOrUpdateExperiment(experiment); } }); final ExperimentBO experimentBO = createExperimentBO(); @@ -356,7 +356,7 @@ public final class ExperimentBOTest extends AbstractBOTest one(permIdDAO).createPermId(); will(returnValue("2009010101011111-1")); - one(experimentDAO).createExperiment(experiment); + one(experimentDAO).createOrUpdateExperiment(experiment); will(throwException(new DataIntegrityViolationException( "exception description..."))); } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/MaterialTableTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/MaterialTableTest.java index b6bcf48284e7f03a209d34519e87028c50129e27..fa8a58a7047a9f6db10515a23dc163c5265a3a31 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/MaterialTableTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/MaterialTableTest.java @@ -87,7 +87,7 @@ public final class MaterialTableTest extends AbstractBOTest allowing(daoFactory).getMaterialDAO(); will(returnValue(materialDAO)); - one(materialDAO).createMaterials(materials); + one(materialDAO).createOrUpdateMaterials(materials); one(propertiesConverter).checkMandatoryProperties( new HashSet<MaterialPropertyPE>(), materialType, diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBOTest.java index ea8a2651179395356fc4d06b2b89186909577aa4..5600b3b9d3b2b87f384c5672865a02459f6dab5b 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBOTest.java @@ -210,7 +210,7 @@ public final class SampleBOTest extends AbstractBOTest return true; } }; - one(sampleDAO).createSample(with(matcher)); + one(sampleDAO).createOrUpdateSample(with(matcher)); allowing(externalDataDAO).listExternalData(with(matcher)); will(returnValue(new ArrayList<ExternalDataPE>())); @@ -666,7 +666,7 @@ public final class SampleBOTest extends AbstractBOTest allowing(externalDataDAO).hasExternalData(with(sample)); will(returnValue(false)); - one(sampleDAO).createSample(sample); + one(sampleDAO).createOrUpdateSample(sample); one(propertiesConverter).checkMandatoryProperties(sample.getProperties(), sample.getSampleType()); } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EntityTypeDAOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EntityTypeDAOTest.java index 463bef223db328d080965d5f35c6a63a78e46847..d51441485ef52c242f5a7e67df97fd53373a1c80 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EntityTypeDAOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EntityTypeDAOTest.java @@ -202,7 +202,7 @@ public final class EntityTypeDAOTest extends AbstractDAOTest materialTypeDAO.createOrUpdateEntityType(materialType); final IMaterialDAO materialDAO = daoFactory.getMaterialDAO(); List<MaterialPE> materials = createMaterials(3, MATERIAL, materialType); - materialDAO.createMaterials(materials); + materialDAO.createOrUpdateMaterials(materials); boolean exceptionThrown = false; try { @@ -260,7 +260,7 @@ public final class EntityTypeDAOTest extends AbstractDAOTest EntityTypePropertyTypePE assignment = assignPropertyType(expType, materialPropertyType); // Create material - value MaterialPE value = createMaterial(materialType, MATERIAL); - daoFactory.getMaterialDAO().createMaterials(Arrays.asList(value)); + daoFactory.getMaterialDAO().createOrUpdateMaterials(Arrays.asList(value)); // Add property to first found experiment ExperimentPropertyPE property = new ExperimentPropertyPE(); property.setEntityTypePropertyType(assignment); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExperimentDAOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExperimentDAOTest.java index 56ff1aa4c9a6fc33fddf161f985eb1b45a252216..7c26ae3de7129d68672e8b021be0cc17c0f47efa 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExperimentDAOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExperimentDAOTest.java @@ -315,7 +315,7 @@ public class ExperimentDAOTest extends AbstractDAOTest assertEqualsOrGreater(8, sizeBefore); ExperimentPE experiment = createExperiment("CISD", "CISD", "NEMO", "EXP12", "SIRNA_HCS"); - daoFactory.getExperimentDAO().createExperiment(experiment); + daoFactory.getExperimentDAO().createOrUpdateExperiment(experiment); List<ExperimentPE> experimentsAfter = daoFactory.getExperimentDAO().listExperiments(); assertEquals(sizeBefore + 1, experimentsAfter.size()); @@ -337,7 +337,7 @@ public class ExperimentDAOTest extends AbstractDAOTest experiment.setCode(codeModified); experiment.setPermId(daoFactory.getPermIdDAO().createPermId()); final Date modificationTimestamp = experiment.getModificationDate(); - daoFactory.getExperimentDAO().createExperiment(experiment); + daoFactory.getExperimentDAO().createOrUpdateExperiment(experiment); List<ExperimentPE> experimentsAfter = daoFactory.getExperimentDAO().listExperiments(); assertEquals(sizeBefore, experimentsAfter.size()); @@ -355,11 +355,11 @@ public class ExperimentDAOTest extends AbstractDAOTest assertEqualsOrGreater(8, sizeBefore); ExperimentPE experiment = createExperiment("CISD", "CISD", "NEMO", "EXP13", "SIRNA_HCS"); - daoFactory.getExperimentDAO().createExperiment(experiment); + daoFactory.getExperimentDAO().createOrUpdateExperiment(experiment); ExperimentPE experiment2 = createExperiment("CISD", "CISD", "NEMO", "EXP12", "COMPOUND_HCS"); - daoFactory.getExperimentDAO().createExperiment(experiment2); + daoFactory.getExperimentDAO().createOrUpdateExperiment(experiment2); List<ExperimentPE> experimentsAfter = daoFactory.getExperimentDAO().listExperiments(); Collections.sort(experimentsAfter); @@ -384,7 +384,7 @@ public class ExperimentDAOTest extends AbstractDAOTest boolean exceptionThrown = false; try { - daoFactory.getExperimentDAO().createExperiment(experiment); + daoFactory.getExperimentDAO().createOrUpdateExperiment(experiment); } catch (DataIntegrityViolationException e) { exceptionThrown = true; @@ -414,7 +414,7 @@ public class ExperimentDAOTest extends AbstractDAOTest boolean exceptionThrown = false; try { - daoFactory.getExperimentDAO().createExperiment(experiment); + daoFactory.getExperimentDAO().createOrUpdateExperiment(experiment); } catch (final DataIntegrityViolationException ex) { exceptionThrown = true; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/MaterialDAOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/MaterialDAOTest.java index 8fa1b0c704d7fec6d26ff6c8c158012f8972684d..3ae96fa3d72cf75a732b0c5a65ec9a328e959a06 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/MaterialDAOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/MaterialDAOTest.java @@ -69,7 +69,7 @@ public final class MaterialDAOTest extends AbstractDAOTest newMaterials.add(createMaterial(type, "BRAND_NEW_BACTERIUM_1")); newMaterials.add(createMaterial(type, "BRAND_NEW_BACTERIUM_2")); Collections.sort(newMaterials); - daoFactory.getMaterialDAO().createMaterials(newMaterials); + daoFactory.getMaterialDAO().createOrUpdateMaterials(newMaterials); List<MaterialPE> bacteria_after = daoFactory.getMaterialDAO().listMaterialsWithProperties(type); Assert.assertEquals(NUMBER_OF_BACTERIA + newMaterials.size(), bacteria_after.size()); @@ -90,7 +90,7 @@ public final class MaterialDAOTest extends AbstractDAOTest List<MaterialPE> newMaterials = new ArrayList<MaterialPE>(); newMaterials.add(createMaterial(type, BRAND_NEW_BACTERIUM)); newMaterials.add(createMaterial(type, BRAND_NEW_BACTERIUM)); - daoFactory.getMaterialDAO().createMaterials(newMaterials); + daoFactory.getMaterialDAO().createOrUpdateMaterials(newMaterials); } @Test(expectedExceptions = DataIntegrityViolationException.class) @@ -104,7 +104,7 @@ public final class MaterialDAOTest extends AbstractDAOTest String existingBacteriumCode = bacteria_before.get(0).getCode(); List<MaterialPE> newMaterials = new ArrayList<MaterialPE>(); newMaterials.add(createMaterial(type, existingBacteriumCode)); - daoFactory.getMaterialDAO().createMaterials(newMaterials); + daoFactory.getMaterialDAO().createOrUpdateMaterials(newMaterials); } @Test diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAOTest.java index bb791a6a9c8f070855b6f6799f871f5bd0422f09..e54c7c20f5928e0c865894dc21547ae61f5efbb5 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAOTest.java @@ -456,7 +456,7 @@ public final class SampleDAOTest extends AbstractDAOTest final DatabaseInstancePE homeDatabaseInstance = daoFactory.getHomeDatabaseInstance(); samplePE.setDatabaseInstance(homeDatabaseInstance); samplePE.setRegistrator(getSystemPerson()); - sampleDAO.createSample(samplePE); + sampleDAO.createOrUpdateSample(samplePE); // Following line throws a NonUniqueResultException if sample code not unique. sampleDAO.tryFindByCodeAndDatabaseInstance(sampleCode, homeDatabaseInstance); } @@ -470,10 +470,10 @@ public final class SampleDAOTest extends AbstractDAOTest final ISampleDAO sampleDAO = daoFactory.getSampleDAO(); if (samples.length > 1) { - sampleDAO.createSamples(Arrays.asList(samples)); + sampleDAO.createOrUpdateSamples(Arrays.asList(samples)); } else { - sampleDAO.createSample(samples[0]); + sampleDAO.createOrUpdateSample(samples[0]); } } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/scalability/DBCreator.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/scalability/DBCreator.java index e999e5b49cd8472cc91ff04604a31f543aacb8e5..60db0c64bfb349c2be66f4873e54dbdb1e2330d9 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/scalability/DBCreator.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/scalability/DBCreator.java @@ -249,7 +249,7 @@ public final class DBCreator extends AbstractDAOTest long start = System.currentTimeMillis(); log("creating experiment: %d/%d", i, EXPERIMENTS_NO); ExperimentPE experiment = generateExperiment(); - daoFactory.getExperimentDAO().createExperiment(experiment); + daoFactory.getExperimentDAO().createOrUpdateExperiment(experiment); createSamplesWithDataSetsForExperiment(experiment); flushAndClearSession(); long time = (System.currentTimeMillis() - start) / 1000; @@ -281,7 +281,7 @@ public final class DBCreator extends AbstractDAOTest { log("creating sample: %d/%d", i, size); SamplePE sample = generateSampleForExperiment(experiment); - daoFactory.getSampleDAO().createSample(sample); + daoFactory.getSampleDAO().createOrUpdateSample(sample); createDataSetsForSample(sample); } log("created samples"); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java index f53ebac48fb49ff031d25408ff40a6b915563d70..5f1fa78301ad0a0cdfa72d0d49b9509cb8ba6f72 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java @@ -34,7 +34,6 @@ import org.testng.annotations.Test; import ch.rinn.restrictions.Friend; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.openbis.generic.server.business.bo.MaterialUpdateDTO; -import ch.systemsx.cisd.openbis.generic.server.dataaccess.DynamicPropertyEvaluationOperation; import ch.systemsx.cisd.openbis.generic.server.plugin.IDataSetTypeSlaveServerPlugin; import ch.systemsx.cisd.openbis.generic.server.plugin.ISampleTypeSlaveServerPlugin; import ch.systemsx.cisd.openbis.generic.shared.AbstractServerTestCase; @@ -180,11 +179,6 @@ public final class GenericServerTest extends AbstractServerTestCase sample.setId(id); allowing(sampleBO).getSample(); will((returnValue(sample))); - - final DynamicPropertyEvaluationOperation operation = - DynamicPropertyEvaluationOperation.evaluate(SamplePE.class, - Arrays.asList(id)); - one(evaluator).scheduleUpdate(with(operation)); } }); createServer().registerSample(SESSION_TOKEN, newSample, @@ -249,9 +243,10 @@ public final class GenericServerTest extends AbstractServerTestCase newSamples.add(createNewSample("same")); newSamples.add(createNewSample("same")); List<NewSamplesWithTypes> samplesWithTypes = new ArrayList<NewSamplesWithTypes>(); - final NewSamplesWithTypes newSamplesWithType = new NewSamplesWithTypes(new SampleType(), newSamples); + final NewSamplesWithTypes newSamplesWithType = + new NewSamplesWithTypes(new SampleType(), newSamples); samplesWithTypes.add(newSamplesWithType); - + try { server.registerSamples(SESSION_TOKEN, samplesWithTypes); @@ -274,7 +269,8 @@ public final class GenericServerTest extends AbstractServerTestCase newSamples.add(createNewSample("one")); newSamples.add(createNewSample("two")); List<NewSamplesWithTypes> samplesWithTypes = new ArrayList<NewSamplesWithTypes>(); - final NewSamplesWithTypes newSamplesWithType = new NewSamplesWithTypes(sampleType, newSamples); + final NewSamplesWithTypes newSamplesWithType = + new NewSamplesWithTypes(sampleType, newSamples); samplesWithTypes.add(newSamplesWithType); context.checking(new Expectations() { @@ -283,7 +279,7 @@ public final class GenericServerTest extends AbstractServerTestCase will(returnValue(sampleTypePE)); one(sampleTypeSlaveServerPlugin).registerSamples(SESSION, newSamples, null); - + one(propertiesBatchManager).manageProperties(sampleTypePE, newSamplesWithType); } }); @@ -312,7 +308,7 @@ public final class GenericServerTest extends AbstractServerTestCase will(returnValue(sampleTypePE)); one(sampleTypeSlaveServerPlugin).registerSamples(SESSION, newSamples, null); - + one(propertiesBatchManager).manageProperties(sampleTypePE, newSamplesWithType); } }); @@ -339,11 +335,6 @@ public final class GenericServerTest extends AbstractServerTestCase experiment.setId(id); allowing(experimentBO).getExperiment(); will((returnValue(experiment))); - - final DynamicPropertyEvaluationOperation operation = - DynamicPropertyEvaluationOperation.evaluate(ExperimentPE.class, - Arrays.asList(id)); - one(evaluator).scheduleUpdate(with(operation)); } }); createServer().registerExperiment(SESSION_TOKEN, newExperiment, @@ -394,11 +385,6 @@ public final class GenericServerTest extends AbstractServerTestCase will(returnValue(sampleBO)); one(sampleBO).loadBySampleIdentifier(sampleIdentifier2WithGroup); one(sampleBO).setExperiment(experimentPE); - - final DynamicPropertyEvaluationOperation operation = - DynamicPropertyEvaluationOperation.evaluate(ExperimentPE.class, - Arrays.asList(id)); - one(evaluator).scheduleUpdate(with(operation)); } }); createServer().registerExperiment(SESSION_TOKEN, newExperiment, @@ -463,7 +449,7 @@ public final class GenericServerTest extends AbstractServerTestCase { one(daoFactory).getEntityTypeDAO(EntityKind.MATERIAL); will(returnValue(entityTypeDAO)); - + one(propertiesBatchManager).manageProperties(materialTypePE, newMaterials); one(entityTypeDAO).tryToFindEntityTypeByCode(typeCode); @@ -686,11 +672,6 @@ public final class GenericServerTest extends AbstractServerTestCase one(sampleBO).save(); allowing(sampleBO).getSample(); will(returnValue(sample)); - - final DynamicPropertyEvaluationOperation operation = - DynamicPropertyEvaluationOperation.evaluate(SamplePE.class, - Arrays.asList(id)); - one(evaluator).scheduleUpdate(with(operation)); } }); SampleUpdateResult result = createServer().updateSample(SESSION_TOKEN, updates); @@ -726,11 +707,6 @@ public final class GenericServerTest extends AbstractServerTestCase one(experimentBO).save(); allowing(experimentBO).getExperiment(); will(returnValue(experiment)); - - final DynamicPropertyEvaluationOperation operation = - DynamicPropertyEvaluationOperation.evaluate(ExperimentPE.class, - Arrays.asList(id)); - one(evaluator).scheduleUpdate(with(operation)); } }); ExperimentUpdateResult result = createServer().updateExperiment(SESSION_TOKEN, updates); @@ -872,8 +848,7 @@ public final class GenericServerTest extends AbstractServerTestCase one(experimentTable).save(); } }); - createServer().registerExperiments(SESSION_TOKEN, - experiments); + createServer().registerExperiments(SESSION_TOKEN, experiments); context.assertIsSatisfied(); } }