class DataSetSDOHelper
extends java.lang.Object
The DataSet
is constructed as a DataGraph
, for which
the metadata has the following structure (each graph node is a DataObject
):
graph
type, with two properties:
scope
, which holds the HelperContext
used to build the metadata.
metadata
, having the custom graphmetadata
type.graphmetadata
defines the details about the tables and relations, in these properties:
scope
, which helps the HelperContext
used to build the metadataname
, a String with the DataSet nameidSequence
, the internal record ID sequencetables
, a list of tablemetadata
holding the defined tablesrelations
, a list ofrelationmetadata
holding the defined relationstablemetadata
defines the details about a table:
name
, a String with the legacy table name.numFields
, an int with the number of defined fields.b4img
, a boolean flag identifying if a table as a BEFORE-IMAGE.numIndexes
, an int identifying the number of defined indexes.indexes
, a String with the index definitions.xmlns
, a String with the XML namespace.xmlPrefix
, a String with the XML prefix.xmlNodeName
, a String with the XML node name.errorString
, a String with the table's ERROR-STRING attribute value.tabletype
, a Type
defining this table (used to add rows to the table). This
type MUST extend the baserowtype
, so that the rows know their container.
fields
, a list with the field definitions, of fieldmetadata
type.rows
, a list with the table's rows (they have as type a custom type
build based on the table'sfields
. The base type is
baserowtype
, an empty type.
beforeRows
, a list with the before-table's rows, with the same record
type as the rows
list. These are created/managed only when logging is enabled.
normalizedExtent
, flag indicating if the extent fields are kept in a single field
(normalized, as for Java clients) or denormalized, with individual fields for each index (as for
.NET clients).
relationmetadata
defines the details about a relation:
name
, a String with the relation name.parentBuffer
, a String with the name of the parent table.childBuffer
, a String with the name of the child table.whereString
, a String with the WHERE clause of this relation.active
, a Boolean with the relation's active state.parentId
, a Boolean with the parent-id state.pairs
, a String with parent, child
field pairs, comma delimited.fkeyHidden
, a Boolean with the FOREIGN-KEY-HIDDEN status.recursive
, a Boolean with the recursive status.nested
, a Boolean with the NESTED status.reposition
, a Boolean with Rthe REPOSITION status.fieldmetadata
defines the details about a field:
idx
, an int with the field's position in the table's fields
name
, a String with the legacy field name; indexed for denormalized extent.extent
, an int with the field's extent.extentIndex
, an int with the extent field's index, for denormalized extent.extentName
, the legacy name of the extent field (non-indexed).type
, a BaseDataType
class with the field's type.legacytype
, an int with the field's type, as specified by
LegacyJavaAppserver
constants.order
, an int with the fields order.xmlMapping
, a String with the XML name describing this field.LegacyJavaAppserver
.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DENORMALIZED_PREFIX
A prefix added to denormalized extent fields.
|
private static java.lang.String |
FWD_TABLE_TYPE_SUFFIX
The suffix for a table row.
|
static java.lang.String |
FWD_URI
The URI for the custom types.
|
private static java.util.logging.Logger |
LOG
Logger
|
static java.lang.String |
SDO_API_URI
The URI for defining known types (as int, String, etc).
|
Constructor and Description |
---|
DataSetSDOHelper() |
Modifier and Type | Method and Description |
---|---|
(package private) static void |
addBeforeObject(commonj.sdo.DataGraph graph,
commonj.sdo.DataObject row)
Add a new before-table row.
|
static void |
addDataObject(commonj.sdo.DataGraph graph,
commonj.sdo.DataObject row)
Add the specified row to the graph.
|
static void |
addDataObject(commonj.sdo.DataObject tableMetaData,
commonj.sdo.DataObject row)
Add the specified row to the graph.
|
protected static commonj.sdo.DataObject |
addPropertyDescription(commonj.sdo.DataObject containerType,
java.lang.Object propertyType,
java.lang.String propertyName)
Create a new property for the specified type.
|
static void |
addRelation(commonj.sdo.DataObject metaData,
java.lang.String name,
java.lang.String parentBuffer,
java.lang.String childBuffer,
java.lang.String whereString,
boolean active,
boolean parentId,
java.lang.String pairs,
boolean fkeyHidden,
boolean recursive,
boolean nested,
boolean reposition)
Add a relation to the graph's metadata.
|
static void |
addTableMetaData(commonj.sdo.DataObject metaData,
commonj.sdo.DataObject table)
Add the specified table metadata to the graph.
|
static void |
beginLogging(commonj.sdo.DataGraph graph)
Begin the logging for changes in this graph.
|
(package private) static java.lang.String |
buildDenormalizedFieldName(java.lang.String fname,
int idx)
Compute the denormalized field name.
|
private static void |
createBeforeRow(FWDDataObject record,
int state)
Create a before-table row with the specified state.
|
static commonj.sdo.DataGraph |
createDataGraph()
Create a new graph to hold a dataset.
|
static commonj.sdo.DataGraph |
createDataGraph(commonj.sdo.DataObject metadata)
Create a new metadata object to hold the table details.
|
static commonj.sdo.DataObject |
createDataObject(commonj.sdo.DataGraph graph,
java.lang.String table)
Create a new row for the specified table.
|
static commonj.sdo.DataObject |
createDataObject(commonj.sdo.DataObject tableMetaData)
Create a new row for the specified table.
|
static commonj.sdo.DataObject |
createGraphMetaData(java.lang.String name)
Create a metadata object with the specified name.
|
static void |
createGraphMetaDataTypes(commonj.sdo.helper.HelperContext scope)
Create the metadata types.
|
static commonj.sdo.DataObject |
createTableMetaData(java.lang.String name,
int numFields,
boolean b4img,
int numIndexes,
java.lang.String indexes,
java.lang.String xmlns,
java.lang.String xmlPrefix,
java.lang.String xmlNodeName,
java.lang.String errorString,
boolean normalizedExtent)
Create an object with a table metadata.
|
protected static commonj.sdo.DataObject |
createTypeDescription(commonj.sdo.helper.HelperContext scope,
java.lang.String uri,
java.lang.String name)
Create a new type description.
|
static void |
endLogging(commonj.sdo.DataGraph graph)
End the logging for changes in this graph.
|
static java.util.List<commonj.sdo.DataObject> |
getBeforeObjects(commonj.sdo.DataGraph graph,
java.lang.String name)
Get the before-table rows for the specified after-table.
|
static java.util.List<commonj.sdo.DataObject> |
getBeforeObjects(commonj.sdo.DataObject table)
Get the before-table rows for this after-table.
|
static java.util.List<commonj.sdo.DataObject> |
getChildRows(commonj.sdo.DataObject row,
java.lang.String relation)
Get the child rows for this record.
|
static java.lang.String |
getDataGraphName(commonj.sdo.DataObject metadata)
Get the graph name from the specified metadata, of type
graphmetadata . |
static java.util.List<commonj.sdo.DataObject> |
getDataObjects(commonj.sdo.DataGraph graph,
int idx)
Get all the records for the table on the specified index, in the graph metadata.
|
static java.util.List<commonj.sdo.DataObject> |
getDataObjects(commonj.sdo.DataGraph graph,
java.lang.String name)
Get all the records for the table with the given name, in the graph metadata.
|
static java.util.List<commonj.sdo.DataObject> |
getDataObjects(commonj.sdo.DataObject table)
Get all the records for this table.
|
static java.util.List<commonj.sdo.DataObject> |
getDataObjects(commonj.sdo.DataObject graphMeta,
java.lang.String name)
Get all the records for the table with the given name, in the graph metadata.
|
static int |
getFieldCount(commonj.sdo.DataObject row)
Get the number of fields for a given row.
|
static int |
getFieldExtent(commonj.sdo.DataObject fieldMeta)
Get the field's extent from the given field metadata.
|
static java.util.List<commonj.sdo.DataObject> |
getFieldMetaData(commonj.sdo.DataObject tableMeta)
Get the metadata for all fields in the specified table.
|
static commonj.sdo.DataObject |
getFieldMetaData(commonj.sdo.DataObject tableMeta,
java.lang.String fname,
boolean forceNormalizedFields)
Get the field metadata for the specified property.
|
static commonj.sdo.DataObject |
getFieldMetaData(commonj.sdo.DataObject tableMeta,
java.lang.String fname,
boolean forceNormalizedFields,
boolean failNotFound)
Get the field metadata for the specified property.
|
static java.lang.String |
getFieldName(commonj.sdo.DataObject fieldMeta)
Get the field's name from the given field metadata.
|
static java.lang.String |
getFieldName(commonj.sdo.DataObject row,
int i)
Get the name of the field on the given index in the metadata.
|
static int |
getFieldType(commonj.sdo.DataObject fieldMeta)
Get the type of the field from the given field metadata.
|
static int |
getFieldType(commonj.sdo.DataObject row,
int i)
Get the type of the field on the given index in the metadata.
|
static java.lang.String |
getGraphName(commonj.sdo.DataObject tableMetadata)
Get the data graph name for the given table metadata.
|
static commonj.sdo.DataObject |
getMetaData(commonj.sdo.DataGraph graph)
Get the metadata object for this graph, from the
metadata property of the root
object. |
private static long |
getNextId(commonj.sdo.DataGraph graph)
Get next internal record ID for this graph.
|
private static long |
getNextId(commonj.sdo.DataObject graphMeta)
Get next internal record ID for this graph.
|
static int |
getNumTables(commonj.sdo.DataObject metadata)
Get the number of tables for a graph metadata.
|
static int |
getTableFieldType(commonj.sdo.DataObject tableMetadata,
java.lang.String fieldName)
Get the field type.
|
static java.util.List<commonj.sdo.DataObject> |
getTableMetaData(commonj.sdo.DataGraph graph)
Get the metadata list for all tables.
|
static commonj.sdo.DataObject |
getTableMetaData(commonj.sdo.DataGraph graph,
java.lang.String table)
Get the metadata for the specified table.
|
static commonj.sdo.DataObject |
getTableMetaData(commonj.sdo.DataObject metaData,
int i)
Get the metadata for the table registered on the given index in the graph.
|
static commonj.sdo.DataObject |
getTableMetaData(commonj.sdo.DataObject metaData,
java.lang.String name)
Get the metadata for the table registered with the given name in the graph.
|
static java.lang.String |
getTableName(commonj.sdo.DataObject value)
Get the table name for a given row or table metadata.
|
static java.lang.String[] |
getTableNames(commonj.sdo.DataGraph graph)
Get all table names from the given graph.
|
static java.lang.String[] |
getTableNames(commonj.sdo.DataObject metadata)
Get all table names from the given graph metadata.
|
static boolean |
isTableField(commonj.sdo.DataObject tableMetadata,
java.lang.String fieldName)
Check if this table has a field defined with that name.
|
(package private) static void |
logChanged(FWDDataObject record)
Mark this record as being changed, in the before-table.
|
(package private) static void |
logCreated(FWDDataObject record)
Mark this record as being created, in the before-table.
|
(package private) static void |
logDeleted(FWDDataObject record)
Mark this record as being deleted, in the before-table.
|
static void |
main(java.lang.String[] args)
A simple test for the Tuscany SDO APIs.
|
static java.util.List<commonj.sdo.DataObject> |
selectRows(commonj.sdo.DataObject tableMetadata,
java.lang.String[] fields,
java.lang.Object[] values)
Retrieve all rows which have an exact match for the specified fields.
|
static commonj.sdo.DataObject |
setFieldMetaData(commonj.sdo.DataObject metaData,
int idx,
java.lang.String name,
int extent,
java.lang.Class<?> cls,
int legacyType,
int order,
int xmlMapping)
Add a new new field with the specified configuration.
|
static void |
setGraphMetaData(commonj.sdo.DataGraph graph,
commonj.sdo.DataObject metadata)
Set the metadata to the specified graph.
|
private static java.lang.String |
tableFromType(commonj.sdo.Type type)
Compute the table name from the custom type of the table's records.
|
private static java.lang.String |
tableTypeName(java.lang.String table)
Construct the custom type to hold records for this table.
|
public static final java.lang.String FWD_URI
public static final java.lang.String SDO_API_URI
public static final java.lang.String DENORMALIZED_PREFIX
private static final java.lang.String FWD_TABLE_TYPE_SUFFIX
private static final java.util.logging.Logger LOG
public static void beginLogging(commonj.sdo.DataGraph graph)
graph
- The graph to track changes.public static void endLogging(commonj.sdo.DataGraph graph)
graph
- The graph to track changes.public static java.lang.String getDataGraphName(commonj.sdo.DataObject metadata)
graphmetadata
.metadata
- The metadata.public static commonj.sdo.DataObject getMetaData(commonj.sdo.DataGraph graph)
metadata
property of the root
object.graph
- The graph.public static commonj.sdo.DataObject setFieldMetaData(commonj.sdo.DataObject metaData, int idx, java.lang.String name, int extent, java.lang.Class<?> cls, int legacyType, int order, int xmlMapping)
metaData
- The table metadata, of type tablemetadata
. The field will be added
to the fields
property.idx
- The field's index in the metadata.name
- The field's name.extent
- The field's extent.cls
- The fields BaseDataType
class.legacyType
- The legacy type (numeric value based on LegacyJavaAppserver
constants.order
- The field's order.xmlMapping
- The field's mapping.public static void addRelation(commonj.sdo.DataObject metaData, java.lang.String name, java.lang.String parentBuffer, java.lang.String childBuffer, java.lang.String whereString, boolean active, boolean parentId, java.lang.String pairs, boolean fkeyHidden, boolean recursive, boolean nested, boolean reposition)
metaData
- The graph metadata.name
- The relation name.parentBuffer
- The parent buffer.childBuffer
- The child buffer.whereString
- The where string.active
- Flag indicating if this relation is active.parentId
- Flag indicating if parent-id is used.pairs
- The field pairs, in parent, child
format.fkeyHidden
- Flag indicating if fkey-hidden is used.recursive
- Flag indicating if recursive is used.nested
- Flag indicating if nested is used.reposition
- Flag indicating if reposition is used.public static commonj.sdo.DataObject createTableMetaData(java.lang.String name, int numFields, boolean b4img, int numIndexes, java.lang.String indexes, java.lang.String xmlns, java.lang.String xmlPrefix, java.lang.String xmlNodeName, java.lang.String errorString, boolean normalizedExtent)
tablemetadata
type and is not
attached to the graph.name
- The table's name.numFields
- The number of fields.b4img
- Flag indicating if the table has a BEFORE-IMAGE.numIndexes
- The number of indexes.indexes
- The index specification (TODO: not validated/implemented at this time).xmlns
- The XML namespace (TODO: not validated/implemented at this time).xmlPrefix
- The XML prefix (TODO: not validated/implemented at this time).xmlNodeName
- The XML node name (TODO: not validated/implemented at this time).errorString
- The table's ERROR-STRING attribute (TODO: not validated/implemented at this time).normalizedExtent
- Flag indicating if the extents are normalized or individual fields will be created for each
index.public static void addTableMetaData(commonj.sdo.DataObject metaData, commonj.sdo.DataObject table)
metaData
- The graph metadata.table
- The table metadata.public static java.util.List<commonj.sdo.DataObject> getFieldMetaData(commonj.sdo.DataObject tableMeta)
tableMeta
- The table metadata.public static commonj.sdo.DataObject getFieldMetaData(commonj.sdo.DataObject tableMeta, java.lang.String fname, boolean forceNormalizedFields)
tableMeta
- The table metadata.fname
- The field name.forceNormalizedFields
- When this flag is set, only normalized extent fields are looked.java.lang.IllegalStateException
- If the field can't be resolved.public static commonj.sdo.DataObject getFieldMetaData(commonj.sdo.DataObject tableMeta, java.lang.String fname, boolean forceNormalizedFields, boolean failNotFound)
tableMeta
- The table metadata.fname
- The field name.forceNormalizedFields
- When this flag is set, only normalized extent fields are looked.failNotFound
- Throw an IllegalStateException
if the field can't be resolved.java.lang.IllegalStateException
- If the field can't be resolved and failNotFound
flag is set.public static commonj.sdo.DataObject getTableMetaData(commonj.sdo.DataObject metaData, int i)
metaData
- The graph metadata.i
- The table index.public static commonj.sdo.DataObject getTableMetaData(commonj.sdo.DataObject metaData, java.lang.String name)
metaData
- The graph metadata.name
- The table name.public static commonj.sdo.DataObject getTableMetaData(commonj.sdo.DataGraph graph, java.lang.String table)
graph
- The graph.table
- The table name.null
if the table is not part of this graph.public static java.util.List<commonj.sdo.DataObject> getTableMetaData(commonj.sdo.DataGraph graph)
graph
- The graph.public static commonj.sdo.DataGraph createDataGraph()
graph
node.public static commonj.sdo.DataGraph createDataGraph(commonj.sdo.DataObject metadata)
metadata
- The root graph node.public static void setGraphMetaData(commonj.sdo.DataGraph graph, commonj.sdo.DataObject metadata)
graph
- The graph object.metadata
- The metadata object which will be set to the graph's metadata
property.public static commonj.sdo.DataObject createGraphMetaData(java.lang.String name)
name
- The graph name.setGraphMetaData(commonj.sdo.DataGraph, commonj.sdo.DataObject)
.public static void createGraphMetaDataTypes(commonj.sdo.helper.HelperContext scope)
scope
- The helper context where the types will be defined.public static java.lang.String[] getTableNames(commonj.sdo.DataGraph graph)
graph
- The graph.public static java.lang.String[] getTableNames(commonj.sdo.DataObject metadata)
metadata
- The graph metadata.public static int getNumTables(commonj.sdo.DataObject metadata)
metadata
- The graph metadata.public static java.lang.String getTableName(commonj.sdo.DataObject value)
value
- The table row or table metadata.public static java.lang.String getGraphName(commonj.sdo.DataObject tableMetadata)
tableMetadata
- The table metadata.null
if the table is not part of a graph.public static int getFieldCount(commonj.sdo.DataObject row)
row
- The table row.public static java.lang.String getFieldName(commonj.sdo.DataObject row, int i)
row
- The table row. Must be attached to a table.i
- The field index.public static int getFieldType(commonj.sdo.DataObject row, int i)
row
- The table row. Must be attached to a table.i
- The field index.public static int getFieldType(commonj.sdo.DataObject fieldMeta)
fieldMeta
- The field metadata.public static boolean isTableField(commonj.sdo.DataObject tableMetadata, java.lang.String fieldName)
tableMetadata
- The table metadata.fieldName
- The field name.true
if there is a field defined with this name.public static int getTableFieldType(commonj.sdo.DataObject tableMetadata, java.lang.String fieldName)
tableMetadata
- The table metadata.fieldName
- The field name.public static int getFieldExtent(commonj.sdo.DataObject fieldMeta)
fieldMeta
- The field metadata.public static java.lang.String getFieldName(commonj.sdo.DataObject fieldMeta)
fieldMeta
- The field metadata.public static commonj.sdo.DataObject createDataObject(commonj.sdo.DataGraph graph, java.lang.String table)
addDataObject(commonj.sdo.DataGraph, commonj.sdo.DataObject)
to add it.graph
- The graph.table
- The table name.public static commonj.sdo.DataObject createDataObject(commonj.sdo.DataObject tableMetaData)
addDataObject(DataObject, DataObject)
to add it.tableMetaData
- The table metadata.public static void addDataObject(commonj.sdo.DataGraph graph, commonj.sdo.DataObject row)
graph
- The field'srow
- The row to add to the table.public static void addDataObject(commonj.sdo.DataObject tableMetaData, commonj.sdo.DataObject row)
tableMetaData
- The table metadata.row
- The row to add to the table.public static java.util.List<commonj.sdo.DataObject> getDataObjects(commonj.sdo.DataGraph graph, int idx)
graph
- The graph.idx
- The table index.public static java.util.List<commonj.sdo.DataObject> getDataObjects(commonj.sdo.DataObject table)
table
- The table metadata.public static java.util.List<commonj.sdo.DataObject> getBeforeObjects(commonj.sdo.DataObject table)
table
- The after-table.public static java.util.List<commonj.sdo.DataObject> getDataObjects(commonj.sdo.DataGraph graph, java.lang.String name)
graph
- The graph.name
- The table name.public static java.util.List<commonj.sdo.DataObject> getDataObjects(commonj.sdo.DataObject graphMeta, java.lang.String name)
graphMeta
- The graph metadata.name
- The table name.public static java.util.List<commonj.sdo.DataObject> getBeforeObjects(commonj.sdo.DataGraph graph, java.lang.String name)
graph
- The graph.name
- The table name.public static java.util.List<commonj.sdo.DataObject> selectRows(commonj.sdo.DataObject tableMetadata, java.lang.String[] fields, java.lang.Object[] values)
tableMetadata
- The table metadata.fields
- The field list.values
- The values to be matched.public static java.util.List<commonj.sdo.DataObject> getChildRows(commonj.sdo.DataObject row, java.lang.String relation)
row
- The row.relation
- The child relation.protected static commonj.sdo.DataObject createTypeDescription(commonj.sdo.helper.HelperContext scope, java.lang.String uri, java.lang.String name)
scope
- The context.uri
- The type URI.name
- The type name.protected static commonj.sdo.DataObject addPropertyDescription(commonj.sdo.DataObject containerType, java.lang.Object propertyType, java.lang.String propertyName)
containerType
- The object type.propertyType
- The property type.propertyName
- The property name.static java.lang.String buildDenormalizedFieldName(java.lang.String fname, int idx)
DENORMALIZED_PREFIX
and
end with the field's index.fname
- The legacy extent field name.idx
- The field's index.static void logChanged(FWDDataObject record)
record
- The changed record.static void logDeleted(FWDDataObject record)
record
- The delete record.static void logCreated(FWDDataObject record)
record
- The created record.static void addBeforeObject(commonj.sdo.DataGraph graph, commonj.sdo.DataObject row)
graph
- The graph.row
- The row to add.private static void createBeforeRow(FWDDataObject record, int state)
record
- The after-table row.state
- The record state.private static java.lang.String tableTypeName(java.lang.String table)
table
- The table name.private static java.lang.String tableFromType(commonj.sdo.Type type)
type
- The table's record type.private static long getNextId(commonj.sdo.DataGraph graph)
graph
- The graph.private static long getNextId(commonj.sdo.DataObject graphMeta)
graphMeta
- The graph metadata.public static void main(java.lang.String[] args)