edu.iris.dmc.pdcc.director
Class PdccDbImportDirector

java.lang.Object
  extended byedu.iris.Fissures.seed.director.ImportDirector
      extended byedu.iris.dmc.pdcc.director.PdccDbImportDirector

public class PdccDbImportDirector
extends ImportDirector

Import Director class for importing data from a database following the PDCC schema.

Version:
06/30/2004
Author:
Robert Casey, IRIS DMC

Field Summary
 
Fields inherited from class edu.iris.Fissures.seed.director.ImportDirector
builder, fixedRecordLength, inStream, maxRecordLength, outputString, readBuffer, recCount, recLen, record, recordOffset, streamOpen
 
Constructor Summary
PdccDbImportDirector()
          This variant is not used and is only indicated for compatibility with its superclass.
PdccDbImportDirector(ObjectBuilder builder)
          This variant is not used and is only indicated for compatibility with its superclass.
PdccDbImportDirector(ObjectBuilder builder, java.lang.String configFile, java.lang.String sessionConfigName, PdccTableContainer tblContainer)
          Same as previous except that the field mapper object is not indicated and must be specified after instantiation with assignFieldMapper().
PdccDbImportDirector(ObjectBuilder builder, java.lang.String configFile, java.lang.String sessionConfigName, PdccTableContainer tblContainer, FieldMapper mapper)
          Same as previous except that the database configuration is not indicated, so a default database configuration, determined by the session configuration name.
PdccDbImportDirector(ObjectBuilder builder, java.lang.String configFile, java.lang.String sessionConfigName, java.lang.String dbConfigName, PdccTableContainer tblContainer, FieldMapper mapper)
          Create director that registers to an indicated Object Builder, uses the configuration in the indicated file, uses the configuration from the indicated session name, connects to the database using the configuration identified by the database configuration name, and maps to objects using the indicated field mapper object.
 
Method Summary
 void assignFieldMapper(FieldMapper mapper)
          used to establish the specific concrete mapper class which should be in line with the object builder.
 int build()
          Prepare a call to the registered builder to construct an object.
 int build(FieldMapper mapper)
          Prepare a call to the registered builder to construct an object.
 int construct(int categoryNum)
          Constructs all objects from the database pertaining to a particular category number.
 int construct(edu.iris.dmc.pdcc.director.PdccDbImportDirector.PdccQueryBlock queryObj)
          Constructs objects from the database query process.
 int construct(edu.iris.dmc.pdcc.director.PdccDbImportDirector.PdccQueryBlock queryObj, boolean getChildren)
          Constructs objects from the database query process.
 int construct(java.lang.String tableName, int keyNum)
          Constructs objects from the database query process.
 int constructChildren(PdccObject parentObj)
          Accepts a PdccObject as the parent object...children will be loaded as relates to this parent.
 int constructChildren(java.lang.String parentTableName, int parentPKey, int parentLookupId, boolean setParent)
          Construct child tables from the database which point to the parent table in parentTableName with primary key equal to parentPKey.
 java.lang.String getQuerySortString(java.lang.String tableName)
          Return an ORDER BY string that consists of the prominent blockette fields in the listed order as provided by PdccObjectLabelMap.getFieldLabels(int blkType).
 int getRecLen()
          This is an implementation of an abstract method.
static void main(java.lang.String[] args)
          Main method for testing.
 
Methods inherited from class edu.iris.Fissures.seed.director.ImportDirector
assignBuilder, close, construct, construct, getBuilder, open, read, read, setRecLen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PdccDbImportDirector

public PdccDbImportDirector(ObjectBuilder builder,
                            java.lang.String configFile,
                            java.lang.String sessionConfigName,
                            java.lang.String dbConfigName,
                            PdccTableContainer tblContainer,
                            FieldMapper mapper)
                     throws java.lang.Exception
Create director that registers to an indicated Object Builder, uses the configuration in the indicated file, uses the configuration from the indicated session name, connects to the database using the configuration identified by the database configuration name, and maps to objects using the indicated field mapper object.


PdccDbImportDirector

public PdccDbImportDirector(ObjectBuilder builder,
                            java.lang.String configFile,
                            java.lang.String sessionConfigName,
                            PdccTableContainer tblContainer,
                            FieldMapper mapper)
                     throws java.lang.Exception
Same as previous except that the database configuration is not indicated, so a default database configuration, determined by the session configuration name.


PdccDbImportDirector

public PdccDbImportDirector(ObjectBuilder builder,
                            java.lang.String configFile,
                            java.lang.String sessionConfigName,
                            PdccTableContainer tblContainer)
                     throws java.lang.Exception
Same as previous except that the field mapper object is not indicated and must be specified after instantiation with assignFieldMapper().


PdccDbImportDirector

public PdccDbImportDirector(ObjectBuilder builder)
This variant is not used and is only indicated for compatibility with its superclass.


PdccDbImportDirector

public PdccDbImportDirector()
This variant is not used and is only indicated for compatibility with its superclass.

Method Detail

assignFieldMapper

public void assignFieldMapper(FieldMapper mapper)
used to establish the specific concrete mapper class which should be in line with the object builder.


construct

public int construct(int categoryNum)
              throws java.lang.Exception
Constructs all objects from the database pertaining to a particular category number.

Throws:
java.lang.Exception

construct

public int construct(java.lang.String tableName,
                     int keyNum)
              throws java.lang.Exception
Constructs objects from the database query process. Construct objects based on the indicated database table name and id reference number. If reference number is negative, then ignore and load all from tableName. Returns the number of database records read. This is an overload of the method(s) found in the abstract superclass.

Throws:
java.lang.Exception

construct

public int construct(edu.iris.dmc.pdcc.director.PdccDbImportDirector.PdccQueryBlock queryObj)
              throws java.lang.Exception
Constructs objects from the database query process. Returns the number of database records read. This is an overload of the method(s) found in the abstract superclass.

Throws:
java.lang.Exception

construct

public int construct(edu.iris.dmc.pdcc.director.PdccDbImportDirector.PdccQueryBlock queryObj,
                     boolean getChildren)
              throws java.lang.Exception
Constructs objects from the database query process. Returns the number of database records read. Set getChildren flag to true if you want the children to be recursively loaded as well. This is an overload of the method(s) found in the abstract superclass.

Throws:
java.lang.Exception

constructChildren

public int constructChildren(java.lang.String parentTableName,
                             int parentPKey,
                             int parentLookupId,
                             boolean setParent)
                      throws java.lang.Exception
Construct child tables from the database which point to the parent table in parentTableName with primary key equal to parentPKey. However, we must ignore the tables which are repeat tables, so check against the blockette types. In order to ensure that we connect the child with the parent when running construct(), we need to assert the parent's lookupId. If the parent needs to be reasserted with the SeedObjectContainer because of intermittent container activity, then flag setParent to true. Otherwise, set to false in the interest of speed.

Throws:
java.lang.Exception

constructChildren

public int constructChildren(PdccObject parentObj)
                      throws java.lang.Exception
Accepts a PdccObject as the parent object...children will be loaded as relates to this parent.

Throws:
java.lang.Exception

build

public int build(FieldMapper mapper)
          throws java.lang.Exception
Prepare a call to the registered builder to construct an object. Make use of provided field mapper to assign the field values. Returns the lookup ID number of the created object.

Throws:
java.lang.Exception

build

public int build()
          throws java.lang.Exception
Prepare a call to the registered builder to construct an object. Makes use of global field mapper to assign the field values. Returns the lookup ID number of the created object. This is an implementation of an abstract method.

Specified by:
build in class ImportDirector
Throws:
java.lang.Exception

getRecLen

public int getRecLen()
              throws java.lang.Exception
This is an implementation of an abstract method. Nothing is performed here.

Specified by:
getRecLen in class ImportDirector
Throws:
java.lang.Exception

getQuerySortString

public java.lang.String getQuerySortString(java.lang.String tableName)
                                    throws java.lang.Exception
Return an ORDER BY string that consists of the prominent blockette fields in the listed order as provided by PdccObjectLabelMap.getFieldLabels(int blkType).

Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
Main method for testing.



brought to you by Incorporated Research Institutions for Seismology
June 29 2006