Search in sources :

Example 1 with AvuData

use of org.irods.jargon.core.pub.domain.AvuData in project metalnx-web by irods-contrib.

the class MetadataServiceImpl method addMetadataToPath.

@Override
public boolean addMetadataToPath(String path, String attribute, String value, String unit) throws DataGridConnectionRefusedException {
    CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    boolean isMetadataAdded = false;
    logger.debug(path + ": " + attribute + " " + value + " " + unit);
    try {
        AvuData avuData = new AvuData(attribute, value, unit);
        Object obj = collectionAndDataObjectListAndSearchAO.getFullObjectForType(path);
        if (obj instanceof DataObject) {
            DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
            dataObjectAO.addAVUMetadata(path, avuData);
        } else {
            CollectionAO collectionAO = irodsServices.getCollectionAO();
            collectionAO.addAVUMetadata(path, avuData);
        }
        isMetadataAdded = true;
    } catch (JargonException e) {
        logger.error("Error trying to add metadata: " + e);
    }
    return isMetadataAdded;
}
Also used : CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataObject(org.irods.jargon.core.pub.domain.DataObject) CollectionAO(org.irods.jargon.core.pub.CollectionAO) JargonException(org.irods.jargon.core.exception.JargonException) AvuData(org.irods.jargon.core.pub.domain.AvuData) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataObject(org.irods.jargon.core.pub.domain.DataObject) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO)

Example 2 with AvuData

use of org.irods.jargon.core.pub.domain.AvuData in project metalnx-web by irods-contrib.

the class MetadataServiceImpl method modMetadataFromPath.

@Override
public boolean modMetadataFromPath(String path, String oldAttribute, String oldValue, String oldUnit, String newAttribute, String newValue, String newUnit) throws DataGridConnectionRefusedException {
    CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    try {
        AvuData oldAVUData = new AvuData(oldAttribute, oldValue, oldUnit);
        AvuData newAVUData = new AvuData(newAttribute, newValue, newUnit);
        Object obj = collectionAndDataObjectListAndSearchAO.getFullObjectForType(path);
        if (obj instanceof DataObject) {
            DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
            dataObjectAO.modifyAVUMetadata(path, oldAVUData, newAVUData);
        } else {
            CollectionAO collectionAO = irodsServices.getCollectionAO();
            collectionAO.modifyAVUMetadata(path, oldAVUData, newAVUData);
        }
    } catch (JargonException e) {
        logger.error("Error trying to modify metadata: " + e.toString());
        return false;
    }
    return true;
}
Also used : CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataObject(org.irods.jargon.core.pub.domain.DataObject) CollectionAO(org.irods.jargon.core.pub.CollectionAO) JargonException(org.irods.jargon.core.exception.JargonException) AvuData(org.irods.jargon.core.pub.domain.AvuData) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataObject(org.irods.jargon.core.pub.domain.DataObject) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO)

Example 3 with AvuData

use of org.irods.jargon.core.pub.domain.AvuData in project metalnx-web by irods-contrib.

the class SpecQueryServiceImplTest method decorateChildren.

public static void decorateChildren(final IRODSFile file, final CollectionAO collectionAO, final DataObjectAO dataObjectAO) throws Exception {
    IRODSFile childIrods;
    int i = 0;
    AvuData dataToAdd;
    for (File child : file.listFiles()) {
        childIrods = (IRODSFile) child;
        if (childIrods.isDirectory()) {
            if (i % 2 == 0) {
                dataToAdd = AvuData.instance(COLL_AVU_ATTR1, COLL_AVU_VAL1, "");
            } else {
                dataToAdd = AvuData.instance(COLL_AVU_ATTR2, COLL_AVU_VAL2, "");
            }
            collectionAO.addAVUMetadata(childIrods.getAbsolutePath(), dataToAdd);
            decorateChildren(childIrods, collectionAO, dataObjectAO);
        } else {
            if (i % 2 == 0) {
                dataToAdd = AvuData.instance(DATA_AVU_ATTR1, DATA_AVU_VAL1, "");
            } else {
                dataToAdd = AvuData.instance(DATA_AVU_ATTR2, DATA_AVU_VAL2, "");
            }
            dataObjectAO.addAVUMetadata(childIrods.getAbsolutePath(), dataToAdd);
        }
    }
}
Also used : AvuData(org.irods.jargon.core.pub.domain.AvuData) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile) File(java.io.File)

Example 4 with AvuData

use of org.irods.jargon.core.pub.domain.AvuData in project metalnx-web by irods-contrib.

the class MetadataServiceImpl method delMetadataFromPath.

@Override
public boolean delMetadataFromPath(String path, String attribute, String value, String unit) throws DataGridConnectionRefusedException {
    CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    try {
        AvuData avuData = new AvuData(attribute, value, unit);
        Object obj = collectionAndDataObjectListAndSearchAO.getFullObjectForType(path);
        if (obj instanceof DataObject) {
            DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
            dataObjectAO.deleteAVUMetadata(path, avuData);
        } else {
            CollectionAO collectionAO = irodsServices.getCollectionAO();
            collectionAO.deleteAVUMetadata(path, avuData);
        }
    } catch (JargonException e) {
        logger.error("Error trying to delete metadata: " + e.toString());
        return false;
    }
    return true;
}
Also used : CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataObject(org.irods.jargon.core.pub.domain.DataObject) CollectionAO(org.irods.jargon.core.pub.CollectionAO) JargonException(org.irods.jargon.core.exception.JargonException) AvuData(org.irods.jargon.core.pub.domain.AvuData) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataObject(org.irods.jargon.core.pub.domain.DataObject) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO)

Aggregations

AvuData (org.irods.jargon.core.pub.domain.AvuData)4 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)3 JargonException (org.irods.jargon.core.exception.JargonException)3 CollectionAO (org.irods.jargon.core.pub.CollectionAO)3 CollectionAndDataObjectListAndSearchAO (org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO)3 DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)3 DataObject (org.irods.jargon.core.pub.domain.DataObject)3 File (java.io.File)1 IRODSFile (org.irods.jargon.core.pub.io.IRODSFile)1