psdi.configure

Class TableElement

  • java.lang.Object
    • org.jdom2.Content
      • org.jdom2.Element
        • psdi.configure.TableElement
  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.jdom2.NamespaceAware, org.jdom2.Parent, UpgConstants


    public class TableElement
    extends org.jdom2.Element
    implements UpgConstants
    Element to represent a table (maxobject or maxobjectcfg) in the XML file that is output by BuildUpgMetadata and input to Upgrade. This is an extension of org.jdom.Element.

    TableElement is instanciated by the following:

    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 NameDescription
    forcedropWhen 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:

    <TABLE tbname="JOBOPERATION" forcedrop="Y">
    <
    /TABLE>

    forcerebuildFor 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:

    <TABLE tbname="ITEM" forcerebuild="Y">
    <
    /TABLE>

    See Also:
    psdi.upgrade.BuildUpgMetadata, psdi.upgrade.Upgrade, Serialized Form
    • Constructor Detail

      • TableElement

        public TableElement(java.lang.String name,
                            org.jdom2.Namespace namespace,
                            java.lang.String dir)
        Parameters:
        name - Name of the table.
        namespace -
        dir - Callout directory.
      • TableElement

        public TableElement(java.lang.String name,
                            java.lang.String dir)
        Parameters:
        name - Name of the table.
        dir - Callout directory.
      • TableElement

        public TableElement(java.lang.String name,
                            java.lang.String uri,
                            java.lang.String dir)
        Parameters:
        name - Name of the table.
        uri -
        dir - Callout directory.
      • TableElement

        public TableElement(java.lang.String name,
                            java.lang.String prefix,
                            java.lang.String uri,
                            java.lang.String dir)
        Parameters:
        name - Name of the table.
        prefix -
        uri -
        dir - Callout directory.
      • TableElement

        public TableElement(java.lang.String tbname,
                            java.util.HashMap newTable,
                            java.util.HashMap oldTable)
                     throws java.lang.Exception
        This constructor is used when creating a new TableElement for the purpose of writing out XML. It calls buildFromHashMaps.
        Parameters:
        tbname - Name of the table.
        newTable - The table from the new database.
        oldTable - The table from the old database.
        Throws:
        java.lang.Exception
        See Also:
        TableElement.buildFromHashMaps()
    • Method Detail

      • isView

        public boolean isView(java.util.HashMap objMap)
        Determine if the object is a view. See if the ISVIEW attribuite is set to true.

        Parameters:
        objMap - HashMap containing the object to test.

        Returns:
        true if the object is a view
      • isView

        public boolean isView()
                       throws java.lang.Exception
        Determine if the object is a view.
        Returns:
        true if the object is a view
        Throws:
        java.lang.Exception
      • addView

        public boolean addView()
                        throws java.lang.Exception
        Determine if the object is to be added as a view. See if the ISVIEW attribute is specified and set to true.

        Returns:
        true if the object is being added as a view
        Throws:
        java.lang.Exception
      • getTableName

        public java.lang.String getTableName()
        Get the table name.
        Returns:
        The table name.
      • setTableName

        public void setTableName(java.lang.String tableName)
        Set the table name.
        Parameters:
        tableName - The value to set as the table name.
      • getStatus

        public java.lang.String getStatus()
        Get the value of the table's attribute value "status" (see status). This will equal OLDONLY, NEWONLY, or OLDANDNEW to indicate whether the table exists in the old database, the new database, or both.
        Returns:
        The value of the "status" attribute.
      • getNewChanged

        public java.lang.String getNewChanged()
        Get the new value for maxobjectcfg.changed (newChanged).
        Returns:
        The new value for changed.
      • setNewChanged

        public void setNewChanged(java.lang.String value)
        Set the new value for maxobjectcfg.changed (newChanged).
      • forceDrop

        public boolean forceDrop()
        Determine whether the table must be dropped. If FORCEDROP is specified in UpgCodes.xml, then the table must be dropped.
        Returns:
        true is FORCEDROP was specified in UpgCodes.
      • forceRebuild

        public boolean forceRebuild()
        Determine whether the table must be rebuilt. If FORCEREBUILD is specified in UpgCodes.xml, then the table must be rebuilt.
        Returns:
        true is FORCEDROP was specified in UpgCodes.
      • getColumnsFromTable

        public java.util.TreeMap getColumnsFromTable(java.util.HashMap table)
                                              throws java.lang.Exception
        Fetch the maximo column definitions as stored in a table HashMap. This method combines column attributes, as defined by $MAXATTRIBUTES, and view column attributes, as defined by $MAXVIEWCOLUMNS.

        Parameters:
        table - HashMap containing a full maximo table definition.
        Returns:
        TreeMap containing all Maximo column definitions for this table
        Throws:
        java.lang.Exception
      • getTableAttributes

        public java.util.List getTableAttributes()
                                          throws java.lang.Exception
        Get the attributes for this TableElement. Each "attribute" represents a cell from maxobjectcfg, and is technically an instance of Element.

        To get a particular attribute without explicitly iterating through the list, call getTableAttribute.

        Returns:
        List of table's attributes.
        Throws:
        java.lang.Exception
      • getTableAttribute

        public org.jdom2.Element getTableAttribute(java.lang.String attrName)
                                            throws java.lang.Exception
        Get a particular attribute element for this TableElement. To get a list of all attributes, call getTableAttributes.
        Parameters:
        attrName - The attribute name (case sensitive), for example SERVICENAME, SITEORGTYPE, etc.
        Returns:
        The element that represents that attribute; null if attribute does not exist.
        Throws:
        java.lang.Exception
      • getColumns

        public java.util.List getColumns()
                                  throws java.lang.Exception
        Get the columns for this table. To get a particular column without explicitly iterating through the list, call getColumn.
        Returns:
        List of child ColumnElements. If no column elements, returns an empty list.
        Throws:
        java.lang.Exception
      • getColumn

        public ColumnElement getColumn(java.lang.String colName)
                                throws java.lang.Exception
        Get a particular ColumnElement for this TableElement. To get a list of all columns, call getColumns.
        Parameters:
        colName - The column name (case sensitive), for example EQNUM, ITEMNUM, etc.
        Returns:
        The element that represents that column; null if column does not exist.
        Throws:
        java.lang.Exception
      • getPreDropSql

        public java.util.ArrayList getPreDropSql()
                                          throws java.lang.Exception
        Prior to dropping a table, update its columns and attributes. Tables are not dropped until late in the upgrade process. In the meantime, the existence of an obsolete table can cause problems. Make sure no upgrade processes act upon an obsolete table.
        Returns:
        List of SQL stement to execute.
        Throws:
        java.lang.Exception
      • getDropIndexesSql

        public java.lang.String getDropIndexesSql(java.lang.String tableName)
        Generate SQL to drop indexes for a table. Tables are not dropped until late in the upgrade process. In the meantime, the existence of obsolete indexes can cause problems.
        Returns:
        SQL statement to execute.
        Throws:
        java.lang.Exception
      • getNextAttributeID

        protected int getNextAttributeID()
        Used when adding new rows to maxattributecfg to get the next value for attributeno. Adds one to attributeno each time it is called.
        Returns:
        the next attribute number
      • getNextViewColumnID

        protected int getNextViewColumnID()
        Used when adding new rows to maxviewcolumncfg to get the next value for TableElement.viewcolumnno. Adds one to viewcolumnno each time it is called.
        Returns:
        the next view column number
      • toHashmap

        public java.util.HashMap toHashmap(java.util.HashMap oldMap)
                                    throws java.lang.Exception
        This method can be used when reading XML to output a HashMap in the format of getObjectMeta.
        Parameters:
        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.
        Returns:
        A HashMap like oldMap, but with the new XML changes applied to it.
        Throws:
        java.lang.Exception
        See Also:
        ColumnElement.toHashmap(java.util.HashMap)
      • getNextVal

        public int getNextVal(java.lang.String tableName,
                              java.lang.String columnName)
                       throws java.lang.Exception
        Get the next sequential value for a column. Get the current highest value and add 1.
        Parameters:
        tableName - Name of the table
        columnName - Name of the column
        Returns:
        The next value to be assigned to the column.
        Throws:
        java.lang.Exception
      • adjustView

        public java.util.ArrayList adjustView(java.util.HashMap baseTable,
                                              Util util)
                                       throws java.lang.Exception
        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
        Parameters:
        view - A view that extends this table
        Returns:
        List of SQL commands to adjust the view definition.
        Throws:
        java.lang.Exception
      • getUpdateCount

        public int getUpdateCount()
                           throws java.lang.Exception
        When validating the XML against the database, determine the number of attributes that are being updated for a table and its columns. This count excludes maxobjectid, maxtableid, and maxviewid. Called from validateTable.
        Returns:
        Number of attributes being updated.
        Throws:
        java.lang.Exception