Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.storage.sql
Class SelectionContext

java.lang.Object
  extended by org.nuxeo.ecm.core.storage.sql.SelectionContext

public class SelectionContext
extends Object

A SelectionContext holds information for a set Selection objects, mostly acting as a cache.

Some of the information is identical to what's in the database and can be safely be GC'ed, so it lives in a memory-sensitive map (softMap), otherwise it's moved to a normal map (hardMap) (creation or deletion).


Field Summary
 Map<Serializable,Selection> hardMap
           
 
Constructor Summary
SelectionContext(SelectionType selType, Serializable criterion, RowMapper mapper, PersistenceContext context)
           
 
Method Summary
 boolean applicable(SimpleFragment fragment)
           
 int clearCaches()
           
 void gatherInvalidations(Invalidations invalidations)
          Gathers invalidations from this session.
 SimpleFragment getSelectionFragment(Serializable selId, String filter)
          Find a fragment given its selection id and value.
 List<SimpleFragment> getSelectionFragments(Serializable selId, String filter)
          Finds all the selection fragments for a given id.
 void markInvalidated(Set<RowId> modified)
          Marks locally all the invalidations gathered by a Mapper operation (like a version restore).
 void newSelection(Serializable selId)
          Notes that a new empty selection should be created.
 void postSave()
           
 void processReceivedInvalidations(Set<RowId> modified)
          Processes all invalidations accumulated.
 void recordCreated(SimpleFragment fragment)
          Records the fragment as a just-created selection member.
 void recordExisting(SimpleFragment fragment, boolean invalidate)
           
 void recordRemoved(Serializable id, Serializable selId)
          Removes a selection item from the selection.
 void recordRemoved(SimpleFragment fragment)
          Removes a selection item from the selection.
 void recordRemovedSelection(Serializable selId)
          Records a selection as removed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hardMap

public final Map<Serializable,Selection> hardMap
Constructor Detail

SelectionContext

public SelectionContext(SelectionType selType,
                        Serializable criterion,
                        RowMapper mapper,
                        PersistenceContext context)
Method Detail

clearCaches

public int clearCaches()

applicable

public boolean applicable(SimpleFragment fragment)
                   throws StorageException
Throws:
StorageException

recordCreated

public void recordCreated(SimpleFragment fragment)
                   throws StorageException
Records the fragment as a just-created selection member.

Throws:
StorageException

newSelection

public void newSelection(Serializable selId)
Notes that a new empty selection should be created.


recordExisting

public void recordExisting(SimpleFragment fragment,
                           boolean invalidate)
                    throws StorageException
Parameters:
invalidate - true if this is for a fragment newly created by internal database process (copy, etc.) and must notified to other session; false if this is a normal read
Throws:
StorageException

recordRemoved

public void recordRemoved(SimpleFragment fragment)
                   throws StorageException
Removes a selection item from the selection.

Throws:
StorageException

recordRemoved

public void recordRemoved(Serializable id,
                          Serializable selId)
                   throws StorageException
Removes a selection item from the selection.

Throws:
StorageException

recordRemovedSelection

public void recordRemovedSelection(Serializable selId)
                            throws StorageException
Records a selection as removed.

Throws:
StorageException

getSelectionFragment

public SimpleFragment getSelectionFragment(Serializable selId,
                                           String filter)
                                    throws StorageException
Find a fragment given its selection id and value.

If the fragment is not in the context, fetch it from the mapper.

Parameters:
selId - the selection id
filter - the value to filter on
Returns:
the fragment, or null if not found
Throws:
StorageException

getSelectionFragments

public List<SimpleFragment> getSelectionFragments(Serializable selId,
                                                  String filter)
                                           throws StorageException
Finds all the selection fragments for a given id.

No sorting on value is done.

Parameters:
selId - the selection id
filter - the value to filter on, or null for all
Returns:
the list of fragments
Throws:
StorageException

postSave

public void postSave()

markInvalidated

public void markInvalidated(Set<RowId> modified)
Marks locally all the invalidations gathered by a Mapper operation (like a version restore).


gatherInvalidations

public void gatherInvalidations(Invalidations invalidations)
Gathers invalidations from this session.

Called post-transaction to gathers invalidations to be sent to others.


processReceivedInvalidations

public void processReceivedInvalidations(Set<RowId> modified)
                                  throws StorageException
Processes all invalidations accumulated.

Called pre-transaction.

Throws:
StorageException

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.