diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonBusinessObjectFactory.java index 71734770c1e72fd0e9ee0b44b7677928b9306caf..a6a18fdb75a605542aa812b38e54bb95257b4fbb 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonBusinessObjectFactory.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonBusinessObjectFactory.java @@ -26,7 +26,6 @@ import ch.systemsx.cisd.openbis.generic.server.business.bo.EntityTypeBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.EntityTypePropertyTypeBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.ExperimentBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.ExperimentTable; -import ch.systemsx.cisd.openbis.generic.server.business.bo.ExternalDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.GridCustomColumnBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.GridCustomFilterBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.GroupBO; @@ -39,7 +38,6 @@ import ch.systemsx.cisd.openbis.generic.server.business.bo.IEntityTypeBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IEntityTypePropertyTypeBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExperimentBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExperimentTable; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IExternalDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IGridCustomFilterOrColumnBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IGroupBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IMaterialBO; @@ -138,11 +136,6 @@ public final class CommonBusinessObjectFactory extends AbstractBusinessObjectFac return new DataBO(getDaoFactory(), session); } - public IExternalDataBO createExternalDataBO(Session session) - { - return new ExternalDataBO(getDaoFactory(), session); - } - public final IDataSetTable createDataSetTable(final Session session) { return new DataSetTable(getDaoFactory(), getDSSFactory(), session); 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 592523fb9f2162ab95d0514209e9b82b8c017fbc..df2748117442b43c18f47c8e23594e5e4f5c3540 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 @@ -49,7 +49,6 @@ import ch.systemsx.cisd.openbis.generic.server.business.bo.IEntityTypeBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IEntityTypePropertyTypeBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExperimentBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExperimentTable; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IExternalDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IGridCustomFilterOrColumnBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IGroupBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IMaterialBO; @@ -2254,9 +2253,9 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt switch (entityKind) { case DATA_SET: - IExternalDataBO bo = businessObjectFactory.createExternalDataBO(session); + IDataBO bo = businessObjectFactory.createDataBO(session); bo.loadByCode(entityIdentifier); - entity = bo.getExternalData(); + entity = bo.getData(); break; case EXPERIMENT: IExperimentBO expBO = businessObjectFactory.createExperimentBO(session); @@ -2341,13 +2340,12 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt Session session = getSession(sessionToken); try { - IExternalDataBO dataSetBO = businessObjectFactory.createExternalDataBO(session); + IDataBO dataSetBO = businessObjectFactory.createDataBO(session); dataSetBO.loadDataByTechId(experimentId); // Evaluate the script dataSetBO.enrichWithProperties(); - Set<? extends EntityPropertyPE> properties = - dataSetBO.getExternalData().getProperties(); + Set<? extends EntityPropertyPE> properties = dataSetBO.getData().getProperties(); ManagedPropertyEvaluator evaluator = tryManagedPropertyEvaluator(managedProperty, properties); extendWithPerson(updateAction, session.tryGetPerson()); 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 97cde4b4c38cf8f033aba951b7a3c3eaea9c63e7..4b6832c2363f24c2803b8a4f1fe473b17eae1169 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 @@ -37,7 +37,6 @@ import ch.systemsx.cisd.openbis.generic.server.business.bo.ICommonBusinessObject import ch.systemsx.cisd.openbis.generic.server.business.bo.IDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExperimentBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExperimentTable; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IExternalDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IGroupBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IProjectBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IRoleAssignmentTable; @@ -136,7 +135,6 @@ import ch.systemsx.cisd.openbis.generic.shared.translator.EntityPropertyTranslat import ch.systemsx.cisd.openbis.generic.shared.translator.ExperimentTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.ExperimentTranslator.LoadableFields; import ch.systemsx.cisd.openbis.generic.shared.translator.ExperimentTypeTranslator; -import ch.systemsx.cisd.openbis.generic.shared.translator.ExternalDataTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.GroupTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.PersonTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.ProjectTranslator; @@ -693,8 +691,8 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET { assert sessionToken != null : "Unspecified session token."; final Session session = getSession(sessionToken); - final IExternalDataBO externalDataBO = businessObjectFactory.createExternalDataBO(session); - externalDataBO.addPropertiesToDataSet(dataSetCode, properties); + final IDataBO dataBO = businessObjectFactory.createDataBO(session); + dataBO.addPropertiesToDataSet(dataSetCode, properties); } public void updateShareIdAndSize(String sessionToken, String dataSetCode, String shareId, @@ -727,8 +725,8 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET { assert sessionToken != null : "Unspecified session token."; final Session session = getSession(sessionToken); - final IExternalDataBO externalDataBO = businessObjectFactory.createExternalDataBO(session); - externalDataBO.updateStatuses(dataSetCodes, newStatus, presentInArchive); + final IDataBO dataBO = businessObjectFactory.createDataBO(session); + dataBO.updateStatuses(dataSetCodes, newStatus, presentInArchive); } public boolean compareAndSetDataSetStatus(String sessionToken, String dataSetCode, @@ -737,9 +735,9 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET { assert sessionToken != null : "Unspecified session token."; final Session session = getSession(sessionToken); - final IExternalDataBO externalDataBO = businessObjectFactory.createExternalDataBO(session); - externalDataBO.loadByCode(dataSetCode); - return externalDataBO.compareAndSetDataSetStatus(oldStatus, newStatus, newPresentInArchive); + final IDataBO dataBO = businessObjectFactory.createDataBO(session); + dataBO.loadByCode(dataSetCode); + return dataBO.compareAndSetDataSetStatus(oldStatus, newStatus, newPresentInArchive); } public ExternalData tryGetDataSet(String sessionToken, String dataSetCode) @@ -1021,12 +1019,12 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET + experiment.getIdentifier() + "' is invalid."); } - final IExternalDataBO externalDataBO = businessObjectFactory.createExternalDataBO(session); + final IDataBO dataBO = businessObjectFactory.createDataBO(session); SourceType sourceType = externalData.isMeasured() ? SourceType.MEASUREMENT : SourceType.DERIVED; - externalDataBO.define(externalData, samplePE, sourceType); - externalDataBO.save(); - final String dataSetCode = externalDataBO.getExternalData().getCode(); + dataBO.define(externalData, samplePE, sourceType); + dataBO.save(); + final String dataSetCode = dataBO.getData().getCode(); assert dataSetCode != null : "Data set code not specified."; } @@ -1216,24 +1214,24 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET AtomicEntityOperationDetails operationDetails) { final Session session = getSession(sessionToken); - ArrayList<ExternalDataPE> dataSetsCreated = new ArrayList<ExternalDataPE>(); + ArrayList<DataPE> dataSetsCreated = new ArrayList<DataPE>(); ArrayList<? extends NewExternalData> dataSetRegistrations = operationDetails.getDataSetRegistrations(); for (NewExternalData dataSet : dataSetRegistrations) { SampleIdentifier sampleIdentifier = dataSet.getSampleIdentifierOrNull(); - IExternalDataBO externalData; + IDataBO dataBO; if (sampleIdentifier != null) { - externalData = registerDataSetInternal(session, sampleIdentifier, dataSet); + dataBO = registerDataSetInternal(session, sampleIdentifier, dataSet); } else { ExperimentIdentifier experimentIdentifier = dataSet.getExperimentIdentifierOrNull(); - externalData = registerDataSetInternal(session, experimentIdentifier, dataSet); + dataBO = registerDataSetInternal(session, experimentIdentifier, dataSet); } - dataSetsCreated.add(externalData.getExternalData()); + dataSetsCreated.add(dataBO.getData()); } - return ExternalDataTranslator.translate(dataSetsCreated, "", session.getBaseIndexURL()); + return DataSetTranslator.translate(dataSetsCreated, "", session.getBaseIndexURL()); } private ArrayList<Experiment> createExperiments(String sessionToken, @@ -1251,7 +1249,7 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET return experimentsCreated; } - private IExternalDataBO registerDataSetInternal(final Session session, + private IDataBO registerDataSetInternal(final Session session, SampleIdentifier sampleIdentifier, NewExternalData externalData) { ExperimentPE experiment = tryLoadExperimentBySampleIdentifier(session, sampleIdentifier); @@ -1267,18 +1265,18 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET final ISampleBO sampleBO = businessObjectFactory.createSampleBO(session); sampleBO.loadBySampleIdentifier(sampleIdentifier); final SamplePE cellPlate = sampleBO.getSample(); - final IExternalDataBO externalDataBO = businessObjectFactory.createExternalDataBO(session); + final IDataBO dataBO = businessObjectFactory.createDataBO(session); SourceType sourceType = externalData.isMeasured() ? SourceType.MEASUREMENT : SourceType.DERIVED; - externalDataBO.define(externalData, cellPlate, sourceType); - externalDataBO.save(); - final String dataSetCode = externalDataBO.getExternalData().getCode(); + dataBO.define(externalData, cellPlate, sourceType); + dataBO.save(); + final String dataSetCode = dataBO.getData().getCode(); assert dataSetCode != null : "Data set code not specified."; - return externalDataBO; + return dataBO; } - private IExternalDataBO registerDataSetInternal(final Session session, + private IDataBO registerDataSetInternal(final Session session, ExperimentIdentifier experimentIdentifier, NewExternalData externalData) { ExperimentPE experiment = tryToLoadExperimentByIdentifier(session, experimentIdentifier); @@ -1287,12 +1285,12 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET throw new UserFailureException("Data set can not be registered because experiment '" + experiment.getIdentifier() + "' is invalid."); } - final IExternalDataBO externalDataBO = businessObjectFactory.createExternalDataBO(session); + final IDataBO externalDataBO = businessObjectFactory.createDataBO(session); SourceType sourceType = externalData.isMeasured() ? SourceType.MEASUREMENT : SourceType.DERIVED; externalDataBO.define(externalData, experiment, sourceType); externalDataBO.save(); - final String dataSetCode = externalDataBO.getExternalData().getCode(); + final String dataSetCode = externalDataBO.getData().getCode(); assert dataSetCode != null : "Data set code not specified."; return externalDataBO; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObject.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObject.java index b24852f3c9cc71a33c7c2ad508397695cb8ae2d6..7ef236f31c3dd310e16646e4dc64792945a92048 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObject.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObject.java @@ -31,7 +31,6 @@ import ch.systemsx.cisd.openbis.generic.server.dataaccess.IEntityPropertyTypeDAO import ch.systemsx.cisd.openbis.generic.server.dataaccess.IEntityTypeDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IEventDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IExperimentDAO; -import ch.systemsx.cisd.openbis.generic.server.dataaccess.IExternalDataDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IFileFormatTypeDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IGridCustomColumnDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IGridCustomFilterDAO; @@ -209,11 +208,6 @@ abstract class AbstractBusinessObject implements IDAOFactory return daoFactory.getDataDAO(); } - public final IExternalDataDAO getExternalDataDAO() - { - return daoFactory.getExternalDataDAO(); - } - public final IHibernateSearchDAO getHibernateSearchDAO() { return daoFactory.getHibernateSearchDAO(); 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 deleted file mode 100644 index 6f2097e129656229ca0fa85bae403d19e220a502..0000000000000000000000000000000000000000 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataBO.java +++ /dev/null @@ -1,722 +0,0 @@ -/* - * Copyright 2009 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.business.bo; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import ch.rinn.restrictions.Friend; -import ch.systemsx.cisd.common.collections.CollectionUtils; -import ch.systemsx.cisd.common.exceptions.UserFailureException; -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.dataaccess.IVocabularyDAO; -import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetArchivingStatus; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityProperty; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.FileFormatType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.LocatorType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SourceType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.IManagedProperty; -import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetPropertyPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetTypePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetUpdatesDTO; -import ch.systemsx.cisd.openbis.generic.shared.dto.DataStorePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.FileFormatTypePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.NewExternalData; -import ch.systemsx.cisd.openbis.generic.shared.dto.NewProperty; -import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.Session; -import ch.systemsx.cisd.openbis.generic.shared.dto.StorageFormat; -import ch.systemsx.cisd.openbis.generic.shared.dto.VocabularyPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.VocabularyTermPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifier; -import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; -import ch.systemsx.cisd.openbis.generic.shared.dto.types.DataSetTypeCode; -import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils; - -/** - * @author Franz-Josef Elmer - */ -@SuppressWarnings("deprecation") -@Friend(toClasses = DataPE.class) -public class ExternalDataBO extends AbstractDataSetBusinessObject implements IExternalDataBO -{ - private ExternalDataPE externalData; - - public ExternalDataBO(IDAOFactory daoFactory, Session session) - { - super(daoFactory, session); - } - - public ExternalDataBO(IDAOFactory daoFactory, Session exampleSession, - IEntityPropertiesConverter propertiesConverter) - { - super(daoFactory, exampleSession, propertiesConverter); - } - - public ExternalDataPE tryExternalData() - { - return externalData; - } - - public ExternalDataPE getExternalData() - { - // TODO 2010-04-12, CR: This should throw an exception if the external data is null - // -- will that cause problems with clients? - return externalData; - } - - public void loadByCode(String dataSetCode) - { - loadByCode(dataSetCode, true, false); - } - - private void loadByCode(String dataSetCode, boolean withPropertyTypes, boolean lockForUpdate) - { - externalData = - getExternalDataDAO().tryToFindFullDataSetByCode(dataSetCode, withPropertyTypes, - lockForUpdate); - } - - static final String DATA_SET_TYPE = "dataSetType"; - - static final String PROPERTY_TYPES = "dataSetType.dataSetTypePropertyTypesInternal"; - - public void loadDataByTechId(TechId datasetId) - { - String[] connections = - { PROPERTY_TYPES, DATA_SET_TYPE }; - externalData = getExternalDataDAO().tryGetByTechId(datasetId, connections); - if (externalData == null) - { - throw new UserFailureException(String.format("Data set with ID '%s' does not exist.", - datasetId)); - } - } - - public void enrichWithParentsAndExperiment() - { - if (externalData != null) - { - enrichWithParentsAndExperiment(externalData); - } - } - - public void enrichWithChildren() - { - if (externalData != null) - { - enrichWithChildren(externalData); - } - } - - public final void enrichWithProperties() - { - if (externalData != null) - { - HibernateUtils.initialize(externalData.getProperties()); - } - } - - public void enrichWithContainedDataSets() - { - if (externalData != null && externalData.isContainer()) - { - HibernateUtils.initialize(externalData.getContainedDataSets()); - } - } - - public void define(NewExternalData data, SamplePE sample, SourceType sourceType) - { - assert sample != null : "Undefined sample."; - - final DataStorePE dataStore = define(data, sourceType); - final ExperimentPE experiment = sample.getExperiment(); - - externalData.setSample(sample); - externalData.setExperiment(experiment); - - setParentDataSets(dataStore, experiment, data); - } - - public void define(NewExternalData data, ExperimentPE experiment, SourceType sourceType) - { - assert experiment != null : "Undefined experiment."; - - final DataStorePE dataStore = define(data, sourceType); - - externalData.setExperiment(experiment); - setParentDataSets(dataStore, experiment, data); - } - - private void setParentDataSets(DataStorePE dataStore, ExperimentPE experiment, - NewExternalData data) - { - final List<String> parentDataSetCodes = data.getParentDataSetCodes(); - if (parentDataSetCodes != null) - { - for (String parentCode : parentDataSetCodes) - { - final DataPE parent = getOrCreateParentData(parentCode, dataStore, experiment); - externalData.addParent(parent); - } - } - } - - private DataStorePE define(NewExternalData data, SourceType sourceType) - { - assert data != null : "Undefined data."; - final DataSetType dataSetType = data.getDataSetType(); - assert dataSetType != null : "Undefined data set type."; - final FileFormatType fileFormatType = data.getFileFormatType(); - assert fileFormatType != null : "Undefined file format type."; - final String location = data.getLocation(); - assert location != null : "Undefined location."; - final LocatorType locatorType = data.getLocatorType(); - assert locatorType != null : "Undefined location type."; - assert sourceType != null : "Undefined source type."; - - externalData = new ExternalDataPE(); - - externalData.setDataProducerCode(data.getDataProducerCode()); - externalData.setProductionDate(data.getProductionDate()); - externalData.setCode(data.getCode()); - externalData.setDataSetType(getDataSetType(dataSetType)); - externalData.setFileFormatType(getFileFomatType(fileFormatType)); - externalData.setComplete(data.getComplete()); - externalData.setShareId(data.getShareId()); - externalData.setLocation(location); - externalData.setSize(data.getSize()); - externalData.setSpeedHint(data.getSpeedHint()); - externalData.setStorageFormatVocabularyTerm(tryToFindStorageFormatTerm(data - .getStorageFormat())); - externalData.setLocatorType(getLocatorTypeDAO().tryToFindLocatorTypeByCode( - locatorType.getCode())); - externalData.setRegistrator(tryToGetRegistrator(data)); - DataStorePE dataStore = getDataStoreDAO().tryToFindDataStoreByCode(data.getDataStoreCode()); - externalData.setDataStore(dataStore); - defineDataSetProperties(externalData, - convertToDataSetProperties(data.getDataSetProperties())); - externalData.setDerived(sourceType == SourceType.DERIVED); - return dataStore; - } - - private PersonPE tryToGetRegistrator(NewExternalData data) - { - String userId = data.getUserId(); - if (userId != null) - { - return getPersonDAO().tryFindPersonByUserId(userId); - } - String userEMail = data.getUserEMail(); - if (userEMail == null) - { - return null; - } - List<PersonPE> persons = getPersonDAO().listPersons(); - for (PersonPE person : persons) - { - if (userEMail.equalsIgnoreCase(person.getEmail())) - { - return person; - } - } - return null; - } - - private VocabularyTermPE tryToFindStorageFormatTerm(StorageFormat storageFormat) - { - IVocabularyDAO vocabularyDAO = getVocabularyDAO(); - VocabularyPE vocabulary = - vocabularyDAO.tryFindVocabularyByCode(StorageFormat.VOCABULARY_CODE); - Set<VocabularyTermPE> terms = vocabulary.getTerms(); - for (VocabularyTermPE term : terms) - { - if (storageFormat.getCode().equals(term.getCode())) - { - return term; - } - } - return null; - } - - private final DataSetTypePE getDataSetType(final DataSetType dataSetType) - { - final String dataSetTypeCode = dataSetType.getCode(); - final DataSetTypePE dataSetTypeOrNull = - getDataSetTypeDAO().tryToFindDataSetTypeByCode(dataSetTypeCode); - if (dataSetTypeOrNull == null) - { - throw UserFailureException.fromTemplate("There is no data set type with code '%s'", - dataSetTypeCode); - } - return dataSetTypeOrNull; - } - - private final FileFormatTypePE getFileFomatType(final FileFormatType fileFormatType) - { - final String fileFormatTypeCode = fileFormatType.getCode(); - final FileFormatTypePE fileFormatTypeOrNull = - getFileFormatTypeDAO().tryToFindFileFormatTypeByCode(fileFormatTypeCode); - if (fileFormatTypeOrNull == null) - { - throw UserFailureException.fromTemplate("There is no file format type with code '%s'", - fileFormatTypeCode); - } - return fileFormatTypeOrNull; - } - - private final DataPE getOrCreateParentData(final String parentDataSetCode, - DataStorePE dataStore, ExperimentPE experiment) - { - assert parentDataSetCode != null : "Unspecified parent data set code."; - - final IExternalDataDAO dataDAO = getExternalDataDAO(); - DataPE parent = dataDAO.tryToFindDataSetByCode(parentDataSetCode); - if (parent == null) - { - parent = new DataPE(); - parent.setDataStore(dataStore); - parent.setCode(parentDataSetCode); - String code = DataSetTypeCode.UNKNOWN.getCode(); - parent.setDataSetType(getDataSetTypeDAO().tryToFindDataSetTypeByCode(code)); - parent.setExperiment(experiment); - parent.setPlaceholder(true); - dataDAO.createDataSet(parent); - } - return parent; - } - - public void save() throws UserFailureException - { - assert externalData != null : "Undefined external data."; - IExternalDataDAO externalDataDAO = getExternalDataDAO(); - String dataCode = externalData.getCode(); - DataPE data = externalDataDAO.tryToFindDataSetByCode(dataCode); - if (data == null) - { - externalDataDAO.createDataSet(externalData); - } else - { - if (data.isPlaceholder() == false) - { - throw new UserFailureException("Already existing data set for code '" + dataCode - + "' can not be updated by data set " + externalData); - } - // NOTE: If new data set is created and there was no placeholder - // cycles will not be created because only connections to parents are added - // and we assume that there were no cycles before. On the other hand placeholders - // have at least one child so cycles need to be checked when they are updated. - validateRelationshipGraph(externalData.getParents()); - - externalData.setPlaceholder(false); - externalData.setId(HibernateUtils.getId(data)); - externalData.setRegistrationDate(new Date()); - externalData.setModificationDate(data.getModificationDate()); - - externalDataDAO.updateDataSet(externalData); - } - entityPropertiesConverter.checkMandatoryProperties(externalData.getProperties(), - externalData.getDataSetType()); - } - - public void addPropertiesToDataSet(String dataSetCode, List<NewProperty> properties) - { - loadByCode(dataSetCode); - updatePropertiesPreservingExisting(properties); - entityPropertiesConverter.checkMandatoryProperties(externalData.getProperties(), - externalData.getDataSetType()); - validateAndSave(); - } - - private void updatePropertiesPreservingExisting(List<NewProperty> properties) - { - final Set<DataSetPropertyPE> existingProperties = externalData.getProperties(); - Set<String> propertyUpdatesCodes = - extractPropertyCodesToUpdate(properties, existingProperties); - List<NewProperty> propertyUpdates = - extractNewPropertiesToUpdate(properties, propertyUpdatesCodes); - final DataSetTypePE type = externalData.getDataSetType(); - final PersonPE registrator = findRegistrator(); - externalData.setProperties(entityPropertiesConverter.updateProperties(existingProperties, - type, Arrays.asList(convertToDataSetProperties(propertyUpdates)), registrator, - propertyUpdatesCodes)); - } - - private List<NewProperty> extractNewPropertiesToUpdate(List<NewProperty> properties, - Set<String> propertiesToUpdate) - { - List<NewProperty> newPropertiesToUpdate = new ArrayList<NewProperty>(); - for (NewProperty np : properties) - { - if (propertiesToUpdate.contains(np.getPropertyCode())) - { - newPropertiesToUpdate.add(np); - } - } - return newPropertiesToUpdate; - } - - private Set<String> extractPropertyCodesToUpdate(List<NewProperty> properties, - final Set<DataSetPropertyPE> existingProperties) - { - Set<String> propertiesToUpdate = new HashSet<String>(); - for (NewProperty np : properties) - { - propertiesToUpdate.add(np.getPropertyCode()); - } - for (DataSetPropertyPE ep : existingProperties) - { - propertiesToUpdate.remove(ep.getEntityTypePropertyType().getPropertyType().getCode()); - } - return propertiesToUpdate; - } - - public void update(DataSetUpdatesDTO updates) - { - loadDataByTechId(updates.getDatasetId()); - if (updates.getVersion().equals(externalData.getModificationDate()) == false) - { - throwModifiedEntityException("Data set"); - } - final SampleIdentifier sampleIdentifierOrNull = updates.getSampleIdentifierOrNull(); - if (sampleIdentifierOrNull != null) - { - // update sample and indirectly experiment - updateSample(updates.getSampleIdentifierOrNull()); - } else - { - updateExperiment(updates.getExperimentIdentifierOrNull()); - // remove connection with sample - externalData.setSample(null); - } - updateParents(updates.getModifiedParentDatasetCodesOrNull()); - updateFileFormatType(updates.getFileFormatTypeCode()); - updateProperties(externalData, updates.getProperties()); - entityPropertiesConverter.checkMandatoryProperties(externalData.getProperties(), - externalData.getDataSetType()); - validateAndSave(); - } - - private void validateAndSave() - { - getExternalDataDAO().validateAndSaveUpdatedEntity(externalData); - } - - private void updateParents(String[] modifiedParentDatasetCodesOrNull) - { - if (modifiedParentDatasetCodesOrNull == null) - { - return; // parents were not changed - } else - { - final Set<DataPE> currentParents = externalData.getParents(); - final Set<String> currentParentCodes = extractCodes(currentParents); - final Set<String> newCodes = asSet(modifiedParentDatasetCodesOrNull); - newCodes.removeAll(currentParentCodes); - - // quick check for direct cycle - if (newCodes.contains(externalData.getCode())) - { - throw new UserFailureException("Data set '" + externalData.getCode() - + "' can not be its own parent."); - } - - final List<DataPE> parentsToAdd = findDataSetsByCodes(newCodes); - validateRelationshipGraph(parentsToAdd); - addParents(parentsToAdd); - - final Set<String> removedCodes = currentParentCodes; - removedCodes.removeAll(asSet(modifiedParentDatasetCodesOrNull)); - removeParents(filterDataSets(currentParents, removedCodes)); - } - } - - /** - * Throws {@link UserFailureException} if adding specified parents to this data set will create - * a cycle in data set relationships. - */ - private void validateRelationshipGraph(Collection<DataPE> parentsToAdd) - { - // DFS from new parents that are to be added to this business object going in direction - // of parent relationship until: - // - all related ancestors are visited == graph has no cycles - // - we get to this business object == cycle is found - // NOTE: The assumption is that there were no cycles in the graph of relationship before. - // This algorithm will not find cycles that don't include this business object, - // although such cycles shouldn't cause it to loop forever. - - // Algorithm operates only on data set ids to make it perform better - // - there is no need to join DB tables. - // To be able to inform user about the exact data set that cannot be connected as a parent - // we need start seeking cycles starting from each parent to be added separately. Otherwise - // we would need to get invoke more queries to DB (not going layer by layer of graph depth - // per query) or use BFS instead (which would also be slower in a general case). - for (DataPE parentToAdd : parentsToAdd) - { - validateRelationshipGraph(parentToAdd); - } - } - - private void validateRelationshipGraph(DataPE parentToAdd) - { - final TechId updatedDataSetId = TechId.create(externalData); - final Set<TechId> visited = new HashSet<TechId>(); - Set<TechId> toVisit = new HashSet<TechId>(); - toVisit.add(TechId.create(parentToAdd)); - while (toVisit.isEmpty() == false) - { - if (toVisit.contains(updatedDataSetId)) - { - throw UserFailureException.fromTemplate( - "Data Set '%s' is an ancestor of Data Set '%s' " - + "and cannot be at the same time set as its child.", - externalData.getCode(), parentToAdd.getCode()); - } else - { - final Set<TechId> nextToVisit = findParentIds(toVisit); - visited.addAll(toVisit); - nextToVisit.removeAll(visited); - toVisit = nextToVisit; - } - } - } - - private Set<TechId> findParentIds(Set<TechId> dataSetIds) - { - return getExternalDataDAO().findParentIds(dataSetIds); - } - - private Collection<DataPE> filterDataSets(Collection<DataPE> dataSets, - Collection<String> seekenCodes) - { - Collection<DataPE> result = new ArrayList<DataPE>(); - for (DataPE dataSet : dataSets) - { - if (seekenCodes.contains(dataSet.getCode())) - { - result.add(dataSet); - } - } - return result; - } - - private void addParents(Collection<DataPE> parentsToAdd) - { - for (DataPE parent : parentsToAdd) - { - externalData.addParent(parent); - } - } - - private void removeParents(Collection<DataPE> parentsToRemove) - { - for (DataPE parent : parentsToRemove) - { - externalData.removeParent(parent); - } - } - - private List<DataPE> findDataSetsByCodes(Set<String> codes) - { - final IExternalDataDAO dao = getExternalDataDAO(); - final List<DataPE> dataSets = new ArrayList<DataPE>(); - final List<String> missingDataSetCodes = new ArrayList<String>(); - for (String code : codes) - { - DataPE dataSetOrNull = dao.tryToFindDataSetByCode(code); - if (dataSetOrNull == null) - { - missingDataSetCodes.add(code); - } else - { - dataSets.add(dataSetOrNull); - } - } - if (missingDataSetCodes.size() > 0) - { - throw UserFailureException.fromTemplate( - "Data Sets with following codes do not exist: '%s'.", - CollectionUtils.abbreviate(missingDataSetCodes, 10)); - } else - { - return dataSets; - } - } - - private static Set<String> asSet(String[] objects) - { - return new HashSet<String>(Arrays.asList(objects)); - } - - private static Set<String> extractCodes(Collection<DataPE> parents) - { - Set<String> codes = new HashSet<String>(parents.size()); - for (DataPE parent : parents) - { - codes.add(parent.getCode()); - } - return codes; - } - - // - - private void updateSample(SampleIdentifier sampleIdentifierOrNull) - { - assert sampleIdentifierOrNull != null; - SamplePE newSample = getSampleByIdentifier(sampleIdentifierOrNull); - SamplePE previousSampleOrNull = externalData.tryGetSample(); - if (newSample.equals(previousSampleOrNull)) - { - return; // nothing to change - } - if (newSample.getSpace() == null) - { - throw createWrongSampleException(newSample, "the new sample is shared"); - } - ExperimentPE experiment = newSample.getExperiment(); - if (experiment == null) - { - throw createWrongSampleException(newSample, - "the new sample is not connected to any experiment"); - } - // move dataset to the experiment if needed - if (experiment.equals(externalData.getExperiment()) == false) - { - externalData.setExperiment(experiment); - } - externalData.setSample(newSample); - } - - private void updateExperiment(ExperimentIdentifier experimentIdentifierOrNull) - { - assert experimentIdentifierOrNull != null; - ExperimentPE experiment = getExperimentByIdentifier(experimentIdentifierOrNull); - externalData.setExperiment(experiment); - } - - private ExperimentPE getExperimentByIdentifier(final ExperimentIdentifier identifier) - { - assert identifier != null : "Experiment identifier unspecified."; - final ProjectPE project = - getProjectDAO().tryFindProject(identifier.getDatabaseInstanceCode(), - identifier.getSpaceCode(), identifier.getProjectCode()); - if (project == null) - { - throw new UserFailureException("Unkown experiment because of unkown project: " - + identifier); - } - final ExperimentPE exp = - getExperimentDAO().tryFindByCodeAndProject(project, identifier.getExperimentCode()); - return exp; - } - - private void updateFileFormatType(String fileFormatTypeCode) - { - FileFormatTypePE fileFormatTypeOrNull = - getFileFormatTypeDAO().tryToFindFileFormatTypeByCode(fileFormatTypeCode); - if (fileFormatTypeOrNull == null) - { - throw new UserFailureException(String.format("File type '%s' does not exist.", - fileFormatTypeCode)); - } else - { - externalData.setFileFormatType(fileFormatTypeOrNull); - } - } - - private UserFailureException createWrongSampleException(SamplePE sample, String reason) - { - return UserFailureException.fromTemplate( - "The dataset '%s' cannot be connected to the sample '%s'" + " because %s.", - externalData.getCode(), sample.getIdentifier(), reason); - } - - private final void defineDataSetProperties(final ExternalDataPE data, - final IEntityProperty[] newProperties) - { - final String dataSetTypeCode = data.getDataSetType().getCode(); - final List<DataSetPropertyPE> properties = - entityPropertiesConverter.convertProperties(newProperties, dataSetTypeCode, - findRegistrator()); - for (final DataSetPropertyPE property : properties) - { - data.addProperty(property); - } - } - - private static IEntityProperty[] convertToDataSetProperties(List<NewProperty> list) - { - IEntityProperty[] result = new IEntityProperty[list.size()]; - for (int i = 0; i < list.size(); i++) - { - result[i] = convertProperty(list.get(i)); - } - return result; - } - - private static IEntityProperty convertProperty(NewProperty newProperty) - { - IEntityProperty result = new EntityProperty(); - result.setValue(newProperty.getValue()); - PropertyType propertyType = new PropertyType(); - propertyType.setCode(newProperty.getPropertyCode()); - result.setPropertyType(propertyType); - return result; - } - - public void updateStatuses(List<String> dataSetCodes, DataSetArchivingStatus newStatus, - boolean newPresentInArchive) - { - getExternalDataDAO().updateDataSetStatuses(dataSetCodes, newStatus, newPresentInArchive); - } - - public boolean compareAndSetDataSetStatus(DataSetArchivingStatus oldStatus, - DataSetArchivingStatus newStatus, boolean newPresentInArchive) - { - if (externalData == null || externalData.getStatus() != oldStatus) - { - return false; - } - updateStatuses(Arrays.asList(externalData.getCode()), newStatus, newPresentInArchive); - return true; - } - - public void updateManagedProperty(IManagedProperty managedProperty) - { - final Set<DataSetPropertyPE> existingProperties = externalData.getProperties(); - final DataSetTypePE type = externalData.getDataSetType(); - final PersonPE registrator = findRegistrator(); - externalData.setProperties(entityPropertiesConverter.updateManagedProperty( - existingProperties, type, managedProperty, registrator)); - } - -} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ICommonBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ICommonBusinessObjectFactory.java index 8f61d8327b97dcc2c3370250c9a49a0a5dd290f3..1b82b956f99fdf64a3a8847786e61e45b78912e1 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ICommonBusinessObjectFactory.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ICommonBusinessObjectFactory.java @@ -42,8 +42,6 @@ public interface ICommonBusinessObjectFactory public ISampleBO createSampleBO(final Session session); - public IExternalDataBO createExternalDataBO(Session session); - public IDataBO createDataBO(Session session); public IDataSetTable createDataSetTable(final Session session); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/IExternalDataBO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/IExternalDataBO.java deleted file mode 100644 index 63bd7b40936b737d8cdefa7ea51bac6e4ffbc227..0000000000000000000000000000000000000000 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/IExternalDataBO.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2009 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.business.bo; - -import java.util.List; - -import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetArchivingStatus; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SourceType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.IManagedProperty; -import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetUpdatesDTO; -import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.NewExternalData; -import ch.systemsx.cisd.openbis.generic.shared.dto.NewProperty; -import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; - -/** - * @deprecated this code will be removed - use IDataBO if possible - * @author Franz-Josef Elmer - */ -@Deprecated -public interface IExternalDataBO extends IEntityBusinessObject -{ - /** - * Returns the external data item which has been created by - * {@link #define(NewExternalData, SamplePE, SourceType)} or null. - */ - public ExternalDataPE tryExternalData(); - - /** - * Returns the external data item which has been created by - * {@link #define(NewExternalData, SamplePE, SourceType)}. - */ - public ExternalDataPE getExternalData(); - - /** - * Defines a new external data item directly connected to a sample. - * <p> - * After invocation of this method {@link IExperimentBO#save()} should be invoked to store the - * new external data item in the Data Access Layer. - */ - public void define(NewExternalData externalData, SamplePE sample, SourceType sourceType); - - /** - * Defines a new external data item not directly connected to a sample but with mandatory - * connection with an experiment. - * <p> - * After invocation of this method {@link IExperimentBO#save()} should be invoked to store the - * new external data item in the Data Access Layer. - */ - public void define(NewExternalData data, ExperimentPE experiment, SourceType sourceType); - - /** - * Changes given data set. Currently allowed changes: properties, sample. - */ - public void update(DataSetUpdatesDTO updates); - - /** - * Updates status of given data sets. - * - * @throws UserFailureException if a data set does not exist or status couldn't be set. - */ - public void updateStatuses(List<String> dataSetCodes, DataSetArchivingStatus newStatus, - boolean newPresentInArchive) throws UserFailureException; - - /** - * Set the status for the loaded dataset to the given new status value if the current status - * equals an expected value. - * - * @return true if the update is successful, false if the current status is different than - * <code>oldStatus</code>. - */ - public boolean compareAndSetDataSetStatus(DataSetArchivingStatus oldStatus, - DataSetArchivingStatus newStatus, boolean newPresentInArchive); - - /** - * Adds chosen properties to given data set. If given property has been already defined, the - * value is not updated. - */ - public void addPropertiesToDataSet(String dataSetCode, List<NewProperty> properties); - - /** - * Loads the external data item with specified code. - */ - public void loadByCode(String dataSetCode); - - /** - * Enrich external data with parents and experiment. - */ - public void enrichWithParentsAndExperiment(); - - /** - * Enrich external data with children and experiment. - */ - public void enrichWithChildren(); - - /** - * Enrich external data with virtual children. - */ - public void enrichWithContainedDataSets(); - - /** - * Enrich external data with properties. - */ - public void enrichWithProperties(); - - /** - * Changes the value of a managed property. - */ - public void updateManagedProperty(IManagedProperty managedProperty); - -} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IAuthorizationDAOFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IAuthorizationDAOFactory.java index 0c3c30881d27549b0de71ee5b2b9c045c77ebda1..2eabc8d6e160796bd55dc1ee6e9d047b0b7ddb09 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IAuthorizationDAOFactory.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IAuthorizationDAOFactory.java @@ -59,9 +59,6 @@ public interface IAuthorizationDAOFactory public IDataDAO getDataDAO(); - @Deprecated - public IExternalDataDAO getExternalDataDAO(); - public IExperimentDAO getExperimentDAO(); public IProjectDAO getProjectDAO(); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/AuthorizationDAOFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/AuthorizationDAOFactory.java index 67ca8690e126144eb453fe70af754dee1bdbe577..70d95ab7e9b4c38223c677c3b068743650a98b81 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/AuthorizationDAOFactory.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/AuthorizationDAOFactory.java @@ -32,7 +32,6 @@ import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDataDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDatabaseInstanceDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDynamicPropertyEvaluationScheduler; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IExperimentDAO; -import ch.systemsx.cisd.openbis.generic.server.dataaccess.IExternalDataDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IGridCustomColumnDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IGridCustomFilterDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IPersonDAO; @@ -68,9 +67,6 @@ public class AuthorizationDAOFactory implements IAuthorizationDAOFactory private final IDataDAO dataDAO; - // FIXME use IDataDAO - private final IExternalDataDAO externalDataDAO; - private final IExperimentDAO experimentDAO; private final DatabaseInstancePE homeDatabaseInstance; @@ -103,7 +99,6 @@ public class AuthorizationDAOFactory implements IAuthorizationDAOFactory groupDAO = new SpaceDAO(sessionFactory, homeDatabaseInstance); roleAssignmentDAO = new RoleAssignmentDAO(sessionFactory, homeDatabaseInstance); dataDAO = new DataDAO(persistencyResources, homeDatabaseInstance); - externalDataDAO = new ExternalDataDAO(persistencyResources, homeDatabaseInstance); experimentDAO = new ExperimentDAO(persistencyResources, homeDatabaseInstance); projectDAO = new ProjectDAO(sessionFactory, homeDatabaseInstance); sampleDAO = new SampleDAO(persistencyResources, homeDatabaseInstance); @@ -212,11 +207,6 @@ public class AuthorizationDAOFactory implements IAuthorizationDAOFactory return dataDAO; } - public final IExternalDataDAO getExternalDataDAO() - { - return externalDataDAO; - } - public final IExperimentDAO getExperimentDAO() { return experimentDAO; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericBusinessObjectFactory.java index cf285e675e1f6b4e2cd7c4bf2018218e4b0b4c84..b9994f8ffce71c2282b83b8131f6c1529a8e928c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericBusinessObjectFactory.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericBusinessObjectFactory.java @@ -22,7 +22,6 @@ import ch.systemsx.cisd.openbis.generic.server.business.bo.IDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IDataSetTable; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExperimentBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExperimentTable; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IExternalDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IMaterialBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IMaterialTable; import ch.systemsx.cisd.openbis.generic.server.business.bo.IProjectBO; @@ -83,11 +82,6 @@ public final class GenericBusinessObjectFactory extends AbstractPluginBusinessOb return getCommonBusinessObjectFactory().createDataBO(session); } - public IExternalDataBO createExternalDataBO(Session session) - { - return getCommonBusinessObjectFactory().createExternalDataBO(session); - } - public IDataSetTable createDataSetTable(Session session) { return getCommonBusinessObjectFactory().createDataSetTable(session); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/IGenericBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/IGenericBusinessObjectFactory.java index ce6c7659f90131e70575f52464c72cc435ff9dc5..9cdee5b6fc6f35579e2253449378ae25ba7b26e9 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/IGenericBusinessObjectFactory.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/IGenericBusinessObjectFactory.java @@ -20,7 +20,6 @@ import ch.systemsx.cisd.openbis.generic.server.business.bo.IDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IDataSetTable; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExperimentBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExperimentTable; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IExternalDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IMaterialBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IMaterialTable; import ch.systemsx.cisd.openbis.generic.server.business.bo.IProjectBO; @@ -66,11 +65,6 @@ public interface IGenericBusinessObjectFactory */ public IDataBO createDataBO(final Session session); - /** - * Creates a {@link IExternalDataBO} <i>Business Object</i>. - */ - public IExternalDataBO createExternalDataBO(final Session session); - /** * Creates a {@link ISampleTable} <i>Business Object</i>. */ 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 a784a1e8a896c50600a202cbfb7b4cb8c1d26c72..f8aa3466495fdd32041fa3ce52012f0ca62c969d 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 @@ -811,12 +811,12 @@ public class ETLServiceTest extends AbstractServerTestCase one(personDAO).tryFindPersonByUserId(CommonTestUtils.USER_ID); will(returnValue(new PersonPE())); - one(boFactory).createExternalDataBO(SESSION); - will(returnValue(externalDataBO)); + one(boFactory).createDataBO(SESSION); + will(returnValue(dataBO)); - one(externalDataBO).define(externalData, samplePE, SourceType.MEASUREMENT); - one(externalDataBO).save(); - one(externalDataBO).getExternalData(); + one(dataBO).define(externalData, samplePE, SourceType.MEASUREMENT); + one(dataBO).save(); + one(dataBO).getData(); ExternalDataPE externalDataPE = new ExternalDataPE(); externalDataPE.setCode(externalData.getCode()); will(returnValue(externalDataPE)); @@ -864,12 +864,12 @@ public class ETLServiceTest extends AbstractServerTestCase one(sampleBO).getSample(); will(returnValue(samplePE)); - one(boFactory).createExternalDataBO(SESSION); - will(returnValue(externalDataBO)); + one(boFactory).createDataBO(SESSION); + will(returnValue(dataBO)); - one(externalDataBO).define(externalData, samplePE, SourceType.MEASUREMENT); - one(externalDataBO).save(); - one(externalDataBO).getExternalData(); + one(dataBO).define(externalData, samplePE, SourceType.MEASUREMENT); + one(dataBO).save(); + one(dataBO).getData(); ExternalDataPE externalDataPE = new ExternalDataPE(); externalDataPE.setCode(externalData.getCode()); will(returnValue(externalDataPE)); @@ -937,7 +937,7 @@ public class ETLServiceTest extends AbstractServerTestCase context.checking(new Expectations() { { - one(externalDataBO).getExternalData(); + one(dataBO).getData(); ExternalDataPE externalDataPE = new ExternalDataPE(); externalDataPE.setCode(externalData.getCode()); @@ -946,15 +946,15 @@ public class ETLServiceTest extends AbstractServerTestCase externalDataPE.setDataStore(store); will(returnValue(externalDataPE)); - // one(boFactory).createExternalDataBO(SESSION); - // will(returnValue(externalDataBO)); + // one(boFactory).createDataBO(SESSION); + // will(returnValue(dataBO)); // // exactly(1).of(boFactory).createSampleBO(SESSION); // will(returnValue(sampleBO)); // - // one(externalDataBO).define(externalData, samplePE, SourceType.MEASUREMENT); - // one(externalDataBO).save(); - // one(externalDataBO).getExternalData(); + // one(dataBO).define(externalData, samplePE, SourceType.MEASUREMENT); + // one(dataBO).save(); + // one(dataBO).getExternalData(); // ExternalDataPE externalDataPE = new ExternalDataPE(); // externalDataPE.setCode(externalData.getCode()); // will(returnValue(externalDataPE)); @@ -1001,12 +1001,12 @@ public class ETLServiceTest extends AbstractServerTestCase sample.setExperiment(experiment); will(returnValue(sample)); - one(boFactory).createExternalDataBO(SESSION); - will(returnValue(externalDataBO)); + one(boFactory).createDataBO(SESSION); + will(returnValue(dataBO)); - one(externalDataBO).define(externalData, sample, sourceType); - one(externalDataBO).save(); - one(externalDataBO).getExternalData(); + one(dataBO).define(externalData, sample, sourceType); + one(dataBO).save(); + one(dataBO).getData(); ExternalDataPE externalDataPE = new ExternalDataPE(); externalDataPE.setCode(externalData.getCode()); will(returnValue(externalDataPE)); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBOTest.java index a8c37686a71699835aba44ed74eafc6c0808b6a5..e20989c430624258b586ff784f2b164b6f7484a0 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBOTest.java @@ -36,7 +36,6 @@ import ch.systemsx.cisd.openbis.generic.server.dataaccess.IEntityPropertyTypeDAO import ch.systemsx.cisd.openbis.generic.server.dataaccess.IEntityTypeDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IEventDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IExperimentDAO; -import ch.systemsx.cisd.openbis.generic.server.dataaccess.IExternalDataDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IFileFormatTypeDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IGridCustomFilterDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.ILocatorTypeDAO; @@ -84,9 +83,6 @@ public abstract class AbstractBOTest extends AssertJUnit protected IDataDAO dataDAO; - // FIXME remove - protected IExternalDataDAO externalDataDAO; - protected IDatabaseInstanceDAO databaseInstanceDAO; protected ISampleDAO sampleDAO; @@ -135,7 +131,6 @@ public abstract class AbstractBOTest extends AssertJUnit sampleDAO = context.mock(ISampleDAO.class); databaseInstanceDAO = context.mock(IDatabaseInstanceDAO.class); dataDAO = context.mock(IDataDAO.class); - externalDataDAO = context.mock(IExternalDataDAO.class); personDAO = context.mock(IPersonDAO.class); propertiesConverter = context.mock(IEntityPropertiesConverter.class); sampleTypeDAO = context.mock(ISampleTypeDAO.class); @@ -175,8 +170,6 @@ public abstract class AbstractBOTest extends AssertJUnit will(returnValue(locatorTypeDAO)); allowing(daoFactory).getDataDAO(); will(returnValue(dataDAO)); - allowing(daoFactory).getExternalDataDAO(); - will(returnValue(externalDataDAO)); allowing(daoFactory).getDataStoreDAO(); will(returnValue(dataStoreDAO)); allowing(daoFactory).getVocabularyDAO(); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/DataBOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/DataBOTest.java index a4d631e2330eb2d47584a81620c02828137245db..abc7af21abadb9de71ca128624b05a4b30e6f74f 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/DataBOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/DataBOTest.java @@ -575,8 +575,8 @@ public class DataBOTest extends AbstractBOTest context.checking(new Expectations() { { - one(dataDAO).tryGetByTechId(TECH_ID, ExternalDataBO.PROPERTY_TYPES, - ExternalDataBO.DATA_SET_TYPE); + one(dataDAO).tryGetByTechId(TECH_ID, DataBO.PROPERTY_TYPES, + DataBO.DATA_SET_TYPE); will(returnValue(dataSet)); one(propertiesConverter).updateProperties( @@ -605,8 +605,8 @@ public class DataBOTest extends AbstractBOTest context.checking(new Expectations() { { - one(dataDAO).tryGetByTechId(TECH_ID, ExternalDataBO.PROPERTY_TYPES, - ExternalDataBO.DATA_SET_TYPE); + one(dataDAO).tryGetByTechId(TECH_ID, DataBO.PROPERTY_TYPES, + DataBO.DATA_SET_TYPE); will(returnValue(dataSet)); ExperimentIdentifier identifier = EXPERIMENT_IDENTIFIER; 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 deleted file mode 100644 index a0bbd96621a88f3dbf18ae7d48192abf1a830fe2..0000000000000000000000000000000000000000 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataBOTest.java +++ /dev/null @@ -1,756 +0,0 @@ -/* - * Copyright 2009 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.business.bo; - -import static ch.systemsx.cisd.openbis.generic.server.business.ManagerTestTool.EXAMPLE_SESSION; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.HashSet; -import java.util.List; - -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; -import org.jmock.Expectations; -import org.testng.annotations.Test; - -import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.systemsx.cisd.common.types.BooleanOrUnknown; -import ch.systemsx.cisd.openbis.generic.server.business.ManagerTestTool; -import ch.systemsx.cisd.openbis.generic.shared.Constants; -import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetArchivingStatus; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.FileFormatType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.LocatorType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SourceType; -import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetPropertyPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetTypePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetTypePropertyTypePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetUpdatesDTO; -import ch.systemsx.cisd.openbis.generic.shared.dto.DataStorePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.DatabaseInstancePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.FileFormatTypePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.LocatorTypePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.NewExternalData; -import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.StorageFormat; -import ch.systemsx.cisd.openbis.generic.shared.dto.VocabularyPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.VocabularyTermPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.DatabaseInstanceIdentifier; -import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifier; -import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.GroupIdentifier; -import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ProjectIdentifier; -import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; -import ch.systemsx.cisd.openbis.generic.shared.dto.types.DataSetTypeCode; - -/** - * @author Franz-Josef Elmer - */ -// TODO 2009-09-10, Piotr Buczek: write tests with many parents and cycle check -@SuppressWarnings("deprecation") -public class ExternalDataBOTest extends AbstractBOTest -{ - private static final int SPEED_HINT = (Constants.DEFAULT_SPEED_HINT + Constants.MAX_SPEED) / 2; - - private static final TechId TECH_ID = new TechId(42l); - - private static final DatabaseInstanceIdentifier DATABASE_INSTANCE_IDENTIFIER = - new DatabaseInstanceIdentifier(ManagerTestTool.EXAMPLE_DATABASE_INSTANCE.getCode()); - - private static final GroupIdentifier GROUP_IDENTIFIER = new GroupIdentifier( - DATABASE_INSTANCE_IDENTIFIER, ManagerTestTool.EXAMPLE_GROUP.getCode()); - - private static final SampleIdentifier SAMPLE_IDENTIFIER = new SampleIdentifier( - GROUP_IDENTIFIER, "EXAMPLE_SAMPLE"); - - private static final ExperimentIdentifier EXPERIMENT_IDENTIFIER = new ExperimentIdentifier( - new ProjectIdentifier(GROUP_IDENTIFIER, ManagerTestTool.EXAMPLE_PROJECT.getCode()), - "EXPERIMENT_CODE"); - - private static final String DATA_STORE_CODE = "dss1"; - - private static final String PARENT_CODE = "parent"; - - private static final Date PRODUCTION_DATE = new Date(1001); - - private static final String DATA_PRODUCER_CODE = "DPC"; - - private static final String DATA_SET_CODE = "DS1"; - - private static final String LOCATION = "folder/subfolder/file.fft"; - - private static final LocatorType LOCATOR_TYPE = new LocatorType("LT"); - - private static final FileFormatType FILE_FORMAT_TYPE = new FileFormatType("FFT"); - - private static final DataSetType DATA_SET_TYPE = new DataSetType("DST"); - - private static final class DataMatcher extends BaseMatcher<ExternalDataPE> - { - public void describeTo(Description description) - { - description.appendText(DATA_SET_CODE); - } - - public boolean matches(Object item) - { - if (item instanceof DataPE) - { - DataPE data = (DataPE) item; - return data.getCode().equals(DATA_SET_CODE); - } - return false; - } - } - - @Test - public void testDefineWithDirectSampleConnection() - { - final DataSetTypePE dataSetType = new DataSetTypePE(); - final FileFormatTypePE fileFormatType = new FileFormatTypePE(); - final VocabularyPE vocabulary = new VocabularyPE(); - vocabulary.addTerm(new VocabularyTermPE()); - VocabularyTermPE vocabularyTerm = new VocabularyTermPE(); - vocabularyTerm.setCode(StorageFormat.PROPRIETARY.toString()); - vocabulary.addTerm(vocabularyTerm); - final LocatorTypePE locatorType = new LocatorTypePE(); - SamplePE sample = new SamplePE(); - ExperimentPE experimentPE = new ExperimentPE(); - sample.setExperiment(experimentPE); - prepareDefine(dataSetType, fileFormatType, vocabulary, locatorType, new DataStorePE()); - - IExternalDataBO dataBO = createExternalDataBO(); - dataBO.define(createData(null), sample, SourceType.DERIVED); - ExternalDataPE externalData = dataBO.getExternalData(); - - assertEquals(DATA_SET_CODE, externalData.getCode()); - assertEquals(BooleanOrUnknown.U, externalData.getComplete()); - assertEquals(DATA_PRODUCER_CODE, externalData.getDataProducerCode()); - assertSame(dataSetType, externalData.getDataSetType()); - assertSame(fileFormatType, externalData.getFileFormatType()); - assertSame(locatorType, externalData.getLocatorType()); - assertEquals(LOCATION, externalData.getLocation()); - assertEquals(0, externalData.getParents().size()); - assertSame(experimentPE, externalData.getExperiment()); - assertEquals(PRODUCTION_DATE, externalData.getProductionDate()); - assertSame(sample, externalData.tryGetSample()); - assertSame(true, externalData.isDerived()); - assertEquals(StorageFormat.PROPRIETARY, externalData.getStorageFormat()); - assertSame(vocabularyTerm, externalData.getStorageFormatVocabularyTerm()); - assertEquals(null, externalData.getRegistrator()); - assertEquals(SPEED_HINT, externalData.getSpeedHint()); - context.assertIsSatisfied(); - } - - @Test - public void testDefineWithUserID() - { - final DataSetTypePE dataSetType = new DataSetTypePE(); - final FileFormatTypePE fileFormatType = new FileFormatTypePE(); - final VocabularyPE vocabulary = new VocabularyPE(); - vocabulary.addTerm(new VocabularyTermPE()); - VocabularyTermPE vocabularyTerm = new VocabularyTermPE(); - vocabularyTerm.setCode(StorageFormat.PROPRIETARY.toString()); - vocabulary.addTerm(vocabularyTerm); - final LocatorTypePE locatorType = new LocatorTypePE(); - SamplePE sample = new SamplePE(); - ExperimentPE experimentPE = new ExperimentPE(); - sample.setExperiment(experimentPE); - prepareDefine(dataSetType, fileFormatType, vocabulary, locatorType, new DataStorePE()); - final NewExternalData data = createData(null); - data.setUserId("my-id"); - final PersonPE registrator = new PersonPE(); - context.checking(new Expectations() - { - { - one(personDAO).tryFindPersonByUserId(data.getUserId()); - will(returnValue(registrator)); - } - }); - - IExternalDataBO dataBO = createExternalDataBO(); - dataBO.define(data, sample, SourceType.DERIVED); - ExternalDataPE externalData = dataBO.getExternalData(); - - assertEquals(DATA_SET_CODE, externalData.getCode()); - assertEquals(BooleanOrUnknown.U, externalData.getComplete()); - assertEquals(DATA_PRODUCER_CODE, externalData.getDataProducerCode()); - assertSame(dataSetType, externalData.getDataSetType()); - assertSame(fileFormatType, externalData.getFileFormatType()); - assertSame(locatorType, externalData.getLocatorType()); - assertEquals(LOCATION, externalData.getLocation()); - assertEquals(0, externalData.getParents().size()); - assertSame(experimentPE, externalData.getExperiment()); - assertEquals(PRODUCTION_DATE, externalData.getProductionDate()); - assertSame(sample, externalData.tryGetSample()); - assertSame(true, externalData.isDerived()); - assertEquals(StorageFormat.PROPRIETARY, externalData.getStorageFormat()); - assertSame(vocabularyTerm, externalData.getStorageFormatVocabularyTerm()); - assertSame(registrator, externalData.getRegistrator()); - context.assertIsSatisfied(); - } - - @Test - public void testDefineWithUserEMail() - { - final DataSetTypePE dataSetType = new DataSetTypePE(); - final FileFormatTypePE fileFormatType = new FileFormatTypePE(); - final VocabularyPE vocabulary = new VocabularyPE(); - vocabulary.addTerm(new VocabularyTermPE()); - VocabularyTermPE vocabularyTerm = new VocabularyTermPE(); - vocabularyTerm.setCode(StorageFormat.PROPRIETARY.toString()); - vocabulary.addTerm(vocabularyTerm); - final LocatorTypePE locatorType = new LocatorTypePE(); - SamplePE sample = new SamplePE(); - ExperimentPE experimentPE = new ExperimentPE(); - sample.setExperiment(experimentPE); - prepareDefine(dataSetType, fileFormatType, vocabulary, locatorType, new DataStorePE()); - final NewExternalData data = createData(null); - data.setUserEMail("my-email"); - final PersonPE registrator = new PersonPE(); - registrator.setEmail(data.getUserEMail()); - context.checking(new Expectations() - { - { - one(personDAO).listPersons(); - will(returnValue(Arrays.asList(new PersonPE(), registrator))); - } - }); - - IExternalDataBO dataBO = createExternalDataBO(); - dataBO.define(data, sample, SourceType.DERIVED); - ExternalDataPE externalData = dataBO.getExternalData(); - - assertEquals(DATA_SET_CODE, externalData.getCode()); - assertEquals(BooleanOrUnknown.U, externalData.getComplete()); - assertEquals(DATA_PRODUCER_CODE, externalData.getDataProducerCode()); - assertSame(dataSetType, externalData.getDataSetType()); - assertSame(fileFormatType, externalData.getFileFormatType()); - assertSame(locatorType, externalData.getLocatorType()); - assertEquals(LOCATION, externalData.getLocation()); - assertEquals(0, externalData.getParents().size()); - assertSame(experimentPE, externalData.getExperiment()); - assertEquals(PRODUCTION_DATE, externalData.getProductionDate()); - assertSame(sample, externalData.tryGetSample()); - assertSame(true, externalData.isDerived()); - assertEquals(StorageFormat.PROPRIETARY, externalData.getStorageFormat()); - assertSame(vocabularyTerm, externalData.getStorageFormatVocabularyTerm()); - assertSame(registrator, externalData.getRegistrator()); - context.assertIsSatisfied(); - } - - @Test - public void testDefineWithExistingParentDataSet() - { - final DataSetTypePE dataSetType = new DataSetTypePE(); - final FileFormatTypePE fileFormatType = new FileFormatTypePE(); - final VocabularyPE vocabulary = new VocabularyPE(); - vocabulary.addTerm(new VocabularyTermPE()); - VocabularyTermPE vocabularyTerm = new VocabularyTermPE(); - vocabularyTerm.setCode(StorageFormat.PROPRIETARY.toString()); - vocabulary.addTerm(vocabularyTerm); - final LocatorTypePE locatorType = new LocatorTypePE(); - ExperimentPE experimentPE = new ExperimentPE(); - DataStorePE dataStore = new DataStorePE(); - prepareDefine(dataSetType, fileFormatType, vocabulary, locatorType, dataStore); - final DataPE data = new DataPE(); - context.checking(new Expectations() - { - { - one(externalDataDAO).tryToFindDataSetByCode(PARENT_CODE); - will(returnValue(data)); - } - }); - - IExternalDataBO dataBO = createExternalDataBO(); - dataBO.define(createData(PARENT_CODE), experimentPE, SourceType.MEASUREMENT); - ExternalDataPE externalData = dataBO.getExternalData(); - - assertSame(experimentPE, externalData.getExperiment()); - assertEquals(null, externalData.tryGetSample()); - assertSame(true, externalData.isMeasured()); - assertSame(dataStore, externalData.getDataStore()); - assertEquals(1, externalData.getParents().size()); - assertSame(data, externalData.getParents().iterator().next()); - context.assertIsSatisfied(); - } - - @Test - public void testDefineWithNonExistingParentDataSet() - { - final DataSetTypePE dataSetType = new DataSetTypePE(); - final FileFormatTypePE fileFormatType = new FileFormatTypePE(); - final VocabularyPE vocabulary = new VocabularyPE(); - vocabulary.addTerm(new VocabularyTermPE()); - VocabularyTermPE vocabularyTerm = new VocabularyTermPE(); - vocabularyTerm.setCode(StorageFormat.PROPRIETARY.toString()); - vocabulary.addTerm(vocabularyTerm); - final LocatorTypePE locatorType = new LocatorTypePE(); - final ExperimentPE experiment = new ExperimentPE(); - final DataStorePE dataStore = new DataStorePE(); - prepareDefine(dataSetType, fileFormatType, vocabulary, locatorType, dataStore); - final DataSetTypePE dataSetTypeUnknown = new DataSetTypePE(); - final DataPE parentData = new DataPE(); - parentData.setCode(PARENT_CODE); - parentData.setDataSetType(dataSetTypeUnknown); - parentData.setExperiment(createExperiment("EXP1")); - parentData.setPlaceholder(true); - context.checking(new Expectations() - { - { - one(externalDataDAO).tryToFindDataSetByCode(PARENT_CODE); - will(returnValue(null)); - - one(dataSetTypeDAO).tryToFindDataSetTypeByCode("UNKNOWN"); - will(returnValue(dataSetTypeUnknown)); - - one(externalDataDAO).createDataSet(parentData); - } - }); - - IExternalDataBO dataBO = createExternalDataBO(); - dataBO.define(createData(PARENT_CODE), experiment, SourceType.MEASUREMENT); - ExternalDataPE externalData = dataBO.getExternalData(); - - assertSame(experiment, externalData.getExperiment()); - assertEquals(null, externalData.tryGetSample()); - assertSame(true, externalData.isMeasured()); - assertSame(dataStore, externalData.getDataStore()); - assertEquals(1, externalData.getParents().size()); - assertEquals(parentData, externalData.getParents().iterator().next()); - context.assertIsSatisfied(); - } - - @Test - public void testDefineWithNonExistingParentDataSetAndNonExistingExperiment() - { - final DataSetTypePE dataSetType = createDataSetType(); - final FileFormatTypePE fileFormatType = new FileFormatTypePE(); - final VocabularyPE vocabulary = new VocabularyPE(); - vocabulary.addTerm(new VocabularyTermPE()); - VocabularyTermPE vocabularyTerm = new VocabularyTermPE(); - vocabularyTerm.setCode(StorageFormat.PROPRIETARY.toString()); - vocabulary.addTerm(vocabularyTerm); - final LocatorTypePE locatorType = new LocatorTypePE(); - final DataStorePE dataStore = new DataStorePE(); - prepareDefine(dataSetType, fileFormatType, vocabulary, locatorType, dataStore); - final DataSetTypePE dataSetTypeUnknown = new DataSetTypePE(); - final DataPE parentData = new DataPE(); - parentData.setCode(PARENT_CODE); - parentData.setDataSetType(dataSetTypeUnknown); - ExperimentPE experiment = createExperiment("EXP1"); - parentData.setExperiment(experiment); - parentData.setPlaceholder(true); - context.checking(new Expectations() - { - { - one(externalDataDAO).tryToFindDataSetByCode(PARENT_CODE); - will(returnValue(null)); - - one(dataSetTypeDAO).tryToFindDataSetTypeByCode( - DataSetTypeCode.UNKNOWN.getCode()); - will(returnValue(dataSetTypeUnknown)); - - one(externalDataDAO).createDataSet(parentData); - } - }); - - IExternalDataBO dataBO = createExternalDataBO(); - dataBO.define(createData(PARENT_CODE), experiment, SourceType.MEASUREMENT); - ExternalDataPE externalData = dataBO.getExternalData(); - - assertSame(null, externalData.tryGetSample()); - assertSame(true, externalData.isMeasured()); - assertSame(dataStore, externalData.getDataStore()); - assertEquals(1, externalData.getParents().size()); - assertEquals(parentData, externalData.getParents().iterator().next()); - context.assertIsSatisfied(); - } - - @Test - public void testUpdateStatuses() - { - final List<String> codes = Arrays.asList(new String[] - { "CODE-1", "CODE-2" }); - context.checking(new Expectations() - { - { - one(externalDataDAO).updateDataSetStatuses(codes, - DataSetArchivingStatus.ARCHIVED, true); - } - }); - - IExternalDataBO dataBO = createExternalDataBO(); - dataBO.updateStatuses(codes, DataSetArchivingStatus.ARCHIVED, true); - // TODO 2010-04-26, Piotr Buczek: write a DAO test - context.assertIsSatisfied(); - } - - @Test - public void testUpdate() - { - final SamplePE sample = new SamplePE(); - sample.setCode(SAMPLE_IDENTIFIER.getSampleCode()); - final ExternalDataPE dataSet = createDataSet(sample, null); - DataSetUpdatesDTO dataSetUpdatesDTO = - createDataSetUpdates(dataSet, SAMPLE_IDENTIFIER, null); - prepareForUpdate(dataSet, sample); - context.checking(new Expectations() - { - { - one(fileFormatTypeDAO) - .tryToFindFileFormatTypeByCode(FILE_FORMAT_TYPE.getCode()); - FileFormatTypePE fileFormatTypePE = new FileFormatTypePE(); - fileFormatTypePE.setCode(FILE_FORMAT_TYPE.getCode()); - will(returnValue(fileFormatTypePE)); - - one(propertiesConverter).checkMandatoryProperties( - Collections.<DataSetPropertyPE> emptySet(), dataSet.getDataSetType()); - - one(externalDataDAO).validateAndSaveUpdatedEntity(dataSet); - } - }); - - IExternalDataBO dataBO = createExternalDataBO(); - dataBO.update(dataSetUpdatesDTO); - context.assertIsSatisfied(); - } - - @Test - public void testUpdateWithDataSetAsItsOwnParent() - { - final ExperimentPE experiment = new ExperimentPE(); - experiment.setCode(EXPERIMENT_IDENTIFIER.getExperimentCode()); - - final ExternalDataPE dataSet = createDataSet(null, experiment); - DataSetUpdatesDTO dataSetUpdatesDTO = - createDataSetUpdates(dataSet, null, EXPERIMENT_IDENTIFIER); - String[] parentCodes = - { dataSet.getCode() }; - dataSetUpdatesDTO.setModifiedParentDatasetCodesOrNull(parentCodes); - prepareForUpdate(dataSet, experiment); - - IExternalDataBO dataBO = createExternalDataBO(); - try - { - dataBO.update(dataSetUpdatesDTO); - fail("UserFailureException expected"); - } catch (UserFailureException e) - { - assertEquals("Data set 'DS1' can not be its own parent.", e.getMessage()); - } - - context.assertIsSatisfied(); - } - - @Test - public void testUpdateWithNonExistingParentDataSet() - { - final ExperimentPE experiment = new ExperimentPE(); - experiment.setCode(EXPERIMENT_IDENTIFIER.getExperimentCode()); - - final ExternalDataPE dataSet = createDataSet(null, experiment); - DataSetUpdatesDTO dataSetUpdatesDTO = - createDataSetUpdates(dataSet, null, EXPERIMENT_IDENTIFIER); - String[] parentCodes = - { PARENT_CODE }; - dataSetUpdatesDTO.setModifiedParentDatasetCodesOrNull(parentCodes); - prepareForUpdate(dataSet, experiment); - context.checking(new Expectations() - { - { - one(externalDataDAO).tryToFindDataSetByCode(PARENT_CODE); - will(returnValue(null)); - } - }); - - IExternalDataBO dataBO = createExternalDataBO(); - try - { - dataBO.update(dataSetUpdatesDTO); - fail("UserFailureException expected"); - } catch (UserFailureException e) - { - assertEquals("Data Sets with following codes do not exist: '[" + PARENT_CODE + "]'.", - e.getMessage()); - } - - context.assertIsSatisfied(); - } - - private void prepareForUpdate(final ExternalDataPE dataSet, final SamplePE sample) - { - context.checking(new Expectations() - { - { - one(externalDataDAO).tryGetByTechId(TECH_ID, ExternalDataBO.PROPERTY_TYPES, - ExternalDataBO.DATA_SET_TYPE); - will(returnValue(dataSet)); - - one(propertiesConverter).updateProperties( - Collections.<DataSetPropertyPE> emptySet(), dataSet.getDataSetType(), - null, ManagerTestTool.EXAMPLE_PERSON); - will(returnValue(Collections.emptySet())); - - one(databaseInstanceDAO).tryFindDatabaseInstanceByCode( - DATABASE_INSTANCE_IDENTIFIER.getDatabaseInstanceCode()); - will(returnValue(ManagerTestTool.EXAMPLE_DATABASE_INSTANCE)); - - one(groupDAO).tryFindSpaceByCodeAndDatabaseInstance( - GROUP_IDENTIFIER.getSpaceCode(), - ManagerTestTool.EXAMPLE_DATABASE_INSTANCE); - will(returnValue(ManagerTestTool.EXAMPLE_GROUP)); - - one(sampleDAO).tryFindByCodeAndSpace(SAMPLE_IDENTIFIER.getSampleCode(), - ManagerTestTool.EXAMPLE_GROUP); - will(returnValue(sample)); - } - }); - } - - private void prepareForUpdate(final ExternalDataPE dataSet, final ExperimentPE experiment) - { - context.checking(new Expectations() - { - { - one(externalDataDAO).tryGetByTechId(TECH_ID, ExternalDataBO.PROPERTY_TYPES, - ExternalDataBO.DATA_SET_TYPE); - will(returnValue(dataSet)); - - ExperimentIdentifier identifier = EXPERIMENT_IDENTIFIER; - - one(daoFactory).getProjectDAO(); - will(returnValue(projectDAO)); - one(projectDAO).tryFindProject(identifier.getDatabaseInstanceCode(), - identifier.getSpaceCode(), identifier.getProjectCode()); - will(returnValue(ManagerTestTool.EXAMPLE_PROJECT)); - - one(experimentDAO).tryFindByCodeAndProject(ManagerTestTool.EXAMPLE_PROJECT, - identifier.getExperimentCode()); - will(returnValue(experiment)); - } - }); - } - - private DataSetUpdatesDTO createDataSetUpdates(final ExternalDataPE dataSet, - final SampleIdentifier sampleIdentifierOrNull, - final ExperimentIdentifier experimentIdentifierOrNull) - { - DataSetUpdatesDTO dataSetUpdatesDTO = new DataSetUpdatesDTO(); - dataSetUpdatesDTO.setDatasetId(TECH_ID); - dataSetUpdatesDTO.setVersion(dataSet.getModificationDate()); - dataSetUpdatesDTO.setSampleIdentifierOrNull(sampleIdentifierOrNull); - dataSetUpdatesDTO.setExperimentIdentifierOrNull(experimentIdentifierOrNull); - dataSetUpdatesDTO.setFileFormatTypeCode(FILE_FORMAT_TYPE.getCode()); - return dataSetUpdatesDTO; - } - - private ExternalDataPE createDataSet(final SamplePE sampleOrNull, - final ExperimentPE experimentOrNull) - { - final ExternalDataPE dataSet = new ExternalDataPE(); - dataSet.setId(TECH_ID.getId()); - dataSet.setCode(DATA_SET_CODE); - dataSet.setModificationDate(PRODUCTION_DATE); - dataSet.setSample(sampleOrNull); - dataSet.setExperiment(experimentOrNull); - DataSetTypePE dataSetType = new DataSetTypePE(); - dataSetType.setCode(DATA_SET_TYPE.getCode()); - DatabaseInstancePE databaseInstance = new DatabaseInstancePE(); - databaseInstance.setCode("db"); - dataSetType.setDatabaseInstance(databaseInstance); - dataSetType.setDataSetTypePropertyTypes(new HashSet<DataSetTypePropertyTypePE>()); - dataSet.setDataSetType(dataSetType); - return dataSet; - } - - @Test - public void testSaveNewDataSet() - { - final DataSetTypePE dataSetType = createDataSetType(); - final FileFormatTypePE fileFormatType = new FileFormatTypePE(); - final VocabularyPE vocabulary = new VocabularyPE(); - vocabulary.addTerm(new VocabularyTermPE()); - VocabularyTermPE vocabularyTerm = new VocabularyTermPE(); - vocabularyTerm.setCode(StorageFormat.PROPRIETARY.toString()); - vocabulary.addTerm(vocabularyTerm); - final LocatorTypePE locatorType = new LocatorTypePE(); - SamplePE sample = new SamplePE(); - sample.setExperiment(new ExperimentPE()); - final DataStorePE dataStore = new DataStorePE(); - prepareDefine(dataSetType, fileFormatType, vocabulary, locatorType, dataStore); - context.checking(new Expectations() - { - { - one(externalDataDAO).tryToFindDataSetByCode(DATA_SET_CODE); - will(returnValue(null)); - - one(externalDataDAO).createDataSet(with(new DataMatcher())); - - expectMandatoryPropertiesCheck(this, dataSetType); - } - }); - - IExternalDataBO dataBO = createExternalDataBO(); - dataBO.define(createData(null), sample, SourceType.DERIVED); - dataBO.save(); - - context.assertIsSatisfied(); - } - - @Test - public void testUpdatePlaceholderDataSet() - { - final DataSetTypePE dataSetType = createDataSetType(); - final FileFormatTypePE fileFormatType = new FileFormatTypePE(); - final VocabularyPE vocabulary = new VocabularyPE(); - vocabulary.addTerm(new VocabularyTermPE()); - VocabularyTermPE vocabularyTerm = new VocabularyTermPE(); - vocabularyTerm.setCode(StorageFormat.PROPRIETARY.toString()); - vocabulary.addTerm(vocabularyTerm); - final LocatorTypePE locatorType = new LocatorTypePE(); - SamplePE sample = new SamplePE(); - sample.setExperiment(new ExperimentPE()); - final DataStorePE dataStore = new DataStorePE(); - prepareDefine(dataSetType, fileFormatType, vocabulary, locatorType, dataStore); - context.checking(new Expectations() - { - { - one(externalDataDAO).tryToFindDataSetByCode(DATA_SET_CODE); - DataPE data = new DataPE(); - data.setId(4711L); - data.setPlaceholder(true); - will(returnValue(data)); - - one(externalDataDAO).updateDataSet(with(new DataMatcher())); - - expectMandatoryPropertiesCheck(this, dataSetType); - } - - }); - - IExternalDataBO dataBO = createExternalDataBO(); - dataBO.define(createData(null), sample, SourceType.DERIVED); - dataBO.save(); - - ExternalDataPE externalData = dataBO.getExternalData(); - assertSame(dataStore, externalData.getDataStore()); - assertEquals(false, externalData.isPlaceholder()); - assertEquals(4711, externalData.getId().longValue()); - assertSame(sample, externalData.tryGetSample()); - assertSame(true, externalData.isDerived()); - - context.assertIsSatisfied(); - } - - @SuppressWarnings("unchecked") - private void expectMandatoryPropertiesCheck(Expectations exp, final DataSetTypePE type) - { - exp.one(propertiesConverter).checkMandatoryProperties( - exp.with(Expectations.any(Collection.class)), exp.with(type)); - } - - private DataSetTypePE createDataSetType() - { - final DataSetTypePE dataSetType = new DataSetTypePE(); - dataSetType.setCode("data-set-type-code"); - dataSetType.setDatabaseInstance(new DatabaseInstancePE()); - return dataSetType; - } - - private ExperimentPE createExperiment(String experimentCode) - { - ExperimentPE experiment = new ExperimentPE(); - experiment.setCode(experimentCode); - ProjectPE project = new ProjectPE(); - project.setCode("P"); - SpacePE group = new SpacePE(); - group.setCode("G"); - DatabaseInstancePE databaseInstance = new DatabaseInstancePE(); - databaseInstance.setCode("DB"); - group.setDatabaseInstance(databaseInstance); - project.setSpace(group); - experiment.setProject(project); - return experiment; - } - - private void prepareDefine(final DataSetTypePE dataSetType, - final FileFormatTypePE fileFormatType, final VocabularyPE vocabulary, - final LocatorTypePE locatorType, final DataStorePE dataStore) - { - context.checking(new Expectations() - { - { - one(dataSetTypeDAO).tryToFindDataSetTypeByCode(DATA_SET_TYPE.getCode()); - will(returnValue(dataSetType)); - one(fileFormatTypeDAO) - .tryToFindFileFormatTypeByCode(FILE_FORMAT_TYPE.getCode()); - will(returnValue(fileFormatType)); - one(vocabularyDAO).tryFindVocabularyByCode(StorageFormat.VOCABULARY_CODE); - will(returnValue(vocabulary)); - one(locatorTypeDAO).tryToFindLocatorTypeByCode(LOCATOR_TYPE.getCode()); - will(returnValue(locatorType)); - - one(propertiesConverter).convertProperties(new IEntityProperty[0], - dataSetType.getCode(), EXAMPLE_SESSION.tryGetPerson()); - ArrayList<DataSetPropertyPE> properties = new ArrayList<DataSetPropertyPE>(); - will(returnValue(properties)); - - one(dataStoreDAO).tryToFindDataStoreByCode(DATA_STORE_CODE); - will(returnValue(dataStore)); - } - }); - } - - private NewExternalData createData(String parentDataSetCodeOrNull) - { - NewExternalData data = new NewExternalData(); - data.setCode(DATA_SET_CODE); - if (parentDataSetCodeOrNull != null) - { - data.setParentDataSetCodes(Collections.singletonList(parentDataSetCodeOrNull)); - } - data.setDataProducerCode(DATA_PRODUCER_CODE); - data.setProductionDate(PRODUCTION_DATE); - data.setComplete(BooleanOrUnknown.U); - data.setStorageFormat(StorageFormat.PROPRIETARY); - data.setDataSetType(DATA_SET_TYPE); - data.setFileFormatType(FILE_FORMAT_TYPE); - data.setLocatorType(LOCATOR_TYPE); - data.setLocation(LOCATION); - data.setDataStoreCode(DATA_STORE_CODE); - data.setSpeedHint(SPEED_HINT); - return data; - } - - private final IExternalDataBO createExternalDataBO() - { - return new ExternalDataBO(daoFactory, EXAMPLE_SESSION, propertiesConverter); - } - -} 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 deleted file mode 100644 index 557d0e40763cf8b9c6fb102901716d46a46153ee..0000000000000000000000000000000000000000 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExternalDataDAOTest.java +++ /dev/null @@ -1,422 +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.dataaccess.db; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.fail; - -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.springframework.dao.DataIntegrityViolationException; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; - -import ch.systemsx.cisd.common.types.BooleanOrUnknown; -import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDataSetTypeDAO; -import ch.systemsx.cisd.openbis.generic.server.dataaccess.IExternalDataDAO; -import ch.systemsx.cisd.openbis.generic.server.dataaccess.IFileFormatTypeDAO; -import ch.systemsx.cisd.openbis.generic.server.dataaccess.ILocatorTypeDAO; -import ch.systemsx.cisd.openbis.generic.server.dataaccess.ISampleDAO; -import ch.systemsx.cisd.openbis.generic.shared.Constants; -import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetArchivingStatus; -import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetPropertyPE; -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.DatabaseInstancePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.EntityTypePropertyTypePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.FileFormatTypePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.LocatorTypePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.StorageFormat; -import ch.systemsx.cisd.openbis.generic.shared.dto.VocabularyPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.VocabularyTermPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.properties.EntityKind; -import ch.systemsx.cisd.openbis.generic.shared.dto.types.DataSetTypeCode; - -/** - * Test cases for corresponding {@link ExternalDataDAO} class. - * - * @author Christian Ribeaud - */ -@Test(groups = - { "db", "externalData" }) -@SuppressWarnings("deprecation") -public final class ExternalDataDAOTest extends AbstractDAOTest -{ - - private static final int SPEED_HINT = Constants.DEFAULT_SPEED_HINT / 4; - - private final String PARENT_CODE = "20081105092158673-1"; - - private final String CHILD_CODE = "20081105092159188-3"; - - @Test - public final void testListExternalData() - { - testCreateDataSetWithSample(); - final IExternalDataDAO externalDataDAO = daoFactory.getExternalDataDAO(); - List<ExternalDataPE> list = externalDataDAO.listExternalData(pickASample()); - - assertEquals(1, list.size()); - ExternalDataPE dataSet = list.get(0); - assertEquals("abcd", dataSet.getLocation()); - assertEquals(BooleanOrUnknown.U, dataSet.getComplete()); - } - - @Test - public void testCreateDataSetWithSample() - { - IExternalDataDAO externalDataDAO = daoFactory.getExternalDataDAO(); - String dataSetCode = daoFactory.getPermIdDAO().createPermId(); - SamplePE sample = pickASample(); - ExternalDataPE externalData = createExternalData(dataSetCode, sample); - externalData.setShareId("42"); - externalData.setSize(4711L); - externalData.setSpeedHint(SPEED_HINT); - externalDataDAO.createDataSet(externalData); - - ExternalDataPE dataSet = - (ExternalDataPE) externalDataDAO.tryToFindDataSetByCode(dataSetCode); - assertDataEqual(externalData, dataSet); - assertEquals("42", dataSet.getShareId()); - assertEquals(4711L, dataSet.getSize().longValue()); - assertEquals(SPEED_HINT, dataSet.getSpeedHint()); - } - - @Test - public void testCreateDataSetWithNoSample() - { - IExternalDataDAO externalDataDAO = daoFactory.getExternalDataDAO(); - String dataSetCode = daoFactory.getPermIdDAO().createPermId(); - ExternalDataPE externalData = createExternalData(dataSetCode, null); - externalDataDAO.createDataSet(externalData); - - ExternalDataPE dataSet = - (ExternalDataPE) externalDataDAO.tryToFindDataSetByCode(dataSetCode); - assertDataEqual(externalData, dataSet); - assertEquals(Constants.DEFAULT_SPEED_HINT, dataSet.getSpeedHint()); - } - - private ExternalDataPE createExternalData(String dataSetCode, SamplePE sampleOrNull) - { - ExternalDataPE externalData = new ExternalDataPE(); - - externalData.setCode(dataSetCode); - externalData.setDataSetType(getDataSetType(DataSetTypeCode.UNKNOWN)); - externalData.setExperiment(pickAnExperiment()); - if (sampleOrNull != null) - { - externalData.setSampleAcquiredFrom(sampleOrNull); - } else - { - externalData.setDerived(true); - } - externalData.setFileFormatType(pickAFileFormatType()); - externalData.setLocatorType(pickALocatorType()); - externalData.setLocation("abcd"); - externalData.setComplete(BooleanOrUnknown.U); - externalData.setStorageFormatVocabularyTerm(pickAStorageFormatVocabularyTerm()); - externalData.setPlaceholder(true); - externalData.setDataStore(pickADataStore()); - return externalData; - } - - private void assertDataEqual(ExternalDataPE externalData, ExternalDataPE dataSet) - { - assertEquals(externalData.getCode(), dataSet.getCode()); - assertEquals(externalData.getDataSetType(), dataSet.getDataSetType()); - assertEquals(externalData.getExperiment(), dataSet.getExperiment()); - assertEquals(externalData.getFileFormatType(), dataSet.getFileFormatType()); - assertEquals(externalData.getLocatorType(), dataSet.getLocatorType()); - assertEquals(externalData.getLocation(), dataSet.getLocation()); - assertEquals(externalData.getComplete(), dataSet.getComplete()); - assertEquals(externalData.getStorageFormat(), dataSet.getStorageFormat()); - assertEquals(externalData.isPlaceholder(), dataSet.isPlaceholder()); - assertEquals(externalData.isMeasured(), dataSet.isMeasured()); - assertEquals(externalData.tryGetSample(), dataSet.tryGetSample()); - } - - @Test - public void testUpdateDataSetAquiredFromSampleWithoutDataSetSize() - { - checkUpdate(null); - } - - @Test - public void testUpdateDataSetAquiredFromSampleWithDataSetSize() - { - checkUpdate(4711L); - } - - private void checkUpdate(Long size) - { - IExternalDataDAO externalDataDAO = daoFactory.getExternalDataDAO(); - DataPE data = new DataPE(); - String dataSetCode = daoFactory.getPermIdDAO().createPermId(); - data.setCode(dataSetCode); - data.setDataSetType(getDataSetType(DataSetTypeCode.UNKNOWN)); - data.setExperiment(pickAnExperiment()); - data.setSampleAcquiredFrom(pickASample()); - data.setPlaceholder(true); - data.setDataStore(pickADataStore()); - data.setModificationDate(new Date()); - externalDataDAO.createDataSet(data); - - ExternalDataPE externalData = new ExternalDataPE(); - externalData.setId(externalDataDAO.tryToFindDataSetByCode(dataSetCode).getId()); - externalData.setCode(dataSetCode); - externalData.setDataSetType(getDataSetType(DataSetTypeCode.UNKNOWN)); - externalData.setDataStore(pickADataStore()); - externalData.setExperiment(pickAnExperiment()); - externalData.setSampleAcquiredFrom(pickASample()); - externalData.setFileFormatType(pickAFileFormatType()); - externalData.setLocatorType(pickALocatorType()); - externalData.setLocation("abcd"); - externalData.setShareId("share-42"); - externalData.setSize(size); - externalData.setComplete(BooleanOrUnknown.U); - externalData.setStorageFormatVocabularyTerm(pickAStorageFormatVocabularyTerm()); - externalData.setPlaceholder(true); - externalData.setStatus(DataSetArchivingStatus.AVAILABLE); - final Date modificationTimestamp = data.getModificationDate(); - externalData.setModificationDate(modificationTimestamp); - externalDataDAO.updateDataSet(externalData); - - ExternalDataPE dataSet = - (ExternalDataPE) externalDataDAO.tryToFindDataSetByCode(dataSetCode); - assertEquals(externalData.getCode(), dataSet.getCode()); - assertEquals(externalData.getDataSetType(), dataSet.getDataSetType()); - assertEquals(externalData.getExperiment(), dataSet.getExperiment()); - assertEquals(externalData.getFileFormatType(), dataSet.getFileFormatType()); - assertEquals(externalData.getLocatorType(), dataSet.getLocatorType()); - assertEquals(externalData.getShareId(), dataSet.getShareId()); - assertEquals(externalData.getLocation(), dataSet.getLocation()); - assertEquals(externalData.getSize(), dataSet.getSize()); - assertEquals(externalData.getComplete(), dataSet.getComplete()); - assertEquals(externalData.getStorageFormat(), dataSet.getStorageFormat()); - assertEquals(externalData.isPlaceholder(), dataSet.isPlaceholder()); - assertEquals(externalData.isMeasured(), dataSet.isMeasured()); - assertFalse(externalData.getModificationDate().equals(modificationTimestamp)); - } - - @Test - public void testUpdateDataSetWithParent() - { - final IExternalDataDAO externalDataDAO = daoFactory.getExternalDataDAO(); - - // try to add a parent to a data set that already had one - final ExternalDataPE dataSetConnectedWithParent = findExternalData(CHILD_CODE); - assertFalse(dataSetConnectedWithParent.getParents().isEmpty()); - final ExternalDataPE anotherDataSet = findExternalData("20081105092159111-1"); - dataSetConnectedWithParent.addParent(anotherDataSet); - externalDataDAO.updateDataSet(dataSetConnectedWithParent); - - ExternalDataPE dataSet = - (ExternalDataPE) externalDataDAO.tryToFindDataSetByCode(CHILD_CODE); - assertEquals(dataSetConnectedWithParent.getParents().size(), dataSet.getParents().size()); - Set<DataPE> extractedParents = dataSet.getParents(); - for (DataPE parent : dataSetConnectedWithParent.getParents()) - { - assertTrue(extractedParents.contains(parent)); - } - assertTrue(extractedParents.contains(anotherDataSet)); - } - - @Test - public final void testDeleteWithPropertiesButParentPreserved() - { - final IExternalDataDAO externalDataDAO = daoFactory.getExternalDataDAO(); - final ExternalDataPE deletedData = findExternalData(CHILD_CODE); - - // Deleted data set should have all collections which prevent it from deletion empty. - assertTrue(deletedData.getChildren().isEmpty()); - - // delete - externalDataDAO.delete(deletedData); - - // test successful deletion of data set - assertNull(externalDataDAO.tryGetByTechId(TechId.create(deletedData))); - - // test successful deletion of data set properties - assertFalse(deletedData.getProperties().isEmpty()); - List<EntityTypePropertyTypePE> retrievedPropertyTypes = - daoFactory.getEntityPropertyTypeDAO(EntityKind.DATA_SET).listEntityPropertyTypes( - deletedData.getEntityType()); - for (DataSetPropertyPE property : deletedData.getProperties()) - { - int index = retrievedPropertyTypes.indexOf(property.getEntityTypePropertyType()); - EntityTypePropertyTypePE retrievedPropertyType = retrievedPropertyTypes.get(index); - assertFalse(retrievedPropertyType.getPropertyValues().contains(property)); - } - - // deleted sample had parent connected that should not have been deleted - // NOTE: somehow cannot get parents even though connection is the same as with children - // DataPE parent = deletedData.tryGetParent(); - // assertNotNull(parent); - // assertNotNull(externalDataDAO.tryGetByTechId(new TechId(HibernateUtils.getId(parent)))); - - // FIXME throws ClassCastException, uncomment when fixed, see: - // http://sysin.wordpress.com/2009/02/27/hibernate-inheritance-classcastexception-part-1/ - // http://docs.jboss.org/hibernate/core/3.3/reference/en/html/performance.html#performance-fetching-proxies -// findExternalData(PARENT_CODE); - } - - @Test(expectedExceptions = DataIntegrityViolationException.class) - public final void testDeleteFailWithChildrenDatasets() - { - final IExternalDataDAO externalDataDAO = daoFactory.getExternalDataDAO(); - final ExternalDataPE deletedData = findExternalData(PARENT_CODE); - - // Deleted data set should have 'child' data sets which prevent it from deletion. - assertFalse(deletedData.getChildren().isEmpty()); - - // delete - externalDataDAO.delete(deletedData); - } - - protected VocabularyTermPE pickAStorageFormatVocabularyTerm() - { - String code = StorageFormat.VOCABULARY_CODE; - VocabularyPE vocabulary = daoFactory.getVocabularyDAO().tryFindVocabularyByCode(code); - assertNotNull(vocabulary); - return vocabulary.getTerms().iterator().next(); - } - - protected FileFormatTypePE pickAFileFormatType() - { - IFileFormatTypeDAO fileFormatTypeDAO = daoFactory.getFileFormatTypeDAO(); - FileFormatTypePE fileFormatType = fileFormatTypeDAO.tryToFindFileFormatTypeByCode("TIFF"); - assertNotNull(fileFormatType); - return fileFormatType; - } - - protected LocatorTypePE pickALocatorType() - { - ILocatorTypeDAO locatorTypeDAO = daoFactory.getLocatorTypeDAO(); - LocatorTypePE locatorType = locatorTypeDAO.tryToFindLocatorTypeByCode("RELATIVE_LOCATION"); - assertNotNull(locatorType); - return locatorType; - } - - protected SamplePE pickASample() - { - ISampleDAO sampleDAO = daoFactory.getSampleDAO(); - DatabaseInstancePE dbInstance = daoFactory.getHomeDatabaseInstance(); - SamplePE sample = sampleDAO.tryFindByCodeAndDatabaseInstance("MP", dbInstance); - assertNotNull(sample); - return sample; - } - - protected DataStorePE pickADataStore() - { - return daoFactory.getDataStoreDAO().tryToFindDataStoreByCode("STANDARD"); - } - - protected DataSetTypePE getDataSetType(DataSetTypeCode type) - { - IDataSetTypeDAO dataSetTypeDAO = daoFactory.getDataSetTypeDAO(); - String code = type.getCode(); - DataSetTypePE dataSetType = dataSetTypeDAO.tryToFindDataSetTypeByCode(code); - assertNotNull(dataSetType); - return dataSetType; - } - - protected ExperimentPE pickAnExperiment() - { - List<ExperimentPE> experiments = daoFactory.getExperimentDAO().listExperiments(); - for (ExperimentPE experimentPE : experiments) - { - if (experimentPE.getInvalidation() == null) - { - return experimentPE; - } - } - fail("No valid experiment found."); - return null; // to make the compiler happy - } - - @Test - public void testCreateDataSetWithBothSampleAndParent() - { - final IExternalDataDAO externalDataDAO = daoFactory.getExternalDataDAO(); - - // try to create a dataset connected with a sample and a parent at the same time - final String dataSetCode = daoFactory.getPermIdDAO().createPermId(); - final SamplePE sample = pickASample(); - ExternalDataPE parentData = findExternalData(PARENT_CODE); - ExternalDataPE externalData = createExternalData(dataSetCode, sample); - externalData.addParent(parentData); - externalDataDAO.createDataSet(externalData); - } - - @Test - public void testUpdateOfDataSetAddParentWhenThereIsSampleConnected() - { - final IExternalDataDAO externalDataDAO = daoFactory.getExternalDataDAO(); - - // try to update dataset connected with a sample - adding a parent should succeed - final ExternalDataPE dataSetConnectedWithSample = findExternalData(PARENT_CODE); - assertNotNull(dataSetConnectedWithSample.tryGetSample()); - final ExternalDataPE anotherDataSet = findExternalData("20081105092159111-1"); - dataSetConnectedWithSample.addParent(anotherDataSet); - externalDataDAO.updateDataSet(dataSetConnectedWithSample); - } - - @Test - public void testUpdateOfDataSetConnectSampleWhenThereIsParent() - { - final IExternalDataDAO externalDataDAO = daoFactory.getExternalDataDAO(); - - // try to update dataset connected with a parent - connecting with a sample should succeed - final ExternalDataPE dataSetConnectedWithParent = findExternalData(CHILD_CODE); - assertFalse(dataSetConnectedWithParent.getParents().isEmpty()); - dataSetConnectedWithParent.setSampleAcquiredFrom(pickASample()); - externalDataDAO.updateDataSet(dataSetConnectedWithParent); - } - - @Test - public void testLoadByPermId() throws Exception - { - ExternalDataPE exp = daoFactory.getExternalDataDAO().listAllEntities().get(0); - HashSet<String> keys = new HashSet<String>(); - keys.add(exp.getCode()); - keys.add("nonexistent"); - List<ExternalDataPE> result = daoFactory.getExternalDataDAO().listByCode(keys); - AssertJUnit.assertEquals(1, result.size()); - AssertJUnit.assertEquals(exp, result.get(0)); - } - - @Test - public void testLoadByPermIdNoEntries() throws Exception - { - HashSet<String> keys = new HashSet<String>(); - List<ExternalDataPE> result = daoFactory.getExternalDataDAO().listByCode(keys); - AssertJUnit.assertTrue(result.isEmpty()); - } - -} 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 33e140a53acc7ec539f286a7e6e8469fa3dcf11d..2d66ee25a82d81e2e5b356d552b8a86a98eafab7 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 @@ -304,7 +304,6 @@ public final class DBCreator extends AbstractDAOTest // DataSets - @SuppressWarnings("deprecation") private void createDataSetsForSample(SamplePE sample) { final int size = SizeHelper.getNextDataSetsPerSampleSize(); @@ -312,7 +311,7 @@ public final class DBCreator extends AbstractDAOTest { log("creating dataset: %d/%d", i, size); ExternalDataPE dataSet = generateDataSetForSample(sample); - daoFactory.getExternalDataDAO().createDataSet(dataSet); + daoFactory.getDataDAO().createDataSet(dataSet); } log("created datasets"); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerTestCase.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerTestCase.java index f3933d2112fea1a8fcb54e7e539bbfeb573d02ba..073a00327261dea55bff7440825536fb6c36007b 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerTestCase.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerTestCase.java @@ -33,12 +33,12 @@ import ch.systemsx.cisd.common.logging.BufferedAppender; import ch.systemsx.cisd.common.logging.LogInitializer; import ch.systemsx.cisd.openbis.generic.server.CommonServerTest.PersonWithDisplaySettingsMatcher; import ch.systemsx.cisd.openbis.generic.server.business.IPropertiesBatchManager; +import ch.systemsx.cisd.openbis.generic.server.business.bo.IDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IDataSetTable; import ch.systemsx.cisd.openbis.generic.server.business.bo.IEntityTypeBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IEntityTypePropertyTypeBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExperimentBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExperimentTable; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IExternalDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IGroupBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IMaterialBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IMaterialTable; @@ -57,7 +57,6 @@ import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDataStoreDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDatabaseInstanceDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IEntityTypeDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IExperimentDAO; -import ch.systemsx.cisd.openbis.generic.server.dataaccess.IExternalDataDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IFileFormatTypeDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IPersonDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IProjectDAO; @@ -114,9 +113,6 @@ public abstract class AbstractServerTestCase extends AssertJUnit protected ISpaceDAO groupDAO; - // FIXME use IDataDAO - protected IExternalDataDAO externalDataDAO; - protected IDataDAO dataSetDAO; protected IPermIdDAO permIdDAO; @@ -159,7 +155,7 @@ public abstract class AbstractServerTestCase extends AssertJUnit protected IAttachmentDAO experimentAttachmentDAO; - protected IExternalDataBO externalDataBO; + protected IDataBO dataBO; protected IEntityTypeBO entityTypeBO; @@ -197,7 +193,6 @@ public abstract class AbstractServerTestCase extends AssertJUnit sampleDAO = context.mock(ISampleDAO.class); roleAssignmentDAO = context.mock(IRoleAssignmentDAO.class); dataSetDAO = context.mock(IDataDAO.class); - externalDataDAO = context.mock(IExternalDataDAO.class); permIdDAO = context.mock(IPermIdDAO.class); entityTypeDAO = context.mock(IEntityTypeDAO.class); experimentDAO = context.mock(IExperimentDAO.class); @@ -219,7 +214,7 @@ public abstract class AbstractServerTestCase extends AssertJUnit propertyTypeBO = context.mock(IPropertyTypeBO.class); vocabularyBO = context.mock(IVocabularyBO.class); entityTypePropertyTypeBO = context.mock(IEntityTypePropertyTypeBO.class); - externalDataBO = context.mock(IExternalDataBO.class); + dataBO = context.mock(IDataBO.class); // Table dataSetTable = context.mock(IDataSetTable.class); sampleLister = context.mock(ISampleLister.class); @@ -253,8 +248,6 @@ public abstract class AbstractServerTestCase extends AssertJUnit will(returnValue(sampleTypeDAO)); allowing(daoFactory).getDataDAO(); will(returnValue(dataSetDAO)); - allowing(daoFactory).getExternalDataDAO(); - will(returnValue(externalDataDAO)); allowing(daoFactory).getAttachmentDAO(); will(returnValue(experimentAttachmentDAO)); allowing(daoFactory).getFileFormatTypeDAO(); diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/IScreeningBusinessObjectFactory.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/IScreeningBusinessObjectFactory.java index aabc57814459d7865a792f0983a147e01a3a19d8..04b6c0e65cf33a6f7f1b17806fafdeb8d7509119 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/IScreeningBusinessObjectFactory.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/IScreeningBusinessObjectFactory.java @@ -16,9 +16,9 @@ package ch.systemsx.cisd.openbis.plugin.screening.server; +import ch.systemsx.cisd.openbis.generic.server.business.bo.IDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IDataSetTable; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExperimentBO; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IExternalDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IMaterialBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.datasetlister.IDatasetLister; @@ -55,7 +55,7 @@ public interface IScreeningBusinessObjectFactory public IMaterialLister createMaterialLister(Session session); - public IExternalDataBO createExternalDataBO(Session session); + public IDataBO createDataBO(Session session); public IDatasetLister createDatasetLister(Session session); diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningBusinessObjectFactory.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningBusinessObjectFactory.java index 2f5c2fcd2db4d5326bcd82a457f66ea3d2473ad2..554e64793c327da82ffbbc0b9d7b85167642ab89 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningBusinessObjectFactory.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningBusinessObjectFactory.java @@ -22,9 +22,9 @@ import javax.annotation.Resource; import org.springframework.stereotype.Component; +import ch.systemsx.cisd.openbis.generic.server.business.bo.IDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IDataSetTable; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExperimentBO; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IExternalDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IMaterialBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.datasetlister.IDatasetLister; @@ -122,9 +122,9 @@ public final class ScreeningBusinessObjectFactory extends AbstractPluginBusiness return getCommonBusinessObjectFactory().createMaterialBO(session); } - public IExternalDataBO createExternalDataBO(Session session) + public IDataBO createDataBO(Session session) { - return getCommonBusinessObjectFactory().createExternalDataBO(session); + return getCommonBusinessObjectFactory().createDataBO(session); } public IDatasetLister createDatasetLister(Session session) diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/LogicalImageLoader.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/LogicalImageLoader.java index 2a4fbcda7cc452ceac8b32c88f781a4accd22d0b..44273e6b4bc4eba8c47a39437401537a0e81f6f6 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/LogicalImageLoader.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/LogicalImageLoader.java @@ -20,12 +20,12 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IExternalDataBO; +import ch.systemsx.cisd.openbis.generic.server.business.bo.IDataBO; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE; import ch.systemsx.cisd.openbis.generic.shared.dto.Session; -import ch.systemsx.cisd.openbis.generic.shared.translator.ExternalDataTranslator; +import ch.systemsx.cisd.openbis.generic.shared.translator.DataSetTranslator; import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils; import ch.systemsx.cisd.openbis.plugin.screening.server.IScreeningBusinessObjectFactory; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.DatasetImagesReference; @@ -94,7 +94,7 @@ public class LogicalImageLoader { ImageDatasetParameters imageParameters = datasetLoader.getImageParameters(); - ExternalDataPE dataset = loadDatasetWithChildren(datasetCode); + DataPE dataset = loadDatasetWithChildren(datasetCode); DatasetImagesReference datasetImagesReference = createDatasetImagesReference(translate(dataset), imageParameters); List<DatasetImagesReference> overlayDatasets = extractImageOverlays(dataset); @@ -116,7 +116,7 @@ public class LogicalImageLoader return refs; } - private List<DatasetImagesReference> extractImageOverlays(ExternalDataPE imageDataset) + private List<DatasetImagesReference> extractImageOverlays(DataPE imageDataset) { List<ExternalData> overlayDatasets = fetchOverlayDatasets(imageDataset); @@ -128,7 +128,7 @@ public class LogicalImageLoader return overlays; } - private List<ExternalData> fetchOverlayDatasets(ExternalDataPE imageDataset) + private List<ExternalData> fetchOverlayDatasets(DataPE imageDataset) { List<DataPE> overlayPEs = ScreeningUtils.filterImageOverlayDatasets(imageDataset.getChildren()); @@ -150,18 +150,18 @@ public class LogicalImageLoader imageParameters); } - DatasetImagesReference loadImageDatasetReference(ExternalDataPE imageDataset) + DatasetImagesReference loadImageDatasetReference(DataPE imageDataset) { return loadImageDatasetReference(translate(imageDataset)); } - private ExternalDataPE loadDatasetWithChildren(String datasetPermId) + private DataPE loadDatasetWithChildren(String datasetPermId) { - IExternalDataBO externalDataBO = businessObjectFactory.createExternalDataBO(session); - externalDataBO.loadByCode(datasetPermId); - externalDataBO.enrichWithChildren(); - ExternalDataPE externalData = externalDataBO.getExternalData(); - return externalData; + IDataBO dataBO = businessObjectFactory.createDataBO(session); + dataBO.loadByCode(datasetPermId); + dataBO.enrichWithChildren(); + DataPE dataSet = dataBO.getData(); + return dataSet; } private static Collection<Long> extractIds(List<DataPE> datasets) @@ -174,8 +174,8 @@ public class LogicalImageLoader return ids; } - private ExternalData translate(ExternalDataPE externalData) + private ExternalData translate(DataPE dataSet) { - return ExternalDataTranslator.translate(externalData, session.getBaseIndexURL()); + return DataSetTranslator.translate(dataSet, session.getBaseIndexURL()); } } diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/PlateContentLoader.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/PlateContentLoader.java index 9fbc2cb96c9da471ec4147cb11c851af776c0d70..749c2dd072267530d4730f3fb891deb28c06cc2b 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/PlateContentLoader.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/PlateContentLoader.java @@ -22,8 +22,8 @@ import java.util.Collections; import java.util.List; import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.openbis.generic.server.business.bo.IDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IDataSetTable; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IExternalDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.materiallister.IMaterialLister; import ch.systemsx.cisd.openbis.generic.server.business.bo.samplelister.ISampleLister; @@ -35,6 +35,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListOrSearchSampleCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Material; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; +import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; import ch.systemsx.cisd.openbis.generic.shared.dto.Session; @@ -128,16 +129,16 @@ public class PlateContentLoader private PlateImages getPlateContentForDataset(TechId datasetId) { - ExternalDataPE externalData = loadDataset(datasetId); - SamplePE plate = externalData.tryGetSample(); + DataPE dataSet = loadDataset(datasetId); + SamplePE plate = dataSet.tryGetSample(); if (plate == null) { throw UserFailureException.fromTemplate("Dataset '%s' has no sample connected.", - externalData.getCode()); + dataSet.getCode()); } List<WellMetadata> wells = loadWells(new TechId(HibernateUtils.getId(plate))); DatasetImagesReference datasetImagesReference = - imageLoader.loadImageDatasetReference(externalData); + imageLoader.loadImageDatasetReference(dataSet); Geometry plateGeometry = getPlateGeometry(plate); PlateMetadata plateMetadata = new PlateMetadata(translate(plate), wells, plateGeometry.getNumberOfRows(), @@ -152,12 +153,12 @@ public class PlateContentLoader return PlateDimensionParser.getPlateGeometry(properties); } - private ExternalDataPE loadDataset(TechId datasetId) + private DataPE loadDataset(TechId datasetId) { - IExternalDataBO externalDataBO = businessObjectFactory.createExternalDataBO(session); - externalDataBO.loadDataByTechId(datasetId); - ExternalDataPE externalData = externalDataBO.getExternalData(); - return externalData; + IDataBO dataBO = businessObjectFactory.createDataBO(session); + dataBO.loadDataByTechId(datasetId); + DataPE dataSet = dataBO.getData(); + return dataSet; } private ExternalData translate(ExternalDataPE externalData) diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/ScreeningApiImpl.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/ScreeningApiImpl.java index 8044637a04f1d3ad5117381415f269b64ceca88f..3b8190d5ccee7fa254e719b083ab6d2ba3b74dbf 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/ScreeningApiImpl.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/ScreeningApiImpl.java @@ -35,7 +35,7 @@ import org.apache.commons.lang.StringUtils; import ch.rinn.restrictions.Friend; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.openbis.generic.server.api.v1.Translator; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IExternalDataBO; +import ch.systemsx.cisd.openbis.generic.server.business.bo.IDataBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.common.DatabaseContextUtils; import ch.systemsx.cisd.openbis.generic.server.business.bo.samplelister.ISampleLister; @@ -49,8 +49,8 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Project; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space; +import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE; import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialPE; import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; @@ -282,7 +282,7 @@ public class ScreeningApiImpl public List<IDatasetIdentifier> getDatasetIdentifiers(List<String> datasetCodes) { - IExternalDataBO externalDataBO = businessObjectFactory.createExternalDataBO(session); + IDataBO externalDataBO = businessObjectFactory.createDataBO(session); List<IDatasetIdentifier> identifiers = new ArrayList<IDatasetIdentifier>(); for (String datasetCode : datasetCodes) { @@ -291,16 +291,15 @@ public class ScreeningApiImpl return identifiers; } - private IDatasetIdentifier getDatasetIdentifier(IExternalDataBO externalDataBO, - String datasetCode) + private IDatasetIdentifier getDatasetIdentifier(IDataBO dataBO, String datasetCode) { - externalDataBO.loadByCode(datasetCode); - ExternalDataPE externalData = externalDataBO.getExternalData(); - if (externalData == null) + dataBO.loadByCode(datasetCode); + DataPE dataSet = dataBO.getData(); + if (dataSet == null) { throw UserFailureException.fromTemplate("Dataset '%s' does not exist", datasetCode); } - return new DatasetIdentifier(datasetCode, externalData.getDataStore().getDownloadUrl()); + return new DatasetIdentifier(datasetCode, dataSet.getDataStore().getDownloadUrl()); } static class DatasetReferenceHolder @@ -439,7 +438,7 @@ public class ScreeningApiImpl Sample sample = loadSampleByPermId(wellIdentifier.getPermId(), enrichWithProperties); return Translator.translate(sample); } - + public ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample getPlateSample( PlateIdentifier plateIdentifier) {