com.holonplatform.vaadin.data

## Interface ItemDataSource<ITEM,PROPERTY>

- Type Parameters:
    `ITEM` - Item type
    `PROPERTY` - Item property type
  All Superinterfaces:
    Serializable

      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.Builder<ITEM,PROPERTY>` Builder to create `ItemDataSource` instances.
    `static interface` | `ItemDataSource.CommitHandler<ITEM>` Data source commit handler to perform concrete persistence operations when data is committed invoking `commit()`.
    `static interface` | `ItemDataSource.Configuration<ITEM,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.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_BATCH_SIZE` Default batch (page) size for items loading using `ItemDataProvider`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `Object` | `add(ITEM item)` Adds an item to the data source.
    `static <ITEM,PROPERTY> ItemDataSource.Builder<ITEM,PROPERTY>` | `builder()` Get a builder to create an `ItemDataSource`.
    `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<ITEM,PROPERTY>` | `getConfiguration()` Get the data source configuration.
    `Object` | `getId(ITEM item)` Get the identifier of given item
    `ITEM` | `getItemAt(int index)` Get the item at given index.
    `Collection<?>` | `getItemIds()` Get all item ids available from this data source
    `int` | `indexOfItem(ITEM item)` Get index of given item
    `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.
    `void` | `setDataProviderQuery(com.vaadin.data.provider.Query<ITEM,com.holonplatform.core.query.QueryFilter> dataProviderQuery)` Set the data provider `Query` to use to obtain filters and sorts.
    `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.

- - ### Field Detail

    - #### DEFAULT_BATCH_SIZE

          static final int DEFAULT_BATCH_SIZE

      Default batch (page) size for items loading using `ItemDataProvider`
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getConfiguration

          ItemDataSource.Configuration<ITEM,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

    - #### indexOfItem

          int indexOfItem(ITEM item)

      Get index of given item
      Parameters:
        `item` - Item
      Returns:
        Item index, or `-1` if not found

    - #### getItemAt

          ITEM getItemAt(int index)

      Get the item at given index.
      Parameters:
        `index` - Item index
      Returns:
        The itemat given index, or `null` if not available

    - #### 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.

    - #### sort

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

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

    - #### setDataProviderQuery

          void setDataProviderQuery(com.vaadin.data.provider.Query<ITEM,com.holonplatform.core.query.QueryFilter> dataProviderQuery)

      Set the data provider `Query` to use to obtain filters and sorts.
      Parameters:
        `dataProviderQuery` - the query to set

    - #### builder

          static <ITEM,PROPERTY> ItemDataSource.Builder<ITEM,PROPERTY> builder()

      Get a builder to create an `ItemDataSource`.
      Type Parameters:
        `ITEM` - Item type
        `PROPERTY` - Item property type
      Returns:
        `ItemDataSource` builder

Copyright © 2017 The Holon Platform. All rights reserved.