def get_object_manifest(self, api_root, id_, filter_args, allowed_filters): # TODO: Handle if mongodb is not available api_root_db = self.client[api_root] manifest_info = api_root_db["manifests"] full_filter = MongoDBFilter(filter_args, {"collection_id": id_}, allowed_filters) objects_found = full_filter.process_filter(manifest_info, allowed_filters, None) if objects_found: for obj in objects_found: del obj["_id"] del obj["collection_id"] return objects_found
def get_object_manifest(self, api_root, id_, filter_args, allowed_filters): api_root_db = self.client[api_root] manifest_info = api_root_db["manifests"] full_filter = MongoDBFilter(filter_args, {"_collection_id": id_}, allowed_filters) objects_found = full_filter.process_filter(manifest_info, allowed_filters, None) if objects_found: for obj in objects_found: if obj: obj.pop("_id", None) obj.pop("_collection_id", None) return objects_found
def get_objects(self, api_root, id_, filter_args, allowed_filters): # TODO: Handle if mongodb is not available api_root_db = self.client[api_root] objects = api_root_db["objects"] full_filter = MongoDBFilter(filter_args, {"collection_id": id_}, allowed_filters) objects_found = full_filter.process_filter(objects, allowed_filters, {"mongodb_collection": api_root_db["manifests"], "collection_id": id_}) for obj in objects_found: del obj["_id"] del obj["collection_id"] return create_bundle(objects_found)
def get_objects(self, api_root, id_, filter_args, allowed_filters): api_root_db = self.client[api_root] objects = api_root_db["objects"] full_filter = MongoDBFilter(filter_args, {"_collection_id": id_}, allowed_filters) # Note: error handling was not added to following call as mongo will # handle (user supplied) filters gracefully if they don't exist objects_found = full_filter.process_filter( objects, allowed_filters, { "mongodb_collection": api_root_db["manifests"], "_collection_id": id_ }) for obj in objects_found: if obj: obj.pop("_id", None) obj.pop("_collection_id", None) return create_bundle(objects_found)
def get_object_manifest(self, api_root, id_, filter_args, allowed_filters, start_index, page_size): api_root_db = self.client[api_root] manifest_info = api_root_db["manifests"] full_filter = MongoDBFilter(filter_args, {"_collection_id": id_}, allowed_filters, start_index, page_size) total, objects_found = full_filter.process_filter( manifest_info, allowed_filters, None) if objects_found: for obj in objects_found: if obj: obj.pop("_id", None) obj.pop("_collection_id", None) obj.pop("_type", None) # format date_added which is an ISODate object obj['date_added'] = format_datetime(obj['date_added']) return total, objects_found
def get_object(self, api_root, id_, object_id, filter_args, allowed_filters): api_root_db = self.client[api_root] objects = api_root_db["objects"] full_filter = MongoDBFilter(filter_args, { "_collection_id": id_, "id": object_id }, allowed_filters) objects_found = full_filter.process_filter( objects, allowed_filters, { "mongodb_collection": api_root_db["manifests"], "_collection_id": id_ }) if objects_found: for obj in objects_found: if obj: obj.pop("_id", None) obj.pop("_collection_id", None) return create_bundle(objects_found)