def get_dataobj_names_by_query(self, criteria): """ Generic method to retrieve the name of all data objects returned by a query using the given criteria. :param criteria: a list of Criterion objects :return: the names of data object satisfying those criteria """ query = Query(self.session, DataObject.name) for criterion in criteria: query = query.filter(criterion) results = query.execute() return [row[DataObject.name] for row in results.rows]
def is_external_dataset_dataobj_present(self, owner_id, dataset_id, recipient_id): """ Determines whether a share of a given user dataset by the given owner to the given recipient is manifest in the recipient's external dataset collection. :param owner_id: owner's WDK id :param dataset_id: irods dataset id :param recipient_id: recipient's WDK id :return: True if the share is manifest in the recipient's external dataset collection and False otherwise """ user_external_dataset_coll = paths.USER_EXTERNAL_DATASETS_COLLECTION_TEMPLATE.format( recipient_id) if self.session.collections.exists(user_external_dataset_coll): query = Query(self.session, DataObject.name)\ .filter(Collection.name == user_external_dataset_coll)\ .filter(DataObject.name == owner_id + "." + dataset_id)\ .count(DataObject.name) # Note that, due to replication, the count is likely to be 2 rather than 1 return True if query.execute().rows[0][ DataObject.name] > 0 else False else: return False
def query(self, *args): return Query(self, *args)
def get_coll_create_time(self, path): if self.session.collections.exists(path): query = Query(self.session, Collection.create_time) query = query.filter(Collection.name == path) result = query.execute() return result[0][Collection.create_time]
def get_dataobj_names_created_between(self, path, start_time, end_time): query = Query(self.session, DataObject.name) query = query.filter(Collection.name == path) \ .filter(Between(DataObject.create_time, (start_time, end_time))) results = query.execute() return [row[DataObject.name] for row in results.rows]