use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject in project metalnx-web by irods-contrib.
the class RuleServiceImpl method execManifestFileRule.
@Override
public void execManifestFileRule(String host, String targetPath, String objPath, String filePath) throws DataGridRuleException, DataGridConnectionRefusedException, FileNotFoundException, JargonException {
if (!DataGridCoreUtils.isPrideXMLManifestFile(objPath))
return;
logger.info("Get Manifest Rule called");
DataGridRule rule = new DataGridRule(DataGridRule.XML_MANIFEST_RULE, host);
List<DataGridCollectionAndDataObject> objs = cs.getSubCollectionsAndDataObjectsUnderPath(targetPath);
for (DataGridCollectionAndDataObject obj : objs) {
logger.info("Extracting metadata from [{}] and applying on [{}]", filePath, obj.getPath());
rule.setInputRuleParams(obj.getPath(), filePath, filePath);
executeRule(rule.toString());
}
}
use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method listCollectionsUnderPathThatMatchSearchText.
/**
* Lists all collections under the given path that match a search term. Any
* collection where the term appears in the beginning, middle, and the end of
* its name will be retrieved.
*
* @param parentPath
* path to the parent collection where you are looking for items that
* match a search term
* @param searchText
* term to be matched
* @param offset
* partial start index
* @param limit
* max number of items retrieved
* @return list of data objects that match the given search text
* @throws DataGridConnectionRefusedException
*/
private List<DataGridCollectionAndDataObject> listCollectionsUnderPathThatMatchSearchText(String parentPath, String searchText, int offset, int limit, int orderColumn, String orderDir) throws DataGridConnectionRefusedException {
logger.info("listCollectionsUnderPathThatMatchSearchText()");
logger.info("parentPath:{}", parentPath);
logger.info("searchText:{}", searchText);
logger.info("offset:{}", offset);
logger.info("limit:{}", limit);
logger.info("orderColumn:{}", orderColumn);
logger.info("orderDir:{}", orderDir);
SpecificQueryAO specificQueryAO = adminServices.getSpecificQueryAO();
SpecificQueryDefinition queryDef = null;
List<CollectionAndDataObjectListingEntry> itemsListingEntries = null;
List<DataGridCollectionAndDataObject> dataGridItemsList = null;
String sqlQueryAlias = "";
try {
sqlQueryAlias = SQL_LIST_COLLS_MATCHING_SEARCH_TEXT_ALIAS_WITH_ORDERING;
ClientHints clientHints = this.irodsServices.getEnvironmentalInfoAO().retrieveClientHints(false);
SpecificQueryProvider provider = specificQueryProviderFactory.instance(clientHints.whatTypeOfIcatIsIt());
String query = provider.buildSelectCollectionsUnderPathThatMatchSearchText(parentPath, searchText, offset, limit, orderColumn, orderDir);
// Creating Specific Query instance
queryDef = new SpecificQueryDefinition();
queryDef.setAlias(sqlQueryAlias);
queryDef.setSql(query);
// Creating spec query on iRODS
specificQueryAO.addSpecificQuery(queryDef);
// Executing specific query
String zone = irodsServices.getCurrentUserZone();
List<String> args = new ArrayList<String>();
String collNameParam = null;
if (IRODS_PATH_SEPARATOR.equals(parentPath)) {
collNameParam = String.format("%%%s%%%%%s%%", IRODS_PATH_SEPARATOR, searchText);
} else {
collNameParam = String.format("%s%s%%%s%%", parentPath, IRODS_PATH_SEPARATOR, searchText);
}
args.add(collNameParam);
args.add(parentPath);
args.add(String.valueOf(offset));
args.add(String.valueOf(limit));
SpecificQuery specQuery = SpecificQuery.instanceArguments(sqlQueryAlias, args, 0, zone);
logger.debug("specificQuery for text search:{}", specQuery);
SpecificQueryResultSet queryResultSet = specificQueryAO.executeSpecificQueryUsingAlias(specQuery, MAX_RESULTS_PER_PAGE, 0);
// Mapping spec query results to DataGrid* objects
itemsListingEntries = DataGridUtils.mapCollectionQueryResultSetToDataGridObjects(queryResultSet);
dataGridItemsList = DataGridUtils.mapListingEntryToDataGridCollectionAndDataObject(itemsListingEntries);
} catch (JargonException | JargonQueryException | UnsupportedDataGridFeatureException e) {
logger.error("Could not execute specific query to find collections matching a search text. ", e);
} finally {
try {
// after running the user specific query, we need to remove from the database
specificQueryAO.removeSpecificQueryByAlias(sqlQueryAlias);
} catch (JargonException e) {
logger.error("Could not remove specific query {}: ", sqlQueryAlias, e.getMessage());
}
}
return dataGridItemsList;
}
use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method getSubCollectionsUnderPath.
@Override
public List<DataGridCollectionAndDataObject> getSubCollectionsUnderPath(String parent) throws DataGridConnectionRefusedException {
logger.info("getSubCollectionsUnderPath()");
CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = null;
try {
List<CollectionAndDataObjectListingEntry> collectionAndDataObjects = collectionAndDataObjectListAndSearchAO.listCollectionsUnderPath(parent, 0);
dataGridCollectionAndDataObjects = this.mapListingEntryToDataGridCollectionAndDataObject(collectionAndDataObjects);
return dataGridCollectionAndDataObjects;
} catch (FileNotFoundException e) {
logger.error("Could not locate file: ", e);
} catch (JargonException e) {
logger.error("Error: ", e);
}
return dataGridCollectionAndDataObjects;
}
use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method getSubCollectionsAndDataObjectsUnderPath.
@Override
public List<DataGridCollectionAndDataObject> getSubCollectionsAndDataObjectsUnderPath(String parent) throws DataGridConnectionRefusedException, JargonException {
logger.info("getSubCollectionsAndDataObjectsUnderPath()");
if (parent == null || parent.isEmpty()) {
throw new IllegalArgumentException("null or empty parent");
}
logger.info("parent:{}", parent);
CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = null;
try {
List<CollectionAndDataObjectListingEntry> collectionAndDataObjects = collectionAndDataObjectListAndSearchAO.listDataObjectsAndCollectionsUnderPath(parent);
dataGridCollectionAndDataObjects = new ArrayList<DataGridCollectionAndDataObject>();
dataGridCollectionAndDataObjects = this.mapListingEntryToDataGridCollectionAndDataObject(collectionAndDataObjects);
return dataGridCollectionAndDataObjects;
} catch (FileNotFoundException e) {
logger.error("Could not locate file: ", e);
throw e;
} catch (JargonException e) {
logger.error("Error: ", e);
throw e;
}
}
use of com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method isFileInCollection.
@Override
public boolean isFileInCollection(String filename, String collectionPath) throws DataGridConnectionRefusedException, JargonException {
logger.info("isFileInCollection()");
if (filename == null || collectionPath == null)
return false;
List<DataGridCollectionAndDataObject> items = getSubCollectionsAndDataObjectsUnderPath(collectionPath);
for (DataGridCollectionAndDataObject i : items) {
if (!i.isCollection() && filename.equals(i.getName()))
return true;
}
return false;
}
Aggregations