com.holonplatform.vaadin7.data

## Interface ItemDataSource<ITEM,PROPERTY>

- Type Parameters:
    `ITEM` - Item type
    `PROPERTY` - Item property type
  All Superinterfaces:
    Serializable
  All Known Subinterfaces:
    ItemDataSourceContainer<ITEM,PROPERTY>

      public interface ItemDataSource<ITEM,PROPERTY>
      extends Serializable

  Represents an item set data source, providing operations to retrieve items by id and change the item set composition adding a removing items.

  Items values are accessed using a defined set of properties.

  Item set modifications can be persisted in a backend data store using a `ItemDataSource.CommitHandler`, triggered through the `commit()` method.

  Since:
    5.0.0
  See Also:
    `ItemDataProvider`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `ItemDataSource.CommitHandler<ITEM>` Data source commit handler to perform concrete persistence operations when data is committed invoking `commit()`.
    `static interface` | `ItemDataSource.Configuration<PROPERTY>`
    `static class` | `ItemDataSource.ItemAction` Item actions enumeration.
    `static interface` | `ItemDataSource.ItemSort<PROPERTY>` An item sort directive.
    `static interface` | `ItemDataSource.PropertySortGenerator<PROPERTY>` `QuerySort` generator to provide query sorts for an item property.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `Object` | `add(ITEM item)` Adds an item to the data source.
    `void` | `clear()` Clear data source contents (current item set)
    `void` | `commit()` Updates all changes since the previous commit.
    `void` | `discard()` Discards all changes since last commit.
    `Optional<ITEM>` | `get(Object itemId)` Get the item identified by given `itemId`.
    `ItemDataSource.Configuration<PROPERTY>` | `getConfiguration()` Get the data source configuration.
    `Object` | `getId(ITEM item)` Get the identifier of given item
    `Collection<?>` | `getItemIds()` Get all item ids available from this data source
    `boolean` | `isBuffered()` Get whether the data source is in buffered mode.
    `void` | `refresh()` Refresh data source items.
    `void` | `refresh(ITEM item)` Refresh given item in data source
    `boolean` | `remove(ITEM item)` Removes given item from the data source.
    `int` | `size()` Returns current data source size (considering any applied filter), i.e. the total number of available items.
    `void` | `sort(ItemDataSource.ItemSort<PROPERTY>... sorts)` Sort the data source items using given `ItemDataSource.ItemSort` directives.
    `void` | `update(ITEM item)` Update given item in data source.

- - ### Method Detail

    - #### getConfiguration

          ItemDataSource.Configuration<PROPERTY> getConfiguration()

      Get the data source configuration.
      Returns:
        Data source configuration (never null)

    - #### refresh

          void refresh()

      Refresh data source items.
      Throws:
        `com.holonplatform.core.exceptions.DataAccessException` - Error performing concrete items loading operations

    - #### clear

          void clear()

      Clear data source contents (current item set)

    - #### size

          int size()

      Returns current data source size (considering any applied filter), i.e. the total number of available items.
      Returns:
        the total number of available items in data source

    - #### getItemIds

          Collection<?> getItemIds()

      Get all item ids available from this data source
      Returns:
        Item ids, empty if none

    - #### getId

          Object getId(ITEM item)

      Get the identifier of given item
      Parameters:
        `item` - Item to get the identifier for
      Returns:
        Item identifier

    - #### get

          Optional<ITEM> get(Object itemId)

      Get the item identified by given `itemId`.
      Parameters:
        `itemId` - Item id (not null)
      Returns:
        Optional item identified by given `itemId`, empty if not found

    - #### add

          Object add(ITEM item)

      Adds an item to the data source.
      Parameters:
        `item` - The item to add (not null)
      Returns:
        Id of the added item

    - #### update

          void update(ITEM item)

      Update given item in data source.
      Parameters:
        `item` - Item to update (not null)

    - #### remove

          boolean remove(ITEM item)

      Removes given item from the data source.
      Parameters:
        `item` - Item to remove (not null)
      Returns:
        `true` if the item was successfully removed from data source

    - #### refresh

          void refresh(ITEM item)

      Refresh given item in data source
      Parameters:
        `item` - Item to refresh (not null)
      Throws:
        `UnsupportedOperationException` - If the refresh operation is not supported by concrete data store

    - #### commit

          void commit()

      Updates all changes since the previous commit.

    - #### discard

          void discard()

      Discards all changes since last commit.

    - #### isBuffered

          boolean isBuffered()

      Get whether the data source is in buffered mode.
      Returns:
        whether the data source is in buffered mode

    - #### sort

          void sort(ItemDataSource.ItemSort<PROPERTY>... sorts)

      Sort the data source items using given `ItemDataSource.ItemSort` directives.
      Parameters:
        `sorts` - Item sorts to apply

Copyright © 2019 The Holon Platform. All rights reserved.