com.vaadin.addon.jpacontainer
Interface EntityContainer<T>

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

public interface EntityContainer<T>
extends com.vaadin.data.Container, com.vaadin.data.Container.Sortable, AdvancedFilterable, com.vaadin.data.Container.ItemSetChangeNotifier, com.vaadin.data.Buffered, com.vaadin.data.Container.Filterable

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)

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.vaadin.data.Container
com.vaadin.data.Container.Editor, com.vaadin.data.Container.Filter, com.vaadin.data.Container.Filterable, com.vaadin.data.Container.Hierarchical, com.vaadin.data.Container.Indexed, com.vaadin.data.Container.ItemSetChangeEvent, com.vaadin.data.Container.ItemSetChangeListener, com.vaadin.data.Container.ItemSetChangeNotifier, com.vaadin.data.Container.Ordered, com.vaadin.data.Container.PropertySetChangeEvent, com.vaadin.data.Container.PropertySetChangeListener, com.vaadin.data.Container.PropertySetChangeNotifier, com.vaadin.data.Container.SimpleFilterable, com.vaadin.data.Container.Sortable, com.vaadin.data.Container.Viewer
 
Nested classes/interfaces inherited from interface com.vaadin.addon.jpacontainer.AdvancedFilterable
AdvancedFilterable.FiltersAppliedEvent<C extends com.vaadin.data.Container & AdvancedFilterable>
 
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered
com.vaadin.data.Buffered.SourceException
 
Method Summary
 void addContainerFilter(Object propertyId, String filterString, boolean ignoreCase, boolean onlyMatchPrefix)
          
 Object addEntity(T entity)
          Adds a new entity to the container.
 void addNestedContainerProperty(String nestedProperty)
          Adds the nested property nestedProperty to the set of properties.
 EntityItem<T> createEntityItem(T entity)
          Creates a new EntityItem for entity without adding it to the container.
 Class<T> getEntityClass()
          Gets the class of the entities that are/can be contained in this container.
 EntityProvider<T> getEntityProvider()
          Gets the entity provider that is used for fetching and storing entities.
 EntityItem<T> getItem(Object itemId)
          
 PropertyKind getPropertyKind(Object propertyId)
           
 QueryModifierDelegate getQueryModifierDelegate()
          Gets the QueryModifierDelegate set for this container.
 boolean isAutoCommit()
          Alias of Buffered#isWriteThrough() .
 boolean isReadOnly()
          Returns whether the container is read only or writable.
 void refresh()
          Refreshes the entire container from the database.
 void refreshItem(Object itemId)
          Causes all EntityItems created from this container and identified by given entityId to be refreshed.
 void removeContainerFilters(Object propertyId)
          
 void setAutoCommit(boolean autoCommit)
          Alias of Buffered#setWriteThrough(boolean) .
 void setEntityProvider(EntityProvider<T> entityProvider)
          Sets the entity provider to use for fetching and storing entities.
 void setReadOnly(boolean readOnly)
          Changes the read only state of the container, if possible.
 
Methods inherited from interface com.vaadin.data.Container.Sortable
getSortableContainerPropertyIds, sort
 
Methods inherited from interface com.vaadin.data.Container.Ordered
addItemAfter, addItemAfter, firstItemId, isFirstId, isLastId, lastItemId, nextItemId, prevItemId
 
Methods inherited from interface com.vaadin.data.Container
addContainerProperty, addItem, addItem, containsId, getContainerProperty, getContainerPropertyIds, getItemIds, getType, removeAllItems, removeContainerProperty, removeItem, size
 
Methods inherited from interface com.vaadin.addon.jpacontainer.AdvancedFilterable
applyFilters, getAppliedFilters, getFilterablePropertyIds, getFilters, hasUnappliedFilters, isApplyFiltersImmediately, isFilterable, setApplyFiltersImmediately
 
Methods inherited from interface com.vaadin.data.Container.ItemSetChangeNotifier
addItemSetChangeListener, addListener, removeItemSetChangeListener, removeListener
 
Methods inherited from interface com.vaadin.data.Buffered
commit, discard, isBuffered, isModified, setBuffered
 
Methods inherited from interface com.vaadin.data.Container.Filterable
addContainerFilter, getContainerFilters, removeAllContainerFilters, removeContainerFilter
 

Method Detail

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

Object addEntity(T entity)
                 throws UnsupportedOperationException,
                        IllegalStateException
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 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:
EntityItem.getItemId()

getItem

EntityItem<T> getItem(Object itemId)

Specified by:
getItem in interface com.vaadin.data.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 com.vaadin.data.Buffered.SourceException,
                          com.vaadin.data.Validator.InvalidValueException
Alias of Buffered#setWriteThrough(boolean) .

Throws:
com.vaadin.data.Buffered.SourceException
com.vaadin.data.Validator.InvalidValueException

isAutoCommit

boolean isAutoCommit()
Alias of Buffered#isWriteThrough() .


addContainerFilter

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

This method creates a new StringComparisonFilter for the specified parameters and applies the filter immediately, regardless of the state of AdvancedFilterable.isApplyFiltersImmediately().

See Also:
AdvancedFilterable.applyFilters()

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:
EntityItem.refresh()

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


Copyright © 2013 Vaadin Ltd. All rights reserved.