use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method listReplicasByResource.
@Override
public Map<DataGridCollectionAndDataObject, DataGridResource> listReplicasByResource(String path) throws DataGridConnectionRefusedException {
logger.info("listReplicasByResource()");
logger.info("Listing all replicas of " + path);
Map<DataGridCollectionAndDataObject, DataGridResource> map = new HashMap<DataGridCollectionAndDataObject, DataGridResource>();
String collectionAbsPath = null;
String fileName = null;
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
try {
collectionAbsPath = path.substring(0, path.lastIndexOf(IRODS_PATH_SEPARATOR));
fileName = path.substring(path.lastIndexOf(IRODS_PATH_SEPARATOR) + 1, path.length());
List<DataObject> replicas = dataObjectAO.listReplicationsForFile(collectionAbsPath, fileName);
for (DataObject replica : replicas) {
DataGridCollectionAndDataObject dataGridCollectionAndDataObject = DataGridUtils.getDataGridCollectionAndDataObject(replica);
DataGridResource dataGridResource = resourceService.find(replica.getResourceName());
map.put(dataGridCollectionAndDataObject, dataGridResource);
}
} catch (JargonException e) {
logger.error("Could not list replicas by resource for " + path);
}
return DataGridUtils.sortReplicaResourceMap(map);
}
use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method getSubCollectionsAndDataObjectsUnderPathThatMatchSearchTextPaginated.
@Override
public List<DataGridCollectionAndDataObject> getSubCollectionsAndDataObjectsUnderPathThatMatchSearchTextPaginated(String parentPath, String searchText, int pageNum, int pageSize, int orderColumn, String orderDir, DataGridPageContext pageContext) throws DataGridDataNotFoundException, DataGridQueryException, DataGridException {
logger.info("getSubCollectionsAndDataObjectsUnderPathThatMatchSearchTextPaginated()");
List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = new ArrayList<>();
List<DataGridCollectionAndDataObject> dataGridCollections = null;
List<DataGridCollectionAndDataObject> dataGridObjects = null;
int totalCollections = 0;
int totalDataObjects = 0;
int startIndex = (pageNum - 1) * pageSize;
int endIndex = pageNum * pageSize - 1;
int endIndexForDataObjs;
int endIndexForCollections;
try {
totalCollections = getTotalCollectionsUnderPathThatMatchSearchText(parentPath, searchText);
totalDataObjects = getTotalDataObjectsUnderPathThatMatchSearchText(parentPath, searchText);
pageContext.setStartItemNumber(startIndex + 1);
pageContext.setTotalNumberOfItems(totalCollections + totalDataObjects);
if (endIndex + 1 <= totalCollections) {
dataGridCollections = listCollectionsUnderPathThatMatchSearchText(parentPath, searchText, startIndex, pageSize, orderColumn, orderDir);
int collectionEntriesSize = dataGridCollections.size();
endIndexForCollections = collectionEntriesSize;
dataGridCollectionAndDataObjects = dataGridCollections.subList(0, endIndexForCollections);
pageContext.setEndItemNumber(pageContext.getStartItemNumber() + endIndexForCollections - 1);
} else if (startIndex + 1 > totalCollections) {
dataGridObjects = listDataObjectsUnderPathThatMatchSearchText(parentPath, searchText, startIndex - totalCollections, pageSize, orderColumn, orderDir);
pageContext.setEndItemNumber(pageContext.getStartItemNumber() + dataGridObjects.size() - 1);
dataGridCollectionAndDataObjects.addAll(dataGridObjects);
} else {
dataGridCollections = listCollectionsUnderPathThatMatchSearchText(parentPath, searchText, startIndex, pageSize, orderColumn, orderDir);
endIndexForDataObjs = pageSize - totalCollections % pageSize;
dataGridObjects = listDataObjectsUnderPathThatMatchSearchText(parentPath, searchText, 0, endIndexForDataObjs, orderColumn, orderDir);
endIndexForDataObjs = endIndexForDataObjs > dataGridObjects.size() ? dataGridObjects.size() : endIndexForDataObjs;
dataGridCollectionAndDataObjects.addAll(dataGridCollections);
dataGridCollectionAndDataObjects.addAll(dataGridObjects);
pageContext.setEndItemNumber(pageContext.getStartItemNumber() + endIndexForDataObjs + dataGridCollections.size() - 1);
}
} catch (DataNotFoundException e) {
logger.error("Could not find items under path: {}", e.getMessage());
throw new DataGridDataNotFoundException(e.getMessage());
} catch (JargonQueryException e) {
logger.error("Could not query catalog for items under path: {}", e.getMessage());
throw new DataGridQueryException(e.getMessage());
}
return dataGridCollectionAndDataObjects;
}
use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method findByName.
@Override
public DataGridCollectionAndDataObject findByName(String path) throws FileNotFoundException, DataGridException {
logger.info("findByName()");
if (path == null || path.isEmpty()) {
logger.info("Could not find collection or data object by name: path is null");
return null;
}
logger.info("Find collection or data object by name: {}", path);
CollectionAndDataObjectListAndSearchAO objectsAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
DataGridCollectionAndDataObject dataGridCollectionAndDataObject;
try {
CollectionAndDataObjectListingEntry entry = objectsAO.getCollectionAndDataObjectListingEntryAtGivenAbsolutePathWithHeuristicPathGuessing(path);
dataGridCollectionAndDataObject = this.mapListingEntryToDataGridCollectionAndDataObject(entry);
} catch (FileNotFoundException fnf) {
logger.warn("file not found for path:{}", path);
throw fnf;
} catch (JargonException e) {
logger.debug("error finding collection/data object by name: {}", path);
throw new DataGridException("Could not find path " + path);
}
return dataGridCollectionAndDataObject;
}
use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method searchCollectionAndDataObjectsByName.
@Override
public List<DataGridCollectionAndDataObject> searchCollectionAndDataObjectsByName(String collectionName) throws DataGridConnectionRefusedException {
logger.info("searchCollectionAndDataObjectsByName()");
CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
List<CollectionAndDataObjectListingEntry> collectionAndDataObjects = null;
List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = null;
try {
collectionAndDataObjects = collectionAndDataObjectListAndSearchAO.searchCollectionsAndDataObjectsBasedOnName(collectionName);
dataGridCollectionAndDataObjects = this.mapListingEntryToDataGridCollectionAndDataObject(collectionAndDataObjects);
return dataGridCollectionAndDataObjects;
} catch (JargonException e) {
logger.error("Could not search collections: {}", e.getMessage());
}
return null;
}
use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method mapListingEntryToDataGridCollectionAndDataObject.
@Override
public List<DataGridCollectionAndDataObject> mapListingEntryToDataGridCollectionAndDataObject(List<CollectionAndDataObjectListingEntry> entries) {
logger.info("mapListingEntryToDataGridCollectionAndDataObject()");
logger.debug("Mapping a CollectionAndDataObjectListingEntry list into a DataGridCollectionAndDataObject list");
List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = new ArrayList<DataGridCollectionAndDataObject>();
for (CollectionAndDataObjectListingEntry entry : entries) {
dataGridCollectionAndDataObjects.add(mapListingEntryToDataGridCollectionAndDataObject(entry));
}
return dataGridCollectionAndDataObjects;
}
Aggregations