Search in sources :

Example 1 with CollectionAndDataObjectListAndSearchAO

use of org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO 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 CollectionAndDataObjectListAndSearchAO

use of org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO 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 CollectionAndDataObjectListAndSearchAO

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

the class CollectionServiceImpl method listInheritanceForPath.

@Override
public Set<String> listInheritanceForPath(String path) throws DataGridConnectionRefusedException {
    logger.info("listInheritanceForPath()");
    Set<String> collections = new HashSet<String>();
    CollectionAO collectionAO = irodsServices.getCollectionAO();
    CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    try {
        List<CollectionAndDataObjectListingEntry> collList = collectionAndDataObjectListAndSearchAO.listCollectionsUnderPathWithPermissions(path, 0);
        for (CollectionAndDataObjectListingEntry collEntry : collList) {
            String currentCollPath = collEntry.getPathOrName();
            if (collectionAO.isCollectionSetForPermissionInheritance(currentCollPath)) {
                collections.add(currentCollPath);
            }
        }
        return collections;
    } catch (JargonException e) {
        logger.error("Could not get collections with inheritance option enabled: ", e);
    }
    return null;
}
Also used : CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) CollectionAO(org.irods.jargon.core.pub.CollectionAO) JargonException(org.irods.jargon.core.exception.JargonException) CollectionAndDataObjectListingEntry(org.irods.jargon.core.query.CollectionAndDataObjectListingEntry) HashSet(java.util.HashSet)

Example 4 with CollectionAndDataObjectListAndSearchAO

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

the class CollectionServiceImplTest method testGetSubCollectionsAndDataObjectsUnderPathThatMatchSearchTextPaginated.

@Test
public void testGetSubCollectionsAndDataObjectsUnderPathThatMatchSearchTextPaginated() throws Exception {
    CollectionServiceImpl collectionService = new CollectionServiceImpl();
    IRODSServices irodsService = Mockito.mock(IRODSServices.class);
    AdminServices adminServices = Mockito.mock(AdminServices.class);
    IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);
    EnvironmentalInfoAO environmentalInfoAO = irodsFileSystem.getIRODSAccessObjectFactory().getEnvironmentalInfoAO(irodsAccount);
    CollectionAndDataObjectListAndSearchAO listAndSearchAO = irodsFileSystem.getIRODSAccessObjectFactory().getCollectionAndDataObjectListAndSearchAO(irodsAccount);
    SpecificQueryAO specificQueryAO = irodsFileSystem.getIRODSAccessObjectFactory().getSpecificQueryAO(irodsAccount);
    Mockito.when(irodsService.getEnvironmentalInfoAO()).thenReturn(environmentalInfoAO);
    Mockito.when(irodsService.getCollectionAndDataObjectListAndSearchAO()).thenReturn(listAndSearchAO);
    Mockito.when(adminServices.getSpecificQueryAO()).thenReturn(specificQueryAO);
    collectionService.setIrodsServices(irodsService);
    collectionService.setAdminServices(adminServices);
    List<DataGridCollectionAndDataObject> actual = collectionService.searchCollectionAndDataObjectsByName("textSearch");
    Assert.assertTrue("no recs returned", actual.size() > 1);
}
Also used : EnvironmentalInfoAO(org.irods.jargon.core.pub.EnvironmentalInfoAO) CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) AdminServices(com.emc.metalnx.services.interfaces.AdminServices) IRODSAccount(org.irods.jargon.core.connection.IRODSAccount) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) IRODSServices(com.emc.metalnx.services.interfaces.IRODSServices) SpecificQueryAO(org.irods.jargon.core.pub.SpecificQueryAO) Test(org.junit.Test)

Example 5 with CollectionAndDataObjectListAndSearchAO

use of org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO 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)

Aggregations

CollectionAndDataObjectListAndSearchAO (org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO)11 JargonException (org.irods.jargon.core.exception.JargonException)10 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)9 CollectionAndDataObjectListingEntry (org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)6 CollectionAO (org.irods.jargon.core.pub.CollectionAO)5 DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)4 DataObject (org.irods.jargon.core.pub.domain.DataObject)4 HashSet (java.util.HashSet)3 FileNotFoundException (org.irods.jargon.core.exception.FileNotFoundException)3 AvuData (org.irods.jargon.core.pub.domain.AvuData)3 DataGridFilePermission (com.emc.metalnx.core.domain.entity.DataGridFilePermission)1 DataGridGroupPermission (com.emc.metalnx.core.domain.entity.DataGridGroupPermission)1 DataGridMetadata (com.emc.metalnx.core.domain.entity.DataGridMetadata)1 DataGridUserPermission (com.emc.metalnx.core.domain.entity.DataGridUserPermission)1 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)1 AdminServices (com.emc.metalnx.services.interfaces.AdminServices)1 IRODSServices (com.emc.metalnx.services.interfaces.IRODSServices)1 ArrayList (java.util.ArrayList)1 IRODSAccount (org.irods.jargon.core.connection.IRODSAccount)1 EnvironmentalInfoAO (org.irods.jargon.core.pub.EnvironmentalInfoAO)1