public class DataModelWorker.Library
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private XmlAst |
schemaElem
The XML
schema element for the temporary schema. |
private java.util.List<DataModelWorker.DMOElementInfo> |
tempSchema
The list of
class elements in dmo_index.xml. |
Constructor and Description |
---|
Library() |
Modifier and Type | Method and Description |
---|---|
Aast |
createAst(int type,
java.lang.String text,
Aast parent)
General purpose data model AST creation function which can create a
DataModelAst node using the given token type and text. |
DataModelWorker.DMOElementInfo |
createDMOChildInfo(DataModelWorker.DMOElementInfo parent,
java.lang.String tag)
Create a structure to hold additional information, and attach it to the given parent.
|
DataModelWorker.DMOElementInfo |
createDMOClassInfo()
Create a structure to hold all the information for a
class element in
the dmo_index.xml file. |
Aast |
createPeerAst(int type,
java.lang.String text)
Common case for data model AST creation which creates a
DataModelAst node using the passed token type and text
and then attaches that node to the parent specified by the "peerid"
annotation of the source AST's parent node. |
Aast |
createPeerAst(int type,
java.lang.String text,
Aast parent)
General purpose data model AST creation function which can create a
DataModelAst node using the given token type and text. |
Aast |
createRootAst(Aast peerRoot,
boolean virtualFile)
Create a new data model AST that is the root for the data model
hierarchy.
|
Aast |
createRootAst(Aast peerRoot,
java.lang.String filename,
boolean virtualFile)
Create a new data model AST that is the root for the data model
hierarchy.
|
java.lang.String |
formatWithEscapedParameter(java.lang.String format,
java.lang.String parameter)
Returns a formatted string using the specified format string and parameter optionally
containing backticks.
|
java.lang.String |
formatWithEscapedParameter(java.lang.String format,
java.lang.String parameter,
java.lang.Long index)
Returns a formatted string using the specified format string and arguments optionally
containing backticks.
|
java.lang.String |
formatWithEscapedParameters(java.lang.String format,
java.lang.String table,
java.lang.String param)
Returns a formatted string using the specified format string and arguments optionally
containing backticks.
|
Aast |
getAstRoot()
Return the AST node that is the root of the data model AST hierarchy.
|
void |
loadRelatedTree(java.lang.String extension)
Load an AST from a file with the same name as the currently loaded file, but with the
given extension instead.
|
java.util.List<P2JIndex> |
nonRedundantIndexes(java.util.List<P2JIndex> indexes)
Convenience method to expose to rulesets the
P2JIndex static method of the same name. |
java.util.List<P2JIndex> |
normalizeUniqueIndexes(java.util.List<P2JIndex> indexes)
Convenience method to expose to rulesets the
P2JIndex static method of the same name. |
boolean |
persistTarget()
Save the current target data model AST to file if the tree is not
empty (the root has at least 1 child).
|
XmlAst |
restoreTempSchema(XmlAst indexElem,
XmlAst schemaElem,
java.lang.String schema)
Load the specified _temp schema from the XML structure into the
tempSchema . |
void |
setAstRoot(Aast root)
Set the AST node that is the root of the data model AST hierarchy and make it the target
root AST of the resolver.
|
void |
sortClasses(Aast parent)
Sorts
CLASS children ASTs of parent
in place into ascending order, according to the association
dependencies of each class. |
void |
sortProperties(Aast parent)
Shifts order attribute for denormalized fields and sorts
PROPERTY children
ASTs of parent in place into ascending order, according to the numeric
value specified by the "order" annotation. |
void |
storeTempSchema(XmlAst indexRoot)
Give a XML structure, attach the
schemaElem element and populate it with all
the DMO information stored in tempSchema . |
private XmlAst schemaElem
schema
element for the temporary schema.private java.util.List<DataModelWorker.DMOElementInfo> tempSchema
class
elements in dmo_index.xml.public Aast createRootAst(Aast peerRoot, boolean virtualFile) throws ConfigurationException
getAstRoot()
user function.peerRoot
- Root node of Progress schema AST currently being processed.virtualFile
- If true
the file is not supposed to be persisted into the file
system, the file name is used to map some ID to the ASTConfigurationException
- if P2J environment is not properly initialized.public Aast createRootAst(Aast peerRoot, java.lang.String filename, boolean virtualFile) throws ConfigurationException
getAstRoot()
user function.peerRoot
- Root node of Progress schema AST currently being processed.filename
- The file in which to persist the new AST.virtualFile
- If true
the file is not supposed to be persisted into the file
system, the file name is used to map some ID to the ASTConfigurationException
- if P2J environment is not properly initialized.public Aast createAst(int type, java.lang.String text, Aast parent)
DataModelAst
node using the given token type and text.
The created node will then be attached to the specified parent. This
is used in cases where the conversion is simple enough to drive
it completely from the rule set rather than from a custom worker.type
- The token type for the data model AST.text
- The text for the AST.parent
- The ID of the parent AST node.null
if the parent ID is invalid, if the type
is not valid or on any unexpected error during AST
creation.public Aast createPeerAst(int type, java.lang.String text, Aast parent)
DataModelAst
node using the given token type and text.
The created node will then be attached to the specified parent. Most
importantly, on success the ID of the generated AST node will be
stored in the current source AST node's "peerid" annotation. This
provides a standard mechanism to duplicate the structure of a source
AST in the target data model AST. The source AST's ID will also
be stored in the target AST's "peerid" annotation which allows
subsequent bidirectional referencing between these peers. This
is used in cases where the conversion is simple enough to drive
it completely from the rule set rather than from a custom worker.type
- The token type for the data model AST.text
- The text for the AST.parent
- The ID of the parent AST node.null
if the parent ID is invalid, if the type
is not valid or on any unexpected error during AST
creation.public Aast getAstRoot()
public void setAstRoot(Aast root)
public Aast createPeerAst(int type, java.lang.String text)
DataModelAst
node using the passed token type and text
and then attaches that node to the parent specified by the "peerid"
annotation of the source AST's parent node. This greatly simplifies
creation of entire hierarchies of structure that match between the
source and target ASTs. This uses the services of createPeerAst(int,String,Aast)
.type
- The token type for the data model AST.text
- The text for the AST.null
if the parent ID is invalid, if the type
is not valid or on any unexpected error during AST
creation.public java.lang.String formatWithEscapedParameter(java.lang.String format, java.lang.String parameter)
format
- Format string.parameter
- String parameter optionally containing backticks..public java.lang.String formatWithEscapedParameter(java.lang.String format, java.lang.String parameter, java.lang.Long index)
format
- Format string.parameter
- String parameter optionally containing backticks..index
- Nullable value.public java.lang.String formatWithEscapedParameters(java.lang.String format, java.lang.String table, java.lang.String param)
format
- Format string.table
- String parameter optionally containing backticks.param
- String parameter optionally containing backticks.public void sortProperties(Aast parent)
PROPERTY
children
ASTs of parent
in place into ascending order, according to the numeric
value specified by the "order" annotation. Sibling ASTs of other types are left in
place.parent
- Parent AST of type CLASS
.public void sortClasses(Aast parent)
CLASS
children ASTs of parent
in place into ascending order, according to the association
dependencies of each class. Classes are sorted after classes upon
which they have dependencies. Within dependency levels, they are
sorted alphabetically by class name.parent
- Parent AST of type DATA_MODEL
.public void loadRelatedTree(java.lang.String extension)
extension
- Filename extension of related AST file.public boolean persistTarget()
AstManager
which will essentially
disable further use of this AST.true
if the tree is persisted,
false
if the tree is empty or on any failure
during persistence.public java.util.List<P2JIndex> normalizeUniqueIndexes(java.util.List<P2JIndex> indexes)
P2JIndex
static method of the same name.indexes
- The list of indexes.P2JIndex.normalizeUniqueIndexes(java.util.List<com.goldencode.p2j.persist.P2JIndex>, int)
public java.util.List<P2JIndex> nonRedundantIndexes(java.util.List<P2JIndex> indexes)
P2JIndex
static method of the same name.indexes
- The list of indexes.P2JIndex.nonRedundantIndexes(java.util.List<com.goldencode.p2j.persist.P2JIndex>)
public void storeTempSchema(XmlAst indexRoot)
schemaElem
element and populate it with all
the DMO information stored in tempSchema
.indexRoot
- The root element for the dmo_index.xml file.public XmlAst restoreTempSchema(XmlAst indexElem, XmlAst schemaElem, java.lang.String schema)
tempSchema
.indexElem
- The XML element for the dmo-index
node.schemaElem
- The schema element to load. May be null
, if this does not exist
already.schema
- The schema name.public DataModelWorker.DMOElementInfo createDMOClassInfo()
class
element in
the dmo_index.xml file.public DataModelWorker.DMOElementInfo createDMOChildInfo(DataModelWorker.DMOElementInfo parent, java.lang.String tag)
parent
- The parent structure, from dmo_index.xml.tag
- The that for this structure.