Follow the links below to browse sample Javadoc for MJ classes and tools, including the MJ Runtime Library.

 

Package: com.arsi.mj.maprpt.entity.etlgen  previous next contents

Interfaces and classes that facilitate and support generation of MJ's ETL (Extract, Transform and Load) artifacts.

Classes and Interfaces
DefaultDataEntityEtlGenerator
DefaultEtlGeneratorBase
IDataEntityEtlGenerator Defines operations that generate ETL artifacts (e.g., scripts, data files) needed to load a data entity (database table) with lines of data from a Mapper report.
IInlineDataEtlGenerator
ILineMetadataEtlGenerator
InsertSQL Represents an SQL INSERT statement generated by Hibernate (or other means) and the place holders in the VALUES clause of the statement.
InsertSQLPlaceholder Represents a place holder (e.g., ?)
PredefinedObjectFactory Simple class for creating objects whose definition is always known but have utility when treated as other objects that are created dynamically.
VetoOnPrepareException Runtime exception thrown to act as veto of org.hibernate.Interceptor.onPrepareStatement once SQL has been obtained.

Class: DefaultDataEntityEtlGenerator   next package

public class com.arsi.mj.maprpt.entity.etlgen.DefaultDataEntityEtlGenerator
  extends com.arsi.mj.maprpt.entity.etlgen.DefaultEtlGeneratorBase
  implements com.arsi.mj.maprpt.entity.etlgen.IDataEntityEtlGenerator
Fields
File that contains complete Scriptella template for generated ETL script that inserts entity rows.
public static final java.lang.String INSERT_ENTITY_ETL_TEMPLATE = "com/arsi/mj/maprpt/entity/etlgen/model/insert_entity_table_etl.xml.ftl"
Prefix of temporary table used to map previously generated keys to Mapper line numbers.
public static final java.lang.String TEMP_KEYMAP_TABLE_PREFIX = "TMP_"
Constructors
public DefaultDataEntityEtlGenerator()
Methods
public java.lang.String currentTimestampSqlBinding()
public java.lang.String emptyClobSqlBinding()
public java.lang.String etlUserSqlBinding()
public com.arsi.mj.NameValuePair generateCreateTempTable(com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler)
    throws com.arsi.mj.MJTranslateException
public java.io.Reader generateCSV(java.util.Iterator aTupleIterator, java.lang.String aPersistentEntityClassName, com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler, com.arsi.mj.maprpt.entity.etlgen.config.IEtlConfig anEtlConfig, com.arsi.mj.maprpt.entity.etlgen.InsertSQL anInsertSQL, org.springframework.context.ApplicationContext anAppCtx, int aReportNumber, com.arsi.mj.maprpt.entity.etlgen.bnfkey.IBinaryFindKeyBuilder aBnfKeyBuilder)
    throws com.arsi.mj.MJTranslateException
public com.arsi.mj.NameValuePair generateDropTempTable(com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler)
    throws com.arsi.mj.MJTranslateException
public com.arsi.mj.maprpt.entity.etlgen.InsertSQL generateInsertSQL(java.lang.String aPersistentEntityClassName, com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler, java.util.List someInlineHandlers)
    throws com.arsi.mj.MJTranslateException
public com.arsi.mj.NameValuePair generateScriptella(java.lang.String aPersistentEntityClassName, com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler, java.util.List someInlineHandlers, com.arsi.mj.maprpt.entity.etlgen.config.IEtlConfig anEtlConfig, com.arsi.mj.maprpt.entity.etlgen.InsertSQL anInsertEntitySQL, com.arsi.mj.maprpt.entity.etlgen.InsertSQL anInsertTempSQL, java.lang.String aMapperReportDescription)
    throws com.arsi.mj.MJTranslateException
public java.lang.String nullClobSqlBinding()
public java.lang.String surrogateKeyCurrentSqlBinding(com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler)
    throws java.lang.UnsupportedOperationException
public java.lang.String surrogateKeyNextSqlBinding(com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler)

Class: DefaultEtlGeneratorBase   previous next package

public abstract class com.arsi.mj.maprpt.entity.etlgen.DefaultEtlGeneratorBase
  extends java.lang.Object
Inner Class SQLInterceptor
Hibernate interceptor that captures insert SQL.
protected static class com.arsi.mj.maprpt.entity.etlgen.DefaultEtlGeneratorBase.SQLInterceptor
  extends org.hibernate.EmptyInterceptor
protected DefaultEtlGeneratorBase.SQLInterceptor()
public java.lang.String onPrepareStatement(java.lang.String sql)
Fields
Mapper pseudo-column directive for cabinet number in original Mapper report.
public static final java.lang.String CABINET_MAPPER_PSEUDO_COLNAME = "%%mprCabinet"
Mapper pseudo-column directive that acts as stand-in for currentTimestampSqlBinding().
public static final java.lang.String CURRTIMESTAMP_MAPPER_PSEUDO_COLNAME = "%%mjCurrentTimestamp"
Mapper pseudo-column directive for drawer letter in original Mapper report.
public static final java.lang.String DRAWER_MAPPER_PSEUDO_COLNAME = "%%mprDrawer"
Mapper pseudo-column directive that acts as stand-in for emptyClobSqlBinding().
public static final java.lang.String EMPTYCLOB_MAPPER_PSEUDO_COLNAME = "%%mjEmptyClob"
Mapper pseudo-column directive that acts as stand-in for etlUserSqlBinding().
public static final java.lang.String ETLUSER_MAPPER_PSEUDO_COLNAME = "%%mjEtlUser"
Hibernate configuration property for closing session on transaction commit or rollback.
public static final java.lang.String HIBERNATE_TXN_AUTO_CLOSE_SESSION = "hibernate.transaction.auto_close_session"
Database dialect in use by Hibernate.
protected final org.hibernate.dialect.Dialect hibernateDialect
Mapper pseudo-column directive that acts as stand-in for surrogateKeySqlBinding().
public static final java.lang.String ID_MAPPER_PSEUDO_COLNAME = "%%mjSurrogateKey"
Mapper pseudo-column for line number in original Mapper report.
public static final java.lang.String LINENUMBER_MAPPER_PSEUDO_COLNAME = "__mprLinenum"
Mapper pseudo-column for line type (as enumeration) of line in Mapper report.
public static final java.lang.String LINETYPE_ENUM_MAPPER_PSEUDO_COLNAME = "__mjLinetypeEnum"
Mapper pseudo-column directive that acts as stand-in for nullClobSqlBinding().
public static final java.lang.String NULLCLOB_MAPPER_PSEUDO_COLNAME = "%%mjNullClob"
Prefix for all Mapper pseudo column names that cannot be evaluated without translation.
public static final java.lang.String PSEUDO_COLNAME_REQXLT_PREFIX = "%%"
Mapper pseudo-column directive for report number in original Mapper report.
public static final java.lang.String REPORT_MAPPER_PSEUDO_COLNAME = "%%mprReport"
Mapper pseudo-column for report number (as enumeration) of line in Mapper report.
public static final java.lang.String REPORTNUMBER_ENUM_MAPPER_PSEUDO_COLNAME = "__mjRptnumEnum"
Mapper pseudo-column for report number range (as enumeration) of line in Mapper report.
public static final java.lang.String REPORTRANGE_ENUM_MAPPER_PSEUDO_COLNAME = "__mjRptrngEnum"
Name of table that serves as prototype temp table for mapping previously generated keys.
public static final java.lang.String TEMP_KEYMAP_PROTOTYPE_TABLE_NAME = "MJ_TEMP_KEYMAP_PROTOTYPE"
Constructors
protected DefaultEtlGeneratorBase()
Methods
Factory method for creating InsertSQLPlaceholder instances.
Parameters:
aProperty - Hibernate property object for entity attribute.
aComponentProperty - parent component property, i.e., aProperty is property of this Hibernate component.
anEntityHandler - data entity handler for Mapper name lookup.
aQmidxAndStartIdxAndLength - three-dimensional array of question mark index, starting index of value phrase and length of value phrase in insert SQL.
someUniqueEtlNames - set used to ensure all ETL variable names are unique.
Returns:
place holder object.
protected com.arsi.mj.maprpt.entity.etlgen.InsertSQLPlaceholder createInsertSQLPlaceholder(org.hibernate.mapping.Property aProperty, org.hibernate.mapping.Property aComponentProperty, com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler, java.util.List someInlineHandlers, int aQmidxAndStartIdxAndLength, java.util.Set someUniqueEtlNames)
public java.lang.String dialectToScriptellaDriverName(org.hibernate.dialect.Dialect aDialect)
    throws com.arsi.mj.MJTranslateException
protected java.lang.String doCurrentTimestampSqlBinding()
protected java.lang.String doEmptyClobSqlBinding()
protected java.lang.String doEtlUserSqlBinding()
protected java.lang.String doNullClobSqlBinding()
protected java.lang.String doSurrogateKeyCurrentSqlBinding(com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler)
    throws java.lang.UnsupportedOperationException
protected java.lang.String doSurrogateKeyNextSqlBinding(com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler)
Fill a prototype persistent POJO with non-NULL default values for all basic types supported by MJ, including enumerations. References in the POJO to one-to-one or child relationships are not set to non-NULL values.
Parameters:
aPrototypeObject - prototype persistent POJO.
Throws:
InvocationTargetException - if BeanUtils fail to call a mutator or other POJO method.
IllegalAccessException - if BeanUtils fail to call a mutator or other POJO method.
Returns:
the filled POJO.
protected java.lang.Object fillPrototypeObject(java.lang.Object aPrototypeObject)
    throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException, java.lang.IllegalStateException
protected java.util.Map getJdbcVariableMapForFreemarker(com.arsi.mj.maprpt.entity.etlgen.config.IEtlConfig anEtlConfig)
    throws com.arsi.mj.MJTranslateException
Given an IGenericEnum enumeration class, get the first constant defined in the enumeration as a sample enumeration value.
Parameters:
anEnumClass - enumeration class that implements IGenericEnum.
Throws:
IllegalStateException - if enumeration class does not implement IGenericEnum, does not have any constant values, has no values method, or other unexpected error occurs.
Returns:
an instance of the enumeration class, i.e., an enumeration constant.
protected java.lang.Enum getSampleEnumConstant(java.lang.Class anEnumClass)
    throws java.lang.IllegalStateException
Make a guess if the specified name is a simple Mapper column name or not.
Parameters:
aName - name to guess disposition of.
Returns:
true if name appears to be a simple Mapper column name, false if not.
public static boolean guessIfMapperName(java.lang.String aName)
protected com.arsi.mj.maprpt.entity.etlgen.InsertSQL interceptSQL(java.lang.String aPersistentEntityClassName, com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler, java.util.List someInlineHandlers, java.lang.Object aPrototypeObject)
    throws java.lang.Throwable
Make the specified into a valid ETL variable name that cab be used in both ETL expressions and headings in a CSV text file.
Parameters:
aName - name to transform into valid ETL variable name.
Returns:
valid ETL variable name.
public static java.lang.String makeEtlName(java.lang.String aName)
Parse question mark place holders from VALUES clause of INSERT SQL.
Parameters:
anInsertSQL - an INSERT SQL statement captured from Hibernate that contains question mark place holders.
Returns:
list of integer arrays of dimension three, where first integer is index of question mark place holder (as a single character) in SQL, second integer is index of start of value phrase (usually just question mark place holder, but mary be an expression or function) and third integer is length of start of value phrase.
public static java.util.List parsePlaceholderFromInsertSQL(java.lang.String anInsertSQL)
protected java.lang.String substituteInsertSQLPlaceholders(com.arsi.mj.maprpt.entity.etlgen.InsertSQL anInsertSQL, com.arsi.mj.maprpt.entity.etlgen.IDataEntityEtlGenerator anEntityGenerator, com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler, java.lang.String aSurrogateKeyNextSqlBinding)

Interface: IDataEntityEtlGenerator   previous next package

Defines operations that generate ETL artifacts (e.g., scripts, data files) needed to load a data entity (database table) with lines of data from a Mapper report.
public interface com.arsi.mj.maprpt.entity.etlgen.IDataEntityEtlGenerator
Methods
Get the INSERT SQL binding to place into the ETL script for the current timestamp.
Returns:
a valid SQL literal, function, token, sub statement or other SQL construct, or a JEXL expression or other syntax supported by Scriptella ETL.
public java.lang.String currentTimestampSqlBinding()
Get the INSERT SQL binding to place into the ETL script for an EMPTY CLOB column. This may be the same as a NULL CLOB column, bur this method allows for a distinction between the two.
Returns:
a valid SQL literal, function, token, sub statement or other SQL construct, or a JEXL expression or other syntax supported by Scriptella ETL.
public java.lang.String emptyClobSqlBinding()
Get the INSERT SQL binding to place into the ETL script for the current time stamp, e.g., systimestamp in Oracle.
Returns:
a valid SQL literal, function, token, sub statement or other SQL construct, or a JEXL expression or other syntax supported by Scriptella ETL.
public java.lang.String etlUserSqlBinding()
Generate SQL to create the temporary table used to load related keys into child tables and auxiliary tables of the data entity table.
Parameters:
anEntityHandler - data entity handler.
Throws:
MJTranslateException - if an error occurs generating SQL.
Returns:
name/value pair where name is name of temporary table and value is the CREATE TABLE SQL.
public com.arsi.mj.NameValuePair generateCreateTempTable(com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler)
    throws com.arsi.mj.MJTranslateException
Generate comma-separated values (CSV) output that contains data lines from a Mapper report suitable for loading into a data entity's database table.
Parameters:
aTupleIterator - iterates over the data tuples in a Mapper report.
aPersistentEntityClassName - full class name of persistent entity, passed as a convenience.
anEntityHandler - data entity handler that defines table, columns, enumerations, etc.
anEtlConfig - ETL configuration object.
anInsertSQL - object that describes INSERT SQL statement, including place holders in VALUES clause.
anAppCtx - Spring application context for looking up data type beans.
aReportNumber - Mapper report number for report number range enumeration.
aBnfKeyBuilder - optional builder instance for creating binary find key objects for verifying the Mapper tuples are sorted by this key, if NULL no such checking is performed.
Throws:
MJTranslateException - if an error occurs during generation of the CSV output.
Returns:
reader for traversing the CSV heading line and data lines produced by this method.
public java.io.Reader generateCSV(java.util.Iterator aTupleIterator, java.lang.String aPersistentEntityClassName, com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler, com.arsi.mj.maprpt.entity.etlgen.config.IEtlConfig anEtlConfig, com.arsi.mj.maprpt.entity.etlgen.InsertSQL anInsertSQL, org.springframework.context.ApplicationContext anAppCtx, int aReportNumber, com.arsi.mj.maprpt.entity.etlgen.bnfkey.IBinaryFindKeyBuilder aBnfKeyBuilder)
    throws com.arsi.mj.MJTranslateException
Generate SQL to drop the temporary table used to load related keys into child tables and auxiliary tables of the data entity table.
Parameters:
anEntityHandler - data entity handler.
Throws:
MJTranslateException - if an error occurs generating SQL.
Returns:
name/value pair where name is name of temporary table and value is the DROP TABLE SQL.
public com.arsi.mj.NameValuePair generateDropTempTable(com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler)
    throws com.arsi.mj.MJTranslateException
Create an object that describes the SQL statement used to insert new rows into a data entity, including place holders in the VALUES clause of the INSERT SQL.
Parameters:
aPersistentEntityClassName - full class name of persistent entity, passed as a convenience.
anEntityHandler - data entity handler that defines table, columns, enumerations, etc.
someInlineHandlers - handlers for processing trailing lines associated with a data tuple that contain embedded data in a custom format, i.e., extra data that is stored in-line in a Mapper report.
Throws:
MJTranslateException - if an error occurs during generation of the INSERT SQL.
Returns:
object that describes the INSERT SQL statement for the data entity.
public com.arsi.mj.maprpt.entity.etlgen.InsertSQL generateInsertSQL(java.lang.String aPersistentEntityClassName, com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler, java.util.List someInlineHandlers)
    throws com.arsi.mj.MJTranslateException
Generate ETL script for loading the database table for the data entity defined for a Mapper report with data tuples (rows) from the report.
Parameters:
aPersistentEntityClassName - full class name of persistent entity, passed as a convenience.
anEntityHandler - data entity handler that defines table, columns, enumerations, etc.
someInlineHandlers - handlers for processing trailing lines associated with a data tuple that contain embedded data in a custom format, i.e., extra data that is stored in-line in a Mapper report.
anEtlConfig - ETL configuration object.
anInsertEntitySQL - object that describes INSERT SQL statement for data entity table, including place holders in VALUES clause.
anInsertTempSQL - object that describes INSERT SQL statement for temporary table (see generateCreateTempTable), including place holders in VALUES clause.
aMapperReportDescription - description of Mapper report (e.g., Mapper report name) for generating errors and comments.
Throws:
MJTranslateException - if an error occurs during script generation.
Returns:
pair of script filename (name) and script content (value).
public com.arsi.mj.NameValuePair generateScriptella(java.lang.String aPersistentEntityClassName, com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler, java.util.List someInlineHandlers, com.arsi.mj.maprpt.entity.etlgen.config.IEtlConfig anEtlConfig, com.arsi.mj.maprpt.entity.etlgen.InsertSQL anInsertEntitySQL, com.arsi.mj.maprpt.entity.etlgen.InsertSQL anInsertTempSQL, java.lang.String aMapperReportDescription)
    throws com.arsi.mj.MJTranslateException
Get the INSERT SQL binding to place into the ETL script for a NULL CLOB column.
Returns:
a valid SQL literal, function, token, sub statement or other SQL construct, or a JEXL expression or other syntax supported by Scriptella ETL.
public java.lang.String nullClobSqlBinding()
Get the INSERT SQL binding to place into the ETL script for the current surrogate key value, e.g., myseq.currval in Oracle.
Parameters:
anEntityHandler - data entity handler to generate surrogate key for.
Throws:
UnsupportedOperationException - if current surrogate key value is not supported.
Returns:
a valid SQL literal, function, token, sub statement or other SQL construct, or a JEXL expression or other syntax supported by Scriptella ETL.
public java.lang.String surrogateKeyCurrentSqlBinding(com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler)
    throws java.lang.UnsupportedOperationException
Get the INSERT SQL binding to place into the ETL script for the next surrogate key value, e.g., myseq.nextval in Oracle.
Parameters:
anEntityHandler - data entity handler to generate surrogate key for.
Returns:
a valid SQL literal, function, token, sub statement or other SQL construct, or a JEXL expression or other syntax supported by Scriptella ETL.
public java.lang.String surrogateKeyNextSqlBinding(com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler)

Interface: IInlineDataEtlGenerator   previous next package

public interface com.arsi.mj.maprpt.entity.etlgen.IInlineDataEtlGenerator
Methods
public java.io.Reader generateCSV(com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler)
    throws com.arsi.mj.MJTranslateException
public java.lang.String generateScriptella(java.lang.String aTempTable, com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler, int anEntityNum, com.arsi.mj.maprpt.parser.tuple.inline.IInlineDataHandler anInlineHandler, java.lang.String aMapperReportDescription)
    throws com.arsi.mj.MJTranslateException

Interface: ILineMetadataEtlGenerator   previous next package

public interface com.arsi.mj.maprpt.entity.etlgen.ILineMetadataEtlGenerator
Methods
public java.io.Reader generateCSV(com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler)
    throws com.arsi.mj.MJTranslateException
public java.lang.String generateScriptella(java.lang.String aTempTable, com.arsi.mj.maprpt.entity.handler.DataEntityHandler anEntityHandler, java.lang.String aMapperReportDescription)
    throws com.arsi.mj.MJTranslateException

Class: InsertSQL   previous next package

Represents an SQL INSERT statement generated by Hibernate (or other means) and the place holders in the VALUES clause of the statement.
Treat as "thread-safe" since immutable once created.
public class com.arsi.mj.maprpt.entity.etlgen.InsertSQL
  extends java.lang.Object

Class: InsertSQLPlaceholder   previous next package

Represents a place holder (e.g., ?) in an SQL INSERT statement generated by Hibernate or other means.
Treat as "thread-safe" since immutable once created.
public class com.arsi.mj.maprpt.entity.etlgen.InsertSQLPlaceholder
  extends java.lang.Object

Class: PredefinedObjectFactory   previous next package

Simple class for creating objects whose definition is always known but have utility when treated as other objects that are created dynamically.
Treat this class as "thread-safe", since the methods here are static and should use or save no state.
public class com.arsi.mj.maprpt.entity.etlgen.PredefinedObjectFactory
  extends java.lang.Object
Constructors
public PredefinedObjectFactory()
Methods
Create a data entity handler instance for the key map temporary prototype persistent entity (the prototype is used as the basis for a temporary table that maps previously generated keys to Mapper line numbers for a "real" data entity).
A data entity handler is typically configured as a Spring bean but we can hard code everything for the prototype since it never varies and must always exist for MJ's ETL capabilities to function properly.
Returns:
data entity handler instance.
public static com.arsi.mj.maprpt.entity.handler.DataEntityHandler createEntityHandlerForTempKeyMapPrototype()

Exception: VetoOnPrepareException   previous package

Runtime exception thrown to act as veto of org.hibernate.Interceptor.onPrepareStatement once SQL has been obtained.
public class com.arsi.mj.maprpt.entity.etlgen.VetoOnPrepareException
  extends java.lang.RuntimeException
Constructors
public VetoOnPrepareException()