public class Subsetter
extends java.lang.Object
Constructor and Description |
---|
Subsetter()
Default constructor.
|
Subsetter(javax.sql.DataSource dataSource,
DBMS dbms,
java.io.File dataModel,
java.io.File extractionModel,
ScriptFormat scriptFormat)
Creates a new Subsetter with all mandatory attributes.
|
Subsetter(javax.sql.DataSource dataSource,
DBMS dbms,
java.net.URL dataModel,
java.net.URL extractionModel,
ScriptFormat scriptFormat)
Creates a new Subsetter with all mandatory attributes.
|
Subsetter(Subsetter other)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
ExportStatistic |
execute(java.lang.String whereClause,
java.io.File exportScriptFile)
Generates the export-script.
|
ExportStatistic |
execute(java.lang.String whereClause,
java.io.File exportScriptFile,
java.io.File deleteScriptFile)
Generates the export- and/or delete-script.
|
java.net.URL |
getDataModelURL()
Gets URL of the current data model (the datamodel's base folder)
|
javax.sql.DataSource |
getDataSource()
Gets the data-source to connect with the database.
|
DBMS |
getDbms()
Gets the DBMS of the database.
|
ExecutionContext |
getExecutionContext()
Gets the
ExecutionContext . |
java.net.URL |
getExtractionModelURL()
Gets the URL of the extraction model.
|
java.lang.String |
getImportFilterMappingTableSchema()
Gets schema in which the import-filter mapping tables will be created
|
java.lang.Integer |
getIsolationLevel()
Gets IsolationLevel.
|
java.lang.String |
getLocalDatabaseStorage() |
int |
getModelPoolSize() |
boolean |
getNoRowid()
Deprecated.
use
getUseRowid() |
boolean |
getNoSorting()
If
true , The exported rows will not be sorted according to
foreign key constraints |
int |
getNumberOfEntities()
Gets maximum number of entities per insert-statement (in export-file,
default is 10)
|
int |
getNumberOfThreads()
Gets number of parallel threads (default is 1) to be used.
|
java.util.Map<java.lang.String,java.lang.String> |
getParameters()
Gets parameters.
|
java.util.Map<java.lang.String,java.lang.String> |
getSchemaMapping()
Gets schema map for destination database.
|
WorkingTableScope |
getScope()
Gets scope of working tables, GLOBAL, SESSION_LOCAL or LOCAL_DATABASE
Default is GLOBAL. |
ScriptFormat |
getScriptFormat()
Gets the script format.
|
java.util.Map<java.lang.String,java.lang.String> |
getSourceSchemaMapping()
Gets schema map for source database.
|
DBMS |
getTargetDBMS()
Gets target-DBMS.
|
boolean |
getTransactional()
If
true , export rows in a single transaction. |
boolean |
getUpsertOnly()
If
true , Generate 'upsert'-statements for all entities (in
export-file) |
boolean |
getUseRowid()
If
true , use rowid/ctid-column to determine row identity (instead
of primary keys) |
boolean |
getUseRowIdsOnlyForTablesWithoutPK()
If
true , use rowid/ctid-column only for tables without primary key. |
boolean |
getUTF8()
If
true , Use uTF-8 encoding |
java.lang.String |
getWorkingTableSchema()
Gets schema in which the working tables will be created
|
java.lang.String |
getXmlDatePattern()
Gets pattern for dates in XML and LIQUIBASE_XML export file
|
java.lang.String |
getXmlRootTag()
Gets root tag of XML export file
|
java.lang.String |
getXmlTimePattern()
Gets pattern for times in XML and LIQUIBASE_XML export file
|
java.lang.String |
getXmlTimeStampPattern()
Gets pattern for time-stamps in XML and LIQUIBASE_XML export file
|
boolean |
isAbortInCaseOfInconsistency() |
boolean |
isDisallowNonAggregated() |
boolean |
isIgnoreNonAggregated() |
boolean |
isIncludeNonAggregated() |
boolean |
isSingleRoot() |
boolean |
isUnformatted() |
void |
setAbortInCaseOfInconsistency(boolean abortInCaseOfInconsitency) |
void |
setDataModelBaseFolder(java.io.File datamodelBaseFolder)
Sets the current data model as
File |
void |
setDataModelURL(java.net.URL datamodelURL)
Sets URL of the current data model (the datamodel's base folder)
|
void |
setDataSource(javax.sql.DataSource dataSource)
Sets the data-source to connect with the database.
|
void |
setDbms(DBMS dbms)
Sets the DBMS of the database.
|
void |
setDisallowNonAggregated(boolean disallowNonAggregated) |
void |
setExtractionModelURL(java.net.URL extractionModelURL)
Sets the URL of the extraction model.
|
void |
setIgnoreNonAggregated(boolean ignoreNonAggregated) |
void |
setImportFilterMappingTableSchema(java.lang.String importFilterMappingTableSchema)
Sets schema in which the import-filter mapping tables will be created
|
void |
setIncludeNonAggregated(boolean includeNonAggregated) |
void |
setIsolationLevel(java.lang.Integer isolationLevel)
Sets IsolationLevel.
|
void |
setLocalDatabaseStorage(java.io.File localDatabaseStorage)
Sets the folder where the local database will be stored.
|
void |
setLocalDatabaseStorage(java.lang.String localDatabaseStorage)
Sets the folder where the local database will be stored.
|
void |
setModelPoolSize(int modelPoolSize) |
void |
setNoRowid(boolean noRowid)
Deprecated.
|
void |
setNoSorting(boolean noSorting)
If
true , The exported rows will not be sorted according to
foreign key constraints |
void |
setNumberOfEntities(int numberOfEntities)
Sets maximum number of entities per insert-statement (in export-file,
default is 10)
|
void |
setNumberOfThreads(int numberOfThreads)
Sets number of parallel threads (default is 1) to be used
|
void |
setParameter(java.lang.String name,
java.lang.String value)
Sets a parameter.
|
void |
setSchemaMapping(java.util.Map<java.lang.String,java.lang.String> schemaMapping)
Sets schema map for destination database.
|
void |
setScope(WorkingTableScope scope)
Sets scope of working tables, GLOBAL, SESSION_LOCAL or LOCAL_DATABASE
|
void |
setScriptFormat(ScriptFormat scriptFormat)
Sets the script format.
|
void |
setSingleRoot(boolean singleRoot) |
void |
setSourceSchemaMapping(java.util.Map<java.lang.String,java.lang.String> sourceSchemaMapping)
Sets schema map for source database.
|
void |
setTargetDBMS(DBMS targetDBMS)
Sets target-DBMS.
|
void |
setTransactional(boolean transactional)
If
true , export rows in a single transaction. |
void |
setUnformatted(boolean unformatted) |
void |
setUpsertOnly(boolean upsertOnly)
If
true , Generate 'upsert'-statements for all entities (in
export-file) |
void |
setUseRowid(boolean useRowid)
If
true , use rowid/ctid-column to determine row identity (instead
of primary keys) |
void |
setUseRowIdsOnlyForTablesWithoutPK(boolean useRowIdsOnlyForTablesWithoutPK)
If
true , use rowid/ctid-column only for tables without primary key. |
void |
setUTF8(boolean uTF8)
If
true , use UTF-8 encoding |
void |
setWorkingTableSchema(java.lang.String workingTableSchema)
Sets schema in which the working tables will be created
|
void |
setXmlDatePattern(java.lang.String xmlDatePattern)
Sets pattern for dates in XML and LIQUIBASE_XML export file
|
void |
setXmlRootTag(java.lang.String xmlRootTag)
Sets root tag of XML export file
|
void |
setXmlTimePattern(java.lang.String xmlTimePattern)
Sets pattern for times in XML and LIQUIBASE_XML export file
|
void |
setXmlTimeStampPattern(java.lang.String xmlTimeStampPattern)
Sets pattern for time-stamps in XML and LIQUIBASE_XML export file
|
public Subsetter()
public Subsetter(Subsetter other)
public Subsetter(javax.sql.DataSource dataSource, DBMS dbms, java.net.URL dataModel, java.net.URL extractionModel, ScriptFormat scriptFormat)
dataSource
- the data-source to connect with the source databasedbms
- the DBMS of the source databasedataModel
- URL of the current data model folder. Use Class.getResource(String)
if the data model is available as a resource.extractionModel
- URL of the extraction model. Use Class.getResource(String)
if the extraction model is available as a resource.scriptFormat
- script formatpublic Subsetter(javax.sql.DataSource dataSource, DBMS dbms, java.io.File dataModel, java.io.File extractionModel, ScriptFormat scriptFormat)
dataSource
- the data-source to connect with the source databasedbms
- the DBMS of the source databasedataModel
- the current data model (the datamodel's base folder)extractionModel
- the extraction modelscriptFormat
- script formatpublic ExportStatistic execute(java.lang.String whereClause, java.io.File exportScriptFile) throws java.sql.SQLException, java.io.IOException
whereClause
- if not null
, overrides the extraction model's subject conditionexportScriptFile
- the export-script file (compressed if it ends with '.zip' or '.gz')InconsistentSubsettingResultException
- if ExecutionContext.isAbortInCaseOfInconsistency()
and the number of exported rows differs from that of the collected onesjava.sql.SQLException
java.io.IOException
public ExportStatistic execute(java.lang.String whereClause, java.io.File exportScriptFile, java.io.File deleteScriptFile) throws java.sql.SQLException, java.io.IOException
whereClause
- if not null
, overrides the extraction model's subject conditionexportScriptFile
- the export-script file (compressed if it ends with '.zip' or '.gz'), optionaldeleteScriptFile
- the delete-script file (compressed if it ends with '.zip' or '.gz'), optionalInconsistentSubsettingResultException
- if ExecutionContext.isAbortInCaseOfInconsistency()
and the number of exported rows differs from that of the collected onesjava.sql.SQLException
java.io.IOException
public javax.sql.DataSource getDataSource()
public void setDataSource(javax.sql.DataSource dataSource)
dataSource
- the data-source to connect with the databasepublic DBMS getDbms()
public void setDbms(DBMS dbms)
BasicDataSource
is used.dbms
- the DBMSpublic java.net.URL getDataModelURL()
public void setDataModelURL(java.net.URL datamodelURL)
public void setDataModelBaseFolder(java.io.File datamodelBaseFolder)
File
datamodelBaseFolder
- represents the folder. Will be converted to an URL an set as datamodel URLsetDataModelURL(URL)
public java.net.URL getExtractionModelURL()
public void setExtractionModelURL(java.net.URL extractionModelURL)
extractionModelURL
- the URL of the extraction modelpublic ScriptFormat getScriptFormat()
public void setScriptFormat(ScriptFormat scriptFormat)
public boolean getUTF8()
true
, Use uTF-8 encodingtrue
if use UTF-8 encodingpublic void setUTF8(boolean uTF8)
true
, use UTF-8 encodinguTF8
- true
if use UTF-8 encodingpublic DBMS getTargetDBMS()
public void setTargetDBMS(DBMS targetDBMS)
targetDBMS
- target-DBMS. If it's null
, target DBMS is assumed to be the same as getDbms()
public java.lang.String getXmlRootTag()
public void setXmlRootTag(java.lang.String xmlRootTag)
xmlRootTag
- root tag of XML export filepublic java.lang.String getXmlDatePattern()
public void setXmlDatePattern(java.lang.String xmlDatePattern)
xmlDatePattern
- pattern for dates in XML and LIQUIBASE_XML export filepublic java.lang.String getXmlTimePattern()
public void setXmlTimePattern(java.lang.String xmlTimePattern)
xmlTimePattern
- pattern for times in XML and LIQUIBASE_XML export filepublic java.lang.String getXmlTimeStampPattern()
public void setXmlTimeStampPattern(java.lang.String xmlTimeStampPattern)
xmlTimeStampPattern
- pattern for time-stamps in XML and LIQUIBASE_XML export filepublic boolean isUnformatted()
true
: don't format JSON/YAML/XML export filespublic void setUnformatted(boolean unformatted)
unformatted
- true
: don't format JSON/YAML/XML export filespublic boolean isSingleRoot()
public void setSingleRoot(boolean singleRoot)
singleRoot
- allow only a single root/subject object to be written out into JSON/YAML/XML export filepublic boolean isDisallowNonAggregated()
public void setDisallowNonAggregated(boolean disallowNonAggregated)
disallowNonAggregated
- allow only a single root/subject object to be written out into JSON/YAML/XML export filepublic boolean isIncludeNonAggregated()
public void setIncludeNonAggregated(boolean includeNonAggregated)
includeNonAggregated
- write out all objects that are not aggregated in any other object at root level into JSON/YAML/XML export filepublic boolean isIgnoreNonAggregated()
public void setIgnoreNonAggregated(boolean ignoreNonAggregated)
ignoreNonAggregated
- don't write out any object that are not aggregated in any other object into JSON/YAML/XML export filepublic int getNumberOfThreads()
public void setNumberOfThreads(int numberOfThreads)
numberOfThreads
- number of threadspublic boolean getTransactional()
true
, export rows in a single transaction. (default is false)true
if Import rows in a single transactionpublic void setTransactional(boolean transactional)
true
, export rows in a single transaction. (default is false)transactional
- true
if import rows in a single transactionpublic java.lang.Integer getIsolationLevel()
Connection.setTransactionIsolation(int)
public void setIsolationLevel(java.lang.Integer isolationLevel)
Connection.setTransactionIsolation(int)
public int getNumberOfEntities()
public void setNumberOfEntities(int numberOfEntities)
numberOfEntities
- maximum number of entities per insert-statement (in
export-file, default is 10)public boolean getUpsertOnly()
true
, Generate 'upsert'-statements for all entities (in
export-file)true
if Generate 'upsert'-statements for all
entities (in export-file)public void setUpsertOnly(boolean upsertOnly)
true
, Generate 'upsert'-statements for all entities (in
export-file)upsertOnly
- true
if Generate 'upsert'-statements for all
entities (in export-file)public WorkingTableScope getScope()
public void setScope(WorkingTableScope scope)
scope
- scope of working tables, GLOBAL, SESSION_LOCAL or
LOCAL_DATABASEpublic java.lang.String getWorkingTableSchema()
public void setWorkingTableSchema(java.lang.String workingTableSchema)
workingTableSchema
- schema in which the working tables will be createdpublic boolean getNoSorting()
true
, The exported rows will not be sorted according to
foreign key constraintstrue
if The exported rows will not be sorted
according to foreign key constraintspublic void setNoSorting(boolean noSorting)
true
, The exported rows will not be sorted according to
foreign key constraintsnoSorting
- true
if The exported rows will not be sorted
according to foreign key constraintspublic boolean getNoRowid()
getUseRowid()
public void setNoRowid(boolean noRowid)
setUseRowid(boolean)
public boolean getUseRowid()
true
, use rowid/ctid-column to determine row identity (instead
of primary keys)true
use rowid/ctid-column to determine row identity
(instead of primary keys)public void setUseRowid(boolean useRowid)
true
, use rowid/ctid-column to determine row identity (instead
of primary keys)useRowid
- if true
use rowid/ctid-column to determine row
identity (instead of primary keys)public boolean getUseRowIdsOnlyForTablesWithoutPK()
true
, use rowid/ctid-column only for tables without primary key.true
if use rowid/ctid-column only for tables without primary keygetUseRowIdsOnlyForTablesWithoutPK()
public void setUseRowIdsOnlyForTablesWithoutPK(boolean useRowIdsOnlyForTablesWithoutPK)
true
, use rowid/ctid-column only for tables without primary key.useRowIdsOnlyForTablesWithoutPK
- true
if use rowid/ctid-column only for tables without primary keysetUseRowid(boolean)
public java.lang.String getImportFilterMappingTableSchema()
public void setImportFilterMappingTableSchema(java.lang.String importFilterMappingTableSchema)
importFilterMappingTableSchema
- schema in which the import-filter mapping tables will be
createdpublic java.util.Map<java.lang.String,java.lang.String> getParameters()
public void setParameter(java.lang.String name, java.lang.String value)
name
- parameter namevalue
- valuepublic java.util.Map<java.lang.String,java.lang.String> getSchemaMapping()
public void setSchemaMapping(java.util.Map<java.lang.String,java.lang.String> schemaMapping)
schemaMapping
- schema mappublic void setSourceSchemaMapping(java.util.Map<java.lang.String,java.lang.String> sourceSchemaMapping)
sourceSchemaMapping
- the sourceSchemaMapping to setpublic java.util.Map<java.lang.String,java.lang.String> getSourceSchemaMapping()
public boolean isAbortInCaseOfInconsistency()
true
, the Subsetter throws an exception if the result is inconsistent due to insufficient transaction isolationpublic void setAbortInCaseOfInconsistency(boolean abortInCaseOfInconsitency)
abortInCaseOfInconsitency
- if true
, abort the process if the result is inconsistent due to insufficient transaction isolationpublic int getModelPoolSize()
public void setModelPoolSize(int modelPoolSize)
modelPoolSize
- size of extraction-model pool (default is 10)public java.lang.String getLocalDatabaseStorage()
null
, default temp folder is used.public void setLocalDatabaseStorage(java.io.File localDatabaseStorage)
localDatabaseStorage
- the folder where the local database will be stored. If null
, default temp folder is used.public void setLocalDatabaseStorage(java.lang.String localDatabaseStorage)
localDatabaseStorage
- the folder where the local database will be stored. If null
, default temp folder is used.public ExecutionContext getExecutionContext()
ExecutionContext
. ExecutionContext