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<java.lang.String,java.lang.reflect.Constructor<?>> |
ctorMap
Map of short data type names to constructors which instantiate those types
|
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.Map<java.lang.String,java.lang.Class<?>> |
fieldClassMap
Map of short data type names to associated wrapper classes
|
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 java.util.logging.Logger |
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.lang.String |
PK_TYPE
The type of PK field.
|
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 |
---|---|
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 |
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 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,
java.lang.String schema)
Populate the specified, embedded database with metaschema information read from XML files
stored in the application jar file with a well-known naming/pathing convention:
|
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 |
populateTenant(Database database,
Persistence p)
Populates the
_Tenant meta table with initial values. |
static void |
prepareDatabase(Database database)
Create and load the embedded metadata database for the associated primary database.
|
private static Record |
prepareRecord(org.w3c.dom.Element record,
java.lang.String schema)
Given an XML element describing an individual metaschema table record, instantiate a DMO
and initialize its fields for the purpose of inserting the record into the metaschema
database.
|
private static void |
registerWordTables(DmoMeta dmoMeta)
Register word tables for a master table.
|
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)
Sets a meta-table record.
|
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 java.util.logging.Logger log
private static final boolean LOG_WARNING
private static final boolean LOG_INFO
private static final java.lang.String PK_TYPE
BaseDataType
.private static final java.util.Map<java.lang.String,java.lang.Class<?>> fieldClassMap
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,java.lang.reflect.Constructor<?>> ctorMap
private static final java.util.Map<java.lang.String,MetadataManager.Helper> helpers
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, java.lang.String schema) throws PersistenceException
{base DMO package}.{database name}.meta.xml
metaDb
- Metaschema database to populate.schema
- Name of the associated, primary database's schema.PersistenceException
- if there is any problem reading the XML file, 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.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 databasetrue
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 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 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.IllegalAccessException
java.lang.InstantiationException
java.lang.reflect.InvocationTargetException
java.lang.IllegalArgumentException
PersistenceException
public 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 Record prepareRecord(org.w3c.dom.Element record, java.lang.String schema) throws PersistenceException, java.lang.NoSuchMethodException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
record
- XML element describing the record to be inserted.schema
- Name of the associated, primary database's schema.PersistenceException
- if a data value to be set into the DMO is invalid/illegal for the associated setter
method.java.lang.NoSuchMethodException
- if a DMO setter method cannot be found.java.lang.InstantiationException
- if a DMO or data wrapper class cannot be instantiated.java.lang.reflect.InvocationTargetException
- if the underlying methods called with reflection throw an exception.java.lang.IllegalAccessException
- if a method called with reflection cannot be accessed.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
- table nameprivate 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.