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

Customize MovideEntity Links #23

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

rehab-reda0
Copy link

Expecting the output of the links object in the jsonapi response inside each movie item to be:
links : {self:" ...",rates:" ... ",comments:"..."}
but unfortunately it is not working as expected!

Expecting the output of the links object in the jsonapi response inside each movie item to be:
links : {self:" ...",rates:" ... ",comments:"..."}
but unfortunately it is not working as expected!

public String getRates() {

return "https://www.imdb.com/" + getId() + "/rates";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If would do something like:

public String getRates(){
  if(rates == null){
    return "https://www....";
  }
  return rates
  }
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this way you have the built-in default, but will also support the setters, e.g. as used by crnk-client.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@remmeier please check the updates I added the self link also but is there a way so the self link can return the base path also beside the endpoint like before customizing the links
before customizing links
it will return "localhost:8080/movie/{id}"
now I overrided it to return /movie/{id}

1- Added the self link.
2-removed the static type from the movielinks class
@@ -57,5 +60,55 @@

@Version
private Integer version;

//This is an example on links customization.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use /**... */ for the comment to facilitate multi line comments

@JsonApiLinksInformation
private MovieLinks links = new MovieLinks();

public class MovieLinks implements LinksInformation//,SelfLinksInformation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implements SelfLinksInformation would seems right.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lombok @DaTa would allow you to get rid of the setters

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done if u have any more comments please specify it : ) Thanks!

Add @DaTa annotation on the MovieLinks class
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.

2 participants