public class FillSqlTableComponent extends AbstractLogEnabled implements Component, Serviceable
Modifier and Type | Field and Description |
---|---|
private Connection |
_connection |
protected ContentTypeExtensionPoint |
_contentTypeExtensionPoint
Content type extension point.
|
protected Map<String,String> |
_contentTypesToExport
The configured list of content types to export associated to the SQL table name to use
|
private static String |
_EXCLUDE_XML_TAGS |
private boolean |
_exportNoMultiValuedTable |
private boolean |
_exportOnlyValidatedContent |
protected I18nUtils |
_i18nTranslator
The i18n translator.
|
protected LanguagesManager |
_languageManager
The language manager
|
private String |
_mappingPolicy |
protected NormalizeNameComponent |
_normaliseNameComponent
The normalise name component.
|
protected AmetysObjectResolver |
_resolver
The ametys object resolver.
|
private String |
_separator |
private String |
_sqlPrefixConf |
private String |
_sqlTablePrefix |
private LinkedList<PreparedStatement> |
_stmtList |
private Map<String,ExportTableInfo> |
_tablesInfos |
protected UserManager |
_userManager
The user manager
|
static String |
ROLE
The component role
|
Constructor and Description |
---|
FillSqlTableComponent() |
Modifier and Type | Method and Description |
---|---|
private void |
_fillContentTable(String idContent,
String tableName) |
private String |
_getCompositeMetadataPath(CompositeMetadata metadata) |
private void |
executeInsert() |
protected void |
fillAdditionnalValueForContentMetadata(ExportCounter fillIndex,
Content content,
PreparedStatement stmt)
Add additional values for content (Title, type, language, creator, creationDate, ...)
|
protected void |
fillColumnForBinaryMetadata(PreparedStatement stmt,
ExportCounter fillIndex,
CompositeMetadata metadata,
String metadataName)
Fill column for binary metadata
|
private void |
fillColumnForBooleanMetadata(PreparedStatement stmt,
ExportCounter fillIndex,
CompositeMetadata metadata,
String metadataName,
boolean multiple)
Fill column for Boolean metadata
|
private void |
fillColumnForDateMetadata(PreparedStatement stmt,
ExportCounter fillIndex,
CompositeMetadata metadata,
String metadataName,
boolean multiple)
Fill column for Date metadata
|
private void |
fillColumnForDoubleMetadata(PreparedStatement stmt,
ExportCounter fillIndex,
CompositeMetadata metadata,
String metadataName,
boolean multiple)
Fill column for Double metadata
|
protected void |
fillColumnForFileMetadata(PreparedStatement stmt,
ExportCounter fillIndex,
CompositeMetadata metadata,
String metadataName)
Fill columns for file metadata
|
protected void |
fillColumnForGeocodeMetadata(PreparedStatement stmt,
ExportCounter fillIndex,
CompositeMetadata metadata,
String metadataName,
boolean multiple)
Fill column for geocode metadata
|
private void |
fillColumnForLongMetadata(PreparedStatement stmt,
ExportCounter fillIndex,
CompositeMetadata metadata,
String metadataName,
boolean multiple)
Fill column for Long metadata
|
private void |
fillColumnForMultilangualStringMetadata(PreparedStatement stmt,
ExportCounter fillIndex,
CompositeMetadata metadata,
String metadataName,
boolean multiple)
Fill column for multilangual String metadata
|
protected void |
fillColumnForRichTextData(RichText richText,
String metadataName,
String contentId)
Fill column for data in rich text
|
protected void |
fillColumnForRichTextMetadata(PreparedStatement stmt,
ExportCounter fillIndex,
CompositeMetadata metadata,
String metadataName,
String id)
Fill column for rich text metadata
|
private void |
fillColumnForStringMetadata(PreparedStatement stmt,
ExportCounter fillIndex,
CompositeMetadata metadata,
String metadataName,
boolean multiple)
Fill column for String metadata
|
protected void |
fillColumnForUserMetadata(PreparedStatement stmt,
ExportCounter fillIndex,
CompositeMetadata metadata,
String metadataName,
boolean multiple)
Fill column for User metadata
|
protected void |
fillCompositeMetadata(ExportCounter fillIndex,
Content content,
MetadataDefinitionHolder metadataDef,
CompositeMetadata metadata,
String tableName,
String columnNamePrefix,
String id,
PreparedStatement stmt)
Fill values from a composite metadata
|
protected void |
fillMetadata(ExportCounter fillIndex,
MetadataDefinition metadataDef,
CompositeMetadata compositeMetadata,
String metadataName,
String tableName,
String columnPrefix,
String id,
PreparedStatement stmt)
Fill values from a metadata
|
void |
fillTable(ExportConfiguration exportConfiguration,
Map<String,ExportTableInfo> tableInfo)
Fill table with contents
|
protected void |
fillTableForContentType(String contentTypeId)
Fill values from JCR request with specific content type
|
protected void |
fillTableForMultipleMetadata(MetadataDefinition metadataDefComposite,
CompositeMetadata metadataComposite,
String metadataName,
String tableName,
String id)
Fill values from multiple metadata
|
protected void |
fillTableForRepeater(MetadataDefinition metadataDef,
CompositeMetadata metadata,
String tableName,
String id)
Fill values from a repeater metadata
|
protected PreparedStatement |
getInsertPreparedStatementFromTableName(String prefix,
String tableName,
String mappingPolicy)
Prepare INSERT statement
|
protected String |
getTableName(String cTypeId)
Get the name of SQL table for given content type
|
protected void |
insertValues()
Fill the SQL tables with values from JCR
|
void |
service(ServiceManager manager) |
getLogger, setLogger
private static final String _EXCLUDE_XML_TAGS
protected ContentTypeExtensionPoint _contentTypeExtensionPoint
protected AmetysObjectResolver _resolver
protected NormalizeNameComponent _normaliseNameComponent
protected Map<String,String> _contentTypesToExport
protected I18nUtils _i18nTranslator
protected LanguagesManager _languageManager
protected UserManager _userManager
private Connection _connection
private String _sqlTablePrefix
private String _sqlPrefixConf
private Map<String,ExportTableInfo> _tablesInfos
private String _mappingPolicy
private LinkedList<PreparedStatement> _stmtList
private boolean _exportOnlyValidatedContent
private boolean _exportNoMultiValuedTable
private String _separator
public FillSqlTableComponent()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void fillTable(ExportConfiguration exportConfiguration, Map<String,ExportTableInfo> tableInfo) throws SQLException, AmetysRepositoryException, ContextException
exportConfiguration
- the content export configurationtableInfo
- the map of table informationSQLException
- if a sql error occurredContextException
- if a context error occurredAmetysRepositoryException
- if an ametys repository error occurredprivate void executeInsert() throws SQLException
SQLException
protected void insertValues() throws SQLException, AmetysRepositoryException, ContextException
SQLException
- if a sql error occurredContextException
- if a context error occurredAmetysRepositoryException
- if an ametys repository error occurredprotected void fillTableForContentType(String contentTypeId) throws SQLException, AmetysRepositoryException, ContextException
contentTypeId
- the content type idSQLException
- if a sql error occurredContextException
- if a context error occurredAmetysRepositoryException
- if an ametys repository error occurredprivate void _fillContentTable(String idContent, String tableName) throws SQLException, ContextException
SQLException
ContextException
protected void fillTableForRepeater(MetadataDefinition metadataDef, CompositeMetadata metadata, String tableName, String id) throws SQLException, AmetysRepositoryException, ContextException
metadataDef
- the metadata definition modelmetadata
- the composite metadatatableName
- the table nameid
- the content idSQLException
- if a sql error occurredContextException
- if a context error occurredAmetysRepositoryException
- if an ametys repository error occurredprotected void fillCompositeMetadata(ExportCounter fillIndex, Content content, MetadataDefinitionHolder metadataDef, CompositeMetadata metadata, String tableName, String columnNamePrefix, String id, PreparedStatement stmt) throws SQLException, AmetysRepositoryException, ContextException
fillIndex
- the position indicator in the insert statementcontent
- the contentmetadataDef
- the metadata definition modelmetadata
- the composite metadatatableName
- the table namecolumnNamePrefix
- the column name prefixid
- the content idstmt
- the jdbc statementSQLException
- if a sql error occurredContextException
- if a context error occurredAmetysRepositoryException
- if an ametys repository error occurredprotected void fillAdditionnalValueForContentMetadata(ExportCounter fillIndex, Content content, PreparedStatement stmt) throws UnknownMetadataException, AmetysRepositoryException, SQLException
fillIndex
- the position indicator in the insert statementcontent
- the contentstmt
- the jdbc statementSQLException
- if a sql error occurredUnknownMetadataException
- if a metadata error occurredAmetysRepositoryException
- if an ametys repository error occurredprotected void fillMetadata(ExportCounter fillIndex, MetadataDefinition metadataDef, CompositeMetadata compositeMetadata, String metadataName, String tableName, String columnPrefix, String id, PreparedStatement stmt) throws SQLException, AmetysRepositoryException, ContextException
fillIndex
- the position indicator in the insert statementmetadataDef
- the metadata definition modelcompositeMetadata
- the composite metadatametadataName
- the metadata nametableName
- the table namecolumnPrefix
- the column prefixid
- the content idstmt
- the jdbc statementSQLException
- if a sql error occurredContextException
- if a context error occurredAmetysRepositoryException
- if an ametys repository error occurredprotected void fillTableForMultipleMetadata(MetadataDefinition metadataDefComposite, CompositeMetadata metadataComposite, String metadataName, String tableName, String id) throws SQLException, ContextException
metadataDefComposite
- the metadata definition modelmetadataComposite
- the composite metadatametadataName
- the metadata nametableName
- the table nameid
- the content idSQLException
- if a sql error occurredContextException
- if a context error occurredprivate void fillColumnForDateMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata namemultiple
- true
if the metadata is multipleSQLException
- if a sql error occurredprivate void fillColumnForBooleanMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata namemultiple
- true
if the metadata is multipleSQLException
- if a sql error occurredprivate void fillColumnForLongMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata namemultiple
- true
if the metadata is multipleSQLException
- if a sql error occurredprivate void fillColumnForMultilangualStringMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata namemultiple
- true
if the metadata is multipleSQLException
- if a sql error occurredprivate void fillColumnForStringMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata namemultiple
- true
if the metadata is multipleSQLException
- if a sql error occurredprotected void fillColumnForGeocodeMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata namemultiple
- true
if the metadata is multipleSQLException
- if a sql error occurredprotected void fillColumnForUserMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata namemultiple
- true
if the metadata is multipleSQLException
- if a sql error occurredprotected void fillColumnForFileMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName) throws SQLException
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata nameSQLException
- if a sql error occurredprotected void fillColumnForBinaryMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName) throws SQLException
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata nameSQLException
- if a sql error occurredprotected void fillColumnForRichTextMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, String id) throws SQLException, AmetysRepositoryException, ContextException
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata nameid
- the idSQLException
- if a sql error occurredContextException
- if a context error occurredAmetysRepositoryException
- if an ametys repository error occurredprotected void fillColumnForRichTextData(RichText richText, String metadataName, String contentId) throws AmetysRepositoryException, SQLException, ContextException
richText
- the rich textmetadataName
- the metadata namecontentId
- the content idAmetysRepositoryException
- if an error occurredSQLException
- if a sql error occurredContextException
- if a context error occurredprivate void fillColumnForDoubleMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the name of the metadatamultiple
- true
if the metadata is multipleSQLException
- if a sql error occurredprotected PreparedStatement getInsertPreparedStatementFromTableName(String prefix, String tableName, String mappingPolicy) throws SQLException, ContextException
prefix
- the table prefixtableName
- the table namemappingPolicy
- the mapping policySQLException
- if a sql error occurredContextException
- if a context error occurredprivate String _getCompositeMetadataPath(CompositeMetadata metadata)
protected String getTableName(String cTypeId)
cTypeId
- The id of content type