public class CreateSqlTableComponent extends AbstractLogEnabled implements Component, Serviceable
Constructor and Description |
---|
CreateSqlTableComponent() |
Modifier and Type | Method and Description |
---|---|
protected void |
_executeQueryFromlistQuery(List<String> listQuery)
Execute query list
|
private int |
_getNbTable() |
protected void |
addAdditionnalContentMetadata(MetadataDefinitionHolder metadataDef,
StringBuilder currentCreateTableSQLQuery,
String tableName)
Add additionnal metadata for content (title, type, language, creator, creationDate, ....)
|
protected void |
addColumnForBooleanMetadata(StringBuilder currentCreateTableSQLQuery,
String columnName,
String tableName)
Add column for Boolean metadata
|
protected void |
addColumnForCompositeMetadata(MetadataDefinitionHolder metadataDef,
StringBuilder currentCreateTableSQLQuery,
String tableName,
String columnNamePrefix)
Add all the column for each metadata in the composite
|
private void |
addColumnForContentMetadata(StringBuilder currentCreateTableSQLQuery,
String columnName,
String tableName)
Add column for content metadata
|
protected void |
addColumnForDateMetadata(StringBuilder currentCreateTableSQLQuery,
String columnName,
String tableName)
Add column for Date metadata
|
protected void |
addColumnForDateTimeMetadata(StringBuilder currentCreateTableSQLQuery,
String columnName,
String tableName)
Add column for DateTime metadata
|
protected void |
addColumnForDoubleMetadata(StringBuilder currentCreateTableSQLQuery,
String columnName,
String tableName)
Add column for Double metadata
|
protected void |
addColumnForEnumStringMetadata(StringBuilder currentCreateTableSQLQuery,
String columnName,
String tableName)
Add column for enumerator metadata
|
protected void |
addColumnForLongMetadata(StringBuilder currentCreateTableSQLQuery,
String columnName,
String tableName)
Add column for Long metadata
|
protected void |
addColumnForMetadata(MetadataDefinition metadataDef,
StringBuilder currentCreateTableSQLQuery,
String tableName,
String columnNamePrefix)
Add column for the metadata (multiple or single)
|
protected void |
addColumnForRichTextMetadata(StringBuilder currentCreateTableSQLQuery,
String columnName,
String tableName)
Add column for rich Text
|
protected void |
addColumnForSingleMetadata(MetadataDefinition metadataDef,
StringBuilder currentCreateTableSQLQuery,
String tableName,
String columnName)
Add column for single metadata
|
protected void |
addColumnForStringMetadata(StringBuilder currentCreateTableSQLQuery,
String columnName,
String tableName)
Add column for String metadata
|
protected void |
addColumnForUserMetadata(StringBuilder currentCreateTableSQLQuery,
String columnName,
String tableName)
Add column for User metadata
|
protected void |
addColumnParentId(StringBuilder currentCreateTableSQLQuery,
String tableParentName,
String tableName)
Add an id column which refer to another table
|
protected void |
addColumnsForBinaryMetadata(StringBuilder currentCreateTableSQLQuery,
String initialColumnName,
String tableName,
String comment)
Add columns for binary metadata
|
protected void |
addColumnsForFileMetadata(StringBuilder currentCreateTableSQLQuery,
String initialColumnName,
String tableName,
String comment)
Add columns for file metadata
|
protected void |
addColumnsForGeocodeMetadata(StringBuilder currentCreateTableSQLQuery,
String initialColumnName,
String tableName,
String comment)
Add columns for geocode metadata
|
protected void |
addColumnsForMultilingualStringMetadata(StringBuilder currentCreateTableSQLQuery,
String initialColumnName,
String tableName,
String comment)
Add columns for multilangual string metadata (one for each language)
|
protected void |
addSortColumn(StringBuilder currentCreateTableSQLQuery,
String tableName)
Add a column to sort
|
protected String |
convertMetadataTypeToSql(String metadataType)
Return the sql type depends on the metadata and the database type
|
protected String |
createCommentQuery(String table,
String column,
String comments)
Create the query to add comment to a table or a column
|
protected void |
createContentTable()
Create table for metadata content
|
protected String |
createEngineQuery()
Create the query to add engine
|
protected String |
createForeignKeyQuery(String fkName,
String tableName,
String columnName)
Create the query to add foreign key
|
protected void |
createMappingNameTableSql()
Create the two table mapping (for table name and column name)
|
protected String |
createPrimaryKeyQuery()
Create the query to add primary key
|
protected void |
createRichTextDataTable()
Create table for images in rich text
|
protected void |
createSqlQueriesForTableCreation(MetadataDefinitionHolder metadataDef,
String tableName,
String tableParentName,
String comment,
boolean isSortTable)
Create SQL queries to create necessary SQL tables for content type export
|
protected void |
createSqlQueryForMultipleMetadata(MetadataDefinition metadataDef,
String tableParentName,
String tableName)
Create table for a multiple metadata
|
Map<String,ExportTableInfo> |
createSqlTables(ExportConfiguration exportConfiguration)
Create sql tables for contents
|
protected void |
createTableForEnumerator(MetadataDefinition metadataDef,
String tableParentName,
String tableName,
String columnName,
StringBuilder currentCreateTableSQLQuery)
Create the table for the enumerator (key, value)
|
protected void |
createTablesInfos(Map<String,String> contents)
Created all tables informations
|
protected void |
executeSqlQueries()
Execute SQL queries
|
protected void |
fillMappingTableSql(String mappingTableName,
String mappingColumnName)
Fill the two mapping table (for table name and column name)
|
protected void |
fillTableForEnumerator(MetadataDefinition metadataDef,
String tableName)
Fill values for the enumerator table
|
protected PreparedStatement |
getInsertPreparedStatementFromTableName(String tableName)
Prepare INSERT statement
|
protected void |
initialize(String productVersion)
Initialization
|
void |
service(ServiceManager manager) |
getLogger, setLogger
public static final String DEFAULT_LANGUAGE_CODE_FOR_COMMENTS
public static final String MYSQL_CONTENT_EXPORT_ENGINE
public static final String MYSQL_CONTENT_EXPORT_CHARSET
public static final String COLUMN_PARENT_TABLE_PREFIX
private static final Pattern _MYSQL_VERSION_NUMBER_EXTRACT
protected ContentTypeExtensionPoint _contentTypeExtensionPoint
protected I18nUtils _i18nTranslator
protected NormalizeNameComponent _normalizeNameComponent
protected LanguagesManager _languageManager
private Connection _connection
private String _databaseType
private LinkedHashMap<String,ExportTableInfo> _tablesInfos
private int _commentTableMaxLength
private int _commentColumnMaxLength
private String _sqlTablePrefix
private String _sqlPrefixConf
private String _mappingPolicy
private ArrayList<String> _mappingTablesQueries
private boolean _exportNoMultiValuedTable
private int _fkIndice
private int _pkIndice
public CreateSqlTableComponent()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public Map<String,ExportTableInfo> createSqlTables(ExportConfiguration exportConfiguration) throws SQLException, ContextException, IOException
exportConfiguration
- the content export configurationSQLException
- if a sql error occurredContextException
- if a context error occurredIOException
- if an IO error occurredprotected void initialize(String productVersion)
productVersion
- The database product versionprotected void createTablesInfos(Map<String,String> contents) throws SQLException, ContextException
contents
- to exportSQLException
- if a sql error occurredContextException
- if a context error occurredprotected void createSqlQueriesForTableCreation(MetadataDefinitionHolder metadataDef, String tableName, String tableParentName, String comment, boolean isSortTable) throws ContextException
metadataDef
- the metadata definition model The component holding metadata definitionstableName
- the table name The SQL table nametableParentName
- The SQL parent table namecomment
- the commentisSortTable
- true if table's rows have to be orderedContextException
- if a context error occurredprotected void createSqlQueryForMultipleMetadata(MetadataDefinition metadataDef, String tableParentName, String tableName) throws ContextException
metadataDef
- the metadata definition modeltableParentName
- the table parent nametableName
- the table nameContextException
- if a context error occurredprotected void createRichTextDataTable() throws ContextException
ContextException
- if a context error occurredprotected void createContentTable() throws ContextException
ContextException
- if a context error occurredprotected void createTableForEnumerator(MetadataDefinition metadataDef, String tableParentName, String tableName, String columnName, StringBuilder currentCreateTableSQLQuery) throws ContextException
metadataDef
- the metadata definition modeltableParentName
- the table parent nametableName
- the table namecolumnName
- the column namecurrentCreateTableSQLQuery
- the current SQL create table queryContextException
- if a context error occurredprotected void fillTableForEnumerator(MetadataDefinition metadataDef, String tableName)
metadataDef
- the metadata definition modeltableName
- the table nameprotected void createMappingNameTableSql() throws ContextException
ContextException
- if a context error occurredprotected void fillMappingTableSql(String mappingTableName, String mappingColumnName) throws ContextException
mappingTableName
- the table mapping table namemappingColumnName
- the column mapping table nameContextException
- if a context error occurredprotected void addColumnForCompositeMetadata(MetadataDefinitionHolder metadataDef, StringBuilder currentCreateTableSQLQuery, String tableName, String columnNamePrefix) throws ContextException
metadataDef
- the metadata definition modelcurrentCreateTableSQLQuery
- the current SQL create table querytableName
- the table namecolumnNamePrefix
- the column namePrefixContextException
- if a context error occurredprotected void addColumnForMetadata(MetadataDefinition metadataDef, StringBuilder currentCreateTableSQLQuery, String tableName, String columnNamePrefix) throws ContextException
metadataDef
- the metadata definition modelcurrentCreateTableSQLQuery
- the current SQL create table querytableName
- the table namecolumnNamePrefix
- the column namePrefixContextException
- if a context error occurredprotected void addColumnForSingleMetadata(MetadataDefinition metadataDef, StringBuilder currentCreateTableSQLQuery, String tableName, String columnName) throws ContextException
metadataDef
- the metadata definition modelcurrentCreateTableSQLQuery
- the current SQL create table querytableName
- the table namecolumnName
- the column nameContextException
- if a context error occurredprotected void addSortColumn(StringBuilder currentCreateTableSQLQuery, String tableName) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table querytableName
- the table nameContextException
- if a context error occurredprotected void addColumnParentId(StringBuilder currentCreateTableSQLQuery, String tableParentName, String tableName) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table querytableParentName
- the table parent nametableName
- the table nameContextException
- if a context error occurredprotected void addColumnsForGeocodeMetadata(StringBuilder currentCreateTableSQLQuery, String initialColumnName, String tableName, String comment) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table queryinitialColumnName
- the initial column nametableName
- the table namecomment
- the commentContextException
- if a context error occurredprotected void addColumnsForBinaryMetadata(StringBuilder currentCreateTableSQLQuery, String initialColumnName, String tableName, String comment) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table queryinitialColumnName
- the initial column nametableName
- the table namecomment
- the commentContextException
- if a context error occurredprotected void addColumnsForFileMetadata(StringBuilder currentCreateTableSQLQuery, String initialColumnName, String tableName, String comment) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table queryinitialColumnName
- the initial column nametableName
- the table namecomment
- the commentContextException
- if a context error occurredprotected void addColumnsForMultilingualStringMetadata(StringBuilder currentCreateTableSQLQuery, String initialColumnName, String tableName, String comment) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table queryinitialColumnName
- the initial column nametableName
- the table namecomment
- the commentContextException
- if a context error occurredprotected void addColumnForRichTextMetadata(StringBuilder currentCreateTableSQLQuery, String columnName, String tableName) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table querycolumnName
- the column nametableName
- the table nameContextException
- if a context error occurredprivate void addColumnForContentMetadata(StringBuilder currentCreateTableSQLQuery, String columnName, String tableName) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table querycolumnName
- the column nametableName
- the table nameContextException
- if a context error occurredprotected void addColumnForDoubleMetadata(StringBuilder currentCreateTableSQLQuery, String columnName, String tableName) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table querycolumnName
- the column nametableName
- the table nameContextException
- if a context error occurredprotected void addColumnForDateTimeMetadata(StringBuilder currentCreateTableSQLQuery, String columnName, String tableName) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table querycolumnName
- the column nametableName
- the table nameContextException
- if a context error occurredprotected void addColumnForDateMetadata(StringBuilder currentCreateTableSQLQuery, String columnName, String tableName) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table querycolumnName
- the column nametableName
- the table nameContextException
- if a context error occurredprotected void addColumnForStringMetadata(StringBuilder currentCreateTableSQLQuery, String columnName, String tableName) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table querycolumnName
- the column nametableName
- the table nameContextException
- if a context error occurredprotected void addColumnForUserMetadata(StringBuilder currentCreateTableSQLQuery, String columnName, String tableName) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table querycolumnName
- the column nametableName
- the table nameContextException
- if a context error occurredprotected void addColumnForEnumStringMetadata(StringBuilder currentCreateTableSQLQuery, String columnName, String tableName) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table querycolumnName
- the column nametableName
- the table nameContextException
- if a context error occurredprotected void addColumnForBooleanMetadata(StringBuilder currentCreateTableSQLQuery, String columnName, String tableName) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table querycolumnName
- the column nametableName
- the table nameContextException
- if a context error occurredprotected void addColumnForLongMetadata(StringBuilder currentCreateTableSQLQuery, String columnName, String tableName) throws ContextException
currentCreateTableSQLQuery
- the current SQL create table querycolumnName
- the column nametableName
- the table nameContextException
- if a context error occurredprotected void addAdditionnalContentMetadata(MetadataDefinitionHolder metadataDef, StringBuilder currentCreateTableSQLQuery, String tableName) throws ContextException
metadataDef
- the metadata definition modelcurrentCreateTableSQLQuery
- the current SQL create table querytableName
- the table nameContextException
- if a context error occurredprotected String createCommentQuery(String table, String column, String comments) throws ContextException
table
- the table namecolumn
- the column namecomments
- the commentsContextException
- if a context error occurredprotected String createForeignKeyQuery(String fkName, String tableName, String columnName) throws ContextException
fkName
- the foreign key nametableName
- the table namecolumnName
- the column nameContextException
- if a context error occurredprotected String createEngineQuery() throws ContextException
ContextException
- if a context error occurredprotected String createPrimaryKeyQuery() throws ContextException
ContextException
- if a context error occurredprotected String convertMetadataTypeToSql(String metadataType)
metadataType
- the metadata typeprotected void executeSqlQueries() throws SQLException, IOException
SQLException
- if a sql error occurredIOException
- if an IO error occurredprivate int _getNbTable()
protected void _executeQueryFromlistQuery(List<String> listQuery) throws SQLException, IOException
listQuery
- the list of query to executeSQLException
- if a sql error occurredIOException
- if an IO error occurredprotected PreparedStatement getInsertPreparedStatementFromTableName(String tableName) throws SQLException, ContextException
tableName
- the table nameSQLException
- if a sql error occurredContextException
- if a context error occurred