- Notifications
You must be signed in to change notification settings - Fork 39
Add support for embedded items of different kinds and multiplicity #4
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
Conversation
Hi Alexander, first of all thanks for contributing to the project! The change about multiple embedded items is clear to me, but could you give me an example on how to generate such a response with multiple embedded items within Spring Data REST? And about the second change: What do you mean with embedded items of different kinds? Could you also show me an example here? Thanks and regards, Guy |
We're actually using this outside of the Spring Data REST context. We could provide some JSON that we're able to generate with our backend. Not sure if that puts our PR out of scope or not. :) |
@guylabs Here is some sample JSON we're trying to work with: { "progress": 0, "_links": { "self": { "href": "/sandbox/card/15" }, "random": { "href": "/sandbox/random" }, "entity": { "href": "/sandbox/entity/15" } }, "_embedded": { "entity": { "id": 15, "name": "Name1", "discr": "action", "_links": { "self": { "href": "/sandbox/entity/15" }, "content": { "href": "/sandbox/content/15" } }, "_embedded": { "content": { "id": 15, "instruction": "Instruction1", "question": "Question1", "url": "http: //www.google.be", "discr": "urlsimple", "_links": { "answers": { "href": "/sandbox/content/15/answers" } }, "_embedded": { "answers": [ { "id": 17, "answer": "a", "_links": { "self": { "href": "/sandbox/answer/17" } } }, { "id": 18, "answer": "b", "_links": { "self": { "href": "/sandbox/answer/18" } } } ] } } } } } } |
Ok thanks for the JSON. And how should the result JSON look like after it has been processed by the I thought that you would have a JSON like the following (having an array of embedded items): ... "_embedded": [{ "entity": { ... }, "entity2": { ... }, ... ], ... Or do you also have something like that? |
Hello Guy, I'm Mihai and I've worked with @aderuwe on the above pull request. Sorry for our late response, here is the result we get after processing the request (JSON-ified): { "progress":0, "_links":{ "self":{ "href":"/sandbox/card/1" }, "random":{ "href":"/sandbox/random" }, "learning-entity":{ "href":"/sandbox/learning-entity/1" } }, "_embeddedItems":{ "learning-entity":{ "id":1, "name":"Sample A", "discr":"action", "_links":{ "self":{ "href":"/sandbox/learning-entity/1" }, "content":{ "href":"/sandbox/content/1" } }, "_embeddedItems":{ "content":{ "id":1, "instruction":"Don't have any", "question":"Like ?", "url":"http://www.google.com", "discr":"urlsimple", "_links":{ "answers":{ "href":"/sandbox/content/1/answers" } }, "_embeddedItems":{ "answers":[ { "id":1, "answer":"Yes", "_links":{ "self":{ "href":"/sandbox/answer/1" } } }, { "id":2, "answer":"No", "_links":{ "self":{ "href":"/sandbox/answer/2" } } } ] } } } } } } Processing will replace
Best regards, |
Hi Mihai, thanks for your reply! Ok now I see your point. Ok then I will have a look at it right away and come up with a solution for you guys. Is that ok for you like that? Regards, Guy |
Hi Guy, Definitely, thank you for taking the time to look over it. Best regards, |
Changed the moveArray method to take into account all the keys of the _embedded object.
Ok I added the Could you please test this and let me know if it worked? Then I will release a new version and close this pull request. Is that ok for you guys? Regards, Guy |
Thanks a lot, Guy! We will test it by tomorrow evening and let you know. Best regards, |
Hi Guy, I have added my feedback on your last commit. There's still a change to be made to Best regards, |
Hi Mihai, you are right I missed that. I just changed it and also added a test for it. So now it should work on your side ;). Can you please verify such that I can do a minor release such that you can use it through bower/npm? Thanks and regards, Guy |
Hi Guy, Thanks again for your quick response. I have verified it and I can confirm that it works perfectly! Best regards, |
Hi Mihai, ok nice to hear that! :) Ok I just released 0.3.2 in bower and npm. https://github.com/guylabs/angular-spring-data-rest/releases/tag/0.3.2 Thanks again for the pull request and the idea to support this. Regards, Guy |
Add support for embedded items of different kinds (not just arrays) and multiplicity (grouping of embedded items so nested embedded items are supported).
This breaks the tests for now - before we fix those, I'm curious about your opinion here.