public final class MetadataManager
extends java.lang.Object
isMetaDMO(Class) method, however, is meant to be used by callers who need to
determine whether a particular DMO interface is metadata-related.| Modifier and Type | Class and Description |
|---|---|
static class |
MetadataManager.Category
System table categories
|
private static class |
MetadataManager.FileTableRecordBuilder
_File table record field/value map builder.
|
private static class |
MetadataManager.Helper
Helper class for calling DMO setter methods when populating a metaschema record.
|
private static class |
MetadataManager.MapBuilder<T extends MetadataManager.MapBuilder<T>>
Map<String, Object> fluent builder. |
static class |
MetadataManager.SystemTable
System tables (as of Progress 11.6.3)
|
private static interface |
MetadataManager.TableFlags
System tables' flags
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
_CONNECT
Constant used to identify the
_Connect meta table. |
static java.lang.String |
_DB
Constant used to identify the
_Db meta table. |
static java.lang.String |
_FIELD
Constant used to identify the
_Field meta table. |
static java.lang.String |
_FILE
Constant used to identify the
_File meta table. |
static java.lang.String |
_INDEX
Constant used to identify the
_Index meta table. |
static java.lang.String |
_INDEX_FIELD
Constant used to identify the
_Index meta table. |
static java.lang.String |
_LOCK
Constant used to identify the
_Lock meta table. |
static java.lang.String |
_MYCONNECTION
Constant used to identify the
_MyConnection meta table. |
static java.lang.String |
_TRANS
Constant used to identify the
_Trans meta table. |
static java.lang.String |
_USER
Constant used to identify the
_User meta table. |
static java.lang.String |
_USERTABLESTAT
Constant used to identify the
_UserTableStat meta table. |
private static java.lang.String |
baseDir
Base directory for DMO resources in jar file
|
private static java.util.Set<java.lang.String> |
CHAR_TYPES
Character field types
|
private static java.util.Map<Database,Database> |
coreDatabases
Map that stores the core database for a tenant database.
|
private static int |
DB_RECID
The recid of the database in
_Db table. |
static java.lang.String |
DDL_INDEX
Well-known name of DDL script to create indexes
|
static java.lang.String |
DDL_TABLE
Well-known name of DDL script to create tables
|
private static java.util.Set<java.lang.Class<? extends DataModelObject>> |
dmoMetaTypes
Set of DMO interfaces which are metadata DMOs
|
private static java.util.Map<java.lang.String,java.lang.Integer> |
DTYPE
Map of data type names to associated _Field._dtype value
|
private static java.util.Map<java.lang.String,java.lang.String> |
FETCH_TYPE
Map of data type names to associated _Field._fetch-type value
|
private static java.util.concurrent.ConcurrentMap<Database,java.util.concurrent.ConcurrentMap<java.lang.Class<?>,integer>> |
FILE_NUM
_File._File_num values for the primary databases
|
private static java.util.concurrent.ConcurrentMap<Database,java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Integer>> |
FILE_NUM_BY_TBL_NAME
_File._File_num values for the primary databases by table name
|
private static java.util.Map<java.lang.String,MetadataManager.Helper> |
helpers
Map of short meta DMO names to helper objects
|
private static boolean |
inUse
Stores the status of the metadata server.
|
private static CentralLogger |
log
Logger
|
private static boolean |
LOG_INFO
Do we log INFO-level events ?
|
private static boolean |
LOG_WARNING
Do we log WARNING-level events ?
|
static java.lang.String |
META_PREFIX
Well-known prefix of metadata DMOs
|
static java.lang.String |
META_SCHEMA
Well-known name of metadata schema
|
private static java.util.concurrent.ConcurrentMap<Database,java.util.concurrent.ConcurrentMap<java.lang.String,java.util.concurrent.atomic.AtomicLong>> |
TABLE_IDS
_File table ID generator
|
private static java.util.Map<java.lang.Class<? extends Record>,java.lang.Long> |
templateRecords
Cached the template records (
_file._template values) for fast access. |
private static java.util.concurrent.ConcurrentMap<java.lang.String,java.util.Map<java.lang.String,java.util.Map<java.lang.String,DmoMeta.WordIndexData>>> |
WORD_TABLES
Word tables' names for the primary databases
|
| Modifier | Constructor and Description |
|---|---|
private |
MetadataManager()
Private constructor; this class is not instantiated.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addDynamicTableToFile(Database primaryDb,
java.lang.String dmoName)
Adds the details of a dynamic permanent table to meta tables.
|
private static void |
addFilelist(Persistence p,
MetadataManager.Helper h,
int fileListId,
int fileListSize,
int fileListExtend,
int fileListLogicalSz,
int fileListBlkSize,
java.lang.String fileListOpenmode,
java.lang.String fileListName)
Sets a single _Filelist metatable data.
|
private static boolean |
addMetaTableToFile(Database metaDb,
MetadataManager.Helper fileHelper,
java.lang.Class<? extends DataModelObject> dmoIface,
java.lang.Class<? extends Record> dmoImpl,
Persistence p)
Add record for a table from the meta database to the _File table.
|
private static void |
addTableToFile(Database primary,
Database meta,
java.lang.String dmoName,
MetadataManager.Helper fileHelper,
Persistence p)
Add record for a table from the primary database to the _File table.
|
private static java.util.Map<MetadataManager.SystemTable,java.util.List<java.util.Map<java.lang.String,java.lang.Object>>> |
childData(Database metaDb,
java.lang.Class<? extends DataModelObject> dmoIface,
int _file_num,
integer pk)
Collect child metadata for a record in the _File meta table.
|
private static void |
createDbMetaRecord(Database database,
Persistence p)
Creates and saves a record in
MetaDb table with the given recId. |
private static void |
deleteRecord(java.sql.Connection conn,
long p,
java.lang.String sql,
java.lang.String what)
Executes a specific delete statement and optionally log the result using the logger's configuration.
|
private static void |
executeDDLScript(Database database,
java.sql.Connection connection,
java.lang.String script)
Execute a script containing DDL SQL statements.
|
private static java.util.Map<java.lang.String,java.lang.Object> |
fieldData(Database metaDb,
int _file_num,
Property property,
java.lang.Class<?> ftype,
java.util.Map<java.lang.String,integer> fieldRecidByName,
java.util.Map<java.lang.String,integer> fieldRposByName)
Collect _Field table data for a DMO field.
|
static integer |
getFileNum(Database db,
java.lang.Class<?> dmoImpl)
Get _File._File_num value for the table
|
static java.lang.Integer |
getFileNum(Database db,
java.lang.String tableName)
Get _File._File_num value for the table
|
private static MetadataManager.Helper |
getHelper(java.lang.String type)
Gets the metadata helper for a specified table.
|
private static java.lang.String |
getShortName(java.lang.String tableName)
Calculate short DMO interface name for a table.
|
static java.lang.Long |
getTemplateRowid(java.lang.Class<?> table)
Return the rowid of the template record for a permanent table.
|
static DmoMeta.WordIndexData |
getWordTableName(java.lang.String dbName,
java.lang.String tableName,
java.lang.String fieldName)
Get the word index data.
|
private static void |
indexData(Database metaDb,
java.lang.String tblDmoName,
int _file_num,
java.util.Iterator<P2JIndex> indices,
integer pk,
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> indexes,
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> indexFields,
java.util.Map<java.lang.String,integer> fieldRecidByName)
Collect index metadata for a record in the _File meta table.
|
static boolean |
initialize()
Initialize this class and start up a secure database server to allow remote P2J servers to
access metadata.
|
static boolean |
inUse()
Checks the status of the metadata subsystem.
|
static boolean |
inUse(java.lang.String meta)
Checks the status of one of the tables of the metadata subsystem.
|
static boolean |
isMetaDMO(java.lang.Class<? extends DataModelObject> dmoIface)
Indicate whether the given DMO interface represents a metaschema table.
|
private static long |
nextId(Database metaDb,
java.lang.String table)
Return record id for table in the meta database.
|
private static void |
populateArea(Database database,
Persistence p)
Populates the
_Area meta table with initial values. |
static void |
populateDatabase(Database metaDb)
Populate the specified, embedded database with metaschema information read from DMO interface
annotations.
|
private static void |
populateDatabaseFeatures(Database database,
Persistence p)
Populates the
_Database-Feature meta table with initial values. |
private static void |
populateFilelist(Database database,
Persistence p)
Populates the
_Filelist meta table with initial values. |
private static void |
populateFileTable(Database database,
Persistence p)
Populates the
_File meta table with initial values. |
private static void |
populateSequence(Database metaDb,
Persistence p)
Populates the
_Sequence meta table with initial values. |
private static void |
populateStartupTable(Database database,
Persistence p)
Populates the
_Startup meta table with an initial record. |
private static void |
populateTenant(Database database,
Persistence p)
Populates the
_Tenant meta table with initial values. |
private static void |
populateTransTable(Database database,
Persistence p)
Populates the
_Trans meta table with an initial record. |
static void |
prepareDatabase(Database database)
Create and load the embedded metadata database for the associated primary database.
|
private static void |
registerWordTables(DmoMeta dmoMeta)
Register word tables for a master table.
|
static void |
removeDynamicTable(Database primaryDb,
DmoMeta dmoMeta)
Removes a registered dynamic permanent table from this manager.
|
static void |
reset(Database primaryDB,
Database metaDB)
Reset in-memory metadata.
|
private static void |
saveChildren(Persistence p,
java.util.Map<MetadataManager.SystemTable,java.util.List<java.util.Map<java.lang.String,java.lang.Object>>> children)
Save child metadata (_Field, _Index, _Index-Field, ...
|
private static void |
setArea(Persistence p,
MetadataManager.Helper h,
int areaVersion,
int areaNumber,
java.lang.String areaName,
int areaType,
int areaBlock,
int areaAttrib,
int areaClustersize,
int areaBlocksize,
int areaRecbits,
int areaExtents)
Sets a single _Area metatable data.
|
private static void |
setDatabaseFeature(Persistence p,
MetadataManager.Helper h,
int featureId,
java.lang.String featureName,
boolean isActive,
boolean isEnabled)
Sets a single database feature.
|
private static void |
setMetaTableRecord(Persistence p,
MetadataManager.Helper h,
java.util.Map<java.lang.String,java.lang.Object> values)
Created a new meta-table record using the helper constructor, populates it with the values passed in the
map and save it to (meta) database.
|
static void |
setupIdentityManager(Database database,
Dialect dialect)
Set up sequence identity mManager for this database by creating the fresh instance of
p2j_id_generator_sequence. |
public static final java.lang.String META_SCHEMA
public static final java.lang.String META_PREFIX
public static final java.lang.String DDL_TABLE
public static final java.lang.String DDL_INDEX
public static final java.lang.String _FILE
_File meta table. Used a key in helpers.public static final java.lang.String _DB
_Db meta table. Used a key in helpers.public static final java.lang.String _LOCK
_Lock meta table. Used a key in helpers.public static final java.lang.String _MYCONNECTION
_MyConnection meta table. Used a key in helpers.public static final java.lang.String _CONNECT
_Connect meta table. Used a key in helpers.public static final java.lang.String _TRANS
_Trans meta table. Used a key in helpers.public static final java.lang.String _INDEX
_Index meta table. Used a key in helpers.public static final java.lang.String _INDEX_FIELD
_Index meta table. Used a key in helpers.public static final java.lang.String _FIELD
_Field meta table. Used a key in helpers.public static final java.lang.String _USERTABLESTAT
_UserTableStat meta table. Used a key in helpers.public static final java.lang.String _USER
_User meta table. Used a key in helpers.private static final CentralLogger log
private static final boolean LOG_WARNING
private static final boolean LOG_INFO
private static final int DB_RECID
_Db table.private static final java.util.Map<java.lang.String,java.lang.Integer> DTYPE
private static final java.util.Map<java.lang.String,java.lang.String> FETCH_TYPE
private static final java.util.Set<java.lang.String> CHAR_TYPES
private static final java.util.Map<java.lang.String,MetadataManager.Helper> helpers
private static final java.util.Map<Database,Database> coreDatabases
private static final java.util.Set<java.lang.Class<? extends DataModelObject>> dmoMetaTypes
private static final java.lang.String baseDir
private static boolean inUse
private static final java.util.Map<java.lang.Class<? extends Record>,java.lang.Long> templateRecords
_file._template values) for fast access. The keys are
the DMO implementation classes of the tables from permanent database. The values are the
rowid values as Long data.private static final java.util.concurrent.ConcurrentMap<Database,java.util.concurrent.ConcurrentMap<java.lang.String,java.util.concurrent.atomic.AtomicLong>> TABLE_IDS
private static final java.util.concurrent.ConcurrentMap<Database,java.util.concurrent.ConcurrentMap<java.lang.Class<?>,integer>> FILE_NUM
private static final java.util.concurrent.ConcurrentMap<Database,java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Integer>> FILE_NUM_BY_TBL_NAME
private static final java.util.concurrent.ConcurrentMap<java.lang.String,java.util.Map<java.lang.String,java.util.Map<java.lang.String,DmoMeta.WordIndexData>>> WORD_TABLES
private MetadataManager()
public static void reset(Database primaryDB, Database metaDB)
primaryDB - primary databasemetaDB - meta databasepublic static boolean isMetaDMO(java.lang.Class<? extends DataModelObject> dmoIface)
dmoIface - DMO interface to test.true if dmoIface represents a metaschema table, else false.public static integer getFileNum(Database db, java.lang.Class<?> dmoImpl)
db - primary dbdmoImpl - Table DMO classpublic static java.lang.Integer getFileNum(Database db, java.lang.String tableName)
db - primary dbtableName - Table nbamepublic static boolean initialize()
throws PersistenceException
true if the metadata manager was initialized; false if
there are no metadata classes found.PersistenceException - if there is any error initializing the class or starting the server.public static boolean inUse(java.lang.String meta)
true from the moment the initialize() has finished with success.
At that moment the whole metadata system is not yet ready as the metadata tables are not yet
populated.
Use this method to check if the project was not configured with this feature or if metadata
initialization failed, and quickly leave the calling method in these cases. If this method
returns false it means that:
meta - The short name (see _<name> constants in this class) of a metadata table.true if the MetadataManager was successfully initialized, queries
on internal data are possible and the specified meta table is active in the
current configuration.
Returns false if the initialization failed, the metadata is not "in use" or
the specified table does not appear in the metadata block of the current
config file.public static boolean inUse()
true from
the moment the initialize() has finished with success. At that moment the whole
metadata system is not yet ready as the metadata tables are not yet populated.
Use this method to check if the project was not configured with this feature or if metadata initialization failed, and quickly leave the calling method in these cases.
true if the MetadataManager was successfully initialized and
queries on internal data are possible and false if the initialization
failed and the metadata is not "in use".public static void prepareDatabase(Database database) throws PersistenceException
database - Database information object.PersistenceException - if there is any error creating or loading the database.public static void setupIdentityManager(Database database, Dialect dialect) throws PersistenceException
p2j_id_generator_sequence. Because it is repopulated at each startup the start value
of the sequence is not crucial; the value is hardcoded to 10000.database - The database to set up the identity manager for.dialect - The dialect for the database. It is used to build the DDL for the sequence create
statement.PersistenceException - if something goes wrong with database connection.public static void populateDatabase(Database metaDb) throws PersistenceException
metaDb - Metaschema database to populate.PersistenceException - if there is any problem reading the DMO annotations, instantiating DMO instances, or
inserting records into the database.public static DmoMeta.WordIndexData getWordTableName(java.lang.String dbName, java.lang.String tableName, java.lang.String fieldName)
dbName - Database name.tableName - Master table name.fieldName - Field name.public static void addDynamicTableToFile(Database primaryDb, java.lang.String dmoName)
primaryDb - The primary database where the table belongs to.dmoName - The DMO of the dynamic table.public static void removeDynamicTable(Database primaryDb, DmoMeta dmoMeta)
primaryDb - The primary databasedmoMeta - The meta information of the table to be removed.private static void deleteRecord(java.sql.Connection conn,
long p,
java.lang.String sql,
java.lang.String what)
throws java.sql.SQLException
conn - The Connection to database.sql - The SQL statement to be executed.p - The unique long parameter which identifies the records to be deleted.what - Used only when logging is enabled, additional information on what is deleted.java.sql.SQLException - If the statement failed to be executed.private static void populateFileTable(Database database, Persistence p)
_File meta table with initial values.database - The database structure whose features need to be added to _Database-Feature
table.p - The Persistence that manages the database.private static void addTableToFile(Database primary, Database meta, java.lang.String dmoName, MetadataManager.Helper fileHelper, Persistence p)
primary - primary databasemeta - meta databasedmoName - table DMO interfacefileHelper - _File table helperp - Persistence for the meta databaseprivate static void registerWordTables(DmoMeta dmoMeta)
dmoMeta - DmoMeta for master tableprivate static boolean addMetaTableToFile(Database metaDb, MetadataManager.Helper fileHelper, java.lang.Class<? extends DataModelObject> dmoIface, java.lang.Class<? extends Record> dmoImpl, Persistence p)
metaDb - meta databasefileHelper - _File table helperdmoIface - table DMO interfacedmoImpl - table DMOp - Persistence for the meta database.true if successfulprivate static void saveChildren(Persistence p, java.util.Map<MetadataManager.SystemTable,java.util.List<java.util.Map<java.lang.String,java.lang.Object>>> children)
p - Persistence for the meta databasechildren - child metadataprivate static void populateSequence(Database metaDb, Persistence p)
_Sequence meta table with initial values. These are specific
to FWD implementation, specific to backing database server or may be set manually in a
configuration file.metaDb - The database structure whose features need to be added to _Database-Feature
table.p - The Persistence that manages the database.private static void populateDatabaseFeatures(Database database, Persistence p)
_Database-Feature meta table with initial values. These are specific
to FWD implementation, specific to backing database server or may be set manually in a
configuration file.database - The database structure whose features need to be added to _Database-Feature
table.p - The Persistence that manages the database.private static void createDbMetaRecord(Database database, Persistence p)
MetaDb table with the given recId.database - The database to be processed.p - The persistence context to be used when saving.private static void populateArea(Database database, Persistence p)
_Area meta table with initial values.
This is a "mock" since _Area data has no meaningful counterparts in FWDdatabase - The database structure whose features need to be added to _Area
table.p - The Persistence that manages the database.private static void populateFilelist(Database database, Persistence p)
_Filelist meta table with initial values.
This is a "mock" since _Filelist data has no meaningful counterparts in FWDdatabase - The database structure whose features need to be added to _Area
table.p - The Persistence that manages the database.private static void populateStartupTable(Database database, Persistence p)
_Startup meta table with an initial record.database - The database.p - The Persistence that manages the database.private static void populateTransTable(Database database, Persistence p)
_Trans meta table with an initial record.database - The database.p - The Persistence that manages the database.private static void populateTenant(Database database, Persistence p)
_Tenant meta table with initial values.
This is a "mock" since _Tenant data has no meaningful counterparts in FWDdatabase - The database structure whose features need to be added to _Area
table.p - The Persistence that manages the database.private static void setDatabaseFeature(Persistence p, MetadataManager.Helper h, int featureId, java.lang.String featureName, boolean isActive, boolean isEnabled)
p - Persistence instance for the tableh - The helper to be used.featureId - The id of the feature to be set.featureName - The name of the feature to be set.isActive - Whether the feature is active at startup.isEnabled - Whether the feature is enabled at startup.private static void setArea(Persistence p, MetadataManager.Helper h, int areaVersion, int areaNumber, java.lang.String areaName, int areaType, int areaBlock, int areaAttrib, int areaClustersize, int areaBlocksize, int areaRecbits, int areaExtents)
p - Persistence instance for the tableh - The helper to be used.areaVersion - area versionareaNumber - area numberareaName - area nameareaType - area typeareaBlock - area blockareaAttrib - area attributesareaClustersize - area cluster sizeareaBlocksize - area block sizeareaRecbits - area recbits (rows per block = 2 ^ recbits)areaExtents - area extentsprivate static void addFilelist(Persistence p, MetadataManager.Helper h, int fileListId, int fileListSize, int fileListExtend, int fileListLogicalSz, int fileListBlkSize, java.lang.String fileListOpenmode, java.lang.String fileListName)
p - Persistence instance for the tableh - The helper to be used.fileListId - fileList idfileListSize - fileList sizefileListExtend - fileList extendfileListLogicalSz - fileList logical sizefileListBlkSize - fileList block sizefileListOpenmode - fileList open modefileListName - fileList nameprivate static void setMetaTableRecord(Persistence p, MetadataManager.Helper h, java.util.Map<java.lang.String,java.lang.Object> values)
p - Persistence instance for the tableh - The helper to be used.values - The record fields' valuesjava.lang.IllegalAccessExceptionjava.lang.InstantiationExceptionjava.lang.reflect.InvocationTargetExceptionjava.lang.IllegalArgumentExceptionPersistenceExceptionpublic static java.lang.Long getTemplateRowid(java.lang.Class<?> table)
table - The permanent table to lookup.rowid of the template record. If metadata is not enabled
for this project or _file metatable is not configured or table is
an invalid name null is returned.private static MetadataManager.Helper getHelper(java.lang.String type)
null is returned.type - The name of meta file.type, or null if no support such table was set up.private static void executeDDLScript(Database database, java.sql.Connection connection, java.lang.String script) throws PersistenceException
database - Target database.connection - Connection to target database.script - Short name of script file, which is expected to be found in the application jar
file. The following path is implied:
{base DMO package}._meta.{script name}
PersistenceException - if there is any error connecting to the target database or executing the DDL
statements.private static java.lang.String getShortName(java.lang.String tableName)
tableName - The table name.private static long nextId(Database metaDb, java.lang.String table)
metaDb - meta databasetable - meta tableprivate static java.util.Map<MetadataManager.SystemTable,java.util.List<java.util.Map<java.lang.String,java.lang.Object>>> childData(Database metaDb, java.lang.Class<? extends DataModelObject> dmoIface, int _file_num, integer pk)
metaDb - meta databasedmoIface - table DMO interface_file_num - _File._file_num field valuepk - table primary key id in the _Index table holderprivate static void indexData(Database metaDb, java.lang.String tblDmoName, int _file_num, java.util.Iterator<P2JIndex> indices, integer pk, java.util.List<java.util.Map<java.lang.String,java.lang.Object>> indexes, java.util.List<java.util.Map<java.lang.String,java.lang.Object>> indexFields, java.util.Map<java.lang.String,integer> fieldRecidByName)
metaDb - meta databasetblDmoName - table DMO_file_num - _File._file_num field valueindices - P2JIndex iteratorpk - table primary key id in the _Index table holderindexes - table indexes metadataindexFields - table index fields metadatafieldRecidByName - Map of property names to their recid.private static java.util.Map<java.lang.String,java.lang.Object> fieldData(Database metaDb, int _file_num, Property property, java.lang.Class<?> ftype, java.util.Map<java.lang.String,integer> fieldRecidByName, java.util.Map<java.lang.String,integer> fieldRposByName)
metaDb - meta database_file_num - _File._file_num field valueproperty - Property annotation of the field.fieldRecidByName - Fields' record id by property name map.fieldRposByName - Fields' (r)pos id by property name map.