org.opencms.setup.update6to7.generic
Class CmsUpdateDBProjectId

java.lang.Object
  extended by org.opencms.setup.update6to7.A_CmsUpdateDBPart
      extended by org.opencms.setup.update6to7.generic.CmsUpdateDBProjectId
All Implemented Interfaces:
I_CmsUpdateDBPart
Direct Known Subclasses:
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.

Author:
metzler

Field Summary
protected static java.lang.String COLUMN_PROJECT_ID
          Constant for the sql column PROJECT_ID.
protected static java.lang.String COLUMN_PROJECT_ID_RESOURCE_PATH
          Constant for the sql primary key of the CMS_PROJECTRESOURCES table.
protected static java.lang.String COLUMN_PROJECT_LASTMODIFIED
          Constant for the sql query to use the column PROJECT_LASTMODIFIED.
protected static java.lang.String COLUMN_PROJECT_UUID
          Constant for the sql column PROJECT_UUID.
protected static java.lang.String COLUMN_TEMP_PROJECT_UUID
          Constant for the sql column TEMP_PROJECT_UUID.
protected static java.lang.String HISTORY_PROJECTS_TABLE
          Constant for the table name of the CMS_HISTORY_PROJECTS table.
protected static java.lang.String REPLACEMENT_COLUMN
          Constant for the replacement in the SQL query for the columnname.
protected static java.lang.String REPLACEMENT_NEW_COLUMN
          Constant for the replacement in the SQL query for the new columnname.
protected static java.lang.String REPLACEMENT_OLDID
          Constant for the replacement in the SQL query for old id to update.
protected static java.lang.String REPLACEMENT_PRIMARY_KEY
          Constant for the replacement in the SQL query for the primary key.
protected static java.lang.String REPLACEMENT_TABLENAME
          Constant for the replacement in the SQL query for the tablename.
protected static java.lang.String[] RESOURCE_TABLES
          Array of the online and offline resources tables.
protected static java.util.List RESOURCES_TABLES_LIST
          Arraylist for the online and offline resources tables that shall be updated.
protected static java.lang.String[] TABLES
          Array of the tables that are to be updated.
protected static java.util.List TABLES_LIST
          Arraylist for the tables that shall be updated.
protected static java.lang.String TEMP_UUID_COLUMN
          Constant for the temporary UUID column in the tables.
protected static java.lang.String TEMPORARY_TABLE_NAME
          Constant for the name of temporary table containing the project ids and uuids.
 
Fields inherited from class org.opencms.setup.update6to7.A_CmsUpdateDBPart
m_poolData, m_queries, QUERY_PROPERTIES_PREFIX
 
Constructor Summary
CmsUpdateDBProjectId()
          Constructor.
 
Method Summary
protected  void createHistProjectsTable(CmsSetupDb dbCon)
          Creates the CMS_HISTORY_PROJECTS table if it does not exist yet.
protected  void createTempTable(CmsSetupDb dbCon)
          Creates the temp table for project ids if it does not exist yet.
protected  void internalExecute(CmsSetupDb dbCon)
          Does the hard work.
protected  void transferDataToHistoryTable(CmsSetupDb dbCon)
          Transfers the data from the CMS_BACKUP_PROJECTS to the CMS_HISTORY_PROJECTS table.
 
Methods inherited from class org.opencms.setup.update6to7.A_CmsUpdateDBPart
execute, getDbInstance, getPoolData, isKeepHistory, loadQueryProperties, readQuery, setPoolData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HISTORY_PROJECTS_TABLE

protected static final java.lang.String HISTORY_PROJECTS_TABLE
Constant for the table name of the CMS_HISTORY_PROJECTS table.

See Also:
Constant Field Values

TEMPORARY_TABLE_NAME

protected static final java.lang.String TEMPORARY_TABLE_NAME
Constant for the name of temporary table containing the project ids and uuids.

See Also:
Constant Field Values

COLUMN_PROJECT_ID

protected static final java.lang.String COLUMN_PROJECT_ID
Constant for the sql column PROJECT_ID.

See Also:
Constant Field Values

COLUMN_PROJECT_ID_RESOURCE_PATH

protected static final java.lang.String COLUMN_PROJECT_ID_RESOURCE_PATH
Constant for the sql primary key of the CMS_PROJECTRESOURCES table.

See Also:
Constant Field Values

COLUMN_PROJECT_LASTMODIFIED

protected static final java.lang.String COLUMN_PROJECT_LASTMODIFIED
Constant for the sql query to use the column PROJECT_LASTMODIFIED.

See Also:
Constant Field Values

COLUMN_PROJECT_UUID

protected static final java.lang.String COLUMN_PROJECT_UUID
Constant for the sql column PROJECT_UUID.

See Also:
Constant Field Values

COLUMN_TEMP_PROJECT_UUID

protected static final java.lang.String COLUMN_TEMP_PROJECT_UUID
Constant for the sql column TEMP_PROJECT_UUID.

See Also:
Constant Field Values

REPLACEMENT_COLUMN

protected static final java.lang.String REPLACEMENT_COLUMN
Constant for the replacement in the SQL query for the columnname.

See Also:
Constant Field Values

REPLACEMENT_NEW_COLUMN

protected static final java.lang.String REPLACEMENT_NEW_COLUMN
Constant for the replacement in the SQL query for the new columnname.

See Also:
Constant Field Values

REPLACEMENT_OLDID

protected static final java.lang.String REPLACEMENT_OLDID
Constant for the replacement in the SQL query for old id to update.

See Also:
Constant Field Values

REPLACEMENT_PRIMARY_KEY

protected static final java.lang.String REPLACEMENT_PRIMARY_KEY
Constant for the replacement in the SQL query for the primary key.

See Also:
Constant Field Values

REPLACEMENT_TABLENAME

protected static final java.lang.String REPLACEMENT_TABLENAME
Constant for the replacement in the SQL query for the tablename.

See Also:
Constant Field Values

RESOURCE_TABLES

protected static final java.lang.String[] RESOURCE_TABLES
Array of the online and offline resources tables.


RESOURCES_TABLES_LIST

protected static final java.util.List RESOURCES_TABLES_LIST
Arraylist for the online and offline resources tables that shall be updated.


TABLES

protected static final java.lang.String[] TABLES
Array of the tables that are to be updated.


TABLES_LIST

protected static final java.util.List TABLES_LIST
Arraylist for the tables that shall be updated.


TEMP_UUID_COLUMN

protected static final java.lang.String TEMP_UUID_COLUMN
Constant for the temporary UUID column in the tables.

See Also:
Constant Field Values
Constructor Detail

CmsUpdateDBProjectId

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

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

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

internalExecute

protected void internalExecute(CmsSetupDb dbCon)
                        throws java.sql.SQLException
Description copied from class: A_CmsUpdateDBPart
Does the hard work.

Specified by:
internalExecute in class A_CmsUpdateDBPart
Parameters:
dbCon - the db connection interface
Throws:
java.sql.SQLException - if somethign goes wrong
See Also:
A_CmsUpdateDBPart.internalExecute(org.opencms.setup.CmsSetupDb)

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