-
Notifications
You must be signed in to change notification settings - Fork 265
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
updateContext "replace" and geolocalization #1142
Comments
Hello, I would like to work on this issue. Can you assign it to me? (due to possible relationship with #3167 ) |
Done. Thanks! |
The problem is where building the final append query in case of replace action. As done for the expirationDate feature, the logic has to check if there is a new location, or if the old one must be deleted, and then append it either to set or unset BSONObjBuilders. In order to avoid code complication (too many if), in the updateEntity() function, a good approach could be using a BSONObjBuilder (replaceSet) instead BSON stream form, something like the following:
For instance, if (newGeoJson.nFields() > 0) checks indeed if there is a new location in the payload, then to be set.
As I understand, this case, instead:
|
- Existing location attribute L1, replace including L1 - Existing location attribute L1, replace no including any location attribute - Not existing location attribute, replace including location attribute
I've added unit test for 3 cases, except the following one:
|
I will try to ilustrate with an example. Let's assume we have the following situation (S) in DB:
Then a replace like this is proccessed:
The resulting situation in DB is:
Another case, let's assume again situation S and the following replace request:
the situation in DB after processing it should be:
Please tell me if this clarifies how it should behave. From an implementation point of view, I guess that is a matter of adjusting toSet, toUnset, etc. arrays accordingly, but I haven't go too much into details. |
Ok, right. So only for the replace case we should allow replacing a target location attribute (e.g. L2) when there is already a different location attribute? (e.g. L1). Currently we have:
So, should this part be refined with a "if v2 replace" check, avoiding to return an error in that case? |
Sounds good (although I haven't analyzed the problem in deep in order to know if there are better options ;) |
In fact, replace can also be used in v1 (POST /v1/updateContext with actionType: REPLACE). However, it is fine if the check is only working for NGSIv2 (NGSIv1 is about to be deprecated so fixing it is not a priority). |
Fixed in 40da980 |
Fixed by PR #3283 |
It is not clear if the implementation of the "replace" functionality at mongoBackend (done in PR #1132) will work right in the case of using location attributes. Four situations needs to be tested:
The right strategy to test this (either unit test for mongoBackend, end2end test harness or a combination of both) will be decided in the moment of addressing this issue.
The best moment to implement this issue is once the new geolocation in NGSIv2 gets implemented (i.e. "geo:point" stuff).
Effort: 3 man day
The text was updated successfully, but these errors were encountered: