Class CmsUpdateDBProjectId

  • All Implemented Interfaces:
    I_CmsUpdateDBPart
    Direct Known Subclasses:
    CmsUpdateDBProjectId, CmsUpdateDBProjectId, CmsUpdateDBProjectId

    public class CmsUpdateDBProjectId
    extends A_CmsUpdateDBPart
    This class updates the project ids from integer values to CmsUUIDs in all existing database tables.

    It creates new UUIDs for each existing project and stores it into a temporary table.

    For each table using a project id a new column for the UUID is added and the according data is transferred.

    After that the original indexes and the column for the project id index is dropped and the new column with the project uuid becomes the primary key.

    Since:
    7.0.0
    • Constructor Detail

      • CmsUpdateDBProjectId

        public CmsUpdateDBProjectId()
                             throws java.io.IOException
        Constructor.

        Throws:
        java.io.IOException - if the query properties cannot be read
    • Method Detail

      • addPrimaryKey

        protected void addPrimaryKey​(CmsSetupDb dbCon,
                                     java.lang.String tablename,
                                     java.lang.String primaryKey)
                              throws java.sql.SQLException
        Adds a new primary key to the given table.

        Parameters:
        dbCon - the db connection interface
        tablename - the table to add the primary key to
        primaryKey - the new primary key
        Throws:
        java.sql.SQLException - if something goes wrong
      • addUUIDColumnToTable

        protected void addUUIDColumnToTable​(CmsSetupDb dbCon,
                                            java.lang.String tablename,
                                            java.lang.String column)
                                     throws java.sql.SQLException
        Adds the new column for the uuids to a table.

        Parameters:
        dbCon - the db connection interface
        tablename - the table to add the column to
        column - the new colum to add
        Throws:
        java.sql.SQLException - if something goes wrong
      • checkColumnTypeProjectId

        protected boolean checkColumnTypeProjectId​(int type)
        Check if the column type of the project id is incorrect.

        Parameters:
        type - the type of the column from the meta data
        Returns:
        true if the type is incorrect
      • createHistProjectsTable

        protected void createHistProjectsTable​(CmsSetupDb dbCon)
                                        throws java.sql.SQLException
        Creates the CMS_HISTORY_PROJECTS table if it does not exist yet.

        Parameters:
        dbCon - the db connection interface
        Throws:
        java.sql.SQLException - if soemthing goes wrong
      • createTempTable

        protected void createTempTable​(CmsSetupDb dbCon)
                                throws java.sql.SQLException
        Creates the temp table for project ids if it does not exist yet.

        Parameters:
        dbCon - the db connection interface
        Throws:
        java.sql.SQLException - if soemthing goes wrong
      • getColumnProjectIdResourcePath

        protected java.lang.String getColumnProjectIdResourcePath()
        Returns the columns for the primary key of the project resources table.

        Returns:
        the columns for the primary key of the project resources table
      • needsUpdating

        protected boolean needsUpdating​(CmsSetupDb dbCon,
                                        java.lang.String tablename)
                                 throws java.sql.SQLException
        Checks if the given table needs an update of the uuids.

        Parameters:
        dbCon - the db connection interface
        tablename - the table to check
        Returns:
        true if the project ids are not yet updated, false if nothing needs to be done
        Throws:
        java.sql.SQLException - if something goes wrong
      • transferDataToHistoryTable

        protected void transferDataToHistoryTable​(CmsSetupDb dbCon)
                                           throws java.sql.SQLException
        Transfers the data from the CMS_BACKUP_PROJECTS to the CMS_HISTORY_PROJECTS table.

        The datetime type for the column PROJECT_PUBLISHDATE is converted to the new long value.

        Parameters:
        dbCon - the db connection interface
        Throws:
        java.sql.SQLException - if something goes wrong