psdi.configure

Class Util

  • java.lang.Object
    • psdi.configure.Util
  • All Implemented Interfaces:
    UpgConstants
    Direct Known Subclasses:
    SQLConverterUtil


    public class Util
    extends java.lang.Object
    implements UpgConstants
    Utility methods for programs in the psdi.configure package. These methods output various kinds of Sql statements, values, etc. but generally do not actually perform any database updates.

    Click here for an overview of the most commonly-used data structures.

    • Constructor Summary

      Constructors 
      Constructor and Description
      Util(java.sql.Connection conparam, java.io.PrintStream outparam, java.lang.String schemaOwnerparam)
      Calls Util with last param True.
      Util(java.sql.Connection conparam, java.io.PrintStream outparam, java.lang.String schemaOwnerparam, boolean reloadAttrs)
      This constructor does the following.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method and Description
      java.util.ArrayList activateRichTextSearch(java.util.ArrayList list, java.lang.String tbname, boolean doCheck)
      Activate text search for a specified table.
      java.util.ArrayList addIndex(java.lang.String tbname, java.lang.String[] names, java.lang.String startWith, boolean addUnique, java.lang.String storagepartition)
      Generates sql for creating a new index with the specified column names.
      java.util.ArrayList addIndex(java.lang.String tbname, java.lang.String[] names, java.lang.String startWith, boolean addUnique, java.lang.String storagepartition, boolean isPrimary, boolean isRequired)
      Generates sql for creating a new index with the specified column names.
      java.util.List addTenantid(java.lang.String tablename, java.lang.String uniqueColumnName, MTStorageType storageType)
      Add tenantid column to table if MT Enabled.
      java.util.ArrayList addTenantIDIndex(java.lang.String tbname, java.lang.String storagepartition, MTStorageType storageType)
      Generates sql for creating a multi-tenancy index with tenantid column name.
      java.util.ArrayList addTenantidToTable(java.lang.String tabName, MTStorageType storageType)
      Adds tenantid to table based on storagtype
      java.lang.String adjustNativeSql(java.lang.String origSql)
      Called from Maxinst and UpdateDB, when intercepting a native Sql statement (create table or alter table).
      java.util.ArrayList adjustPrimaryKeyColSeq(java.util.TreeMap indexMeta)
      Adjust the value of primarykeycolseq in the column metadata (maxattribute and maxattributecfg) to reflect the actual columns used in the primary unique index.
      java.util.ArrayList adjustViewMeta(java.lang.String viewname)
      Adjust view metadata by removing obsolete persistent attributes and adding new persistent attributes.
      java.util.ArrayList adjustViewMeta(java.lang.String viewname, boolean addP, boolean addNP)
      Adjust view metadata by removing obsolete persistent attributes and adding new persistent and/or non-persistent attributes.
      java.util.ArrayList attrRefresh(int tenantid, boolean mtEnabled)
      Refresh all the attribute metadata for all objects.
      java.lang.String buildChangeCaseStatement(java.lang.String tbname, java.lang.String name, java.lang.String oldMaxtype, java.lang.String newMaxtype)
      If changing maxtype to LOWER or UPPER from another alphanumeric type, output the Sql statement to convert the data.
      java.util.ArrayList buildChangeCaseStatement(java.lang.String tbname, java.util.TreeMap oldCols, java.util.TreeMap newCols)
      Loop through the columns for this table to see if any need case change to lower or upper.
      java.lang.String buildColumnLine(java.util.HashMap colInfo, boolean doDefault, boolean alter)
      Build a line defining a particular column.
      java.lang.String buildColumnLine(java.util.HashMap colInfo, boolean doDefault, boolean doNullClause, boolean alter)
      Build a line defining a particular column.
      java.lang.String buildCreateTableStatement(java.util.HashMap tableInfo, boolean doColDefault, boolean includeDroppedCols, java.lang.String dbstoragepartition, boolean specifyStorage)
      Build "create table" statement.
      java.lang.String buildCreateTableStatement(java.lang.String tbname, java.util.TreeMap tableCols, boolean doColDefault, boolean includeDroppedCols, java.lang.String dbstoragepartition, boolean addRowstamp, java.lang.String storageClause)
      Build "create table" statement.
      java.util.ArrayList buildCreateViewStatement(java.util.HashMap viewInfo, boolean includeDroppedCols, boolean forceDropStmt)
      Build "create view" statement.
      java.lang.String buildDefaultDataStatement(java.lang.String tbname, java.util.HashMap newColInfo, java.util.HashMap oldColInfo)
      Output statement "update table set column = value where column is null".
      java.util.ArrayList buildDefaultDataStatement(java.lang.String tbname, java.util.TreeMap newTableCols, java.lang.String colNameList, java.util.TreeMap oldTableCols)
      Output an array of update statements in the format "update table set column = value where column is null".
      java.util.ArrayList buildGrants(java.lang.String tbname, boolean outputSchema, boolean maxusersOnly)
      Create an array where each element is a "grant" statement.
      java.lang.String buildIndexStatement(java.util.HashMap ixInfo, boolean specifySchema, boolean specifyStorage)
      Construct a "create index" statement using index metadata.
      java.lang.String buildIndexStatement(java.lang.String tbname, java.util.TreeMap tableCols, java.lang.String dbstoragepartition)
      Uses primarykeycolseq in metadata to build a "create unique index" statement.
      java.lang.String buildInsertStatementPrefix(java.lang.String tbname, java.util.TreeMap tableCols, boolean doRowstamp, boolean includeDroppedCols)
      Builds the beginning of an insert statement in the format "insert into tbname (col1, col2, col3, ...)", with line breaks.
      java.lang.String buildInsertStatementPrefix(java.lang.String tbname, java.util.TreeMap tableCols, boolean doRowstamp, boolean includeDroppedCols, java.lang.String colNameList, boolean doLineBreaks) 
      java.lang.String buildInsertStatementPrefix(java.lang.String tbname, java.util.TreeMap tableCols, boolean doRowstamp, boolean includeDroppedCols, java.lang.String colNameList, boolean doLineBreaks, boolean addTenantid)
      Builds the beginning of an insert statement in the format "insert into tbname (col1, col2, col3, ...)".
      java.util.TreeMap buildInsertValuesStatement(java.lang.String prefix, java.sql.ResultSet rs, java.util.TreeMap tableCols, boolean includeDroppedCols, java.lang.String rowstampValue) 
      java.util.TreeMap buildInsertValuesStatement(java.lang.String prefix, java.sql.ResultSet rs, java.util.TreeMap tableCols, boolean includeDroppedCols, java.lang.String rowstampValue, boolean psFormat)
      Build one complete insert statement in the format "insert into tbname (col1, col2, col3, ...) values (val1, val2, val3,...)".
      java.util.TreeMap buildInsertValuesStatement(java.lang.String prefix, java.sql.ResultSet rs, java.util.TreeMap tableCols, boolean includeDroppedCols, java.lang.String rowstampValue, boolean psFormat, java.util.Map allSeq) 
      java.util.TreeMap buildInsertValuesStatement(java.lang.String prefix, java.sql.ResultSet rs, java.util.TreeMap tableCols, boolean includeDroppedCols, java.lang.String rowstampValue, boolean psFormat, java.util.Map allSeq, int tenantid)
      Build one complete insert statement in the format "insert into tbname (col1, col2, col3, ...) values (val1, val2, val3,...)".
      java.lang.String buildSelectStatement(java.lang.String tbname, java.util.TreeMap tableCols, boolean includeDroppedCols, boolean addRowstamp)
      Builds a select statement in the format "select col1, col2, col3, ...
      java.lang.String buildSelectStatement(java.lang.String tbname, java.util.TreeMap tableCols, boolean includeDroppedCols, boolean addRowstamp, boolean addTenantID)
      Builds a select statement in the format "select col1, col2, col3, ...
      java.lang.String buildSelectStatement(java.lang.String tbname, java.util.TreeMap tableCols, boolean includeDroppedCols, boolean addRowstamp, boolean addtenantID, java.lang.String colNameList)
      Builds a select statement in the format "select col1, col2, col3, ...
      java.lang.String buildSelectStatementForRestore(java.lang.String tempTbName, java.util.TreeMap newTableCols, boolean addRowstamp, java.lang.String colNameList, boolean doLineBreaks)
      Builds a select statement in the format "select col1, col2, col3, ...
      java.util.ArrayList buildSequences(java.util.HashSet sequences, boolean doMaxseq)
      Returns sql statements for dropping and recreating all the sequences for Oracle and DB2.
      java.util.ArrayList buildSequences(java.util.HashSet sequences, java.util.Map alreadyDone, boolean doMaxseq)
      Returns sql statements for dropping and recreating all the sequences for Oracle and DB2.
      java.util.ArrayList buildShortenStringStatement(java.lang.String tbname, java.util.TreeMap newTableCols, java.util.TreeMap oldTableCols)
      Output an array of update statements in the (pseudocode) format "update table set column = substring(column) where length of column > target length".
      int bytesSpaceNeeded(java.lang.String spaceName)
      Deprecated. 
      Replaced by spaceNeeded.
      boolean canAlterForLengthChange(java.lang.String tablename, java.lang.String columnname, int oldLength, int newLength)
      Called from canAlterTable to determine whether table can be altered for a column length change.
      boolean canAlterTable(java.lang.String tablename, java.util.HashMap newAttr, java.util.HashMap oldAttr, java.lang.String upgradeDir)
      Given that one attribute is being added, modified or dropped, and we're not adding or dropping the entire table, this method identifies whether that change can be done in ConfigDB via an "alter table" statement.
      boolean canAnalyzeTable()
      Identifies whether getAnalyzeTableStatement would normally return anything.
      java.util.ArrayList changeAmountFormat(int newLength, int newScale)
      Change the format for Amount fields.
      java.util.ArrayList changeStorageType(java.lang.String tabName, java.lang.String uniqueName, MTStorageType oldType, MTStorageType newType, java.lang.String userName, java.lang.String adminUser, boolean isInternal)
      Rebuild triggers as secure, and activae row level control for all tables
      java.util.TreeMap changeTreeKey(java.util.TreeMap oldMap, java.lang.String keyAttr)
      Given a TreeMap of metadata, output a new TreeMap that is the same except for its key.
      java.util.ArrayList cleanStatisticNames()
      If this is SqlServer and native statistics exist with the same name as an entry in maxsysindexes, then drop the statistics.
      void clearAlreadyDidUsingMultiSchema()
      Sets alreadyDidUsingMultiSchema to False so that usingMultiSchema will recalculate the value next time it is called.
      boolean columnIsEmpty(java.lang.String tbname, java.lang.String name)
      Identifies whether all rows for this table have null values for this column.
      boolean configInProcess()
      Determine whether configuration is currently in process (ConfigDB and RestoreFromBackup).
      void copyData(java.lang.String tabName, java.lang.String uniqueColumn, int toTenantid, int storageType, boolean delete, java.io.PrintStream out)
      Copy all template data for a table from template (TENANTID = 0) to a tenant
      java.util.List createExtensionView(java.lang.String objectName, java.util.Map extendedTables, java.sql.Connection masterCon, int tenantId, boolean deleteOnly, boolean mtEnabled)
      Calls createTable for each extension table to be created.
      void createMaxsequenceTrigger()
      For DB2, the trigger names are tbname + "_M", tbname + "_D" and tbname + "_E".
      java.util.ArrayList createOneSequenceFromMaxSequence(java.lang.String sequenceName)
      Returns sql statement for creating one sequence from values specified in maxsequence table.
      void createOneSqlServerSequences(java.lang.String sequenceName, java.lang.String tableName, java.lang.String columnName, int seqIncInt)
      Cache the sequences for later use in createSequences.
      java.util.List createPermission(java.lang.String tabName, java.lang.String uniqueName, java.lang.String newTenantUser, java.lang.String landlordUser, MTStorageType type)
      Create permissions for Multitenancy
      java.util.List createPermission(java.lang.String tabName, java.lang.String uniqueName, java.lang.String newTenantUser, java.lang.String landlordUser, MTStorageType type, boolean addProcessUser)
      Create permissions for Multitenancy
      void createSqlServerSequences(boolean dropOnly) 
      java.sql.Statement createStatement()
      Return a Statement created with the appropriate parameters for this platform.
      java.util.List createTenantidTriggeres(java.lang.String tbname, MTStorageType storageType, boolean secureRowlevelTriggers, boolean dropInsert, boolean dropUpdateDelete, boolean createDeltaTriggers)
      For DB2, the trigger names are tbname + "_M", tbname + "_D" and tbname + "_E".
      java.util.ArrayList db2textAlterIndexes() 
      java.util.ArrayList db2textAlterIndexes(boolean updateNow)
      For DB2, read through the vector of index names populated by enableRichTextSearch and return array of "db2ts alter index" statements specifying Update Frequency.
      java.util.ArrayList deleteObjectDelta(int tenantId)
      Return "delete from maxobjectcfg where exists".
      boolean descendingIndexesSupported()
      Identifies whether descending indexes are supported by this database platform.
      java.util.ArrayList disableMTPermission(java.lang.String tabName, MTStorageType storageType)
      deactivate row level control for a table
      java.util.ArrayList disableRichTextSearch(java.lang.String tbname, java.lang.String colName, java.lang.String handleColName)
      Return the Sql statements needed to disable rich text searching for a given column.
      java.util.ArrayList dropDeltaTriggers()
      Rebuild triggers as secure, and activae row level control for all tables
      boolean dupIndexNamesExist(java.lang.String tbname, java.lang.String ixname)
      Determine whether the same index name is used on more than one table on the native database.
      java.util.ArrayList enableForMultiTenancy(java.lang.String tabName, java.lang.String uniqueName, java.lang.String userName, java.lang.String adminUser, MTStorageType storageType)
      Rebuild triggers as secure, and activae row level control for all tables
      java.util.ArrayList enableRichTextSearch(java.util.HashMap objInfo, java.util.TreeMap tbIndexes, boolean doCheck, boolean skipDb2Connect)
      Enable rich text search for a table and any attributes that are flagged for it.
      java.util.ArrayList enableRichTextSearch(java.lang.String tbname, java.lang.String colName, java.lang.String handleColName, java.util.HashMap ixInfo, boolean skipCreateUniqueIndex)
      Call enableRichTextSearch with last param (startIxNum) = 1.
      java.util.ArrayList enableRichTextSearch(java.lang.String tbname, java.lang.String colName, java.lang.String handleColName, java.util.HashMap ixInfo, boolean skipCreateUniqueIndex, int startIxNum)
      Call other version of this method with skipDb2Connect param false.
      java.util.ArrayList enableRichTextSearch(java.lang.String tbname, java.lang.String colName, java.lang.String handleColName, java.util.HashMap ixInfo, boolean skipCreateUniqueIndex, int startIxNum, boolean skipDb2Connect)
      Return the Sql statements needed to enable rich text searching for a given table or column.
      boolean explicitConversionSupported(java.lang.String newType, java.lang.String oldType)
      Identifies whether explicit datatype conversion is supported for SqlServer or DB2 datatype change.
      java.util.ArrayList fixMetadataForDescendingKeys(java.lang.String tbname, java.lang.String ixname)
      This method should be called immediately after executing the Sql from getSysIndexRefresh on an Oracle platform.
      void fixSqlServerPrimaryIndex()
      Primary index in SQL Server have to be clustered
      void fixSqlServerSequence()
      Cache the sequences for later use in createSequences.
      void fixSqlServerSequence(java.lang.String whereClause)
      Cache the sequences for later use in createSequences.
      java.lang.String getAddRowstampSql(java.lang.String tbname)
      Return the "alter table" statement for adding the rowstamp column.
      java.util.ArrayList getAnalyzeTableStatement(java.lang.String tbname)
      Output "analyze table compute statistics" statement(s) for Oracle.
      java.util.ArrayList getApplyTenantChanges(int tenantid, boolean mtEnabled)
      Generate Sql statements to remove configuration changes that have not yet been implemented.
      java.util.ArrayList getAttributeCfgRefresh()
      Return "insert into maxattributecfg (col1, col2, ...) select col1, col2, ...
      java.util.ArrayList getAttributeCfgRefresh(int tenantId, boolean mtEnabled)
      Return "insert into maxattributecfg (col1, col2, ...) select col1, col2, ...
      java.util.HashMap getAttributeForMaxViewColumn(java.lang.String viewName, java.util.HashMap viewcolInfo, java.util.TreeMap distinctAttrs)
      Given a row from MaxViewColumn and a set from MaxAttribute, find the row in MaxAttribute that corresponds to this MaxViewColumn.
      java.util.TreeMap getAttributeMeta(java.lang.String objectname, boolean getCfg, boolean orderByName, boolean getPersistentOnly, boolean getChangedOnly, boolean selectView, java.lang.String entityName)
      Get attribute metadata (maxattributes and maxviewcolumns) for an object.
      java.lang.String getAttributeName(java.lang.String objectname, java.lang.String tablename, java.lang.String columnname)
      Get attributename for a given column.
      java.util.ArrayList getAttributeRefresh()
      Return "insert into maxattribute (col1, col2, ...) select col1, col2, ...
      java.util.ArrayList getAttributeRefresh(int tenantId, boolean mtEnabled, java.lang.String objectName)
      Return "insert into maxattribute (col1, col2, ...) select col1, col2, ...
      java.lang.String getBackupTableName(java.lang.String tbname)
      Get the name of the backup table.
      java.util.HashMap getColumnInfo(java.util.TreeMap tableCols, java.lang.String name)
      Given a TreeMap of columns in a table that is keyed by attribute number (attributeno), find the HashMap for the specified column name and return it.
      java.lang.String[] getColumnName(java.lang.String objectname, java.lang.String attributename)
      Get tablename and columnname for a given attribute.
      java.lang.String getColumnNames(java.util.TreeMap tableCols, boolean doLineBreaks, boolean includeDroppedCols)
      Calls getColumnNames with the colNameList parameter null, and the useAlias parameter False.
      java.lang.String getColumnNames(java.util.TreeMap tableCols, boolean doLineBreaks, boolean includeDroppedCols, java.lang.String colNameList, boolean useAlias)
      For a table, output the persistent column names (lower case) delimited by commas.
      java.lang.String[] getColumnNamesForExtendedView(java.util.TreeMap tableCols, java.lang.String tableName, java.util.Map extendedTables, java.lang.String uniqueColumnName, java.lang.String isView, boolean mtEnabled)
      For a table, output the persistent column names (lower case) delimited by commas.
      java.lang.String getColumnNamesNative(java.lang.String tbname)
      Get comma-delimited list of lowercase column names from the native metadata for the specified table.
      java.lang.String getCurrentNativeSchema()
      Get the current session's default schema from the native system tables.
      java.util.TreeMap getData(java.lang.String tbname, java.util.TreeMap tableCols, java.lang.String where)
      Output the data in the table to a TreeMap.
      java.lang.String getDatabaseName()
      Get the database name from system tables depending on database type.
      java.lang.String getDB2ConvertString(java.lang.String oldNativeType, java.lang.String newNativeType, java.lang.String colName)
      If a DB2 function can convert the oldNativeType to the newNativeType, return the function.
      java.lang.String getDB2TextIndexSpace()
      Get the index space for DB2 text search indexes.
      int getDB2Version()
      If dbIn is DB2, this method returns the first part of the database version (8, 9, etc.).
      double getDB2Version(boolean getPoint)
      If dbIn is DB2, this method returns the database version.
      java.lang.String getDBHostName()
      Get the host name where database is installed from system tables depending on database type.
      java.util.ArrayList getDBStoragePartitions()
      Get the names of the storagepartitions from the valuelist DBSTORAGEPARTITION.
      java.lang.String getDefaultStoragePartition(boolean checkValuelist)
      Get the name of the default storagepartition.
      java.lang.String getDefaultString(java.lang.String tbname, java.util.HashMap colInfo)
      Return a string in format for use in a Sql statement for the designated column.
      java.lang.String getDefaultString(java.lang.String tbname, java.lang.String colName, java.lang.String maxtype, java.lang.String metaDefaultValue, java.lang.String domainid) 
      java.lang.String getDefaultString(java.lang.String tbname, java.lang.String colName, java.lang.String maxtype, java.lang.String metaDefaultValue, java.lang.String domainid, java.lang.String sequenceName, int uidRule, int seqRule, int autoRule, int mboRule, int appRule, boolean outputQuotes, boolean assignIfNoMeta)
      This method is the central respository for database utilities (other than upgrade and Mbo framework) to get an attribute's default value.
      java.util.List getDeltaTriggerSql(java.lang.String tbname)
      Rebuild triggers as secure, and activate row level control for all tables.
      java.lang.String getDisableTriggerStatement(java.lang.String triggerName, java.lang.String tbname)
      Return a "disable trigger" statement for the specified trigger.
      java.util.ArrayList getDisallowPageLocks()
      Return the Sql statements to disallow page locks for the indexes on Maximo tables that are not already disallowed.
      java.util.ArrayList getDropStatisticsStatements(java.lang.String tbname, java.lang.String colname)
      Return "drop statistics" statement(s) for SqlServer platform only.
      java.util.ArrayList getDropStatisticsStatementsForConfig(java.lang.String entityname)
      Get the "drop statistics" statements for all columns that are pending ConfigDB.
      java.lang.String getEnableDisableTriggersAll(java.lang.String tbname, boolean enable)
      Return the Sql command for enabling or disabling all triggers on a specified table.
      java.lang.String getEnableTriggerStatement(java.lang.String triggerName, java.lang.String tbname)
      Return a "enable trigger" statement for the specified trigger.
      java.lang.String getExtendedUniqueColumnForView(java.lang.String viewName, java.lang.String extTableName)
      This method gets unique column name for the view and extended table name.
      static java.lang.String getFileText(java.io.InputStream fileStrm)
      Get the content of the file
      java.util.HashMap getGrants(java.lang.String username, java.lang.String entityname)
      Determine what objects the user has read, insert, update, or delete access to.
      java.lang.String getGrantSql(java.lang.String dbUserID, java.lang.String entityname, java.lang.String privilege, boolean grant)
      Grant or revoke native database access for a given user and table/view.
      java.util.TreeMap getIndexMeta(java.lang.String tbname, boolean getChangedOnly) 
      java.util.TreeMap getIndexMeta(java.lang.String tbname, boolean getChangedOnly, boolean getPrimary) 
      java.util.TreeMap getIndexMeta(java.lang.String tbname, boolean getChangedOnly, boolean getPrimary, boolean includeDeleted)
      Get metadata for indexes.
      java.util.ArrayList getIndexNamesForColumn(java.lang.String tbname, java.lang.String colName)
      Get the names of indexes that exist in the metadata and contain the specified column.
      java.lang.String getInternalSearchType(java.lang.String externalSearchType)
      Given the external value of searchtype, return the internal value from synonymdomain table.
      java.lang.String getInternalSiteOrgType(java.lang.String externalSiteOrgType)
      Given the external value of siteorgtype, return the internal value from synonymdomain table.
      int getJdbcType(java.lang.String nativeType, int dbPlatform)
      Get the JDBC Type (java.sql.Types) for the native datatype.
      java.lang.String getKeyAttribute(java.lang.String objectname, java.lang.String tablename)
      This method identifies the "key attribute" (i.e., the unique column within siteid or orgid) so that ConfigDB can determine whether the table has an attribute that can be autonumbered (canautonum = True).
      java.util.TreeMap getKeyColumns(java.util.TreeMap indexMeta, java.util.TreeMap tableCols, java.lang.String indexToSkip)
      Determine the columns in a table's primary key.
      java.lang.String getLangColumnName(java.lang.String tbname)
      Get the name of the language column for a given table.
      boolean getLocDefault(java.lang.String objectName, java.lang.String attributeName, java.util.HashMap attrInfo, java.util.HashMap sameasAttrInfo)
      Identifies the default value for "localizable" for the specified attribute.
      int getMaxColno(java.lang.String objectname, boolean getCfg, java.lang.String where)
      Get the maximum value of "attributeno" from the metadata for this object.
      int getMaxColumnLength(java.lang.String tbname, java.lang.String name)
      Get the maximum actual data length for this column.
      int getMaxEAuditTransID()
      Get the maximum value of "eaudittransid" from all of the eaudit tables.
      int getMaximumColumnNameLength()
      Get the maximum length of a column name.
      int getMaxLengthColumnInIndex()
      Get the maximum allowed for the length of any one column in an index.
      int getMaxLengthIndex()
      Get the maximum allowed for the sum of lengths of all columns in an index.
      java.lang.String[] getMaxTableAttrs()
      Loads the attributes of the MaxTable table.
      java.lang.String getMaxType(java.lang.String nativeType)
      Return the Maximo datatype for the specified native datatype.
      java.lang.String getMaxUpgVersion()
      Return the value of maxUpgVersion (the maxvar value for MAXUPG), initialized via the constructor.
      java.lang.String getMaxvar(java.lang.String varname, boolean getDefault)
      Get value of maxvar from database.
      int getMaxVarcharLength()
      Get the maximum allowed for the length a varchar column.
      java.util.HashSet getMetadataSequenceNames()
      Get description of the sequences used on the metadata tables for objects, attributes, tables and views.
      java.lang.String getNativeDateDefault()
      Return the native command for getting the current system date.
      java.lang.String getNativePartition(java.lang.String tbname)
      Return the native storage partition for the specified table.
      java.lang.String getNativeType(java.lang.String maxType, java.lang.String length, int dbPlatform)
      Return the native datatype for the specified Maximo datatype.
      java.lang.String getNativeTypeForColumn(java.lang.String tbname, java.lang.String name)
      Return the native datatype from the system tables for the specified column.
      java.lang.String getNewIndexName(java.lang.String tbname, int startWith)
      Identify an index name that can be used for creating a new index on this table.
      int getNextAttrNo(java.lang.String tablename)
      Rebuild triggers as secure, and activae row level control for all tables
      long getNextSequenceNo(java.lang.String sequenceName)
      Get the next value for this sequence.
      java.lang.String getNextSequenceValueForSqlServer(java.lang.String seqName)
      This method gets the next value from maxsequence and updates maxsequence.
      java.lang.String getNo()
      Return the value of sNo.
      java.util.ArrayList getObjectCfgRefresh()
      Return "insert into maxobjectcfg (col1, col2, ...) select col1, col2, ...
      java.util.ArrayList getObjectCfgRefresh(int tenantId, boolean mtEnabled)
      Return "insert into maxobjectcfg (col1, col2, ...) select col1, col2, ...
      java.util.TreeMap getObjectMeta(java.lang.String objectname, boolean getCfg, boolean getPersistentOnly, boolean getChangedOnly, boolean getColumns, boolean colsOrderByName, boolean getTablesOnly, boolean getViewsOnly)
      Get metadata for an object (table or view).
      java.lang.String getObjectName(java.lang.String entityname, boolean useIsViewConstraint, boolean isView)
      Get objectname for a given table or view.
      java.util.ArrayList getObjectRefresh()
      Return "insert into maxobject (col1, col2, ...) select col1, col2, ...
      java.util.ArrayList getObjectRefresh(int tenantId, boolean mtEnabled, java.lang.String objectName)
      Return "insert into maxobject (col1, col2, ...) select col1, col2, ...
      java.lang.String getOldBackupTables(java.lang.String tbname)
      Return a Sql statement that checks for the existence of old backup tables.
      java.lang.String getOracleConvertString(java.lang.String oldNativeType, java.lang.String newNativeType, java.lang.String colName)
      If an Oracle function can convert the oldNativeType to the newNativeType, return the function.
      int getOracleVersion()
      If dbIn is Oracle, this method returns the first part of the database version (8, 9, etc.).
      double getOracleVersion(boolean getPoint)
      If dbIn is Oracle, this method returns the database version.
      java.util.TreeMap getOrgs(boolean includeDisabled)
      Identify the organizations on the database.
      java.util.ArrayList getPartitionRefresh()
      Output the Sql statements needed to update dbstoragepartition on maxtable and maxtablecfg with the actual native partition name.
      java.util.Map getPrimaryKeys() 
      java.util.TreeMap getPrimaryKeys(java.lang.String objname, boolean getCfg) 
      java.util.ArrayList getRemoveChanges()
      Generate Sql statements to remove configuration changes that have not yet been implemented.
      java.util.ArrayList getRemoveTenantChanges(int tenantid, boolean mtEnabled)
      Generate Sql statements to remove configuration changes that have not yet been implemented.
      java.lang.String getRenameTableStatement(java.lang.String oldTbname, java.lang.String newTbname)
      Return a "rename table" statement for the specified table.
      java.util.ArrayList getRowstampTriggerSql(java.lang.String tbname, boolean dropIfExists)
      Return the "create or replace trigger" statement(s) for populating the rowstamp column.
      java.util.ArrayList getRowstampTriggerSql(java.lang.String tbname, boolean dropIfExists, boolean makeSecure)
      Return the "create or replace trigger" statement(s) for populating the rowstamp column.
      java.lang.String getSchemaName()
      Get the schema name from system tables depending on database type.
      java.util.HashMap getSequences(java.lang.String tableName)
      Cache the sequences for later use in createSequences.
      java.lang.String getSiteOrgType(java.lang.String objectname)
      Get internal siteorgtype for a given table.
      java.util.TreeMap getSites(boolean includeDisabled)
      Identify the sites on the database.
      int getSqlServerCompatLevel()
      If dbIn is SqlServer, this method returns the database compatibility level.
      java.lang.String getSqlServerConvertString(java.lang.String oldTbname, java.lang.String newTbname, java.util.HashMap newColInfo)
      Return SqlServer sql for "convert" from datatype for a specified column.
      int getSqlServerVersion()
      If dbIn is SqlServer, this method returns the first part of the database version (8, 9, etc.).
      double getSqlServerVersion(boolean getPoint)
      If dbIn is SqlServer, this method returns the database version.
      java.lang.String getStorageClause(java.lang.String name, boolean isTable)
      Get the "storage" clause to use when creating a table or index.
      java.lang.String getStoragePartition(java.lang.String tbname)
      Get storagepartition for a given table.
      MTStorageType getStorageType(java.lang.String tableName)
      Get storage type for a given table.
      java.util.ArrayList getSysIndexRefresh(java.lang.String tbname, java.lang.String ixname)
      Create an array of "insert into maxsysindexes" and "insert into maxsyskeys" statements based on the actual existing native indexes.
      java.lang.String getTableCfgRefresh()
      Return "insert into maxtablecfg (col1, col2, ...) select col1, col2, ...
      java.lang.String getTableCfgRefresh(int tenantId, boolean mtEnabled)
      Return "insert into maxtablecfg (col1, col2, ...) select col1, col2, ...
      java.lang.String getTableName(java.lang.String objectname)
      Get tablename for a given object.
      java.lang.String getTableRefresh()
      Return "insert into maxtable (col1, col2, ...) select col1, col2, ...
      java.lang.String getTableRefresh(int tenantId, boolean mtEnabled, java.lang.String tableName)
      Return "insert into maxtable (col1, col2, ...) select col1, col2, ...
      java.util.HashMap getTenantAttributeMeta(java.lang.String objectname, int tenantId)
      Get attribute metadata (maxattributes and maxviewcolumns) for an object.
      java.util.ArrayList getTenantCodeMetadata()
      Retrieve datatype and length for TENANTCODE from maxattributecfg talbe TENANTREG
      java.util.Map getTenantExtAttributes(java.sql.Connection conn, java.lang.String objectName, int tenantId)
      Returns the attributes for the given tenant and/or object.
      java.util.Map gettenantSameAsExtendedAtributes(int tenantId)
      Get attribute metadata (maxattributes and maxviewcolumns) for an object.
      java.util.Map getTextSearchIndexes() 
      java.util.HashMap getTextSearchIndexForColumn(java.lang.String tbname, java.lang.String colName, java.util.TreeMap tbIndexes)
      Get the index metadata for the text search index for the specified table and column.
      java.util.ArrayList getTriggerNames(java.lang.String tbname, boolean getEnabled, boolean getDisabled, boolean includeRowstamp)
      Get the names of triggers that satisfy the specified parameters.
      java.lang.String getTrigRoot(java.lang.String tbname)
      Gets the trigger name root for the table.
      java.lang.String getUniqueColumnName(java.lang.String tbname)
      Get the name of the unique column for a given table, from our metadata.
      java.lang.String getUniqueColumnNameNative(java.lang.String tbname)
      Get the name of the unique column for a given table, from the native db (NOT our metadata).
      java.lang.String getUniqueIndexSpace(java.lang.String tbname, java.lang.String tbPartition)
      This method is intended for building DB2 "create table" statements.
      java.lang.String getUnrestoredTables(java.lang.String tbname)
      Return a Sql statement that checks for the existence of tables where maxtablecfg.restoredata = True.
      java.util.ArrayList getUpdateStatistics(java.util.TreeMap tableMap, java.util.TreeMap indexMap)
      Generate "dbms_stats.gather_table_stats" (for Oracle) or "update statistics" (for SqlServer) statements for the specified tables/indexes; does not include an index if it is being dropped.
      java.util.ArrayList getUpdateTenantDelta(java.util.HashMap changedObjects, int tenantId, java.util.TreeMap cfgAttrs, java.util.Vector skipList)
      THis method will store all attributes which were changed by System Admistrator.
      java.lang.String getUserFromProperties(boolean getLandlordUser)
      Rebuild triggers as secure, and activae row level control for all tables
      int getVarcharMultiple()
      Return the value of varchar multiple.
      java.lang.String getViewCfgRefresh()
      Return "insert into maxviewcfg (col1, col2, ...) select col1, col2, ...
      java.lang.String getViewCfgRefresh(int tenantId, boolean mtEnabled)
      Return "insert into maxviewcfg (col1, col2, ...) select col1, col2, ...
      java.lang.String getViewColumnCfgRefresh()
      Return "insert into maxviewcolumncfg (col1, col2, ...) select col1, col2, ...
      java.lang.String getViewColumnCfgRefresh(int tenantId, boolean mtEnabled)
      Return "insert into maxviewcolumncfg (col1, col2, ...) select col1, col2, ...
      java.lang.String getViewColumnRefresh()
      Return "insert into maxviewcolumn (col1, col2, ...) select col1, col2, ...
      java.lang.String getViewColumnRefresh(int tenantId, boolean mtEnabled)
      Return "insert into maxviewcolumn (col1, col2, ...) select col1, col2, ...
      java.lang.String getViewName(java.lang.String objectname)
      Get viewname for a given object.
      java.lang.String getViewRefresh()
      Return "insert into maxview (col1, col2, ...) select col1, col2, ...
      java.lang.String getViewRefresh(int tenantId, boolean mtEnabled)
      Return "insert into maxview (col1, col2, ...) select col1, col2, ...
      java.lang.String getYes()
      Return the value of sYes.
      boolean hasGrants() 
      boolean implicitConversionSupported(java.lang.String newType, java.lang.String oldType)
      Identifies whether implicit datatype conversion is supported for SqlServer datatype change.
      boolean indexMetaExistsForPrikeycolseq(java.lang.String objname, java.lang.String tbname, boolean getCfg)
      Determine whether index metadata exists for the primarykeycolseq for the specified table.
      boolean isHandleColumn(java.lang.String colName, java.util.TreeMap attrs)
      Determines whether the specified column is a "handle column" for text search, based on our metadata.
      boolean isLocAllowed(java.lang.String objectName, java.lang.String attributeName, java.util.HashMap attrInfo, java.util.HashMap sameasAtrInfo)
      Identifies whether "localizable" allowed to be True for the specified attribute.
      boolean isMTEnabled()
      Given the name of a column on maxtablecfg, maxattributecfg, maxsysindexes, or maxsyskeys, identify whether this is a YORN attribute.
      boolean isNickname(java.lang.String name)
      Determine whether the given name is a nickname.
      boolean isObjectLocked(java.lang.String entityname)
      Identifies whether an object has been locked in the native database.
      boolean isPrimaryIndex(java.util.List indexColumns, java.util.HashSet primaryKeys) 
      boolean isReorgPending(java.lang.String tbname)
      Specifies whether reorg is pending for this table (DB2 only).
      boolean isReservedWord(java.lang.String testWord)
      Identifies whether the testWord is a reserved word on the native database.
      boolean isRichTextSupported(java.lang.String tbname, java.lang.String name)
      This method identifies whether rich text functionality is supported in this database.
      boolean isRTSupportedForDB()
      Is Text Search supported for this database platform and Maximo parameters? Same as isRichTextSupported(null, null) but optimized for performance.
      boolean isSpecialDefaultValue(java.lang.String value)
      Identify whether the give value is one of the special reserved words for defaultvalue (e.g.
      boolean isSysNumeric(java.lang.String attrName)
      Given the name of a column on maxtablecfg, maxattributecfg, maxsysindexes, or maxsyskeys, identify whether this is a numeric attribute.
      boolean isSysYORN(java.lang.String attrName)
      Given the name of a column on maxtablecfg, maxattributecfg, maxsysindexes, or maxsyskeys, identify whether this is a YORN attribute.
      boolean isTable(java.util.HashMap tableInfo)
      Quickly identifies whether this is a table or a view.
      boolean lockMaximoTables(java.lang.String tbname, boolean lock)
      Deprecated. 
      The logic for SqlServer is not working consistently. This method may be removed.
      boolean longIndexNamesExist(java.lang.String tbname)
      Identified whether native indexes exist whose index name is longer than that allowed by Maximo.
      java.util.ArrayList makeSpace(java.lang.String spaceName, int numBytes)
      Deprecated. 
      Replaced by makeSpace
      java.util.ArrayList makeSpace(java.lang.String spaceName, int numBytes, java.lang.String multiplier)
      Return Sql statements that will effectively determine whether space can be extended for the specified number of bytes.
      boolean mxServerIsUp(java.lang.String serverName)
      Determine whether MXServer is running.
      boolean nameInList(java.lang.String name, java.lang.String list)
      Does the name exist in the list? Called from getColumnNames.
      boolean nativeColumnExists(java.lang.String tbname, java.lang.String name)
      Determine whether the native column exists.
      boolean nativeColumnIsNullable(java.lang.String tbname, java.lang.String name)
      Determine whether the native column is nullable.
      java.util.ArrayList nativeDefaultConstraintExists(java.lang.String tbname, java.lang.String name)
      Identifies whether the given column has a default constraint in SqlServer.
      boolean nativeIndexExists(java.lang.String ixname, java.lang.String tbname)
      Determine whether the native index exists.
      java.util.ArrayList nativeIndexExistsForColumn(java.lang.String tbname, java.lang.String name)
      Identifies whether the given column participates in a native index for the given table.
      java.lang.String nativeIndexExistsForColumns(java.lang.String tbname, java.lang.Object[] names)
      Call nativeIndexExistsForColumns with last parameter false.
      java.lang.String nativeIndexExistsForColumns(java.lang.String tbname, java.lang.Object[] names, boolean ignoreTS)
      Identifies whether an index exists on the given table with the given sequence of columns.
      boolean nativeIndexIsPrimaryKey(java.lang.String ixname)
      Identifies whether an index is a native primary key for DB2.
      boolean nativeIndexIsUnique(java.lang.String ixname)
      Identifies whether an index is unique on the native database.
      boolean nativeSequenceExists(java.lang.String name)
      Determine whether the native sequence exists.
      boolean nativeSpaceExists(java.lang.String name)
      For Oracle and DB2, checks to see whether the native tablespace exists.
      boolean nativeTableExists(java.lang.String tbname)
      Determine whether the native table exists.
      boolean nativeTriggerExists(java.lang.String trigname)
      Determine whether the native trigger exists.
      boolean nativeTypesAreCompatible(java.lang.String oldNativeType, java.lang.String newNativeType)
      Identifies whether data can be copied from old table to new table without any conversion activity.
      boolean nativeViewExists(java.lang.String vname)
      Determine whether the native view exists.
      boolean needLength(java.lang.String maxtype, java.lang.String nativeType)
      For the specified datatype, identifies whether the column definition needs a length (for example, in a "create table" statement).
      boolean needScale(java.lang.String maxtype, java.lang.String nativeType)
      For the specified datatype, identifies whether the column definition needs a scale (for example, in a "create table" statement).
      boolean nullValueExists(java.lang.String tbname, java.lang.String name)
      Identifies whether any row for this table has null value for this column.
      java.util.ArrayList objAttrDelRefresh(int tenantid, boolean mtEnabled) 
      java.sql.PreparedStatement prepareStatement(java.lang.String sql)
      Return a prepared Statement created with the appropriate parameters for this platform.
      void processTemplateData(int toTenantid, boolean delete, java.lang.String maxUserGroup, java.lang.String allUserGroup, java.lang.String newUserGroup, java.io.PrintStream out)
      Copy all template data (STORAGETYPE = 3) from template (TENANTID = 0) to a tenant
      java.util.ArrayList rebuildIndexes(java.util.TreeMap indexMeta, boolean alwaysDrop, boolean neverDrop, boolean specifySchema, boolean specifyStorage)
      Output sql to drop and recreate the indexes.
      java.util.ArrayList rebuildMetadataSequences()
      Rebuild the native sequence and update maxsequence table for the sequences used by the Maximo metadata tables.
      void rebuildPermissions(java.lang.String processUser)
      Rebuild triggers as secure, and activate row level control for all tables
      java.util.ArrayList rebuildPrimaryIndex(java.lang.String tbname, java.lang.String ixName, java.util.List arrayNames, java.util.List textSearchKeys)
      Generates sql for creating a new index with the specified column names.
      java.util.List rebuildProcessUserVariable(java.lang.String adminUser)
      Rebuilds variable GV_MTPRCUSR for new user
      java.lang.String reEvaluateAttributeChanged(java.lang.String entityname, java.util.HashMap newAttr, java.util.HashMap oldAttr, java.lang.String upgradeDir, boolean isView)
      Call reEvaluateTableAttributeChanged or reEvaluateViewAttributeChanged, depending on whether this is a table or a view.
      java.lang.String reEvaluateAttributeChangedQuickGL(java.lang.String entityname, java.lang.String columnname, boolean isView, int oldLength, int newLength, boolean persistent, java.lang.String origChanged)
      This method is used for quick evaluation of the "changed" attribute for an attribute, when changing ONLY the length of the attribute for the purposes of GL account configuration.
      java.lang.String reEvaluateObjectChanged(java.util.HashMap newObject, java.util.HashMap oldObject, boolean useAttrChanged, java.lang.String upgradeDir)
      Look through the metadata for maxobjectcfg and maxattributecfg (old and new), and determine the proper value for maxobjectcfg changed.
      java.lang.String reEvaluateObjectChanged(java.util.HashMap newObject, java.util.HashMap oldObject, boolean useAttrChanged, java.lang.String upgradeDir, java.lang.String langcode) 
      java.lang.String reEvaluateObjectChangedQuickGL(java.lang.String entityname, boolean isView, java.util.HashMap attrs, boolean persistent, java.lang.String origChanged)
      For quick calculation of new value of "changed" when the only change being made is to GL Configure.
      java.lang.String reEvaluateTableAttributeChanged(java.lang.String tablename, java.util.HashMap newAttr, java.util.HashMap oldAttr, java.lang.String upgradeDir)
      For table attributes, look through the metadata for maxattributecfg (old and new) and determine the proper value for maxattributecfg changed.
      java.lang.String reEvaluateViewAttributeChanged(java.lang.String viewname, java.util.HashMap newAttr, java.util.HashMap oldAttr, java.lang.String upgradeDir)
      For view attributes, look through the metadata for maxattributecfg (old and new) and determine the proper value for maxattributecfg changed.
      java.util.List registerTableFromTemplate(java.lang.String tbname, java.util.TreeMap tableCols, java.lang.String whereClause)
      Output to the print stream a series of "insert into..." statements so that the table can be rebuilt.
      void reloadAttributeList()
      This builds the lists of metadata attributes to support instanciating Util for a database from a different release than the installed source code, which may have a different metadata structure.
      java.util.ArrayList renumberAttributeNumber(java.lang.String objectname, java.util.TreeMap attrs) 
      java.util.ArrayList renumberExtAttributeNumber(java.lang.String objectname, java.util.Map extTables, int start, java.util.ArrayList sqlList) 
      java.util.ArrayList renumberExtendedAttributes(int tenantId, java.util.Map lastNumbers, java.util.ArrayList list)
      This method will store all attributes which were changed by System Admistrator.
      void reorgBeforeDB2TSUpdate()
      Reorg tables that have DB2 TS indexes to avoid exceptions while updating TS indexes.
      java.util.ArrayList reorgTable(java.lang.String tbname, boolean redoTriggers)
      Call Reorg and related commands for a given table.
      java.util.ArrayList revalidateTextSearchIndexes(java.lang.String tbname)
      Get statements for revalidating text search indexes (DB2).
      boolean rowFound(java.lang.String sql)
      General purpose utility to test whether something exists.
      java.lang.String selectString(java.lang.String sql)
      General purpose utility to select one String value from database.
      java.lang.String setConfigInProcess(boolean inProcess)
      Return Sql for setting Config in process (maxvar CONFIGURING).
      void setConnection(java.sql.Connection connection)
      Set the database connection con, used for retrieving data.
      void setDB2tsPreferSysproc(boolean val)
      Set the preference for SYSPROC.TS vs "db2ts" CLP commands.
      void setDBOut(int platform)
      Identify how output should be formatted.
      void setPrintStream(java.io.PrintStream outstream)
      Set the output print stream out.
      void setVarcharMultiple(int val)
      This is used when the native length of a varchar column should be adjusted by some multiple of the length defined on maxattribute and the value cannot be loaded via the constructor (e.g.
      void setVargraphic(boolean val)
      This is used in DB2 platform when native datatype "vargraphic" should be used instead of "varchar".
      java.lang.String singleToDoubleQuotes(java.lang.String in)
      Scan input string to see if it contains any single quotes, and replace any single quote with two single quotes.
      java.lang.String[] spaceCheckForDBConfig()
      Using the metadata in maxattributecfg, determine whether adequate space is or can be made available for running ConfigDB.
      boolean spaceIsActive(java.lang.String spaceName)
      Determine whether the specified tablespace is available.
      boolean spaceIsSysManaged(java.lang.String spaceName)
      Determine whether the specified tablespace is system-managed.
      java.lang.Object[] spaceNeeded(java.lang.String spaceName)
      Determine how much space is needed from the specified tablespace name to run ConfigDB.
      void storeChangedAttributes(java.util.HashMap changedObjects, java.util.TreeMap attrs, java.lang.String objectname)
      THis method will store all attributes which were changed by System Admistrator.
      boolean tableIsEmpty(java.lang.String tbname)
      Identifies whether there are any rows on this table.
      java.lang.String toggleStringConcat(java.lang.String inString, java.lang.String inConcat, java.lang.String outConcat)
      Scan input string and change the concatenator character.
      java.util.List updateDMSource()
      Return sql to update Deployment Manager tables with new source value.
      void updateGroupName(java.lang.String tabName, java.lang.String maxUserGroup, java.lang.String allUserGroup, java.lang.String newUserGroup, int toTenantid)
      Copy all template data for a table from template (TENANTID = 0) to a tenant
      java.util.List updateIndexRequired()
      Sets the MaxSysIndexes Required flag for all indexes.
      java.util.ArrayList updateMaxSequence(java.util.HashSet sequences)
      Returns sql statements for updating MaxSequence MaxReserved.
      java.util.ArrayList updateMaxSequence(java.util.HashSet sequences, java.util.Map lastNumbers)
      Returns sql statements for updating MaxSequence MaxReserved.
      java.util.ArrayList updateViewMetaDataForExtendedAttr(java.sql.Connection conn, java.lang.String objectName, java.lang.String viewName, java.util.Map extAttr, int tenantId) 
      boolean upgradeDefaultExists(java.lang.String tbname, java.lang.String name, java.lang.String upgradeDir)
      If this is the upgrade process (upgradeDir is not null), this method identifies whether the upgrade provides a default value for the specified column.
      boolean useQuotes(java.lang.String maxtype)
      Return True if quotation marks need to surround the column's value in a SQL statement.
      boolean useVargraphic()
      Return the value of useVargraphic.
      boolean usingMultiSchema()
      Does this database use multi-schema?
      void writeDumpTable(java.lang.String tbname, java.util.TreeMap tableCols, java.io.PrintStream out) 
      int writeDumpTable(java.lang.String tbname, java.util.TreeMap tableCols, java.io.PrintStream out, int maxLines, int numLines, Unlcvt unlcvt, boolean psFormat)
      Output to the print stream a series of "insert into..." statements so that the table can be rebuilt.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MAX_NAME_LENGTH

        public int MAX_NAME_LENGTH
        Maximum object name length
      • objectAttrs

        public java.lang.String[] objectAttrs
        The attribute names on maxobject (except objectname and changed).
      • attrAttrs

        public java.lang.String[] attrAttrs
        The attribute names on maxattribute (except objectname, attributename, and changed). Attributeno must be the first element in this array.
      • viewAttrs

        public java.lang.String[] viewAttrs
        The attribute names on maxview (including viewname).
      • viewColAttrs

        public java.lang.String[] viewColAttrs
        The attribute names on maxviewcolumn (except viewname, viewcolumnname, and changed).
      • objectCfgNPAttrs

        public java.lang.String[] objectCfgNPAttrs
        The non-persistent attribute names on maxobjectcfg. This is provided as a convenience for the psdi.app.configure business objects.
      • attrCfgNPAttrs

        public java.lang.String[] attrCfgNPAttrs
        The non-persistent attribute names on maxattributecfg. This is provided as a convenience for the psdi.app.configure business objects.
      • attrTransAttrs

        public java.lang.String[] attrTransAttrs
        The translatable attribute names on maxattribute ("mlinuse" = 1). This is used when populating the language table.
      • objTransAttrs

        public java.lang.String[] objTransAttrs
        The translatable attribute names on maxobject ("mlinuse" = 1). This is used when populating the language table.
      • ssSELECTAUTH

        public static int ssSELECTAUTH
        SqlServer constant for Select privilege (193).
      • ssINSERTAUTH

        public static int ssINSERTAUTH
        SqlServer constant for Insert privilege (195).
      • ssDELETEAUTH

        public static int ssDELETEAUTH
        SqlServer constant for Delete privilege (196).
      • ssUPDATEAUTH

        public static int ssUPDATEAUTH
        SqlServer constant for Update privilege (197).
      • ssGRANTED

        public static int ssGRANTED
        SqlServer constant indicating that a privilege has been granted (205).
      • post602

        public boolean post602
        After release 6.0.2, some of the metadata attributes where changed from alphanumeric to YORN: maxtable/maxtablecfg (restoredata), maxsysindexes (uniquerule), maxsyskeys (ordering removed, replaced by ascending). Since this class may be used to apply patches from a 6.0 database to a 6.0.3 database and later, this class has to know what kind of metadata we're dealing with.
    • Method Detail

      • getMaxTableAttrs

        public java.lang.String[] getMaxTableAttrs()
                                            throws java.sql.SQLException
        Loads the attributes of the MaxTable table.
        Throws:
        java.sql.SQLException
        See Also:
        Util.maxTableAttrs
      • reloadAttributeList

        public void reloadAttributeList()
                                 throws java.lang.Exception
        This builds the lists of metadata attributes to support instanciating Util for a database from a different release than the installed source code, which may have a different metadata structure. This method is called from the constructor. If you intend to call this method manually, it must be the first thing you do after instanciating the class.

        It is conceivable that there may be some methods that still may not work on an exceedingly old database.

        Throws:
        java.lang.Exception
        See Also:
        Util.objectAttrs, #tableAttrs, Util.attrAttrs, Util.viewAttrs, Util.viewColAttrs, Util.sysYORNattrs, Util.sysNumattrs, psdi.upgrade.BuildUpgMetadata, Created to load/reload MaxTable attributes.
      • getCurrentNativeSchema

        public java.lang.String getCurrentNativeSchema()
                                                throws java.lang.Exception
        Get the current session's default schema from the native system tables.
        Returns:
        The current default schema
        Throws:
        java.lang.Exception
        See Also:
        Util.getSchemaName()
      • isTable

        public boolean isTable(java.util.HashMap tableInfo)
        Quickly identifies whether this is a table or a view.
        Parameters:
        tableInfo - HashMap of table and column attributes, see getObjectMeta.
        Returns:
        True if this is a table, False if this is a view.
      • buildCreateTableStatement

        public java.lang.String buildCreateTableStatement(java.util.HashMap tableInfo,
                                                          boolean doColDefault,
                                                          boolean includeDroppedCols,
                                                          java.lang.String dbstoragepartition,
                                                          boolean specifyStorage)
        Build "create table" statement. If the table metadata indicates to add the rowstamp, the rowstamp column will be included.
        Parameters:
        tableInfo - HashMap of table and column attributes, see getObjectMeta.
        doColDefault - True to include "default" info for the columns (if specified in tableCols), else False to skip it.
        includeDroppedCols - True to include columns whose "changed" attribute equals "R", else False to exclude them.
        dbstoragepartition - If this param is not null, the "create table" statment will specify the storageparition. If this param is null, that clause will be omitted.
        specifyStorage - True to include a storage clause. If True, the clause is retrieved from tableInfo "$STORAGECLAUSE".
        Returns:
        Sql statement.
        See Also:
        Util.buildCreateTableStatement(String, TreeMap, boolean, boolean, String, boolean, String)
      • buildCreateTableStatement

        public java.lang.String buildCreateTableStatement(java.lang.String tbname,
                                                          java.util.TreeMap tableCols,
                                                          boolean doColDefault,
                                                          boolean includeDroppedCols,
                                                          java.lang.String dbstoragepartition,
                                                          boolean addRowstamp,
                                                          java.lang.String storageClause)
        Build "create table" statement. This is similar to buildCreateTableStatement, except this has a separate parameter for the table name and an indicator for adding rowstamp.

        The statement will not include the "handle" columns used for DB2 text search. The handle column is created via db2ts (see enableRichTextSearch).

        Parameters:
        tbname - Table name.
        tableCols - Column attributes, see getAttributeMeta.
        doColDefault - True to include "default" info for the columns (if specified in tableCols), else False to skip it.
        includeDroppedCols - True to include columns whose "changed" attribute equals "R", else False to exclude them.
        dbstoragepartition - If this param is not null, the "create table" statment will specify the storageparition. If this param is null, that clause will be omitted.
        addRowstamp - True if the rowstamp column should be included, else False.
        storageClause - If non-null, this will be appended as the storage clause.
        Returns:
        Sql statement.
        See Also:
        Util.buildColumnLine(java.util.HashMap, boolean, boolean), Util.isHandleColumn(java.lang.String, java.util.TreeMap)
      • buildCreateViewStatement

        public java.util.ArrayList buildCreateViewStatement(java.util.HashMap viewInfo,
                                                            boolean includeDroppedCols,
                                                            boolean forceDropStmt)
                                                     throws java.sql.SQLException,
                                                            java.lang.Exception
        Build "create view" statement.
        Parameters:
        viewInfo - HashMap of object, view, viewcolumn, and attributes, see getObjectMeta.
        includeDroppedCols - True to include attributes whose "changed" attribute equals "R", else False to exclude them.
        forceDropStmt - If non-Oracle and this is True, then a "drop view" statement will always be included whether or not the view actually exists at the time this is run. If non-Oracle and this is False, the "drop view" statement will be included only if the view actually exists. Not relevant for Oracle.
        Returns:
        Sql statements. May include "drop view" if non-Oracle (see forceDropStmt parameter). Oracle uses "create or replace view."
        Throws:
        java.sql.SQLException
        java.lang.Exception
        See Also:
        Util.getAttributeForMaxViewColumn(java.lang.String, java.util.HashMap, java.util.TreeMap), Util.toggleStringConcat(java.lang.String, java.lang.String, java.lang.String)
      • getAttributeForMaxViewColumn

        public java.util.HashMap getAttributeForMaxViewColumn(java.lang.String viewName,
                                                              java.util.HashMap viewcolInfo,
                                                              java.util.TreeMap distinctAttrs)
                                                       throws java.lang.Exception
        Given a row from MaxViewColumn and a set from MaxAttribute, find the row in MaxAttribute that corresponds to this MaxViewColumn.
        Parameters:
        viewName - The view name.
        viewcolInfo - The entry from MaxViewColumn (or MaxViewColumnCfg)
        distinctAttrs - The set of MaxAttribute (or MaxAttributeCfg) for this view.
        Returns:
        HashMap representing a row from MaxAttribute (or MaxAttributeCfg)
        Throws:
        java.lang.Exception
      • buildColumnLine

        public java.lang.String buildColumnLine(java.util.HashMap colInfo,
                                                boolean doDefault,
                                                boolean alter)
        Build a line defining a particular column. For example:
        eqnum varchar2 (8) not null
        Calls buildColumnLine with the "doNullClause" parameter True.

        This is useful when building a "create table" or "alter table" statement.

        Parameters:
        colInfo - The HashMap of attributes for one column, see getAttributeMeta.
        doDefault - True to include "default" value info, else False to skip it.
        alter - True if altering the column, False otherwise (such as for "create table" or adding the column).
        Returns:
        String containing column name, datatype, length and scale (where needed), default value (depending on input param), and null / not null identifier.
        See Also:
        Util.buildColumnLine(HashMap, boolean, boolean, boolean)
      • buildColumnLine

        public java.lang.String buildColumnLine(java.util.HashMap colInfo,
                                                boolean doDefault,
                                                boolean doNullClause,
                                                boolean alter)
        Build a line defining a particular column. For example:
        eqnum varchar2 (8) not null

        This is useful when building a "create table" or "alter table" statement. Note, if maxvar VARCHARMULTIPLE is greater than 1 and this is a varchar/varchar2 column, the native length will be a multiple of the length specified in maxattribute.

        Also, if maxvar USEVARGRAPHIC is True and this is normally a varchar/varchar2 column, the native datatype will be vargraphic.

        Parameters:
        colInfo - The HashMap of attributes for one column, see getAttributeMeta.
        doDefault - True to include "default" value info, else False to skip it.
        doNullClause - True to include the "not null" clause where needed, False to omit it. This is used when we first need to create the columns, then assign a value, then alter it to not allow nulls.
        alter - True if altering the column, False otherwise (such as for "create table" or adding the column). (When altering the column, sometimes the null/notnull clause should be omitted, even if "doNullClause" parameter is True, depending on the platform.)
        Returns:
        String containing column name, datatype, length and scale (where needed), default value (depending on input param), and null / not null identifier (depending on input param).
        See Also:
        Util.getDefaultString(String,String,String,String,String,String,int,int,int,int,int,boolean,boolean)
      • buildDefaultDataStatement

        public java.util.ArrayList buildDefaultDataStatement(java.lang.String tbname,
                                                             java.util.TreeMap newTableCols,
                                                             java.lang.String colNameList,
                                                             java.util.TreeMap oldTableCols)
                                                      throws java.lang.Exception
        Output an array of update statements in the format "update table set column = value where column is null".

        Programmer's note: If the logic in canAlterTable changes, it may be necessary to change this method as well. For example, currently, YORN columns default to N even if "nullwithdefault" is No. These two methods have to be in synch.

        Parameters:
        tbname - Table name to use in the update statement
        newTableCols - Column attributes to use to evaluate the column. For a column to be included in the array, the "changed" attribute must not equal "N".
        colNameList - Can be null. If this parameter is not null, it should be a comma-delimited list of column names, and a column name will be included in the output only if it exists in both the tableCols TreeMap and in the colNameList. If this parameter is null then this comparison is not performed. For building this list, see getColumnNames and getColumnNamesNative.
        oldTableCols - Original column attributes to use to evaluate the column. For a column to be included in the array, the "changed" attribute must not equal "N".
        Returns:
        Array of update statements, one for each column that needs it.
        Throws:
        java.lang.Exception
        See Also:
        Util.buildDefaultDataStatement(String, HashMap, HashMap)
      • buildDefaultDataStatement

        public java.lang.String buildDefaultDataStatement(java.lang.String tbname,
                                                          java.util.HashMap newColInfo,
                                                          java.util.HashMap oldColInfo)
                                                   throws java.lang.Exception
        Output statement "update table set column = value where column is null".

        If this is a non-nullable column (required = True) and no default value is specified, this method will assume default values in the following situations. (This is to support the upgrade.)

        1. If this is a YORN column, the default will be No.
        2. If this is a numeric column, the default will be zero.
        Parameters:
        tbname - Table name to use in the update statement
        newColInfo - Column attributes to use to evaluate the column. For a statement to be generated, the column must not allow nulls (required = True), must have nullwithdefault = True, have a defaultvalue specified, and be persistent.
        oldColInfo - Original column attributes to use to evaluate the column.
        Returns:
        Update statement
        Throws:
        java.lang.Exception
        See Also:
        Util.nativeTypesAreCompatible(java.lang.String, java.lang.String), Util.getDefaultString(String,String,String,String,String,String,int,int,int,int,int,boolean,boolean)
      • buildShortenStringStatement

        public java.util.ArrayList buildShortenStringStatement(java.lang.String tbname,
                                                               java.util.TreeMap newTableCols,
                                                               java.util.TreeMap oldTableCols)
                                                        throws java.lang.Exception
        Output an array of update statements in the (pseudocode) format "update table set column = substring(column) where length of column > target length".
        Parameters:
        tbname - Table name to use in the update statement
        newTableCols - Column attributes to use to evaluate the column. For a column to be included in the array, the "changed" attribute must not equal "N", the new length must be less than the old length, and the new and old datatypes must be ALN, UPPER, LOWER, or GL.
        oldTableCols - Original column attributes.
        Returns:
        Array of update statements, one for each column that needs it.
        Throws:
        java.lang.Exception
        See Also:
        Util.getColumnInfo(java.util.TreeMap, java.lang.String)
      • buildChangeCaseStatement

        public java.util.ArrayList buildChangeCaseStatement(java.lang.String tbname,
                                                            java.util.TreeMap oldCols,
                                                            java.util.TreeMap newCols)
                                                     throws java.lang.Exception
        Loop through the columns for this table to see if any need case change to lower or upper. Output the Sql statement(s) to convert the data.
        Parameters:
        tbname - Table on which to perform the conversion.
        oldCols - Original columns and their attributes, in attributeno sequence.
        newCols - New columns and their attributes, in attributeno sequence.
        Returns:
        Array of Sql statements for updating the columns needing it. If no conversions are needed or possible, this will be empty.
        Throws:
        java.lang.Exception
        See Also:
        Util.changeTreeKey(java.util.TreeMap, java.lang.String), Util.buildChangeCaseStatement(String, String, String, String)
      • buildChangeCaseStatement

        public java.lang.String buildChangeCaseStatement(java.lang.String tbname,
                                                         java.lang.String name,
                                                         java.lang.String oldMaxtype,
                                                         java.lang.String newMaxtype)
                                                  throws java.lang.Exception
        If changing maxtype to LOWER or UPPER from another alphanumeric type, output the Sql statement to convert the data.
        Parameters:
        tbname - Table on which to perform the conversion.
        name - Name of the column to be converted.
        oldMaxtype - Original maxtype of the column.
        newMaxtype - New maxtype of the column.
        Returns:
        Sql statement for updating the column. If no conversion is needed or possible, this will be null.
        Throws:
        java.lang.Exception
      • buildSelectStatement

        public java.lang.String buildSelectStatement(java.lang.String tbname,
                                                     java.util.TreeMap tableCols,
                                                     boolean includeDroppedCols,
                                                     boolean addRowstamp)
        Builds a select statement in the format "select col1, col2, col3, ... from tbname". Calls buildSelectStatement with null for the colNameList parameter.

        If you need a "where" clause, you can append it separately.

        Besides being used for Select statements, this can be used with buildInsertStatementPrefix to create an Insert statement.

        See Also:
        #buildSelectStatement(String, TreeMap, boolean, boolean, String)
      • buildSelectStatement

        public java.lang.String buildSelectStatement(java.lang.String tbname,
                                                     java.util.TreeMap tableCols,
                                                     boolean includeDroppedCols,
                                                     boolean addRowstamp,
                                                     boolean addTenantID)
        Builds a select statement in the format "select col1, col2, col3, ... from tbname". Calls buildSelectStatement with null for the colNameList parameter.

        If you need a "where" clause, you can append it separately.

        Besides being used for Select statements, this can be used with buildInsertStatementPrefix to create an Insert statement.

        See Also:
        #buildSelectStatement(String, TreeMap, boolean, boolean, String)
      • buildSelectStatement

        public java.lang.String buildSelectStatement(java.lang.String tbname,
                                                     java.util.TreeMap tableCols,
                                                     boolean includeDroppedCols,
                                                     boolean addRowstamp,
                                                     boolean addtenantID,
                                                     java.lang.String colNameList)
        Builds a select statement in the format "select col1, col2, col3, ... from tbname".

        If you need a "where" clause, you can append it separately.

        Besides being used for Select statements, this can be used with buildInsertStatementPrefix to create an Insert statement.

        Parameters:
        tbname - Table name (must be persistent).
        tableCols - Column info, see getAttributeMeta.
        includeDroppedCols - True to include columns whose "changed" attribute equals "R", else False to exclude them.
        addRowstamp - True if the rowstamp column should be included in the statement, else False.
        colNameList - Can be null. If this parameter is not null, it should be a comma-delimited list of column names, and a column name will be included in the output string only if it exists in both the tableCols TreeMap and in the colNameList. If this parameter is null then this comparison is not performed. For building this list, see getColumnNames and getColumnNamesNative.
        Returns:
        Sql statement for select
      • getDefaultString

        public java.lang.String getDefaultString(java.lang.String tbname,
                                                 java.lang.String colName,
                                                 java.lang.String maxtype,
                                                 java.lang.String metaDefaultValue,
                                                 java.lang.String domainid)
                                          throws java.lang.Exception
        Parameters:
        tbname - Table name
        colName - Column name
        maxtype - Value of maxattribute(cfg) maxtype.
        metaDefaultValue - Value of maxattribute(cfg) defaultvalue.
        domainid - Value of maxattribute(cfg) domainid.
        Returns:
        Value to use in Sql statement for default value of this attribute. This string will include surrounding quotes if needed. Will equal null if no default value could be determined.
        Throws:
        java.lang.Exception
        See Also:
        Util.getDefaultString(String,String,String,String,String,String,int,int,int,int,int,boolean,boolean)
      • getDefaultString

        public java.lang.String getDefaultString(java.lang.String tbname,
                                                 java.lang.String colName,
                                                 java.lang.String maxtype,
                                                 java.lang.String metaDefaultValue,
                                                 java.lang.String domainid,
                                                 java.lang.String sequenceName,
                                                 int uidRule,
                                                 int seqRule,
                                                 int autoRule,
                                                 int mboRule,
                                                 int appRule,
                                                 boolean outputQuotes,
                                                 boolean assignIfNoMeta)
                                          throws java.lang.Exception
        This method is the central respository for database utilities (other than upgrade and Mbo framework) to get an attribute's default value. It does not handle expressions.
        Parameters:
        tbname - Table name
        colName - Column name
        maxtype - Value of maxattribute(cfg) maxtype.
        metaDefaultValue - Value of maxattribute(cfg) defaultvalue.
        domainid - Value of maxattribute(cfg) domainid.
        sequenceName - Sequence name. If null, method will try to select from maxsequence.
        uidRule - For &UNIQUEID& -- 1 = skip , 2 = 0, 3 = nextval
        seqRule - For &SEQUENCE& -- 1 = skip , 2 = 0, 3 = nextval.
        autoRule - For &AUTOKEY& -- 1 = skip , 2 = 0
        mboRule - For &OWNER& and &MBONAME& -- 1 = skip , 2 = "MBO"
        appRule - For &APPNAME& -- 1 = skip , 2 = "STARTCNTR"
        outputQuotes - True will surround output string with single quotes, if alphanumeric datatype. Otherwise, no quotes are added.
        assignIfNoMeta - If true and metaDefaultValue is null, then numeric fields will default to 0 and date fields will default to sysdate. Otherwise no default will be assigned.
        Returns:
        Value to use in Sql statement for default value of this attribute. Will equal null if no default value could be determined.
        Throws:
        java.lang.Exception
      • isSpecialDefaultValue

        public boolean isSpecialDefaultValue(java.lang.String value)
                                      throws java.lang.Exception
        Identify whether the give value is one of the special reserved words for defaultvalue (e.g. &SYSDATE&).
        Parameters:
        value -
        Returns:
        True if value is a special reserved word.
        Throws:
        java.lang.Exception
      • getOracleConvertString

        public java.lang.String getOracleConvertString(java.lang.String oldNativeType,
                                                       java.lang.String newNativeType,
                                                       java.lang.String colName)
                                                throws java.lang.Exception
        If an Oracle function can convert the oldNativeType to the newNativeType, return the function.

        Also see implicitConversionSupported.

        Parameters:
        oldNativeType -
        newNativeType -
        colName -
        Returns:
        to_char(colName)
        Throws:
        java.lang.Exception
      • getSqlServerConvertString

        public java.lang.String getSqlServerConvertString(java.lang.String oldTbname,
                                                          java.lang.String newTbname,
                                                          java.util.HashMap newColInfo)
                                                   throws java.lang.Exception
        Return SqlServer sql for "convert" from datatype for a specified column.

        Also see implicitConversionSupported and explicitConversionSupported.

        Parameters:
        oldTbname - Old table name we are copying data from. This table must exist.
        newTbname - New table name we are copying data to. This table must exist.
        newColInfo - Metadata for the column on the new table
        Returns:
        "convert" statement
        Throws:
        java.lang.Exception
      • getDB2ConvertString

        public java.lang.String getDB2ConvertString(java.lang.String oldNativeType,
                                                    java.lang.String newNativeType,
                                                    java.lang.String colName)
                                             throws java.lang.Exception
        If a DB2 function can convert the oldNativeType to the newNativeType, return the function.

        Also see implicitConversionSupported and explicitConversionSupported.

        Parameters:
        oldNativeType -
        newNativeType -
        colName -
        Returns:
        to_char(colName)
        Throws:
        java.lang.Exception
      • nativeTypesAreCompatible

        public boolean nativeTypesAreCompatible(java.lang.String oldNativeType,
                                                java.lang.String newNativeType)
                                         throws java.lang.Exception
        Identifies whether data can be copied from old table to new table without any conversion activity.
        Parameters:
        oldNativeType - Old native datatype
        newNativeType - New native datatype
        Returns:
        True if data can be copied, else False
        Throws:
        java.lang.Exception
      • buildInsertStatementPrefix

        public java.lang.String buildInsertStatementPrefix(java.lang.String tbname,
                                                           java.util.TreeMap tableCols,
                                                           boolean doRowstamp,
                                                           boolean includeDroppedCols,
                                                           java.lang.String colNameList,
                                                           boolean doLineBreaks)
                                                    throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • buildInsertStatementPrefix

        public java.lang.String buildInsertStatementPrefix(java.lang.String tbname,
                                                           java.util.TreeMap tableCols,
                                                           boolean doRowstamp,
                                                           boolean includeDroppedCols,
                                                           java.lang.String colNameList,
                                                           boolean doLineBreaks,
                                                           boolean addTenantid)
                                                    throws java.sql.SQLException
        Builds the beginning of an insert statement in the format "insert into tbname (col1, col2, col3, ...)".

        This can be used with buildSelectStatement, buildConvertSelectStatement, buildInsertValuesStatement, etc. to create a complete Insert statement.

        Parameters:
        tbname - Table name (must be persistent).
        tableCols - Column info, see getAttributeMeta.
        doRowstamp - True to include the rowstamp in the statement.
        includeDroppedCols - True to include columns whose "changed" attribute equals "R", else False to exclude them.
        colNameList - Can be null. If this parameter is not null, it should be a comma-delimited list of column names, and a column name will be included in the output string only if it exists in both the tableCols TreeMap and in the colNameList. If this parameter is null then this comparison is not performed. For building this list, see getColumnNames and getColumnNamesNative.
        doLineBreaks - If true, a line break will be inserted after every 5 column names.
        Returns:
        Sql statement for beginning of an insert
        Throws:
        java.sql.SQLException
      • buildInsertValuesStatement

        public java.util.TreeMap buildInsertValuesStatement(java.lang.String prefix,
                                                            java.sql.ResultSet rs,
                                                            java.util.TreeMap tableCols,
                                                            boolean includeDroppedCols,
                                                            java.lang.String rowstampValue,
                                                            boolean psFormat)
                                                     throws java.sql.SQLException
        Build one complete insert statement in the format "insert into tbname (col1, col2, col3, ...) values (val1, val2, val3,...)". Uses the current row from the result set. To dump the entire table, you need to code a loop through the result set, calling this method for each row.

        For an example of how this can be used, see writeDumpTable.

        Any encrypted datatypes (such as password) will be set to a foobar value, as encrypted data cannot be output to a print file.

        Parameters:
        prefix - "insert into" part of the statement, see buildInsertStatementPrefix.
        rs - ResultSet, where you have already called "next" to get a row. It is presumed that the Select statement specified the column names in the same sequence as tableCols. See buildSelectStatement.
        tableCols - Column info, see getAttributeMeta. These must be in the same sequence as the columns listed in the prefix, presumed to be in sequence by attributeno.
        includeDroppedCols - True to include columns whose "changed" attribute equals "R", else False to exclude them.
        rowstampValue - String to specify in the statement for rowstamp value (for example, maxseq.nextval or '12345'). If no rowstamp should be included, this should be null.
        psFormat - If true, output will support use of PreparedStatement in Maxinst. If false, output will be normal string format for use in a Sql statement.
        Returns:
        Sql insert statement(s). Normally, the TreeMap will contain only one statement. However, if the data contained a Clob or string datatype longer than 2000 and this is Oracle or DB2, there will be one insert statement followed by one or more update statements until the entire Clob has been filled.
        Throws:
        java.sql.SQLException
        See Also:
        Util.useQuotes(java.lang.String), Util.singleToDoubleQuotes(java.lang.String), Util.getChunkUpdates(java.lang.String, int, java.lang.String, java.lang.String, java.sql.ResultSet, java.lang.Object)
      • buildInsertValuesStatement

        public java.util.TreeMap buildInsertValuesStatement(java.lang.String prefix,
                                                            java.sql.ResultSet rs,
                                                            java.util.TreeMap tableCols,
                                                            boolean includeDroppedCols,
                                                            java.lang.String rowstampValue,
                                                            boolean psFormat,
                                                            java.util.Map allSeq)
                                                     throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • buildInsertValuesStatement

        public java.util.TreeMap buildInsertValuesStatement(java.lang.String prefix,
                                                            java.sql.ResultSet rs,
                                                            java.util.TreeMap tableCols,
                                                            boolean includeDroppedCols,
                                                            java.lang.String rowstampValue,
                                                            boolean psFormat,
                                                            java.util.Map allSeq,
                                                            int tenantid)
                                                     throws java.sql.SQLException
        Build one complete insert statement in the format "insert into tbname (col1, col2, col3, ...) values (val1, val2, val3,...)". Uses the current row from the result set. To dump the entire table, you need to code a loop through the result set, calling this method for each row.

        For an example of how this can be used, see writeDumpTable.

        Any encrypted datatypes (such as password) will be set to a foobar value, as encrypted data cannot be output to a print file.

        Parameters:
        prefix - "insert into" part of the statement, see buildInsertStatementPrefix.
        rs - ResultSet, where you have already called "next" to get a row. It is presumed that the Select statement specified the column names in the same sequence as tableCols. See buildSelectStatement.
        tableCols - Column info, see getAttributeMeta. These must be in the same sequence as the columns listed in the prefix, presumed to be in sequence by attributeno.
        includeDroppedCols - True to include columns whose "changed" attribute equals "R", else False to exclude them.
        rowstampValue - String to specify in the statement for rowstamp value (for example, maxseq.nextval or '12345'). If no rowstamp should be included, this should be null.
        psFormat - If true, output will support use of PreparedStatement in Maxinst. If false, output will be normal string format for use in a Sql statement.
        Returns:
        Sql insert statement(s). Normally, the TreeMap will contain only one statement. However, if the data contained a Clob or string datatype longer than 2000 and this is Oracle or DB2, there will be one insert statement followed by one or more update statements until the entire Clob has been filled.
        Throws:
        java.sql.SQLException
        See Also:
        Util.useQuotes(java.lang.String), Util.singleToDoubleQuotes(java.lang.String), Util.getChunkUpdates(java.lang.String, int, java.lang.String, java.lang.String, java.sql.ResultSet, java.lang.Object)
      • getKeyColumns

        public java.util.TreeMap getKeyColumns(java.util.TreeMap indexMeta,
                                               java.util.TreeMap tableCols,
                                               java.lang.String indexToSkip)
                                        throws java.lang.Exception
        Determine the columns in a table's primary key. If indexMeta is input, this method searches for a unique index. If indexMeta is not input or a unique index is not found, this method uses primarykeycolseq from tableCols. If the table contains more than one unique index, this method uses the first one found.
        Parameters:
        indexMeta - The indexes on this table. Can be null, if tableCols is provided.
        tableCols - The columns on this table. Can be null, if indexMeta is provided.
        indexToSkip - Normally this param should be null. If this is non-null, then the index named by this param will NOT be included in the output, unless no other unique indexes are found, and the param index is identified by primarykeycolseq, and tableCols param was provided. This param can be used when the table has more than one unique index, and you do not want one of them (for example, if it's the index for uniquecolumnname). You can find the index to be skipped by calling nativeIndexExistsForColumns.
        Returns:
        TreeMap of the columns in the unique index, where key = sequence and value = column name.
        Throws:
        java.lang.Exception
      • getColumnNames

        public java.lang.String getColumnNames(java.util.TreeMap tableCols,
                                               boolean doLineBreaks,
                                               boolean includeDroppedCols,
                                               java.lang.String colNameList,
                                               boolean useAlias)
        For a table, output the persistent column names (lower case) delimited by commas. The columns are retrieved from the metadata supplied in the tableCols parameter. This is useful for building various kinds of Sql statements. It is also useful for building the colNameList parameter in buildDefaultDataStatement, buildSelectStatement, buildInsertStatementPrefix, and for this very method.

        This method will NOT output columns that are "handle" columns used for DB2 text search. These columns must be created via db2ts (see enableRichTextSearch).

        Parameters:
        tableCols - Column attributes, see getAttributeMeta.
        doLineBreaks - If true, a line break will be inserted after every 5 column names.
        includeDroppedCols - True to include columns whose "changed" attribute equals "R", else False to exclude them.
        colNameList - Can be null. If this parameter is not null, it should be a comma-delimited list of column names, and a column name will be included in the output string only if it exists in both the tableCols TreeMap and in the colNameList. If this parameter is null then this comparison is not performed. For building this list, see getColumnNames and getColumnNamesNative.
        useAlias - If True, use the alias name (colalias). If False, use the regular column name.
        Returns:
        Comma-delimited list of lower-case column names.
        See Also:
        Util.isHandleColumn(java.lang.String, java.util.TreeMap)
      • processTemplateData

        public void processTemplateData(int toTenantid,
                                        boolean delete,
                                        java.lang.String maxUserGroup,
                                        java.lang.String allUserGroup,
                                        java.lang.String newUserGroup,
                                        java.io.PrintStream out)
                                 throws java.lang.Exception
        Copy all template data (STORAGETYPE = 3) from template (TENANTID = 0) to a tenant
        Parameters:
        tenantid - tenant Id
        Throws:
        java.lang.Exception
      • copyData

        public void copyData(java.lang.String tabName,
                             java.lang.String uniqueColumn,
                             int toTenantid,
                             int storageType,
                             boolean delete,
                             java.io.PrintStream out)
                      throws java.lang.Exception
        Copy all template data for a table from template (TENANTID = 0) to a tenant
        Parameters:
        tenantid - tenant Id
        tabName - Table Name
        Throws:
        java.lang.Exception
      • updateGroupName

        public void updateGroupName(java.lang.String tabName,
                                    java.lang.String maxUserGroup,
                                    java.lang.String allUserGroup,
                                    java.lang.String newUserGroup,
                                    int toTenantid)
                             throws java.lang.Exception
        Copy all template data for a table from template (TENANTID = 0) to a tenant
        Parameters:
        tenantid - tenant Id
        tabName - Table Name
        Throws:
        java.lang.Exception
      • getColumnNamesNative

        public java.lang.String getColumnNamesNative(java.lang.String tbname)
                                              throws java.sql.SQLException
        Get comma-delimited list of lowercase column names from the native metadata for the specified table. To get column names via Maximo metadata, call getColumnNames.
        Parameters:
        tbname - Table name
        Returns:
        Comma-delimited list of lower-case column names.
        Throws:
        java.sql.SQLException
      • getColumnInfo

        public java.util.HashMap getColumnInfo(java.util.TreeMap tableCols,
                                               java.lang.String name)
        Given a TreeMap of columns in a table that is keyed by attribute number (attributeno), find the HashMap for the specified column name and return it.
        Parameters:
        tableCols - The columns on this table, keyed by attributeno. It will also work if sorted by columnname, but in that scenario it would not be necessary to use this method, as you could simply retrieve the entry using the key.
        name - The column name to search for.
        Returns:
        The HashMap for the column. If not found, this will be null.
      • getAddRowstampSql

        public java.lang.String getAddRowstampSql(java.lang.String tbname)
                                           throws java.lang.Exception
        Return the "alter table" statement for adding the rowstamp column.
        Parameters:
        tbname - Table name
        Returns:
        Alter table sql
        Throws:
        java.lang.Exception
      • getRowstampTriggerSql

        public java.util.ArrayList getRowstampTriggerSql(java.lang.String tbname,
                                                         boolean dropIfExists)
                                                  throws java.lang.Exception
        Return the "create or replace trigger" statement(s) for populating the rowstamp column. (If this is SqlServer, returns an empty string.)

        For Oracle, the trigger name is tbname + "_T". For DB2, the trigger names are tbname + "_T" and tbname + "_U".

        Parameters:
        tbname - Table name
        dropIfExists - If this is DB2 and this param is True, then if the trigger exists, a "drop trigger" will be included in the output before the create. Otherwise, the output does not include a "drop trigger" statement.
        Returns:
        Trigger sql.
        Throws:
        java.lang.Exception
      • getRowstampTriggerSql

        public java.util.ArrayList getRowstampTriggerSql(java.lang.String tbname,
                                                         boolean dropIfExists,
                                                         boolean makeSecure)
                                                  throws java.lang.Exception
        Return the "create or replace trigger" statement(s) for populating the rowstamp column. (If this is SqlServer, returns an empty string.)

        For Oracle, the trigger name is tbname + "_T". For DB2, the trigger names are tbname + "_T" and tbname + "_U".

        Parameters:
        tbname - Table name
        dropIfExists - If this is DB2 and this param is True, then if the trigger exists, a "drop trigger" will be included in the output before the create. Otherwise, the output does not include a "drop trigger" statement.
        Returns:
        Trigger sql.
        Throws:
        java.lang.Exception
      • getTrigRoot

        public java.lang.String getTrigRoot(java.lang.String tbname)
                                     throws java.lang.Exception
        Gets the trigger name root for the table. If there's room the trigger root will end with an underscore.
        Parameters:
        tbname - The name of the table.
        Returns:
        The Trigger Name Root
        Throws:
        java.lang.Exception
      • hasGrants

        public boolean hasGrants()
                          throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • buildGrants

        public java.util.ArrayList buildGrants(java.lang.String tbname,
                                               boolean outputSchema,
                                               boolean maxusersOnly)
                                        throws java.lang.Exception
        Create an array where each element is a "grant" statement. The output specifies the grants that already exist. This is used when you anticipate having to rebuild the grants.
        Parameters:
        tbname - Table name
        outputSchema - True if the schema owner should be specified in the output Sql. False to omit the schema owner.
        maxusersOnly - True to include only those native users who are also Maximo users. False to include all native users, whether or not authorized for Maximo.
        Returns:
        Array of grant statements.
        Throws:
        java.lang.Exception
      • getGrants

        public java.util.HashMap getGrants(java.lang.String username,
                                           java.lang.String entityname)
                                    throws java.lang.Exception
        Determine what objects the user has read, insert, update, or delete access to.
        Parameters:
        username - User Name on native database (databaseuserid).
        entityname - Table or view name, if only one is to be queried. If this is null then all maximo entities will be queried.
        Returns:
        HashMap where key = table or view name, element = int[] where [0] = Read access, [1] = Insert access, [2] = Update access, [3] = Delete access. (1 = granted, 0 = not granted.) If the user has no access to the table or view, there will not be an entry in the HashMap.
        Throws:
        java.lang.Exception
      • getGrantSql

        public java.lang.String getGrantSql(java.lang.String dbUserID,
                                            java.lang.String entityname,
                                            java.lang.String privilege,
                                            boolean grant)
                                     throws java.lang.Exception
        Grant or revoke native database access for a given user and table/view.
        Parameters:
        dbUserID - User Name on the native database (databaseuserid).
        entityname - Table or view name.
        privilege - READ, INSERT, UPDATE, or DELETE
        grant - True to grant, False to revoke
        Throws:
        java.lang.Exception
      • getTriggerNames

        public java.util.ArrayList getTriggerNames(java.lang.String tbname,
                                                   boolean getEnabled,
                                                   boolean getDisabled,
                                                   boolean includeRowstamp)
                                            throws java.lang.Exception
        Get the names of triggers that satisfy the specified parameters. For DB2, will not include text search triggers.
        Parameters:
        tbname - Table name
        getEnabled - True to get enabled triggers, False to not get them.
        getDisabled - True to get disabled triggers, False to not get them.
        includeRowstamp - True to include the Maximo rowstamp trigger in the output (if it exists and satisfies the other parameters), else False. Does not pertain to SqlServer.
        Returns:
        Names of triggers for the specified parameters.
        Throws:
        java.lang.Exception
      • getEnableTriggerStatement

        public java.lang.String getEnableTriggerStatement(java.lang.String triggerName,
                                                          java.lang.String tbname)
                                                   throws java.lang.Exception
        Return a "enable trigger" statement for the specified trigger.
        Parameters:
        triggerName - The name of the trigger to be enabled.
        tbname - The table name for this trigger. This is required only for SqlServer.
        Returns:
        Enable trigger statement.
        Throws:
        java.lang.Exception
      • getDisableTriggerStatement

        public java.lang.String getDisableTriggerStatement(java.lang.String triggerName,
                                                           java.lang.String tbname)
                                                    throws java.lang.Exception
        Return a "disable trigger" statement for the specified trigger.
        Parameters:
        triggerName - The name of the trigger to be disabled.
        tbname - The table name for this trigger. This is required only for SqlServer.
        Returns:
        Disable trigger statement.
        Throws:
        java.lang.Exception
      • getEnableDisableTriggersAll

        public java.lang.String getEnableDisableTriggersAll(java.lang.String tbname,
                                                            boolean enable)
                                                     throws java.lang.Exception
        Return the Sql command for enabling or disabling all triggers on a specified table.
        Parameters:
        tbname - Table name
        enable - True for enable all triggers, False for disable all triggers.
        Returns:
        Sql for enabling or disabling triggers.
        Throws:
        java.lang.Exception
      • changeAmountFormat

        public java.util.ArrayList changeAmountFormat(int newLength,
                                                      int newScale)
                                               throws java.lang.Exception
        Change the format for Amount fields. This does NOT update maxvars (which should be done by AmountFormat object). This method returns Sql for doing the following:
        1. Update maxattributecfg with the new length and scale for columns whose maxtype is AMOUNT.
        2. Update maxattributecfg and maxtablecfg "changed" attribute so these changes will be processed by ConfigDB. The database needs to be configured for the new length and scale to take effect.
        Parameters:
        newLength - New length for amount fields (value for maxvar AMTLENGTH).
        newScale - New scale for amount fields (value for maxvar AMTSCALE).
        Returns:
        Sql statements
        Throws:
        java.lang.Exception
      • isRichTextSupported

        public boolean isRichTextSupported(java.lang.String tbname,
                                           java.lang.String name)
                                    throws java.lang.Exception
        This method identifies whether rich text functionality is supported in this database. If it is supported, then the user can use the DB Config utility to identify which columns should support rich text searching.

        Depending on the input parameters, this method will check for the following:

        1. If tbname and name are both null, this method will determine whether the database has been enabled for rich text searching.
        2. If tbname is non-null and name is null, this method will determine whether the database and the specified table have been enabled for rich text searching.
        3. If tbname and name are both non-null, this method will determine whether the database, table, and column have been enabled for rich text searching.

        Oracle databases always support rich text, thus check #1 above will always return True for Oracle.

        Parameters:
        tbname - Table name (optional). See above for usage.
        name - Column name (optional). See above for usage.
        Returns:
        True if the database, table, and/or column supports rich text searching, else false.
        Throws:
        java.lang.Exception
      • isHandleColumn

        public boolean isHandleColumn(java.lang.String colName,
                                      java.util.TreeMap attrs)
        Determines whether the specified column is a "handle column" for text search, based on our metadata. The concept of the "handle column" pertains only to DB2, but this method will search regardless of the DB platform.
        Parameters:
        colName - The coumn name to search for
        attrs - All the columns on the table ("$MAXATTRIBUTES").
        Returns:
        True if a handle column, else False.
      • enableRichTextSearch

        public java.util.ArrayList enableRichTextSearch(java.util.HashMap objInfo,
                                                        java.util.TreeMap tbIndexes,
                                                        boolean doCheck,
                                                        boolean skipDb2Connect)
                                                 throws java.lang.Exception
        Enable rich text search for a table and any attributes that are flagged for it. This method is used by Unlcvt, and will output the Sql even if rich text is already supported by this table or its columns.
        Parameters:
        objInfo - Attributes for the object/table and its columns. See getObjectMeta.
        tbIndexes - Index metadata for this table. Can be null. Used for Oracle to get the index name for a text-enabled column. If this is not provided, we will create an index.
        doCheck - Input to activateRichTextSearch.
        skipDb2Connect - Do not print "db2ts connect" and "db2ts quit" statements. This param is true only for Unlcvt when outputting in DB2 format.
        Returns:
        Sql statements
        Throws:
        java.lang.Exception
        See Also:
        Util.enableRichTextSearch(String, String, String, HashMap, boolean), Util.activateRichTextSearch(java.util.ArrayList, java.lang.String, boolean)
      • enableRichTextSearch

        public java.util.ArrayList enableRichTextSearch(java.lang.String tbname,
                                                        java.lang.String colName,
                                                        java.lang.String handleColName,
                                                        java.util.HashMap ixInfo,
                                                        boolean skipCreateUniqueIndex,
                                                        int startIxNum)
                                                 throws java.lang.Exception
        Call other version of this method with skipDb2Connect param false.
        Throws:
        java.lang.Exception
        See Also:
        Util.enableRichTextSearch(String, String, String, HashMap, boolean, int, boolean)
      • getDB2TextIndexSpace

        public java.lang.String getDB2TextIndexSpace()
        Get the index space for DB2 text search indexes.
      • enableRichTextSearch

        public java.util.ArrayList enableRichTextSearch(java.lang.String tbname,
                                                        java.lang.String colName,
                                                        java.lang.String handleColName,
                                                        java.util.HashMap ixInfo,
                                                        boolean skipCreateUniqueIndex,
                                                        int startIxNum,
                                                        boolean skipDb2Connect)
                                                 throws java.lang.Exception
        Return the Sql statements needed to enable rich text searching for a given table or column.

        This assumes that rich text searching is already enabled for the database as a whole (where needed). See comments printed at the header of the Unlcvt output for how to enable the database for text search. Enabling the database need be done only once.

        For DB2, after you are done running this method for one or more tables, you should then call db2textAlterIndexes.

        Parameters:
        tbname - Table name
        colName - Column name
        handleColName - Handle column name (used only for DB2)
        ixInfo - Index info, used for index name and storage clause in Oracle. Can be null, in which case we will assign a new index name and omit the storage clause.
        skipCreateUniqueIndex - True if the calling method is looping and an earlier iteration of this method has already issued a "create unique index" statement. This will prevent later iterations of this method from issuing a duplicate statement.
        startIxNum - The index number to start when getting a new index name from getNewIndexName.
        skipDb2Connect - Do not print "db2ts connect" and "db2ts quit" statements. This param is true only for Unlcvt when outputting in DB2 format.
        Returns:
        Sql statements
        Throws:
        java.lang.Exception
        See Also:
        Util.isRichTextSupported(java.lang.String, java.lang.String), #getRichTextCreateIndexStatement, Util.getNextSequenceValueForSqlServer(java.lang.String)
      • isRTSupportedForDB

        public boolean isRTSupportedForDB()
                                   throws java.lang.Exception
        Is Text Search supported for this database platform and Maximo parameters? Same as isRichTextSupported(null, null) but optimized for performance.
        Throws:
        java.lang.Exception
      • revalidateTextSearchIndexes

        public java.util.ArrayList revalidateTextSearchIndexes(java.lang.String tbname)
                                                        throws java.lang.Exception
        Get statements for revalidating text search indexes (DB2).
        Parameters:
        tbname -
        Returns:
        Sql statements
        Throws:
        java.lang.Exception
      • isReorgPending

        public boolean isReorgPending(java.lang.String tbname)
                               throws java.lang.Exception
        Specifies whether reorg is pending for this table (DB2 only).
        Parameters:
        tbname -
        Returns:
        True if reorg is pending and this is DB2 platform.
        Throws:
        java.lang.Exception
      • db2textAlterIndexes

        public java.util.ArrayList db2textAlterIndexes()
                                                throws java.lang.Exception
        Throws:
        java.lang.Exception
        See Also:
        Util.db2textAlterIndexes(boolean)
      • db2textAlterIndexes

        public java.util.ArrayList db2textAlterIndexes(boolean updateNow)
                                                throws java.lang.Exception
        For DB2, read through the vector of index names populated by enableRichTextSearch and return array of "db2ts alter index" statements specifying Update Frequency.
        Parameters:
        updateNow - True when called from Maxinst and we need to do an initial update.
        Returns:
        Array of "db2ts alter index" statements specifying Update Frequency.
        Throws:
        java.lang.Exception
      • activateRichTextSearch

        public java.util.ArrayList activateRichTextSearch(java.util.ArrayList list,
                                                          java.lang.String tbname,
                                                          boolean doCheck)
                                                   throws java.lang.Exception
        Activate text search for a specified table. This will append Sql to the list only for SqlServer.
        Parameters:
        list - The ArrayList to be appended to
        tbname - The table name
        doCheck - Indicates whether to include statements to start change tracking and start background updates, based on whether they are already in effect. If this param is False then these statements are always included. If this param is True then we check first before including them.
        Throws:
        java.lang.Exception
      • disableRichTextSearch

        public java.util.ArrayList disableRichTextSearch(java.lang.String tbname,
                                                         java.lang.String colName,
                                                         java.lang.String handleColName)
                                                  throws java.lang.Exception
        Return the Sql statements needed to disable rich text searching for a given column.
        Parameters:
        tbname - Table name
        colName - Column name
        handleColName - Handle column name (used only for DB2)
        Returns:
        Sql statements. If rich text search is not currently supported for this column, this list will be empty.
        Throws:
        java.lang.Exception
        See Also:
        Util.isRichTextSupported(java.lang.String, java.lang.String)
      • getTextSearchIndexForColumn

        public java.util.HashMap getTextSearchIndexForColumn(java.lang.String tbname,
                                                             java.lang.String colName,
                                                             java.util.TreeMap tbIndexes)
                                                      throws java.lang.Exception
        Get the index metadata for the text search index for the specified table and column. This is used to support enabling text search for Oracle, where we will need to specify an index name.
        Parameters:
        tbname - Table name
        colName - Column name
        tbIndexes - Index metadata for this table. If null, this method will retrieve from database.
        Returns:
        HashMap of index metadata for the text-search index for this column (if found).
        Throws:
        java.lang.Exception
      • getRenameTableStatement

        public java.lang.String getRenameTableStatement(java.lang.String oldTbname,
                                                        java.lang.String newTbname)
                                                 throws java.lang.Exception
        Return a "rename table" statement for the specified table. If this is DB2, you must separately disable text search for the table before renaming it.
        Parameters:
        oldTbname - The original table name.
        newTbname - The new table name.
        Returns:
        Sql statement
        Throws:
        java.lang.Exception
      • getDropStatisticsStatementsForConfig

        public java.util.ArrayList getDropStatisticsStatementsForConfig(java.lang.String entityname)
                                                                 throws java.lang.Exception
        Get the "drop statistics" statements for all columns that are pending ConfigDB. This is used only for SqlServer.
        Parameters:
        entityname - If entityname is specified, drop statements will be retrieved only for that entity. Otherwise they will get retrieved for all entities/columns with pending changes. Statistics for column that are not pending configuration will not be affected (unless they also pertain to an affected column).
        Throws:
        java.lang.Exception
        See Also:
        Util.getDropStatisticsStatements(java.lang.String, java.lang.String)
      • getDropStatisticsStatements

        public java.util.ArrayList getDropStatisticsStatements(java.lang.String tbname,
                                                               java.lang.String colname)
                                                        throws java.lang.Exception
        Return "drop statistics" statement(s) for SqlServer platform only.
        Parameters:
        tbname - The table name for which to drop statistics. This cannot be null.
        colname - The column name for which to drop statistics. If null, will drop statistics pertaining to all columns on the specified table.
        Returns:
        Sql statements
        Throws:
        java.lang.Exception
      • canAnalyzeTable

        public boolean canAnalyzeTable()
                                throws java.lang.Exception
        Identifies whether getAnalyzeTableStatement would normally return anything. This is used when determining whether the corresponding menu option in the Config UI should be enabled (optionname ANALYZE, Update Table Statistics).
        Returns:
        True if getAnalyzeTableStatement is applicable to this db platform, else False. Currently, this is supported only for Oracle.
        Throws:
        java.lang.Exception
      • getAnalyzeTableStatement

        public java.util.ArrayList getAnalyzeTableStatement(java.lang.String tbname)
                                                     throws java.lang.Exception
        Output "analyze table compute statistics" statement(s) for Oracle. Running these statements helps to optimize the cost-based Optimizer. The corresponding menu option in the Config UI is optionname ANALYZE (Update Table Statistics).
        Parameters:
        tbname - Table name (optional). If not provided, this outputs a statement for each persistent Maximo table. Otherwise, analyzes only the specified table.
        Returns:
        Sql statement for analyzing table(s). If this is not Oracle, this will be empty.
        Throws:
        java.lang.Exception
      • getDisallowPageLocks

        public java.util.ArrayList getDisallowPageLocks()
                                                 throws java.lang.Exception
        Return the Sql statements to disallow page locks for the indexes on Maximo tables that are not already disallowed. This pertains only to SqlServer. This method gets the index names from the native system tables.
        Returns:
        Sql statements (sp_indexoption). If not SqlServer, this will be empty.
        Throws:
        java.lang.Exception
      • lockMaximoTables

        public boolean lockMaximoTables(java.lang.String tbname,
                                        boolean lock)
                                 throws java.lang.Exception
        Deprecated. The logic for SqlServer is not working consistently. This method may be removed.
        Lock or Unlock tables in Exclusive mode. This actually executes the lock or unlock (rather than merely returning the Sql statement).

        Oracle and DB2 tables remain locked until a Commit or Rollback. Thus, if the program does interim commits, you may have to re-lock for Oracle. SqlServer tables remain locked until the lock is explicitly released or the session is terminated.

        The method mxServerIsUp can be used to determine whether MXServer is up.

        Parameters:
        tbname - The table name (optional). If provided, lock/unlock only the specified table, else do all persistent Maximo tables.
        lock - True to lock, False to unlock. (False is not allowed for Oracle or DB2. To release locks for these platforms, issue a Commit or Rollback.)
        Returns:
        True if successful, False if not successful. Also return False if Oracle or DB2 and the lock parameter is False.
        Throws:
        java.lang.Exception
      • isObjectLocked

        public boolean isObjectLocked(java.lang.String entityname)
                               throws java.lang.Exception
        Identifies whether an object has been locked in the native database.
        Returns:
        True if object is locked, else false
        Throws:
        java.lang.Exception
      • isReservedWord

        public boolean isReservedWord(java.lang.String testWord)
                               throws java.lang.Exception
        Identifies whether the testWord is a reserved word on the native database.
        Parameters:
        testWord - The word to be tested
        Returns:
        True if testWord is reserved, else false
        Throws:
        java.lang.Exception
      • getAttributeRefresh

        public java.util.ArrayList getAttributeRefresh()
                                                throws java.lang.Exception
        Return "insert into maxattribute (col1, col2, ...) select col1, col2, ... from maxattributecfg". Do the same for the language table l_maxattribute.
        Throws:
        java.lang.Exception
      • getAttributeRefresh

        public java.util.ArrayList getAttributeRefresh(int tenantId,
                                                       boolean mtEnabled,
                                                       java.lang.String objectName)
                                                throws java.lang.Exception
        Return "insert into maxattribute (col1, col2, ...) select col1, col2, ... from maxattributecfg". Do the same for the language table l_maxattribute.
        Throws:
        java.lang.Exception
      • getAttributeCfgRefresh

        public java.util.ArrayList getAttributeCfgRefresh()
                                                   throws java.lang.Exception
        Return "insert into maxattributecfg (col1, col2, ...) select col1, col2, ... from maxattribute". Sets "changed" = "N". This is used when removing configuration changes that have not yet been applied. Do the same for the langauge table l_maxattrcfg.
        Returns:
        Sql statements
        Throws:
        java.lang.Exception
      • getAttributeCfgRefresh

        public java.util.ArrayList getAttributeCfgRefresh(int tenantId,
                                                          boolean mtEnabled)
                                                   throws java.lang.Exception
        Return "insert into maxattributecfg (col1, col2, ...) select col1, col2, ... from maxattribute". Sets "changed" = "N". This is used when removing configuration changes that have not yet been applied. Do the same for the langauge table l_maxattrcfg.
        Returns:
        Sql statements
        Throws:
        java.lang.Exception
      • getViewColumnRefresh

        public java.lang.String getViewColumnRefresh()
                                              throws java.lang.Exception
        Return "insert into maxviewcolumn (col1, col2, ...) select col1, col2, ... from maxviewcolumncfg".
        Throws:
        java.lang.Exception
      • getViewColumnRefresh

        public java.lang.String getViewColumnRefresh(int tenantId,
                                                     boolean mtEnabled)
                                              throws java.lang.Exception
        Return "insert into maxviewcolumn (col1, col2, ...) select col1, col2, ... from maxviewcolumncfg".
        Throws:
        java.lang.Exception
      • getViewColumnCfgRefresh

        public java.lang.String getViewColumnCfgRefresh()
                                                 throws java.lang.Exception
        Return "insert into maxviewcolumncfg (col1, col2, ...) select col1, col2, ... from maxviewcolumn". Sets "changed" = "N". This is used when removing configuration changes that have not yet been applied.
        Returns:
        Sql statement
        Throws:
        java.lang.Exception
      • getViewColumnCfgRefresh

        public java.lang.String getViewColumnCfgRefresh(int tenantId,
                                                        boolean mtEnabled)
                                                 throws java.lang.Exception
        Return "insert into maxviewcolumncfg (col1, col2, ...) select col1, col2, ... from maxviewcolumn". Sets "changed" = "N". This is used when removing configuration changes that have not yet been applied.
        Returns:
        Sql statement
        Throws:
        java.lang.Exception
      • getTableRefresh

        public java.lang.String getTableRefresh()
                                         throws java.lang.Exception
        Return "insert into maxtable (col1, col2, ...) select col1, col2, ... from maxtablecfg".
        Throws:
        java.lang.Exception
      • getTableRefresh

        public java.lang.String getTableRefresh(int tenantId,
                                                boolean mtEnabled,
                                                java.lang.String tableName)
                                         throws java.lang.Exception
        Return "insert into maxtable (col1, col2, ...) select col1, col2, ... from maxtablecfg".
        Throws:
        java.lang.Exception
      • getTableCfgRefresh

        public java.lang.String getTableCfgRefresh()
                                            throws java.lang.Exception
        Return "insert into maxtablecfg (col1, col2, ...) select col1, col2, ... from maxtable". This is used when removing configuration changes that have not yet been applied.
        Returns:
        Sql statement
        Throws:
        java.lang.Exception
      • getTableCfgRefresh

        public java.lang.String getTableCfgRefresh(int tenantId,
                                                   boolean mtEnabled)
                                            throws java.lang.Exception
        Return "insert into maxtablecfg (col1, col2, ...) select col1, col2, ... from maxtable". This is used when removing configuration changes that have not yet been applied.
        Returns:
        Sql statement
        Throws:
        java.lang.Exception
      • getViewRefresh

        public java.lang.String getViewRefresh()
                                        throws java.lang.Exception
        Return "insert into maxview (col1, col2, ...) select col1, col2, ... from maxviewcfg".
        Throws:
        java.lang.Exception
      • getViewRefresh

        public java.lang.String getViewRefresh(int tenantId,
                                               boolean mtEnabled)
                                        throws java.lang.Exception
        Return "insert into maxview (col1, col2, ...) select col1, col2, ... from maxviewcfg".
        Throws:
        java.lang.Exception
      • getViewCfgRefresh

        public java.lang.String getViewCfgRefresh()
                                           throws java.lang.Exception
        Return "insert into maxviewcfg (col1, col2, ...) select col1, col2, ... from maxview". This is used when removing configuration changes that have not yet been applied.
        Returns:
        Sql statement
        Throws:
        java.lang.Exception
      • getViewCfgRefresh

        public java.lang.String getViewCfgRefresh(int tenantId,
                                                  boolean mtEnabled)
                                           throws java.lang.Exception
        Return "insert into maxviewcfg (col1, col2, ...) select col1, col2, ... from maxview". This is used when removing configuration changes that have not yet been applied.
        Returns:
        Sql statement
        Throws:
        java.lang.Exception
      • deleteObjectDelta

        public java.util.ArrayList deleteObjectDelta(int tenantId)
                                              throws java.lang.Exception
        Return "delete from maxobjectcfg where exists". Do the same for the maxtable.
        Throws:
        java.lang.Exception
      • getObjectRefresh

        public java.util.ArrayList getObjectRefresh()
                                             throws java.lang.Exception
        Return "insert into maxobject (col1, col2, ...) select col1, col2, ... from maxobjectcfg". Do the same for the language table l_maxobject.
        Throws:
        java.lang.Exception
      • getObjectRefresh

        public java.util.ArrayList getObjectRefresh(int tenantId,
                                                    boolean mtEnabled,
                                                    java.lang.String objectName)
                                             throws java.lang.Exception
        Return "insert into maxobject (col1, col2, ...) select col1, col2, ... from maxobjectcfg". Do the same for the language table l_maxobject.
        Throws:
        java.lang.Exception
      • getObjectCfgRefresh

        public java.util.ArrayList getObjectCfgRefresh()
                                                throws java.lang.Exception
        Return "insert into maxobjectcfg (col1, col2, ...) select col1, col2, ... from maxobject". Sets "changed" = "N". This is used when removing configuration changes that have not yet been applied. Do the same for the language table l_maxobjectcfg.
        Returns:
        Sql statements
        Throws:
        java.lang.Exception
      • getObjectCfgRefresh

        public java.util.ArrayList getObjectCfgRefresh(int tenantId,
                                                       boolean mtEnabled)
                                                throws java.lang.Exception
        Return "insert into maxobjectcfg (col1, col2, ...) select col1, col2, ... from maxobject". Sets "changed" = "N". This is used when removing configuration changes that have not yet been applied. Do the same for the language table l_maxobjectcfg.
        Returns:
        Sql statements
        Throws:
        java.lang.Exception
      • getSysIndexRefresh

        public java.util.ArrayList getSysIndexRefresh(java.lang.String tbname,
                                                      java.lang.String ixname)
                                               throws java.lang.Exception
        Create an array of "insert into maxsysindexes" and "insert into maxsyskeys" statements based on the actual existing native indexes. This does NOT update primarykeycolseq in the column metadata (call adjustPrimaryKeyColSeq to do so).

        If this is Oracle, then immediately after executing the returned array, call fixMetadataForDescendingKeys and execute its returned array so that descending keys are accurately specified in Maximo metadata.

        Parameters:
        tbname - The table name (optional). If provided, the index metadata is rebuilt only for the specified table. If the tbname and ixname parameters are both null, the index metadata is rebuilt for ALL the persistent Maximo tables.
        ixname - The index name (optional). If provided, the index metadata is rebuilt only for the specified index.
        Returns:
        ArrayList of insert statements
        Throws:
        java.lang.Exception
        See Also:
        Util.descendingIndexesSupported(), Util.getNextSequenceValueForSqlServer(java.lang.String), Util.fixMetadataForDescendingKeys(java.lang.String, java.lang.String)
      • longIndexNamesExist

        public boolean longIndexNamesExist(java.lang.String tbname)
                                    throws java.lang.Exception
        Identified whether native indexes exist whose index name is longer than that allowed by Maximo. This can be executed prior to trying to refresh index metadata to see if an error would result.
        Parameters:
        tbname - Tablename (optional). Null to check all tables that are defined in maxtable.
        Returns:
        True if native indexes exist whose name is longer than we can insert into our Maximo metadata.
        Throws:
        java.lang.Exception
      • dupIndexNamesExist

        public boolean dupIndexNamesExist(java.lang.String tbname,
                                          java.lang.String ixname)
                                   throws java.lang.Exception
        Determine whether the same index name is used on more than one table on the native database. This pertains only to SqlServer (other platforms will always return False).
        Parameters:
        tbname - Table name if only one table name is to be checked. If null, all tables will be checked.
        ixname - Index name if only one index name is to be checked. If null, all index names will be checked.
        Returns:
        True if duplicate index names exist, else False.
        Throws:
        java.lang.Exception
      • descendingIndexesSupported

        public boolean descendingIndexesSupported()
                                           throws java.lang.Exception
        Identifies whether descending indexes are supported by this database platform. (They are not supported by Oracle 8i.) This method always returns True because all platforms supported by Merlin do support descending indexes.
        Returns:
        True if descending indexes are supported, else False
        Throws:
        java.lang.Exception
      • getPartitionRefresh

        public java.util.ArrayList getPartitionRefresh()
                                                throws java.lang.Exception
        Output the Sql statements needed to update dbstoragepartition on maxtable and maxtablecfg with the actual native partition name.
        Returns:
        ArrayList of update statements
        Throws:
        java.lang.Exception
      • getOracleVersion

        public int getOracleVersion()
                             throws java.lang.Exception
        If dbIn is Oracle, this method returns the first part of the database version (8, 9, etc.). For example, if the database version is 9.0.1.1.1, this method will return 9.
        Returns:
        The database version for Oracle; zero if not Oracle.
        Throws:
        java.lang.Exception
      • getOracleVersion

        public double getOracleVersion(boolean getPoint)
                                throws java.lang.Exception
        If dbIn is Oracle, this method returns the database version.
        Parameters:
        getPoint - If true, will return the first and second parts of the database version. For example, database version 10.2.0.1.0 will return 10.2 when this is True. If false, will return only the integer portion; for example, database version 10.2.0.1.0 will return 10 when this is False.
        Returns:
        The database version for Oracle; zero if not Oracle.
        Throws:
        java.lang.Exception
      • getDB2Version

        public int getDB2Version()
                          throws java.lang.Exception
        If dbIn is DB2, this method returns the first part of the database version (8, 9, etc.). For example, if the database version is 9.1, this method will return 9.
        Returns:
        The database version for DB2; zero if not DB2.
        Throws:
        java.lang.Exception
      • getDB2Version

        public double getDB2Version(boolean getPoint)
                             throws java.lang.Exception
        If dbIn is DB2, this method returns the database version.
        Parameters:
        getPoint - If true, will return the first and second parts of the database version. For example, database version 9.1. will return 9.1 when this is True. If false, will return only the integer portion; for example, database version 9.1 will return 9 when this is False.
        Returns:
        The database version for DB2; zero if not DB2.
        Throws:
        java.lang.Exception
      • getSqlServerVersion

        public int getSqlServerVersion()
                                throws java.lang.Exception
        If dbIn is SqlServer, this method returns the first part of the database version (8, 9, etc.). For example, if the database version is 9.00.3054.00, this method will return 9.

        For SqlServer 2000, version is 8, and for SqlServer 2005, version is 9. Also see getSqlServerCompatLevel.

        Returns:
        The database version for SqlServer; zero if not SqlServer.
        Throws:
        java.lang.Exception
      • getSqlServerVersion

        public double getSqlServerVersion(boolean getPoint)
                                   throws java.lang.Exception
        If dbIn is SqlServer, this method returns the database version. Also see getSqlServerCompatLevel.
        Parameters:
        getPoint - If true, will return the first and second parts of the database version. For example, if the database version is 9.02.3054.00, this method will return 9.02. If false, will return only the integer portion
        Returns:
        The database version for SqlServer; zero if not SqlServer.
        Throws:
        java.lang.Exception
      • getSqlServerCompatLevel

        public int getSqlServerCompatLevel()
                                    throws java.lang.Exception
        If dbIn is SqlServer, this method returns the database compatibility level. Also see getSqlServerVersion.
        Returns:
        The database compatibility level for SqlServer; zero if not SqlServer.
        Throws:
        java.lang.Exception
      • getUpdateStatistics

        public java.util.ArrayList getUpdateStatistics(java.util.TreeMap tableMap,
                                                       java.util.TreeMap indexMap)
                                                throws java.lang.Exception
        Generate "dbms_stats.gather_table_stats" (for Oracle) or "update statistics" (for SqlServer) statements for the specified tables/indexes; does not include an index if it is being dropped. The corresponding menu option in the Config UI is optionname STATISTICS (Update Index Statistics).

        Important note re: Oracle: To run these under jdbc, you need to create a CallableStatement and separately identify each parameter. Therefore, you cannot simply run these statements via Statement execute. See updateStatistics.

        Parameters:
        tableMap - TreeMap of object metata, for Oracle. (Null or empty for SqlServer.)
        indexMap - TreeMap of index metadata for SqlServer. (Null or empty for Oracle.)
        Returns:
        Series of "update statistics" statements
        Throws:
        java.lang.Exception
        See Also:
        Util.nativeIndexExists(java.lang.String, java.lang.String)
      • objAttrDelRefresh

        public java.util.ArrayList objAttrDelRefresh(int tenantid,
                                                     boolean mtEnabled)
      • attrRefresh

        public java.util.ArrayList attrRefresh(int tenantid,
                                               boolean mtEnabled)
                                        throws java.lang.Exception
        Refresh all the attribute metadata for all objects.
        1. Delete from maxattributecfg for the attributes that are being deleted.
        2. Renumber colno on maxattributecfg where needed.
        3. Delete all the current metadata in maxattribute.
        4. Insert new data in maxattribute, using the values from maxattributecfg.
        5. Update maxattributecfg to set changed = "N".

        upgradeCallout is called in the following place:

        • At the beginning of the method ("refreshAttributes", null, null)
        Parameters:
        tenantid -
        mtEnabled -
        Returns:
        Throws:
        java.lang.Exception
      • renumberAttributeNumber

        public java.util.ArrayList renumberAttributeNumber(java.lang.String objectname,
                                                           java.util.TreeMap attrs)
                                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • renumberExtAttributeNumber

        public java.util.ArrayList renumberExtAttributeNumber(java.lang.String objectname,
                                                              java.util.Map extTables,
                                                              int start,
                                                              java.util.ArrayList sqlList)
                                                       throws MXException
        Throws:
        MXException
      • getPrimaryKeys

        public java.util.TreeMap getPrimaryKeys(java.lang.String objname,
                                                boolean getCfg)
                                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • indexMetaExistsForPrikeycolseq

        public boolean indexMetaExistsForPrikeycolseq(java.lang.String objname,
                                                      java.lang.String tbname,
                                                      boolean getCfg)
                                               throws java.lang.Exception
        Determine whether index metadata exists for the primarykeycolseq for the specified table. This uses the values on maxattribute (or maxattributecfg), maxsysindexes and maxsyskeys.

        This method is used in ConfigDB when creating a new table so that when the index is specified by both primarykeycolseq and by the index metadata, the index is created only once, using the index metadata. (The metadata takes priority because it includes the index name.)

        Parameters:
        objname - Object name
        tbname - Table name
        getCfg - If true, gets column metadata from the configuration table (maxattributecfg), else gets from maxattribute.
        Returns:
        True if index metadata exists, else False. If the metadata does not have any attributes with non-null value for primarykeycolseq, this method will return True.
        Throws:
        java.lang.Exception
      • buildIndexStatement

        public java.lang.String buildIndexStatement(java.lang.String tbname,
                                                    java.util.TreeMap tableCols,
                                                    java.lang.String dbstoragepartition)
                                             throws java.lang.Exception
        Uses primarykeycolseq in metadata to build a "create unique index" statement. Normally this will be called only when building a new table. For SqlServer and DB2, this will be a clustered index.
        Parameters:
        tbname - Table name
        tableCols - TreeMap of columns for the specified table
        dbstoragepartition - The storage partition on which to create the index. If this is not provided, that clause will be omitted from the statement.
        Returns:
        Sql statement for creating native index.
        Throws:
        java.lang.Exception
      • buildIndexStatement

        public java.lang.String buildIndexStatement(java.util.HashMap ixInfo,
                                                    boolean specifySchema,
                                                    boolean specifyStorage)
                                             throws java.lang.Exception
        Construct a "create index" statement using index metadata. This may also contain a storage clause for Oracle (if provided in ixInfo).
        Parameters:
        ixInfo - Metadata from maxsysindexes and maxsyskeys, for one index. This can be derived from the TreeMap from getIndexMeta.
        specifySchema - True to specify the schema or tablespace, False to omit it. If True, this method will use the value identified in the HashMap ixInfo. If this is a SqlServer clustered index, the index's schema should equal the table's schema. This method does not verify whether the maxsysindexes value of storagepartition is valid.
        specifyStorage - True to include a storage clause. If True, the clause is retrieved from ixInfo "$STORAGECLAUSE".
        Returns:
        the "create index" statement
        Throws:
        java.lang.Exception
        See Also:
        Util.descendingIndexesSupported()
      • rebuildIndexes

        public java.util.ArrayList rebuildIndexes(java.util.TreeMap indexMeta,
                                                  boolean alwaysDrop,
                                                  boolean neverDrop,
                                                  boolean specifySchema,
                                                  boolean specifyStorage)
                                           throws java.lang.Exception
        Output sql to drop and recreate the indexes.
        Parameters:
        indexMeta - Index metadata, from getIndexMeta.
        alwaysDrop - True to always include the "drop index" statement, False to include it only if the native index exists.
        neverDrop - True to NEVER include the "drop index" statement.
        specifySchema - True to specify the schema or tablespace in the "create index" statement. False to omit it.
        specifyStorage - True to specify the storage clause, False to omit it.
        Returns:
        ArrayList of "drop index" and "create index" statements.
        Throws:
        java.lang.Exception
        See Also:
        Util.nativeIndexExists(java.lang.String, java.lang.String), Util.buildIndexStatement(HashMap, boolean, boolean)
      • buildSequences

        public java.util.ArrayList buildSequences(java.util.HashSet sequences,
                                                  boolean doMaxseq)
                                           throws java.lang.Exception
        Returns sql statements for dropping and recreating all the sequences for Oracle and DB2.
        Parameters:
        sequences - HashSet of sequences to be built. Entry is string array of sequenceName, tbName, columnName.
        doMaxseq - True to update the "maxseq" sequence (it will not be in the HashSet). False to do only what's specified in the HashSet.
        Returns:
        sql statements
        Throws:
        java.lang.Exception
        See Also:
        Util.getMaxEAuditTransID()
      • buildSequences

        public java.util.ArrayList buildSequences(java.util.HashSet sequences,
                                                  java.util.Map alreadyDone,
                                                  boolean doMaxseq)
                                           throws java.lang.Exception
        Returns sql statements for dropping and recreating all the sequences for Oracle and DB2.
        Parameters:
        sequences - HashSet of sequences to be built. Entry is string array of sequenceName, tbName, columnName.
        doMaxseq - True to update the "maxseq" sequence (it will not be in the HashSet). False to do only what's specified in the HashSet.
        Returns:
        sql statements
        Throws:
        java.lang.Exception
        See Also:
        Util.getMaxEAuditTransID()
      • updateMaxSequence

        public java.util.ArrayList updateMaxSequence(java.util.HashSet sequences)
                                              throws java.lang.Exception
        Returns sql statements for updating MaxSequence MaxReserved.
        Parameters:
        sequences - HastSet of sequences to be built. Entry is string array of sequenceName, tbName, columnName.
        Returns:
        sql statements
        Throws:
        java.lang.Exception
        See Also:
        Util.getMaxEAuditTransID()
      • updateMaxSequence

        public java.util.ArrayList updateMaxSequence(java.util.HashSet sequences,
                                                     java.util.Map lastNumbers)
                                              throws java.lang.Exception
        Returns sql statements for updating MaxSequence MaxReserved.
        Parameters:
        sequences - HastSet of sequences to be built. Entry is string array of sequenceName, tbName, columnName.
        lastNumbers - Map of number to be used as a start to build sequences.
        Returns:
        sql statements
        Throws:
        java.lang.Exception
        See Also:
        Util.getMaxEAuditTransID()
      • getNextSequenceNo

        public long getNextSequenceNo(java.lang.String sequenceName)
                               throws java.lang.Exception
        Get the next value for this sequence. Oracle and DB2 get from the native system. SqlServer gets from the maxsequence table.
        Parameters:
        sequenceName -
        Returns:
        The next sequence number to be assigned for the given sequence name. If not found then return 0;
        Throws:
        java.lang.Exception
        See Also:
        Util.nativeSequenceExists(java.lang.String)
      • getMetadataSequenceNames

        public java.util.HashSet getMetadataSequenceNames()
                                                   throws java.lang.Exception
        Get description of the sequences used on the metadata tables for objects, attributes, tables and views. This is a helper method for rebuildMetadataSequences, buildSequences, and updateMaxSequence.
        Returns:
        HashSet where each element is a String array containing sequence name, table name, column name.
        Throws:
        java.lang.Exception
      • getMaxEAuditTransID

        public int getMaxEAuditTransID()
                                throws java.lang.Exception
        Get the maximum value of "eaudittransid" from all of the eaudit tables. There can be multiple audit tables, but they all use the same sequence (EAUDITSEQ).
        Returns:
        Maximum value of eaudittransid from the eaudit tables
        Throws:
        java.lang.Exception
      • createOneSequenceFromMaxSequence

        public java.util.ArrayList createOneSequenceFromMaxSequence(java.lang.String sequenceName)
                                                             throws java.lang.Exception
        Returns sql statement for creating one sequence from values specified in maxsequence table. This assumes that the data in the maxsequence table is accurate, and will start the sequence with value of "maxreserved". If the native sequence already exists, this method does not output any sql.
        Parameters:
        sequenceName - The name of the sequence
        Returns:
        sql statement(s)
        Throws:
        java.lang.Exception
      • getUnrestoredTables

        public java.lang.String getUnrestoredTables(java.lang.String tbname)
                                             throws java.lang.Exception
        Return a Sql statement that checks for the existence of tables where maxtablecfg.restoredata = True. The statement selects the table name. If the Sql returns any rows, it is assumed that the tables were earlier modified via ConfigDB, and the original data was saved to a backup table named "XX" + tbname, but the data has not yet been copied to the new base table.

        It should be restored using RestoreFromBackup.

        The method getOldBackupTables checks for tables that have been restored, but whose backup tables have not been deleted.

        Parameters:
        tbname - Table name to check for (e.g. ITEM). Usually, this parameter will be null, and the Sql will get all table names that need to be restored. However, if a table name is specified in this parameter, the Sql will check for this table name only.
        Returns:
        Sql statement
        Throws:
        java.lang.Exception
        See Also:
        ConfigDB, RestoreFromBackup, DropBackup
      • getBackupTableName

        public java.lang.String getBackupTableName(java.lang.String tbname)
                                            throws java.lang.Exception
        Get the name of the backup table. This is normally "XX" + base table name, unless the total length would be excessive, in which case it is truncated.
        Parameters:
        tbname - Base table name
        Returns:
        Backup table name
        Throws:
        java.lang.Exception
      • getOldBackupTables

        public java.lang.String getOldBackupTables(java.lang.String tbname)
                                            throws java.lang.Exception
        Return a Sql statement that checks for the existence of old backup tables. The statement selects the table name of the base table (e.g. the first string in the ResultSet is ITEM if the backup table XXITEM exists). If the Sql returns any rows, it is assumed that the base tables were earlier modified via ConfigDB, and the original data was saved to a backup table and copied back to the new base table, but the old backup table named "XX" + tbname still exists on the database.

        It should be dropped using DropBackup.

        The method getUnrestoredTables checks for tables that need to be restored, but have not yet been restored.

        Parameters:
        tbname - Table name to check for (e.g. ITEM). Usually, this parameter will be null, and the Sql will get all table names that are old backup. However, if a table name is specified in this parameter, the Sql will check for this table name only.
        Returns:
        Sql statement
        Throws:
        java.lang.Exception
        See Also:
        ConfigDB, RestoreFromBackup, DropBackup
      • getSites

        public java.util.TreeMap getSites(boolean includeDisabled)
                                   throws java.lang.Exception
        Identify the sites on the database.
        Parameters:
        includeDisabled - If True, this will return all sites, whether disabled or not. If False, this will get only "live" sites.
        Returns:
        TreeMap where key = siteid, value = orgid + "|" + String value of "active".
        Throws:
        java.lang.Exception
      • getOrgs

        public java.util.TreeMap getOrgs(boolean includeDisabled)
                                  throws java.lang.Exception
        Identify the organizations on the database.
        Parameters:
        includeDisabled - If True, this will return all organizations, whether disabled or not. If False, this will get only "live" organizations.
        Returns:
        TreeMap where key = orgid, value = String value of "active".
        Throws:
        java.lang.Exception
      • getSiteOrgType

        public java.lang.String getSiteOrgType(java.lang.String objectname)
                                        throws java.lang.Exception
        Get internal siteorgtype for a given table. Selects from maxobject (join to synonymdomain); if no row found, selects from maxobjectcfg. The method getObjectMeta could also be used, but this is a simpler method if the only attribute needed is siteorgtype.
        Parameters:
        objectname - The name of the object.
        Returns:
        Internal value of siteorgtype. If none found, returns the empty string.
        Throws:
        java.lang.Exception
      • getStoragePartition

        public java.lang.String getStoragePartition(java.lang.String tbname)
                                             throws java.lang.Exception
        Get storagepartition for a given table. Selects from maxtable; if no row found, selects from maxtablecfg. You could also use getObjectMeta, but this is a simpler method if all you need is storagepartition.
        Parameters:
        tbname - The name of the table.
        Returns:
        Value of storagepartition. If none found, returns the empty string.
        Throws:
        java.lang.Exception
      • getUniqueIndexSpace

        public java.lang.String getUniqueIndexSpace(java.lang.String tbname,
                                                    java.lang.String tbPartition)
                                             throws java.lang.Exception
        This method is intended for building DB2 "create table" statements. For DB2, the index space must be defined within the "create table" statement (it cannot be specified with "create index"). This method retrieves the value to use for the index tablespace in the "create table" statement.
        Parameters:
        tbname - Table name
        tbPartition - Table's storage partition
        Returns:
        Index space name
        Throws:
        java.lang.Exception
      • getLangColumnName

        public java.lang.String getLangColumnName(java.lang.String tbname)
                                           throws java.lang.Exception
        Get the name of the language column for a given table. Selects from maxtable; if no row found, selects from maxtablecfg. You could also use getObjectMeta, but this is a simpler method if all you need is language column name.
        Parameters:
        tbname - The name of the table.
        Returns:
        Name of the language column. If none found, returns the empty string.
        Throws:
        java.lang.Exception
      • getUniqueColumnName

        public java.lang.String getUniqueColumnName(java.lang.String tbname)
                                             throws java.lang.Exception
        Get the name of the unique column for a given table, from our metadata. Selects from maxtable; if no row found, selects from maxtablecfg. You could also use getObjectMeta, but this is a simpler method if all you need is unique column name.
        Parameters:
        tbname - The name of the table.
        Returns:
        Name of the unique column. If none found, returns the empty string.
        Throws:
        java.lang.Exception
      • getObjectName

        public java.lang.String getObjectName(java.lang.String entityname,
                                              boolean useIsViewConstraint,
                                              boolean isView)
                                       throws java.lang.Exception
        Get objectname for a given table or view. Selects from maxobject; if no row found, selects from maxobjectcfg. You could also use getObjectMeta, but this is a simpler method if all you need is objectname.
        Parameters:
        entityname - The name of the table or view.
        useIsViewConstraint - True is a constraint shouold be applied per the isView param.
        isView - True if this is a view, False if a table. This constraint is applied only if the useIsViewConstraintparam is True.
        Returns:
        Value of objectname. If none found, returns the empty string.
        Throws:
        java.lang.Exception
      • getTableName

        public java.lang.String getTableName(java.lang.String objectname)
                                      throws java.lang.Exception
        Get tablename for a given object. Selects from maxobject; if no row found, selects from maxobjectcfg. You could also use getObjectMeta, but this is a simpler method if all you need is objectname.
        Parameters:
        objectname - The name of the object.
        Returns:
        Value of tablename. If none found, returns the empty string.
        Throws:
        java.lang.Exception
      • getStorageType

        public MTStorageType getStorageType(java.lang.String tableName)
                                     throws java.sql.SQLException
        Get storage type for a given table. Selects from maxtable; if no row found, selects from maxtablecfg.
        Parameters:
        tableName - The name of the table.
        Returns:
        Value of storage type. If none found, returns the empty string.
        Throws:
        java.sql.SQLException
      • getViewName

        public java.lang.String getViewName(java.lang.String objectname)
                                     throws java.lang.Exception
        Get viewname for a given object. Selects from maxobject; if no row found, selects from maxobjectcfg. You could also use getObjectMeta, but this is a simpler method if all you need is objectname.
        Parameters:
        objectname - The name of the object.
        Returns:
        Value of viewname. If none found, returns the empty string.
        Throws:
        java.lang.Exception
      • getAttributeName

        public java.lang.String getAttributeName(java.lang.String objectname,
                                                 java.lang.String tablename,
                                                 java.lang.String columnname)
                                          throws java.lang.Exception
        Get attributename for a given column. Selects from maxattribute; if no row found, selects from maxattributecfg. You could also use getAttributeMeta, but this is a simpler method if all you need is attributename.
        Parameters:
        objectname - The name of the object.
        tablename - The name of the table.
        columnname - The name of the column.
        Returns:
        Value of attributename. If none found, returns the empty string.
        Throws:
        java.lang.Exception
      • getColumnName

        public java.lang.String[] getColumnName(java.lang.String objectname,
                                                java.lang.String attributename)
                                         throws java.lang.Exception
        Get tablename and columnname for a given attribute. Selects from maxattribute; if no row found, selects from maxattributecfg. You could also use getAttributeMeta, but this is a simpler method if all you need is attributename.
        Parameters:
        objectname - The name of the object.
        attributename - The name of the attribute.
        Returns:
        String array where [0] = tablename and [1] = columnname. If none found, returns the empty string.
        Throws:
        java.lang.Exception
      • getKeyAttribute

        public java.lang.String getKeyAttribute(java.lang.String objectname,
                                                java.lang.String tablename)
                                         throws java.lang.Exception
        This method identifies the "key attribute" (i.e., the unique column within siteid or orgid) so that ConfigDB can determine whether the table has an attribute that can be autonumbered (canautonum = True). This is NOT the same as the "uniquecolumnname" stored on maxtable (for that, see getUniqueColumnName). The "key attribute" is determined as follows:
        1. If the siteorgtype of the table is SYSTEM, there must be a one-column unique index, and this method will return the attribute for the identified column name.
        2. If the siteorgtype of the table is ORG or ORGSITE, there must be a two-column unique index, where the first column is ORGID. This method will return the attribute for the identified name of the second column. However, there are exceptions, where ORGSITE tables are unique within siteid. If the check within orgid fails, this method then checks within siteid (see next step).
        3. If the siteorgtype of the table is SITE, there must be a two-column unique index where the first column is SITEID. This method will return the attribute for the identified name of the second column.
        4. If none of the above is found, this method will return null.

        In theory, if this is the main object for an application, the attribute name should equal the maxapps keycolumn. However, this method does not check or validate against maxapps.

        This method attempts to use maxsysindexes and maxsyskeys (not maxattribute) when determining the index. However, if there is NO data in maxsysindexes for this table, then this method will use primarykeycolseq on maxattributecfg.

        To get the names and sequence of all columns in a table's unique index, use the getKeyColumns method.

        Parameters:
        objectname - The object name.
        tablename - The table name (entityname).
        Returns:
        The key attribute name. If none found, returns null.
        Throws:
        java.lang.Exception
        See Also:
        Util.getSiteOrgType(java.lang.String), Util.getUniqueColumnName(java.lang.String)
      • getObjectMeta

        public java.util.TreeMap getObjectMeta(java.lang.String objectname,
                                               boolean getCfg,
                                               boolean getPersistentOnly,
                                               boolean getChangedOnly,
                                               boolean getColumns,
                                               boolean colsOrderByName,
                                               boolean getTablesOnly,
                                               boolean getViewsOnly)
                                        throws java.sql.SQLException
        Get metadata for an object (table or view).
        Parameters:
        objectname - The object name (optional). If null, gets all objects, else gets only the specified object.
        getCfg - If true, gets metadata from the configuration tables (maxobjectcfg, maxtablecfg, etc.). Otherwise, gets the active metadata.
        getPersistentOnly - If true, gets only persistent objects and attributes. Else gets them all.
        getChangedOnly - If true, gets only objects where the value of "changed" is not "N".
        getColumns - If true, gets attribute metadata and stores under key "$ATTRIBUTES". (Gets all attributes, whether changed or not.) Otherwise, does not get attribute metadata.
        colsOrderByName - If getColumns is True, then if colsOrderByName is True, the attributes will be in sequence by attributename; if False, they will be in sequence by attributeno.
        getTablesOnly - True to get only tables, else False.
        getViewsOnly - True to get only views, else False.
        Returns:
        TreeMap, key = object name (uppercase), value = HashMap. The HashMap has an entry for each attribute in the object and table or view metadata, whose value is the metadata string value.

        The entry "$STORAGECLAUSE" will contain the storage clause (if any) for an Oracle table; otherwise, this is the empty string (see getStorageClause).

        Also, if we are getting attributes, there will be an entry "$ATTRIBUTES" whose value is a TreeMap of the attributes (see getAttributeMeta).

        Throws:
        java.sql.SQLException
        See Also:
        Util.getAttributeMeta(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String), Util.getStorageClause(java.lang.String, boolean)
      • getAttributeMeta

        public java.util.TreeMap getAttributeMeta(java.lang.String objectname,
                                                  boolean getCfg,
                                                  boolean orderByName,
                                                  boolean getPersistentOnly,
                                                  boolean getChangedOnly,
                                                  boolean selectView,
                                                  java.lang.String entityName)
                                           throws java.sql.SQLException
        Get attribute metadata (maxattributes and maxviewcolumns) for an object.
        Parameters:
        objectname - The object name.
        getCfg - If true, gets metadata from the configuration table(s). Otherwise, gets the active metadata.
        orderByName - If true, the key to the "$MAXATTRIBUTES" TreeMap is attribute name (uppercase). Otherwise, the key to this TreeMap is attribute number (4-character String with leading zeroes).
        getPersistentOnly - If true, gets only persistent attributes. Else gets them all.
        getChangedOnly - If true, gets only attributes where the value of "changed" is not "N".
        selectView - True if we want to try to retrieve View metadata (i.e., this is a view, or we are not sure whether this is a table or view).
        entityName - The entityname (if known). This is important when selecting view attributes from maxviewcolumn. Otherwise, it is OK for this to be null.
        Returns:
        TreeMap, containing two child TreeMaps.

        key[0] = "$MAXATTRIBUTES" with all data from maxattribute (or maxattributecfg) for this object. Under this key, there will be stored another TreeMap, key = attributename (uppercase) or attribute number, value = HashMap. The HashMap has an entry for each attribute in the maxattribute metadata, whose value is the metadata string value.

        key[1] = "$MAXVIEWCOLUMNS", with all data from maxviewcolumns (or maxviewcolumncfg) for this object. Under this key, there will be stored another TreeMap, key = viewcolumnname (uppercase), value = HashMap. The HashMap has an entry for each attribute in the maxviewcolumn metadata, whose value is the metadata string value.

        Throws:
        java.sql.SQLException
      • getTenantAttributeMeta

        public java.util.HashMap getTenantAttributeMeta(java.lang.String objectname,
                                                        int tenantId)
                                                 throws java.sql.SQLException
        Get attribute metadata (maxattributes and maxviewcolumns) for an object.
        Parameters:
        objectname - The object name.
        getCfg - If true, gets metadata from the configuration table(s). Otherwise, gets the active metadata.
        orderByName - If true, the key to the "$MAXATTRIBUTES" TreeMap is attribute name (uppercase). Otherwise, the key to this TreeMap is attribute number (4-character String with leading zeroes).
        getPersistentOnly - If true, gets only persistent attributes. Else gets them all.
        getChangedOnly - If true, gets only attributes where the value of "changed" is not "N".
        selectView - True if we want to try to retrieve View metadata (i.e., this is a view, or we are not sure whether this is a table or view).
        entityName - The entityname (if known). This is important when selecting view attributes from maxviewcolumn. Otherwise, it is OK for this to be null.
        tenantId - In MT environment tenant id of the processing tenant.
        Returns:
        TreeMap, containing two child TreeMaps.

        key[0] = "$MAXATTRIBUTES" with all data from maxattribute (or maxattributecfg) for this object. Under this key, there will be stored another TreeMap, key = attributename (uppercase) or attribute number, value = HashMap. The HashMap has an entry for each attribute in the maxattribute metadata, whose value is the metadata string value.

        key[1] = "$MAXVIEWCOLUMNS", with all data from maxviewcolumns (or maxviewcolumncfg) for this object. Under this key, there will be stored another TreeMap, key = viewcolumnname (uppercase), value = HashMap. The HashMap has an entry for each attribute in the maxviewcolumn metadata, whose value is the metadata string value.

        Throws:
        java.sql.SQLException
      • gettenantSameAsExtendedAtributes

        public java.util.Map gettenantSameAsExtendedAtributes(int tenantId)
                                                       throws java.sql.SQLException
        Get attribute metadata (maxattributes and maxviewcolumns) for an object.
        Parameters:
        objectname - The object name.
        getCfg - If true, gets metadata from the configuration table(s). Otherwise, gets the active metadata.
        orderByName - If true, the key to the "$MAXATTRIBUTES" TreeMap is attribute name (uppercase). Otherwise, the key to this TreeMap is attribute number (4-character String with leading zeroes).
        getPersistentOnly - If true, gets only persistent attributes. Else gets them all.
        getChangedOnly - If true, gets only attributes where the value of "changed" is not "N".
        selectView - True if we want to try to retrieve View metadata (i.e., this is a view, or we are not sure whether this is a table or view).
        entityName - The entityname (if known). This is important when selecting view attributes from maxviewcolumn. Otherwise, it is OK for this to be null.
        tenantId - In MT environment tenant id of the processing tenant.
        Returns:
        TreeMap, containing two child TreeMaps.

        key[0] = "$MAXATTRIBUTES" with all data from maxattribute (or maxattributecfg) for this object. Under this key, there will be stored another TreeMap, key = attributename (uppercase) or attribute number, value = HashMap. The HashMap has an entry for each attribute in the maxattribute metadata, whose value is the metadata string value.

        key[1] = "$MAXVIEWCOLUMNS", with all data from maxviewcolumns (or maxviewcolumncfg) for this object. Under this key, there will be stored another TreeMap, key = viewcolumnname (uppercase), value = HashMap. The HashMap has an entry for each attribute in the maxviewcolumn metadata, whose value is the metadata string value.

        Throws:
        java.sql.SQLException
      • getIndexMeta

        public java.util.TreeMap getIndexMeta(java.lang.String tbname,
                                              boolean getChangedOnly)
                                       throws java.sql.SQLException
        Throws:
        java.sql.SQLException
        See Also:
        Util.getIndexMeta(String, boolean, boolean)
      • getIndexMeta

        public java.util.TreeMap getIndexMeta(java.lang.String tbname,
                                              boolean getChangedOnly,
                                              boolean getPrimary)
                                       throws java.sql.SQLException
        Throws:
        java.sql.SQLException
        See Also:
        Util.getIndexMeta(String, boolean, boolean)
      • getIndexMeta

        public java.util.TreeMap getIndexMeta(java.lang.String tbname,
                                              boolean getChangedOnly,
                                              boolean getPrimary,
                                              boolean includeDeleted)
                                       throws java.sql.SQLException
        Get metadata for indexes.
        Parameters:
        tbname - To get indexes for only one table, this will equal the table name. To get indexes for all tables, this will be null.
        getChangedOnly - If true, gets only indexes where the value of "changed" equal "Y" or "D" on maxsysindexes and/or maxsyskeys. If False, gets all indexes, whether or not they've been changed.
        getPrimary - This parameter is used only for DB2. If true, all indexes will be retrieved, including primary keys (defined with the "create table" statement "primary key" clause). If false, primary keys will not be included.
        includeDelted - If False, exclude indexes where the value of "changed" equal "D" on maxsysindexes and/or maxsyskeys. If True, include indexes where the value of "changed" equal "D" on maxsysindexes and/or maxsyskeys.
        Returns:
        TreeMap, key = index name (uppercase), value = HashMap. The HashMap has an entry for each attribute in the maxsysindexes metadata, whose value is the metadata string value. Note, however, that the index name is always stored as "IXNAME" (whether from maxsysindexes or maxsyskeys), and the "changed" attribute is stored as "IXCHANGED" for maxsysindexes, and "KEYCHANGED" for maxsyskeys. Also, there is an entry "$MAXSYSKEYS" whose value is a TreeMap of the key columns, in colseq sequence. The entry "$STORAGECLAUSE" will contain the storage clause (if any) for Oracle; if not Oracle, this is the empty string (see getStorageClause).
        Throws:
        java.sql.SQLException
        See Also:
        Util.getStorageClause(java.lang.String, boolean)
      • getIndexNamesForColumn

        public java.util.ArrayList getIndexNamesForColumn(java.lang.String tbname,
                                                          java.lang.String colName)
                                                   throws java.sql.SQLException
        Get the names of indexes that exist in the metadata and contain the specified column.
        Parameters:
        tbname - Table name
        colName - Column name
        Returns:
        Index names from maxsysindexes. Will be empty if none found.
        Throws:
        java.sql.SQLException
      • getMaxvar

        public java.lang.String getMaxvar(java.lang.String varname,
                                          boolean getDefault)
                                   throws java.sql.SQLException
        Get value of maxvar from database. This presumes there is no orgid or siteid constraint.
        Parameters:
        varname - Name of the maxvar.
        getDefault - If True, gets default value of maxvar from maxvartype table. If False, gets value of maxvar from maxvars table, with orgid and siteid both null.
        Returns:
        The value of the maxvar.
        Throws:
        java.sql.SQLException
      • getYes

        public java.lang.String getYes()
        Return the value of sYes.
        Returns:
        The value for YES.
      • getNo

        public java.lang.String getNo()
        Return the value of sNo.
        Returns:
        The value for NO.
      • getMaxUpgVersion

        public java.lang.String getMaxUpgVersion()
        Return the value of maxUpgVersion (the maxvar value for MAXUPG), initialized via the constructor.
        Returns:
        The maxvar value for MAXUPG.
      • nativeTableExists

        public boolean nativeTableExists(java.lang.String tbname)
                                  throws java.lang.Exception
        Determine whether the native table exists. Oracle selects from user_tables, SqlServer selects from sysobjects.
        Parameters:
        tbname - The table name
        Returns:
        True if it exists, else False.
        Throws:
        java.lang.Exception
      • nativeColumnExists

        public boolean nativeColumnExists(java.lang.String tbname,
                                          java.lang.String name)
                                   throws java.lang.Exception
        Determine whether the native column exists. Oracle selects from user_tab_columns, SqlServer selects from sysobjects.
        Parameters:
        tbname - The table name
        name - The column name
        Returns:
        True if it exists, else False.
        Throws:
        java.lang.Exception
      • nativeViewExists

        public boolean nativeViewExists(java.lang.String vname)
                                 throws java.lang.Exception
        Determine whether the native view exists. Oracle selects from user_views, SqlServer selects from sysobjects. DB2 uses the schemaOwner variable which was initialized in the constructor.
        Parameters:
        vname - The view name
        Returns:
        True if it exists, else False.
        Throws:
        java.lang.Exception
      • nativeIndexExists

        public boolean nativeIndexExists(java.lang.String ixname,
                                         java.lang.String tbname)
                                  throws java.lang.Exception
        Determine whether the native index exists. Oracle selects from user_indexes, SqlServer selects from sysobjects and dbo/sysindexes.
        Parameters:
        ixname - The index name.
        tbname - The table name (optional). If non-null, this method will determine whether the specified index exists on the specified table. If null, this method will check for the index, without using a table constraint.
        Returns:
        True if it exists, else False.
        Throws:
        java.lang.Exception
      • nativeIndexExistsForColumn

        public java.util.ArrayList nativeIndexExistsForColumn(java.lang.String tbname,
                                                              java.lang.String name)
                                                       throws java.lang.Exception
        Identifies whether the given column participates in a native index for the given table.
        Parameters:
        tbname - Table name
        name - Column name
        Returns:
        If the column exists in index(es), this is the index name(s) (may be lowercase if not Oracle). If the column is not in an index, this will be empty.
        Throws:
        java.lang.Exception
      • nativeIndexExistsForColumns

        public java.lang.String nativeIndexExistsForColumns(java.lang.String tbname,
                                                            java.lang.Object[] names)
                                                     throws java.lang.Exception
        Call nativeIndexExistsForColumns with last parameter false.
        Parameters:
        tbname - Table name
        names - Array of column names in the sequence they would appear in the index.
        Returns:
        If the columns exists in an index, this is the index name (may be lowercase if not Oracle). If index is not found, this will be null.
        Throws:
        java.lang.Exception
        See Also:
        Util.nativeIndexExistsForColumns(String, Object[], boolean)
      • nativeIndexExistsForColumns

        public java.lang.String nativeIndexExistsForColumns(java.lang.String tbname,
                                                            java.lang.Object[] names,
                                                            boolean ignoreTS)
                                                     throws java.lang.Exception
        Identifies whether an index exists on the given table with the given sequence of columns.
        Parameters:
        tbname - Table name
        names - Array of column names in the sequence they would appear in the index.
        ignoreTS - When looking for a duplicate index, ignore domain index (Oracle text search).
        Returns:
        If the columns exists in an index, this is the index name (may be lowercase if not Oracle). If index is not found, this will be null.
        Throws:
        java.lang.Exception
      • cleanStatisticNames

        public java.util.ArrayList cleanStatisticNames()
                                                throws java.lang.Exception
        If this is SqlServer and native statistics exist with the same name as an entry in maxsysindexes, then drop the statistics. This could occur if someone defines a new index in the DB Config app, then creates statistics with the same name before running ConfigDB.
        Returns:
        Sql statements to drop statistics
        Throws:
        java.lang.Exception
      • fixMetadataForDescendingKeys

        public java.util.ArrayList fixMetadataForDescendingKeys(java.lang.String tbname,
                                                                java.lang.String ixname)
                                                         throws java.lang.Exception
        This method should be called immediately after executing the Sql from getSysIndexRefresh on an Oracle platform. This method will update maxsyskeys colname for descending keys.
        Parameters:
        tbname - Table name (can be null for all tables).
        ixname - Index name (can be null for all indexes).
        Returns:
        Sql statement(s)
        Throws:
        java.lang.Exception
        See Also:
        Util.getSysIndexRefresh(java.lang.String, java.lang.String)
      • nativeIndexIsUnique

        public boolean nativeIndexIsUnique(java.lang.String ixname)
                                    throws java.lang.Exception
        Identifies whether an index is unique on the native database.
        Parameters:
        ixname - Index name
        Returns:
        True if the index exists and is unique; else False
        Throws:
        java.lang.Exception
      • nativeIndexIsPrimaryKey

        public boolean nativeIndexIsPrimaryKey(java.lang.String ixname)
                                        throws java.lang.Exception
        Identifies whether an index is a native primary key for DB2. For Oracle and SqlServer this will return false.
        Parameters:
        ixname - Index name
        Returns:
        True if the index exists and is defined as primary key for DB2
        Throws:
        java.lang.Exception
      • nativeColumnIsNullable

        public boolean nativeColumnIsNullable(java.lang.String tbname,
                                              java.lang.String name)
                                       throws java.lang.Exception
        Determine whether the native column is nullable.
        Parameters:
        tbname - The table name
        name - The column name
        Returns:
        True if it is nullable, else False.
        Throws:
        java.lang.Exception
      • addIndex

        public java.util.ArrayList addIndex(java.lang.String tbname,
                                            java.lang.String[] names,
                                            java.lang.String startWith,
                                            boolean addUnique,
                                            java.lang.String storagepartition,
                                            boolean isPrimary,
                                            boolean isRequired)
                                     throws java.lang.Exception
        Generates sql for creating a new index with the specified column names. If an index with these columns already exists, the output array will be empty. If this method needs to add the index but cannot come up with a name for the new index, an error will be generated.
        Parameters:
        tbname - Table name
        names - Array of column names to be in the index.
        startWith - The index will be named tbname + "_ndx" + xx, where xx >= startWith. This parameter must be equivalent to an integer value. If null, the method will start with 1.
        addUnique - True if the new index should be unique, else False.
        storagepartition - Storage partition for the index. If this is null, the default partition will be used.
        Returns:
        Sql statements for creating the index (native index and Maximo metadata).
        Throws:
        java.lang.Exception
        See Also:
        Util.nativeIndexExistsForColumns(java.lang.String, java.lang.Object[]), Util.getNewIndexName(java.lang.String, int), Util.nativeIndexExists(java.lang.String, java.lang.String), Util.getDefaultStoragePartition(boolean), Util.getNextSequenceValueForSqlServer(java.lang.String)
      • getNewIndexName

        public java.lang.String getNewIndexName(java.lang.String tbname,
                                                int startWith)
                                         throws java.lang.Exception
        Identify an index name that can be used for creating a new index on this table. Index name is in the format tbname + "_NDX" + x, where x is an integer that's incremented for each index on that table.
        Parameters:
        tbname - Table name
        startWith - If it's known that indexes _ndx3 exists, you can set startWith to 4; Or you can just leave startWith at 0 or 1.
        Returns:
        Name that can be used when creating a new index.
        Throws:
        java.lang.Exception
      • nativeDefaultConstraintExists

        public java.util.ArrayList nativeDefaultConstraintExists(java.lang.String tbname,
                                                                 java.lang.String name)
                                                          throws java.lang.Exception
        Identifies whether the given column has a default constraint in SqlServer. (In order to drop the default, you need the constraint name, which is system-generated if not originally user-specified.)
        Parameters:
        tbname - Table name
        name - Column name
        Returns:
        If the column has default constraint(s), this contains the constraint name(s). If the column does not have a default constraint or this is Oracle, this will be empty.
        Throws:
        java.lang.Exception
      • nativeTriggerExists

        public boolean nativeTriggerExists(java.lang.String trigname)
                                    throws java.lang.Exception
        Determine whether the native trigger exists. Oracle selects from user_triggers, SqlServer selects from sysobjects, DB2 selects from triggers.
        Parameters:
        trigname - The trigger name
        Returns:
        True if it exists, else False.
        Throws:
        java.lang.Exception
      • nativeSequenceExists

        public boolean nativeSequenceExists(java.lang.String name)
                                     throws java.lang.Exception
        Determine whether the native sequence exists. This is only for Oracle and DB2. Other platforms always return False.
        Parameters:
        name - The sequence name
        Returns:
        True if it exists, else False.
        Throws:
        java.lang.Exception
      • isNickname

        public boolean isNickname(java.lang.String name)
                           throws java.lang.Exception
        Determine whether the given name is a nickname. For DB2 federated tables, there will be a row in syscat.nicknames. This method is only for DB2. Other platforms always return False.
        Parameters:
        name - The nickname
        Returns:
        True if it exists, else False.
        Throws:
        java.lang.Exception
      • isSysYORN

        public boolean isSysYORN(java.lang.String attrName)
        Given the name of a column on maxtablecfg, maxattributecfg, maxsysindexes, or maxsyskeys, identify whether this is a YORN attribute.
        Parameters:
        attrName - The name of the attribute (e.g. "canautonum").
        Returns:
        True if this is YORN, else False
        See Also:
        Util.sysYORNattrs
      • isSysNumeric

        public boolean isSysNumeric(java.lang.String attrName)
        Given the name of a column on maxtablecfg, maxattributecfg, maxsysindexes, or maxsyskeys, identify whether this is a numeric attribute. (For this method, YORN attributers are considered numeric.)
        Parameters:
        attrName - The name of the attribute (e.g. "length").
        Returns:
        True if this is numeric, else False
        See Also:
        Util.sysNumattrs, Util.isSysYORN(java.lang.String)
      • adjustViewMeta

        public java.util.ArrayList adjustViewMeta(java.lang.String viewname)
                                           throws java.lang.Exception
        Adjust view metadata by removing obsolete persistent attributes and adding new persistent attributes. Non-persistent attributes are not affected.
        Parameters:
        viewname - The view to be adjusted.
        Returns:
        Sql statements to update the view's metadata.
        Throws:
        java.lang.Exception
        See Also:
        Util.adjustViewMeta(String, boolean, boolean)
      • getMaximumColumnNameLength

        public int getMaximumColumnNameLength()
                                       throws java.sql.SQLException
        Get the maximum length of a column name.
        Returns:
        the length (30)
        Throws:
        java.sql.SQLException
      • adjustViewMeta

        public java.util.ArrayList adjustViewMeta(java.lang.String viewname,
                                                  boolean addP,
                                                  boolean addNP)
                                           throws java.lang.Exception
        Adjust view metadata by removing obsolete persistent attributes and adding new persistent and/or non-persistent attributes. If an attribute does not already exist on the view, it is added. This method returns sql statements that update maxattribute and maxviewcolumn (and cfg) for the view. To regenerate the native "create view" statement, you must separately call buildCreateViewStatement.

        Attributes will be added to the metadata whether or not the view is autoselect. However, if the view is non-autoselect, another process will have to adjust viewselect and other attributes on maxview, as needed. Therefore, the driver to this method should ideally be passing in only autoselect views.

        This method was written to support installations having multiple Industry Solutions, but can be used elsewhere. For example:

        • IS#1 extended TableA to create View1.
        • IS#2 adds persistent column ColX to TableA. We need to dynamically update View1 with ColX.
        Parameters:
        viewname - The view to be adjusted.
        addP - True to add persistent attributes, False to not add them.
        addNP - True to add non-persistent attributes, False to not add them.
        Returns:
        Sql statements to update the view's metadata.
        Throws:
        java.lang.Exception
      • useQuotes

        public boolean useQuotes(java.lang.String maxtype)
        Return True if quotation marks need to surround the column's value in a SQL statement.
        Parameters:
        maxtype - The maxtype to be evaluated.
        Returns:
        True if it needs quotes, else False.
      • singleToDoubleQuotes

        public java.lang.String singleToDoubleQuotes(java.lang.String in)
        Scan input string to see if it contains any single quotes, and replace any single quote with two single quotes. This is used when creating a Sql statement with a value that contains single quotes.
        Parameters:
        in - The value to be analyzed.
        Returns:
        The input value with any single quotes replaced by two single quotes.
      • toggleStringConcat

        public java.lang.String toggleStringConcat(java.lang.String inString,
                                                   java.lang.String inConcat,
                                                   java.lang.String outConcat)
        Scan input string and change the concatenator character. For example, if the inString is in Oracle format, which uses "||" for concatenation, and the output should be for SqlServer, which uses "+", the inConcat would equal "||" and the outConcat would equal "+". This is used by Unlcvt when forming Sql for views.
        Parameters:
        inString - The value to be analyzed.
        inConcat - The contatenator to be searched for and replaced in the input string.
        outConcat - The new concatenator to be used in the output string.
        Returns:
        The input value with any inConcat replaced by outConcat.
      • getNativeType

        public java.lang.String getNativeType(java.lang.String maxType,
                                              java.lang.String length,
                                              int dbPlatform)
        Return the native datatype for the specified Maximo datatype.
        Parameters:
        maxType - The Maximo datatype
        length - The length of the field as specified on maxattribute (to determine if this is a long string).
        dbPlatform - If equal to 0, uses whatever platform we're using for dbOut. Otherwise, can equal one of the values in UpgConstants to specify ORACLE, SQLSERVER, or DB2.
        Returns:
        the native datatype
      • getJdbcType

        public int getJdbcType(java.lang.String nativeType,
                               int dbPlatform)
                        throws java.lang.Exception
        Get the JDBC Type (java.sql.Types) for the native datatype.
        Parameters:
        nativeType -
        dbPlatform -
        Returns:
        JDBC Type
        Throws:
        java.lang.Exception
      • getNativeTypeForColumn

        public java.lang.String getNativeTypeForColumn(java.lang.String tbname,
                                                       java.lang.String name)
                                                throws java.lang.Exception
        Return the native datatype from the system tables for the specified column.
        Parameters:
        tbname - The table name.
        name - The column name.
        Returns:
        the native datatype
        Throws:
        java.lang.Exception
      • getNativeDateDefault

        public java.lang.String getNativeDateDefault()
                                              throws java.lang.Exception
        Return the native command for getting the current system date. For Oracle, this equals SYSDATE. For SqlServer, this equals getdate(). For DB2, this equals current timestamp.
        Returns:
        Native command for current system date.
        Throws:
        java.lang.Exception
      • getNativePartition

        public java.lang.String getNativePartition(java.lang.String tbname)
                                            throws java.lang.Exception
        Return the native storage partition for the specified table. This is called when defining the metadata for an inherited table.
        Parameters:
        tbname - The table name.
        Returns:
        The current native storagepartition for this table. If the table does not exist, this will be null.
        Throws:
        java.lang.Exception
      • spaceIsActive

        public boolean spaceIsActive(java.lang.String spaceName)
                              throws java.lang.Exception
        Determine whether the specified tablespace is available. This does not check for the amount of freespace.
        Parameters:
        spaceName - Name of the tablespace to be checked.
        Returns:
        True if the tablespace is available, else False
        Throws:
        java.lang.Exception
      • spaceIsSysManaged

        public boolean spaceIsSysManaged(java.lang.String spaceName)
                                  throws java.lang.Exception
        Determine whether the specified tablespace is system-managed. This pertains only to DB2. If the platform is not DB2, this method returns False.
        Parameters:
        spaceName - Name of the tablespace to be checked.
        Returns:
        True if the tablespace is system-managed and platform is DB2
        Throws:
        java.lang.Exception
      • bytesSpaceNeeded

        public int bytesSpaceNeeded(java.lang.String spaceName)
                             throws java.lang.Exception
        Deprecated. Replaced by spaceNeeded.
        Determine how much space is needed (in bytes) from the specified tablespace name to run ConfigDB. This uses the metadata in maxtablecfg and maxattributecfg to identify which tables will need space. This method is used only for Oracle.
        Parameters:
        spaceName - Name of the tablespace to be checked.
        Returns:
        Bytes of space needed in this tablespace (without extending). If not Oracle, this will equal 0.
        Throws:
        java.lang.Exception
      • spaceNeeded

        public java.lang.Object[] spaceNeeded(java.lang.String spaceName)
                                       throws java.lang.Exception
        Determine how much space is needed from the specified tablespace name to run ConfigDB. This uses the metadata in maxtablecfg and maxattributecfg to identify which tables will need space. This method is used only for Oracle.
        Parameters:
        spaceName - Name of the tablespace to be checked.
        Returns:
        Array containing: [0] = Integer = Space needed in this tablespace (without extending). If not Oracle, this will equal 0. [1] = Multiple of bytes; Space = bytes, M = Megabytes
        Throws:
        java.lang.Exception
      • makeSpace

        public java.util.ArrayList makeSpace(java.lang.String spaceName,
                                             int numBytes)
                                      throws java.lang.Exception
        Deprecated. Replaced by makeSpace
        Throws:
        java.lang.Exception
      • makeSpace

        public java.util.ArrayList makeSpace(java.lang.String spaceName,
                                             int numBytes,
                                             java.lang.String multiplier)
                                      throws java.lang.Exception
        Return Sql statements that will effectively determine whether space can be extended for the specified number of bytes. This Sql include a "create table" statement for a dummy table ("maximo_makespace") specifying the number of bytes. The next statement drops the dummy table, leaving this space free for other uses. Thus, if the first statement fails execution, the calling program can assume that autoextend is not on or has failed for some reason. This method is used only for Oracle.
        Parameters:
        spaceName - Name of the tablespace.
        numBytes - The number of bytes or megabytes to be allocated.
        multiplier - Space = bytes, "M" = megabytes
        Returns:
        Sql statements needed to perform this check, as described above. If not Oracle, this will be empty.
        Throws:
        java.lang.Exception
      • spaceCheckForDBConfig

        public java.lang.String[] spaceCheckForDBConfig()
                                                 throws java.lang.Exception
        Using the metadata in maxattributecfg, determine whether adequate space is or can be made available for running ConfigDB. This method actually allocates the space, if more is needed. This method is used only for Oracle.
        Returns:
        String Array. If this is not Oracle, this will be empty. If there is sufficient space (Oracle), this will be empty. If there is NOT sufficient space (Oracle), [0] is the partition name and [1] is the bytes needed.
        Throws:
        java.lang.Exception
        See Also:
        Util.spaceIsActive(java.lang.String), Util.spaceNeeded(java.lang.String), Util.makeSpace(java.lang.String, int)
      • getStorageClause

        public java.lang.String getStorageClause(java.lang.String name,
                                                 boolean isTable)
                                          throws java.lang.Exception
        Get the "storage" clause to use when creating a table or index. This is retrieved from the existing table or index before it is dropped and re-created. When it is re-created, this clause should be applied so that the storage parameters remain the same as for the original object. This method is used only for Oracle.
        Parameters:
        name - Object name (table or index name)
        isTable - True if this is a table, False if this is an index
        Returns:
        Storage clause (null if not Oracle).
        Throws:
        java.lang.Exception
      • adjustNativeSql

        public java.lang.String adjustNativeSql(java.lang.String origSql)
                                         throws java.lang.Exception
        Called from Maxinst and UpdateDB, when intercepting a native Sql statement (create table or alter table). This method will adjust the native Sql for varcharMultiple and useVargraphic.

        This method is not needed for ConfigDB and other database utilities, as they create the native statements properly. This method is needed only when the incoming Sql has been hardcoded in a script.

        Parameters:
        origSql - Original create or alter statement.
        Returns:
        new Sql with native lengths and/or datatypes of varchar columns adjusted
        Throws:
        java.lang.Exception
        See Also:
        Util.varcharMultiple, Util.useVargraphic
      • getMaxType

        public java.lang.String getMaxType(java.lang.String nativeType)
        Return the Maximo datatype for the specified native datatype. Used in the Config UI when loading columns for an inherited table. This does not support the CRYPTO and CRYPTOX maxtypes.
        Parameters:
        nativeType - The native datatype
        Returns:
        the Maximo datatype (maxtype)
      • getDefaultStoragePartition

        public java.lang.String getDefaultStoragePartition(boolean checkValuelist)
                                                    throws java.lang.Exception
        Get the name of the default storagepartition.
        Parameters:
        checkValuelist - True if the name must exist in both the native system table and the alndomain table (DBSTORAGEPARTITION). False to get the value from the native system table only, without checking against the valuelist.
        Returns:
        value for storage partition (tablespace)
        Throws:
        java.lang.Exception
      • getDBStoragePartitions

        public java.util.ArrayList getDBStoragePartitions()
                                                   throws java.lang.Exception
        Get the names of the storagepartitions from the valuelist DBSTORAGEPARTITION.
        Returns:
        value(s) for dbstoragepartition
        Throws:
        java.lang.Exception
      • nativeSpaceExists

        public boolean nativeSpaceExists(java.lang.String name)
                                  throws java.lang.Exception
        For Oracle and DB2, checks to see whether the native tablespace exists. For DB2, tablespace datatype must equal 'A' or 'L' for this to return true. This method is used for validating the -s and -t parameters in Maxinst.
        Parameters:
        name - Name of tablespace to be checked.
        Returns:
        True if it exists. For SqlServer, this always returns False.
        Throws:
        java.lang.Exception
      • needLength

        public boolean needLength(java.lang.String maxtype,
                                  java.lang.String nativeType)
        For the specified datatype, identifies whether the column definition needs a length (for example, in a "create table" statement).
        Parameters:
        maxtype - Maximo datatype
        nativeType - Native datatype
        Returns:
        True if length should be specified, else False
      • needScale

        public boolean needScale(java.lang.String maxtype,
                                 java.lang.String nativeType)
        For the specified datatype, identifies whether the column definition needs a scale (for example, in a "create table" statement).
        Parameters:
        maxtype - Maximo datatype
        nativeType - Native datatype
        Returns:
        True if scale should be specified, else False
      • reEvaluateObjectChanged

        public java.lang.String reEvaluateObjectChanged(java.util.HashMap newObject,
                                                        java.util.HashMap oldObject,
                                                        boolean useAttrChanged,
                                                        java.lang.String upgradeDir)
                                                 throws java.lang.Exception
        Look through the metadata for maxobjectcfg and maxattributecfg (old and new), and determine the proper value for maxobjectcfg changed.

        This method is used by the Configure UI and the Upgrade.

        For a description of the values for the "changed" attribute, see MaxObjectCfg.

        Parameters:
        newObject - The new object, with attributes in sequence by name. Cannot be null or empty. If deleting the object, this must have "CHANGED" equal to "R". For the format of this param, see getObjectMeta.
        oldObject - The old object, with attributes in sequence by name. Can be null or empty only if a new object is being added. For the format of this param, see getObjectMeta.
        useAttrChanged - If True, then when examining the attributes, this method will assume that the attributes' value for "changed" has been updated to the proper value. If False, the method will not look at attributes' changed, and will instead call reEvaluateAttributeChanged where needed. However, this does NOT update the attribute HashMap.

        If the attributes are not up-to-date, and you wish to update them, call reEvaluateAttributeChanged and update the column HashMap before calling the object method.

        upgradeDir - This is non-null ONLY when this method is called during the upgrade by TableElement. It is the subdirectory used by custom classes. When called via the Config UI this MUST be null.
        Returns:
        The new value for maxobjectcfg changed. (This does not update the database!)
        Throws:
        java.lang.Exception
        See Also:
        Util.reEvaluateAttributeChanged(java.lang.String, java.util.HashMap, java.util.HashMap, java.lang.String, boolean), Util.canAlterTable(java.lang.String, java.util.HashMap, java.util.HashMap, java.lang.String)
      • reEvaluateObjectChanged

        public java.lang.String reEvaluateObjectChanged(java.util.HashMap newObject,
                                                        java.util.HashMap oldObject,
                                                        boolean useAttrChanged,
                                                        java.lang.String upgradeDir,
                                                        java.lang.String langcode)
                                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • reEvaluateObjectChangedQuickGL

        public java.lang.String reEvaluateObjectChangedQuickGL(java.lang.String entityname,
                                                               boolean isView,
                                                               java.util.HashMap attrs,
                                                               boolean persistent,
                                                               java.lang.String origChanged)
                                                        throws java.lang.Exception
        For quick calculation of new value of "changed" when the only change being made is to GL Configure.
        Parameters:
        entityname - Table or view name
        isView - True if this is a view, else False
        attrs - Key = attributename, value = current value of Changed from maxattributecfg
        persistent - True if persistent, else False
        origChanged - Current value of maxobjectcfg changed
        Returns:
        The new value for maxobjectcfg changed. (This does not update the database!)
        Throws:
        java.lang.Exception
      • reEvaluateAttributeChangedQuickGL

        public java.lang.String reEvaluateAttributeChangedQuickGL(java.lang.String entityname,
                                                                  java.lang.String columnname,
                                                                  boolean isView,
                                                                  int oldLength,
                                                                  int newLength,
                                                                  boolean persistent,
                                                                  java.lang.String origChanged)
                                                           throws java.lang.Exception
        This method is used for quick evaluation of the "changed" attribute for an attribute, when changing ONLY the length of the attribute for the purposes of GL account configuration. This method was created to save memory when reconfiguring GL accounts.
        Parameters:
        entityname - Table or view name
        columnname - Column Name
        isView - True if this is a view, else False
        oldLength - Old column length
        newLength - New column length
        persistent - True if persistent
        origChanged - Old value of "changed"
        Returns:
        New value of "changed"
        Throws:
        java.lang.Exception
        See Also:
        Util.canAlterForLengthChange(java.lang.String, java.lang.String, int, int)
      • reEvaluateTableAttributeChanged

        public java.lang.String reEvaluateTableAttributeChanged(java.lang.String tablename,
                                                                java.util.HashMap newAttr,
                                                                java.util.HashMap oldAttr,
                                                                java.lang.String upgradeDir)
                                                         throws java.lang.Exception
        For table attributes, look through the metadata for maxattributecfg (old and new) and determine the proper value for maxattributecfg changed.

        This method is used by the Configure UI and the Upgrade.

        For a description of the values for the "changed" attribute, see MaxAttributeCfg.

        Parameters:
        tablename - The table name
        newAttr - The new attribute. Cannot be null or empty. If deleting the attribute, this must have "CHANGED" equal to "R". For the format of this param, see getAttributeMeta.
        oldAttr - The old attribute. Can be null or empty only if a new attribute is being added. For the format of this param, see getAttributeMeta.
        upgradeDir - This is non-null ONLY when this method is called during the upgrade by TableElement or ColumnElement. It is the subdirectory used by custom classes. When called via the Config UI this MUST be null.
        Returns:
        The new value for maxattributecfg changed. (This does not update the database!)
        Throws:
        java.lang.Exception
        See Also:
        Util.canAlterTable(java.lang.String, java.util.HashMap, java.util.HashMap, java.lang.String)
      • reEvaluateViewAttributeChanged

        public java.lang.String reEvaluateViewAttributeChanged(java.lang.String viewname,
                                                               java.util.HashMap newAttr,
                                                               java.util.HashMap oldAttr,
                                                               java.lang.String upgradeDir)
                                                        throws java.lang.Exception
        For view attributes, look through the metadata for maxattributecfg (old and new) and determine the proper value for maxattributecfg changed.

        This method is used by the Configure UI and the Upgrade.

        For a description of the values for the "changed" attribute, see MaxAttributeCfg.

        Parameters:
        viewname - The view name
        newAttr - The new attribute. Cannot be null or empty. If deleting the attribute, this must have "CHANGED" equal to "R". For the format of this param, see getAttributeMeta.
        oldAttr - The old attribute. Can be null or empty only if a new attribute is being added. For the format of this param, see getAttributeMeta.
        upgradeDir - This is non-null ONLY when this method is called during the upgrade by TableElement or ColumnElement. It is the subdirectory used by custom classes. When called via the Config UI this MUST be null.
        Returns:
        The new value for maxattributecfg changed. (This does not update the database!)
        Throws:
        java.lang.Exception
      • canAlterTable

        public boolean canAlterTable(java.lang.String tablename,
                                     java.util.HashMap newAttr,
                                     java.util.HashMap oldAttr,
                                     java.lang.String upgradeDir)
                              throws java.lang.Exception
        Given that one attribute is being added, modified or dropped, and we're not adding or dropping the entire table, this method identifies whether that change can be done in ConfigDB via an "alter table" statement. This method does the check based on one attribute only. If multiple attributes are being changed, then if ANY of them requires that the table be rebuilt, it must be rebuilt.

        This method does not analyze the applicability of the native "alter" statement in isolation. It is used to determine whether the ConfigDB program is able to issue "alter table." ConfigDB in some cases may do preparatory work before invoking "alter", such as dropping a default in SqlServer, etc.

        Programmer's note: If the logic in buildDefaultDataStatement changes, it may be necessary to change this method as well. For example, currently, YORN columns default to N even if "nullwithdefault" is No. These two methods have to be in synch.

        Parameters:
        tablename - The table name.
        newAttr - The new attribute (from maxattributecfg). If the attribute is being dropped, this can be null or empty or have "CHANGED" = "R". For the format of this param, see getAttributeMeta.
        oldAttr - The current attribute (from maxattribute). If the attribute is being added, this parameter will be null or empty. For the format of this param, see getAttributeMeta.
        upgradeDir - This is non-null ONLY when this method is called during the upgrade by TableElement or ColumnElement. It is the subdirectory used by custom classes. If adding or changing a non-nullable column, and no default value is provided in the metadata, and it is not a YORN or numeric column, then this method will call upgradeDefaultExists to see whether a custom class provides a default value for that column. When called via the Config UI this MUST be null.
        Returns:
        True if the change can be done via "alter table." False if the table must be rebuilt.
        Throws:
        java.lang.Exception
        See Also:
        Util.canAlterForLengthChange(java.lang.String, java.lang.String, int, int), Util.getDefaultString(String,String,String,String,String,String,int,int,int,int,int,boolean,boolean)
      • canAlterForLengthChange

        public boolean canAlterForLengthChange(java.lang.String tablename,
                                               java.lang.String columnname,
                                               int oldLength,
                                               int newLength)
                                        throws java.lang.Exception
        Called from canAlterTable to determine whether table can be altered for a column length change. This takes into account ONLY the length change.
        Parameters:
        tablename - Table name
        columnname - Column name
        oldLength - Old column length
        newLength - New column length
        Returns:
        True if table can be altered for length change, else False (to rebuild table)
        Throws:
        java.lang.Exception
      • upgradeDefaultExists

        public boolean upgradeDefaultExists(java.lang.String tbname,
                                            java.lang.String name,
                                            java.lang.String upgradeDir)
                                     throws java.lang.Exception
        If this is the upgrade process (upgradeDir is not null), this method identifies whether the upgrade provides a default value for the specified column. This is determined by the presence of an extension of UpgDefaultsTemplate. The name of the class must be "UpgDefaults" + tbname, and it must reside in the upgradeDir. If it returns True for columnHasDefault then the column has an upgrade default.
        Parameters:
        tbname - Table name
        name - Column name
        upgradeDir - The subdirectory where custom classes reside for the original maxupg that is being upgraded from.
        Returns:
        True if an upgrade class provides a default for this column, else False. This is the value returned from columnHasDefault. It is not necessary to provide upgrade defaults for columns that would get a default anyhow, such as YORN columns that default to No, or numeric columns that default to 0.
        Throws:
        java.lang.Exception
      • implicitConversionSupported

        public boolean implicitConversionSupported(java.lang.String newType,
                                                   java.lang.String oldType)
                                            throws java.lang.Exception
        Identifies whether implicit datatype conversion is supported for SqlServer datatype change. This evaluates only the native SqlServer and DB2 datatypes that are used by ConfigDB.
        Parameters:
        newType - The new native SqlServer datatype (from getNativeType).
        oldType - The old native SqlServer datatype (from getNativeType).
        Returns:
        True if implicit conversion is supported, else False. For Oracle, always returns True.
        Throws:
        java.lang.Exception
      • explicitConversionSupported

        public boolean explicitConversionSupported(java.lang.String newType,
                                                   java.lang.String oldType)
                                            throws java.lang.Exception
        Identifies whether explicit datatype conversion is supported for SqlServer or DB2 datatype change. This evaluates only the native SqlServer and DB2 datatypes that are used by ConfigDB.
        Parameters:
        newType - The new native datatype (from getNativeType).
        oldType - The old native datatype (from getNativeType).
        Returns:
        True if explicit conversion is supported, else False For Oracle, always returns True.
        Throws:
        java.lang.Exception
        See Also:
        Util.implicitConversionSupported(java.lang.String, java.lang.String)
      • tableIsEmpty

        public boolean tableIsEmpty(java.lang.String tbname)
                             throws java.lang.Exception
        Identifies whether there are any rows on this table.
        Parameters:
        tbname - Table name.
        Returns:
        True if the table is empty, else False
        Throws:
        java.lang.Exception
      • columnIsEmpty

        public boolean columnIsEmpty(java.lang.String tbname,
                                     java.lang.String name)
                              throws java.lang.Exception
        Identifies whether all rows for this table have null values for this column.
        Parameters:
        tbname - Table name.
        name - Column name.
        Returns:
        True if they are all null, else False
        Throws:
        java.lang.Exception
      • nullValueExists

        public boolean nullValueExists(java.lang.String tbname,
                                       java.lang.String name)
                                throws java.lang.Exception
        Identifies whether any row for this table has null value for this column.
        Parameters:
        tbname - Table name.
        name - Column name.
        Returns:
        True if any (one or more) is null, else False
        Throws:
        java.lang.Exception
      • getMaxColumnLength

        public int getMaxColumnLength(java.lang.String tbname,
                                      java.lang.String name)
                               throws java.lang.Exception
        Get the maximum actual data length for this column. This will be less than or equal to the defined length of the column. Oracle and DB2 use the "length" function, SqlServer uses the "len" function.
        Parameters:
        tbname - Table name.
        name - Column name.
        Returns:
        Maximum actual data length.
        Throws:
        java.lang.Exception
      • getMaxColno

        public int getMaxColno(java.lang.String objectname,
                               boolean getCfg,
                               java.lang.String where)
                        throws java.lang.Exception
        Get the maximum value of "attributeno" from the metadata for this object. The method getAttributeMeta could also be used, but this is a simpler method if the only attribute needed is max(attributeno).
        Parameters:
        objectname - Object name.
        getCfg - If true, gets max(attributeno) from the configuration object (maxattributecfg), else gets from maxattribute.
        where - The Where clause for the select statement (not beginning with "where" or "and"). This is optional. If null, the method gets the max(attributeno) for the object, with no other conditions.
        Returns:
        Maximum value of "attributeno" for this object.
        Throws:
        java.lang.Exception
      • getMaxLengthColumnInIndex

        public int getMaxLengthColumnInIndex()
        Get the maximum allowed for the length of any one column in an index. This value depends on the native db platform.
        Returns:
        The maximum allowed for the length of any one column in an index. If there is no maximum, this will return 999999.
      • getMaxLengthIndex

        public int getMaxLengthIndex()
        Get the maximum allowed for the sum of lengths of all columns in an index. This value depends on the native db platform.
        Returns:
        The maximum allowed for the sum of lengths of all columns in an index. If there is no maximum, this will return 999999.
      • getMaxVarcharLength

        public int getMaxVarcharLength()
        Get the maximum allowed for the length a varchar column. This value depends on the native db platform.
        Returns:
        The maximum allowed for the length of a varchar column.
      • setVarcharMultiple

        public void setVarcharMultiple(int val)
        This is used when the native length of a varchar column should be adjusted by some multiple of the length defined on maxattribute and the value cannot be loaded via the constructor (e.g. from Maxinst). The multiple defaults to 1, so this method would be called only in special conditions related to multi-language. The value is stored as a maxvar named "VARCHARMULTIPLE" and in practice can have a value between 1 and 4.
        Parameters:
        val - Varchar multiple
      • getVarcharMultiple

        public int getVarcharMultiple()
        Return the value of varchar multiple.
        Returns:
        Value of varcharMultiple.
      • setVargraphic

        public void setVargraphic(boolean val)
        This is used in DB2 platform when native datatype "vargraphic" should be used instead of "varchar". This defaults to false, so this method would be called only in special conditions related to multi-language. The value is stored as a maxvar named "USEVARGRAPHIC".
        Parameters:
        val - Vargraphic (true or false)
      • useVargraphic

        public boolean useVargraphic()
        Return the value of useVargraphic.
        Returns:
        Value of useVargraphic.
      • getInternalSiteOrgType

        public java.lang.String getInternalSiteOrgType(java.lang.String externalSiteOrgType)
                                                throws java.sql.SQLException
        Given the external value of siteorgtype, return the internal value from synonymdomain table. This method should not be called from Mbos because they should be using the Translate class.
        Parameters:
        externalSiteOrgType -
        Returns:
        Internal SiteOrgType from synonymdomain.
        Throws:
        java.sql.SQLException
        See Also:
        Util.siteOrgTypes
      • getInternalSearchType

        public java.lang.String getInternalSearchType(java.lang.String externalSearchType)
                                               throws java.sql.SQLException
        Given the external value of searchtype, return the internal value from synonymdomain table. This method should not be called from Mbos because they should be using the Translate class.
        Parameters:
        externalSearchType -
        Returns:
        Internal SearchType from synonymdomain.
        Throws:
        java.sql.SQLException
      • isLocAllowed

        public boolean isLocAllowed(java.lang.String objectName,
                                    java.lang.String attributeName,
                                    java.util.HashMap attrInfo,
                                    java.util.HashMap sameasAtrInfo)
                             throws java.lang.Exception
        Identifies whether "localizable" allowed to be True for the specified attribute.
        Parameters:
        objectName - Object name
        attributeName - Attribute name
        attrInfo - Attribute info from getAttributeMeta. This is optional. If null, the method will look in the database (MaxAttributeCfg).
        sameasAtrInfo - Attribute info from getAttributeMeta for the sameas attribute (if any). This is optional. If null, the method will look in the database (MaxAttributeCfg).
        Returns:
        True if "localizable" is permitted to be True for this attribute.
        Throws:
        java.lang.Exception
        See Also:
        MaxAttributeCfg.getHashMap(), Util.getAttributeMeta(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String)
      • getLocDefault

        public boolean getLocDefault(java.lang.String objectName,
                                     java.lang.String attributeName,
                                     java.util.HashMap attrInfo,
                                     java.util.HashMap sameasAttrInfo)
                              throws java.lang.Exception
        Identifies the default value for "localizable" for the specified attribute.
        Parameters:
        objectName - Object name
        attributeName - Attribute name
        attrInfo - Attribute info from getAttributeMeta. This is optional. If null, the method will look in the database (MaxAttributeCfg).
        sameasAtrInfo - Attribute info from getAttributeMeta for the sameas attribute (if any). This is optional. If null, the method will look in the database (MaxAttributeCfg).
        Returns:
        Default value for "localizable".
        Throws:
        java.lang.Exception
        See Also:
        MaxAttributeCfg.getHashMap(), Util.getAttributeMeta(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String)
      • nameInList

        public boolean nameInList(java.lang.String name,
                                  java.lang.String list)
        Does the name exist in the list? Called from getColumnNames.
        Parameters:
        name - Name to search for in the list
        list - Comma-delimited list of names in which to search for the first param. The comma may or may not have a space following it (the test does a trim).
        Returns:
        True if name is in the list, else False
      • selectString

        public java.lang.String selectString(java.lang.String sql)
                                      throws java.lang.Exception
        General purpose utility to select one String value from database.
        Parameters:
        sql - The sql to be executed by this method to test if any rows found. Must be a select statement that selects one String column!
        Returns:
        The value for the first row found (if any), else null.
        Throws:
        java.lang.Exception
      • rowFound

        public boolean rowFound(java.lang.String sql)
                         throws java.lang.Exception
        General purpose utility to test whether something exists.
        Parameters:
        sql - The sql to be executed by this method to test if any rows found. Must be a select statement!
        Returns:
        True if any rows found, else False
        Throws:
        java.lang.Exception
      • changeTreeKey

        public java.util.TreeMap changeTreeKey(java.util.TreeMap oldMap,
                                               java.lang.String keyAttr)
                                        throws java.lang.Exception
        Given a TreeMap of metadata, output a new TreeMap that is the same except for its key. The attribute name to use for the new key is identified by a parameter (keyAttr).

        The main intended use for this is to allow a TreeMap of columns to be output with a new key, which typically will be the value of either ATTRIBUTENO or ATTRIBUTENAME.

        If the current key starts with $ then do not change it.

        For the regular TreeMap formats, see getAttributeMeta, getObjectMeta, and getIndexMeta.

        Parameters:
        oldMap - The old map.
        keyAttr - The name of the attribute to use as the key in the new map.
        Returns:
        The same map as input, but with a different key so that an Iterator can return entries in a different sequence.
        Throws:
        java.lang.Exception
      • setConnection

        public void setConnection(java.sql.Connection connection)
                           throws java.lang.Exception
        Set the database connection con, used for retrieving data.
        Parameters:
        connection - The database connection.
        Throws:
        java.lang.Exception
        See Also:
        Util.con, Util.dbIn
      • setPrintStream

        public void setPrintStream(java.io.PrintStream outstream)
                            throws java.lang.Exception
        Set the output print stream out.
        Parameters:
        outstream - Output print stream.
        Throws:
        java.lang.Exception
      • setDB2tsPreferSysproc

        public void setDB2tsPreferSysproc(boolean val)
        Set the preference for SYSPROC.TS vs "db2ts" CLP commands.
        Parameters:
        val - True if executing commands on local database via java; False when generating a separate script for DB2 Text commands.
      • setDBOut

        public void setDBOut(int platform)
        Identify how output should be formatted. This needs to be called ONLY if the output should be a different platform than the connection established in the constructor. Sets value of dbOut.
        Parameters:
        platform - Valid values are in UpgConstants: ORACLE, SQLSERVER, or DB2.
        See Also:
        Util.dbOut
      • mxServerIsUp

        public boolean mxServerIsUp(java.lang.String serverName)
                             throws java.lang.Exception
        Determine whether MXServer is running. This can be used to ensure that MXServer is down before running various processes. It checks maxsession servertimestamp, which is normally incremented every 1 minute. Therefore, you must wait up to 1 minute after shutting down MXServer before this method will perceive that it is down. (This interval is defined in serverTimeStampUpdateRate.)

        The method lockMaximoTables can be used to lock tables.

        Parameters:
        serverName - If just checking a particular instance of MXServer, this is the servername to check for. To check for any instance of MXServer on this database, this param should be null.
        Returns:
        True if MXServer is up, else False.
        Throws:
        java.lang.Exception
      • configInProcess

        public boolean configInProcess()
                                throws java.lang.Exception
        Determine whether configuration is currently in process (ConfigDB and RestoreFromBackup).
        Returns:
        True if configuration is in process.
        Throws:
        java.lang.Exception
      • setConfigInProcess

        public java.lang.String setConfigInProcess(boolean inProcess)
                                            throws java.lang.Exception
        Return Sql for setting Config in process (maxvar CONFIGURING).
        Returns:
        True if configuration is in process.
        Throws:
        java.lang.Exception
      • createStatement

        public java.sql.Statement createStatement()
                                           throws java.sql.SQLException
        Return a Statement created with the appropriate parameters for this platform.
        Returns:
        Statement
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                                    throws java.sql.SQLException
        Return a prepared Statement created with the appropriate parameters for this platform.
        Returns:
        Statement
        Throws:
        java.sql.SQLException
      • getNextSequenceValueForSqlServer

        public java.lang.String getNextSequenceValueForSqlServer(java.lang.String seqName)
                                                          throws java.lang.Exception
        This method gets the next value from maxsequence and updates maxsequence. This actually performs the update maxsequence on the database before returning the new value.
        Parameters:
        seqName - The name of the sequence
        Returns:
        The next value, which can be used in an Insert statement.
        Throws:
        java.lang.Exception
      • updateDMSource

        public java.util.List updateDMSource()
                                      throws java.lang.Exception
        Return sql to update Deployment Manager tables with new source value.
        Returns:
        Sql
        Throws:
        java.lang.Exception
      • getDatabaseName

        public java.lang.String getDatabaseName()
                                         throws java.lang.Exception
        Get the database name from system tables depending on database type. This is called from updateDMSource, not from ConfigDB.
        Returns:
        database name
        Throws:
        java.lang.Exception
      • getSchemaName

        public java.lang.String getSchemaName()
                                       throws java.lang.Exception
        Get the schema name from system tables depending on database type. This is called from updateDMSource, not from ConfigDB.
        Returns:
        schema name
        Throws:
        java.lang.Exception
        See Also:
        Util.getCurrentNativeSchema()
      • getDBHostName

        public java.lang.String getDBHostName()
                                       throws java.lang.Exception
        Get the host name where database is installed from system tables depending on database type. This is called from updateDMSource, not from ConfigDB.
        Returns:
        host name
        Throws:
        java.lang.Exception
      • getFileText

        public static java.lang.String getFileText(java.io.InputStream fileStrm)
                                            throws java.io.IOException
        Get the content of the file
        Parameters:
        fileStrm -
        Returns:
        content of the file in string
        Throws:
        java.io.IOException
      • enableForMultiTenancy

        public java.util.ArrayList enableForMultiTenancy(java.lang.String tabName,
                                                         java.lang.String uniqueName,
                                                         java.lang.String userName,
                                                         java.lang.String adminUser,
                                                         MTStorageType storageType)
                                                  throws java.lang.Exception
        Rebuild triggers as secure, and activae row level control for all tables
        Throws:
        java.lang.Exception
      • addTenantidToTable

        public java.util.ArrayList addTenantidToTable(java.lang.String tabName,
                                                      MTStorageType storageType)
                                               throws java.lang.Exception
        Adds tenantid to table based on storagtype
        Throws:
        java.lang.Exception
      • changeStorageType

        public java.util.ArrayList changeStorageType(java.lang.String tabName,
                                                     java.lang.String uniqueName,
                                                     MTStorageType oldType,
                                                     MTStorageType newType,
                                                     java.lang.String userName,
                                                     java.lang.String adminUser,
                                                     boolean isInternal)
                                              throws java.lang.Exception
        Rebuild triggers as secure, and activae row level control for all tables
        Throws:
        java.lang.Exception
      • disableMTPermission

        public java.util.ArrayList disableMTPermission(java.lang.String tabName,
                                                       MTStorageType storageType)
        deactivate row level control for a table
      • createPermission

        public java.util.List createPermission(java.lang.String tabName,
                                               java.lang.String uniqueName,
                                               java.lang.String newTenantUser,
                                               java.lang.String landlordUser,
                                               MTStorageType type)
                                        throws java.lang.Exception
        Create permissions for Multitenancy
        Parameters:
        tabName - Name of the table to create permission for.
        uniqueName - The name of the Unique ID column in the table.
        userName - The name of the Master user.
        type - Extended storage type, not directly same as MaxTable.StorageType
        Throws:
        java.lang.Exception
      • createPermission

        public java.util.List createPermission(java.lang.String tabName,
                                               java.lang.String uniqueName,
                                               java.lang.String newTenantUser,
                                               java.lang.String landlordUser,
                                               MTStorageType type,
                                               boolean addProcessUser)
                                        throws java.lang.Exception
        Create permissions for Multitenancy
        Parameters:
        tabName - Name of the table to create permission for.
        uniqueName - The name of the Unique ID column in the table.
        userName - The name of the Master user.
        type - Extended storage type, not directly same as MaxTable.StorageType
        Throws:
        java.lang.Exception
      • rebuildProcessUserVariable

        public java.util.List rebuildProcessUserVariable(java.lang.String adminUser)
                                                  throws java.lang.Exception
        Rebuilds variable GV_MTPRCUSR for new user
        Parameters:
        adminUser - User name
        Throws:
        java.lang.Exception
      • rebuildPermissions

        public void rebuildPermissions(java.lang.String processUser)
                                throws java.lang.Exception
        Rebuild triggers as secure, and activate row level control for all tables
        Throws:
        java.lang.Exception
      • createTenantidTriggeres

        public java.util.List createTenantidTriggeres(java.lang.String tbname,
                                                      MTStorageType storageType,
                                                      boolean secureRowlevelTriggers,
                                                      boolean dropInsert,
                                                      boolean dropUpdateDelete,
                                                      boolean createDeltaTriggers)
                                               throws java.lang.Exception
        For DB2, the trigger names are tbname + "_M", tbname + "_D" and tbname + "_E".
        Parameters:
        tbname - Table name
        storageType -
        secureRowlevelTriggers -
        dropInsert - Checks for an existing M trigger, dropping it if it exists. This parameter can only be false if it's known there can't be such an index.
        dropUpdateDelete - Checks for existing E & D triggers, dropping them if they exist. This parameter should only be false if it's know there can't be such indexes.
        Throws:
        java.lang.Exception
      • dropDeltaTriggers

        public java.util.ArrayList dropDeltaTriggers()
                                              throws java.lang.Exception
        Rebuild triggers as secure, and activae row level control for all tables
        Throws:
        java.lang.Exception
      • getDeltaTriggerSql

        public java.util.List getDeltaTriggerSql(java.lang.String tbname)
                                          throws java.lang.Exception
        Rebuild triggers as secure, and activate row level control for all tables. This wil affect all tables with Delta StorageType with a defined Maximo Primary key.
        Throws:
        java.lang.Exception
      • getSequences

        public java.util.HashMap getSequences(java.lang.String tableName)
                                       throws java.lang.Exception
        Cache the sequences for later use in createSequences.
        Throws:
        java.lang.Exception
      • createSqlServerSequences

        public void createSqlServerSequences(boolean dropOnly)
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • createOneSqlServerSequences

        public void createOneSqlServerSequences(java.lang.String sequenceName,
                                                java.lang.String tableName,
                                                java.lang.String columnName,
                                                int seqIncInt)
                                         throws java.lang.Exception
        Cache the sequences for later use in createSequences.
        Throws:
        java.lang.Exception
      • fixSqlServerSequence

        public void fixSqlServerSequence()
                                  throws java.lang.Exception
        Cache the sequences for later use in createSequences.
        Throws:
        java.lang.Exception
      • fixSqlServerSequence

        public void fixSqlServerSequence(java.lang.String whereClause)
                                  throws java.lang.Exception
        Cache the sequences for later use in createSequences.
        Throws:
        java.lang.Exception
      • createMaxsequenceTrigger

        public void createMaxsequenceTrigger()
                                      throws java.lang.Exception
        For DB2, the trigger names are tbname + "_M", tbname + "_D" and tbname + "_E".
        Parameters:
        tbname - Table name
        storageType -
        secureRowlevelTriggers -
        dropInsert - Checks for an existing M trigger, dropping it if it exists. This parameter can only be false if it's known there can't be such an index.
        dropUpdateDelete - Checks for existing E & D triggers, dropping them if they exist. This parameter should only be false if it's know there can't be such indexes.
        Throws:
        java.lang.Exception
      • getColumnNamesForExtendedView

        public java.lang.String[] getColumnNamesForExtendedView(java.util.TreeMap tableCols,
                                                                java.lang.String tableName,
                                                                java.util.Map extendedTables,
                                                                java.lang.String uniqueColumnName,
                                                                java.lang.String isView,
                                                                boolean mtEnabled)
                                                         throws java.lang.Exception
        For a table, output the persistent column names (lower case) delimited by commas. The columns are retrieved from the metadata supplied in the tableCols parameter. This is useful for building various kinds of Sql statements. It is also useful for building the colNameList parameter in buildDefaultDataStatement, buildSelectStatement, buildInsertStatementPrefix, and for this very method.

        This method will NOT output columns that are "handle" columns used for DB2 text search. These columns must be created via db2ts (see enableRichTextSearch).

        Parameters:
        tableCols - Column attributes, see getAttributeMeta.
        Throws:
        java.lang.Exception
        See Also:
        Util.isHandleColumn(java.lang.String, java.util.TreeMap)
      • getExtendedUniqueColumnForView

        public java.lang.String getExtendedUniqueColumnForView(java.lang.String viewName,
                                                               java.lang.String extTableName)
                                                        throws java.lang.Exception
        This method gets unique column name for the view and extended table name.
        Parameters:
        viewName - The name of the view
        extTableName - The name of extended table
        Returns:
        Unique Column Name.
        Throws:
        java.lang.Exception
      • isMTEnabled

        public boolean isMTEnabled()
                            throws java.sql.SQLException
        Given the name of a column on maxtablecfg, maxattributecfg, maxsysindexes, or maxsyskeys, identify whether this is a YORN attribute.
        Parameters:
        attrName - The name of the attribute (e.g. "canautonum").
        Returns:
        True if this is YORN, else False
        Throws:
        java.sql.SQLException
        See Also:
        Util.sysYORNattrs
      • getUserFromProperties

        public java.lang.String getUserFromProperties(boolean getLandlordUser)
                                               throws java.lang.Exception
        Rebuild triggers as secure, and activae row level control for all tables
        Throws:
        java.lang.Exception
      • getTenantExtAttributes

        public java.util.Map getTenantExtAttributes(java.sql.Connection conn,
                                                    java.lang.String objectName,
                                                    int tenantId)
                                             throws MXApplicationException
        Returns the attributes for the given tenant and/or object.
        Parameters:
        conn - Connection to the database.
        objectName - name of the object - table or view
        tenantId - Tenant ID #
        Returns:
        A data structure with the ObjectName->Entityname->(AttributeName,ColumnName) - ordered by attribute #
        Throws:
        MXApplicationException
      • updateViewMetaDataForExtendedAttr

        public java.util.ArrayList updateViewMetaDataForExtendedAttr(java.sql.Connection conn,
                                                                     java.lang.String objectName,
                                                                     java.lang.String viewName,
                                                                     java.util.Map extAttr,
                                                                     int tenantId)
                                                              throws MXApplicationException
        Throws:
        MXApplicationException
      • createExtensionView

        public java.util.List createExtensionView(java.lang.String objectName,
                                                  java.util.Map extendedTables,
                                                  java.sql.Connection masterCon,
                                                  int tenantId,
                                                  boolean deleteOnly,
                                                  boolean mtEnabled)
                                           throws MXException,
                                                  java.rmi.RemoteException
        Calls createTable for each extension table to be created.
        Parameters:
        objectName - Name of the object that is extended
        extendedTables - mapped information about the table
        masterCon - Not used
        tenantId - Id# of the tenant to create the view for (-1 is MT is not enabled).
        deleteOnly - Set when we only want to drop any existing extension view.
        mtEnabled - Is Multitenacy enabled?
        Throws:
        "configure" - "RemoveChangesFailure"
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.configure.Util#createTable
      • storeChangedAttributes

        public void storeChangedAttributes(java.util.HashMap changedObjects,
                                           java.util.TreeMap attrs,
                                           java.lang.String objectname)
                                    throws java.sql.SQLException
        THis method will store all attributes which were changed by System Admistrator. Resulting Map will have following structure All objects changed All attributes changed for particular object All fields which were changed for a particular object and new values as a string
        Parameters:
        attrs - map of attributes and new values
        currentAttrs - map of attributes and old values
        Throws:
        java.sql.SQLException
      • renumberExtendedAttributes

        public java.util.ArrayList renumberExtendedAttributes(int tenantId,
                                                              java.util.Map lastNumbers,
                                                              java.util.ArrayList list)
                                                       throws java.sql.SQLException,
                                                              MXException
        This method will store all attributes which were changed by System Admistrator. Resulting Map will have following structure All objects changed All attributes changed for particular object All fields which were changed for a particular object and new values as a string
        Parameters:
        attrs - map of attributes and new values
        currentAttrs - map of attributes and old values
        Throws:
        java.sql.SQLException
        MXException
      • getUpdateTenantDelta

        public java.util.ArrayList getUpdateTenantDelta(java.util.HashMap changedObjects,
                                                        int tenantId,
                                                        java.util.TreeMap cfgAttrs,
                                                        java.util.Vector skipList)
                                                 throws java.sql.SQLException,
                                                        MXException
        THis method will store all attributes which were changed by System Admistrator. Resulting Map will have following structure All objects changed All attributes changed for particular object All fields which were changed for a particular object and new values as a string
        Parameters:
        attrs - map of attributes and new values
        currentAttrs - map of attributes and old values
        skipLst - each element in this list describes the tenant/object/attribute/value that's not being populated from the master. each element in this list is a parameter list that for the message to be displayed
        Throws:
        java.sql.SQLException
        MXException
      • getNextAttrNo

        public int getNextAttrNo(java.lang.String tablename)
                          throws java.lang.Exception
        Rebuild triggers as secure, and activae row level control for all tables
        Throws:
        java.lang.Exception
      • getTenantCodeMetadata

        public java.util.ArrayList getTenantCodeMetadata()
                                                  throws java.lang.Exception
        Retrieve datatype and length for TENANTCODE from maxattributecfg talbe TENANTREG
        Returns:
        List returns the TENANTCODE datatype and length
        Throws:
        java.lang.Exception
      • reorgBeforeDB2TSUpdate

        public void reorgBeforeDB2TSUpdate()
                                    throws java.lang.Exception
        Reorg tables that have DB2 TS indexes to avoid exceptions while updating TS indexes. Exceptions thrown while updating TS indexes due reorg pending do not have an specific error code and sql state. So it is necessary to check for reorg pending before performing TS index update.
        Throws:
        java.lang.Exception
      • fixSqlServerPrimaryIndex

        public void fixSqlServerPrimaryIndex()
                                      throws java.lang.Exception
        Primary index in SQL Server have to be clustered
        Throws:
        java.lang.Exception
      • getPrimaryKeys

        public java.util.Map getPrimaryKeys()
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getTextSearchIndexes

        public java.util.Map getTextSearchIndexes()
                                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • rebuildPrimaryIndex

        public java.util.ArrayList rebuildPrimaryIndex(java.lang.String tbname,
                                                       java.lang.String ixName,
                                                       java.util.List arrayNames,
                                                       java.util.List textSearchKeys)
                                                throws java.lang.Exception
        Generates sql for creating a new index with the specified column names.
        Parameters:
        tbname - Table name
        ixname - Index name
        names - Arraylist of column names to be in the index.
        Returns:
        Sql statements for creating the index (native index and Maximo metadata).
        Throws:
        java.lang.Exception
      • isPrimaryIndex

        public boolean isPrimaryIndex(java.util.List indexColumns,
                                      java.util.HashSet primaryKeys)
                               throws java.lang.Exception
        Throws:
        java.lang.Exception