From 225bc6295955f9fb07debb090673e899cebe4f09 Mon Sep 17 00:00:00 2001 From: cramakri <cramakri> Date: Thu, 27 May 2010 07:39:52 +0000 Subject: [PATCH] LMS-1544 Added query to get datasets associated with a collection of samples. SVN: 16135 --- .../business/bo/datasetlister/DatasetLister.java | 10 ++++++++++ .../business/bo/datasetlister/IDatasetLister.java | 13 +++++++++---- .../bo/datasetlister/IDatasetListingQuery.java | 11 +++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetLister.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetLister.java index 698847a1310..c37a39d27a5 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetLister.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetLister.java @@ -168,6 +168,16 @@ public class DatasetLister implements IDatasetLister } } + public List<ExternalData> listBySampleIds(Collection<Long> sampleIds) + { + LongSet ids = new LongOpenHashSet(); + for (Long id : sampleIds) + { + ids.add(id); + } + return enrichDatasets(query.getDatasetsForSamples(ids)); + } + public List<ExternalData> listByExperimentTechIds(Collection<TechId> experimentIds) { LongSet ids = new LongOpenHashSet(); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetLister.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetLister.java index d6e20c26c1f..14a4b92c080 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetLister.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetLister.java @@ -46,12 +46,12 @@ public interface IDatasetLister /** @return datasets that are parents of a dataset with the specified id */ List<ExternalData> listByChildTechId(TechId childDatasetId); - /** @return datasets that are parents of a dataset with the specified id */ + /** @return datasets that are children of a dataset with the specified id */ List<ExternalData> listByParentTechId(TechId parentDatasetId); - + /** - * Returns a map with all parent data set IDs of specified data set IDs. The keys of the map - * are IDs from the argument. A value of the map contains at least one alement. + * Returns a map with all parent data set IDs of specified data set IDs. The keys of the map are + * IDs from the argument. A value of the map contains at least one alement. */ Map<Long, Set<Long>> listParentIds(Collection<Long> dataSetIDs); @@ -65,4 +65,9 @@ public interface IDatasetLister /** @return datasets specified by given criteria */ List<ExternalData> listByArchiverCriteria(String dataStoreCode, ArchiverDataSetCriteria criteria); + + /** + * @return Datasets connected to the samples with the specified ids + */ + List<ExternalData> listBySampleIds(Collection<Long> sampleIds); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetListingQuery.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetListingQuery.java index 308982b76f0..8b1baed1736 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetListingQuery.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetListingQuery.java @@ -63,6 +63,13 @@ public interface IDatasetListingQuery extends TransactionQuery, IPropertyListing @Select(sql = "select * from data join external_data on data.id = external_data.data_id where data.samp_id=?{1}", fetchSize = FETCH_SIZE) public DataIterator<DatasetRecord> getDatasetsForSample(long sampleId); + /** + * Returns the directly connected datasets for the given sample ids. + */ + @Select(sql = "select * from data join external_data on data.id = external_data.data_id where data.samp_id = any(?{1})", parameterBindings = + { LongSetMapper.class }, fetchSize = FETCH_SIZE) + public DataIterator<DatasetRecord> getDatasetsForSamples(LongSet sampleIds); + /** * Returns datasets that are newer than dataset with given id (<var>lastSeenDatasetId</var>) and * are directly connected with samples of sample type with given <var>sampleTypeId</var>. @@ -97,11 +104,11 @@ public interface IDatasetListingQuery extends TransactionQuery, IPropertyListing */ @Select(sql = "select id from data where data.samp_id=?{1}", fetchSize = FETCH_SIZE) public DataIterator<Long> getDatasetIdsForSample(long sampleId); - + @Select(sql = "select * from data_set_relationships where data_id_child = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) public DataIterator<DatasetRelationRecord> listParentDataSetIds(LongSet ids); - + /** * Returns the datasets that are children of a dataset with given id. */ -- GitLab