public class DmoMeta
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
DmoMeta.WordIndexData
Word index data.
|
Modifier and Type | Field and Description |
---|---|
java.lang.String |
afterTable
Caches the
afterTable attribute from Table annotation. |
java.lang.String |
beforeTable
Caches the
beforeTable attribute from Table annotation. |
java.lang.String |
category
Caches the
category attribute from Table annotation. |
private java.util.Map<java.lang.String,java.lang.Boolean> |
computedIndexedProperties
The set of indexed, character columns.
|
protected java.util.Map<java.lang.String,java.util.List<Property>> |
customExtents
The annotation to for the field corresponding to custom extents
|
private java.util.List<P2JIndex> |
databaseIndexes
The cached list of indexes (lazy initialized in
getDatabaseIndexes() ). |
boolean |
dirtyRead
Caches the
dirtyRead attribute from Table annotation. |
protected java.lang.Class<? extends DataModelObject> |
dmoImplInterface
The interface that will be implemented by
DmoClass es. |
private java.util.Map<java.lang.String,P2JField> |
existingFields
The map of DMO property names to field descriptors for this DMO metadata.
|
protected java.util.Map<java.lang.String,Property> |
fields
The set of annotations for each declared field, mapped by the FQL property name.
|
protected java.util.Map<java.lang.String,Property> |
fieldsByLegacy
The set of annotations for each declared field, mapped by its legacy name.
|
boolean |
hasValidation
Caches the
hasValidation attribute from Table annotation. |
private int |
id
The unique id of this DMO.
|
private static java.util.concurrent.atomic.AtomicInteger |
idSeed
The id generator.
|
protected java.lang.Class<? extends DataModelObject> |
iface
The interface of this DMO.
|
protected java.lang.Class<? extends Record> |
implClass
The implementation class of this DMO.
|
protected java.util.List<Index> |
indexes
The list of indexes of this table.
|
private java.util.Map<java.lang.Class<?>,RelationInfo> |
inverseRelations
Map of all foreign relation descriptors, indexed by local class
|
boolean |
isLikeSequential
Caches the
isLikeSequential attribute from Table annotation. |
java.lang.String |
legacyTable
Caches the interned
legacy attribute from Table annotation. |
private static java.util.logging.Logger |
log
Logger
|
private java.util.List<Property> |
mandatoryFields
The cached list of mandatory fields.
|
java.lang.String |
namespacePrefix
Caches the
namespacePrefix attribute from Table annotation. |
java.lang.String |
namespaceUri
Caches the
namespaceUri attribute from Table annotation. |
java.lang.String |
normalizedLegacyTable
Caches the interned normalized
legacy attribute from Table annotation. |
boolean |
noUndo
Caches the
NO-UNDO attribute from Table annotation (TEMP-TABLE specific). |
private java.util.List<Property> |
originalFields
The cached list of original fields / properties (lazy initialized in
getFields ). |
private org.apache.commons.lang3.tuple.Pair<Property,PropertyMeta>[] |
properties
The set of properties and their metadata, indexed by their in-memory positions.
|
private java.util.Map<java.lang.reflect.Method,PropertyMeta> |
propsByGetter
The set of properties mapped by their getters.
|
private java.util.Map<java.lang.reflect.Method,PropertyMeta> |
propsBySetter
The set of properties mapped by their setters.
|
protected RecordMeta |
recordMeta
The record's runtime-meta data.
|
private java.util.Map<java.lang.Class<? extends DataModelObject>,RelationInfo> |
relations
Map of all foreign relation descriptors, indexed by foreign class.
|
java.lang.String |
schema
Schema name associated with this DMO
|
java.lang.String |
serializeName
Caches the
serializeName attribute from Table annotation. |
private DmoSignature |
signature
A signature containing information about the DMO structure and field constraints.
|
java.lang.String |
sqlTable
Caches the
name attribute (SQL table name) from Table annotation. |
protected Table |
table
The annotation for the table.
|
boolean |
tempTable
Flags DMOs of temporary tables.
|
private static java.util.Map<java.lang.Class<? extends BaseDataType>,java.lang.Class<? extends BaseDataType>> |
toWider |
private java.util.List<java.util.Set<java.lang.String>> |
uniqueConstraints
The cached list of sets of properties participating in UNIQUES indexes.
|
private java.util.List<java.util.List<Property>> |
uniqueProps
The cached list of lists of whole property instances participating in UNIQUES indexes.
|
java.lang.String |
xmlNodeName
Caches the
xmlNodeName attribute from Table annotation. |
Constructor and Description |
---|
DmoMeta(java.lang.Class<? extends DataModelObject> dmoImplInterface,
java.lang.Class<? extends DataModelObject> iface,
Table table)
The constructor initializes the data structure.
|
Modifier and Type | Method and Description |
---|---|
Property |
byLegacyName(java.lang.String legacyField)
Looks up a
Property by its legacy field name. |
java.lang.Class<? extends DataModelObject> |
getAnnotatedInterface()
Obtain the interface that contains the annotations.
|
java.util.Iterator<P2JIndex> |
getDatabaseIndexes()
Get an iterator on all indexes of the DMO.
|
java.lang.Class<? extends DataModelObject> |
getDmoImplInterface()
Obtain the implemented DMO interface.
|
P2JField |
getExistingField(java.lang.String name)
Get the descriptor of a field corresponding with the given DMO property name.
|
java.util.Collection<P2JField> |
getExistingFields()
Get the field descriptors for the table associated with this metadata object.
|
Property |
getFieldInfo(java.lang.String propName)
Obtain meta information about a field specified by its property name.
|
java.util.Iterator<Property> |
getFields(boolean extra)
Obtain the list of properties for this DMO.
|
int |
getId()
Obtain the unique
id of this instance. |
java.lang.Class<? extends Record> |
getImplementationClass()
Obtain the class that implements the DMO interface.
|
int |
getIndexCount(boolean unique)
Return the number of indices for this table (declared in DMO annotations).
|
(package private) RelationInfo |
getInverseRelation(java.lang.Class<?> local)
Get the relation descriptor for the relation to this object's DMO class from
local . |
java.util.List<Property> |
getMandatoryFields()
Get the list of mandatory fields.
|
PropertyMeta |
getMeta(int k)
Get
PropertyMeta that correspond to the k-th entry in data table of the class
implementing this DMO. |
private java.util.Map<java.lang.String,P2JField> |
getOrCreateExistingFields()
Get the map of DMO property names to
P2JField objects describing the corresponding fields,
creating it first, if necessary. |
P2JIndex |
getPrimaryIndex(boolean implicit)
Get the primary index.
|
Property |
getProperty(int k)
Get the
Property that correspond to the k-th entry in data table of the class
implementing this DMO. |
java.util.Map<java.lang.reflect.Method,PropertyMeta> |
getPropsByGetterMap()
Returns (after eventually has constructed) the map of getters to
PropertyMeta map, used to
fast-access record copy (bypassing the reflection to retrieve a field's value). |
java.util.Map<java.lang.reflect.Method,PropertyMeta> |
getPropsBySetterMap()
Returns (after eventually has constructed) the map of setters to
PropertyMeta map, used by
RecordBuffer$Handler . |
RecordMeta |
getRecordMeta()
Get the
RecordMeta holding the runtime meta information of this table. |
RelationInfo |
getRelation(java.lang.Class<?> foreign)
Get the relation descriptor for the relation from this object's DMO class to
foreign . |
java.lang.String |
getSchema()
Obtain the schema name for the DMO represented by this object.
|
private static java.lang.String |
getSchemaByInterface(java.lang.Class<? extends DataModelObject> dmoIface,
boolean temporary)
Return the schema name associated with the given DMO interface.
|
DmoSignature |
getSignature()
Get the structure-based signature for this DMO.
|
java.lang.String |
getSqlTableName()
Obtain the name of the SQL table for this DMO.
|
java.lang.String |
getTableDefinition()
Constructs and returns a string containing the P4GL schema definition of the table.
|
java.util.List<java.util.Set<java.lang.String>> |
getUniqueConstraints()
Obtain the the sets of unique constraints for each DMO.
|
java.util.List<java.util.List<Property>> |
getUniqueConstraintsAsProps()
Obtain the lists of unique constraints for each DMO.
|
java.util.Map<java.lang.String,DmoMeta.WordIndexData> |
getWordTables()
Get word tables' names map by the field name
|
java.util.Map<java.lang.String,java.lang.String> |
getWordTablesByIndexName()
Get word tables' names map by the index name
|
java.util.Iterator<RelationInfo> |
inverseRelations()
Get an iterator on all foreign relation descriptors for the current DMO, which describe
relations to this table from another.
|
boolean |
isDirtyRead()
Test whether the table of this DMO was marked as "dirty read", that is, if the DMO should
share its dirty data.
|
java.lang.Boolean |
isIndexedIgnoreCase(java.lang.String property)
For a given DMO property which may represent an indexed text column, indicate whether that
column is set to ignore case.
|
boolean |
isLeadingIndexComponent(java.lang.String property)
Determine whether the given DMO property represents the leading component of any index on this table.
|
boolean |
isMeta()
Check if DMO corresponds to a meta table.
|
boolean |
isTempTable()
Test whether the DMO belongs to a temp table.
|
boolean |
isVST(MetadataManager.SystemTable systemTable)
Check if DMO corresponds to a specified VST.
|
private void |
processRelations()
Process all relations of this DMO.
|
(package private) void |
putInverseRelation(java.lang.Class<?> local,
RelationInfo info)
Add an object which describes a foreign relation to this table from another.
|
(package private) void |
putRelation(java.lang.Class<? extends DataModelObject> foreign,
RelationInfo info)
Add an object which describes a foreign relation from this table to another.
|
java.util.Iterator<RelationInfo> |
relations()
Get an iterator on all foreign relation descriptors for the current
DMO, which describe relations from this table to another.
|
(package private) void |
setImplClass(java.lang.Class<? extends Record> implClass)
Use the passed
implClass to extract the property metadata and store locally in an indexed
array for fast access. |
java.lang.String |
toString()
Obtain a short description of this object, usually for debugging.
|
private static final java.util.logging.Logger log
private static final java.util.concurrent.atomic.AtomicInteger idSeed
id
of each DmoMeta
is unique.protected final Table table
protected RecordMeta recordMeta
protected java.util.Map<java.lang.String,Property> fields
protected java.util.Map<java.lang.String,java.util.List<Property>> customExtents
protected java.util.Map<java.lang.String,Property> fieldsByLegacy
protected java.util.List<Index> indexes
protected final java.lang.Class<? extends DataModelObject> iface
protected final java.lang.Class<? extends DataModelObject> dmoImplInterface
DmoClass
es.protected java.lang.Class<? extends Record> implClass
private volatile java.util.Map<java.lang.String,P2JField> existingFields
private java.util.List<Property> originalFields
getFields
).private java.util.List<P2JIndex> databaseIndexes
getDatabaseIndexes()
).private java.util.Map<java.lang.reflect.Method,PropertyMeta> propsBySetter
private java.util.Map<java.lang.reflect.Method,PropertyMeta> propsByGetter
private java.util.List<java.util.Set<java.lang.String>> uniqueConstraints
private java.util.List<java.util.List<Property>> uniqueProps
private java.util.List<Property> mandatoryFields
private java.util.Map<java.lang.String,java.lang.Boolean> computedIndexedProperties
private java.util.Map<java.lang.Class<? extends DataModelObject>,RelationInfo> relations
private final java.util.Map<java.lang.Class<?>,RelationInfo> inverseRelations
public final boolean tempTable
public final java.lang.String schema
public final java.lang.String sqlTable
name
attribute (SQL table name) from Table
annotation.public final java.lang.String legacyTable
legacy
attribute from Table
annotation.public final java.lang.String normalizedLegacyTable
legacy
attribute from Table
annotation.public final java.lang.String afterTable
afterTable
attribute from Table
annotation.public final java.lang.String beforeTable
beforeTable
attribute from Table
annotation.public final java.lang.String category
category
attribute from Table
annotation.public final boolean dirtyRead
dirtyRead
attribute from Table
annotation.public final boolean hasValidation
hasValidation
attribute from Table
annotation.public final boolean isLikeSequential
isLikeSequential
attribute from Table
annotation.public final java.lang.String serializeName
serializeName
attribute from Table
annotation.public final java.lang.String xmlNodeName
xmlNodeName
attribute from Table
annotation.public final java.lang.String namespaceUri
namespaceUri
attribute from Table
annotation.public final java.lang.String namespacePrefix
namespacePrefix
attribute from Table
annotation.private final DmoSignature signature
public final boolean noUndo
NO-UNDO
attribute from Table
annotation (TEMP-TABLE specific).private org.apache.commons.lang3.tuple.Pair<Property,PropertyMeta>[] properties
private final int id
private static final java.util.Map<java.lang.Class<? extends BaseDataType>,java.lang.Class<? extends BaseDataType>> toWider
DmoMeta(java.lang.Class<? extends DataModelObject> dmoImplInterface, java.lang.Class<? extends DataModelObject> iface, Table table)
dmoImplInterface
- The interface that will be implemented by DmoClass
es.iface
- The interface that contains the field declarations and the DMO annotations. It is a
parent of dmoImplInterface
or dmoImplInterface
itself. Its (getter)
methods are iterated in order to extract the annotations for the fields.table
- The Table
annotation of iface
. This is the same value from
iface.getAnnotation(Table.class)
.private static java.lang.String getSchemaByInterface(java.lang.Class<? extends DataModelObject> dmoIface, boolean temporary)
dmoIface
- A DMO interface; if a temporary DMO, the temp table schema name is returned.temporary
- true
if dmoIface
represents a legacy temp-table, else false
.public java.lang.Class<? extends DataModelObject> getAnnotatedInterface()
public java.lang.Class<? extends Record> getImplementationClass()
public java.lang.Class<? extends DataModelObject> getDmoImplInterface()
public java.lang.String getSchema()
public int getId()
id
of this instance. The id is unique among all databases. The id
is
usually not the same for multiple runs because the id
s are assigned in the order the tables are
processed.public RecordMeta getRecordMeta()
RecordMeta
holding the runtime meta information of this table.RecordMeta
holding the runtime meta information of this table.public java.lang.String getSqlTableName()
public boolean isTempTable()
true
if the DMO belongs to a temp table.public boolean isDirtyRead()
true
if the table needs to be tracked by the dirty share manager and was
hinted at conversion time with dirty-read
XML attribute.public Property getFieldInfo(java.lang.String propName)
propName
- The field's property name.propName
field if it exists, or null
otherwise.public Property byLegacyName(java.lang.String legacyField)
Property
by its legacy field name.
Note:
This method is rather slow. Do not use it unless you have no other solution.
At the moment when this method was added, it is only needed from within serial
package. This
is also the reason it is public
.
legacyField
- The name of the legacy field.Property
whose legacy name was passed as parameter.public java.util.Iterator<Property> getFields(boolean extra)
extra
- If true
the surrogate/hidden properties (id
, _multiplex
)
are also added, otherwise only the original fields are returned.public P2JField getExistingField(java.lang.String name)
name
- DMO property name for the desired field descriptor.public java.util.Collection<P2JField> getExistingFields()
public boolean isLeadingIndexComponent(java.lang.String property)
property
- DMO property to be tested.true
if property
is a leading index component; else false
.public int getIndexCount(boolean unique)
unique
- Use true
to get the number of unique indices and false
to get the number of
non-unique indices. To obtain the number of all indices, the called must add the two results.public java.util.Map<java.lang.String,DmoMeta.WordIndexData> getWordTables()
public java.util.Map<java.lang.String,java.lang.String> getWordTablesByIndexName()
public java.util.Iterator<P2JIndex> getDatabaseIndexes()
P2JIndex
objects, each of which defines the columns participating in an index.public P2JIndex getPrimaryIndex(boolean implicit)
implicit == false
the method returns false
. If implicit == true
, the first
declared index is returned. If the table does not define any fields, null
is returned.implicit
- If true
, if there is no explicit primary index, the first index is returned as being
the implicit primary index. Otherwise, in the event there is no primary index declared,
the method returns null
.null
as described above.public java.util.List<Property> getMandatoryFields()
mandatoryFields
.public java.lang.Boolean isIndexedIgnoreCase(java.lang.String property)
property
- DMO property name.true
to ignore case, false
to preserve case sensitivity,
null
if the property does not represent an indexed text column.public java.util.List<java.util.Set<java.lang.String>> getUniqueConstraints()
public java.util.List<java.util.List<Property>> getUniqueConstraintsAsProps()
public Property getProperty(int k)
Property
that correspond to the k-th entry in data
table of the class
implementing this DMO.k
- The index of the property.public PropertyMeta getMeta(int k)
PropertyMeta
that correspond to the k-th entry in data
table of the class
implementing this DMO.k
- The index of the property.void setImplClass(java.lang.Class<? extends Record> implClass) throws java.lang.IllegalAccessException, java.lang.NoSuchFieldException
implClass
to extract the property metadata and store locally in an indexed
array for fast access. The indexed array contain both the Property
annotation and the
PropertyMeta
data paired so they can be accessed using getProperty(int)
and
getMeta(int)
methods respectively.implClass
- The implementation class to be processed for extraction of property metadata.java.lang.IllegalAccessException
- when the implClass cannot be accessed via reflection.java.lang.NoSuchFieldException
- when the implClass cannot be accessed via reflection.public RelationInfo getRelation(java.lang.Class<?> foreign)
foreign
.foreign
- DMO interface for the foreign table.null
if this DMO has no foreign key relation with
foreign
.void putRelation(java.lang.Class<? extends DataModelObject> foreign, RelationInfo info)
foreign
- DMO interface for the foreign table.info
- Relation descriptor.public java.util.Iterator<RelationInfo> relations()
RelationInfo
objects.RelationInfo getInverseRelation(java.lang.Class<?> local)
local
.local
- DMO interface for the local table.null
if this DMO has no inverse foreign key relation
with local
.void putInverseRelation(java.lang.Class<?> local, RelationInfo info)
local
- DMO interface for the local table.info
- Relation descriptor.public java.util.Iterator<RelationInfo> inverseRelations()
RelationInfo
objects.private void processRelations()
public java.util.Map<java.lang.reflect.Method,PropertyMeta> getPropsByGetterMap()
PropertyMeta
map, used to
fast-access record copy (bypassing the reflection to retrieve a field's value).PropertyMeta
map.public java.util.Map<java.lang.reflect.Method,PropertyMeta> getPropsBySetterMap()
PropertyMeta
map, used by
RecordBuffer$Handler
.PropertyMeta
map.public DmoSignature getSignature()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getTableDefinition()
public boolean isMeta()
true
if DMO corresponds to a meta table..public boolean isVST(MetadataManager.SystemTable systemTable)
systemTable
- VST to be checkedtrue
if DMO corresponds to a specified VST.private java.util.Map<java.lang.String,P2JField> getOrCreateExistingFields()
P2JField
objects describing the corresponding fields,
creating it first, if necessary.