Interface EntityContainer<T>

All Superinterfaces:
AdvancedFilterable, Buffered, Container, Container.Filterable, Container.ItemSetChangeNotifier, Container.Ordered, Container.Sortable, Serializable
All Known Subinterfaces:
HierarchicalEntityContainer<T>
All Known Implementing Classes:
JPAContainer

A Container for EntityItems. The data is provided by a EntityProvider. Supports sorting, advanced filtering, nested properties and buffering.
Since:
1.0
Author:
Petter Holmström (Vaadin Ltd)
  • Method Details

    • getEntityProvider

      EntityProvider<T> getEntityProvider()
      Gets the entity provider that is used for fetching and storing entities.
      Returns:
      the entity provider, or null if this container has not yet been properly initialized.
    • setEntityProvider

      void setEntityProvider(EntityProvider<T> entityProvider)
      Sets the entity provider to use for fetching and storing entities. The EntityProvider can be changed once set, if necessary.
      Parameters:
      entityProvider - the entity provider to use (must not be null).
    • getEntityClass

      Class<T> getEntityClass()
      Gets the class of the entities that are/can be contained in this container.
      Returns:
      the entity class.
    • addNestedContainerProperty

      void addNestedContainerProperty(String nestedProperty) throws UnsupportedOperationException, IllegalArgumentException
      Adds the nested property nestedProperty to the set of properties. An asterisk can be used as a wildcard to indicate all leaf-properties.

      For example, let's say there is a property named address and that this property's type in turn has the properties street, postalCode and city.

      If we want to be able to access the street property directly, we can add the nested property address.street using this method.

      However, if we want to add all the address properties, we can also use address.*. This will cause the nested properties address.street, address.postalCode and address.city to be added to the set of properties.

      Note, that the wildcard cannot be used in the middle of a chain of property names. E.g. myprop.*.something is illegal.

      Nested properties may be transient, but only persistent nested properties (i.e. embedded properties or ManyToOne references) may be used for filtering or sorting.

      Parameters:
      nestedProperty - the nested property to add (must not be null).
      Throws:
      UnsupportedOperationException - if nested properties are not supported by the container.
      IllegalArgumentException - if nestedProperty is illegal.
    • addEntity

      Adds a new entity to the container. The corresponding EntityItem can then be accessed by calling getItem(java.lang.Object) using the entity identifier returned by this method.

      If isAutoCommit() is activated, the returned identifier is always the actual entity ID. Otherwise, the returned identifier may, depending on the ID generation strategy, be either the actual entity ID or a temporary ID that is changed to the real ID once the changes have been committed using Buffered.commit().

      Parameters:
      entity - the entity to add (must not be null).
      Returns:
      the identifier of the entity (never null).
      Throws:
      UnsupportedOperationException - if the container does not support adding new entities at all.
      IllegalStateException - if the container supports adding entities, but is currently in read only mode.
    • createEntityItem

      EntityItem<T> createEntityItem(T entity)
      Creates a new EntityItem for entity without adding it to the container. This makes it possible to use the same
      invalid reference
      com.vaadin.ui.Form
      for editing both new entities and existing entities.

      To add the entity to the container, addEntity(java.lang.Object) should be used.

      Parameters:
      entity - the entity for which an item should be created.
      Returns:
      the entity item (never null).
      See Also:
    • getItem

      EntityItem<T> getItem(Object itemId)
      Gets the Item with the given Item ID from the Container. If the Container does not contain the requested Item, null is returned.

      Containers should not return Items that are filtered out.

      Specified by:
      getItem in interface Container
      Parameters:
      itemId - ID of the Item to retrieve
      Returns:
      the Item with the given ID or null if the Item is not found in the Container
    • isReadOnly

      boolean isReadOnly()
      Returns whether the container is read only or writable.
      Returns:
      true if read only, false if writable.
    • setReadOnly

      void setReadOnly(boolean readOnly) throws UnsupportedOperationException
      Changes the read only state of the container, if possible.
      Parameters:
      readOnly - true to make the container read only, false to make it writable.
      Throws:
      UnsupportedOperationException - if the read only state cannot be changed.
    • setAutoCommit

      void setAutoCommit(boolean autoCommit) throws Buffered.SourceException, Validator.InvalidValueException
      Alias of
      invalid reference
      Buffered#setWriteThrough(boolean)
      .
      Throws:
      Buffered.SourceException
      Validator.InvalidValueException
    • isAutoCommit

      boolean isAutoCommit()
      Alias of
      invalid reference
      Buffered#isWriteThrough()
      .
    • addContainerFilter

      void addContainerFilter(Object propertyId, String filterString, boolean ignoreCase, boolean onlyMatchPrefix)

      This method creates a new

      invalid reference
      StringComparisonFilter
      for the specified parameters and applies the filter immediately, regardless of the state of AdvancedFilterable.isApplyFiltersImmediately().
      See Also:
    • removeContainerFilters

      void removeContainerFilters(Object propertyId)

      The container is updated immediately regardless of the state of AdvancedFilterable.isApplyFiltersImmediately().

    • getPropertyKind

      PropertyKind getPropertyKind(Object propertyId)
      Parameters:
      propertyId -
      Returns:
      the type of property indentified by given propertyId
    • refreshItem

      void refreshItem(Object itemId)
      Causes all EntityItems created from this container and identified by given entityId to be refreshed.
      Parameters:
      itemId -
      See Also:
    • refresh

      void refresh()
      Refreshes the entire container from the database. All unsaved data will be lost.
    • getQueryModifierDelegate

      QueryModifierDelegate getQueryModifierDelegate()
      Gets the QueryModifierDelegate set for this container. EntityProviders will the delegate returned by this method in their queries.
      Returns:
      QueryModifierDelegate to control queries built by this container