Example #1
0
    def SearchDatasets(self, request, context):
        data = search_dataset_request_serializer.load(request)
        mappings = {
            "id": "_id",
            "name": "name",
            "scope": "scope",
            "project": "project"
        }
        ids = ["_id"]

        query = construct_mongo_query(data["query"], mappings, ids)
        if query:
            datasets = documents.Dataset.objects(__raw__=query).filter(deleted=False)
        else:
            datasets = documents.Dataset.objects(deleted=False)

        paginated = dataset_serializer.paginate(datasets, page=data["page"],
                                                limit=data["limit"])
        payload = {
            "total": len(datasets),
            "page": paginated[0],
            "limit": paginated[1],
            "data": paginated[2]
        }
        return search_dataset_response_serializer.dump(payload)
Example #2
0
    def SearchRevision(self, request, context):
        data = search_revision_request_serializer.load(request)

        mappings = {
            "id": "_id",
            "project": "project",
            "author": "author",
        }
        ids = ["_id", "project"]

        query = utils.construct_mongo_query(data["query"], mappings, ids)
        if query:
            revisions = documents.Revision.objects(__raw__=query).filter(
                project__in=documents.Project.objects(deleted=False))
        else:
            revisions = documents.Revision.objects(
                project__in=documents.Project.objects(deleted=False))

        paginated = project_serializer.paginate(revisions,
                                                page=data["page"],
                                                limit=data["limit"])
        payload = {
            "total": len(revisions),
            "page": paginated[0],
            "limit": paginated[1],
            "data": paginated[2]
        }
        return search_revision_response_serializer.dump(payload)
Example #3
0
    def SearchVersions(self, request, context):
        data = search_version_request_serializer.load(request)
        mappings = {
            "id": "_id",
            "name": "name",
            "dataset": "dataset",
            "author": "author"
        }
        ids = ["_id", "dataset"]

        query = construct_mongo_query(data["query"], mappings, ids)
        if query:
            versions = documents.Version.objects(__raw__=query).filter(
                dataset__in=documents.Dataset.objects(deleted=False))
        else:
            versions = documents.Version.objects(
                dataset__in=documents.Dataset.objects(deleted=False))

        paginated = version_serializer.paginate(versions, page=data["page"],
                                                limit=data["limit"])
        payload = {
            "total": len(versions),
            "page": paginated[0],
            "limit": paginated[1],
            "data": paginated[2]
        }
        return search_version_response_serializer.dump(payload)
Example #4
0
    def Search(self, request, context):
        data = search_project_request_serializer.load(request)
        mappings = {
            "id": "_id",
            "name": "name",
            "visibility": "visibility",
            "template": "template",
            "state": "state",
            "member": "members"
        }
        ids = ["_id"]

        query = utils.construct_mongo_query(data["query"], mappings, ids)
        if query:
            projects = documents.Project.objects(__raw__=query).filter(
                deleted=False)
        else:
            projects = documents.Project.objects(deleted=False)

        paginated = project_serializer.paginate(projects,
                                                page=data["page"],
                                                limit=data["limit"])
        payload = {
            "total": len(projects),
            "page": paginated[0],
            "limit": paginated[1],
            "data": paginated[2]
        }
        return search_project_response_serializer.dump(payload)
Example #5
0
    def Search(self, request, context):
        data = search_request_serializer.load(request)
        mappings = {
            "project": "metadata.project",
            "owner": "metadata.owner",
            "state": "state"
        }
        ids = [""]

        query = utils.construct_mongo_query(data["query"], mappings, ids)
        if query:
            workspaces = documents.Workspace.objects(__raw__=query).filter(deleted=False)
        else:
            workspaces = documents.Workspace.objects(deleted=False)

        paginated = workspace_serializer.paginate(workspaces, page=data["page"],
                                                  limit=data["limit"])
        payload = {
            "total": len(workspaces),
            "page": paginated[0],
            "limit": paginated[1],
            "data": paginated[2]
        }
        return search_workspace_response_serializer.dump(payload)