wt.eff
Class UpdateEffsTask

java.lang.Object
  extended bywt.eff.UpdateEffsTask

class UpdateEffsTask
extends Object

This class encapsulates the logic for updating the effectivity vector of one or more EffManagedVersion objects, recording the history of effectivity changes as appropriate.


Field Summary
private  EffChangeAudit audit
           
private  ChangeActivityIfc authorizedBy
           
private static EffSet EMPTY_SET
           
private  HashMap emvMap
           
private  WTHashSet modifiedVersions
           
private static Boolean recordHistory
           
private static String RESOURCE
           
 
Constructor Summary
UpdateEffsTask(EffManagedVersion[] emvs, ChangeActivityIfc authorizedBy)
          Constructs a new UpdateEffsTask object for a particular batch of effectivity updates.
 
Method Summary
private  void advanceCreation(EffSet effSet)
          Advances the creation audits of the specified Eff objects.
private  void advanceDeletion(EffSet effSet)
          Advances the factual deletion audits of the specified Eff objects.
private  void delete(EffSet effSet)
          Factually deletes specified Eff objects.
private  EffSet difference(EffSet a, EffSet b)
           
private  EffChangeAudit getAudit()
          Returns a previously cached EffChangeAudit object, or a new one if none has been previously cached.
private static boolean historyExists()
          Returns true if and only if any effectivity history has been recorded in the system.
private  EffSet intersection(EffSet a, EffSet b)
           
private static boolean isRecordHistory()
          Returns true if and only if history should be recorded in general.
private  boolean isRecordHistory(EffManagedVersion emv, int hSize, int phSize)
          Returns true if and only if effectivity history should be recorded for the specified EffManagedVersion object.
private  void remove(EffSet effSet)
          Properly deletes (i.e., removes from persistence) the specified Eff objects.
private  void restore(EffSet effSet)
          Restores from factual deletion the specified Eff objects.
private  void store(EffSet effSet)
          Persist the specified new Eff objects.
private  EffSet union(EffSet a, EffSet b)
           
 void updateEffs(long emvBID, EffSet newEffs, EffHistoryMap antiHistoryMap, int predHistSize)
          Updates the effectivities of the specified EffManagedVersion.
 void updateVersions()
          Nominally updates (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

EMPTY_SET

private static final EffSet EMPTY_SET

recordHistory

private static Boolean recordHistory

emvMap

private HashMap emvMap

authorizedBy

private ChangeActivityIfc authorizedBy

audit

private EffChangeAudit audit

modifiedVersions

private WTHashSet modifiedVersions
Constructor Detail

UpdateEffsTask

public UpdateEffsTask(EffManagedVersion[] emvs,
                      ChangeActivityIfc authorizedBy)
Constructs a new UpdateEffsTask object for a particular batch of effectivity updates.

Parameters:
emvs - array of EffManagedVersions whose effectivity vectors will possibly be updated by this UpdateEffsTask authorizedBy change activity object via which the effectivity update is being performed (for audit purposes); may be null
Method Detail

updateEffs

public void updateEffs(long emvBID,
                       EffSet newEffs,
                       EffHistoryMap antiHistoryMap,
                       int predHistSize)
                throws WTPropertyVetoException,
                       WTException
Updates the effectivities of the specified EffManagedVersion.

Parameters:
emvBID - branch identifier of the EffManagedVersion whose effectivity is being updated newEffs Set of Eff objects defining the new (cumulative) effectivity value for an implicitly given EffContext and Eff type antiHistoryMap EffHistoryMap of the effectivity history for the specified EffManagedVersion for the same implicitly given EffContext and Eff type, in anti-chronological order (i.e. the first element of the map represents the current effectivity) predHistSize the cardinality of the specified EffManagedVersion's predecessor's effectivity history (or zero if no such history exists) for the same implicitly given EffContext and Eff type
Throws:
WTPropertyVetoException
WTException

updateVersions

public void updateVersions()
                    throws WTException
Nominally updates (i.e. updates the update count of) EffManagedVersion objects whose effectivities have been updated by this UpdateEffsTask.

Throws:
WTException

isRecordHistory

private boolean isRecordHistory(EffManagedVersion emv,
                                int hSize,
                                int phSize)
                         throws WTException,
                                WTPropertyVetoException
Returns true if and only if effectivity history should be recorded for the specified EffManagedVersion object. This depends upon whether effectivity history is generally recorded, whether the version is private, and if so, on the relative sizes of the version's effectivity history and its predecessor's.

Parameters:
emv - EffManagedVersion for which effectivity history recording is to be determined hSize the size of the argument EffManagedVersion's effectivity history for an implicitly given EffContext and Eff type phSize the size of the argument EffManagedVersion's predecessor version's effectivity history for the same implicitly given EffContext and Eff type
Throws:
WTException
WTPropertyVetoException

isRecordHistory

private static boolean isRecordHistory()
                                throws WTException,
                                       WTPropertyVetoException
Returns true if and only if history should be recorded in general. This depends on the value of the wt.eff.recordHistory property setting. If this setting is false, but history has already been recorded, then a WTException is thrown.

Returns:
true if and only if history should be recorded in general
Throws:
WTException
WTPropertyVetoException

historyExists

private static boolean historyExists()
                              throws WTException
Returns true if and only if any effectivity history has been recorded in the system. This is the case if either of the following conditions is met: (1) at least one persistent Eff object has a valid deletion reference, or (2) at least one group of relevant Eff objects (i.e. those Eff objects of the same type associated with the same version and context, if any) has at least two members with differing valid creation references.

Returns:
true if and only if any effetivity history has been recorded in the system
Throws:
WTException

union

private EffSet union(EffSet a,
                     EffSet b)

intersection

private EffSet intersection(EffSet a,
                            EffSet b)

difference

private EffSet difference(EffSet a,
                          EffSet b)

restore

private void restore(EffSet effSet)
              throws WTPropertyVetoException,
                     WTException
Restores from factual deletion the specified Eff objects. This is appropriate when an Eff value is 'recreated' immediately following its factual deletion and history recording has been suspended (say, for a modified working copy of an EffManagedVersion).

Parameters:
effSet - EffSet of Eff objects that have previously been factually deleted, that are to be restored
Throws:
WTPropertyVetoException
WTException

advanceCreation

private void advanceCreation(EffSet effSet)
                      throws WTPropertyVetoException,
                             WTException
Advances the creation audits of the specified Eff objects. This is appropriate when an Eff value is 'carried forward' immediately following its creation and the suspension of history recording (say, for a modified working copy of an EffManagedVersion).

Parameters:
effSet - EffSet of Eff objects whose creation is to be advanced
Throws:
WTPropertyVetoException
WTException

advanceDeletion

private void advanceDeletion(EffSet effSet)
                      throws WTPropertyVetoException,
                             WTException
Advances the factual deletion audits of the specified Eff objects. This is appropriate when a factually deleted Eff value is to remain so immediately following its factual deletion and the suspension of history recording (say, for a modified working copy of an EffManagedVersion).

Parameters:
effSet - EffSet of Eff objects whose factual deletion is to be advanced
Throws:
WTPropertyVetoException
WTException

delete

private void delete(EffSet effSet)
             throws WTPropertyVetoException,
                    WTException
Factually deletes specified Eff objects. This is appropriate when effectivity history is being recorded.

Parameters:
effSet - EffSet of Eff objects to be factually deleted
Throws:
WTPropertyVetoException
WTException

store

private void store(EffSet effSet)
            throws WTPropertyVetoException,
                   WTException
Persist the specified new Eff objects.

Parameters:
effSet - EffSet of new (non-persistent) Eff objects to be persisted
Throws:
WTPropertyVetoException
WTException

remove

private void remove(EffSet effSet)
             throws WTException
Properly deletes (i.e., removes from persistence) the specified Eff objects. This is appropriate when history recording has been suspended (say, for a modified working copy of an EffManagedVersion).

Parameters:
effSet - EffSet of existing (persistent) Eff objects to be properly deleted
Throws:
WTException

getAudit

private EffChangeAudit getAudit()
                         throws WTException,
                                WTPropertyVetoException
Returns a previously cached EffChangeAudit object, or a new one if none has been previously cached. The same EffChangeAudit object is meant to apply to all effectivity modifications effected by this UpdateEffsTask object, hence the caching.

Throws:
WTException
WTPropertyVetoException