-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic datalink #212
Dynamic datalink #212
Conversation
This is working with the dynamic-datalink branch of gaia-app |
daiquiri/datalink/adapter.py
Outdated
rows = list(Datalink.objects.filter(ID__in=identifiers).values_list(*field_names)) | ||
|
||
# get the dynamic datalink entries | ||
dyn_rows = [tuple(link.values()) for link in self.get_dyn_datalink_links(identifiers)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tuple(link.values())
does not guaranty the order of the items in the resulting array.
daiquiri/datalink/adapter.py
Outdated
link['description'], | ||
link['semantics'], | ||
link['content_type'], | ||
link['content_size']) for link in self.get_dyn_datalink_links(identifiers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
content_size
should be changed to content_length
(datalink standard)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation breaks rebuild_oai_schema
. The culprit is the re-implemented get_datalink_list
which is used by rebuild_oai_schema
. In general, this function must return all datalink entries with the semantic #doi
. This must be addressed.
… get_datalink_list from DatalinkAdapter)
…t and get_datalink_rows
Pull Request Test Coverage Report for Build 6311071061
💛 - Coveralls |
This is the first attempt to create dynamic datalink.
Why dynamic datalink?
making use of tables for datalink is useful since it allows more flexibility (for non-programmable entries) and it is easier to maintain.
Additionally the datalink entries are usually part of the release, and as such get a DOI.
However, in one cases making use of tables to provide datalink entries may not be confortable:
In these cases datalink entries generated on the fly based on the ID are necessary.
Implementation
I added a DynamicDatalinkAdapterMixin class that take care of the dynamic datalink entries. I also added a method called:
get_datalink_rows
andget_dyn_datalink_links
to theBaseDatalinkAdapter
, to provide a single point of gathering for the datalink entries (slighlty slower).This improve greatly the maintenance and flexibility.
These changes should not break the former functionality.
How to
With this new implementation it is possible to add new datalink entries by overwriting the method:
get_dyn_datalink_links
from the DatalinkAdapter. This method returns a list of dynamic datalink entries for the provided IDs. The user is free of implementing anything necessary. It just need to declare the new DatalinkAdapter insettings/base.py
Improvements
This pull request also solves some issues the previous implementation had: