예제 #1
0
  @Override
  public Resource<Property> toResource(Property term) {
    Resource<Property> resource = new Resource<Property>(term);
    try {
      String id = UriUtils.encode(term.getIri(), "UTF-8");
      final ControllerLinkBuilder lb =
          ControllerLinkBuilder.linkTo(
              ControllerLinkBuilder.methodOn(OntologyPropertyController.class)
                  .getProperty(term.getOntologyName(), id));

      resource.add(lb.withSelfRel());

      if (!term.isRoot()) {
        resource.add(lb.slash("parents").withRel("parents"));
        resource.add(lb.slash("ancestors").withRel("ancestors"));
        resource.add(lb.slash("jstree").withRel("jstree"));
      }

      if (term.hasChildren()) {
        resource.add(lb.slash("children").withRel("children"));
        resource.add(lb.slash("descendants").withRel("descendants"));
      }

      // other links
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }

    return resource;
  }
 @RequestMapping(value = "/{id}", method = RequestMethod.GET)
 HttpEntity<Resource<Profile>> showCustomer(@PathVariable Long id) {
   Resource<Profile> resource = new Resource<Profile>(this.repository.findOne(id));
   resource.add(this.entityLinks.linkToSingleResource(Profile.class, id));
   return new ResponseEntity<Resource<Profile>>(resource, HttpStatus.OK);
 }