use of com.emc.metalnx.core.domain.entity.DataGridMetadataSearch in project metalnx-web by irods-contrib.
the class TestMetadataCase method testCaseInsensitiveMetadataSearchEqual.
@Test
public void testCaseInsensitiveMetadataSearchEqual() throws DataGridConnectionRefusedException {
search.add(new DataGridMetadataSearch(attr, val, unit, DataGridSearchOperatorEnum.EQUAL));
assertMetadataSearch(3, 1);
}
use of com.emc.metalnx.core.domain.entity.DataGridMetadataSearch in project metalnx-web by irods-contrib.
the class MetadataController method exportSearchResultsToCSVFile.
@RequestMapping(value = "/downloadCSVResults/")
public void exportSearchResultsToCSVFile(final HttpServletResponse response) throws DataGridConnectionRefusedException, IOException {
String loggedUser = loggedUserUtils.getLoggedDataGridUser().getUsername();
String date = new SimpleDateFormat(METADATA_CSV_DATE_FORMAT).format(new Date());
String filename = String.format(METADATA_CSV_FILENAME_FORMAT, loggedUser, date);
// Setting CSV Mime type
response.setContentType("text/csv");
response.setHeader("Content-disposition", "attachment;filename=" + filename);
ServletOutputStream outputStream = response.getOutputStream();
// Building search parameters lines
outputStream.print("Search condition #;Condition\n");
ListIterator<DataGridMetadataSearch> resultEnumeration = currSearch.listIterator();
while (resultEnumeration.hasNext()) {
String condition = resultEnumeration.next().toString();
outputStream.print(String.format("%d;%s\n", resultEnumeration.nextIndex() + 1, condition));
}
outputStream.print("\n");
outputStream.flush();
// Executing query
DataGridPageContext pageContext = new DataGridPageContext();
List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = metadataService.findByMetadata(currSearch, pageContext, 1, Integer.MAX_VALUE);
// Printing number of results
outputStream.print("Number of results\n");
outputStream.print(String.format("%d\n", pageContext.getTotalNumberOfItems()));
outputStream.print("\n");
// Printing results
outputStream.print(METADATA_CSV_HEADER);
for (DataGridCollectionAndDataObject obj : dataGridCollectionAndDataObjects) {
String kind = obj.isCollection() ? "collection" : "data object";
StringBuilder row = new StringBuilder();
row.append(obj.getName() + ";");
row.append(obj.getPath() + ";");
row.append(obj.getOwner() + ";");
row.append(kind + ";");
row.append(obj.getModifiedAtFormattedForCSVReport() + ";");
row.append(String.valueOf(obj.getSize()) + ";");
row.append(String.valueOf(obj.getNumberOfMatches()));
row.append("\n");
outputStream.print(row.toString());
outputStream.flush();
}
}
use of com.emc.metalnx.core.domain.entity.DataGridMetadataSearch in project metalnx-web by irods-contrib.
the class TestMetadataCase method testCaseInsensitiveMetadataSearchContains.
@Test
public void testCaseInsensitiveMetadataSearchContains() throws DataGridConnectionRefusedException {
search.add(new DataGridMetadataSearch(attr, val, unit, DataGridSearchOperatorEnum.LIKE));
assertMetadataSearch(3, 1);
}
use of com.emc.metalnx.core.domain.entity.DataGridMetadataSearch in project metalnx-web by irods-contrib.
the class SpecQueryServiceImplTest method testSearchByMetadataDataObjects.
@Test
public void testSearchByMetadataDataObjects() throws Exception {
SpecQueryServiceImpl specQueryService = new SpecQueryServiceImpl();
IRODSServices irodsService = Mockito.mock(IRODSServices.class);
AdminServices adminServices = Mockito.mock(AdminServices.class);
IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);
EnvironmentalInfoAO environmentalInfoAO = irodsFileSystem.getIRODSAccessObjectFactory().getEnvironmentalInfoAO(irodsAccount);
SpecificQueryAO specificQueryAO = irodsFileSystem.getIRODSAccessObjectFactory().getSpecificQueryAO(irodsAccount);
Mockito.when(irodsService.getEnvironmentalInfoAO()).thenReturn(environmentalInfoAO);
Mockito.when(adminServices.getSpecificQueryAO()).thenReturn(specificQueryAO);
specQueryService.setIrodsServices(irodsService);
specQueryService.setAdminServices(adminServices);
List<DataGridMetadataSearch> metadataSearch = new ArrayList<DataGridMetadataSearch>();
DataGridMetadataSearch search = new DataGridMetadataSearch(DATA_AVU_ATTR1, DATA_AVU_VAL1, "", DataGridSearchOperatorEnum.EQUAL);
metadataSearch.add(search);
SpecificQueryResultSet result = specQueryService.searchByMetadata(metadataSearch, irodsAccount.getZone(), false, null, 0, 0);
Assert.assertFalse("no result", result.getResults().isEmpty());
}
Aggregations