wt.epm.util
Class EPMCache.IterationCache

java.lang.Object
  extended bywt.epm.util.EPMCache.IterationCache
Enclosing class:
EPMCache

public static class EPMCache.IterationCache
extends Object

An Iteration Cache holds Iterated objects and indexes them by the object identifier of their master. Given an object identifier of a master, it returns the iteration for that master selected by the config spec. If an iteration is not in the cache, the Iteration Cache will use its config spec to query it from the database and add it to its cache.


Field Summary
private  ConfigSpec configSpec
           
private  HashMap masterToIteration
           
private  EPMCache.ObjectCache objectCache
           
 
Constructor Summary
EPMCache.IterationCache(ConfigSpec configSpec)
          Using the given config spec, constructs an Iteration Cache.
EPMCache.IterationCache(ConfigSpec configSpec, Collection objects)
          Using the given config spec, constructs an Iteration Cache and adds the collection of Iterated objects to its cache.
 
Method Summary
 void add(Collection iterations)
          Adds a collection of Iterated objects to the Iteration Cache.
 void add(Iterated iteration)
          Adds an Iterated object to the Iteration Cache.
protected  void add(Mastered master)
           
 List find(Collection masterIds, boolean returnMasters)
          Given the object identifiers for a set of masters, returns the iterations of those masters selected by the config spec.
 Persistable getIteration(ObjectIdentifier masterId)
          Given the object identifier for a master, return the iteration selected by the config spec for this master provided it is in the cache.
 ObjectIdentifier getIterationId(ObjectIdentifier masterId)
          Given the object identifier for a master, return the object identifier for iteration selected by the config spec for this master provided it is in the cache.
 Persistable getObject(ObjectIdentifier objectId)
          Given the object identifier for an iteration or a master, return the object provided it is in the cache.
 boolean isEmpty()
          Returns true if this cache contains no objects.
 Collection objects()
          Returns an unmodifiable collection view of the iterations and masters in this cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objectCache

private EPMCache.ObjectCache objectCache

masterToIteration

private HashMap masterToIteration

configSpec

private ConfigSpec configSpec
Constructor Detail

EPMCache.IterationCache

public EPMCache.IterationCache(ConfigSpec configSpec)
Using the given config spec, constructs an Iteration Cache.


EPMCache.IterationCache

public EPMCache.IterationCache(ConfigSpec configSpec,
                               Collection objects)
Using the given config spec, constructs an Iteration Cache and adds the collection of Iterated objects to its cache.

Method Detail

getIteration

public Persistable getIteration(ObjectIdentifier masterId)
Given the object identifier for a master, return the iteration selected by the config spec for this master provided it is in the cache. If it is not, this method will return null. Note: If the config spec did not select any iteration for this master, this method with return the master.


getObject

public Persistable getObject(ObjectIdentifier objectId)
Given the object identifier for an iteration or a master, return the object provided it is in the cache. If it is not, this method will return null.


getIterationId

public ObjectIdentifier getIterationId(ObjectIdentifier masterId)
Given the object identifier for a master, return the object identifier for iteration selected by the config spec for this master provided it is in the cache. If it is not, this method will return null. Note: If the config spec did not select any iteration for this master, this method with return the object identifier for the master.


add

public void add(Iterated iteration)
Adds an Iterated object to the Iteration Cache.


add

public void add(Collection iterations)
Adds a collection of Iterated objects to the Iteration Cache.


find

public List find(Collection masterIds,
                 boolean returnMasters)
          throws WTException
Given the object identifiers for a set of masters, returns the iterations of those masters selected by the config spec. If an iteration is not in the cache, the Iteration Cache will use its config spec to query it from the database and add it to its cache. If the returnMasters flag is set to true and the config spec did not select any iteration for a particular master, this method will return the master instead.

Throws:
WTException

objects

public Collection objects()
Returns an unmodifiable collection view of the iterations and masters in this cache.


isEmpty

public boolean isEmpty()
Returns true if this cache contains no objects.


add

protected void add(Mastered master)