Skip to content

Commit

Permalink
#137: Basic implementation of GET endpoint for entities
Browse files Browse the repository at this point in the history
- Implementation for the Python ICAT backend
- This implementation ignores any filter parameters in the request as this haven't been implemented for the Python ICAT backend. As a result, this endpoint just gets all the records for a specified entity
  • Loading branch information
MRichards99 committed Jul 24, 2020
1 parent cac1003 commit cc4358e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions common/python_icat_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from common.helpers import queries_records
from common.python_icat_helpers import requires_session_id, get_session_details_helper, logout_icat_client, \
refresh_client_session, get_entity_by_id, update_entity_by_id, \
delete_entity_by_id
delete_entity_by_id, get_entity_with_filters
from common.config import config
from common.exceptions import AuthenticationError
from common.models.db_models import SESSION
Expand Down Expand Up @@ -56,7 +56,7 @@ def logout(self, session_id):
@requires_session_id
@queries_records
def get_with_filters(self, session_id, table, filters):
pass
return get_entity_with_filters(self.client, table.__name__, filters)

@requires_session_id
@queries_records
Expand Down
11 changes: 11 additions & 0 deletions common/python_icat_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,14 @@ def update_entity_by_id(client, table_name, id, new_data):
# The record is re-obtained from Python ICAT (rather than using entity_id_data) to show to the
# user whether the change has actually been applied
return get_entity_by_id(client, table_name, id, True)


def get_entity_with_filters(client, table_name, filters):
selected_entity_name = get_python_icat_entity_name(client, table_name)
query = construct_icat_query(client, selected_entity_name)
data = execute_icat_query(client, query, True)

if data == []:
raise MissingRecordError("No results found")

return data

0 comments on commit cc4358e

Please sign in to comment.