class DynamicTablesHelper
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
DynamicTablesHelper.CacheData
DMO data to be cached for a dynamically defined temp-table.
|
private static class |
DynamicTablesHelper.CacheKey
A hashable key that encapsulates the characteristics which uniquely define the structure of
a dynamic temp-table; namely, its field and index definitions.
|
private class |
DynamicTablesHelper.Context
Context local information, used to clean up resources when the context ends and to respond
to queries about temp-table resources in use.
|
private static class |
DynamicTablesHelper.DMOInfo
Class which contains information about a dynamically define DMO, including the compiled
interface and implementation classes, and mappings between the legacy and converted fields.
|
private class |
DynamicTablesHelper.DMOResourceManager
An instance of this class manages resources requiring cleanup, across all contexts.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<DynamicTablesHelper.CacheKey,DynamicTablesHelper.CacheData> |
cache
Cache for dynamically converted and compiled DMO resources
|
private java.lang.Object |
cacheLock
Lock object on which to synchronize cache operations
|
private org.hibernate.cfg.Configuration |
cfg
Shared Hibernate
Configuration object. |
private ContextLocal<DynamicTablesHelper.Context> |
context
Containers for context-specific data.
|
private static java.lang.String |
DMO_BASE_PACKAGE
Base package for generated DMOs.
|
private static java.lang.String |
DMO_IFACE_CATEGORY
Category name for DMO interfaces, used in conversion rules.
|
private static java.lang.String |
DMO_IMPL_CATEGORY
Category name for DMO implementation classes, used in conversion rules.
|
private DynamicTablesHelper.DMOResourceManager |
dmoResourceManager
Cross-context manager which cleans up shared DMO resources once they go out of scope
|
private static DynamicTablesHelper |
instance
Singleton instance.
|
private static java.util.logging.Logger |
LOG
Logger.
|
private static java.util.Map<ParmType,java.lang.Integer> |
propTypeToProgress
Param type to Progress type.
|
private static AsmClassLoader |
systemInMemoryClassLoader
In-memory class loader
|
private java.util.concurrent.atomic.AtomicLong |
tableCounter
Counter used for generation of unique names for dynamic tables.
|
Modifier | Constructor and Description |
---|---|
private |
DynamicTablesHelper()
Private constructor to enforce singleton.
|
Modifier and Type | Method and Description |
---|---|
private long |
assignIds(Aast root,
long startId)
Traverse an AST and assign unique IDs to all of its nodes.
|
(package private) boolean |
createDynamicDMO(TempTableBuilder builder,
java.lang.String legacyTableName)
Generate DMO interface, implementation class and mapping document and register the new DMO
type.
|
(package private) void |
deregisterBuilder(TempTableBuilder builder)
Deregister the given temp-table builder from the DMO resource manager.
|
(package private) static Persistence |
findExistingTable(java.lang.String fullTableName)
Search for an existing table with the specified name.
|
private Aast |
generateSchemaAst(TempTableBuilder builder,
java.lang.String ifaceName,
java.lang.String tableName,
java.lang.String legacyTableName,
java.util.Map<java.lang.String,java.lang.String> fields4GLtoHibernate)
Generate AST that represents the target table and has the same structure as .p2o files from
the conversion stage.
|
(package private) static java.lang.String |
get4GLFieldName(java.lang.Class<?> dmoIface,
java.lang.String fieldNameHibernate)
Get 4GL field name by Hibernate field name for a dynamic DMO.
|
(package private) static java.lang.String |
get4GLTableName(Persistence persistence,
java.lang.String tableName4GL)
Get original 4GL table name.
|
(package private) static java.lang.String |
get4GLTableName(RecordBuffer buffer)
Get 4GL name of the table which corresponds the given record buffer.
|
(package private) static java.lang.String |
getHibernateFieldName(java.lang.Class<?> dmoIface,
int fieldId)
Get Hibernate field name by field creation id for a dynamic DMO.
|
(package private) static java.lang.String |
getHibernateFieldName(java.lang.Class<?> dmoIface,
java.lang.String name4gl)
Get Hibernate field name by 4GL field name for a dynamic DMO.
|
(package private) static DynamicTablesHelper |
getInstance()
Get singleton instance of the helper.
|
(package private) static TempTableBuilder |
getTableInfo(RecordBuffer buffer)
Returns the
TempTableBuilder object that contains information about the 4GL
representation of the table or null if there is no corresponding dynamic table
for the specified record buffer. |
(package private) static boolean |
isDynamicTableBuffer(RecordBuffer buffer)
Allows to determine if the buffer is for a dynamic table.
|
(package private) static java.lang.String |
normalizeName(java.lang.String name)
Normalize 4GL field or index name: drop trailing spaces and convert to lower case.
|
(package private) static java.lang.String[] |
parseTableName(java.lang.String fullTableName)
Get table name and database name from the string which represents full table name
|
private static java.lang.String |
rightTrim(java.lang.String str)
Convenience method to remove trailing spaces from the string.
|
(package private) static boolean |
tableExists(Persistence persistence,
java.lang.String tableName4GL)
Determines if the specified table exists.
|
private static final java.lang.String DMO_BASE_PACKAGE
private static final java.lang.String DMO_IMPL_CATEGORY
private static final java.lang.String DMO_IFACE_CATEGORY
private static final java.util.logging.Logger LOG
private static volatile DynamicTablesHelper instance
private static final java.util.Map<ParmType,java.lang.Integer> propTypeToProgress
private static AsmClassLoader systemInMemoryClassLoader
private final java.util.Map<DynamicTablesHelper.CacheKey,DynamicTablesHelper.CacheData> cache
private final java.lang.Object cacheLock
private final ContextLocal<DynamicTablesHelper.Context> context
private final java.util.concurrent.atomic.AtomicLong tableCounter
private final org.hibernate.cfg.Configuration cfg
Configuration
object.private final DynamicTablesHelper.DMOResourceManager dmoResourceManager
private DynamicTablesHelper()
static DynamicTablesHelper getInstance()
static java.lang.String getHibernateFieldName(java.lang.Class<?> dmoIface, java.lang.String name4gl)
dmoIface
- DMO interface that corresponds the target dynamic DMO class.name4gl
- 4GL field name.null
if no corresponding name was found.static java.lang.String getHibernateFieldName(java.lang.Class<?> dmoIface, int fieldId)
dmoIface
- DMO interface that corresponds the target dynamic DMO class.fieldId
- 4GL field id.null
if no corresponding name was found.static java.lang.String get4GLFieldName(java.lang.Class<?> dmoIface, java.lang.String fieldNameHibernate)
dmoIface
- DMO interface that corresponds the target dynamic DMO class.fieldNameHibernate
- Hibernate field name.null
if no corresponding name was found.static java.lang.String normalizeName(java.lang.String name)
name
- Field or index name to normalize.static java.lang.String[] parseTableName(java.lang.String fullTableName)
fullTableName
- The string which represents full table name. Can have two formats:
"databaseName.tableName" or "tableName".null
if the database name wasn't specified in the
full table name.static boolean isDynamicTableBuffer(RecordBuffer buffer)
buffer
- Buffer to check.true
if buffer is for a dynamic table.static java.lang.String get4GLTableName(RecordBuffer buffer)
buffer
- Record buffer.static TempTableBuilder getTableInfo(RecordBuffer buffer)
TempTableBuilder
object that contains information about the 4GL
representation of the table or null
if there is no corresponding dynamic table
for the specified record buffer.buffer
- Record buffer that corresponds to the target dynamic table.static boolean tableExists(Persistence persistence, java.lang.String tableName4GL)
persistence
- Persistence which corresponds the target database.tableName4GL
- 4GL table name.true
if the specified table exists.static Persistence findExistingTable(java.lang.String fullTableName)
fullTableName
- Table name in format "databaseName.tableName" or "tableName". In the latter case
table search is performed in all permanent databases and then the temporary
database. Dynamic tables are ignored.null
if there is
no such table.static java.lang.String get4GLTableName(Persistence persistence, java.lang.String tableName4GL)
persistence
- Persistence which corresponds the target database.tableName4GL
- 4GL table name (case-insensitive, may have trailing spaces).private static java.lang.String rightTrim(java.lang.String str)
str
- Target string.boolean createDynamicDMO(TempTableBuilder builder, java.lang.String legacyTableName)
builder
- Temporary table builder containing definitions of the target table.legacyTableName
- The legacy name of the table.true
on success.void deregisterBuilder(TempTableBuilder builder)
builder
- Builder to be deregistered.private Aast generateSchemaAst(TempTableBuilder builder, java.lang.String ifaceName, java.lang.String tableName, java.lang.String legacyTableName, java.util.Map<java.lang.String,java.lang.String> fields4GLtoHibernate)
builder
- Temporary table builder containing definitions of the target table.ifaceName
- The name of the target DMO interface.tableName
- The name of the target SQL table.legacyTableName
- The lecagy (Progress) name of the table.fields4GLtoHibernate
- Map 4GL field names to Hibernate names.private long assignIds(Aast root, long startId)
root
- The root node of the AST.startId
- First available id for assignment.