Skip to content
Snippets Groups Projects
Commit 01f65d43 authored by juanf's avatar juanf
Browse files

SSDM-3726: File search domain first, fix dependencies, remove non working test

SVN: 36884
parent 875816ea
No related branches found
No related tags found
No related merge requests found
...@@ -137,11 +137,31 @@ public class DatabaseBasedDataSetPathInfoProvider implements IDataSetPathInfoPro ...@@ -137,11 +137,31 @@ public class DatabaseBasedDataSetPathInfoProvider implements IDataSetPathInfoPro
} }
@Override @Override
public List<ExtendedDataSetFileRecord> listPathInfosByRegularExpression( public List<DataSetPathInfo> listPathInfosByRegularExpression(
String substring) String substring)
{ {
List<ExtendedDataSetFileRecord> fileRecords = getDao().listFilesByRelativePathLikeExpression("%" + substring + "%"); List<ExtendedDataSetFileRecord> fileRecords = getDao().listFilesByRelativePathLikeExpression("%" + substring + "%");
return fileRecords; List<DataSetPathInfo> pathInfos = new ArrayList<DataSetPathInfo>(fileRecords.size());
for (ExtendedDataSetFileRecord fileRecord : fileRecords)
{
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);
dataSetPathInfo.setLastModified(fileRecord.last_modified);
dataSetPathInfo.setRelativePath(fileRecord.relative_path);
dataSetPathInfo.setSizeInBytes(fileRecord.size_in_bytes);
if (fileRecord.parent_id != null)
{
DataSetPathInfo dataSetPathInfoParent = new DataSetPathInfo();
dataSetPathInfoParent.setId(fileRecord.parent_id);
dataSetPathInfo.setParent(dataSetPathInfoParent);
}
pathInfos.add(dataSetPathInfo);
}
return pathInfos;
} }
@Override @Override
......
...@@ -6,9 +6,9 @@ import java.util.List; ...@@ -6,9 +6,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import ch.systemsx.cisd.openbis.dss.generic.server.DatabaseBasedDataSetPathInfoProvider.ExtendedDataSetFileRecord;
import ch.systemsx.cisd.openbis.dss.generic.shared.IDataSetPathInfoProvider; import ch.systemsx.cisd.openbis.dss.generic.shared.IDataSetPathInfoProvider;
import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider;
import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetPathInfo;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetFileSearchResultLocation; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetFileSearchResultLocation;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.EntityKind; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.EntityKind;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchDomain; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchDomain;
...@@ -29,38 +29,37 @@ public class FileSearchDomain extends AbstractSearchDomainService ...@@ -29,38 +29,37 @@ public class FileSearchDomain extends AbstractSearchDomainService
return true; return true;
} }
@Override @Override
public List<SearchDomainSearchResult> search(String searchString, Map<String, String> optionalParametersOrNull) public List<SearchDomainSearchResult> search(String searchString, Map<String, String> optionalParametersOrNull)
{ {
IDataSetPathInfoProvider dataSetPathInfoProvider = ServiceProvider.getDataSetPathInfoProvider(); IDataSetPathInfoProvider dataSetPathInfoProvider = ServiceProvider.getDataSetPathInfoProvider();
List<ExtendedDataSetFileRecord> dataSetPathInfos = dataSetPathInfoProvider.listPathInfosByRegularExpression(searchString); List<DataSetPathInfo> dataSetPathInfos = dataSetPathInfoProvider.listPathInfosByRegularExpression(searchString);
List<SearchDomainSearchResult> results = new ArrayList<SearchDomainSearchResult>(); List<SearchDomainSearchResult> results = new ArrayList<SearchDomainSearchResult>();
for(ExtendedDataSetFileRecord dataSetPathInfo : dataSetPathInfos){ for (DataSetPathInfo dataSetPathInfo : dataSetPathInfos)
{
SearchDomainSearchResult searchDomainSearchResult = new SearchDomainSearchResult();
SearchDomainSearchResult searchDomainSearchResult = new SearchDomainSearchResult();
SearchDomain searchDomain = new SearchDomain();
searchDomain.setName("File"); SearchDomain searchDomain = new SearchDomain();
searchDomain.setLabel("File"); searchDomain.setName("File");
searchDomain.setLabel("File");
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);
searchDomainSearchResult.setResultLocation(dfsrl);
results.add(searchDomainSearchResult);
}
searchDomainSearchResult.setSearchDomain(searchDomain); return results;
DataSetFileSearchResultLocation dfsrl = new DataSetFileSearchResultLocation();
dfsrl.setPermId(dataSetPathInfo.code);
dfsrl.setCode(dataSetPathInfo.code);
dfsrl.setPathInDataSet(dataSetPathInfo.relative_path);
dfsrl.setIdentifier(dataSetPathInfo.code);
dfsrl.setEntityKind(EntityKind.DATA_SET);
searchDomainSearchResult.setResultLocation(dfsrl);
results.add(searchDomainSearchResult);
}
return results;
} }
} }
\ No newline at end of file
...@@ -19,7 +19,6 @@ package ch.systemsx.cisd.openbis.dss.generic.shared; ...@@ -19,7 +19,6 @@ package ch.systemsx.cisd.openbis.dss.generic.shared;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import ch.systemsx.cisd.openbis.dss.generic.server.DatabaseBasedDataSetPathInfoProvider.ExtendedDataSetFileRecord;
import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetPathInfo; import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetPathInfo;
/** /**
...@@ -29,11 +28,11 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetPathInfo; ...@@ -29,11 +28,11 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetPathInfo;
*/ */
public interface IDataSetPathInfoProvider public interface IDataSetPathInfoProvider
{ {
public List<DataSetPathInfo> listPathInfosByRegularExpression(String dataSetCode, String regularExpression); public List<DataSetPathInfo> listPathInfosByRegularExpression(String dataSetCode, String regularExpression);
public List<ExtendedDataSetFileRecord> listPathInfosByRegularExpression(String regularExpression); public List<DataSetPathInfo> listPathInfosByRegularExpression(String regularExpression);
public DataSetPathInfo tryGetFullDataSetRootPathInfo(String dataSetCode); public DataSetPathInfo tryGetFullDataSetRootPathInfo(String dataSetCode);
public ISingleDataSetPathInfoProvider tryGetSingleDataSetPathInfoProvider(String dataSetCode); public ISingleDataSetPathInfoProvider tryGetSingleDataSetPathInfoProvider(String dataSetCode);
......
...@@ -27,6 +27,8 @@ public class DataSetPathInfo ...@@ -27,6 +27,8 @@ public class DataSetPathInfo
{ {
private long id; private long id;
private String dataSetCode;
private String fileName; private String fileName;
private String relativePath; private String relativePath;
...@@ -136,4 +138,13 @@ public class DataSetPathInfo ...@@ -136,4 +138,13 @@ public class DataSetPathInfo
children.add(child); children.add(child);
} }
public String getDataSetCode()
{
return dataSetCode;
}
public void setDataSetCode(String dataSetCode)
{
this.dataSetCode = dataSetCode;
}
} }
class = ch.systemsx.cisd.openbis.dss.generic.server.api.v2.sequencedatabases.FileSearchDomain
label = File
\ No newline at end of file
package ch.systemsx.cisd.openbis.datastoreserver.systemtests;
import java.util.List;
import org.testng.annotations.Test;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchDomainSearchResult;
public class FileSearchDomainTest extends GenericSystemTest
{
@Test
public void test() throws Exception
{
System.out.println("HERE");
IGeneralInformationService gis = getGeneralInformationService();
String sessionToken = gis.tryToAuthenticateForAllServices("test", "test");
List<SearchDomainSearchResult> results = gis.searchOnSearchDomain(sessionToken, "File", "", null);
System.out.println("RESULT: " + results);
gis.logout(sessionToken);
}
}
\ No newline at end of file
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