Skip to content
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

Support for HATEOAS-Links in Json-Views #359

Closed
wants to merge 28 commits into from

Conversation

tinne
Copy link

@tinne tinne commented Jun 14, 2015

The @JSONVIEW annotation supports filtering class trees in order to provide custom views on specific partial data, cf. eg. https://spring.io/blog/2014/12/02/latest-jackson-integration-improvements-in-spring

The main purpose of this patch is to provide a means of views including the links properties of REST models using ResourceSupport. Usage: extend Link.LinkView to denote your view properties.

Also contributes bundlor support for eclipse m2e environment: tell eclipse to run bundlor:bundlor even on incremental builds.

Karsten Tinnefeld added 5 commits June 13, 2015 00:08
…iding a tooling interface.

Signed-off-by: Karsten Tinnefeld <k.tinnefeld@googlemail.com>
Signed-off-by: Karsten Tinnefeld <k.tinnefeld@googlemail.com>
… by providing a tooling interface."

This reverts commit 0fdf663.
when filtered by providing a tooling interface, now complete.

Signed-off-by: Karsten Tinnefeld <k.tinnefeld@googlemail.com>
Signed-off-by: Karsten Tinnefeld <k.tinnefeld@googlemail.com>
Karsten Tinnefeld added 3 commits June 17, 2015 23:45
Signed-off-by: Karsten Tinnefeld <k.tinnefeld@googlemail.com>
Signed-off-by: Karsten Tinnefeld <k.tinnefeld@googlemail.com>
@gBarrerasSanz
Copy link

Hi,
I'm interested in including this feature in my gradle project. For now, the latest version I could get is http://mvnrepository.com/artifact/org.springframework.hateoas/spring-hateoas/0.17.0.RELEASE. How could add this github project to my gradle script?
Thank you!

@gregturn
Copy link
Contributor

gregturn commented Jul 4, 2015

Use 0.18.0.Build-snapshot from repo.spring.io/lib-snapshot.

Sent from my iPhone

On Jul 4, 2015, at 9:45 AM, gBarrerasSanz notifications@github.com wrote:

Hi,
I'm interested in including this feature in my gradle project. For now, the latest version I could get is http://mvnrepository.com/artifact/org.springframework.hateoas/spring-hateoas/0.17.0.RELEASE. How could add this github project to my gradle script?
Thank you!


Reply to this email directly or view it on GitHub.

@gBarrerasSanz
Copy link

Sorry for the inconvenience, but I've just tried the build from either http://repo.gradle.org/gradle/repo/org/springframework/hateoas/spring-hateoas/0.18.0.BUILD-SNAPSHOT/ and https://repo.spring.io/libs-snapshot/org/springframework/hateoas/spring-hateoas/0.18.0.BUILD-SNAPSHOT/. None of those builds contain nor ResourcesLinksVisible or Link.LinkView class interfaces. As far as I could understand, my View classes must extend one of those interfaces (don't know which of them exactly, though).
Thank you!

@tinne
Copy link
Author

tinne commented Jul 5, 2015

@gBarrerasSanz This pull request has not yet been merged into the main project, please build from source by cloning https://github.com/tinne/spring-hateoas.git in the meantime.

@gBarrerasSanz
Copy link

@gregturn @tinne Thank you guys for your attention. I did make it work.

@sergiorc
Copy link

Hi all
Does anybody know when this pull request is going to be merged?
Thanks a lot

odrotbohm and others added 11 commits August 4, 2015 10:48
Spring Framework 4.0.9 -> 4.1.7
Minidev JSON 2.1.1 -> 2.2
JSONPath 0.9.1 -> 2.0.0
Spring Data Build Resources 1.6.0 -> 1.6.2
Lombok 1.14.4 -> 1.16.4
JUnit 4.11 -> 4.12
Mockito 1.9.5 -> 1.10.19
JodaTime 2.3 -> 2.8.1
XMLUnit 1.5 -> 1.6

Asciidoctor Maven Plugin 1.5.2 -> 1.5.2.1
AsciidoctorJ PDF 1.5.0-alpha.6 -> 1.5.0-alpha.8
Maven Assembly Plugin 2.5.4 -> 2.5.5

Updated available build profiles. Update Javadoc reference to link to used Spring Framework version.
…rializer on Jackson 2.6.

Added missing override for isEmpty(…) that gets used by Jackson 2.6+ to prevent { templated : false } get rendered in HAL link representations.

Polished Javadoc on the way.
…figure multiple curies.

DefaultCurieProvider now also takes a Map<String, UriTemplate> to expose multiple curies. The default curie to be used to expand unprefixed, non-IANA link relations has to be defined explicitly in case more than one curie is if given. If there's only one, that becomes the default, too.
The curie rendering has been improved in the following ways:

- Resources now get their embeds inspected for namespaced keys and curies are added if at least one is found. This makes sure curies are also rendered if no namespaced link is registered.
- Nested resources skip curies entirely, assuming they have been added to the root correctly.

Had to change the order of _embedded and _links to make sure the embedded elements are processed first to tweak the links to indicate the need for curies.
…d through a resource bundle.

HalLinkListSerializer now tries to obtain a link title by looking up key _links.$rel.title for both the namespaced (curied) and local link relation if the former doesn't resolve into a message.
This commit updates Spring HATEOAS' optional dependency on the JAX-RS API to use the latest version (which uses a different artifact ID). This change will make things a little easier for the Spring IO Platform which currently provides dependency management for Jersey 2.x (which uses JAX-RS 2.0), by allowing it to stop providing dependency management for the JAX-RS 1.0 API.
@odrotbohm
Copy link
Member

Any chance you add a few test cases to express the purpose of the changes and prevent regressions? Also, please remove all changes not related to this ticket, i.e. the cahnge in pom.xml and the removal of the warning suppression.

spring-builds and others added 6 commits September 1, 2015 00:10
We now avoid calling URI.toString() to early to prevent the need to re-parse it and thus accidentally cause a double-encoding.

Original pull request: spring-projects#382.
Re-introduced the simple isEmpty(…) methods in custom Jackson serializers as the more complex ones were introduced in Jackson 2.5 only. Removed the @OverRide annotations so that we could even compile against 2.4 if needed.
@tinne
Copy link
Author

tinne commented Sep 6, 2015

I did not post my test project and an still digging through your test code, so you will get your tests some day later.

Extracting removal of the warning expression was most easy so you got this as a separate pull request first.

Let me first start with the semantics (notation borrowed from jasmine):

  • describe("test set", {
    • describe("Resource View Tests", {
      • it("ignores links when rendering them to JSON, as before", assertEquals(objectMapper.writeValueAsString(someBean), objectMapper.writeValueAsString(createResourceWithLinks(someBean)))),
      • it("writes out links when rendered to JSON on annotating with @JSONVIEW(ResourceLinkView.class)", assertEquals(objectMapper.writeValueAsString(subclassAndAddLinksByHand(someBean),
        objectMapper.writeValueAsString(createResourceWithLinks(someBean)))),
    • it("writes out links when rendered to JSON and filters bean itself", assertEquals(objectMapper.writeValueAsString(subclassAndAddLinksByHand(otherBeanWithJsonViewPropertiesAnnotatedWithInterfaceExtendingResouceWithLinks), objectMapper.writeValueAsString(createResourceWithLinks((otherBeanWithJsonViewPropertiesAnnotatedWithInterfaceExtendingResouceWithLinks)))) },
    • describe("Resources View Tests", { /** same for collections **/ },
    • describe("Resource(s)Support View Tests, { /** dito **/ }}}}

@DharaSingh
Copy link

Hi olivergierke,
I am using 0.19.0.RELEASE for hateoas but still did not find any view which can help me to include links into my model object.

And in general most of the models have id and method implemented getId(), and ResourceSupport has method getId to get link. is there any other way to use it except changing the method name in model class ?

@ianaz
Copy link

ianaz commented Aug 31, 2016

Same issues as @DharaSingh

  • Apparently Link.LinkView hasn't been merged yet. Would love to have it
  • getId() is really inconvenient

Using 0.20.0.RELEASE

@tinne
Copy link
Author

tinne commented Aug 31, 2016

Thank you for the discussion. Kindly move it (and your support) to #387.

@ajitkumargiri
Copy link

Thanks @tinne and @odrotbohm ,
I am using The @JSONVIEW annotation for filtering the response. But It is blocking RepresentationModel _link json attribute.
I am using Spring HateOAS 1.0.1.RELEASE and Spring boot 2.2.1.RELEASE .
Any help how to implement @JSONVIEW in hateoas RepresentationModel .
Is current spring boot support hateoas with @JSONVIEW.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.