edu.indiana.dde.mylead.dai
Class MyLeadBuilder

java.lang.Object
  extended by edu.indiana.dde.mylead.dai.MyLeadBuilder

public class MyLeadBuilder
extends java.lang.Object


Field Summary
protected static java.lang.String DN_TAG_NAME
           
protected static int LOCK_RETRY
           
protected  int mBadAttr
           
protected  int mBadElements
           
protected  int mTotalAttr
           
protected  javax.xml.transform.TransformerFactory mTransFactory
           
protected  int mUserId
           
protected  javax.xml.transform.Transformer mXslTransformer
           
protected static int SQL_RETRY
           
 
Constructor Summary
MyLeadBuilder(java.sql.Connection dbConnect, OrderedTimerLog timerLog, boolean attrOnly)
          Constructor
 
Method Summary
protected  ReturnType addAttrClobs(org.w3c.dom.Element result, java.util.ArrayList queryables, java.lang.String globalId, long objId, int objTypeId, int clobBase)
          This method is used to process metadata attribute nodes in the schema, adding the CLOBs to the database and putting the queryable metadata attributes into the queryables parameter with the position in the list indicating the CLOB ID (adjusted by the clobBase).
protected  ReturnType addQueryableAttr(java.util.ArrayList queryables, java.lang.String globalId, long objId, int objTypeId, int clobBase, int attrBase)
          This method is used to process metadata attribute nodes in the schema.
protected  ReturnType createObject(java.lang.String dn, int userId, java.lang.String nodeXml, java.lang.String objType, edu.indiana.dde.mylead.dai.Parent myParent)
          Used to create a new object (file or collection).
protected  int getAttrCount()
          Returns the total number of attributes processed (based on the number of CLOBs).
protected  int getBadAttrCount()
          Returns the total number of queryable attributes that could not be inserted.
protected  int getBadElementCount()
          Returns the total number of elements in queryable attributes that could not be inserted.
protected  void resetCounter()
          Resets the total attributes, bad attribute, and bad element counters to zero.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCK_RETRY

protected static final int LOCK_RETRY
See Also:
Constant Field Values

SQL_RETRY

protected static final int SQL_RETRY
See Also:
Constant Field Values

DN_TAG_NAME

protected static final java.lang.String DN_TAG_NAME
See Also:
Constant Field Values

mTransFactory

protected javax.xml.transform.TransformerFactory mTransFactory

mXslTransformer

protected javax.xml.transform.Transformer mXslTransformer

mUserId

protected int mUserId

mTotalAttr

protected int mTotalAttr

mBadAttr

protected int mBadAttr

mBadElements

protected int mBadElements
Constructor Detail

MyLeadBuilder

public MyLeadBuilder(java.sql.Connection dbConnect,
                     OrderedTimerLog timerLog,
                     boolean attrOnly)
              throws uk.org.ogsadai.common.exception.engine.activity.ActivityUserException,
                     uk.org.ogsadai.common.exception.engine.activity.ActivitySystemException
Constructor

Parameters:
dbConnect - The activity's connection to the database.
timerLog - Instance of OrderedTimerLog class which wraps a logger that logss an ordered list of messages and the time received.
attrOnly - If the builder is being used only to insert attributes for existing objects, then the transformer does not need to be set up.
Throws:
uk.org.ogsadai.common.exception.engine.activity.ActivitySystemException - If there is a problem constructing the activity due to an implementation error or OGSA-DAI confguration problem.
uk.org.ogsadai.common.exception.engine.activity.ActivityUserException - If there is a problem constructing the activity due to a user mistake such as an invalid setting.
Method Detail

resetCounter

protected void resetCounter()
Resets the total attributes, bad attribute, and bad element counters to zero.


getAttrCount

protected int getAttrCount()
Returns the total number of attributes processed (based on the number of CLOBs).


getBadAttrCount

protected int getBadAttrCount()
Returns the total number of queryable attributes that could not be inserted. The CLOBs must have successfully been inserted for these attributes.


getBadElementCount

protected int getBadElementCount()
Returns the total number of elements in queryable attributes that could not be inserted. The CLOBs must have successfully been inserted for these attributes these attributes belong to.


createObject

protected ReturnType createObject(java.lang.String dn,
                                  int userId,
                                  java.lang.String nodeXml,
                                  java.lang.String objType,
                                  edu.indiana.dde.mylead.dai.Parent myParent)
Used to create a new object (file or collection). This routine is passed an object's LEAD schema node as an XML fragment and a Parent object that contains the parent object's internal ID and numeric type. If there is no parent, then null can be passed for the Parent object. The object, along with any attributes contained within are created. If the object could be created, then this routine returns OPERATION_SUCCESSFUL. Any errors adding queryable attributes are logged, but do not cause a failure - the object will still be created to the extent possible. If the attribute CLOBs could not be inserted then this fails to insert the object since an incomplete or invalid metadata document would then exist in the database if it did not fail.

Parameters:
dn - String with the distinguished name of the user creating the object. Since userId must also be passed, this is only needed for logging.
userId - Internal ID for the user represented by the dn parameter.
nodeXml - String with the XML fragment from the OGSA-DAI perform document containing the LEAD schema resource for the object to be created.
objType - String with the type of the collection or file.
myParent - A Parent object with the internal ID and type of the object's parent object. If there is no parent (top-level object) then can be null.
Returns:
ReturnType indicates success or failure:
OPERATION_SUCCESSFUL or MCS_INTERNAL_ERROR

addAttrClobs

protected ReturnType addAttrClobs(org.w3c.dom.Element result,
                                  java.util.ArrayList queryables,
                                  java.lang.String globalId,
                                  long objId,
                                  int objTypeId,
                                  int clobBase)
This method is used to process metadata attribute nodes in the schema, adding the CLOBs to the database and putting the queryable metadata attributes into the queryables parameter with the position in the list indicating the CLOB ID (adjusted by the clobBase). It is assumed that this method call will be wrapped in a transaction by the caller and rolled back if the return value is not OPERATION_SUCCESSFUL. The clobs either all are added or all fail, so there is no need to count how many succeeded or failed to be inserted. Parameters:

Parameters:
result - DOM Element Node that is the root for an insert
globalId - String containing the globally unique ID for the object
objId - long int with the internal ID of the object attributes are being added to
objTypeId - int with internal ID of the object type (file, collection, etc.)
clobBase - int with first clob ID to use - for new objects always 1
Returns:
ReturnType with the status of the inserts

addQueryableAttr

protected ReturnType addQueryableAttr(java.util.ArrayList queryables,
                                      java.lang.String globalId,
                                      long objId,
                                      int objTypeId,
                                      int clobBase,
                                      int attrBase)
This method is used to process metadata attribute nodes in the schema. The arrayList passed as a parameter contains the queryable metadata attributes and the position in the list is the CLOB id (adjusted by the clobBase). At this point, all of the top-level attribute nodes are now in the queryables array list. We process this list adding any subattributes to the end of the list and putting each attribute and its elements in the insert strings. All elements go in one string that will be used with all data types, but attributes are put in an arraylist with top level attributes at index 0, the first level of subattributes at index 1, and so on. The CLOBs will have already been successfully added and committed to the database. Parameters:

Parameters:
queryables - ArrayList with the shredded metadata attributes to be added.
globalId - String containing the globally unique ID for the object
objId - long int with the internal ID of the object attributes are being added to
objTypeId - int with internal ID of the object type (file, collection, etc.)
clobBase - int with first clob ID to use - for new objects always 1
attrBase - int with first attribute ID to use - for new objects always 1
Returns:
ReturnType with the status of the inserts