-
Notifications
You must be signed in to change notification settings - Fork 5
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
Checking for undefined attributes that could be sent by the user in the comparison POST request #74
Conversation
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.
Tim can confirm once he's back from holiday, but for what it's worth I think your implementation makes sense and the code looks good. My only suggestion would be to add your example (or a version of it) to the tests as well, as it's useful for understanding the behaviour.
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.
Looks good to me
// "array_elements" attribute | "a" | ||
for (String attribute: seqColAAttributeSet) { | ||
// Looping through each attribute of seqcolA, Eg: "sequences", "lengths", etc... | ||
comparisonResult.putIntoArrayElements("a", attribute, seqColAEntityMap.get(attribute).size()); |
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.
I was going to say that we should check the that seqColAEntityMap.get(attribute)
returns a List
but it is currently enforced anyway.
We may need to support in the future sequence collection that contains non-list attributes. But that's for another issue.
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.
Absolutely, I was going to mention that in the next meeting.
Currently, when providing a single value attribute, the service throws an exception and I didn't know how to handle it (how the spec specifies how should we handle it).
Description
Currently, for the POST comparison endpoint, the seqcol service can only function when the user provides attributes that are already defined in our seqcol service implementation, and it will crash when the user provides an undefined attribute within the seqcol body.
So we're trying to make the service function even it gets undefined attributes from the user in the POST comparison endpoint request's body.
Fixes #70
Type of change
We'll be catching the exception thrown when the service tries to cast the undefined_attribute into a seqcol attribute of one of our implementation's in some of comparison result's parts, and ignore that attribute in that particular part.
Note: the attribute may be ignored for some parts of the comparison but it can appear in other parts (see the example below)
New Comparison Result output example
When providing the following secol level 2 object in the comparison POST body:
We get the following Comparison Result:
We can see that
new_attribute_1
andnew_attribute_2
appear in some of the comparisonResult's body parts, and don't in other parts where they can't be compared to existing attributes of our implementation.Further discussion
@tcezard So in this PR we made the service able to accept undefined attributes from the user in the POST comparison request, but these attributes will only appear in some parts of the comparison result.
Is this the right implementation or should we completely ignore the undefined attributes given in the comparison result body ? And in that case, what should be the output result (format) of that endpoint ?
Note
This branch is a child of the one of #73, so I think it's better to merge that one first for easier review.