public class TableElement extends org.jdom.Element implements UpgConstants
org.jdom.Element
.
TableElement is instanciated by the following:
compareTableMeta
.
The constructor will populate the TableElement object appropriately, and populate with children for
ColumnElement
.
Upgrade
.
The TableElement methods getAddSql(String, Connection, Util, HashMap)
and getUpdateSql(String, Connection, Util, HashMap)
return sql statements for modifying the table metadata prior to running ConfigDB
.
This class supports the following special codes during the Upgrade.
If any additional codes are supported in the future,
they should be documented here and in the UpgCodes file in PVCS.
Also see comments in BuildUpgMetadata
.
Attribute Name | Description |
---|---|
forcedrop | When performing the Upgrade, if table is being dropped, and it contains data,
this class will mark it as user-defined rather than actually dropping it.
However, if the UpgCodes XML file that is input
to BuildUpgMetadata provides a table attribute named "forcedrop" with any value
other than N or NO, the table will be dropped regardless of whether it contains data.
For example:
|
forcerebuild | For the Upgrade, if the table is being changed, and you anticipate that the
Utility class may determine that the table needs to simply be altered (rather than rebuilt),
and you want to force a rebuild because you need some complex logic for reloading
the data, then UpgCodes XML file that is input to BuildUpgMetadata should provide
a table attribute named "forcerebuild" with any value other than N or NO.
This would be done only in unusual circumstances.
For example:
|
psdi.upgrade.BuildUpgMetadata
,
psdi.upgrade.Upgrade
,
Serialized FormDB2, doNotUpdateACTION, doNotUpdateALNDOMAIN, doNotUpdateAPPLICATIONAUTH, doNotUpdateAUTOKEY, doNotUpdateCONDITION, doNotUpdateCONTRACTPROPERTY, doNotUpdateCONTRACTTYPE, doNotUpdateCROSSOVERDOMAIN, doNotUpdateDOCTYPES, doNotUpdateLANGUAGE, doNotUpdateMAXAPPS, doNotUpdateMAXCONDDETAIL, doNotUpdateMAXCONTROLVALUE, doNotUpdateMAXDOMAIN, doNotUpdateMAXLOGAPPENDER, doNotUpdateMAXLOGGER, doNotUpdateMAXMENU, doNotUpdateMAXMESSAGES, doNotUpdateMAXMODULES, doNotUpdateMAXPROP, doNotUpdateMAXPROPVALUE, doNotUpdateMAXROLE, doNotUpdateMAXSEQUENCE, doNotUpdateMAXSERSECURITY, doNotUpdateMAXSERVICE, doNotUpdateMAXTABLEDOMAIN, doNotUpdateMAXVARS, doNotUpdateMAXVARTYPE, doNotUpdateMXCOLLAB, doNotUpdateMXCOLLABREF, doNotUpdateNUMERICDOMAIN, doNotUpdateNUMRANGEDOMAIN, doNotUpdatePORTLET, doNotUpdatePRICALC, doNotUpdateSECURITYRESTRICT, doNotUpdateSIGOPTION, doNotUpdateSYNONYMDOMAIN, doNotUpdateTAXTYPE, doNotUpdateWORKPRIORITY, doNotUpdateWORKTYPE, doNotUpdateWPEDITSETTING, messageCache, NEWONLY, OLDANDNEW, OLDONLY, ORACLE, SQLINET, SQLMICROSOFT, SQLSERVER, SYSDATATABLES, SYSTEMTABLES, UNKNOWN
Constructor and Description |
---|
TableElement(java.lang.String tbname,
java.util.HashMap newTable,
java.util.HashMap oldTable)
This constructor is used when creating a new TableElement for the purpose
of writing out XML.
|
TableElement(java.lang.String name,
org.jdom.Namespace namespace,
java.lang.String dir) |
TableElement(java.lang.String name,
java.lang.String dir) |
TableElement(java.lang.String name,
java.lang.String uri,
java.lang.String dir) |
TableElement(java.lang.String name,
java.lang.String prefix,
java.lang.String uri,
java.lang.String dir) |
Modifier and Type | Method and Description |
---|---|
boolean |
addView()
Determine if the object is to be added as a view.
|
java.util.ArrayList |
adjustView(java.util.HashMap baseTable,
Util util)
Verify that all views are defined correctly, including:
autoselect views must view all columns on the table
if a column is required, view of column must be required
|
boolean |
forceDrop()
Determine whether the table must be dropped.
|
boolean |
forceRebuild()
Determine whether the table must be rebuilt.
|
java.util.ArrayList |
getAddSql(java.lang.String tbname,
java.sql.Connection con,
Util util,
java.util.HashMap oldTable)
When reading XML, called from
psdi.upgrade.Upgrade#Upgrade . |
ColumnElement |
getColumn(java.lang.String colName)
Get a particular ColumnElement for this TableElement.
|
java.util.List |
getColumns()
Get the columns for this table.
|
java.util.TreeMap |
getColumnsFromTable(java.util.HashMap table)
Fetch the maximo column definitions as stored in a table HashMap.
|
java.lang.String |
getDropIndexesSql(java.lang.String tableName)
Generate SQL to drop indexes for a table.
|
java.lang.String |
getNewChanged()
Get the new value for maxobjectcfg.changed (
newChanged ). |
java.util.HashMap |
getNewHashmap(java.util.HashMap oldMap,
boolean rebuild)
This method can be used when reading XML to output a HashMap in the format
of
Util.getAttributeMeta(String, boolean, boolean, boolean, boolean, boolean, String) . |
int |
getNextVal(java.lang.String tableName,
java.lang.String columnName)
Get the next sequential value for a column.
|
java.util.ArrayList |
getPreDropSql()
Prior to dropping a table, update its columns and attributes.
|
java.lang.String |
getStatus()
Get the value of the table's attribute value "status" (see
status ). |
org.jdom.Element |
getTableAttribute(java.lang.String attrName)
Get a particular attribute element for this TableElement.
|
java.util.List |
getTableAttributes()
Get the attributes for this TableElement.
|
java.lang.String |
getTableName()
Get the table name.
|
int |
getUpdateCount()
When validating the XML against the database, determine the number of attributes
that are being updated for a table and its columns.
|
java.util.ArrayList |
getUpdateSql(java.lang.String tbname,
java.sql.Connection con,
Util util,
java.util.HashMap oldTable)
When reading XML, called from
Upgrade . |
boolean |
isView()
Determine if the object is a view.
|
boolean |
isView(java.util.HashMap objMap)
Determine if the object is a view.
|
void |
setNewChanged(java.lang.String value)
Set the new value for maxobjectcfg.changed (
newChanged ). |
void |
setTableName(java.lang.String tableName)
Set the table name.
|
java.util.HashMap |
toHashmap(java.util.HashMap oldMap)
This method can be used when reading XML to output a HashMap in the format
of
getObjectMeta . |
addContent, addContent, addContent, addContent, addContent, addNamespaceDeclaration, clone, cloneContent, getAdditionalNamespaces, getAttribute, getAttribute, getAttributes, getAttributeValue, getAttributeValue, getAttributeValue, getAttributeValue, getChild, getChild, getChildren, getChildren, getChildren, getChildText, getChildText, getChildTextNormalize, getChildTextNormalize, getChildTextTrim, getChildTextTrim, getContent, getContent, getContent, getContentSize, getDescendants, getDescendants, getName, getNamespace, getNamespace, getNamespacePrefix, getNamespaceURI, getQualifiedName, getText, getTextNormalize, getTextTrim, getValue, indexOf, isAncestor, isRootElement, removeAttribute, removeAttribute, removeAttribute, removeChild, removeChild, removeChildren, removeChildren, removeContent, removeContent, removeContent, removeContent, removeNamespaceDeclaration, setAttribute, setAttribute, setAttribute, setAttributes, setAttributes, setContent, setContent, setContent, setContent, setName, setNamespace, setText, toString
public TableElement(java.lang.String name, org.jdom.Namespace namespace, java.lang.String dir)
name
- Name of the table.namespace
- dir
- Callout directory.public TableElement(java.lang.String name, java.lang.String dir)
name
- Name of the table.dir
- Callout directory.public TableElement(java.lang.String name, java.lang.String uri, java.lang.String dir)
name
- Name of the table.uri
- dir
- Callout directory.public TableElement(java.lang.String name, java.lang.String prefix, java.lang.String uri, java.lang.String dir)
name
- Name of the table.prefix
- uri
- dir
- Callout directory.public TableElement(java.lang.String tbname, java.util.HashMap newTable, java.util.HashMap oldTable) throws java.lang.Exception
buildFromHashMaps
.tbname
- Name of the table.newTable
- The table from the new database.oldTable
- The table from the old database.java.lang.Exception
buildFromHashMaps()
public boolean isView(java.util.HashMap objMap)
objMap
- HashMap containing the object to test.
true
if the object is a viewpublic boolean isView() throws java.lang.Exception
true
if the object is a viewjava.lang.Exception
public boolean addView() throws java.lang.Exception
true
if the object is being added as a viewjava.lang.Exception
public java.lang.String getTableName()
public void setTableName(java.lang.String tableName)
tableName
- The value to set as the table name.public java.lang.String getStatus()
status
).
This will equal OLDONLY, NEWONLY,
or OLDANDNEW
to indicate
whether the table exists in the old database, the new database, or both.public java.lang.String getNewChanged()
newChanged
).public void setNewChanged(java.lang.String value)
newChanged
).public boolean forceDrop()
true
is FORCEDROP was specified in UpgCodes.public boolean forceRebuild()
true
is FORCEDROP was specified in UpgCodes.public java.util.TreeMap getColumnsFromTable(java.util.HashMap table) throws java.lang.Exception
$MAXATTRIBUTES
,
and view column attributes, as defined by $MAXVIEWCOLUMNS
.
table
- HashMap containing a full maximo table definition.java.lang.Exception
public java.util.List getTableAttributes() throws java.lang.Exception
To get a particular attribute without explicitly iterating through the list,
call getTableAttribute
.
java.lang.Exception
public org.jdom.Element getTableAttribute(java.lang.String attrName) throws java.lang.Exception
getTableAttributes
.attrName
- The attribute name (case sensitive), for example SERVICENAME, SITEORGTYPE, etc.java.lang.Exception
public java.util.List getColumns() throws java.lang.Exception
getColumn
.java.lang.Exception
public ColumnElement getColumn(java.lang.String colName) throws java.lang.Exception
getColumns
.colName
- The column name (case sensitive), for example EQNUM, ITEMNUM, etc.java.lang.Exception
public java.util.ArrayList getAddSql(java.lang.String tbname, java.sql.Connection con, Util util, java.util.HashMap oldTable) throws java.lang.Exception
psdi.upgrade.Upgrade#Upgrade
.
This method outputs the Sql to add new tables and views or update existing
in preparation for running ConfigDB
.
Any new columns that require a value will be added here as not required,
then modified to required in getUpdateSql(String, Connection, Util, HashMap)
.
Any required columns that are to be dropped will be marked as not required,
then dropped in getUpdateSql(String, Connection, Util, HashMap)
.tbname
- The table name.con
- The connection to the database being upgraded.util
- Reference to the Util class.oldTable
- The current attributes for the table and columns, before being upgraded.java.lang.Exception
addTableCfg()
,
updateTableCfg()
,
getNewHashmap(java.util.HashMap, boolean)
,
getFormatValue(java.lang.String, java.lang.String)
,
ColumnElement.getAddSql(String, String, Connection, Util, HashMap, TableElement)
public java.util.ArrayList getUpdateSql(java.lang.String tbname, java.sql.Connection con, Util util, java.util.HashMap oldTable) throws java.lang.Exception
Upgrade
.
This method outputs the Sql to update or delete existing tables and
columns in preparation for running ConfigDB
.tbname
- The table name.con
- The connection to the database being upgraded.util
- Reference to the Util class.oldTable
- The current attributes for the table and columns, before being upgraded.java.lang.Exception
addTableCfg()
,
updateTableCfg()
,
getNewHashmap(java.util.HashMap, boolean)
,
getFormatValue(java.lang.String, java.lang.String)
,
ColumnElement.getUpdateSql(java.lang.String, java.lang.String, java.sql.Connection, psdi.configure.Util, java.util.HashMap, psdi.configure.TableElement)
public java.util.ArrayList getPreDropSql() throws java.lang.Exception
java.lang.Exception
public java.lang.String getDropIndexesSql(java.lang.String tableName)
java.lang.Exception
public java.util.HashMap getNewHashmap(java.util.HashMap oldMap, boolean rebuild) throws java.lang.Exception
Util.getAttributeMeta(String, boolean, boolean, boolean, boolean, boolean, String)
.
If the "rebuild" parameter is True, this also calls
reEvaluateObjectChanged
,
updates the "CHANGED" value in the map, and updates the "newChanged" variable.
This method retrieves but does not rebuild the columns' hashmaps from ColumnElement.
oldMap
- The HashMap representing the original values of the column metadata
from the customer's database, before applying the XML changes.
If this is a new column to be added, then this parameter will be null or empty.rebuild
- True to rebuild the map. When True,
reEvaluateObjectChanged
is called and lastNewMap
is replaced.
This does not cause the maps in ColumnElement to be rebuilt.
False to return the most recently built map
(lastNewMap
).
java.lang.Exception
ColumnElement.getNewHashmap(java.util.HashMap, boolean)
,
Util.reEvaluateObjectChanged(HashMap, HashMap, boolean, String)
public java.util.HashMap toHashmap(java.util.HashMap oldMap) throws java.lang.Exception
getObjectMeta
.oldMap
- The HashMap representing the original values of the table metadata
from the customer's database, before applying the XML changes.
If this is a new table to be added, then this parameter will be null or empty.java.lang.Exception
ColumnElement.toHashmap(java.util.HashMap)
public int getNextVal(java.lang.String tableName, java.lang.String columnName) throws java.lang.Exception
tableName
- Name of the tablecolumnName
- Name of the columnjava.lang.Exception
public java.util.ArrayList adjustView(java.util.HashMap baseTable, Util util) throws java.lang.Exception
view
- A view that extends this tablejava.lang.Exception
public int getUpdateCount() throws java.lang.Exception
validateTable
.java.lang.Exception