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