psdi.configure

Class SysDataElementSYNONYMDOMAIN

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.jdom2.NamespaceAware, org.jdom2.Parent, UpgConstants


    public class SysDataElementSYNONYMDOMAIN
    extends SysDataElement
    implements UpgConstants
    Element to represent the SynonymDomain table in the XML file that is output by BuildUpgMetadata and input to Upgrade. This is an extension of psdi.configure.SysDataElement.

    SysDataElementSYNONYMDOMAIN is instanciated by the following:

    • When writing XML (BuildUpgMetadata), instanciated from compareSystemData. The constructor will populate the SysDataElementSYNONYMDOMAIN object appropriately.
    • When reading XML (Upgrade), instanciated from ConfigXMLFactory, via Upgrade. The SysDataElementSYNONYMDOMAIN method getSql returns sql statements for populating the data tables appropriately, after having run ConfigDB.

    Multisite functionality is handled by the presence or absence of siteid/orgid in the primary unique index.

    The default processing in SysDataElementSYNONYMDOMAIN presumes that the columns in the primary unique index have not changed from the old to the new database. If the index has changed, this class will have to be extended, with the new instance residing in the subdirectory with the old database name. For example, if the key to the table changed after 5.2, you will need a class psdi.configure.V520.SysDataElementSYNONYMDOMAIN. The extension can then perform the processing needed to support the key structure conversion between specific releases.

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

      • SysDataElementSYNONYMDOMAIN

        public SysDataElementSYNONYMDOMAIN()
      • SysDataElementSYNONYMDOMAIN

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

        public SysDataElementSYNONYMDOMAIN(java.lang.String name)
      • SysDataElementSYNONYMDOMAIN

        public SysDataElementSYNONYMDOMAIN(java.lang.String name,
                                           java.lang.String uri)
      • SysDataElementSYNONYMDOMAIN

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

        public SysDataElementSYNONYMDOMAIN(java.lang.String tbname,
                                           java.util.TreeMap newCol,
                                           java.util.TreeMap oldCol,
                                           java.util.TreeMap newData,
                                           java.util.TreeMap oldData,
                                           java.util.TreeMap newDataOldKeys,
                                           java.util.TreeMap keyCols,
                                           java.io.File codefile)
                                    throws java.lang.Exception
        This constructor is used when creating a new Element for the purpose of writing out XML. It calls buildFromHashMaps.
        Parameters:
        tbname - The name of the table. See tbname.
        newCol - The column metadata on this table, from the new database. See newCol.
        oldCol - The column metadata on this table, from the old database. See oldCol.
        newData - The data from the new database. See newData.
        oldData - The data from the old database. See oldData.
        keyCols - Key columns for this table. See keyCols.
        codeFile - The file UpgCodes.xml that may contain special codes for rows in the table. For SysDataElementSYNONYMDOMAIN this is null.
        Throws:
        java.lang.Exception
        See Also:
        SysDataElement.scanKeyCols(), SysDataElementSYNONYMDOMAIN.buildFromHashMaps()
    • Method Detail

      • setKeyAttributes

        public void setKeyAttributes(org.jdom2.Element row,
                                     java.util.HashMap rowValues)
                              throws java.lang.Exception
        When generating XML, create attributes where name = column name and value = column value, for each column in the primary unique index. This uses keyCols.
        Overrides:
        setKeyAttributes in class SysDataElement
        Parameters:
        row - The Element representing a particular row in the table.
        rowValues - The HashMap of the data values for this row.
        Throws:
        java.lang.Exception
      • haveDup

        public boolean haveDup(org.jdom2.Element checkEl)
                        throws java.lang.Exception
        When generating XML, before adding an element, check to see if we already have a duplicate. This could occur if we have a multisite database. For example, if we want to add SynonymDomain "ABC" our database may have it for site 1 and site 2. We would want to add only one element specifying to add SynonymDomain "ABC". Such duplicates may be found only when the key includes siteid or orgid.
        Overrides:
        haveDup in class SysDataElement
        Parameters:
        checkEl - The element that we've constructed but not yet added.
        Returns:
        True if this element is a duplicate, else False.
        Throws:
        java.lang.Exception
      • getSql

        public java.util.ArrayList getSql(java.lang.String tbname,
                                          java.sql.Connection con,
                                          Util util,
                                          java.util.TreeMap oldCol,
                                          java.util.TreeMap keyCols)
                                   throws java.lang.Exception
        When reading XML, return a series of sql statements to update the customer's database.
        • For any other XML status
          • If the row does not currently exist, it will be added.
          • If the row DOES exist, the values will be compared, and any old value not equal to the XML new value will be updated.
        Overrides:
        getSql in class SysDataElement
        Parameters:
        tbname - The table name. See tbname.
        con - The connection to the database being upgraded. See con.
        util - Reference to the Util class. See util.
        oldCol - TreeMap of the data structure for the columns on this table (key = column name). (This is retrieved AFTER ConfigDB may have updated the format.) See oldCol.
        keyCols - The key columns for this table. See keyCols.
        Returns:
        Series of sql statements
        Throws:
        java.lang.Exception
        See Also:
        SysDataElement.scanKeyCols(), SysDataElementSYNONYMDOMAIN.compareRows(Element, TreeMap)
      • getDeleteSql

        public java.util.ArrayList getDeleteSql(java.lang.String tbname,
                                                java.sql.Connection con,
                                                Util util,
                                                java.util.TreeMap oldCol,
                                                java.util.TreeMap keyCols)
                                         throws java.lang.Exception
        When reading XML, return a series of sql statements to update the customer's database.
        • If the XML status is OLDONLY, the sql will delete from table for that row.
        Overrides:
        getDeleteSql in class SysDataElement
        Parameters:
        tbname - The table name. See tbname.
        con - The connection to the database being upgraded. See con.
        util - Reference to the Util class. See util.
        oldCol - TreeMap of the data structure for the columns on this table (key = column name). (This is retrieved AFTER ConfigDB may have updated the format.) See oldCol.
        keyCols - The key columns for this table. See keyCols.
        Returns:
        Series of sql statements
        Throws:
        java.lang.Exception
        See Also:
        SysDataElement.scanKeyCols(), SysDataElementSYNONYMDOMAIN.deleteRow(org.jdom2.Element)
      • getWhereClause

        public java.lang.String getWhereClause(org.jdom2.Element row,
                                               boolean useSiteOrg,
                                               java.lang.String siteid,
                                               java.lang.String orgid)
                                        throws java.lang.Exception
        When reading XML, generate the Where clause to use in a Sql statement (for delete or update). This uses keyCols to identify the names of the key columns.
        Overrides:
        getWhereClause in class SysDataElement
        Parameters:
        row - The Element representing a row in the database.
        useSiteOrg - If the primary key includes siteid and/or orgid, and this param is True, then the value or siteid/orgid will be included in the Where clause. If this param is False, or the primary key does not contain siteid/orgid, then the Where clause will not have any constraint for siteid/orgid.
        siteid - If this is null, and the Where clause includes siteid, the method uses the siteid from the row Element, otherwise it uses the value of this param. If this equals the empty string (""), the Where clause will specify "siteid is null".
        orgid - If this is null, and the Where clause includes orgid, the method uses the orgid from the row Element, otherwise it uses the value of this param. If this equals the empty string (""), the Where clause will specify "orgid is null".
        Returns:
        The Where clause (not including the word "where").
        Throws:
        java.lang.Exception
      • deleteRow

        public java.util.ArrayList deleteRow(org.jdom2.Element row)
                                      throws java.lang.Exception
        When reading XML, and the row needs to be deleted from the customer's database, return the sql statement for deleting the row. Called from getSql.
        Overrides:
        deleteRow in class SysDataElement
        Parameters:
        row - The element from the input XML representing a row in this table. This is an ArrayList so that extensions of this class can provide more than one Sql statement if needed, e.g. for parent/child tables.
        Returns:
        A "delete from..." sql statement. There will be no siteid/orgid condition, so it may delete multiple rows.
        Throws:
        java.lang.Exception
        See Also:
        SysDataElement.deleteRowExtension(org.jdom2.Element, java.util.ArrayList)
      • updateRow

        public java.util.ArrayList updateRow(org.jdom2.Element row,
                                             java.util.HashMap currentData,
                                             java.lang.String siteid,
                                             java.lang.String orgid)
                                      throws java.lang.Exception
        When reading XML, and the row needs to be updated on the customer's database, this method returns the Sql statement for updating the row. It does NOT update any value for SITEID or ORGID. Called from compareRows.
        Overrides:
        updateRow in class SysDataElement
        Parameters:
        row - The element from the input XML representing a row in the table.
        currentData - The data currently on the customer's database (one row).
        siteid - The siteid to use in the Where clause (if any).
        orgid - The orgid to use in the Where clause (if any).
        Returns:
        An "update ..." sql statement for updating one row. If no columns need to be updated, this will be an empty string. This is an ArrayList so that extensions of this class can provide more than one Sql statement if needed, e.g. for parent/child tables.
        Throws:
        java.lang.Exception
        See Also:
        SysDataElement.canUpdateColumn(java.lang.String)
      • insertRow

        public java.util.ArrayList insertRow(org.jdom2.Element row,
                                             java.lang.String siteid,
                                             java.lang.String orgid)
                                      throws java.lang.Exception
        When reading XML, and the row needs to be added to the customer's database, this method returns the Sql statement for inserting the row. Called from compareRows.
        Overrides:
        insertRow in class SysDataElement
        Parameters:
        row - The element from the input XML representing a row in the table.
        siteid - The siteid to use in the Insert statement (if any).
        orgid - The orgid to use in the Insert statement (if any).
        Returns:
        An "insert into..." sql statement for inserting one row. This is an ArrayList so that extensions of this class can provide more than one Sql statement if needed, e.g. for parent/child tables.
        Throws:
        java.lang.Exception
        See Also:
        SysDataElement.insertRowExtension(org.jdom2.Element, java.lang.String, java.lang.String, java.util.ArrayList)