SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

com.solarmetric.rd.kodo.impl.jdbc.meta
Class MappingTool

java.lang.Object
  |
  +--com.solarmetric.rd.kodo.impl.jdbc.meta.MappingTool

public class MappingTool
extends java.lang.Object

Tool for manipulating class mappings and associated schema.


Field Summary
static java.lang.String ACTION_BUILD_SCHEMA
           
static java.lang.String ACTION_DROP
           
static java.lang.String ACTION_EXPORT
           
static java.lang.String ACTION_IMPORT
           
static java.lang.String ACTION_REFRESH
           
static java.lang.String ACTION_REVERT
           
static java.lang.String ACTION_VALIDATE
           
 
Constructor Summary
MappingTool(com.solarmetric.rd.kodo.impl.jdbc.conf.JDBCConfiguration conf)
          Constructor.
 
Method Summary
 void buildSchema(java.lang.Class cls)
          Update the schema to match the tables and columns dictated by the mappings.
 void clear()
          Reset the internal repository.
 void drop(java.lang.Class cls)
          Remove the given mapping from the list.
 java.io.Writer getMappingWriter()
          The stream to export the planned mappings to as an XML document.
 boolean getReadSchema()
          Set to false to prevent reading of the entire schema before mapping.
 com.solarmetric.rd.kodo.impl.jdbc.meta.MappingRepository getRepository()
          Return the repository to use to access mapping information.
 java.lang.String getSchemaAction()
          The schema modification policy.
 com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup getSchemaGroup()
          Return the schema group to use in mapping.
 com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaTool getSchemaTool()
          Return the schema tool to use for schema modification.
 java.io.Writer getSchemaWriter()
          The stream to export the planned schema to as an XML document.
static void main(java.lang.String[] args)
          Usage: java com.solarmetric.kodo.impl.jdbc.meta.MappingTool [option]* -action/-a <refresh | drop | validate | buildSchema | revert | import | export> <class name | .java file | .class file | .jdo file>+
 void record()
          Records the changes that have been made to both the mappings and the associated schema, and clears the tool for further use.
 void refresh(java.lang.Class cls)
          Refresh or add the mapping for the given instance.
 void revert(java.lang.Class cls)
          Revert the given mapping to its previous state.
static boolean run(com.solarmetric.rd.kodo.impl.jdbc.conf.JDBCConfiguration conf, java.lang.String action, java.lang.String[] args, java.io.Writer mappingWriter, java.lang.String schema, boolean dropTables, boolean ignoreErrors, boolean readSchema, java.io.Writer schemaWriter, java.lang.ClassLoader loader)
          Run the tool.
 void setMappingWriter(java.io.Writer mappingWriter)
          The stream to export the planned mappings to as an XML document.
 void setReadSchema(boolean readSchema)
          Set to false to prevent reading of the entire schema before mapping.
 void setRepository(com.solarmetric.rd.kodo.impl.jdbc.meta.MappingRepository repos)
          Set the repository to use to access mapping information.
 void setSchemaAction(java.lang.String schemaAction)
          The schema modification policy.
 void setSchemaGroup(com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup schema)
          Set the schema to use in mapping.
 void setSchemaTool(com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaTool tool)
          Set the schema tool to use for schema modification.
 void setSchemaWriter(java.io.Writer schemaWriter)
          The stream to export the planned schema to as an XML document.
 void validate(java.lang.Class cls)
          Validate the mappings for the given class and its fields.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_REFRESH

public static final java.lang.String ACTION_REFRESH
See Also:
Constant Field Values

ACTION_DROP

public static final java.lang.String ACTION_DROP
See Also:
Constant Field Values

ACTION_VALIDATE

public static final java.lang.String ACTION_VALIDATE
See Also:
Constant Field Values

ACTION_REVERT

public static final java.lang.String ACTION_REVERT
See Also:
Constant Field Values

ACTION_EXPORT

public static final java.lang.String ACTION_EXPORT
See Also:
Constant Field Values

ACTION_IMPORT

public static final java.lang.String ACTION_IMPORT
See Also:
Constant Field Values

ACTION_BUILD_SCHEMA

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

MappingTool

public MappingTool(com.solarmetric.rd.kodo.impl.jdbc.conf.JDBCConfiguration conf)
Constructor. Supply configuration.

Method Detail

getSchemaAction

public java.lang.String getSchemaAction()
The schema modification policy. Can be any of: Defaults to SchemaTool.ACTION_ADD.


setSchemaAction

public void setSchemaAction(java.lang.String schemaAction)
The schema modification policy. Can be any of: Defaults to SchemaTool.ACTION_ADD.


getReadSchema

public boolean getReadSchema()
Set to false to prevent reading of the entire schema before mapping. This option saves time, but is dangerous to use when adding new mappings, because without full knowledge of the existing schema the mapping tool might create tables or indexes that conflict with existing components.


setReadSchema

public void setReadSchema(boolean readSchema)
Set to false to prevent reading of the entire schema before mapping. This option saves time, but is dangerous to use when adding new mappings, because without full knowledge of the existing schema the mapping tool might create tables or indexes that conflict with existing components.


getSchemaTool

public com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaTool getSchemaTool()
Return the schema tool to use for schema modification.


setSchemaTool

public void setSchemaTool(com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaTool tool)
Set the schema tool to use for schema modification.


getSchemaWriter

public java.io.Writer getSchemaWriter()
The stream to export the planned schema to as an XML document. If non-null, then the database schema will not be altered.


setSchemaWriter

public void setSchemaWriter(java.io.Writer schemaWriter)
The stream to export the planned schema to as an XML document. If non-null, then the database schema will not be altered.


getMappingWriter

public java.io.Writer getMappingWriter()
The stream to export the planned mappings to as an XML document. If non-null, then the mapping repository will not be altered.


setMappingWriter

public void setMappingWriter(java.io.Writer mappingWriter)
The stream to export the planned mappings to as an XML document. If non-null, then the mapping repository will not be altered.


getRepository

public com.solarmetric.rd.kodo.impl.jdbc.meta.MappingRepository getRepository()
Return the repository to use to access mapping information. Defaults to a new MappingRepository.


setRepository

public void setRepository(com.solarmetric.rd.kodo.impl.jdbc.meta.MappingRepository repos)
Set the repository to use to access mapping information.


getSchemaGroup

public com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup getSchemaGroup()
Return the schema group to use in mapping. If none has been set, the schema will be generated from the database.


setSchemaGroup

public void setSchemaGroup(com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup schema)
Set the schema to use in mapping.


clear

public void clear()
Reset the internal repository. This is called automatically after every record().


record

public void record()
Records the changes that have been made to both the mappings and the associated schema, and clears the tool for further use. This also involves clearing the internal mapping repository.


refresh

public void refresh(java.lang.Class cls)
Refresh or add the mapping for the given instance.


drop

public void drop(java.lang.Class cls)
Remove the given mapping from the list.


revert

public void revert(java.lang.Class cls)
Revert the given mapping to its previous state.


validate

public void validate(java.lang.Class cls)
Validate the mappings for the given class and its fields.


buildSchema

public void buildSchema(java.lang.Class cls)
Update the schema to match the tables and columns dictated by the mappings. Note that this action cannot be combined with any others in a single record() invocation.


main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        java.sql.SQLException

Usage: java com.solarmetric.kodo.impl.jdbc.meta.MappingTool [option]* -action/-a <refresh | drop | validate | buildSchema | revert | import | export> <class name | .java file | .class file | .jdo file>+

Where the following options are recognized.

The various actions are as follows.

Each class supplied as an argument must have valid JDO metadata.

Examples:

java.io.IOException
java.sql.SQLException

run

public static boolean run(com.solarmetric.rd.kodo.impl.jdbc.conf.JDBCConfiguration conf,
                          java.lang.String action,
                          java.lang.String[] args,
                          java.io.Writer mappingWriter,
                          java.lang.String schema,
                          boolean dropTables,
                          boolean ignoreErrors,
                          boolean readSchema,
                          java.io.Writer schemaWriter,
                          java.lang.ClassLoader loader)
                   throws java.io.IOException,
                          java.sql.SQLException
Run the tool. Return false if an invalid option was given.

java.io.IOException
java.sql.SQLException

SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.