Package org.opencms.setup.db.update6to7
Class CmsUpdateDBProjectId
java.lang.Object
org.opencms.setup.db.A_CmsUpdateDBPart
org.opencms.setup.db.update6to7.CmsUpdateDBProjectId
- All Implemented Interfaces:
I_CmsUpdateDBPart
- Direct Known Subclasses:
CmsUpdateDBProjectId
,CmsUpdateDBProjectId
,CmsUpdateDBProjectId
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
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
Constant for the sql column PROJECT_ID.protected static final String
Constant for the sql query to use the column PROJECT_LASTMODIFIED.protected static final String
Constant for the sql column PROJECT_UUID.protected static final String
Constant for the sql column TEMP_PROJECT_UUID.protected static final String
Constant for the table name of the CMS_HISTORY_PROJECTS table.protected static final String
Constant for the sql query to add a new primary key.protected static final String
Constant for the sql query to add a new column to the table.protected static final String
Constant for the sql query to create the new CMS_HISTORY_PROJECTS table.protected static final String
Constant for the sql query to create the temporary table.protected static final String
Constant for the sql query to describe the given table.protected static final String
Constant for the sql query to read max publish tag.protected static final String
Constant for the replacement in the SQL query for the columnname.protected static final String
Constant for the replacement in the SQL query for the new columnname.protected static final String
Constant for the replacement in the SQL query for old id to update.protected static final String
Constant for the replacement in the SQL query for the primary key.protected static final String
Constant for the replacement in the SQL query for the tablename.protected static final String[]
Array of the online and offline resources tables.Arraylist for the online and offline resources tables that shall be updated.protected static final String[]
Array of the tables that are to be updated.Arraylist for the tables that shall be updated.protected static final String
Constant for the temporary UUID column in the tables.protected static final String
Constant for the name of temporary table containing the project ids and uuids.Fields inherited from class org.opencms.setup.db.A_CmsUpdateDBPart
m_poolData, m_queries
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addPrimaryKey
(CmsSetupDb dbCon, String tablename, String primaryKey) Adds a new primary key to the given table.protected void
addUUIDColumnToTable
(CmsSetupDb dbCon, String tablename, String column) Adds the new column for the uuids to a table.protected boolean
checkColumnTypeProjectId
(int type) Check if the column type of the project id is incorrect.protected void
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 String
Returns the columns for the primary key of the project resources table.protected void
internalExecute
(CmsSetupDb dbCon) Does the hard work.protected boolean
needsUpdating
(CmsSetupDb dbCon, String tablename) Checks if the given table needs an update of the uuids.protected void
Transfers the data from the CMS_BACKUP_PROJECTS to the CMS_HISTORY_PROJECTS table.Methods inherited from class org.opencms.setup.db.A_CmsUpdateDBPart
execute, getPoolData, getPropertyFileLocation, isKeepHistory, loadQueryProperties, readQuery
-
Field Details
-
COLUMN_PROJECT_ID
Constant for the sql column PROJECT_ID.- See Also:
-
COLUMN_PROJECT_LASTMODIFIED
Constant for the sql query to use the column PROJECT_LASTMODIFIED.- See Also:
-
COLUMN_PROJECT_UUID
Constant for the sql column PROJECT_UUID.- See Also:
-
COLUMN_TEMP_PROJECT_UUID
Constant for the sql column TEMP_PROJECT_UUID.- See Also:
-
HISTORY_PROJECTS_TABLE
Constant for the table name of the CMS_HISTORY_PROJECTS table.- See Also:
-
QUERY_ADD_PRIMARY_KEY
Constant for the sql query to add a new primary key.- See Also:
-
QUERY_ADD_TEMP_UUID_COLUMN
Constant for the sql query to add a new column to the table.- See Also:
-
QUERY_CREATE_HISTORY_PROJECTS_TABLE
Constant for the sql query to create the new CMS_HISTORY_PROJECTS table.- See Also:
-
QUERY_CREATE_TEMP_TABLE_UUIDS
Constant for the sql query to create the temporary table.- See Also:
-
QUERY_DESCRIBE_TABLE
Constant for the sql query to describe the given table.- See Also:
-
QUERY_READ_MAX_PUBTAG
Constant for the sql query to read max publish tag.- See Also:
-
REPLACEMENT_COLUMN
Constant for the replacement in the SQL query for the columnname.- See Also:
-
REPLACEMENT_NEW_COLUMN
Constant for the replacement in the SQL query for the new columnname.- See Also:
-
REPLACEMENT_OLDID
Constant for the replacement in the SQL query for old id to update.- See Also:
-
REPLACEMENT_PRIMARY_KEY
Constant for the replacement in the SQL query for the primary key.- See Also:
-
REPLACEMENT_TABLENAME
Constant for the replacement in the SQL query for the tablename.- See Also:
-
RESOURCE_TABLES
Array of the online and offline resources tables. -
RESOURCES_TABLES_LIST
Arraylist for the online and offline resources tables that shall be updated. -
TABLES
Array of the tables that are to be updated. -
TABLES_LIST
Arraylist for the tables that shall be updated. -
TEMP_UUID_COLUMN
Constant for the temporary UUID column in the tables.- See Also:
-
TEMPORARY_TABLE_NAME
Constant for the name of temporary table containing the project ids and uuids.- See Also:
-
-
Constructor Details
-
CmsUpdateDBProjectId
Constructor.- Throws:
IOException
- if the query properties cannot be read
-
-
Method Details
-
addPrimaryKey
protected void addPrimaryKey(CmsSetupDb dbCon, String tablename, String primaryKey) throws SQLException Adds a new primary key to the given table.- Parameters:
dbCon
- the db connection interfacetablename
- the table to add the primary key toprimaryKey
- the new primary key- Throws:
SQLException
- if something goes wrong
-
addUUIDColumnToTable
protected void addUUIDColumnToTable(CmsSetupDb dbCon, String tablename, String column) throws SQLException Adds the new column for the uuids to a table.- Parameters:
dbCon
- the db connection interfacetablename
- the table to add the column tocolumn
- the new colum to add- Throws:
SQLException
- if something goes wrong
-
checkColumnTypeProjectId
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
Creates the CMS_HISTORY_PROJECTS table if it does not exist yet.- Parameters:
dbCon
- the db connection interface- Throws:
SQLException
- if soemthing goes wrong
-
createTempTable
Creates the temp table for project ids if it does not exist yet.- Parameters:
dbCon
- the db connection interface- Throws:
SQLException
- if soemthing goes wrong
-
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
-
internalExecute
Description copied from class:A_CmsUpdateDBPart
Does the hard work.- Specified by:
internalExecute
in classA_CmsUpdateDBPart
- Parameters:
dbCon
- the db connection interface- Throws:
SQLException
- if something goes wrong- See Also:
-
needsUpdating
Checks if the given table needs an update of the uuids.- Parameters:
dbCon
- the db connection interfacetablename
- the table to check- Returns:
- true if the project ids are not yet updated, false if nothing needs to be done
- Throws:
SQLException
- if something goes wrong
-
transferDataToHistoryTable
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:
SQLException
- if something goes wrong
-