Uploaded image for project: 'Spring Data REST'
  1. Spring Data REST
  2. DATAREST-317

Add support for excerpt projections

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.2 M1 (Evans)
    • Component/s: None
    • Labels:
      None
    • Sprint:
      48 - Dijkstra GA

      Description

      When representations are rendered in HAL, we currently render the complete entity in the _embedded clause for collection resources. If an item resource is accessed, we currently don't render an _embedded clause. This ticket suggests to allow to customize this behavior as follows.

      • the user has means to identify a projection interface (see DATAREST-221 for the general mechanism) as an excerpt projection
      • for collection resources the excerpt will automatically rendered in _embedded clauses if an excerpt projection is in place
      • for related resources, the excerpt projection will be rendered. If the value is rendered within an _embedded clause itself, the links to the related resource shall be omitted.

      Example

      class Author {
          public String name;
          public Set<Book> books;
      }
      
      class Book {
          public String title;
          public Set<Author> authors;
      }
      
      interface BooksExcerpt {
          String getTitle();
      }
      

      authors collection resource - full rendering of items but related resource's excerpt rendered embedded.

      { _embedded : {
          authors : [{
            name : "Oliver Gierke",
            _embedded : {
              books : [{
                title : "Spring Data"
              }]
            },
            _links : {
              self : { href : "…" }
            }
          }]
        }
      }
      

      author item resource - full rendering of item, related resource's excerpt rendered embedded, link to related resource present

      { name : "Oliver Gierke",
        _embedded : {
          books : [{
            title : "Spring Data"
          }]
        },
        _links : {
          self : { href : "…" },
          books : { href : "…" }
        }
      }
      

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            olivergierke Oliver Drotbohm
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: