Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.enableit.db.darrt
Class SchemaHandler  view SchemaHandler download SchemaHandler.java

java.lang.Object
  extended byorg.enableit.db.darrt.AbstractSchemaHandler
      extended byorg.enableit.db.darrt.SchemaHandler

public class SchemaHandler
extends AbstractSchemaHandler

The entry point or facade for the library. External tools should only need to access this class.

This class expects always to have a reference and a target schema. Sometimes they may be taken from the same XML file, as in the case of installing a .dar file. On other occasions they may be completly separate as with the case of comparing two online datasources.

Either schema may be specified in a range of ways such as by setting the URL where a darrt-schema document may be found, specifying online datasources or providing pre-instantiated object representations.


Field Summary
private static org.apache.log4j.Logger logger
          The Log4J Logger doing the logging.
 
Fields inherited from class org.enableit.db.darrt.AbstractSchemaHandler
 
Constructor Summary
SchemaHandler()
          Default constructor.
 
Method Summary
 void alterSchema()
          Compares the reference and target schemas, then modifies the target as necessary to match the reference.
 void alterSchemaScript()
           
 void changeTarget()
          Changes the target database defined by the reference schema XML document to the values held in the target provider.
private  void checkMandatory()
          Checks the mandatory properties have been set, so can continue.
 void createSchema()
          Creates the reference schema at the location identified first by the provider parameter or if null by the provider details inside the target schema.
 java.util.List diffSchemas()
          Returns the differences between the reference and target schemas as a List of DiffData objects.
private  void parseSchemas()
          /** Parses a schema.
private  void raiseEvent(int eventId, java.lang.Object eventBean)
          Notify listeners of the specified event.
 
Methods inherited from class org.enableit.db.darrt.AbstractSchemaHandler
addListener, addListeners, getDatabase, getDebug, getListeners, getOnlineRefSchema, getOnlineTargetSchema, getRefDatabase, getRefSchemaName, getRefSchemaUrl, getTablePattern, getTargetDatabase, getTargetSchemaUrl, setDebug, setOnlineRefSchema, setOnlineTargetSchema, setRefDatabase, setRefSchemaName, setRefSchemaUrl, setTablePattern, setTargetDatabase, setTargetSchemaUrl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static org.apache.log4j.Logger logger
The Log4J Logger doing the logging.

Constructor Detail

SchemaHandler

public SchemaHandler()
Default constructor.

Method Detail

parseSchemas

private void parseSchemas()
                   throws SchemaHandlingException
/** Parses a schema.


diffSchemas

public java.util.List diffSchemas()
                           throws SchemaHandlingException
Returns the differences between the reference and target schemas as a List of DiffData objects.

Overrides:
diffSchemas in class AbstractSchemaHandler

createSchema

public void createSchema()
                  throws SchemaHandlingException
Creates the reference schema at the location identified first by the provider parameter or if null by the provider details inside the target schema.

Note that if this method is used to create a schema in a database where any tables exist with the same names, then those tables will be modified to fit the reference schema.


alterSchema

public void alterSchema()
                 throws SchemaHandlingException
Compares the reference and target schemas, then modifies the target as necessary to match the reference.


changeTarget

public void changeTarget()
                  throws SchemaHandlingException
Changes the target database defined by the reference schema XML document to the values held in the target provider.


alterSchemaScript

public void alterSchemaScript()
                       throws SchemaHandlingException

checkMandatory

private void checkMandatory()
                     throws SchemaHandlingException
Checks the mandatory properties have been set, so can continue.


raiseEvent

private void raiseEvent(int eventId,
                        java.lang.Object eventBean)
Notify listeners of the specified event.