Example #1
0
    def obj_get_list(self, bundle, domain, **kwargs):
        include_archived = 'include_archived' in bundle.request.GET
        try:
            es_query = es_search(bundle.request, domain, ['include_archived'])
        except Http400 as e:
            raise BadRequest(e.message)
        if include_archived:
            es_query['filter']['and'].append({
                'or': [
                    {
                        'term': {
                            'doc_type': 'xforminstance'
                        }
                    },
                    {
                        'term': {
                            'doc_type': 'xformarchived'
                        }
                    },
                ]
            })
        else:
            es_query['filter']['and'].append(
                {'term': {
                    'doc_type': 'xforminstance'
                }})

        # Note that XFormES is used only as an ES client, for `run_query` against the proper index
        return ElasticAPIQuerySet(
            payload=es_query,
            model=ESXFormInstance,
            es_client=self.xform_es(domain)).order_by('-received_on')
Example #2
0
    def obj_get_list(self, bundle, domain, **kwargs):
        es_query = es_search(bundle.request, domain)    
        es_query['filter']['and'].append({'term': {'doc_type': 'xforminstance'}})

        return ESQuerySet(payload = es_query,
                          model = XFormInstance, 
                          es_client=self.xform_es(domain)) # Not that XFormES is used only as an ES client, for `run_query` against the proper index
Example #3
0
    def obj_get_list(self, bundle, domain, **kwargs):
        include_archived = 'include_archived' in bundle.request.GET
        try:
            es_query = es_search(bundle.request, domain, ['include_archived'])
        except Http400 as e:
            raise BadRequest(e.message)
        if include_archived:
            es_query['filter']['and'].append({'or': [
                {'term': {'doc_type': 'xforminstance'}},
                {'term': {'doc_type': 'xformarchived'}},
            ]})
        else:
            es_query['filter']['and'].append({'term': {'doc_type': 'xforminstance'}})

        def wrapper(doc):
            if doc['doc_type'] in xform_doc_types:
                return xform_doc_types[doc['doc_type']].wrap(doc)
            else:
                return doc

        # Note that XFormES is used only as an ES client, for `run_query` against the proper index
        return ElasticAPIQuerySet(
            payload=es_query,
            model=wrapper,
            es_client=self.xform_es(domain)
        ).order_by('-received_on')
Example #4
0
    def obj_get_list(self, bundle, domain, **kwargs):
        es_query = es_search(bundle.request, domain)
        es_query["filter"]["and"].append({"term": {"doc_type": "xforminstance"}})

        # Note that XFormES is used only as an ES client, for `run_query` against the proper index
        return ESQuerySet(payload=es_query, model=XFormInstance, es_client=self.xform_es(domain)).order_by(
            "-received_on"
        )
Example #5
0
    def obj_get_list(self, bundle, domain, **kwargs):
        try:
            es_query = es_search(bundle.request, domain)
        except Http400 as e:
            raise BadRequest(str(e))

        return ElasticAPIQuerySet(
            payload=es_query, model=ESCase,
            es_client=self.case_es(domain)).order_by('server_modified_on')
Example #6
0
    def obj_get_list(self, bundle, domain, **kwargs):
        try:
            es_query = es_search(bundle.request, domain)
        except Http400 as e:
            raise BadRequest(e.message)
        es_query['filter']['and'].append({'term': {'doc_type': 'xforminstance'}})

        # Note that XFormES is used only as an ES client, for `run_query` against the proper index
        return ESQuerySet(payload = es_query,
                          model = XFormInstance,
                          es_client=self.xform_es(domain)).order_by('-received_on')
Example #7
0
    def obj_get_list(self, bundle, domain, **kwargs):
        try:
            es_query = es_search(bundle.request, domain)
        except Http400 as e:
            raise BadRequest(e.message)
        es_query['filter']['and'].append({'term': {'doc_type': 'xforminstance'}})

        # Note that XFormES is used only as an ES client, for `run_query` against the proper index
        return ESQuerySet(payload = es_query,
                          model = XFormInstance,
                          es_client=self.xform_es(domain)).order_by('-received_on')
Example #8
0
    def obj_get_list(self, bundle, domain, **kwargs):
        es_query = es_search(bundle.request, domain)
        es_query['filter']['and'].append(
            {'term': {
                'doc_type': 'xforminstance'
            }})

        return ESQuerySet(
            payload=es_query,
            model=XFormInstance,
            es_client=self.xform_es(domain)
        )  # Not that XFormES is used only as an ES client, for `run_query` against the proper index
Example #9
0
    def obj_get_list(self, bundle, domain, **kwargs):
        include_archived = "include_archived" in bundle.request.GET
        try:
            es_query = es_search(bundle.request, domain, ["include_archived"])
        except Http400 as e:
            raise BadRequest(e.message)
        if include_archived:
            es_query["filter"]["and"].append(
                {"or": [{"term": {"doc_type": "xforminstance"}}, {"term": {"doc_type": "xformarchived"}}]}
            )
        else:
            es_query["filter"]["and"].append({"term": {"doc_type": "xforminstance"}})

        def wrapper(doc):
            if doc["doc_type"] in xform_doc_types:
                return xform_doc_types[doc["doc_type"]].wrap(doc)
            else:
                return doc

        # Note that XFormES is used only as an ES client, for `run_query` against the proper index
        return ESQuerySet(payload=es_query, model=wrapper, es_client=self.xform_es(domain)).order_by("-received_on")
Example #10
0
 def obj_get_list(self, request, domain, **kwargs):
     return ESQuerySet(payload = es_search(request, domain),
                       model = XFormInstance, 
                       es_client=XFormES(domain)) # Not that XFormES is used only as an ES client, for `run_query` against the proper index