edu.iris.dmc.pdcc.builder
Class PdccDbExportBuilder

java.lang.Object
  extended byedu.iris.Fissures.seed.builder.ExportBuilder
      extended byedu.iris.dmc.pdcc.builder.PdccDbExportBuilder

public class PdccDbExportBuilder
extends ExportBuilder

Concrete Builder class for exporting Blockette objects from the SeedObjectContainer to the PDCC database schema.

Version:
2/17/2006
Author:
Robert Casey, IRIS DMC

Nested Class Summary
 
Nested classes inherited from class edu.iris.Fissures.seed.builder.ExportBuilder
ExportBuilder.LogicalRecord
 
Field Summary
 
Fields inherited from class edu.iris.Fissures.seed.builder.ExportBuilder
builderType, endOfGroup, endOfLogical, endOfPhysical, exportMold, exportScript, logicalPerPhysical, logicalRecord, logicalRecordCount, logicalRecordLength, logicalRecords, nestingDepth, nestingScore, outputStream, penDown, physicalRecordLength, recordPadding, scriptCursor, scriptNesting, vaxOrder
 
Constructor Summary
PdccDbExportBuilder(java.lang.String configFile, java.lang.String sessionConfigName, PdccTableContainer tblContainer)
          Instantiate without a pre-existing dbConfig name.
PdccDbExportBuilder(java.lang.String configFile, java.lang.String sessionConfigName, java.lang.String dbConfigName, PdccTableContainer tblContainer)
          Create an instance of the export builder.
 
Method Summary
protected  boolean checkTrigger(java.lang.String s)
          Implement export script triggers here.
 void deleteToTableContainer(Blockette blk)
          Pull back tables relating to the indicated blockette and mark them for deletion by the database on the next export/update call -- does not delete the table record (will happen after database update).
static void main(java.lang.String[] args)
          Command-line application interface for database export facilities.
protected  void packToRecord()
          Pack SQL statements for logical records for export to database.
protected  void padLogical()
          No function performed.
protected  void padPhysical()
          No function performed.
 void restoreToTableContainer(Blockette blk, int startField, int endField)
          DEPRECATED parameter variant turn off update flags for the indicated start and end field numbers used for repeat group restore actions
 void restoreToTableContainer(int blkType, int blkLookupId)
          turn off ALL update flags and restore db record object to it original state
 void restoreToTableContainer(int blkType, int blkLookupId, int startField, int endField)
          turn off update flags for the indicated start and end repeat field numbers.
 void setDefaultMode()
          Set up script pattern for playing out Blockette types to the database exporter.
protected  void startNewLogical(SeedObject obj, boolean continuation)
          Accept the incoming object, which is a PdccTableRecord, and write an SQL string to a new logical record, which is added to the logical record vector.
 void updateToTableContainer(Blockette blk, int fieldNum, int fieldIndex)
          Mark table record in table container for UPDATE query but ONLY if there is a db table object, otherwise nothing happens.
 void updateToTableContainer(Blockette blk, int fieldNum, int fieldIndex, char op)
          Mark table record in table container for UPDATE (u) or DELETE (d), depending on the operation character, but ONLY if there is a db table object, otherwise nothing happens.
protected  void volumeFinish()
          Perform finishing actions on the database export process.
 void writeToDb(boolean verboseFlag)
          Set up thread to turn output stream into SQL executions to the database.
 
Methods inherited from class edu.iris.Fissures.seed.builder.ExportBuilder
build, close, finish, getNext, getType, open, push, setLogicalRecLen, setPhysicalRecLen, setVaxOrder, startVolume, writeRecord
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PdccDbExportBuilder

public PdccDbExportBuilder(java.lang.String configFile,
                           java.lang.String sessionConfigName,
                           java.lang.String dbConfigName,
                           PdccTableContainer tblContainer)
                    throws java.lang.Exception
Create an instance of the export builder.

Parameters:
configFile - pathname of the PDCC configuration file
sessionConfigName - session config name
dbConfigName - database config name
tblContainer - instance of PdccTableContainer in current use by PDCC
Throws:
java.lang.Exception

PdccDbExportBuilder

public PdccDbExportBuilder(java.lang.String configFile,
                           java.lang.String sessionConfigName,
                           PdccTableContainer tblContainer)
                    throws java.lang.Exception
Instantiate without a pre-existing dbConfig name.

Parameters:
configFile - pathname of the PDCC configuration file
sessionConfigName - session config name
tblContainer - instance of PdccTableContainer in current use by PDCC
Throws:
java.lang.Exception
Method Detail

setDefaultMode

public void setDefaultMode()
Set up script pattern for playing out Blockette types to the database exporter. miniSEED files should have already been exported... so first, rewind export tempate...then get db table records related to the file placement...write to DB begin reading dictionary information...set up SQL fields...query for existing entry...generate update query if new...write to DB. next, read station information...write updates to DB. lastly, read event information...write udpates to DB.


writeToDb

public void writeToDb(boolean verboseFlag)
               throws java.lang.Exception
Set up thread to turn output stream into SQL executions to the database.

Parameters:
verboseFlag - set to true for SQL transaction verbosity
Throws:
java.lang.Exception

updateToTableContainer

public void updateToTableContainer(Blockette blk,
                                   int fieldNum,
                                   int fieldIndex)
                            throws java.lang.Exception
Mark table record in table container for UPDATE query but ONLY if there is a db table object, otherwise nothing happens. no updated values are transferred from the blockette until packToRecord() or updateRecord() is called. This preps fields for update, though.

Parameters:
blk - update to be marked for this blockete
fieldNum - update to be marked for this field number
fieldIndex - update to be marked for this field index
Throws:
java.lang.Exception

updateToTableContainer

public void updateToTableContainer(Blockette blk,
                                   int fieldNum,
                                   int fieldIndex,
                                   char op)
                            throws java.lang.Exception
Mark table record in table container for UPDATE (u) or DELETE (d), depending on the operation character, but ONLY if there is a db table object, otherwise nothing happens. packToRecord() sets up the actual SQL call for the update or delete operation. The delete operation should generally only be done for repeating field groups, which have child tables to be deleted but we don't want the entire blockette's contents wiped out.

Parameters:
blk - change flag for this blockette
fieldNum - change flag for this field number
fieldIndex - change flag for this field index
op - operation flag to be used ('u' or 'd')
Throws:
java.lang.Exception

deleteToTableContainer

public void deleteToTableContainer(Blockette blk)
                            throws java.lang.Exception
Pull back tables relating to the indicated blockette and mark them for deletion by the database on the next export/update call -- does not delete the table record (will happen after database update).

Parameters:
blk - this is the blockette being marked for deletion
Throws:
java.lang.Exception

restoreToTableContainer

public void restoreToTableContainer(Blockette blk,
                                    int startField,
                                    int endField)
                             throws java.lang.Exception
DEPRECATED parameter variant turn off update flags for the indicated start and end field numbers used for repeat group restore actions

Parameters:
blk - blockette having fields restored
startField - start field of the restoration
endField - end field of the restoration
Throws:
java.lang.Exception

restoreToTableContainer

public void restoreToTableContainer(int blkType,
                                    int blkLookupId,
                                    int startField,
                                    int endField)
                             throws java.lang.Exception
turn off update flags for the indicated start and end repeat field numbers. used for repeat group restore actions.

Parameters:
blkType - blockette type of the object being restored
blkLookupId - lookup ID of the object being restored
startField - beginning blockette field number of the repeat group
endField - ending blockette field number of the repeat group
Throws:
java.lang.Exception

restoreToTableContainer

public void restoreToTableContainer(int blkType,
                                    int blkLookupId)
                             throws ContainerException,
                                    PdccDbException
turn off ALL update flags and restore db record object to it original state

Parameters:
blkType - blockette type of the object being restored
blkLookupId - lookup ID of the object being restored
Throws:
ContainerException
PdccDbException

main

public static void main(java.lang.String[] args)
Command-line application interface for database export facilities.


padLogical

protected void padLogical()
No function performed. Overrides ExportBuilder method.

Overrides:
padLogical in class ExportBuilder

padPhysical

protected void padPhysical()
No function performed. Overrides ExportBuilder method.

Overrides:
padPhysical in class ExportBuilder

packToRecord

protected void packToRecord()
                     throws java.lang.Exception
Pack SQL statements for logical records for export to database. Update and create database table record objects for all blockettes in the export mold. Generate SQL from those record objects and write to Logical Records.

Specified by:
packToRecord in class ExportBuilder
Throws:
java.lang.Exception

checkTrigger

protected boolean checkTrigger(java.lang.String s)
                        throws java.lang.Exception
Implement export script triggers here.

Specified by:
checkTrigger in class ExportBuilder
Throws:
java.lang.Exception

volumeFinish

protected void volumeFinish()
                     throws BuilderException
Perform finishing actions on the database export process. This method serves to properly finish an SQL query stream and communicate to the supporting export thread that all query records have been placed on the LogicalRecords vector construct for JDBC execution. The writer thread is then reset when it signals its completion of the JDBC communications.

Specified by:
volumeFinish in class ExportBuilder
Throws:
BuilderException

startNewLogical

protected void startNewLogical(SeedObject obj,
                               boolean continuation)
                        throws java.lang.Exception
Accept the incoming object, which is a PdccTableRecord, and write an SQL string to a new logical record, which is added to the logical record vector. The continuation flag is not implemented. If the SQL string is blank, then do not create a new logical record.

Specified by:
startNewLogical in class ExportBuilder
Throws:
java.lang.Exception


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