Skip to content
Snippets Groups Projects
Commit 73a75eeb authored by buczekp's avatar buczekp
Browse files

[LMS-2442] changed listing share ids for to list also trashed data sets

SVN: 22473
parent 80a37211
No related branches found
No related tags found
No related merge requests found
...@@ -65,7 +65,6 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria; ...@@ -65,7 +65,6 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchableEntityKind; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchableEntityKind;
import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ArchiverDataSetCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ArchiverDataSetCriteria;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSet;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetArchivingStatus; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetArchivingStatus;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetTypeWithVocabularyTerms; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetTypeWithVocabularyTerms;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataStoreServiceKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataStoreServiceKind;
...@@ -810,24 +809,13 @@ public class ETLService extends AbstractCommonServer<IETLLIMSService> implements ...@@ -810,24 +809,13 @@ public class ETLService extends AbstractCommonServer<IETLLIMSService> implements
return SampleTranslator.translate(sampleTable.getSamples(), ""); return SampleTranslator.translate(sampleTable.getSamples(), "");
} }
public List<DataSetShareId> listShareIds(String sessionToken, String dataStore) public List<DataSetShareId> listShareIds(String sessionToken, String dataStoreCode)
throws UserFailureException throws UserFailureException
{ {
// FIXME trashed data sets are not listed Session session = getSession(sessionToken);
List<ExternalData> dataSets = loadDataSets(sessionToken, dataStore); IDatasetLister datasetLister = businessObjectFactory.createDatasetLister(session);
ArrayList<DataSetShareId> shareIds = new ArrayList<DataSetShareId>(); DataStorePE dataStore = loadDataStore(session, dataStoreCode);
for (ExternalData dataSet : dataSets) return datasetLister.listAllDataSetShareIdsByDataStore(dataStore.getId());
{
DataSetShareId dataSetShareId = new DataSetShareId();
dataSetShareId.setDataSetCode(dataSet.getCode());
DataSet ds = dataSet.tryGetAsDataSet();
if (ds != null)
{
dataSetShareId.setShareId(ds.getShareId());
}
shareIds.add(dataSetShareId);
}
return shareIds;
} }
public List<SimpleDataSetInformationDTO> listDataSets(String sessionToken, String dataStoreCode) public List<SimpleDataSetInformationDTO> listDataSets(String sessionToken, String dataStoreCode)
...@@ -872,14 +860,20 @@ public class ETLService extends AbstractCommonServer<IETLLIMSService> implements ...@@ -872,14 +860,20 @@ public class ETLService extends AbstractCommonServer<IETLLIMSService> implements
private List<ExternalData> loadDataSets(String sessionToken, String dataStoreCode) private List<ExternalData> loadDataSets(String sessionToken, String dataStoreCode)
{ {
Session session = getSession(sessionToken); Session session = getSession(sessionToken);
DataStorePE dataStore = loadDataStore(session, dataStoreCode);
IDatasetLister datasetLister = businessObjectFactory.createDatasetLister(session); IDatasetLister datasetLister = businessObjectFactory.createDatasetLister(session);
return datasetLister.listByDataStore(dataStore.getId());
}
private DataStorePE loadDataStore(Session session, String dataStoreCode)
{
DataStorePE dataStore = DataStorePE dataStore =
getDAOFactory().getDataStoreDAO().tryToFindDataStoreByCode(dataStoreCode); getDAOFactory().getDataStoreDAO().tryToFindDataStoreByCode(dataStoreCode);
if (dataStore == null) if (dataStore == null)
{ {
throw new UserFailureException(String.format("Unknown data store '%s'", dataStoreCode)); throw new UserFailureException(String.format("Unknown data store '%s'", dataStoreCode));
} }
return datasetLister.listByDataStore(dataStore.getId()); return dataStore;
} }
public List<DeletedDataSet> listDeletedDataSets(String sessionToken, public List<DeletedDataSet> listDeletedDataSets(String sessionToken,
......
package ch.systemsx.cisd.openbis.generic.server.business.bo.datasetlister;
import ch.rinn.restrictions.Private;
import ch.systemsx.cisd.openbis.generic.server.business.bo.common.CodeRecord;
/**
* A record object representing one row of the dataset table.
*/
@Private
public class DatasetCodeWithShareIdRecord extends CodeRecord
{
public String share_id; // can be NULL in case of container(virtual) data sets
}
...@@ -71,6 +71,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; ...@@ -71,6 +71,7 @@ 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.LocatorType;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TrackingDataSetCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TrackingDataSetCriteria;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetShareId;
import ch.systemsx.cisd.openbis.generic.shared.translator.DataStoreTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.DataStoreTranslator;
/** /**
...@@ -349,6 +350,22 @@ public class DatasetLister extends AbstractLister implements IDatasetLister ...@@ -349,6 +350,22 @@ public class DatasetLister extends AbstractLister implements IDatasetLister
return enrichDatasets(query.getDatasetsByDataStoreId(dataStoreID)); return enrichDatasets(query.getDatasetsByDataStoreId(dataStoreID));
} }
public List<DataSetShareId> listAllDataSetShareIdsByDataStore(long dataStoreID)
{
List<DataSetShareId> results = new ArrayList<DataSetShareId>();
DataIterator<DatasetCodeWithShareIdRecord> records =
query.getAllDatasetsWithShareIdsByDataStoreId(dataStoreID);
for (DatasetCodeWithShareIdRecord record : records)
{
DataSetShareId dataSetShareId = new DataSetShareId();
dataSetShareId.setDataSetCode(record.code);
dataSetShareId.setShareId(record.share_id);
results.add(dataSetShareId);
}
return results;
}
public List<ExternalData> listByTrackingCriteria(TrackingDataSetCriteria criteria) public List<ExternalData> listByTrackingCriteria(TrackingDataSetCriteria criteria)
{ {
DataIterator<DatasetRecord> dataSets; DataIterator<DatasetRecord> dataSets;
...@@ -816,4 +833,5 @@ public class DatasetLister extends AbstractLister implements IDatasetLister ...@@ -816,4 +833,5 @@ public class DatasetLister extends AbstractLister implements IDatasetLister
return result; return result;
} }
} }
...@@ -27,6 +27,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ArchiverDataSetCriteria ...@@ -27,6 +27,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ArchiverDataSetCriteria
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TrackingDataSetCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TrackingDataSetCriteria;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetShareId;
/** /**
* A class for fast dataset listing. * A class for fast dataset listing.
...@@ -79,10 +80,16 @@ public interface IDatasetLister ...@@ -79,10 +80,16 @@ public interface IDatasetLister
List<ExternalData> listByDatasetCode(Collection<String> datasetCodes); List<ExternalData> listByDatasetCode(Collection<String> datasetCodes);
/** /**
* Lists all data sets of specified data store. Unenriched data sets will be returned. * Lists all data sets of specified data store. Unenriched data sets will be returned (FIXME -
* the last sentence is not true).
*/ */
List<ExternalData> listByDataStore(long dataStoreID); List<ExternalData> listByDataStore(long dataStoreID);
/**
* Lists {@link DataSetShareId}s of all data sets (even those in trash) in specified data store.
*/
List<DataSetShareId> listAllDataSetShareIdsByDataStore(long dataStoreID);
/** @return datasets with given ids */ /** @return datasets with given ids */
List<ExternalData> listByDatasetIds(Collection<Long> datasetIds); List<ExternalData> listByDatasetIds(Collection<Long> datasetIds);
...@@ -101,4 +108,5 @@ public interface IDatasetLister ...@@ -101,4 +108,5 @@ public interface IDatasetLister
* @return properties of given type for given dataset ids * @return properties of given type for given dataset ids
*/ */
Map<Long, GenericEntityPropertyRecord> fetchProperties(List<Long> ids, String propertyTypeCode); Map<Long, GenericEntityPropertyRecord> fetchProperties(List<Long> ids, String propertyTypeCode);
} }
...@@ -199,6 +199,12 @@ public interface IDatasetListingQuery extends TransactionQuery, IPropertyListing ...@@ -199,6 +199,12 @@ public interface IDatasetListingQuery extends TransactionQuery, IPropertyListing
@Select(sql = SELECT_ALL + " where data.dast_id = ?{1}", fetchSize = FETCH_SIZE) @Select(sql = SELECT_ALL + " where data.dast_id = ?{1}", fetchSize = FETCH_SIZE)
public DataIterator<DatasetRecord> getDatasetsByDataStoreId(long dataStoreId); public DataIterator<DatasetRecord> getDatasetsByDataStoreId(long dataStoreId);
// NOTE: we list ALL data sets (even those in trash) using data_all table here
@Select(sql = "SELECT code, share_id FROM data_all LEFT OUTER JOIN external_data "
+ "ON data_all.id = external_data.data_id WHERE data_all.dast_id = ?{1}", fetchSize = FETCH_SIZE)
public DataIterator<DatasetCodeWithShareIdRecord> getAllDatasetsWithShareIdsByDataStoreId(
long dataStoreId);
/** /**
* Returns the children dataset ids of the specified datasets. * Returns the children dataset ids of the specified datasets.
*/ */
......
...@@ -422,7 +422,7 @@ public interface IETLLIMSService extends IServer, ISessionProvider ...@@ -422,7 +422,7 @@ public interface IETLLIMSService extends IServer, ISessionProvider
throws UserFailureException; throws UserFailureException;
/** /**
* Lists share ids of all data sets belonging to chosen data store. * Lists share ids of all data sets belonging to chosen data store (even the ones in trash!). // TODO
*/ */
@Transactional(readOnly = true) @Transactional(readOnly = true)
@RolesAllowed(RoleWithHierarchy.SPACE_ETL_SERVER) @RolesAllowed(RoleWithHierarchy.SPACE_ETL_SERVER)
......
...@@ -22,13 +22,13 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ServiceVersionHolder; ...@@ -22,13 +22,13 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ServiceVersionHolder;
/** /**
* Share id of a data set. * Share id of a data set.
* *
* @author Franz-Josef Elmer * @author Franz-Josef Elmer
*/ */
public class DataSetShareId implements Serializable public class DataSetShareId implements Serializable
{ {
private static final long serialVersionUID = ServiceVersionHolder.VERSION; private static final long serialVersionUID = ServiceVersionHolder.VERSION;
private String dataSetCode; private String dataSetCode;
private String shareId; private String shareId;
...@@ -53,4 +53,10 @@ public class DataSetShareId implements Serializable ...@@ -53,4 +53,10 @@ public class DataSetShareId implements Serializable
this.shareId = dataSetShareId; this.shareId = dataSetShareId;
} }
@Override
public String toString()
{
return "DataSetShareId [dataSetCode=" + dataSetCode + ", shareId=" + shareId + "]";
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment