Class NoopDataContext
- All Implemented Interfaces:
- DataContext
DataContext used for read-only views like entity list views.- 
Nested Class SummaryNested classes/interfaces inherited from interface io.jmix.flowui.model.DataContextDataContext.ChangeEvent, DataContext.PostSaveEvent, DataContext.PreSaveEvent
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContext
- 
Constructor SummaryConstructorsConstructorDescriptionNoopDataContext(org.springframework.context.ApplicationContext applicationContext) 
- 
Method SummaryModifier and TypeMethodDescriptionaddChangeListener(Consumer<DataContext.ChangeEvent> listener) Adds a listener toDataContext.ChangeEvent.addPostSaveListener(Consumer<DataContext.PostSaveEvent> listener) Adds a listener toDataContext.PostSaveEvent.addPreSaveListener(Consumer<DataContext.PreSaveEvent> listener) Adds a listener toDataContext.PreSaveEvent.voidclear()Evicts all tracked entities.booleanReturns true if the context contains the given entity (distinguished by its class and id).<T> TCreates an entity instance and merges it into the context.voidRemoves the entity from the context so the context stops tracking it.voidClears the lists of created/modified/deleted entities and evicts these entities.<T> TReturns an entity instance by its class and id.<T> Tfind(T entity) Returns the instance of entity with the same id if it exists in this context.Returns an immutable set of entities registered as modified.Returns a parent context, if any.Returns an immutable set of entities registered for removal.Returns a function which will be used to save data instead of standard implementation.booleanReturns true if the context has detected changes in the tracked entities.booleanisModified(Object entity) Returns true if the context has detected changes in the given entity.booleanReturns true if the context has registered removal of the given entity.merge(Collection entities) Merge the given entities into the context.merge(Collection entities, MergeOptions options) Merge the given entities into the context.<T> Tmerge(T entity) Same asDataContext.merge(Object, MergeOptions)with default options.<T> Tmerge(T entity, MergeOptions options) Merge the given entity into the context.voidRemoves the entity from the context and registers it as deleted.save()Saves changed and removed instances using DataManager or a custom save delegate.save(boolean reloadSaved) Saves changed and removed instances using DataManager, custom save delegate or merges them to parent data context if it is set.voidsetModified(Object entity, boolean modified) Registers or unregisters the given entity as modified.voidsetParent(DataContext parentContext) Sets the parent context.voidsetSaveDelegate(Function<SaveContext, Set<Object>> delegate) Sets a function which will be used to save data instead of standard implementation.
- 
Field Details- 
applicationContextprotected org.springframework.context.ApplicationContext applicationContext
 
- 
- 
Constructor Details- 
NoopDataContextpublic NoopDataContext(org.springframework.context.ApplicationContext applicationContext) 
 
- 
- 
Method Details- 
findDescription copied from interface:DataContextReturns an entity instance by its class and id.- Specified by:
- findin interface- DataContext
- Returns:
- entity instance or null if there is no such entity in the context
 
- 
findpublic <T> T find(T entity) Description copied from interface:DataContextReturns the instance of entity with the same id if it exists in this context.- Specified by:
- findin interface- DataContext
- Returns:
- entity instance or null if there is no such entity in the context
 
- 
containsDescription copied from interface:DataContextReturns true if the context contains the given entity (distinguished by its class and id).- Specified by:
- containsin interface- DataContext
 
- 
mergeDescription copied from interface:DataContextMerge the given entity into the context. The whole object graph with all references will be merged.If an entity with the same identifier already exists in the context, the passed entity state is copied into it and the existing instance is returned. Otherwise, a copy of the passed instance is registered in the context and returned. If the given instance is new and the context doesn't contain an instance with the same identifier, the context will save the new instance on DataContext.save(). Otherwise, even if some attributes of the merged instance are changed as a result of copying the state of the passed instance, the merged instance will not be saved. Such modifications are considered as a result of loading more fresh state from the database.WARNING: use the returned value because it is always a different object instance. The only case when you get the same instance is if the input was previously returned from the same context as a result of DataContext.find(Class, Object)ormerge().- Specified by:
- mergein interface- DataContext
- Parameters:
- entity- instance to merge
- options- merge options
- Returns:
- the instance which is tracked by the context
 
- 
mergepublic <T> T merge(T entity) Description copied from interface:DataContextSame asDataContext.merge(Object, MergeOptions)with default options.- Specified by:
- mergein interface- DataContext
 
- 
mergeDescription copied from interface:DataContextMerge the given entities into the context. The whole object graph for each element of the collection with all references will be merged.Same as DataContext.merge(Object)but for a collection of instances.- Specified by:
- mergein interface- DataContext
- Returns:
- set of instances tracked by the context
 
- 
mergeDescription copied from interface:DataContextMerge the given entities into the context. The whole object graph for each element of the collection with all references will be merged.Same as DataContext.merge(Object, MergeOptions)but for a collection of instances.- Specified by:
- mergein interface- DataContext
- Returns:
- set of instances tracked by the context
 
- 
removeDescription copied from interface:DataContextRemoves the entity from the context and registers it as deleted. The entity will be removed from the data store upon subsequent call toDataContext.save().If the given entity is not in the context, nothing happens. - Specified by:
- removein interface- DataContext
 
- 
evictDescription copied from interface:DataContextRemoves the entity from the context so the context stops tracking it.If the given entity is not in the context, nothing happens. - Specified by:
- evictin interface- DataContext
 
- 
evictModifiedpublic void evictModified()Description copied from interface:DataContextClears the lists of created/modified/deleted entities and evicts these entities.- Specified by:
- evictModifiedin interface- DataContext
 
- 
clearpublic void clear()Description copied from interface:DataContextEvicts all tracked entities.- Specified by:
- clearin interface- DataContext
- See Also:
 
- 
createDescription copied from interface:DataContextCreates an entity instance and merges it into the context.Same as: Foo foo = dataContext.merge(metadata.create(Foo.class)); - Specified by:
- createin interface- DataContext
- Parameters:
- entityClass- entity class
- Returns:
- a new instance which is tracked by the context
 
- 
hasChangespublic boolean hasChanges()Description copied from interface:DataContextReturns true if the context has detected changes in the tracked entities.- Specified by:
- hasChangesin interface- DataContext
 
- 
isModifiedDescription copied from interface:DataContextReturns true if the context has detected changes in the given entity.- Specified by:
- isModifiedin interface- DataContext
 
- 
setModifiedDescription copied from interface:DataContextRegisters or unregisters the given entity as modified.- Specified by:
- setModifiedin interface- DataContext
- Parameters:
- entity- entity instance which is already merged into the context
- modified- true to register or false to unregister
 
- 
getModifiedDescription copied from interface:DataContextReturns an immutable set of entities registered as modified.- Specified by:
- getModifiedin interface- DataContext
 
- 
isRemovedDescription copied from interface:DataContextReturns true if the context has registered removal of the given entity.- Specified by:
- isRemovedin interface- DataContext
 
- 
getRemovedDescription copied from interface:DataContextReturns an immutable set of entities registered for removal.- Specified by:
- getRemovedin interface- DataContext
 
- 
saveDescription copied from interface:DataContextSaves changed and removed instances using DataManager or a custom save delegate. After successful save, the context contains updated instances returned from the backend code.- Specified by:
- savein interface- DataContext
- Returns:
- set of saved and merged back to the context instances. Does not contain removed instances.
- See Also:
 
- 
saveDescription copied from interface:DataContextSaves changed and removed instances using DataManager, custom save delegate or merges them to parent data context if it is set. If reloadSaved is set, merge and reload of saved instances is performed so the context will contain updated instances after successful save.- Specified by:
- savein interface- DataContext
- Parameters:
- reloadSaved- flag indicating whether to reload and merge entities after save using DataManager
- Returns:
- set of saved and merged back to the context instances if reloadSaved is true. Empty set otherwise.
- See Also:
 
- 
getParentDescription copied from interface:DataContextReturns a parent context, if any. If the parent context is set,DataContext.save()method merges the changed instances to it instead of sending them to DataManager or a custom save delegate.- Specified by:
- getParentin interface- DataContext
 
- 
setParentDescription copied from interface:DataContextSets the parent context. If the parent context is set,DataContext.save()andDataContext.save(boolean)methods merge the changed instances to it instead of sending them to DataManager or a custom save delegate.- Specified by:
- setParentin interface- DataContext
 
- 
addChangeListenerDescription copied from interface:DataContextAdds a listener toDataContext.ChangeEvent.- Specified by:
- addChangeListenerin interface- DataContext
 
- 
addPreSaveListenerDescription copied from interface:DataContextAdds a listener toDataContext.PreSaveEvent.You can also add an event listener declaratively using a controller method annotated with Subscribe:@Subscribe(target = Target.DATA_CONTEXT) protected void onPreSave(DataContext.PreSaveEvent event) { // handle event here }- Specified by:
- addPreSaveListenerin interface- DataContext
- Parameters:
- listener- listener
- Returns:
- subscription
 
- 
addPostSaveListenerDescription copied from interface:DataContextAdds a listener toDataContext.PostSaveEvent.You can also add an event listener declaratively using a controller method annotated with Subscribe:@Subscribe(target = Target.DATA_CONTEXT) protected void onPostSave(DataContext.PostSaveEvent event) { // handle event here }- Specified by:
- addPostSaveListenerin interface- DataContext
- Parameters:
- listener- listener
- Returns:
- subscription
 
- 
getSaveDelegateDescription copied from interface:DataContextReturns a function which will be used to save data instead of standard implementation.- Specified by:
- getSaveDelegatein interface- DataContext
 
- 
setSaveDelegateDescription copied from interface:DataContextSets a function which will be used to save data instead of standard implementation.- Specified by:
- setSaveDelegatein interface- DataContext
 
 
-