Skip to content

Commit

Permalink
Fixed selectedTags getter
Browse files Browse the repository at this point in the history
  • Loading branch information
Marlon Weghorn committed May 11, 2021
1 parent 177fb57 commit 2eeba5a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/mdh_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,34 @@
"""

"""
This class allows for easy communication with the Metadatahub webql. For this it offers classes, mirroring
every query or object that can be used in the MDH. All of these classes inherit MDHObject, which offers
This class allows for easy communication with the Metadatahub webql. For this it offers classes, mirroring
every query or object that can be used in the MDH. All of these classes inherit MDHObject, which offers
functionality to (de-)serialize the contents from the class into a query, or the result of a query into the classes.
All Queries inherit from MDHQuery, which implements a different serialization algorithm.
The usage of this functionality can be broken down into a few steps:
1. Set up a MDHQueryRoot class. This class contains a list of queries that will be executed in the MDH.
1. Set up a MDHQueryRoot class. This class contains a list of queries that will be executed in the MDH.
query_root = MDHQueryRoot()
2. Set up an MDHQuery. For this you have to create some new Query, like this:
query = MDHQuery_searchMetadata()
Every query has some flags as their members, which are default set to False. When they are set to another value, that
value is used as an argument for their query. For example, when you only want to search metadata with a certain fileId:
query.fileIds = [1, 2, 3, 4, 5]
3. Set the result field of the Query: For every query, the result field has to be specified. This field is repsonsible,
for telling the MDH which of the resulting objects attributes you actually want to get returned. For example, if you
for telling the MDH which of the resulting objects attributes you actually want to get returned. For example, if you
only want to see the total number of results and all the metadata for all the resulting classes, use the following:
query.result.totalFilesCount = True
query.result.files = MDHFile()
query.result.files.metadata = MDHMetadata()
query.result.files.metadata.metadatum.name = True
query.result.files.metadata.metadatum.value = True
4. Add the query to the query_root and execute it:
query_root.queries.append(query)
query_root.build_and_send_request()
query_root.build_and_send_request()
5. Access the queries results:
total_file_count = query_root.queries[0].result.totalFilesCount
...
Expand Down Expand Up @@ -104,7 +104,7 @@ def serialize(self):

# Get all members of the Query
attributes = [attr for attr in dir(self) if not callable(
getattr(self, attr)) and not attr.startswith("__") and attr not in ["query_name", "result"]]
getattr(self, attr)) and not attr.startswith("_") and attr not in ["query_name", "result"]]

has_arguments = False

Expand Down Expand Up @@ -307,6 +307,7 @@ class MDHQuery_searchMetadata(MDHQuery):
offset: bool or int = False
fileSizeAsHumanReadable: bool = False # TODO how do we do this with bool values?
convertDateTimeTo: bool or str = False
_selectedTags: bool or [str] = False

@property
def selectedTags(self) -> bool or [str]:
Expand Down

0 comments on commit 2eeba5a

Please sign in to comment.