Class DatabaseDataIO
java.lang.Object
edu.internet2.middleware.grouper.ext.org.apache.ddlutils.io.DatabaseDataIO
Provides basic live database data <-> XML functionality.
- Version:
- $Revision: $
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the batch size override.getConfiguredDataReader
(Platform platform, Database model) Returns a data reader instance configured for the given platform (which needs to be connected to a live database) and model.getConfiguredDataWriter
(OutputStream output, String xmlEncoding) Returns a data writer instance configured to write to the given output stream in the specified encoding.getConfiguredDataWriter
(Writer output, String xmlEncoding) Returns a data writer instance configured to write to the given output writer in the specified encoding.getConfiguredDataWriter
(String path, String xmlEncoding) Returns a data writer instance configured to write to the indicated file in the specified encoding.boolean
Determines whether batch mode is used for inserting data into the database.boolean
Determines whether the sink delays the insertion of beans so that the beans referenced by it via foreignkeys are already inserted into the database.boolean
Determines whether data io is stopped when an error happens.void
registerConverter
(DataConverterRegistration converterRegistration) Registers a converter.void
setBatchSize
(Integer batchSize) Sets the batch size to be used by this object.void
setDetermineSchema
(boolean determineSchema) Deprecated.Will be removed once proper schema support is in placevoid
setEnsureFKOrder
(boolean ensureFKOrder) Specifies whether the sink shall delay the insertion of beans so that the beans referenced by it via foreignkeys are already inserted into the database.
Note that you should careful with settinghaltOnErrors
to false as this might result in beans not inserted at all.void
setFailOnError
(boolean failOnError) Specifies whether data io shall be stopped when an error happens.void
setSchemaPattern
(String schemaPattern) Deprecated.Will be removed once proper schema support is in placevoid
setUseBatchMode
(boolean useBatchMode) Specifies whether batch mode should be used for inserting data into the database.void
writeDataToDatabase
(DataReader dataReader, InputStream input) Reads the data from the given input stream and writes it to the database via the given data reader.void
writeDataToDatabase
(DataReader dataReader, InputStream[] inputs) Reads the data from the given input stream and writes it to the database via the given data reader.void
writeDataToDatabase
(DataReader dataReader, Reader input) Reads the data from the given input stream and writes it to the database via the given data reader.void
writeDataToDatabase
(DataReader dataReader, Reader[] inputs) Reads the data from the given input stream and writes it to the database via the given data reader.void
writeDataToDatabase
(DataReader dataReader, String path) Reads the data from the indicated XML file and writes it to the database via the given data reader.void
writeDataToDatabase
(DataReader dataReader, String[] files) Reads the data from the specified files and writes it to the database via the given data reader.void
writeDataToDatabase
(Platform platform, Database model, InputStream[] inputs) Reads the data from the given input streams and writes it to the database to which the given platform is connected.void
writeDataToDatabase
(Platform platform, Database model, Reader[] inputs) Reads the data from the given input readers and writes it to the database to which the given platform is connected.void
writeDataToDatabase
(Platform platform, Database model, String[] files) Reads the data from the indicated files and writes it to the database to which the given platform is connected.void
writeDataToDatabase
(Platform platform, InputStream[] inputs) Reads the data from the given input streams and writes it to the database to which the given platform is connected.void
writeDataToDatabase
(Platform platform, Reader[] inputs) Reads the data from the given input readers and writes it to the database to which the given platform is connected.void
writeDataToDatabase
(Platform platform, String[] files) Reads the data from the specified files and writes it to the database to which the given platform is connected.void
writeDataToXML
(Platform platform, DataWriter writer) Writes the data contained in the database to which the given platform is connected, as XML to the given data writer.void
writeDataToXML
(Platform platform, Database model, DataWriter writer) Writes the data contained in the database to which the given platform is connected, as XML to the given data writer.void
writeDataToXML
(Platform platform, Database model, OutputStream output, String xmlEncoding) Writes the data contained in the database to which the given platform is connected, as XML to the given output stream (which won't be closed by this method).void
writeDataToXML
(Platform platform, Database model, Writer output, String xmlEncoding) Writes the data contained in the database to which the given platform is connected, as XML to the given output writer (which won't be closed by this method).void
writeDataToXML
(Platform platform, Database model, String path, String xmlEncoding) Writes the data contained in the database to which the given platform is connected, as XML to the given output stream (which won't be closed by this method).void
writeDataToXML
(Platform platform, OutputStream output, String xmlEncoding) Writes the data contained in the database to which the given platform is connected, as XML to the given output stream (which won't be closed by this method).void
writeDataToXML
(Platform platform, Writer output, String xmlEncoding) Writes the data contained in the database to which the given platform is connected, as XML to the given output writer (which won't be closed by this method).void
writeDataToXML
(Platform platform, String path, String xmlEncoding) Writes the data contained in the database to which the given platform is connected, as XML to the given output stream (which won't be closed by this method).
-
Constructor Details
-
DatabaseDataIO
public DatabaseDataIO()
-
-
Method Details
-
registerConverter
Registers a converter.- Parameters:
converterRegistration
- The registration info
-
isFailOnError
public boolean isFailOnError()Determines whether data io is stopped when an error happens.- Returns:
- Whether io is stopped when an error was detected (true by default)
-
setFailOnError
public void setFailOnError(boolean failOnError) Specifies whether data io shall be stopped when an error happens.- Parameters:
failOnError
- Whether io should stop when an error was detected
-
getUseBatchMode
public boolean getUseBatchMode()Determines whether batch mode is used for inserting data into the database.- Returns:
true
if batch mode is used
-
setUseBatchMode
public void setUseBatchMode(boolean useBatchMode) Specifies whether batch mode should be used for inserting data into the database.- Parameters:
useBatchMode
-true
if batch mode shall be used
-
getBatchSize
Returns the batch size override.- Returns:
- The batch size if different from the default,
null
otherwise
-
setBatchSize
Sets the batch size to be used by this object.- Parameters:
batchSize
- The batch size if different from the default, ornull
if the default shall be used
-
isEnsureFKOrder
public boolean isEnsureFKOrder()Determines whether the sink delays the insertion of beans so that the beans referenced by it via foreignkeys are already inserted into the database.- Returns:
true
if beans are inserted after its foreignkey-references
-
setEnsureFKOrder
public void setEnsureFKOrder(boolean ensureFKOrder) Specifies whether the sink shall delay the insertion of beans so that the beans referenced by it via foreignkeys are already inserted into the database.
Note that you should careful with settinghaltOnErrors
to false as this might result in beans not inserted at all. The sink will then throw an appropriate exception at the end of the insertion process (methodDataSink.end()
).- Parameters:
ensureFKOrder
-true
if beans shall be inserted after its foreignkey-references
-
setDetermineSchema
public void setDetermineSchema(boolean determineSchema) Deprecated.Will be removed once proper schema support is in placeSpecifies whether DdlUtils should try to find the schema of the tables when reading data from a live database.- Parameters:
determineSchema
- Whether to try to find the table's schemas
-
setSchemaPattern
Deprecated.Will be removed once proper schema support is in placeSets the schema pattern to find the schemas of tables when reading data from a live database.- Parameters:
schemaPattern
- The schema pattern
-
getConfiguredDataWriter
Returns a data writer instance configured to write to the indicated file in the specified encoding.- Parameters:
path
- The path to the output XML data filexmlEncoding
- The encoding to use for writing the XML- Returns:
- The writer
- Throws:
DdlUtilsException
-
getConfiguredDataWriter
public DataWriter getConfiguredDataWriter(OutputStream output, String xmlEncoding) throws DdlUtilsException Returns a data writer instance configured to write to the given output stream in the specified encoding.- Parameters:
output
- The output streamxmlEncoding
- The encoding to use for writing the XML- Returns:
- The writer
- Throws:
DdlUtilsException
-
getConfiguredDataWriter
public DataWriter getConfiguredDataWriter(Writer output, String xmlEncoding) throws DdlUtilsException Returns a data writer instance configured to write to the given output writer in the specified encoding.- Parameters:
output
- The output writer; needs to be configured with the specified encodingxmlEncoding
- The encoding to use for writing the XML- Returns:
- The writer
- Throws:
DdlUtilsException
-
writeDataToXML
public void writeDataToXML(Platform platform, String path, String xmlEncoding) throws DdlUtilsException Writes the data contained in the database to which the given platform is connected, as XML to the given output stream (which won't be closed by this method).- Parameters:
platform
- The platform; needs to be connected to a live databasepath
- The path of the output filexmlEncoding
- The encoding to use for the XML- Throws:
DdlUtilsException
-
writeDataToXML
Writes the data contained in the database to which the given platform is connected, as XML to the given output stream (which won't be closed by this method).- Parameters:
platform
- The platform; needs to be connected to a live databasemodel
- The model for which to retrieve and write the datapath
- The path of the output filexmlEncoding
- The encoding to use for the XML
-
writeDataToXML
Writes the data contained in the database to which the given platform is connected, as XML to the given output stream (which won't be closed by this method).- Parameters:
platform
- The platform; needs to be connected to a live databaseoutput
- The output streamxmlEncoding
- The encoding to use for the XML
-
writeDataToXML
public void writeDataToXML(Platform platform, Database model, OutputStream output, String xmlEncoding) Writes the data contained in the database to which the given platform is connected, as XML to the given output stream (which won't be closed by this method).- Parameters:
platform
- The platform; needs to be connected to a live databasemodel
- The model for which to retrieve and write the dataoutput
- The output streamxmlEncoding
- The encoding to use for the XML
-
writeDataToXML
Writes the data contained in the database to which the given platform is connected, as XML to the given output writer (which won't be closed by this method).- Parameters:
platform
- The platform; needs to be connected to a live databaseoutput
- The output writer (which needs to be openend with the specified encoding)xmlEncoding
- The encoding to use for the XML
-
writeDataToXML
Writes the data contained in the database to which the given platform is connected, as XML to the given output writer (which won't be closed by this method).- Parameters:
platform
- The platform; needs to be connected to a live databasemodel
- The model for which to retrieve and write the dataoutput
- The output writer (which needs to be openend with the specified encoding)xmlEncoding
- The encoding to use for the XML
-
writeDataToXML
Writes the data contained in the database to which the given platform is connected, as XML to the given data writer.- Parameters:
platform
- The platform; needs to be connected to a live databasewriter
- The data writer
-
writeDataToXML
Writes the data contained in the database to which the given platform is connected, as XML to the given data writer.- Parameters:
platform
- The platform; needs to be connected to a live databasemodel
- The model for which to retrieve and write the datawriter
- The data writer
-
getConfiguredDataReader
public DataReader getConfiguredDataReader(Platform platform, Database model) throws DdlUtilsException Returns a data reader instance configured for the given platform (which needs to be connected to a live database) and model.- Parameters:
platform
- The databasemodel
- The model- Returns:
- The data reader
- Throws:
DdlUtilsException
-
writeDataToDatabase
Reads the data from the specified files and writes it to the database to which the given platform is connected.- Parameters:
platform
- The platform, must be connected to a live databasefiles
- The XML data files- Throws:
DdlUtilsException
-
writeDataToDatabase
Reads the data from the given input streams and writes it to the database to which the given platform is connected.- Parameters:
platform
- The platform, must be connected to a live databaseinputs
- The input streams for the XML data- Throws:
DdlUtilsException
-
writeDataToDatabase
Reads the data from the given input readers and writes it to the database to which the given platform is connected.- Parameters:
platform
- The platform, must be connected to a live databaseinputs
- The input readers for the XML data- Throws:
DdlUtilsException
-
writeDataToDatabase
public void writeDataToDatabase(Platform platform, Database model, String[] files) throws DdlUtilsException Reads the data from the indicated files and writes it to the database to which the given platform is connected. Only data that matches the given model will be written.- Parameters:
platform
- The platform, must be connected to a live databasemodel
- The model to which to constrain the written datafiles
- The XML data files- Throws:
DdlUtilsException
-
writeDataToDatabase
public void writeDataToDatabase(Platform platform, Database model, InputStream[] inputs) throws DdlUtilsException Reads the data from the given input streams and writes it to the database to which the given platform is connected. Only data that matches the given model will be written.- Parameters:
platform
- The platform, must be connected to a live databasemodel
- The model to which to constrain the written datainputs
- The input streams for the XML data- Throws:
DdlUtilsException
-
writeDataToDatabase
public void writeDataToDatabase(Platform platform, Database model, Reader[] inputs) throws DdlUtilsException Reads the data from the given input readers and writes it to the database to which the given platform is connected. Only data that matches the given model will be written.- Parameters:
platform
- The platform, must be connected to a live databasemodel
- The model to which to constrain the written datainputs
- The input readers for the XML data- Throws:
DdlUtilsException
-
writeDataToDatabase
Reads the data from the specified files and writes it to the database via the given data reader. Note that the sink that the data reader is configured with, won't be started or ended by this method. This has to be done by the code using this method.- Parameters:
dataReader
- The data readerfiles
- The XML data files- Throws:
DdlUtilsException
-
writeDataToDatabase
public void writeDataToDatabase(DataReader dataReader, InputStream[] inputs) throws DdlUtilsException Reads the data from the given input stream and writes it to the database via the given data reader. Note that the input stream won't be closed by this method. Note also that the sink that the data reader is configured with, won't be started or ended by this method. This has to be done by the code using this method.- Parameters:
dataReader
- The data readerinputs
- The input streams for the XML data- Throws:
DdlUtilsException
-
writeDataToDatabase
Reads the data from the given input stream and writes it to the database via the given data reader. Note that the input stream won't be closed by this method. Note also that the sink that the data reader is configured with, won't be started or ended by this method. This has to be done by the code using this method.- Parameters:
dataReader
- The data readerinputs
- The input readers for the XML data- Throws:
DdlUtilsException
-
writeDataToDatabase
Reads the data from the indicated XML file and writes it to the database via the given data reader. Note that the sink that the data reader is configured with, won't be started or ended by this method. This has to be done by the code using this method.- Parameters:
dataReader
- The data readerpath
- The path to the XML data file- Throws:
DdlUtilsException
-
writeDataToDatabase
Reads the data from the given input stream and writes it to the database via the given data reader. Note that the input stream won't be closed by this method. Note also that the sink that the data reader is configured with, won't be started or ended by this method. This has to be done by the code using this method.- Parameters:
dataReader
- The data readerinput
- The input stream for the XML data- Throws:
DdlUtilsException
-
writeDataToDatabase
Reads the data from the given input stream and writes it to the database via the given data reader. Note that the input stream won't be closed by this method. Note also that the sink that the data reader is configured with, won't be started or ended by this method. This has to be done by the code using this method.- Parameters:
dataReader
- The data readerinput
- The input reader for the XML data- Throws:
DdlUtilsException
-