use of org.irods.jargon.core.query.MetaDataAndDomainData 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;
}
Aggregations