コード例 #1
0
 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)
コード例 #2
0
    def get_objects(self, api_root, id_, filter_args, allowed_filters):
        if api_root in self.data:
            api_info = self._get(api_root)
            collections = api_info.get("collections", [])

            objs = []
            for collection in collections:
                if "id" in collection and id_ == collection["id"]:

                    if filter_args:
                        full_filter = BasicFilter(filter_args)
                        objs.extend(full_filter.process_filter(collection.get("objects", []),
                                                               allowed_filters,
                                                               collection.get("manifest", [])))
                    else:
                        objs.extend(collection.get("objects", []))
            return create_bundle(objs)

        return None
コード例 #3
0
    def get_object(self, api_root, id_, object_id, filter_args,
                   allowed_filters):

        if api_root in self.data:
            api_info = self._get(api_root)
            collections = api_info.get("collections", [])

            objs = []
            for collection in collections:
                if "id" in collection and id_ == collection["id"]:
                    for obj in collection.get("objects", []):
                        if object_id == obj["id"]:
                            objs.append(obj)
                if filter_args:
                    full_filter = BasicFilter(filter_args)
                    objs = full_filter.process_filter(
                        objs, allowed_filters, collection.get("manifest", []))
            return create_bundle(objs)

        return None