Search in sources :

Example 11 with DataGridMetadata

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

the class MetadataServiceImpl method findMetadataValuesByPath.

@Override
public List<DataGridMetadata> findMetadataValuesByPath(String path) throws DataGridConnectionRefusedException {
    List<MetaDataAndDomainData> metadataList;
    List<DataGridMetadata> dataGridMetadataList = new ArrayList<>();
    List<MetaDataAndDomainData> resultingList;
    CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    try {
        Object obj = collectionAndDataObjectListAndSearchAO.getFullObjectForType(path);
        if (obj instanceof DataObject) {
            DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
            metadataList = dataObjectAO.findMetadataValuesForDataObject(path);
        } else {
            CollectionAO collectionAO = irodsServices.getCollectionAO();
            metadataList = collectionAO.findMetadataValuesForCollection(path);
        }
        // TODO2: Making sure all AVUs are unique. Jargon should do that.
        resultingList = new ArrayList<>();
        Set<Integer> setOfAlreadyListedAVUs = new HashSet<>();
        for (MetaDataAndDomainData avuForItem : metadataList) {
            int avuId = avuForItem.getAvuId();
            if (!setOfAlreadyListedAVUs.contains(avuId)) {
                resultingList.add(avuForItem);
                setOfAlreadyListedAVUs.add(avuId);
            }
        }
        for (MetaDataAndDomainData metadata : resultingList) {
            DataGridMetadata dataGridMetadata = new DataGridMetadata();
            dataGridMetadata.setAttribute(metadata.getAvuAttribute());
            dataGridMetadata.setValue(metadata.getAvuValue());
            dataGridMetadata.setUnit(metadata.getAvuUnit());
            dataGridMetadataList.add(dataGridMetadata);
        }
        Collections.sort(dataGridMetadataList);
    } catch (JargonQueryException e) {
        logger.error("Error getting metadata info from collection: " + e.toString());
    } catch (JargonException e) {
        logger.error("Error getting metadata info from dataobject: " + e.toString());
    }
    return dataGridMetadataList;
}
Also used : CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) CollectionAO(org.irods.jargon.core.pub.CollectionAO) JargonException(org.irods.jargon.core.exception.JargonException) ArrayList(java.util.ArrayList) MetaDataAndDomainData(org.irods.jargon.core.query.MetaDataAndDomainData) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataObject(org.irods.jargon.core.pub.domain.DataObject) JargonQueryException(org.irods.jargon.core.query.JargonQueryException) DataGridMetadata(com.emc.metalnx.core.domain.entity.DataGridMetadata) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataObject(org.irods.jargon.core.pub.domain.DataObject) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO) HashSet(java.util.HashSet)

Example 12 with DataGridMetadata

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

the class MetadataUtils method createRandomMetadata.

static List<DataGridMetadata> createRandomMetadata(int numberOfMetadataTags) {
    List<DataGridMetadata> metadataList = new ArrayList<>();
    for (int i = 0; i < numberOfMetadataTags; i++) {
        String attribute = "attr" + i;
        String value = "val" + i;
        String unit = "unit" + i;
        metadataList.add(new DataGridMetadata(attribute, value, unit));
    }
    return metadataList;
}
Also used : ArrayList(java.util.ArrayList) DataGridMetadata(com.emc.metalnx.core.domain.entity.DataGridMetadata)

Example 13 with DataGridMetadata

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

the class TestCopyObjWithMetadata 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