Search in sources :

Example 6 with DataGridMetadata

use of com.emc.metalnx.core.domain.entity.DataGridMetadata in project metalnx-web by irods-contrib.

the class MetadataController method getMetadata.

@RequestMapping(value = "/getMetadata/", method = RequestMethod.POST)
public String getMetadata(final Model model, final String path) throws DataGridConnectionRefusedException, FileNotFoundException {
    logger.info("MetadataController getMetadata() starts !!");
    List<DataGridMetadata> metadataList = metadataService.findMetadataValuesByPath(path);
    DataGridCollectionAndDataObject dgColObj = null;
    try {
        dgColObj = collectionService.findByName(path);
        permissionsService.resolveMostPermissiveAccessForUser(dgColObj, loggedUserUtils.getLoggedDataGridUser());
    } catch (DataGridException e) {
        logger.error("Could not retrieve collection/dataobject from path: {}", path);
    }
    model.addAttribute("permissionOnCurrentPath", collectionService.getPermissionsForPath(path));
    model.addAttribute("dataGridMetadataList", metadataList);
    model.addAttribute("currentPath", path);
    model.addAttribute("collectionAndDataObject", dgColObj);
    model.addAttribute("metadataFlag", true);
    logger.info("MetadataController getMetadata() ends !!");
    return "metadata/metadataTable :: metadataTable";
}
Also used : DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataGridMetadata(com.emc.metalnx.core.domain.entity.DataGridMetadata) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with DataGridMetadata

use of com.emc.metalnx.core.domain.entity.DataGridMetadata in project metalnx-web by irods-contrib.

the class MetadataController method exportToCSV.

@RequestMapping(value = "/exportToCSV")
public void exportToCSV(final HttpServletResponse response) throws IOException, DataGridConnectionRefusedException {
    String filePath = collectionController.getCurrentPath();
    List<DataGridMetadata> metadataList = metadataService.findMetadataValuesByPath(filePath);
    setReponseHeaderForCSVExport(response);
    ServletOutputStream outputStream = response.getOutputStream();
    outputStream.print("File path\n");
    outputStream.print(String.format("%s\n\n", filePath));
    outputStream.print("Attribute Name,Value,Unit\n");
    for (DataGridMetadata m : metadataList) {
        outputStream.print(String.format("%s,%s,%s\n", m.getAttribute(), m.getValue(), m.getUnit()));
    }
    outputStream.flush();
}
Also used : ServletOutputStream(javax.servlet.ServletOutputStream) DataGridMetadata(com.emc.metalnx.core.domain.entity.DataGridMetadata) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with DataGridMetadata

use of com.emc.metalnx.core.domain.entity.DataGridMetadata in project metalnx-web by irods-contrib.

the class TestAddDataGridMetadataListToColls method setUp.

@Before
public void setUp() throws DataGridException {
    parentPath = String.format("/%s/home/%s", zone, username);
    path = String.format("%s/test-metadata-transfer", parentPath);
    fos.deleteCollection(path, true);
    cs.createCollection(new DataGridCollectionAndDataObject(path, parentPath, true));
    expectedMetadataList = new ArrayList<>();
    expectedMetadataList.add(new DataGridMetadata("attr1", "val1", "unit1"));
    expectedMetadataList.add(new DataGridMetadata("attr2", "val2", "unit2"));
    expectedMetadataList.add(new DataGridMetadata("attr3", "val3", "unit3"));
    for (int i = 0; i < NUMBER_OF_COLLS; i++) {
        String collname = BASE_COLL_NAME + i;
        String collPath = String.format("%s/%s", path, collname);
        cs.createCollection(new DataGridCollectionAndDataObject(collPath, path, true));
        metadataService.addMetadataToPath(collPath, expectedMetadataList);
    }
}
Also used : DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataGridMetadata(com.emc.metalnx.core.domain.entity.DataGridMetadata) Before(org.junit.Before)

Example 9 with DataGridMetadata

use of com.emc.metalnx.core.domain.entity.DataGridMetadata in project metalnx-web by irods-contrib.

the class TestAddDataGridMetadataToColls method setUp.

@Before
public void setUp() throws DataGridException {
    parentPath = String.format("/%s/home/%s", zone, username);
    path = String.format("%s/test-metadata-transfer", parentPath);
    fos.deleteCollection(path, true);
    cs.createCollection(new DataGridCollectionAndDataObject(path, parentPath, true));
    expectedMetadataList = MetadataUtils.createRandomMetadata(NUMBER_OF_METADATA_TAGS);
    for (int i = 0; i < NUMBER_OF_COLLS; i++) {
        String collPath = String.format("%s/%s", path, BASE_COLL_NAME + i);
        cs.createCollection(new DataGridCollectionAndDataObject(collPath, path, true));
        for (DataGridMetadata metadata : expectedMetadataList) {
            metadataService.addMetadataToPath(collPath, metadata);
        }
    }
}
Also used : DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataGridMetadata(com.emc.metalnx.core.domain.entity.DataGridMetadata) Before(org.junit.Before)

Example 10 with DataGridMetadata

use of com.emc.metalnx.core.domain.entity.DataGridMetadata in project metalnx-web by irods-contrib.

the class TestAddMetadataToColls method assertMetadataInPath.

private void assertMetadataInPath(String path) throws DataGridConnectionRefusedException {
    List<DataGridMetadata> actualMetadataList = metadataService.findMetadataValuesByPath(path);
    Assert.assertEquals(expectedMetadataList.size(), actualMetadataList.size());
    for (DataGridMetadata m : actualMetadataList) {
        String metadataStr = m.getAttribute() + " " + m.getValue() + " " + m.getUnit();
        assertTrue(expectedMetadataList.contains(metadataStr));
    }
}
Also used : DataGridMetadata(com.emc.metalnx.core.domain.entity.DataGridMetadata)

Aggregations

DataGridMetadata (com.emc.metalnx.core.domain.entity.DataGridMetadata)13 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)6 Before (org.junit.Before)4 ArrayList (java.util.ArrayList)2 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)1 HashSet (java.util.HashSet)1 ServletOutputStream (javax.servlet.ServletOutputStream)1 JargonException (org.irods.jargon.core.exception.JargonException)1 CollectionAO (org.irods.jargon.core.pub.CollectionAO)1 CollectionAndDataObjectListAndSearchAO (org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO)1 DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)1 DataObject (org.irods.jargon.core.pub.domain.DataObject)1 JargonQueryException (org.irods.jargon.core.query.JargonQueryException)1 MetaDataAndDomainData (org.irods.jargon.core.query.MetaDataAndDomainData)1