Class FillSqlTableComponent
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.contentio.export.component.FillSqlTableComponent
-
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
public class FillSqlTableComponent extends AbstractLogEnabled implements Component, Serviceable
Fill sql table component
-
-
Field Summary
Fields Modifier and Type Field 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 useprivate static String
_EXCLUDE_XML_TAGS
private boolean
_exportNoMultiValuedTable
private boolean
_exportOnlyValidatedContent
protected I18nUtils
_i18nTranslator
The i18n translator.protected LanguagesManager
_languageManager
The language managerprivate 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 managerstatic String
ROLE
The component role
-
Constructor Summary
Constructors Constructor Description FillSqlTableComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 metadataprivate void
fillColumnForBooleanMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple)
Fill column for Boolean metadataprivate void
fillColumnForDateMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple)
Fill column for Date metadataprivate void
fillColumnForDoubleMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple)
Fill column for Double metadataprotected void
fillColumnForFileMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName)
Fill columns for file metadataprotected void
fillColumnForGeocodeMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple)
Fill column for geocode metadataprivate void
fillColumnForLongMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple)
Fill column for Long metadataprivate void
fillColumnForMultilangualStringMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple)
Fill column for multilangual String metadataprotected void
fillColumnForRichTextData(RichText richText, String metadataName, String contentId)
Fill column for data in rich textprotected void
fillColumnForRichTextMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, String id)
Fill column for rich text metadataprivate void
fillColumnForStringMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple)
Fill column for String metadataprotected void
fillColumnForUserMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple)
Fill column for User metadataprotected void
fillCompositeMetadata(ExportCounter fillIndex, Content content, MetadataDefinitionHolder metadataDef, CompositeMetadata metadata, String tableName, String columnNamePrefix, String id, PreparedStatement stmt)
Fill values from a composite metadataprotected void
fillMetadata(ExportCounter fillIndex, MetadataDefinition metadataDef, CompositeMetadata compositeMetadata, String metadataName, String tableName, String columnPrefix, String id, PreparedStatement stmt)
Fill values from a metadatavoid
fillTable(ExportConfiguration exportConfiguration, Map<String,ExportTableInfo> tableInfo)
Fill table with contentsprotected void
fillTableForContentType(String contentTypeId)
Fill values from JCR request with specific content typeprotected void
fillTableForMultipleMetadata(MetadataDefinition metadataDefComposite, CompositeMetadata metadataComposite, String metadataName, String tableName, String id)
Fill values from multiple metadataprotected void
fillTableForRepeater(MetadataDefinition metadataDef, CompositeMetadata metadata, String tableName, String id)
Fill values from a repeater metadataprotected PreparedStatement
getInsertPreparedStatementFromTableName(String prefix, String tableName, String mappingPolicy)
Prepare INSERT statementprotected String
getTableName(String cTypeId)
Get the name of SQL table for given content typeprotected void
insertValues()
Fill the SQL tables with values from JCRvoid
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_EXCLUDE_XML_TAGS
private static final String _EXCLUDE_XML_TAGS
- See Also:
- Constant Field Values
-
_contentTypeExtensionPoint
protected ContentTypeExtensionPoint _contentTypeExtensionPoint
Content type extension point.
-
_resolver
protected AmetysObjectResolver _resolver
The ametys object resolver.
-
_normaliseNameComponent
protected NormalizeNameComponent _normaliseNameComponent
The normalise name component.
-
_contentTypesToExport
protected Map<String,String> _contentTypesToExport
The configured list of content types to export associated to the SQL table name to use
-
_i18nTranslator
protected I18nUtils _i18nTranslator
The i18n translator.
-
_languageManager
protected LanguagesManager _languageManager
The language manager
-
_userManager
protected UserManager _userManager
The user manager
-
_connection
private Connection _connection
-
_sqlTablePrefix
private String _sqlTablePrefix
-
_sqlPrefixConf
private String _sqlPrefixConf
-
_tablesInfos
private Map<String,ExportTableInfo> _tablesInfos
-
_mappingPolicy
private String _mappingPolicy
-
_stmtList
private LinkedList<PreparedStatement> _stmtList
-
_exportOnlyValidatedContent
private boolean _exportOnlyValidatedContent
-
_exportNoMultiValuedTable
private boolean _exportNoMultiValuedTable
-
_separator
private String _separator
-
-
Constructor Detail
-
FillSqlTableComponent
public FillSqlTableComponent()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
fillTable
public void fillTable(ExportConfiguration exportConfiguration, Map<String,ExportTableInfo> tableInfo) throws SQLException, AmetysRepositoryException, ContextException
Fill table with contents- Parameters:
exportConfiguration
- the content export configurationtableInfo
- the map of table information- Throws:
SQLException
- if a sql error occurredContextException
- if a context error occurredAmetysRepositoryException
- if an ametys repository error occurred
-
executeInsert
private void executeInsert() throws SQLException
- Throws:
SQLException
-
insertValues
protected void insertValues() throws SQLException, AmetysRepositoryException, ContextException
Fill the SQL tables with values from JCR- Throws:
SQLException
- if a sql error occurredContextException
- if a context error occurredAmetysRepositoryException
- if an ametys repository error occurred
-
fillTableForContentType
protected void fillTableForContentType(String contentTypeId) throws SQLException, AmetysRepositoryException, ContextException
Fill values from JCR request with specific content type- Parameters:
contentTypeId
- the content type id- Throws:
SQLException
- if a sql error occurredContextException
- if a context error occurredAmetysRepositoryException
- if an ametys repository error occurred
-
_fillContentTable
private void _fillContentTable(String idContent, String tableName) throws SQLException, ContextException
- Throws:
SQLException
ContextException
-
fillTableForRepeater
protected void fillTableForRepeater(MetadataDefinition metadataDef, CompositeMetadata metadata, String tableName, String id) throws SQLException, AmetysRepositoryException, ContextException
Fill values from a repeater metadata- Parameters:
metadataDef
- the metadata definition modelmetadata
- the composite metadatatableName
- the table nameid
- the content id- Throws:
SQLException
- if a sql error occurredContextException
- if a context error occurredAmetysRepositoryException
- if an ametys repository error occurred
-
fillCompositeMetadata
protected void fillCompositeMetadata(ExportCounter fillIndex, Content content, MetadataDefinitionHolder metadataDef, CompositeMetadata metadata, String tableName, String columnNamePrefix, String id, PreparedStatement stmt) throws SQLException, AmetysRepositoryException, ContextException
Fill values from a composite metadata- Parameters:
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 statement- Throws:
SQLException
- if a sql error occurredContextException
- if a context error occurredAmetysRepositoryException
- if an ametys repository error occurred
-
fillAdditionnalValueForContentMetadata
protected void fillAdditionnalValueForContentMetadata(ExportCounter fillIndex, Content content, PreparedStatement stmt) throws UnknownMetadataException, AmetysRepositoryException, SQLException
Add additional values for content (Title, type, language, creator, creationDate, ...)- Parameters:
fillIndex
- the position indicator in the insert statementcontent
- the contentstmt
- the jdbc statement- Throws:
SQLException
- if a sql error occurredUnknownMetadataException
- if a metadata error occurredAmetysRepositoryException
- if an ametys repository error occurred
-
fillMetadata
protected void fillMetadata(ExportCounter fillIndex, MetadataDefinition metadataDef, CompositeMetadata compositeMetadata, String metadataName, String tableName, String columnPrefix, String id, PreparedStatement stmt) throws SQLException, AmetysRepositoryException, ContextException
Fill values from a metadata- Parameters:
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 statement- Throws:
SQLException
- if a sql error occurredContextException
- if a context error occurredAmetysRepositoryException
- if an ametys repository error occurred
-
fillTableForMultipleMetadata
protected void fillTableForMultipleMetadata(MetadataDefinition metadataDefComposite, CompositeMetadata metadataComposite, String metadataName, String tableName, String id) throws SQLException, ContextException
Fill values from multiple metadata- Parameters:
metadataDefComposite
- the metadata definition modelmetadataComposite
- the composite metadatametadataName
- the metadata nametableName
- the table nameid
- the content id- Throws:
SQLException
- if a sql error occurredContextException
- if a context error occurred
-
fillColumnForDateMetadata
private void fillColumnForDateMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
Fill column for Date metadata- Parameters:
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata namemultiple
-true
if the metadata is multiple- Throws:
SQLException
- if a sql error occurred
-
fillColumnForBooleanMetadata
private void fillColumnForBooleanMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
Fill column for Boolean metadata- Parameters:
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata namemultiple
-true
if the metadata is multiple- Throws:
SQLException
- if a sql error occurred
-
fillColumnForLongMetadata
private void fillColumnForLongMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
Fill column for Long metadata- Parameters:
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata namemultiple
-true
if the metadata is multiple- Throws:
SQLException
- if a sql error occurred
-
fillColumnForMultilangualStringMetadata
private void fillColumnForMultilangualStringMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
Fill column for multilangual String metadata- Parameters:
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata namemultiple
-true
if the metadata is multiple- Throws:
SQLException
- if a sql error occurred
-
fillColumnForStringMetadata
private void fillColumnForStringMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
Fill column for String metadata- Parameters:
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata namemultiple
-true
if the metadata is multiple- Throws:
SQLException
- if a sql error occurred
-
fillColumnForGeocodeMetadata
protected void fillColumnForGeocodeMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
Fill column for geocode metadata- Parameters:
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata namemultiple
-true
if the metadata is multiple- Throws:
SQLException
- if a sql error occurred
-
fillColumnForUserMetadata
protected void fillColumnForUserMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
Fill column for User metadata- Parameters:
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata namemultiple
-true
if the metadata is multiple- Throws:
SQLException
- if a sql error occurred
-
fillColumnForFileMetadata
protected void fillColumnForFileMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName) throws SQLException
Fill columns for file metadata- Parameters:
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata name- Throws:
SQLException
- if a sql error occurred
-
fillColumnForBinaryMetadata
protected void fillColumnForBinaryMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName) throws SQLException
Fill column for binary metadata- Parameters:
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata name- Throws:
SQLException
- if a sql error occurred
-
fillColumnForRichTextMetadata
protected void fillColumnForRichTextMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, String id) throws SQLException, AmetysRepositoryException, ContextException
Fill column for rich text metadata- Parameters:
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the metadata nameid
- the id- Throws:
SQLException
- if a sql error occurredContextException
- if a context error occurredAmetysRepositoryException
- if an ametys repository error occurred
-
fillColumnForRichTextData
protected void fillColumnForRichTextData(RichText richText, String metadataName, String contentId) throws AmetysRepositoryException, SQLException, ContextException
Fill column for data in rich text- Parameters:
richText
- the rich textmetadataName
- the metadata namecontentId
- the content id- Throws:
AmetysRepositoryException
- if an error occurredSQLException
- if a sql error occurredContextException
- if a context error occurred
-
fillColumnForDoubleMetadata
private void fillColumnForDoubleMetadata(PreparedStatement stmt, ExportCounter fillIndex, CompositeMetadata metadata, String metadataName, boolean multiple) throws SQLException
Fill column for Double metadata- Parameters:
stmt
- the jdbc statementfillIndex
- the position indicator in the insert statementmetadata
- the composite metadatametadataName
- the name of the metadatamultiple
-true
if the metadata is multiple- Throws:
SQLException
- if a sql error occurred
-
getInsertPreparedStatementFromTableName
protected PreparedStatement getInsertPreparedStatementFromTableName(String prefix, String tableName, String mappingPolicy) throws SQLException, ContextException
Prepare INSERT statement- Parameters:
prefix
- the table prefixtableName
- the table namemappingPolicy
- the mapping policy- Returns:
- the INSERT preparedStatement
- Throws:
SQLException
- if a sql error occurredContextException
- if a context error occurred
-
_getCompositeMetadataPath
private String _getCompositeMetadataPath(CompositeMetadata metadata)
-
getTableName
protected String getTableName(String cTypeId)
Get the name of SQL table for given content type- Parameters:
cTypeId
- The id of content type- Returns:
- the name of SQL table or null if not found
-
-