Search in sources :

Example 46 with DataGridCollectionAndDataObject

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

the class TestUploadService method testDirectTransfer.

@Test
public void testDirectTransfer() throws Exception {
    boolean fileUploaded = false;
    MockMultipartFile file = new MockMultipartFile(TEST_FILE_NAME, "Hello World".getBytes());
    us.upload(file, targetPath, false, false, "", RESOURCE, false);
    List<DataGridCollectionAndDataObject> items = cs.getSubCollectionsAndDataObjectsUnderPath(targetPath);
    for (DataGridCollectionAndDataObject item : items) {
        if (TEST_FILE_NAME.equals(item.getName())) {
            fileUploaded = true;
            break;
        }
    }
    assertTrue(fileUploaded);
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) Test(org.junit.Test)

Example 47 with DataGridCollectionAndDataObject

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

the class TestAddMetadataToObjs method setUp.

@Before
public void setUp() throws DataGridException {
    time = System.currentTimeMillis();
    parentPath = String.format("/%s/home/%s", zone, username);
    srcPath = String.format("%s/test-metadata-transfer-%d", parentPath, time);
    dstPath = String.format("%s/dst-test-metadata-transfer-%d", parentPath, time);
    fos.deleteCollection(srcPath, true);
    fos.deleteCollection(dstPath, true);
    cs.createCollection(new DataGridCollectionAndDataObject(srcPath, parentPath, true));
    cs.createCollection(new DataGridCollectionAndDataObject(dstPath, parentPath, true));
    expectedMetadataList = MetadataUtils.createRandomMetadataAsString(NUMBER_OF_METADATA_TAGS);
    MockMultipartFile file;
    for (int i = 0; i < NUMBER_OF_FILES; i++) {
        String filename = BASE_FILE_NAME + i;
        String fileSrcPath = String.format("%s/%s", srcPath, filename);
        file = new MockMultipartFile(filename, "Hello World Transfer".getBytes());
        fos.deleteDataObject(fileSrcPath, true);
        us.upload(file, srcPath, false, false, "", RESOURCE, false);
        for (String metadataStr : expectedMetadataList) {
            String[] metadata = metadataStr.split(" ");
            String attr = metadata[0], val = metadata[1], unit = metadata[2];
            metadataService.addMetadataToPath(fileSrcPath, attr, val, unit);
        }
    }
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) Before(org.junit.Before)

Example 48 with DataGridCollectionAndDataObject

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

the class TestCopyObjWithMetadata method setUp.

@Before
public void setUp() throws DataGridException {
    parentPath = String.format("/%s/home/%s", zone, username);
    srcPath = String.format("%s/test-metadata-transfer", parentPath);
    dstPath = String.format("%s/dst-test-metadata-transfer", parentPath);
    fos.deleteCollection(srcPath, true);
    fos.deleteCollection(dstPath, true);
    cs.createCollection(new DataGridCollectionAndDataObject(srcPath, parentPath, true));
    cs.createCollection(new DataGridCollectionAndDataObject(dstPath, parentPath, true));
    String content = "Hello World Transfer";
    expectedMetadataList = new ArrayList<>();
    expectedMetadataList.add("attr1 val1 unit1");
    expectedMetadataList.add("attr2 val2 unit2");
    expectedMetadataList.add("attr3 val3 unit3");
    MockMultipartFile file;
    for (int i = 0; i < NUMBER_OF_FILES; i++) {
        String filename = BASE_FILE_NAME + i;
        String fileSrcPath = String.format("%s/%s", srcPath, filename);
        file = new MockMultipartFile(filename, content.getBytes());
        us.upload(file, srcPath, false, false, "", RESOURCE, false);
        for (String s : expectedMetadataList) {
            String[] metadata = s.split(" ");
            String attr = metadata[0], val = metadata[1], unit = metadata[2];
            metadataService.addMetadataToPath(fileSrcPath, attr, val, unit);
        }
    }
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) Before(org.junit.Before)

Example 49 with DataGridCollectionAndDataObject

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

the class DataGridUtils method mapListingEntryToDataGridCollectionAndDataObject.

/**
 * Maps a CollectionAndDataObjectListingEntry list into a DataGridCollectionAndDataObject list
 *
 * @param entries
 *            CollectionAndDataObjectListingEntry objects to map
 * @return list of DataGridCollectionAndDataObject objects
 */
public static List<DataGridCollectionAndDataObject> mapListingEntryToDataGridCollectionAndDataObject(List<CollectionAndDataObjectListingEntry> entries) {
    logger.debug("Mapping a CollectionAndDataObjectListingEntry list into a " + "DataGridCollectionAndDataObject list");
    List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = new ArrayList<DataGridCollectionAndDataObject>();
    for (CollectionAndDataObjectListingEntry entry : entries) {
        if ("/".equals(entry.getPathOrName()))
            continue;
        DataGridCollectionAndDataObject dataGridCollectionAndDataObject = mapListingEntryToDataGridCollectionAndDataObject(entry);
        dataGridCollectionAndDataObjects.add(dataGridCollectionAndDataObject);
    }
    return dataGridCollectionAndDataObjects;
}
Also used : DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) CollectionAndDataObjectListingEntry(org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)

Example 50 with DataGridCollectionAndDataObject

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

the class DataGridUtils method mapMetadataResultSetToDataGridCollections.

/**
 * Maps a query result set coming from a metadata search into a list of collections.
 *
 * @param queryResultSet
 *            sql result set returned from the execution of a specific query
 * @return List of collections
 * @throws JargonException
 */
public static List<DataGridCollectionAndDataObject> mapMetadataResultSetToDataGridCollections(SpecificQueryResultSet queryResultSet) throws JargonException {
    List<DataGridCollectionAndDataObject> colls = new ArrayList<>();
    if (queryResultSet != null) {
        List<IRODSQueryResultRow> results = queryResultSet.getResults();
        for (IRODSQueryResultRow row : results) {
            DataGridCollectionAndDataObject c = new DataGridCollectionAndDataObject();
            String collPath = row.getColumn("obj_name");
            String collName = collPath.substring(collPath.lastIndexOf("/") + 1, collPath.length());
            c.setName(collName);
            c.setPath(collPath);
            c.setParentPath(row.getColumn("parent_path"));
            c.setOwner(row.getColumn("obj_owner"));
            c.setCollection(true);
            c.setReplicaNumber("-");
            c.setCreatedAt(IRODSDataConversionUtil.getDateFromIRODSValue(row.getColumn("create_ts")));
            c.setModifiedAt(IRODSDataConversionUtil.getDateFromIRODSValue(row.getColumn("modify_ts")));
            c.setNumberOfMatches(Integer.valueOf(row.getColumn("totalMatches")));
            c.setResourceName(row.getColumn("resc_name"));
            colls.add(c);
        }
    }
    return colls;
}
Also used : IRODSQueryResultRow(org.irods.jargon.core.query.IRODSQueryResultRow) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)

Aggregations

DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)55 JargonException (org.irods.jargon.core.exception.JargonException)15 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 Before (org.junit.Before)11 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)9 FileNotFoundException (org.irods.jargon.core.exception.FileNotFoundException)9 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)7 ArrayList (java.util.ArrayList)7 CollectionAndDataObjectListingEntry (org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)7 DataGridPageContext (com.emc.metalnx.core.domain.entity.DataGridPageContext)6 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)6 DataGridMetadata (com.emc.metalnx.core.domain.entity.DataGridMetadata)5 CollectionAndDataObjectListAndSearchAO (org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO)5 Date (java.util.Date)4 HashMap (java.util.HashMap)4 JargonQueryException (org.irods.jargon.core.query.JargonQueryException)4 DataGridResource (com.emc.metalnx.core.domain.entity.DataGridResource)3 UnsupportedDataGridFeatureException (com.emc.metalnx.core.domain.exceptions.UnsupportedDataGridFeatureException)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3