Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 3.0.3 generated on February 20 2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## kodo.jdbc.meta
Class MappingTool

    java.lang.Object
      |
      +--kodo.jdbc.meta.MappingTool

public class MappingTool
extends Object

Tool for manipulating class mappings and associated schema.

Field Summary
`static String` | `ACTION_BUILD_SCHEMA`
`static String` | `ACTION_DROP`
`static String` | `ACTION_EXPORT`
`static String` | `ACTION_IMPORT`
`static String` | `ACTION_REFRESH`
`static String` | `ACTION_REVERT`
`static String` | `ACTION_VALIDATE`

Constructor Summary
`MappingTool(JDBCConfiguration conf)` Constructor.

Method Summary
`void` | `buildSchema(Class cls)` Update the schema to match the tables and columns dictated by the mappings.
`void` | `clear()` Reset the internal repository.
`void` | `drop(Class cls)` Remove the given mapping from the list.
`boolean` | `getDropUnusedComponents()` Whether schema components that are unused by any mapping will be dropped from this tool's `#SchemaGroup`, and, depending on the schema action, from the database.
`boolean` | `getForeignKeys()` Return whether foreign keys should be manipulated.
`boolean` | `getIgnoreErrors()` Whether and SQL errors should cause a failure or just issue a warning.
`boolean` | `getIndexes()` Return whether indexes should be manipulated.
`Writer` | `getMappingWriter()` The stream to export the planned mappings to as an XML document.
`boolean` | `getPrimaryKeys()` Return whether primary keys should be generated.
`boolean` | `getReadSchema()` Set to true to read the entire schema before mapping.
`MappingRepository` | `getRepository()` Return the repository to use to access mapping information.
`String` | `getSchemaAction()` The schema modification policy.
`SchemaGroup` | `getSchemaGroup()` Return the schema group to use in mapping.
`SchemaTool` | `getSchemaTool()` Return the schema tool to use for schema modification.
`Writer` | `getSchemaWriter()` The stream to export the planned schema to as an XML document.
`static void` | `main(String[] args)` Usage: java kodo.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(Class cls)` Refresh or add the mapping for the given instance.
`void` | `revert(Class cls)` Revert the given mapping to its previous state.
`static boolean` | `run(JDBCConfiguration conf, String[] args, serp.util.Options opts)` Run the tool.
`static boolean` | `run(JDBCConfiguration conf, String action, String[] args, Writer mappingWriter, String schemaAction, boolean dropTables, boolean ignoreErrors, boolean readSchema, boolean pks, boolean fks, boolean indexes, Writer schemaWriter, ClassLoader loader)` Run the tool.
`void` | `setDropUnusedComponents(boolean dropUnused)` Whether schema components that are unused by any mapping will be dropped from this tool's `#SchemaGroup`, and, depending on the schema action, from the database.
`void` | `setForeignKeys(boolean fks)` Set whether foreign keys should be generated.
`void` | `setIgnoreErrors(boolean ignoreErrors)` Whether and SQL errors should cause a failure or just issue a warning.
`void` | `setIndexes(boolean indexes)` Set whether indexes should be manipulated.
`void` | `setMappingWriter(Writer mappingWriter)` The stream to export the planned mappings to as an XML document.
`void` | `setPrimaryKeys(boolean pks)` Set whether primary keys should be generated.
`void` | `setReadSchema(boolean readSchema)` Set to true to read the entire schema before mapping.
`void` | `setRepository(MappingRepository repos)` Set the repository to use to access mapping information.
`void` | `setSchemaAction(String schemaAction)` The schema modification policy.
`void` | `setSchemaGroup(SchemaGroup schema)` Set the schema to use in mapping.
`void` | `setSchemaTool(SchemaTool tool)` Set the schema tool to use for schema modification.
`void` | `setSchemaWriter(Writer schemaWriter)` The stream to export the planned schema to as an XML document.
`void` | `validate(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 String ACTION_REFRESH

### ACTION_DROP

    public static final String ACTION_DROP

### ACTION_VALIDATE

    public static final String ACTION_VALIDATE

### ACTION_REVERT

    public static final String ACTION_REVERT

### ACTION_EXPORT

    public static final String ACTION_EXPORT

### ACTION_IMPORT

    public static final String ACTION_IMPORT

### ACTION_BUILD_SCHEMA

    public static final String ACTION_BUILD_SCHEMA

Constructor Detail

### MappingTool

    public MappingTool(JDBCConfiguration conf)

  Constructor. Supply configuration.

Method Detail

### getSchemaAction

    public String getSchemaAction()

  The schema modification policy. Can be any of:
  - `SchemaTool.ACTION_ADD`
  - `SchemaTool.ACTION_REFRESH`
  - `SchemaTool.ACTION_RETAIN`
  - `none`
  Defaults to `SchemaTool.ACTION_ADD`.

### setSchemaAction

    public void setSchemaAction(String schemaAction)

  The schema modification policy. Can be any of:
  - `SchemaTool.ACTION_ADD`
  - `SchemaTool.ACTION_REFRESH`
  - `SchemaTool.ACTION_RETAIN`
  - `none`
  Defaults to `SchemaTool.ACTION_ADD`.

### getReadSchema

    public boolean getReadSchema()

  Set to true to read 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 true to read 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.

### getIndexes

    public boolean getIndexes()

  Return whether indexes should be manipulated. Defaults to true.

### setIndexes

    public void setIndexes(boolean indexes)

  Set whether indexes should be manipulated. Defaults to true.

### getForeignKeys

    public boolean getForeignKeys()

  Return whether foreign keys should be manipulated. Defaults to true.

### setForeignKeys

    public void setForeignKeys(boolean fks)

  Set whether foreign keys should be generated. Defaults to true.

### getPrimaryKeys

    public boolean getPrimaryKeys()

  Return whether primary keys should be generated. Defaults to true.

### setPrimaryKeys

    public void setPrimaryKeys(boolean pks)

  Set whether primary keys should be generated. Defaults to true.

### getDropUnusedComponents

    public boolean getDropUnusedComponents()

  Whether schema components that are unused by any mapping will be dropped from this tool's `#SchemaGroup`, and, depending on the schema action, from the database. Defaults to true.

### setDropUnusedComponents

    public void setDropUnusedComponents(boolean dropUnused)

  Whether schema components that are unused by any mapping will be dropped from this tool's `#SchemaGroup`, and, depending on the schema action, from the database. Defaults to true.

### setIgnoreErrors

    public void setIgnoreErrors(boolean ignoreErrors)

  Whether and SQL errors should cause a failure or just issue a warning.

### getIgnoreErrors

    public boolean getIgnoreErrors()

  Whether and SQL errors should cause a failure or just issue a warning.

### getSchemaTool

    public SchemaTool getSchemaTool()

  Return the schema tool to use for schema modification.

### setSchemaTool

    public void setSchemaTool(SchemaTool tool)

  Set the schema tool to use for schema modification.

### getSchemaWriter

    public 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(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 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(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 MappingRepository getRepository()

  Return the repository to use to access mapping information. Defaults to a new `MappingRepository`.

### setRepository

    public void setRepository(MappingRepository repos)

  Set the repository to use to access mapping information.

### getSchemaGroup

    public 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(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(Class cls)

  Refresh or add the mapping for the given instance.

### drop

    public void drop(Class cls)

  Remove the given mapping from the list.

### revert

    public void revert(Class cls)

  Revert the given mapping to its previous state.

### validate

    public void validate(Class cls)

  Validate the mappings for the given class and its fields.

### buildSchema

    public void buildSchema(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(String[] args)
                     throws IOException,
                            SQLException

  Usage: java kodo.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.

  - -properties/-p <properties file or resource>: The path or resource name of a Kodo properties file containing information such as the license key data as outlined in `JDOConfiguration`. Optional.
  - -<property name> <property value>: All bean properties of the Kodo `JDBCConfiguration` can be set by using their names and supplying a value. For example: `-licenseKey adslfja83r3lkadf`
  - -file/-f <stdout | output file or resource>: Use this option to write the planned mappings to an XML document rather than store them in the repository. This option also specifies the file to dump to if using the `export` action.
  - -schemaAction/-sa <add | refresh | retain | none>: The `add`, `refresh`, and `retain` actions correspond to the same-named actions in the `SchemaTool`. Unless you are running the mapping tool on all of your persistent types at once, it is strongly recommended that you use only the `add` action. Otherwise it is possible to drop schema components that are used by classes you aren't currently running the tool over. The action defaults to `add`.
  - -schemaFile/-sf <stdout | output file or resource>: Use this option to write the planned schema to an XML document rather than modify the data store.
  - -dropTables/-dt <true/t | false/f>: Corresponds to the same-named option in the `SchemaTool`.
  - -ignoreErrors/-i <true/t | false/f>: Corresponds to the same-named option in the `SchemaTool`.
  - -readSchema/-rs <true/t | false/f>: Set this to true to read the entire existing schema (even when false the parts of the schema used by classes the tool is run on will still be read). Turning on schema reading can ensure that no naming conflicts will occur, but it can take a long time.
  - -primaryKeys/-pk <true/t | false/f>: Whether primary keys are manipulated. Defaults to false unless -readSchema is true.
  - -foreignKeys/-fk <true/t | false/f>: Whether foreign keys are manipulated. Defaults to false unless -readSchema is true.
  - -indexes/-ix <true/t | false/f>: Whether indexes are manipulated. Defaults to false unless -readSchema is true.
  - -schemas/-s <schema and table names>: A list of schemas and/or tables to read. Corresponds to the same-named option in the `SchemaGenerator`. This option is ignored if `readSchema` is false.

  The various actions are as follows.

  - refresh: Bring the mapping information up-to-date with the class definitions. Classes or fields whose mappings are no longer valid will be re-mapped to new columns/tables.
  - drop: Remove the given classes from the mapping repository.
  - validate: Validate the given mappings. The mapping repository and schema will not be affected.
  - buildSchema: Create the schema based on the information in the given mappings.
  - revert: Revert the mappings for the given classes to their previously saved state. Depending on how you've chosen to store your mapping information, reversion might not be possible.
  - import: Import mappings from an XML document and store them as the current system mappings. If this action is used then the expected arguments will be XML files corresponding to the document structure defined by the `XMLMappingInfoParser`.
  - export: Dump the current mappings for the given classes to an XML document specified by the `file` option.

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

  Examples:

  - Refresh the mappings for given package, without dropping any schema components:
    `java kodo.jdbc.meta.MappingTool -action refresh mypackage.jdo`
  - Make sure the mappings you've created by hand match the object model and schema:
    `java kodo.jbdc.meta.MappingTool -action validate Person.java`
  - Generate the schema for the mappings you've created by hand:
    `java kodo.jdbc.meta.MappingTool -action buildSchema Person.java`
  - Remove the recorded schema mapping for a given class:
    `java kodo.jbdc.meta.MappingTool -action drop Person.java`
  - Record the current mappings in an XML file:
    `java kodo.jdbc.meta.MappingTool -file mypackage.mappings -action export mypackage.jdo`

### run

    public static boolean run(JDBCConfiguration conf,
                              String[] args,
                              serp.util.Options opts)
                       throws IOException,
                              SQLException

  Run the tool. Returns false if invalid options are given.
  See Also:
    `main(java.lang.String[])`

### run

    public static boolean run(JDBCConfiguration conf,
                              String action,
                              String[] args,
                              Writer mappingWriter,
                              String schemaAction,
                              boolean dropTables,
                              boolean ignoreErrors,
                              boolean readSchema,
                              boolean pks,
                              boolean fks,
                              boolean indexes,
                              Writer schemaWriter,
                              ClassLoader loader)
                       throws IOException,
                              SQLException

  Run the tool. Return false if an invalid option was given.

Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 3.0.3 generated on February 20 2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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