com.tivoli.twg.engine
Class TWGAssociation

java.lang.Object
  extended bycom.tivoli.twg.engine.TWGObject
      extended bycom.tivoli.twg.engine.TWGPersistentObject
          extended bycom.tivoli.twg.engine.TWGAssociation
All Implemented Interfaces:
TWGBaseShadowedObject, TWGShadowedObject

public class TWGAssociation
extends TWGPersistentObject
implements TWGShadowedObject

Base class for association functions. This abstract class defines the core interface and core attributes for an association, including the necessary interfaces for activating and deactivating an association, as well as notifying an association of the creation, deletion, or modification of the TWGManagedObject in the TWGManagedObjectSet providing the input to the association (which is used by the association instance to product and maintain a TWGRelationshipSet).

Each TWGAssociation subclass registered is used to construct a single instance of the subclass. This instance can be used to maintian zero or more TWGRelationshipSet instances, so implementation of the evaluateNewAndChangedObjects() method by the subclass is required to be reentrant with respect to the different TWGRelationshipSet instances.

When an association is first selected for a given set of TWGManagedObjects, the evaluateNewAndChangedObject() method will be invoked with an empty TWGRelationshipSet and the add_set containing all the persistent object IDs of the TWGManagedObjects initially to be considered. The evaluateNewAndChangedObject() method implementation is responsible for evaluating these TWGManagedObjects, and adding them to the appropriate TWGRelationship instances in the TWGRelationshipSet (and creating these TWGRelationship instances, as required).

When the population of TWGManagedObjects to be considered by the TWGAssociation changes, either due to creation of one or more new TWGManagedObjects or potential changes in the characteristics of one or more previously considered TWGManagedObjects (i.e. inventory refresh, operating system change, etc), the evaluateNewAndChangedObject() method will again be invoked, with the add_set containing the persistent object IDs of any new TWGManagedObjects (i.e. ones not previously considered) and the chg_set containing the persistent object IDs of any changed TWGManagedObjects (ones which may already be in one or more TWGRelationships). The TWGRelationshipSet passed in will still contain the TWGRelationships previously added, so the evaluateNewAndChangedObject() method is responsible for updating these existing TWGRelationships (i.e. adding new members, removing changed members which no longer match), as well as creating new ones. Deleted TWGManagedObjects are automatically removed from all TWGRelationships without invoking evaluateNewAndChangedObject().

The TWGAssociation instances must not maintain references to any TWGRelationship, IntValueSet or TWGRelationshipSet parameters passed or returned, as these are frequently reused and deleted without notice.

See Also:
TWGManagedObject, TWGRelationship, TWGRelationshipSet, IntValueSet

Field Summary
static java.lang.String DEFAULT_NONE_ASSOC_ID
          ID of default "none" association
 
Fields inherited from class com.tivoli.twg.engine.TWGPersistentObject
CLASS_NAME, SIZEOF_BYTE, SIZEOF_CHAR, SIZEOF_DOUBLE, SIZEOF_FLOAT, SIZEOF_INT, SIZEOF_LONG, SIZEOF_SHORT
 
Constructor Summary
TWGAssociation()
          Default constructor : used by restoreData() : must be provided by any subclasses of TWGAssociation.
 
Method Summary
 void Delete()
          Delete method : use to remove object from list
 void evaluateNewAndChangedObjects(TWGRelationshipSet rel, IntValueSet add_set, IntValueSet chg_set, TWGManagedObjectSet mos)
          Primary functional evaluation method for association object: for the given relationship set, process added and modified managed objects, updating and modifying the relationship set appropriately.
static TWGAssociation findByIDString(java.lang.String id)
          Find association instance by ID string
 java.lang.String GetConShadowClass()
          Get name of console shadow class.
 java.lang.String getExtensionClassName()
          Get the name of the extension class that defined this association.
 java.lang.String getIDString()
          Get ID string
 int getMenuWeight()
          Get menu weight
 java.lang.String getName()
          Get name (default locale)
 java.lang.String getName(java.util.Locale loc)
          Get name (given locale)
 byte[] GetShadowRecord(java.util.Locale locale)
          Get buffer containing current values of the shadowed attributes to be delivered to the console shadow class.
 long GetShadowVersion()
          Get object state version.
static void initBuiltInAssociations()
          Initialize built-in associations, if needed.
 boolean isDatabaseDependent()
          Test to see if association depends upon active database.
 boolean isDisabled()
          Check to see if association is disabled
 boolean isLicenseDisabled()
          Check to see if association is disabled due to license restriction
protected  void restoreData(TWGPersistentObjectDictionary dict, boolean do_references)
          Restore method for persistent object
protected  void saveData(TWGPersistentObjectDictionary dict)
          Save method for saving persistent state
 void setExtensionClassName(java.lang.String extensionClassName)
          Set the name of the extension class that defined this association.
 boolean setIDString(java.lang.String new_id)
          Set ID string.
 void setMenuWeight(int new_w)
          Set menu weight : menu weights are used for ordering different TWGAssociation names under the "Associations" menu.
 void setName(java.lang.String n)
          Set name of association
 void setName(java.lang.String nameid, java.lang.String namerb)
          Set name of association using resouce bundle name and ID
 java.lang.String toString()
          Returns a string representation of the object.
 void UpdateShadowVersion()
          Update object state version.
 
Methods inherited from class com.tivoli.twg.engine.TWGPersistentObject
Destroy, enableAsyncWrites, fromPersistID, initialize, isNewPersistentStore, isSaveRequired, PersistID, restore, restoreAll, save, save, setSaveRequired, terminate, toPersistID
 
Methods inherited from class com.tivoli.twg.engine.TWGObject
AllObjects, AllObjects, DumpTWGObjects, FindObject, isDeleted, isNewObject, isPersistent, isPersistent, isValid, isValid, ObjectID, setDistinctObjectID, SetObjectID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_NONE_ASSOC_ID

public static final java.lang.String DEFAULT_NONE_ASSOC_ID
ID of default "none" association

See Also:
Constant Field Values
Constructor Detail

TWGAssociation

public TWGAssociation()
Default constructor : used by restoreData() : must be provided by any subclasses of TWGAssociation.

Method Detail

Delete

public void Delete()
Delete method : use to remove object from list

Overrides:
Delete in class TWGObject

saveData

protected void saveData(TWGPersistentObjectDictionary dict)
                 throws TWGPersistentObjectSaveException
Save method for saving persistent state

Overrides:
saveData in class TWGPersistentObject
Parameters:
dict - - dictionary to hold saved data
Throws:
TWGPersistentObjectSaveException - if save aborted

restoreData

protected void restoreData(TWGPersistentObjectDictionary dict,
                           boolean do_references)
                    throws TWGPersistentObjectRestoreException
Restore method for persistent object

Overrides:
restoreData in class TWGPersistentObject
Parameters:
dict - - dictionary containing persistent object records
do_references - - true if second pass (reference restores)
Throws:
TWGPersistentObjectRestoreException - if restore aborted

getName

public java.lang.String getName()
Get name (default locale)

Returns:
name string

getName

public java.lang.String getName(java.util.Locale loc)
Get name (given locale)

Parameters:
loc - - locale to get name relative to
Returns:
name string

setName

public void setName(java.lang.String n)
Set name of association

Parameters:
n - - new name

setName

public void setName(java.lang.String nameid,
                    java.lang.String namerb)
Set name of association using resouce bundle name and ID

Parameters:
nameid - - identifier for name
namerb - - name of resouce bundle containing name

getMenuWeight

public int getMenuWeight()
Get menu weight

Returns:
menu weight

setMenuWeight

public void setMenuWeight(int new_w)
Set menu weight : menu weights are used for ordering different TWGAssociation names under the "Associations" menu.

Parameters:
new_w - - new menu weight

getExtensionClassName

public final java.lang.String getExtensionClassName()
Get the name of the extension class that defined this association.

Returns:
the name of the extension class that defined this association.

setExtensionClassName

public final void setExtensionClassName(java.lang.String extensionClassName)
Set the name of the extension class that defined this association.


UpdateShadowVersion

public void UpdateShadowVersion()
Update object state version. This method must call the TWGActiveConsole.nextShadowVersion() to update its internal state_version attribute (a 'long' instance variable). This method should be called by any methods of the object's class or subclasses which modify attributes which are send to the shadow objects on the console).

Specified by:
UpdateShadowVersion in interface TWGBaseShadowedObject

GetShadowVersion

public long GetShadowVersion()
Get object state version. This returns value of state_version.

Specified by:
GetShadowVersion in interface TWGBaseShadowedObject
Returns:
state_version attribute value

GetConShadowClass

public java.lang.String GetConShadowClass()
Get name of console shadow class. This returns the name of TWGConObject subclass which is used to hold the attributes shadowed to the console.

Specified by:
GetConShadowClass in interface TWGBaseShadowedObject
Returns:
com.tivoli.twg.engine.TWGConObject subclass which object shadows to

GetShadowRecord

public byte[] GetShadowRecord(java.util.Locale locale)
Get buffer containing current values of the shadowed attributes to be delivered to the console shadow class. This data is delivered along with the ObjectID (so the ObjectID shouldn't be included in the shadowed data record).

Specified by:
GetShadowRecord in interface TWGBaseShadowedObject
Parameters:
locale - - Locale of requested data
Returns:
byte array containing opaque data representation of attribute values to be delivered to the console shadow class.

getIDString

public java.lang.String getIDString()
Get ID string

Returns:
ID string (or null if none defined)

setIDString

public boolean setIDString(java.lang.String new_id)
Set ID string. Specifying a unique ID string for each association instance allows for easier programmatic access to the association instance.

Parameters:
new_id - - new ID string (must be unique)
Returns:
true if new ID string set(and is unique)

toString

public java.lang.String toString()
Returns a string representation of the object.

See Also:
Object.toString()

findByIDString

public static TWGAssociation findByIDString(java.lang.String id)
Find association instance by ID string

Parameters:
id - - ID string to search for
Returns:
matching association instance, or null if none

initBuiltInAssociations

public static void initBuiltInAssociations()
                                    throws TWGPersistentObjectSaveException
Initialize built-in associations, if needed. Must be called after persistent object restore. Internal use only.

Throws:
TWGPersistentObjectSaveException - if error saving new objects
TWGPersistentObjectSaveException

evaluateNewAndChangedObjects

public void evaluateNewAndChangedObjects(TWGRelationshipSet rel,
                                         IntValueSet add_set,
                                         IntValueSet chg_set,
                                         TWGManagedObjectSet mos)
Primary functional evaluation method for association object: for the given relationship set, process added and modified managed objects, updating and modifying the relationship set appropriately. The default version of this method does nothing (which is used by the default 'none' association). Specific subclasses must replace this method in order to implement their functionality.

Parameters:
rel - - TWGRelationshipSet to be maintainted
add_set - - IntValueSet of persistent IDs for the TWGManagedObjects which have been added to the TWGManagedObjectSet which was used to produce the TWGRelationshipSet
chg_set - - IntValueSet of persistent IDs for the TWGManagedObjects which have been changed (and were previously in the TWGManagedObjectSet used for the TWGRelationshipSet).
mos - - TWGManagedObjectSet containing full population of persistent object IDs of TWGManagedObjects for TWGRelationshipSet (with changes already applied).

isDisabled

public final boolean isDisabled()
Check to see if association is disabled


isLicenseDisabled

public final boolean isLicenseDisabled()
Check to see if association is disabled due to license restriction


isDatabaseDependent

public boolean isDatabaseDependent()
Test to see if association depends upon active database. Base class returns false: subclasses which use the database to function should replace this method with one which returns true.

Returns:
true if database dependent, false if not