diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommandTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommandTest.java index da6826ab588001a1ff779b8cb0a30c5bab7237de..f6ed78e85b6ee2059d51bafb93ebfd4a63cca30f 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommandTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommandTest.java @@ -169,7 +169,7 @@ public class UploadingCommandTest extends AssertJUnit DataSetTypePE dataSetTypePE = new DataSetTypePE(); dataSetTypePE.setCode("D"); externalData.setDataSetType(dataSetTypePE); - externalData.setupExperiment(createExperiment()); + externalData.setExperiment(createExperiment()); // TODO 2009-09-15, Piotr Buczek: write a test with no parents but with sample connection // Does it make any difference how many parents are added here? externalData.addParent(createParent("parent1")); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataBO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataBO.java index cc55fa8421dab973cfb05feb017825a03c9d15d1..264f839c7c459d4888ccd7e8d84710fd92a68ff4 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataBO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataBO.java @@ -140,7 +140,7 @@ public class ExternalDataBO extends AbstractExternalDataBusinessObject implement define(data, sourceType); externalData.setSample(sample); - externalData.setupExperiment(sample.getExperiment()); + externalData.setExperiment(sample.getExperiment()); } public void define(NewExternalData data, ExperimentPE experiment, SourceType sourceType) @@ -148,7 +148,7 @@ public class ExternalDataBO extends AbstractExternalDataBusinessObject implement assert experiment != null : "Undefined experiment."; DataStorePE dataStore = define(data, sourceType); - externalData.setupExperiment(experiment); + externalData.setExperiment(experiment); final List<String> parentDataSetCodes = data.getParentDataSetCodes(); if (parentDataSetCodes != null) { @@ -250,7 +250,7 @@ public class ExternalDataBO extends AbstractExternalDataBusinessObject implement parent.setCode(parentDataSetCode); String code = DataSetTypeCode.UNKNOWN.getCode(); parent.setDataSetType(getDataSetTypeDAO().tryToFindDataSetTypeByCode(code)); - parent.setupExperiment(experiment); + parent.setExperiment(experiment); parent.setPlaceholder(true); dataDAO.createDataSet(parent); } @@ -513,7 +513,7 @@ public class ExternalDataBO extends AbstractExternalDataBusinessObject implement // move dataset to the experiment if needed if (experiment.equals(externalData.getExperiment()) == false) { - externalData.setupExperiment(experiment); + externalData.setExperiment(experiment); } externalData.setSample(newSample); } @@ -522,7 +522,7 @@ public class ExternalDataBO extends AbstractExternalDataBusinessObject implement { assert experimentIdentifierOrNull != null; ExperimentPE experiment = getExperimentByIdentifier(experimentIdentifierOrNull); - externalData.setupExperiment(experiment); + externalData.setExperiment(experiment); } private ExperimentPE getExperimentByIdentifier(final ExperimentIdentifier identifier) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTable.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTable.java index 33f053db4a1f868139db023e8d6a852a734ed74a..68bad133eabc543846967447d0bb5a7bbe043157 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTable.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTable.java @@ -33,7 +33,6 @@ import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.openbis.generic.server.business.IDataStoreServiceFactory; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IExternalDataDAO; -import ch.systemsx.cisd.openbis.generic.server.util.HibernateTransformer; import ch.systemsx.cisd.openbis.generic.shared.IDataStoreService; import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; @@ -323,9 +322,7 @@ public final class ExternalDataTable extends AbstractExternalDataBusinessObject { IDataStoreService service = dssFactory.create(dataStore.getRemoteUrl()); String sessionToken = dataStore.getSessionToken(); - List<ExternalData> cleanDataSets = - ExternalDataTranslator.translate(HibernateTransformer.HIBERNATE_BEAN_REPLICATOR - .get().copy(dataSets), "?", "?"); + List<ExternalData> cleanDataSets = ExternalDataTranslator.translate(dataSets, "?", "?"); service.uploadDataSetsToCIFEX(sessionToken, cleanDataSets, context); } 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 8d5a180590c9b0d18f4d24f520ede0a81531b3e4..cd8f86dbfa698938a6098982bdf1dd6ea54dac8f 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 @@ -340,7 +340,7 @@ public final class SampleBO extends AbstractSampleBusinessObject implements ISam { for (DataPE dataset : datasets) { - dataset.setupExperiment(experiment); + dataset.setExperiment(experiment); } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/util/HibernateTransformer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/util/HibernateTransformer.java deleted file mode 100644 index f0cee14925fd5bb5d71f92de97c32ef582b5e62d..0000000000000000000000000000000000000000 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/util/HibernateTransformer.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright 2008 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.generic.server.util; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import net.sf.beanlib.hibernate.HibernateBeanReplicator; -import net.sf.beanlib.hibernate3.Hibernate3BeanTransformer; -import net.sf.beanlib.hibernate3.Hibernate3CollectionReplicator; -import net.sf.beanlib.hibernate3.Hibernate3JavaBeanReplicator; -import net.sf.beanlib.spi.BeanTransformerSpi; -import net.sf.beanlib.spi.replicator.BeanReplicatorSpi; -import net.sf.beanlib.spi.replicator.CollectionReplicatorSpi; -import net.sf.beanlib.spi.replicator.CollectionReplicatorSpi.Factory; - -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; -import org.hibernate.Hibernate; -import org.hibernate.collection.PersistentCollection; -import org.hibernate.proxy.HibernateProxy; - -import ch.systemsx.cisd.common.collections.UnmodifiableCollectionDecorator; -import ch.systemsx.cisd.common.exceptions.NotImplementedException; - -/** - * A {@link MethodInterceptor} implementation to get rid of <i>Hibernate</i> proxy classes like - * {@link PersistentCollection} or {@link HibernateProxy}. - * <p> - * Note that this interceptor should only be used on the service layer (when the object is - * <i>detached</i> and when database transactions are closed). Otherwise they might trigger <i>SQL</i> - * calls. - * </p> - * - * @author Christian Ribeaud - */ -public final class HibernateTransformer implements MethodInterceptor -{ - - public final static ThreadLocal<HibernateBeanReplicator> HIBERNATE_BEAN_REPLICATOR = - new ThreadLocal<HibernateBeanReplicator>() - { - - private final HibernateBeanReplicator createHibernateBeanReplicator() - { - final Hibernate3BeanTransformer beanTransformer = - Hibernate3BeanTransformer.newBeanTransformer(); - beanTransformer - .initCollectionReplicatable(new CollectionReplicatorSpiFactory()); - beanTransformer.initBeanReplicatable(new BeanReplicatorSpiFactory()); - return new HibernateBeanReplicator(beanTransformer); - } - - // - // ThreadLocal - // - - @Override - protected final HibernateBeanReplicator initialValue() - { - return createHibernateBeanReplicator(); - } - }; - - // - // MethodInterceptor - // - - public final Object invoke(final MethodInvocation methodInvocation) throws Throwable - { - final Object proceed = methodInvocation.proceed(); - if (proceed != null) - { - return HIBERNATE_BEAN_REPLICATOR.get().copy(proceed); - } - return null; - } - - // - // Helper classes - // - - private static final class BeanReplicatorSpiFactory implements BeanReplicatorSpi.Factory - { - - // - // Factory - // - - public final BeanReplicatorSpi newBeanReplicatable(final BeanTransformerSpi beanTransformer) - { - return new NoInitializationHibernate3JavaBeanReplicator(beanTransformer); - } - } - - private static final class CollectionReplicatorSpiFactory implements Factory - { - - // - // Factory - // - - public final CollectionReplicatorSpi newCollectionReplicatable( - final BeanTransformerSpi beanTransformerSpi) - { - return new NoInitializationHibernate3CollectionReplicator(beanTransformerSpi); - } - } - - private static final class NoInitializationHibernate3CollectionReplicator extends - Hibernate3CollectionReplicator - { - - NoInitializationHibernate3CollectionReplicator(final BeanTransformerSpi beanTransformer) - { - super(beanTransformer); - } - - // - // Hibernate3CollectionReplicator - // - - @SuppressWarnings("unchecked") - @Override - public final <V, T> T replicateCollection(final Collection<V> from, final Class<T> toClass) - { - final boolean unmodifiable = (from instanceof UnmodifiableCollectionDecorator); - final Collection<V> realFrom = - (unmodifiable) ? ((UnmodifiableCollectionDecorator<V>) from).getDecorated() - : from; - if (Hibernate.isInitialized(realFrom) == false) - { - if (realFrom instanceof Set) - { - return (T) new HashSet(0); - } else if (realFrom instanceof List) - { - return (T) new ArrayList(0); - } else - { - throw new NotImplementedException(); - } - } - return super.replicateCollection(realFrom, toClass); - } - } - - private static final class NoInitializationHibernate3JavaBeanReplicator extends - Hibernate3JavaBeanReplicator - { - - NoInitializationHibernate3JavaBeanReplicator(final BeanTransformerSpi beanTransformer) - { - super(beanTransformer); - } - - // - // Hibernate3JavaBeanReplicator - // - - @Override - public final <V, T> T replicateBean(final V from, final Class<T> toClass) - { - if (Hibernate.isInitialized(from) == false) - { - return null; - } - return super.replicateBean(from, toClass); - } - } -} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataPE.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataPE.java index 5c46b9999a20be14e240ef79418c4432bd0950b2..dfa6968a2e38c1cb50a431769579cc755d34ba1c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataPE.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataPE.java @@ -387,7 +387,7 @@ public class DataPE extends AbstractIdAndCodeHolder<DataPE> implements IEntityPr return code; } - public void setupExperiment(final ExperimentPE experiment) + public void setExperiment(final ExperimentPE experiment) { if (experiment != null) { diff --git a/openbis/source/java/genericApplicationContext.xml b/openbis/source/java/genericApplicationContext.xml index e2e6b8a51a9643197975b367ac44d652a7f5bde1..9b10be83ea9da2c18504ee5fa695d239ab6401c5 100644 --- a/openbis/source/java/genericApplicationContext.xml +++ b/openbis/source/java/genericApplicationContext.xml @@ -111,7 +111,6 @@ <property name="interceptorNames"> <list> <value>exception-translator</value> - <value>hibernate-transformer</value> </list> </property> </bean> @@ -125,8 +124,6 @@ </property> </bean> - <bean id="hibernate-transformer" class="ch.systemsx.cisd.openbis.generic.server.util.HibernateTransformer" /> - <!-- // Transaction --> diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataBOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataBOTest.java index e9325e997c7fca7180d187ba893685ad8cdbbc57..f51a82e6ddba5424fd7d449f33c4566c64db7018 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataBOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataBOTest.java @@ -211,7 +211,7 @@ public class ExternalDataBOTest extends AbstractBOTest final DataPE parentData = new DataPE(); parentData.setCode(PARENT_CODE); parentData.setDataSetType(dataSetTypeUnknown); - parentData.setupExperiment(createExperiment("EXP1")); + parentData.setExperiment(createExperiment("EXP1")); parentData.setPlaceholder(true); context.checking(new Expectations() { @@ -258,7 +258,7 @@ public class ExternalDataBOTest extends AbstractBOTest parentData.setCode(PARENT_CODE); parentData.setDataSetType(dataSetTypeUnknown); ExperimentPE experiment = createExperiment("EXP1"); - parentData.setupExperiment(experiment); + parentData.setExperiment(experiment); parentData.setPlaceholder(true); context.checking(new Expectations() { @@ -454,7 +454,7 @@ public class ExternalDataBOTest extends AbstractBOTest dataSet.setCode(DATA_SET_CODE); dataSet.setModificationDate(PRODUCTION_DATE); dataSet.setSample(sampleOrNull); - dataSet.setupExperiment(experimentOrNull); + dataSet.setExperiment(experimentOrNull); return dataSet; } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTableTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTableTest.java index f3230a245dc34575b490db1f1282a1aecf46a420..b14970ad9bedd4e3db964d29608b5d7ebbda0891 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTableTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTableTest.java @@ -406,7 +406,7 @@ public final class ExternalDataTableTest extends AbstractBOTest group.setDatabaseInstance(instance); project.setGroup(group); experiment.setProject(project); - data.setupExperiment(experiment); + data.setExperiment(experiment); return data; } 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 f116b2f5acff7472cc4a171644b704cddbf00283..d49930050bfa507d8303f66fd2c2c31852310674 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 @@ -252,7 +252,7 @@ public class ExperimentDAOTest extends AbstractDAOTest // Currently there is no such experiment in test DB so we first add a data set // to an empty experiment (with no connections). final ExternalDataPE dataSet = findExternalData("20081105092158673-1"); - dataSet.setupExperiment(deletedExperiment); + dataSet.setExperiment(deletedExperiment); daoFactory.getExternalDataDAO().validateAndSaveUpdatedEntity(dataSet); assertTrue(deletedExperiment.getAttachments().isEmpty()); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExternalDataDAOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExternalDataDAOTest.java index cc1d3cc094cd232bd1233e67d61b98bd2355ae99..ccfdc1cf2081a2a4d663660beefca7e7b9e9e55e 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExternalDataDAOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExternalDataDAOTest.java @@ -115,7 +115,7 @@ public final class ExternalDataDAOTest extends AbstractDAOTest externalData.setCode(dataSetCode); externalData.setDataSetType(getDataSetType(DataSetTypeCode.UNKNOWN)); - externalData.setupExperiment(pickAnExperiment()); + externalData.setExperiment(pickAnExperiment()); if (sampleOrNull != null) { externalData.setSampleAcquiredFrom(sampleOrNull); @@ -156,7 +156,7 @@ public final class ExternalDataDAOTest extends AbstractDAOTest String dataSetCode = daoFactory.getPermIdDAO().createPermId(); data.setCode(dataSetCode); data.setDataSetType(getDataSetType(DataSetTypeCode.UNKNOWN)); - data.setupExperiment(pickAnExperiment()); + data.setExperiment(pickAnExperiment()); data.setSampleAcquiredFrom(pickASample()); data.setPlaceholder(true); data.setDataStore(pickADataStore()); @@ -168,7 +168,7 @@ public final class ExternalDataDAOTest extends AbstractDAOTest externalData.setCode(dataSetCode); externalData.setDataSetType(getDataSetType(DataSetTypeCode.UNKNOWN)); externalData.setDataStore(pickADataStore()); - externalData.setupExperiment(pickAnExperiment()); + externalData.setExperiment(pickAnExperiment()); externalData.setSampleAcquiredFrom(pickASample()); externalData.setFileFormatType(pickAFileFormatType()); externalData.setLocatorType(pickALocatorType()); 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 bc361f9ce9b215ea1a6df910c644a4de0c825651..01f72627f56c8762c6b16517794f6b4b07e1dcec 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 @@ -324,7 +324,7 @@ public final class DBCreator extends AbstractDAOTest String dataSetCode = daoFactory.getPermIdDAO().createPermId(); externalData.setCode(dataSetCode); externalData.setDataSetType(defaultDataSetType); - externalData.setupExperiment(sample.getExperiment()); + externalData.setExperiment(sample.getExperiment()); externalData.setSampleAcquiredFrom(sample); externalData.setFileFormatType(pickAFileFormatType()); externalData.setLocatorType(pickALocatorType()); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/translator/ExternalDataTranslatorTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/translator/ExternalDataTranslatorTest.java index 9711c424ac4c3019bc7d0645d218e8e3339a62f1..8a1392cace9a1b781b4b7201777dffc2d9923d9e 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/translator/ExternalDataTranslatorTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/translator/ExternalDataTranslatorTest.java @@ -98,7 +98,7 @@ public class ExternalDataTranslatorTest extends AssertJUnit groupPE.setDatabaseInstance(databaseInstancePE); projectPE.setGroup(groupPE); experimentPE.setProject(projectPE); - externalDataPE.setupExperiment(experimentPE); + externalDataPE.setExperiment(experimentPE); externalDataPE.setProductionDate(new Date(1)); externalDataPE.setRegistrationDate(new Date(2)); SamplePE samplePE = new SamplePE(); @@ -163,7 +163,7 @@ public class ExternalDataTranslatorTest extends AssertJUnit groupPE.setDatabaseInstance(databaseInstancePE); projectPE.setGroup(groupPE); experimentPE.setProject(projectPE); - externalDataPE.setupExperiment(experimentPE); + externalDataPE.setExperiment(experimentPE); externalDataPE.addParent(createParent("parent-1")); externalDataPE.addParent(createParent("parent-2"));