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

SSDM-3726: File search domain, implementation without modifying DataSetPathInfo

SVN: 36885
parent 01f65d43
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
}
}
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