Ejemplo n.º 1
0
    def get(self):
        """Search edge in collections of kind edge from DB."""

        args = pag_collections_arguments.parse_args(request)

        try:
            try:
                page = args.get('page')
                query = args.get('query') or '[]'
                per_page = args.get('per_page')
                collections = args.get('collections').split(',')
                data = json.loads(query)
            except JSONDecodeError:
                raise gmap_exc.SearchException('Parameter query is invalid')
            else:
                res = facade.search_collections(collections, data, page,
                                                per_page)
                return res, 200

        except gmap_exc.CollectionNotExist as err:
            api.abort(404, errors=err.message)

        except ValidationError as error:
            res = validate(error)
            api.abort(400, errors=res)
Ejemplo n.º 2
0
    def get(self):
        """Search document in collections of kind document from DB."""

        args = coll_parsers.search_all_parser.parse_args(request)

        try:
            try:
                page = args.get('page')
                query = args.get('query') or '[]'
                per_page = args.get('per_page')
                collections = args.get('collections').split(',')
                data = json.loads(query)
                app.logger.debug('Receive Data: %s', data)
            except JSONDecodeError:
                raise gmap_exc.SearchException('Parameter query is invalid')
            else:
                res = facade.search_collections(
                    collections, data, page, per_page)
                return res, 200

        except gmap_exc.CollectionNotExist as err:
            app.logger.error(err.message)
            api.abort(404, errors=err.message)

        except ValidationError as error:
            res = validate(error)
            app.logger.error(res)
            api.abort(400, errors=res)
Ejemplo n.º 3
0
    def get(self, collection):
        """Search documents from collection."""

        args = coll_parsers.search_parser.parse_args(request)

        try:
            try:
                page = args.get('page')
                query = args.get('query') or '[]'
                per_page = args.get('per_page')
                data = json.loads(query)
            except JSONDecodeError:
                raise gmap_exc.SearchException('Parameter query is invalid')
            else:
                res = facade.search(collection, data, page, per_page)
                return res, 200

        except gmap_exc.CollectionNotExist as err:
            app.logger.error(err.message)
            api.abort(404, errors=err.message)

        except ValidationError as error:
            res = validate(error)
            app.logger.error(res)
            api.abort(400, errors=res)
Ejemplo n.º 4
0
    def get(self):
        """List all graphs from DB."""

        args = search_parser.parse_args(request)

        try:
            page = args.get('page')
            per_page = args.get('per_page')
            res = facade.list_graphs(page, per_page)
        except JSONDecodeError:
            raise gmap_exc.SearchException('Parameter query is invalid')
        else:
            return res, 200
Ejemplo n.º 5
0
    def get(self):
        """List all collections of kind document from DB."""

        args = search_parser.parse_args(request)

        try:
            query = args.get('query') or '[]'
            page = args.get('page')
            per_page = args.get('per_page')
            data = json.loads(query)
            res = facade.list_collections('document', data, page, per_page)
        except JSONDecodeError:
            raise gmap_exc.SearchException('Parameter query is invalid')
        else:
            return res, 200