wt.fc.collections
Class RefreshHelper.Refresh

java.lang.Object
  extended bywt.fc.collections.RefreshHelper.Refresh
Direct Known Subclasses:
RefreshHelper.LockRefresh, RefreshHelper.UnionRefresh
Enclosing class:
RefreshHelper

abstract static class RefreshHelper.Refresh
extends Object

Base class for both lock and non-locking refreshes. Locking refreshes can't be UNIONed, hence the different implementations


Field Summary
(package private)  WTCollection cachedObjects
          Objects that were found in a cache.
(package private)  Map classesToRefreshDatas
          Mapping of persistable classes to RefreshDatas
(package private)  WTCollection collection
           
(package private)  WTCollection deletedObjects
          Objects that were deleted and removed.
(package private)  int keyMask
           
(package private)  Map keysToReferences
          Mapping of QueryKeys to the WTReference or Collection of WTReference that refer to them
(package private)  RefreshHelper.LinkRefresh linkRefresh
          Utility class for refreshes of links and their roles
(package private)  RefreshSpec spec
           
(package private)  WTCollection staleObjects
          Tracks all stale objects, so that the refresh can throw a multi-object message if necessary.
 
Constructor Summary
(package private) RefreshHelper.Refresh(WTCollection wtc, RefreshSpec rs)
           
(package private) RefreshHelper.Refresh(WTCollection wtc, RefreshSpec rs, int key_mask)
           
 
Method Summary
(package private)  void add(WTReference r)
          Adds the given WTReference to the Refresh's internal data structures
(package private)  void add(WTReference r, boolean role_reference)
          Adds the given WTReference to the Refresh's internal data structures
(package private)  void addStale(Persistable p, QueryKey key)
          Depending on the stale action, process the stale object
(package private)  void addToFirstPass(QueryKey key, Class c)
          Add the given QueryKey to the keys that are queried during the first pass
(package private)  void addToKeysToReferences(WTReference r)
          Adds the reference to keysToReferences
(package private)  void addToSecondPass(QueryKey key, Class c)
          Add the key to the list of keys that are queried during the second pass
(package private)  void appendClassNameSelect(QuerySpec qs, RefreshHelper.RefreshData data)
          Allows subclasses to select the classname during the first pass query, if necessary.
(package private)  void appendPlaceHolderSelect(QuerySpec qs)
          Allows subclasses to select a placeholder branch id if necessary
(package private) abstract  void doFirstPass()
           
(package private)  void doSecondPass(StatementSpec statementspec)
          Inflate the objects selected by the spec and assign them to the references in keysToReferences.
(package private)  QuerySpec getFirstPassQuery(RefreshHelper.RefreshData data)
          Get a statement that selects the oids, classnames, updatecounts, and possibly branch ids for the given RefreshData
(package private)  RefreshHelper.RefreshData getRefreshData(Class persistable_class)
           
(package private)  StatementSpec getSecondPassQuery(RefreshHelper.RefreshData data)
          Get a statment that selects the objects in the RefreshData with any of ids in secondPassBranchIDs or secondPassOids
(package private)  boolean inflateFromCache(WTReference r)
          Inflate the reference from the refresh cache
(package private)  void log()
          Reports debug information to the log
(package private)  void processDeletes()
          At this point keysToReferences should only contain objects that were: 1) not found by the 1st query because they were deleted 2) not found by the 2nd query because there were deleted since the 1st query 3) filtered by access control by the 2nd query
(package private)  void processFirstPassRow(Object[] row, Class oid_class)
          Remove up-to-date objects from keysToReferences.
(package private)  void processSecondPassObject(Persistable p)
          Inflate any references to the object in keysToReferences.
(package private)  void refresh()
          Refresh the references in this object's data structures
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

collection

final WTCollection collection

spec

final RefreshSpec spec

keyMask

final int keyMask

keysToReferences

final Map keysToReferences
Mapping of QueryKeys to the WTReference or Collection of WTReference that refer to them


classesToRefreshDatas

final Map classesToRefreshDatas
Mapping of persistable classes to RefreshDatas


linkRefresh

RefreshHelper.LinkRefresh linkRefresh
Utility class for refreshes of links and their roles


staleObjects

WTCollection staleObjects
Tracks all stale objects, so that the refresh can throw a multi-object message if necessary. Only initialized when refresh state is VALIDATE_STALE


cachedObjects

WTCollection cachedObjects
Objects that were found in a cache. Only initialized when DEBUG is turned on


deletedObjects

WTCollection deletedObjects
Objects that were deleted and removed. Only initialized when DEBUG is turned on and delete state is REMOVE_DELETE

Constructor Detail

RefreshHelper.Refresh

RefreshHelper.Refresh(WTCollection wtc,
                      RefreshSpec rs)

RefreshHelper.Refresh

RefreshHelper.Refresh(WTCollection wtc,
                      RefreshSpec rs,
                      int key_mask)
Method Detail

add

final void add(WTReference r)
        throws WTException
Adds the given WTReference to the Refresh's internal data structures

Parameters:
r -
Throws:
WTException

add

final void add(WTReference r,
               boolean role_reference)
        throws WTException
Adds the given WTReference to the Refresh's internal data structures

Parameters:
r -
role_reference - Whether or not this reference is being added because it is the role reference on a link in the input collection
Throws:
WTException

inflateFromCache

boolean inflateFromCache(WTReference r)
                   throws WTException
Inflate the reference from the refresh cache

Parameters:
r -
Returns:
true If the object was in the cache and is up to date
Throws:
WTException

addToFirstPass

void addToFirstPass(QueryKey key,
                    Class c)
Add the given QueryKey to the keys that are queried during the first pass

Parameters:
key -
c -

addToSecondPass

void addToSecondPass(QueryKey key,
                     Class c)
Add the key to the list of keys that are queried during the second pass

Parameters:
key -
c -

addToKeysToReferences

void addToKeysToReferences(WTReference r)
Adds the reference to keysToReferences

Parameters:
r -

addStale

void addStale(Persistable p,
              QueryKey key)
        throws CollectionContainsStaleException
Depending on the stale action, process the stale object

Parameters:
p - The stale persistable
key - The key to use to add this persistable to the refresh's data structures, so it gets inflated. If the key is null, then the object won't be inflated (used by inflate from cache)
Throws:
CollectionContainsStaleException

getRefreshData

RefreshHelper.RefreshData getRefreshData(Class persistable_class)

refresh

void refresh()
       throws WTException
Refresh the references in this object's data structures

Throws:
WTException

doFirstPass

abstract void doFirstPass()
                   throws WTException
Throws:
WTException

getFirstPassQuery

QuerySpec getFirstPassQuery(RefreshHelper.RefreshData data)
                      throws WTException
Get a statement that selects the oids, classnames, updatecounts, and possibly branch ids for the given RefreshData

Parameters:
data -
Returns:
QuerySpec
Throws:
WTException

appendClassNameSelect

void appendClassNameSelect(QuerySpec qs,
                           RefreshHelper.RefreshData data)
                     throws WTException
Allows subclasses to select the classname during the first pass query, if necessary.

Parameters:
qs -
data -
Throws:
WTException

appendPlaceHolderSelect

void appendPlaceHolderSelect(QuerySpec qs)
                       throws WTException
Allows subclasses to select a placeholder branch id if necessary

Parameters:
qs -
Throws:
WTException

processFirstPassRow

void processFirstPassRow(Object[] row,
                         Class oid_class)
                   throws WTException
Remove up-to-date objects from keysToReferences. Add stale objects to the staleObjects collection

Parameters:
row - A result row from the 1st pass query
oid_class - The class of object for the row
Throws:
WTException

doSecondPass

void doSecondPass(StatementSpec statementspec)
            throws WTException
Inflate the objects selected by the spec and assign them to the references in keysToReferences. Remove updated objects from keysToReferences Add objects to the reference cache as necessary

Throws:
WTException

getSecondPassQuery

StatementSpec getSecondPassQuery(RefreshHelper.RefreshData data)
                           throws WTException
Get a statment that selects the objects in the RefreshData with any of ids in secondPassBranchIDs or secondPassOids

Parameters:
data -
Returns:
StatementSpec
Throws:
WTException

processSecondPassObject

void processSecondPassObject(Persistable p)
                       throws WTException
Inflate any references to the object in keysToReferences. Remove inflated references from keysToReferences.

Parameters:
p -
Throws:
WTException

processDeletes

void processDeletes()
              throws WTException
At this point keysToReferences should only contain objects that were: 1) not found by the 1st query because they were deleted 2) not found by the 2nd query because there were deleted since the 1st query 3) filtered by access control by the 2nd query

Throws:
WTException

log

void log()
   throws WTException
Reports debug information to the log

Throws:
WTException