psdi.configure

Class ColumnElement

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


    public class ColumnElement
    extends org.jdom2.Element
    implements UpgConstants
    Element to represent a column (maxattribute or maxattributecfg) in the XML file that is output by BuildUpgMetadata and input to Upgrade. This is an extension of org.jdom2.Element.

    ColumnElement is instanciated by the following:

    • When writing XML (BuildUpgMetadata), instanciated from TableElement compareColumns and addOneColumnSet The constructor will populate the ColumnElement object appropriately.
    • When reading XML (Upgrade), instanciated from ConfigXMLFactory, via TableElement. The ColumnElement returns sql statements for modifying the column 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 NameDescription
    forcedropWhen performing the Upgrade, if column 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 column attribute named "forcedrop" with any value other than N or NO, the column will be dropped regardless of whether it contains data. This would be done if, for example, a column is being moved from one table to another. If this were the case, we would not actually lose any data by dropping it from the first table. For example:

    <TABLE tbname="MAXDOMAIN" >
    <
    COLUMNS>
    <
    COLUMN name="MUSTEXIST" forcedrop="Y">
    <
    /COLUMN>
    <
    /COLUMNS>
    <
    /TABLE>

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

      • ColumnElement

        public ColumnElement(java.lang.String name,
                             org.jdom2.Namespace namespace,
                             java.lang.String dir)
      • ColumnElement

        public ColumnElement(java.lang.String name,
                             java.lang.String dir)
      • ColumnElement

        public ColumnElement(java.lang.String name,
                             java.lang.String uri,
                             java.lang.String dir)
      • ColumnElement

        public ColumnElement(java.lang.String name,
                             java.lang.String prefix,
                             java.lang.String uri,
                             java.lang.String dir)
      • ColumnElement

        public ColumnElement(TableElement tableElement,
                             java.lang.String name,
                             java.util.HashMap newCol,
                             java.util.HashMap oldCol)
                      throws java.lang.Exception
        This constructor is used when creating a new TableElement for the purpose of writing out XML. It calls buildFromHashMaps.
        Parameters:
        tableElement - The parent TableElement
        name - The column name
        newCol - The column from the new database.
        oldCol - The column from the old database.
        Throws:
        java.lang.Exception
        See Also:
        ColumnElement.buildFromHashMaps()
    • Method Detail

      • getColumnName

        public java.lang.String getColumnName()
        Get the column name.
        Returns:
        The column name.
      • getTableName

        public java.lang.String getTableName()
        Get the name of the table that owns this column.
        Returns:
        The name of the table.
      • getStatus

        public java.lang.String getStatus()
        Get the value of the column's attribute value "status" (see status). This will equal OLDONLY, NEWONLY, or OLDANDNEW to indicate whether the column 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 MaxAttributeCfg.Changed (newChanged).
        Returns:
        The new value for changed.
      • setNewChanged

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

        public java.util.List getColumnAttributes()
        Get the attributes for this ColumnElement. Each "attribute" represents a cell from maxattributecfg, and is technically an instance of Element.

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

        Returns:
        List of column's attributes.
        Throws:
        java.lang.Exception
      • getColumnAttribute

        public org.jdom2.Element getColumnAttribute(java.lang.String attrName)
        Get a particular attribute element for this ColumnElement.

        To get a list of all attributes, call getColumnAttributes.

        Parameters:
        attrName - The attribute name (case sensitive), for example COLUMNTITLE, DEFAULTVALUE, etc.
        Returns:
        The element that represents that attribute.
        Throws:
        java.lang.Exception
      • customClassExists

        public boolean customClassExists(java.lang.String className)
        When a column was dropped from the new release and we're changing it to user-defined, see if the old customclassname still exists as a class.
        Parameters:
        className - The name of the class
        Returns:
        True if it exists or the className is null, else False
      • getNewHashmap

        public java.util.HashMap getNewHashmap(java.util.HashMap oldMap,
                                               boolean rebuild)
                                        throws java.lang.Exception
        This method can be used when reading XML to output a HashMap in the format of getAttributeMeta. If the "rebuild" parameter is True, this also calls reEvaluateAttributeChanged, updates the "CHANGED" value in the map, and updates the "newChanged" variable.

        It is important that this method be called for every column somewhere from getSql, because after the columns are processed, the TableElement uses the columns' new maps to determine the correct value for maxobjectcfg "changed".

        Parameters:
        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. If the "rebuild" parameter is False, this can be null.
        rebuild - True to rebuild the map. When True, reEvaluateAttributeChanged is called and lastNewMap is replaced.

        False to return the most recently built map (lastNewMap).

        Returns:
        A HashMap like oldMap, but with the new XML changes applied to it.
        Throws:
        java.lang.Exception
        See Also:
        Util.reEvaluateAttributeChanged(java.lang.String, java.util.HashMap, java.util.HashMap, java.lang.String, boolean)
      • 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 getAttributeMeta.
        Parameters:
        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.
        Returns:
        A HashMap like oldMap, but with the new XML changes applied to it.
        Throws:
        java.lang.Exception
      • getGLLength

        public java.lang.String getGLLength()
                                     throws java.lang.Exception
        Calculate the length of GL columns. The length must be calculated from the lengths of the existing GL components.
        Returns:
        Length, as a string.
        Throws:
        java.lang.Exception
      • getAmountLength

        public java.lang.String getAmountLength()
                                         throws java.lang.Exception
        Get the defined length of AMOUNT columns. The length must be that defined by MaxVar AMTLENGTH.
        Returns:
        Length, as a string.
        Throws:
        java.lang.Exception
      • getAmountScale

        public java.lang.String getAmountScale()
                                        throws java.lang.Exception
        Get the defined scale of AMOUNT columns. The length must be that defined by MaxVar AMTSCALE.
        Returns:
        Scale, as a string.
        Throws:
        java.lang.Exception
      • isCharType

        public boolean isCharType(org.jdom2.Element attr)
        Determine if the column is a character datatype
        Parameters:
        attr - MaxType element
        Returns:
        true if the element is a charater data type
      • isCharType

        public boolean isCharType(java.lang.String maxtype)
        Determine if a maximo datatype (MaxType) is a character datatype
        Parameters:
        maxtype - Maximo datatype
        Returns:
        true if the maxtype is a charater data type
      • forceDrop

        public boolean forceDrop()
        Determine whether the column must be dropped. If FORCEDROP is specified and set to Y in UpgCodes.xml, then the column must be dropped.
        Returns:
        true is FORCEDROP was specified in UpgCodes.
      • addUserColumn

        public java.util.ArrayList addUserColumn(java.lang.String baseTable)
                                          throws java.lang.Exception
        For any table that becomes a view, all user-defined columns must be created on the new base table of the view. On the new base table, create a mirror image of the original user-defined column.
        Parameters:
        baseTable - Name of the table that is extended by the view
        Returns:
        List of SQL commands to create a user-defined column.
        Throws:
        java.lang.Exception
      • addUserColumn

        public java.util.ArrayList addUserColumn(java.lang.String tableName,
                                                 java.util.HashMap column)
                                          throws java.lang.Exception
        For any table that becomes a view, all user-defined columns must be created on the new base table of the view. On the new base table, create a mirror image of the original user-defined column.
        Parameters:
        tableName - Name of the table that is extended by the view
        column - HashMap of the column definition to clone
        Returns:
        List of SQL commands to create a user-defined column.
        Throws:
        java.lang.Exception
      • addAutoSelectColumn

        public java.util.ArrayList addAutoSelectColumn(java.lang.String tableName,
                                                       Util util)
                                                throws java.lang.Exception
        AutoSelect views must reference every column on the base table. Add any columns to the view that are missing.
        Parameters:
        tableName - Name of the base table that contains the column
        Returns:
        SQL to add a new column to the view
        Throws:
        java.lang.Exception
      • addViewColumn

        public java.util.ArrayList addViewColumn(java.lang.String tableName,
                                                 Util util)
                                          throws java.lang.Exception
        AutoSelect views must reference every column on the base table. Add any view of a column that is missing.
        Parameters:
        tableName - Name of the base table that contains the column
        Returns:
        SQL to add a new column to the view
        Throws:
        java.lang.Exception
      • adjustViewRequired

        public java.util.ArrayList adjustViewRequired(Util util)
                                               throws java.lang.Exception
        If a column is required, any view of the column must also be required.
        Returns:
        SQL to update the view to be required, if necessary.
        Throws:
        java.lang.Exception
      • viewColumnExists

        public boolean viewColumnExists()
                                 throws java.lang.Exception
        AutoSelect views must reference every column on the base table. Add any view of a column that is missing.
        Returns:
        True if the view column exists
        Throws:
        java.lang.Exception
      • getUpdateCount

        public int getUpdateCount()
                           throws java.lang.Exception
        When validating the XML against the database, determine the number of column attributes that are being updated in MaxAttribute and MaxViewColumn. This count excludes maxattributeid and maxviewcolumnid. Called from validateColumns.
        Returns:
        Number of attributes being updated.
        Throws:
        java.lang.Exception