IBM Bank Transformation Toolkit Javadoc

com.ibm.btt.cha.ejb
Class CHAInstanceDBFactory

java.lang.Object
  extended by com.ibm.btt.cha.ejb.CHAInstanceDBFactory

public class CHAInstanceDBFactory
extends java.lang.Object

This class is to manipulate remote context stored in DB.


Field Summary
static java.lang.String COPYRIGHT
           
 
Constructor Summary
CHAInstanceDBFactory()
           
 
Method Summary
 void addChild(java.lang.String childInstanceID, java.lang.String instanceID)
          Adds a child specified by the parameter to the children list of current context.
 void addElement(java.lang.String instanceID, java.io.Serializable anElement)
          Adds an element to the Context
static void chainTo(java.lang.String instanceID, java.lang.String parentInstanceID)
          Chains this context to the context named specified by parentInstanceID.
 void clearKeyedCollection(java.lang.String instanceID)
          Clears the context (current level only) by destroying the current keyed collection associated and replacing it with a new one.
 void clearKeyedCollection(java.lang.String instanceID, boolean keepKCollStatus, boolean clearOnlyValues)
          This method clears both the typed and non-typed elements in the context keyed collection.
 boolean containsChild(java.lang.String instanceID, java.lang.String aContextName)
          Returns true if this context has a child with the name aContextName.
 Vector fields(java.lang.String instanceID)
          Returns all the data fields, which are addressable from this context.
 java.lang.String getAncestorByName(java.lang.String instanceID, java.lang.String aContextName)
          Searches the context tree for an ancestor Context named aContextName and returns the first matching context.
static CHAInstanceLocal getCHAInstanceLocal(java.lang.String instanceID)
           
static Vector getChildren(java.lang.String instanceID)
          Return the children of the context
 Vector getChildrenAtAnyLevel(java.lang.String currentInstanceID)
          Get the children of a remote context at any level from the context tree.
static Context getContext(java.lang.String instanceID)
          Get the context object according to the instanceID.
 java.lang.String getContextByType(java.lang.String instanceID, java.lang.String aTypeName)
          Returns the instanceID of the first context that matches its type to aTypeName.
protected static Context getContextForCommit(java.lang.String instanceID)
          get context from DB.
 java.lang.String getContextNamed(java.lang.String contextName)
          Searches the context tree from the root context for a context named aContextName
 java.io.Serializable getElementAt(java.lang.String instanceID, java.lang.String aCompositeKey, boolean isReadOnly)
          Returns the element of its keyedCollection,or keyedCollections of the upper contexts which is located at aCompositeKey path.
 KeyedCollection getKeyedCollection(java.lang.String instanceID)
          Returns the keyedCollection attribute.
 java.lang.String getLevel(java.lang.String instanceID)
          We can define an attribute --level-- in dsectxt.xml file to indicate level of the context.
 java.lang.String getNextContextHorizontal(java.lang.String currentInstanceID)
          The method used to iterate over the context tree.
 java.lang.String getNextContextVertical(java.lang.String parentInstanceID, java.lang.String childInstanceID)
          The method used to iterate over the context tree.
static java.lang.String getParentID(java.lang.String childInstanceID)
          Return the parent instance ID.
static Context getRootContext()
          Get the context of the root context.
static java.lang.String getRootContextInstanceID()
          Get the instance ID of the root context.
 java.lang.String getTagName(java.lang.String instanceID)
          Returns a String used by the externalizer.
 java.lang.String getTypeName(java.lang.String instanceID)
          Get the type name of the context specified by the parameter instanceID.
static void InitContext(Context aContext, java.lang.String contextName, java.lang.String typeName, java.lang.String parentID, java.lang.String newInstanceID, boolean isRoot)
          Creates a new CHAInstanceMemoryFactory Entity based on a context name, and the following optional params: type name parent CHAInstanceMemoryFactory remote interface The name specified in the context name must exist in the external XML definiton files.
 boolean isAddToDynamicKColl(java.lang.String instanceID)
          Returns the value of the addToDynamicKColl property.
 boolean isChained(java.lang.String instanceID)
          return true/false based on the existence of a parent ID
 boolean isReadOnly(java.lang.String instanceID)
          If the definition of this context in dsetxt.xml has the attribute readonly="true", this method will return true, otherwise, false is returned.
static boolean isRoot(java.lang.String instanceID)
          Judge if the context is a root context.
 Context newDynamicContext(java.lang.String contextName)
          Creates a new dynamic Local context with a supplied name.
 void prune(java.lang.String currentInstanceID)
          Removes this context and its children from the context tree.
 DataElement removeAt(java.lang.String instanceID, java.lang.String aCompositeKey)
          Removes aCompositeKey element of its keyedCollection.
 DataElement removeAtAnyLevel(java.lang.String instanceID, java.lang.String aCompositeKey)
          Removes an element of its keyedCollection, or the keyedCollections in the upper contexts, located in the aCompositeKey path.
static void removeChild(java.lang.String childInstanceID)
          Remove the child-parent relationship of two contexts.
static void removeContext(java.lang.String instanceID)
          Remove the whole row of this context from DB.
 void setAddToDynamicKColl(java.lang.String instanceID, boolean newValue)
          Sets the value of the addToDynamicKColl property.
static void setContext(java.lang.String instanceID, Context aContext)
          Set a context object into the hashtable.
 void setKCollDynamic(java.lang.String instanceID, boolean aValue)
          Set the value to the attribute dynamic for the keyedCollection in this context.
 void setKeyedCollection(java.lang.String instanceID, java.io.Serializable akeyedCollection)
          set the context's KeyedCollection.
static void setName(java.lang.String instanceID, java.lang.String aContextName)
           
static void setParentID(java.lang.String childInstanceID, java.lang.String parentInstanceID)
          Establish the child-parent relationship
static void setRoot(java.lang.String instanceID)
          Set the instance ID of the root context.
static void setTypeName(java.lang.String instanceID, java.lang.String aTypeName)
           
 int setValueAt(java.lang.String instanceID, SortedTable aSortedTable)
          The function is similiar to setValueAt(String, Object) except that set pairs of keys and values stored in aSortedTable via one method.
 void setValueAt(java.lang.String instanceID, java.lang.String aKey, java.io.Serializable aValue)
          Adds a value to the Context Sets the value of the element of its keyedCollection, or keyedCollections of the upper contexts, located in the aCompositeKey path.
 Vector toStrings(java.lang.String instanceID)
          Returns a visual representation of this context.
 int trySetElementAt(java.lang.String instanceID, java.lang.String aCompositeKey, java.io.Serializable aValue)
          Set the value of the element of its keyedCollection, or keyedCollections of the upper contexts which is located at aCompositeKey path.
 void unchain(java.lang.String instanceID)
          Removes this context and all its children from the context tree.
 void updateEntityCache()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
See Also:
Constant Field Values
Constructor Detail

CHAInstanceDBFactory

public CHAInstanceDBFactory()
Method Detail

getContext

public static Context getContext(java.lang.String instanceID)
                          throws CHAPersistenceException
Get the context object according to the instanceID.

Parameters:
instanceID -
Returns:
a context instance
Throws:
CHAPersistenceException

getContextForCommit

protected static Context getContextForCommit(java.lang.String instanceID)
                                      throws CHAPersistenceException
get context from DB.

Parameters:
instanceID - specifing the context
Throws:
CHAPersistenceException

setContext

public static void setContext(java.lang.String instanceID,
                              Context aContext)
                       throws CHAPersistenceException
Set a context object into the hashtable.

Parameters:
instanceID -
aContext -
Throws:
CHAPersistenceException

addElement

public void addElement(java.lang.String instanceID,
                       java.io.Serializable anElement)
                throws CHAPersistenceException
Adds an element to the Context

Parameters:
instanceID -
anElement -
Throws:
CHAPersistenceException

isRoot

public static boolean isRoot(java.lang.String instanceID)
                      throws CHAPersistenceException
Judge if the context is a root context.

Parameters:
instanceID -
Returns:
true if the context is a root context.
Throws:
CHAPersistenceException

getParentID

public static java.lang.String getParentID(java.lang.String childInstanceID)
                                    throws CHAPersistenceException
Return the parent instance ID.

Parameters:
childInstanceID -
Returns:
the parent instance ID.
Throws:
CHAPersistenceException

setParentID

public static void setParentID(java.lang.String childInstanceID,
                               java.lang.String parentInstanceID)
                        throws CHAPersistenceException
Establish the child-parent relationship

Parameters:
childInstanceID -
parentInstanceID -
Throws:
CHAPersistenceException

chainTo

public static void chainTo(java.lang.String instanceID,
                           java.lang.String parentInstanceID)
                    throws CHAPersistenceException
Chains this context to the context named specified by parentInstanceID. This method throws an CHAPersistenceException if this context does not exist.

Throws:
CHAPersistenceException

isChained

public boolean isChained(java.lang.String instanceID)
                  throws CHAPersistenceException
return true/false based on the existence of a parent ID

Parameters:
instanceID -
Returns:
Throws:
CHAPersistenceException

setAddToDynamicKColl

public void setAddToDynamicKColl(java.lang.String instanceID,
                                 boolean newValue)
                          throws CHAPersistenceException
Sets the value of the addToDynamicKColl property.

Parameters:
instanceID -
newValue - The new value of the property.
Throws:
CHAPersistenceException

setValueAt

public void setValueAt(java.lang.String instanceID,
                       java.lang.String aKey,
                       java.io.Serializable aValue)
                throws CHAPersistenceException
Adds a value to the Context Sets the value of the element of its keyedCollection, or keyedCollections of the upper contexts, located in the aCompositeKey path. When the KeyedCollection of the Context is dynamic, this method has different behavior depending on value of addToDynamicKColl property. If addToDynamicKColl is false, this method first looks for the aCompositekey element in the hierarchy. If the method finds it, the method modifies its value. If the method does not find the element, the method creates it dynamically. When addToDynamicKColl is true, this method either creates a new element in the current context or overwrites the existing element without checking the existence of the element in upper contexts.

Parameters:
instanceID -
aKey -
aValue -
Throws:
CHAPersistenceException

trySetElementAt

public int trySetElementAt(java.lang.String instanceID,
                           java.lang.String aCompositeKey,
                           java.io.Serializable aValue)
                    throws CHAPersistenceException
Set the value of the element of its keyedCollection, or keyedCollections of the upper contexts which is located at aCompositeKey path. If the dataElement can be found in the current context or its upper contexts, set its value and return int 1. Otherwise, return -1 saying this dataElement does not exist.

Parameters:
instanceID -
aCompositeKey -
aValue -
Returns:
Throws:
CHAPersistenceException

getElementAt

public java.io.Serializable getElementAt(java.lang.String instanceID,
                                         java.lang.String aCompositeKey,
                                         boolean isReadOnly)
                                  throws CHAPersistenceException
Returns the element of its keyedCollection,or keyedCollections of the upper contexts which is located at aCompositeKey path.

Parameters:
instanceID -
aCompositeKey -
isReadOnly -
Returns:
Throws:
CHAPersistenceException

setKeyedCollection

public void setKeyedCollection(java.lang.String instanceID,
                               java.io.Serializable akeyedCollection)
                        throws CHAPersistenceException
set the context's KeyedCollection. Warning: parameter value can be large. Also any existing keyedCollection in the Context object is immediately replaced.

Parameters:
instanceID -
akeyedCollection -
Throws:
CHAPersistenceException

clearKeyedCollection

public void clearKeyedCollection(java.lang.String instanceID)
                          throws CHAPersistenceException
Clears the context (current level only) by destroying the current keyed collection associated and replacing it with a new one.

Parameters:
instanceID -
Throws:
CHAPersistenceException

clearKeyedCollection

public void clearKeyedCollection(java.lang.String instanceID,
                                 boolean keepKCollStatus,
                                 boolean clearOnlyValues)
                          throws CHAPersistenceException
This method clears both the typed and non-typed elements in the context keyed collection. It can clear only the elements of the kColl and keep the kColl attributes. For the kColl elements it is possible to clear only the values or to clear all the attributes.

Parameters:
keepKCollStatus - boolean (false - clear also the context kColl attributes; true - keep the context kColl attributes and clear only the kColl data elements)
clearOnlyValues - boolean (false - clear all attributes of the context kColl data elements; true - clear only kColl data elements values)
Throws:
java.io.IOException - - If keepKCollStatus or clearOnlyValues are false and the keyed collection has not been defined in the generic data file or in the generic types file
CHAPersistenceException

fields

public Vector fields(java.lang.String instanceID)
              throws CHAPersistenceException
Returns all the data fields, which are addressable from this context. This includes all the data fields of this context and the upper context.

Returns:
Vector
Throws:
CHAPersistenceException

getKeyedCollection

public KeyedCollection getKeyedCollection(java.lang.String instanceID)
                                   throws CHAPersistenceException
Returns the keyedCollection attribute.

Parameters:
instanceID -
Returns:
Throws:
CHAPersistenceException

getAncestorByName

public java.lang.String getAncestorByName(java.lang.String instanceID,
                                          java.lang.String aContextName)
                                   throws CHAPersistenceException
Searches the context tree for an ancestor Context named aContextName and returns the first matching context.

Parameters:
aContextName - java.lang.String
Returns:
String instanceID
Throws:
CHAPersistenceException

getTypeName

public java.lang.String getTypeName(java.lang.String instanceID)
                             throws CHAPersistenceException
Get the type name of the context specified by the parameter instanceID.

Parameters:
instanceID -
Returns:
Throws:
CHAPersistenceException

getContextByType

public java.lang.String getContextByType(java.lang.String instanceID,
                                         java.lang.String aTypeName)
                                  throws CHAPersistenceException
Returns the instanceID of the first context that matches its type to aTypeName.

Parameters:
instanceID -
aTypeName -
Returns:
Throws:
CHAPersistenceException

isAddToDynamicKColl

public boolean isAddToDynamicKColl(java.lang.String instanceID)
                            throws CHAPersistenceException
Returns the value of the addToDynamicKColl property.

Parameters:
instanceID -
Returns:
Throws:
CHAPersistenceException

toStrings

public Vector toStrings(java.lang.String instanceID)
                 throws CHAPersistenceException
Returns a visual representation of this context.

Returns:
Vector
Throws:
CHAPersistenceException

getTagName

public java.lang.String getTagName(java.lang.String instanceID)
                            throws CHAPersistenceException
Returns a String used by the externalizer.

Parameters:
instanceID -
Returns:
Throws:
CHAPersistenceException

unchain

public void unchain(java.lang.String instanceID)
             throws CHAPersistenceException
Removes this context and all its children from the context tree. Also maintains the consistency of the context tree.

Parameters:
instanceID -
Throws:
CHAPersistenceException

removeChild

public static void removeChild(java.lang.String childInstanceID)
                        throws CHAPersistenceException
Remove the child-parent relationship of two contexts.

Parameters:
instanceID -
Throws:
CHAPersistenceException

removeContext

public static void removeContext(java.lang.String instanceID)
                          throws CHAPersistenceException
Remove the whole row of this context from DB.

Parameters:
instanceID - specifing the context
Throws:
CHAPersistenceException

setKCollDynamic

public void setKCollDynamic(java.lang.String instanceID,
                            boolean aValue)
                     throws CHAPersistenceException
Set the value to the attribute dynamic for the keyedCollection in this context.

Parameters:
instanceID -
aValue -
Throws:
CHAPersistenceException

removeAt

public DataElement removeAt(java.lang.String instanceID,
                            java.lang.String aCompositeKey)
                     throws CHAPersistenceException
Removes aCompositeKey element of its keyedCollection.

Parameters:
instanceID -
aCompositeKey -
Returns:
Throws:
CHAPersistenceException

removeAtAnyLevel

public DataElement removeAtAnyLevel(java.lang.String instanceID,
                                    java.lang.String aCompositeKey)
                             throws CHAPersistenceException
Removes an element of its keyedCollection, or the keyedCollections in the upper contexts, located in the aCompositeKey path.

Parameters:
instanceID -
aCompositeKey -
Returns:
Throws:
CHAPersistenceException

setValueAt

public int setValueAt(java.lang.String instanceID,
                      SortedTable aSortedTable)
               throws CHAPersistenceException
The function is similiar to setValueAt(String, Object) except that set pairs of keys and values stored in aSortedTable via one method. Behind this method, when this context is a distributed context, the pairs of keys and values stored in aSortedTable will be sent to CHA server a time, thus improving performance.

Parameters:
instanceID -
aSortedTable -
Returns:
int = 0 : success int = 1,2,...,n: a value is failed to set which is indicated by return int value. For example, if return value is 1, the first value in aSortedTable can not be set successfully. if return value is 2, the first value is set successfully, but the second value is failed to be set and subsequent pairs of the keys and values will not be set .
Throws:
CHAPersistenceException

isReadOnly

public boolean isReadOnly(java.lang.String instanceID)
                   throws CHAPersistenceException
If the definition of this context in dsetxt.xml has the attribute readonly="true", this method will return true, otherwise, false is returned.

Parameters:
instanceID -
Returns:
Throws:
CHAPersistenceException

getLevel

public java.lang.String getLevel(java.lang.String instanceID)
                          throws CHAPersistenceException
We can define an attribute --level-- in dsectxt.xml file to indicate level of the context. The context can be devided into three levels:root, session, normal.

Parameters:
instanceID -
Returns:
"root", "normal". If this attribute is not difined, return null ;
Throws:
CHAPersistenceException

getRootContextInstanceID

public static java.lang.String getRootContextInstanceID()
                                                 throws CHAPersistenceException
Get the instance ID of the root context.

Returns:
Throws:
CHAPersistenceException

getRootContext

public static Context getRootContext()
                              throws CHAPersistenceException
Get the context of the root context.

Returns:
Throws:
CHAPersistenceException

setRoot

public static void setRoot(java.lang.String instanceID)
                    throws CHAPersistenceException
Set the instance ID of the root context.

Parameters:
string -
Throws:
CHAPersistenceException

getChildren

public static Vector getChildren(java.lang.String instanceID)
                          throws CHAPersistenceException
Return the children of the context

Parameters:
parentInstanceID -
Returns:
the children of the context
Throws:
CHAPersistenceException

getChildrenAtAnyLevel

public Vector getChildrenAtAnyLevel(java.lang.String currentInstanceID)
                             throws CHAPersistenceException
Get the children of a remote context at any level from the context tree.

Parameters:
currentInstanceID -
Returns:
Throws:
CHAPersistenceException

InitContext

public static void InitContext(Context aContext,
                               java.lang.String contextName,
                               java.lang.String typeName,
                               java.lang.String parentID,
                               java.lang.String newInstanceID,
                               boolean isRoot)
                        throws CHAPersistenceException
Creates a new CHAInstanceMemoryFactory Entity based on a context name, and the following optional params: type name parent CHAInstanceMemoryFactory remote interface The name specified in the context name must exist in the external XML definiton files.

Parameters:
aContext -
contextName -
typeName -
parentContext -
newInstanceID -
Throws:
CHAPersistenceException

newDynamicContext

public Context newDynamicContext(java.lang.String contextName)
                          throws CHAPersistenceException
Creates a new dynamic Local context with a supplied name. The Context is created based on external definitions If the supplied name is given, it is created from the server-side external definitions. If no name is given, it will return null.

Parameters:
contextName -
location -
Returns:
Throws:
CHAPersistenceException

prune

public void prune(java.lang.String currentInstanceID)
           throws CHAPersistenceException
Removes this context and its children from the context tree.

Parameters:
currentInstanceID -
Throws:
CHAPersistenceException

getContextNamed

public java.lang.String getContextNamed(java.lang.String contextName)
                                 throws CHAPersistenceException
Searches the context tree from the root context for a context named aContextName

Parameters:
contextName -
Returns:
Throws:
CHAPersistenceException

getNextContextHorizontal

public java.lang.String getNextContextHorizontal(java.lang.String currentInstanceID)
                                          throws CHAPersistenceException
The method used to iterate over the context tree.

Parameters:
currentInstanceID -
Returns:
Throws:
CHAPersistenceException

getNextContextVertical

public java.lang.String getNextContextVertical(java.lang.String parentInstanceID,
                                               java.lang.String childInstanceID)
                                        throws CHAPersistenceException
The method used to iterate over the context tree.

Parameters:
parentInstanceID -
childInstanceID -
Returns:
Throws:
CHAPersistenceException

addChild

public void addChild(java.lang.String childInstanceID,
                     java.lang.String instanceID)
              throws CHAPersistenceException
Adds a child specified by the parameter to the children list of current context.

Parameters:
childInstanceID -
Throws:
CHAPersistenceException

containsChild

public boolean containsChild(java.lang.String instanceID,
                             java.lang.String aContextName)
                      throws CHAPersistenceException
Returns true if this context has a child with the name aContextName. It returns false otherwise.

Parameters:
instanceID -
aContextName -
Returns:
Throws:
CHAPersistenceException

updateEntityCache

public void updateEntityCache()

getCHAInstanceLocal

public static CHAInstanceLocal getCHAInstanceLocal(java.lang.String instanceID)
                                            throws CHAPersistenceException
Throws:
CHAPersistenceException

setName

public static void setName(java.lang.String instanceID,
                           java.lang.String aContextName)
                    throws CHAPersistenceException
Parameters:
instanceID -
aContextName -
Throws:
CHAPersistenceException

setTypeName

public static void setTypeName(java.lang.String instanceID,
                               java.lang.String aTypeName)
                        throws CHAPersistenceException
Parameters:
instanceID -
aContextName -
Throws:
CHAPersistenceException

IBM Bank Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2008