Class FillSqlTableComponent
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.contentio.export.sql.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_connectionprotected ContentTypeExtensionPoint_contentTypeExtensionPointContent type extension point.protected Map<String,String>_contentTypesToExportThe configured list of content types to export associated to the SQL table name to useprivate static String_EXCLUDE_XML_TAGSprivate boolean_exportNoMultiValuedTableprivate boolean_exportOnlyValidatedContentprotected I18nUtils_i18nTranslatorThe i18n translator.protected LanguagesManager_languageManagerThe language managerprivate String_mappingPolicyprotected NormalizeNameComponent_normalizeNameComponentThe normalise name component.protected AmetysObjectResolver_resolverThe ametys object resolver.private String_separatorprivate String_sqlPrefixConfprivate String_sqlTablePrefixprivate LinkedList<PreparedStatement>_stmtListprivate Map<String,ExportTableInfo>_tablesInfosprotected UserManager_userManagerThe user managerstatic StringROLEThe 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_getValueForNoMultiValuedTable(Object value, String type)private int_setNull(int position, PreparedStatement stmt, String type)private int_setValue(Object value, int position, PreparedStatement stmt, String type, String name, String contentId)private voidexecuteInsert()protected voidfillAdditionalData(ExportCounter fillIndex, Content content, PreparedStatement stmt)Add additional values for content (Title, type, language, creator, creationDate, ...)protected voidfillColumnForRichTextData(RichText richText, String attributeName, String contentId)Fill column for data in rich textvoidfillTable(ExportConfiguration exportConfiguration, Map<String,ExportTableInfo> tableInfo)Fill table with contentsprotected voidfillTableForContentType(String contentTypeId)Fill values from JCR request with specific content typeprotected voidfillTableForMultipleAttribute(ElementDefinition definition, ModelAwareDataHolder dataHolder, String name, String tableName, String id)Fill values from multiple attributeprotected voidfillTableForRepeater(RepeaterDefinition definition, ModelAwareRepeater repeater, String tableName, String id)Fill values from a repeaterprotected voidfillValue(ExportCounter fillIndex, ElementDefinition definition, ModelAwareDataHolder dataHolder, String name, String id, PreparedStatement stmt)Fill values from an attributeprotected voidfillValues(ExportCounter fillIndex, ModelItemContainer modelItemContainer, ModelAwareDataHolder dataHolder, String tableName, String columnNamePrefix, String id, PreparedStatement stmt)Fill values from a composite metadataprotected PreparedStatementgetInsertPreparedStatementFromTableName(String prefix, String tableName, String mappingPolicy)Prepare INSERT statementprotected StringgetTableName(String cTypeId)Get the name of SQL table for given content typeprotected voidinsertValues()Fill the SQL tables with values from JCRvoidservice(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.
-
_normalizeNameComponent
protected NormalizeNameComponent _normalizeNameComponent
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:
servicein interfaceServiceable- Throws:
ServiceException
-
fillTable
public void fillTable(ExportConfiguration exportConfiguration, Map<String,ExportTableInfo> tableInfo) throws SQLException, AmetysRepositoryException
Fill table with contents- Parameters:
exportConfiguration- the content export configurationtableInfo- the map of table information- Throws:
SQLException- if a sql error occurredAmetysRepositoryException- if an ametys repository error occurred
-
executeInsert
private void executeInsert() throws SQLException
- Throws:
SQLException
-
insertValues
protected void insertValues() throws SQLException, AmetysRepositoryException
Fill the SQL tables with values from JCR- Throws:
SQLException- if a sql error occurredAmetysRepositoryException- if an ametys repository error occurred
-
fillTableForContentType
protected void fillTableForContentType(String contentTypeId) throws SQLException, AmetysRepositoryException
Fill values from JCR request with specific content type- Parameters:
contentTypeId- the content type id- Throws:
SQLException- if a sql error occurredAmetysRepositoryException- if an ametys repository error occurred
-
_fillContentTable
private void _fillContentTable(String idContent, String tableName) throws SQLException
- Throws:
SQLException
-
fillValues
protected void fillValues(ExportCounter fillIndex, ModelItemContainer modelItemContainer, ModelAwareDataHolder dataHolder, String tableName, String columnNamePrefix, String id, PreparedStatement stmt) throws SQLException, AmetysRepositoryException
Fill values from a composite metadata- Parameters:
fillIndex- the position indicator in the insert statementmodelItemContainer- the attribute definitionsdataHolder- theModelAwareDataHoldertableName- the table namecolumnNamePrefix- the column name prefixid- the content idstmt- the jdbc statement- Throws:
SQLException- if a sql error occurredAmetysRepositoryException- if an ametys repository error occurred
-
fillTableForRepeater
protected void fillTableForRepeater(RepeaterDefinition definition, ModelAwareRepeater repeater, String tableName, String id) throws SQLException, AmetysRepositoryException
Fill values from a repeater- Parameters:
definition- the repeater definitionrepeater- the repeatertableName- the table nameid- the content id- Throws:
SQLException- if a sql error occurredAmetysRepositoryException- if an ametys repository error occurred
-
fillTableForMultipleAttribute
protected void fillTableForMultipleAttribute(ElementDefinition definition, ModelAwareDataHolder dataHolder, String name, String tableName, String id) throws SQLException
Fill values from multiple attribute- Parameters:
definition- the attribute definitiondataHolder- theModelAwareDataHoldername- the attribute nametableName- the table nameid- the content id- Throws:
SQLException- if a sql error occurred
-
fillValue
protected void fillValue(ExportCounter fillIndex, ElementDefinition definition, ModelAwareDataHolder dataHolder, String name, String id, PreparedStatement stmt) throws SQLException, AmetysRepositoryException
Fill values from an attribute- Parameters:
fillIndex- the position indicator in the insert statementdefinition- the metadata definition modeldataHolder- theModelAwareDataHoldername- the attribute nameid- the content idstmt- the jdbc statement- Throws:
SQLException- if a sql error occurredAmetysRepositoryException- if an ametys repository error occurred
-
_setValue
private int _setValue(Object value, int position, PreparedStatement stmt, String type, String name, String contentId) throws SQLException
- Throws:
SQLException
-
_setNull
private int _setNull(int position, PreparedStatement stmt, String type) throws SQLException
- Throws:
SQLException
-
_getValueForNoMultiValuedTable
private String _getValueForNoMultiValuedTable(Object value, String type)
-
fillAdditionalData
protected void fillAdditionalData(ExportCounter fillIndex, Content content, PreparedStatement stmt) throws 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 occurredAmetysRepositoryException- if an ametys repository error occurred
-
fillColumnForRichTextData
protected void fillColumnForRichTextData(RichText richText, String attributeName, String contentId) throws AmetysRepositoryException, SQLException
Fill column for data in rich text- Parameters:
richText- the rich textattributeName- the metadata namecontentId- the content id- Throws:
AmetysRepositoryException- if an error occurredSQLException- if a sql error occurred
-
getInsertPreparedStatementFromTableName
protected PreparedStatement getInsertPreparedStatementFromTableName(String prefix, String tableName, String mappingPolicy) throws SQLException
Prepare INSERT statement- Parameters:
prefix- the table prefixtableName- the table namemappingPolicy- the mapping policy- Returns:
- the INSERT preparedStatement
- Throws:
SQLException- if a sql error occurred
-
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
-
-