Search in sources :

Example 6 with DataGridMetadataSearch

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);
}
Also used : DataGridMetadataSearch(com.emc.metalnx.core.domain.entity.DataGridMetadataSearch) Test(org.junit.Test)

Example 7 with DataGridMetadataSearch

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();
    }
}
Also used : DataGridPageContext(com.emc.metalnx.core.domain.entity.DataGridPageContext) DataGridMetadataSearch(com.emc.metalnx.core.domain.entity.DataGridMetadataSearch) ServletOutputStream(javax.servlet.ServletOutputStream) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with DataGridMetadataSearch

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);
}
Also used : DataGridMetadataSearch(com.emc.metalnx.core.domain.entity.DataGridMetadataSearch) Test(org.junit.Test)

Example 9 with DataGridMetadataSearch

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());
}
Also used : EnvironmentalInfoAO(org.irods.jargon.core.pub.EnvironmentalInfoAO) AdminServices(com.emc.metalnx.services.interfaces.AdminServices) DataGridMetadataSearch(com.emc.metalnx.core.domain.entity.DataGridMetadataSearch) IRODSAccount(org.irods.jargon.core.connection.IRODSAccount) ArrayList(java.util.ArrayList) SpecificQueryResultSet(org.irods.jargon.core.query.SpecificQueryResultSet) IRODSServices(com.emc.metalnx.services.interfaces.IRODSServices) SpecificQueryAO(org.irods.jargon.core.pub.SpecificQueryAO) Test(org.junit.Test)

Aggregations

DataGridMetadataSearch (com.emc.metalnx.core.domain.entity.DataGridMetadataSearch)9 Test (org.junit.Test)6 AdminServices (com.emc.metalnx.services.interfaces.AdminServices)4 IRODSServices (com.emc.metalnx.services.interfaces.IRODSServices)4 ArrayList (java.util.ArrayList)4 IRODSAccount (org.irods.jargon.core.connection.IRODSAccount)4 EnvironmentalInfoAO (org.irods.jargon.core.pub.EnvironmentalInfoAO)4 SpecificQueryAO (org.irods.jargon.core.pub.SpecificQueryAO)4 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)2 DataGridPageContext (com.emc.metalnx.core.domain.entity.DataGridPageContext)2 SpecificQueryResultSet (org.irods.jargon.core.query.SpecificQueryResultSet)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 DataGridSearchOperatorEnum (com.emc.metalnx.core.domain.entity.enums.DataGridSearchOperatorEnum)1 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)1 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1