Files
spring-data-rest/spring-data-rest-core/pom.xml
Oliver Gierke 3969c34940 DATAREST-317 - Support for excerpt projections.
This commit adds a mechanism to define excerpt projections to be rendered for exposed repositories. The main user facing mechanism is the addition of the excerptProjection attribute to @RepositoryRestResource. This attribute takes a type which has to be a projection interface (see DATAREST-221 for more information about the general mechanism).

If such a excerpt projection is in place, it will be used by default when rendering instances of the domain type in _embedded clauses or if it is related to.

class Person {

  String name;
  int age;
  Person father;
  Person mother;
  Set<Person> siblings:
}

interface PersonExcerpt {
  String getName();
}

If PersonExcerpt is now configured as excerpt projection for Person the collection resource for people will return:

{ _embedded : {
    people : [{
      name : "Some name",
      _embedded : {
        mother : { name : "…" },
        father : { name : "…" },
        siblings : [ … ]
      },
      _links : { self : { href : "…" }}
    }, … ]
  }
}

Here you can see how the age property is omitted when rendering a person in a collection. Also each person contains the excerpt projections of related resources and the links to them omitted. If you now follow the link to the item resource, you'll something like this:

{ name : "Some name",
  age : 34,
  _embedded : {
    mother : { name : "…" },
    father : { name : "…" },
    siblings : [ … ]
  },
  _links : {
    self : { href : "…" },
    mother : { href : "…" },
    father : { href : "…" },
    siblings : { href : "…" }
  }
}

Note, that age appears, as the representation is now rendered entirely. We also see the excerpts of related resource but also the links pointing to them in case you want to manage them.
2014-06-12 13:16:12 +02:00

71 lines
1.9 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-data-rest-core</artifactId>
<name>Spring Data REST - Core</name>
<description>Spring Data REST - Core</description>
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-parent</artifactId>
<version>2.2.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<properties>
<spring.hateoas>0.13.0.BUILD-SNAPSHOT</spring.hateoas>
<springplugin>1.1.0.RELEASE</springplugin>
<evoinflector>1.1</evoinflector>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
<version>${spring.hateoas}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>${springdata.commons}</version>
</dependency>
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>${springplugin}</version>
</dependency>
<dependency>
<groupId>org.atteo</groupId>
<artifactId>evo-inflector</artifactId>
<version>${evoinflector}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson}</version>
</dependency>
</dependencies>
</project>