Skip to content

Commit

Permalink
add string representation function to SearchAPIWhereFilter #259
Browse files Browse the repository at this point in the history
- To be used by `NestedWhereFilters` when LHS or RHS has an input of this type
  • Loading branch information
MRichards99 committed Dec 2, 2021
1 parent 2114858 commit 490470e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions datagateway_api/src/search_api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
PythonICATSkipFilter,
PythonICATWhereFilter,
)
from icat.query import Query
from icat.client import Client

# TODO - Implement each of these filters for Search API, inheriting from the Python ICAT
# versions
Expand All @@ -17,6 +19,19 @@ def __init__(self, field, value, operation, boolean_operator="and"):
def apply_filter(self, query):
return super().apply_filter(query)

def __str__(self):
# TODO - replace with `SessionHandler.client` when that work is merged
client = Client("https://localhost.localdomain:8181", checkCert=False)
client.login("simple", {"username": "root", "password": "pw"})

# TODO - can't just hardcode investigation entity. Might need `icat_entity_name`
# to be passed into init
query = Query(client, "Investigation")
query.addConditions(self.create_filter())
str_conds = query.get_conditions_as_str()

return str_conds[0]


class SearchAPISkipFilter(PythonICATSkipFilter):
def __init__(self, skip_value):
Expand Down

0 comments on commit 490470e

Please sign in to comment.