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
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.featurepack.data.jpacontainer.AdvancedFilterable
AdvancedFilterable.FiltersAppliedEvent<C extends Container & AdvancedFilterable>Nested classes/interfaces inherited from interface com.vaadin.featurepack.data.Buffered
Buffered.SourceExceptionNested classes/interfaces inherited from interface com.vaadin.featurepack.data.Container
Container.Editor, Container.Filter, Container.Filterable, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeEvent, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeEvent, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.SimpleFilterable, Container.Sortable, Container.Viewer -
Method Summary
Modifier and TypeMethodDescriptionvoidaddContainerFilter(Object propertyId, String filterString, boolean ignoreCase, boolean onlyMatchPrefix) Adds a new entity to the container.voidaddNestedContainerProperty(String nestedProperty) Adds the nested propertynestedPropertyto the set of properties.createEntityItem(T entity) Creates a newEntityItemforentitywithout adding it to the container.Gets the class of the entities that are/can be contained in this container.Gets the entity provider that is used for fetching and storing entities.Gets theItemwith the given Item ID from the Container.getPropertyKind(Object propertyId) Gets the QueryModifierDelegate set for this container.booleanAlias of.invalid reference
Buffered#isWriteThrough()booleanReturns whether the container is read only or writable.voidrefresh()Refreshes the entire container from the database.voidrefreshItem(Object itemId) Causes all EntityItems created from this container and identified by given entityId to be refreshed.voidremoveContainerFilters(Object propertyId) voidsetAutoCommit(boolean autoCommit) Alias of.invalid reference
Buffered#setWriteThrough(boolean)voidsetEntityProvider(EntityProvider<T> entityProvider) Sets the entity provider to use for fetching and storing entities.voidsetReadOnly(boolean readOnly) Changes the read only state of the container, if possible.Methods inherited from interface com.vaadin.featurepack.data.jpacontainer.AdvancedFilterable
applyFilters, getAppliedFilters, getFilterablePropertyIds, getFilters, hasUnappliedFilters, isApplyFiltersImmediately, isFilterable, setApplyFiltersImmediatelyMethods inherited from interface com.vaadin.featurepack.data.Buffered
commit, discard, isBuffered, isModified, setBufferedMethods inherited from interface com.vaadin.featurepack.data.Container
addContainerProperty, addItem, addItem, containsId, getContainerProperty, getContainerPropertyIds, getItemIds, getType, removeAllItems, removeContainerProperty, removeItem, sizeMethods inherited from interface com.vaadin.featurepack.data.Container.Filterable
addContainerFilter, getContainerFilters, removeAllContainerFilters, removeContainerFilterMethods inherited from interface com.vaadin.featurepack.data.Container.ItemSetChangeNotifier
addItemSetChangeListener, removeItemSetChangeListenerMethods inherited from interface com.vaadin.featurepack.data.Container.Ordered
addItemAfter, addItemAfter, firstItemId, isFirstId, isLastId, lastItemId, nextItemId, prevItemIdMethods inherited from interface com.vaadin.featurepack.data.Container.Sortable
getSortableContainerPropertyIds, sort
-
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
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
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 propertynestedPropertyto 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
addressand that this property's type in turn has the propertiesstreet,postalCodeandcity.If we want to be able to access the street property directly, we can add the nested property
address.streetusing this method.However, if we want to add all the address properties, we can also use
address.*. This will cause the nested propertiesaddress.street,address.postalCodeandaddress.cityto 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.*.somethingis 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- ifnestedPropertyis illegal.
-
addEntity
Adds a new entity to the container. The correspondingEntityItemcan then be accessed by callinggetItem(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 usingBuffered.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
Creates a newEntityItemforentitywithout adding it to the container. This makes it possible to use the samefor editing both new entities and existing entities.invalid reference
com.vaadin.ui.FormTo 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
Gets theItemwith the given Item ID from the Container. If the Container does not contain the requested Item,nullis returned.Containers should not return Items that are filtered out.
-
isReadOnly
boolean isReadOnly()Returns whether the container is read only or writable.- Returns:
- true if read only, false if writable.
-
setReadOnly
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) -
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
for the specified parameters and applies the filter immediately, regardless of the state ofinvalid reference
StringComparisonFilterAdvancedFilterable.isApplyFiltersImmediately().- See Also:
-
removeContainerFilters
The container is updated immediately regardless of the state of
AdvancedFilterable.isApplyFiltersImmediately(). -
getPropertyKind
- Parameters:
propertyId-- Returns:
- the type of property indentified by given propertyId
-
refreshItem
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
-