From ad4f18b02485c40b9065dd41d75926ed5d996cc9 Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Tue, 9 Aug 2016 09:10:06 +0000 Subject: [PATCH] SSDM-3726: File search domain, implementation without modifying DataSetPathInfo SVN: 36885 --- .../DatabaseBasedDataSetPathInfoProvider.java | 19 ++++++++--- .../sequencedatabases/FileSearchDomain.java | 33 ++++++++++--------- .../shared/IDataSetPathInfoProvider.java | 2 +- .../generic/shared/dto/DataSetPathInfo.java | 12 ------- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DatabaseBasedDataSetPathInfoProvider.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DatabaseBasedDataSetPathInfoProvider.java index eeb845ae082..1dc04eff195 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DatabaseBasedDataSetPathInfoProvider.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DatabaseBasedDataSetPathInfoProvider.java @@ -137,16 +137,17 @@ public class DatabaseBasedDataSetPathInfoProvider implements IDataSetPathInfoPro } @Override - public List<DataSetPathInfo> listPathInfosByRegularExpression( + public Map<String, List<DataSetPathInfo>> listPathInfosByRegularExpression( String substring) { List<ExtendedDataSetFileRecord> fileRecords = getDao().listFilesByRelativePathLikeExpression("%" + substring + "%"); - List<DataSetPathInfo> pathInfos = new ArrayList<DataSetPathInfo>(fileRecords.size()); + + Map<String, List<DataSetPathInfo>> allPathInfos = new HashMap<String, List<DataSetPathInfo>>(); for (ExtendedDataSetFileRecord fileRecord : fileRecords) { + // Build new info DataSetPathInfo dataSetPathInfo = new DataSetPathInfo(); dataSetPathInfo.setChecksumCRC32(fileRecord.checksum_crc32); - dataSetPathInfo.setDataSetCode(fileRecord.code); dataSetPathInfo.setDirectory(fileRecord.is_directory); dataSetPathInfo.setFileName(fileRecord.file_name); dataSetPathInfo.setId(fileRecord.id); @@ -159,9 +160,17 @@ public class DatabaseBasedDataSetPathInfoProvider implements IDataSetPathInfoPro dataSetPathInfoParent.setId(fileRecord.parent_id); dataSetPathInfo.setParent(dataSetPathInfoParent); } - pathInfos.add(dataSetPathInfo); + + // Add to dataSetCode list + List<DataSetPathInfo> dataSetPathInfos = allPathInfos.get(fileRecord.code); + if (dataSetPathInfos == null) + { + dataSetPathInfos = new ArrayList<DataSetPathInfo>(); + allPathInfos.put(fileRecord.code, dataSetPathInfos); + } + dataSetPathInfos.add(dataSetPathInfo); } - return pathInfos; + return allPathInfos; } @Override diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v2/sequencedatabases/FileSearchDomain.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v2/sequencedatabases/FileSearchDomain.java index 3745f19a9a4..d6918b99434 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v2/sequencedatabases/FileSearchDomain.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v2/sequencedatabases/FileSearchDomain.java @@ -33,30 +33,33 @@ public class FileSearchDomain extends AbstractSearchDomainService public List<SearchDomainSearchResult> search(String searchString, Map<String, String> optionalParametersOrNull) { IDataSetPathInfoProvider dataSetPathInfoProvider = ServiceProvider.getDataSetPathInfoProvider(); - List<DataSetPathInfo> dataSetPathInfos = dataSetPathInfoProvider.listPathInfosByRegularExpression(searchString); + Map<String, List<DataSetPathInfo>> allPathInfos = dataSetPathInfoProvider.listPathInfosByRegularExpression(searchString); List<SearchDomainSearchResult> results = new ArrayList<SearchDomainSearchResult>(); - for (DataSetPathInfo dataSetPathInfo : dataSetPathInfos) + for (String datasetCode : allPathInfos.keySet()) { + List<DataSetPathInfo> dataSetPathInfos = allPathInfos.get(datasetCode); - SearchDomainSearchResult searchDomainSearchResult = new SearchDomainSearchResult(); + for (DataSetPathInfo dataSetPathInfo : dataSetPathInfos) + { + SearchDomainSearchResult searchDomainSearchResult = new SearchDomainSearchResult(); - SearchDomain searchDomain = new SearchDomain(); - searchDomain.setName("File"); - searchDomain.setLabel("File"); + SearchDomain searchDomain = new SearchDomain(); + searchDomain.setName("File"); + searchDomain.setLabel("File"); - searchDomainSearchResult.setSearchDomain(searchDomain); + searchDomainSearchResult.setSearchDomain(searchDomain); - DataSetFileSearchResultLocation dfsrl = new DataSetFileSearchResultLocation(); - dfsrl.setPermId(dataSetPathInfo.getDataSetCode()); - dfsrl.setCode(dataSetPathInfo.getDataSetCode()); - dfsrl.setIdentifier(dataSetPathInfo.getDataSetCode()); - dfsrl.setPathInDataSet(dataSetPathInfo.getRelativePath()); - dfsrl.setEntityKind(EntityKind.DATA_SET); + DataSetFileSearchResultLocation dfsrl = new DataSetFileSearchResultLocation(); + dfsrl.setPermId(datasetCode); + dfsrl.setCode(datasetCode); + dfsrl.setPathInDataSet(dataSetPathInfo.getRelativePath()); + dfsrl.setEntityKind(EntityKind.DATA_SET); - searchDomainSearchResult.setResultLocation(dfsrl); - results.add(searchDomainSearchResult); + searchDomainSearchResult.setResultLocation(dfsrl); + results.add(searchDomainSearchResult); + } } return results; diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IDataSetPathInfoProvider.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IDataSetPathInfoProvider.java index ed4ae0c63ba..318068b658d 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IDataSetPathInfoProvider.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IDataSetPathInfoProvider.java @@ -31,7 +31,7 @@ public interface IDataSetPathInfoProvider public List<DataSetPathInfo> listPathInfosByRegularExpression(String dataSetCode, String regularExpression); - public List<DataSetPathInfo> listPathInfosByRegularExpression(String regularExpression); + public Map<String, List<DataSetPathInfo>> listPathInfosByRegularExpression(String regularExpression); public DataSetPathInfo tryGetFullDataSetRootPathInfo(String dataSetCode); diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/DataSetPathInfo.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/DataSetPathInfo.java index 5cc02a18a00..6f8bf177b76 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/DataSetPathInfo.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/DataSetPathInfo.java @@ -27,8 +27,6 @@ public class DataSetPathInfo { private long id; - private String dataSetCode; - private String fileName; private String relativePath; @@ -137,14 +135,4 @@ public class DataSetPathInfo { children.add(child); } - - public String getDataSetCode() - { - return dataSetCode; - } - - public void setDataSetCode(String dataSetCode) - { - this.dataSetCode = dataSetCode; - } } -- GitLab