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;
}
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;
}
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);
}
}
}
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;
}
Aggregations