Class SqlVersionStorage
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.migration.storage.impl.SqlVersionStorage
-
- All Implemented Interfaces:
VersionStorage
,LogEnabled
,Serviceable
public class SqlVersionStorage extends AbstractLogEnabled implements VersionStorage, Serviceable
SQL implementation ofVersionStorage
, to manage the list of versions in a database
-
-
Field Summary
Fields Modifier and Type Field Description private static TreeMap<String,String>
__AMETYS_VERSIONS_UDPATES
private static String
__COLUMN_COMMENT
private static String
__COLUMN_COMPONENT
private static String
__COLUMN_DATE
private static String
__COLUMN_VERSION
private static String
__VERSION_TABLE_NAME
protected SourceResolver
_sourceResolver
Source resolver
-
Constructor Summary
Constructors Constructor Description SqlVersionStorage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
_addVersion(Connection connection, Version version)
private List<Version>
_getVersionsForComponent(String componentIdentifier, Object versionConfiguration, String versionHandlerId, boolean onlyFirstVersion)
Get the list of versions for a componentprivate List<Version>
_getVersionsForComponent(Connection connection, String dataSourceId, String componentIdentifier, String versionHandlerId, boolean onlyFirstVersion)
protected void
_initVersionsTableIfNeeded(String dataSourceId)
Create the versions table if neededvoid
addVersion(Version version)
Add a versionList<Version>
getAllVersions(String componentIdentifier, VersionConfiguration versionConfiguration, String versionHandlerId)
Get the history of all versions for a component identifierVersionConfiguration
getConfiguration(String componentId, Configuration versionConfiguration)
Create a specific object containing usefull data for the handler/storageVersion
getCurrentVersion(String componentIdentifier, VersionConfiguration versionConfiguration, String versionHandlerId)
Find the current version for a component identifiervoid
removeAllVersions(String componentIdentifier, VersionConfiguration versionConfiguration)
Remove all versions for a component identifiervoid
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
__VERSION_TABLE_NAME
private static final String __VERSION_TABLE_NAME
- See Also:
- Constant Field Values
-
__COLUMN_COMPONENT
private static final String __COLUMN_COMPONENT
- See Also:
- Constant Field Values
-
__COLUMN_VERSION
private static final String __COLUMN_VERSION
- See Also:
- Constant Field Values
-
__COLUMN_DATE
private static final String __COLUMN_DATE
- See Also:
- Constant Field Values
-
__COLUMN_COMMENT
private static final String __COLUMN_COMMENT
- See Also:
- Constant Field Values
-
__AMETYS_VERSIONS_UDPATES
private static final TreeMap<String,String> __AMETYS_VERSIONS_UDPATES
-
_sourceResolver
protected SourceResolver _sourceResolver
Source resolver
-
-
Constructor Detail
-
SqlVersionStorage
public SqlVersionStorage()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getCurrentVersion
public Version getCurrentVersion(String componentIdentifier, VersionConfiguration versionConfiguration, String versionHandlerId) throws MigrationException, NotMigrableInSafeModeException
Description copied from interface:VersionStorage
Find the current version for a component identifier- Specified by:
getCurrentVersion
in interfaceVersionStorage
- Parameters:
componentIdentifier
- component to look forversionConfiguration
- configuration to useversionHandlerId
- id of theVersionHandler
- Returns:
- the current version for this component (can have a versionId null if no version is found), or null if it is impossible to determine the version (e.g. safe mode).
- Throws:
MigrationException
- Something went wrongNotMigrableInSafeModeException
- Impossible to determine the version
-
getAllVersions
public List<Version> getAllVersions(String componentIdentifier, VersionConfiguration versionConfiguration, String versionHandlerId) throws MigrationException, NotMigrableInSafeModeException
Description copied from interface:VersionStorage
Get the history of all versions for a component identifier- Specified by:
getAllVersions
in interfaceVersionStorage
- Parameters:
componentIdentifier
- component to look forversionConfiguration
- configuration to useversionHandlerId
- id of theVersionHandler
- Returns:
- list of all versions for this component
- Throws:
MigrationException
- Something went wrongNotMigrableInSafeModeException
- Impossible to determine the version
-
_getVersionsForComponent
private List<Version> _getVersionsForComponent(String componentIdentifier, Object versionConfiguration, String versionHandlerId, boolean onlyFirstVersion) throws MigrationException, NotMigrableInSafeModeException
Get the list of versions for a component- Parameters:
componentIdentifier
- componentIdentifierversionConfiguration
- versionConfigurationversionHandlerId
- versionHandlerIdonlyFirstVersion
- Only first version is returned- Returns:
- a list of current Version, or an empty list if there is a configuration problem (no version is possible)
- Throws:
MigrationException
- Something went wrongNotMigrableInSafeModeException
- Impossible to find the config
-
_getVersionsForComponent
private List<Version> _getVersionsForComponent(Connection connection, String dataSourceId, String componentIdentifier, String versionHandlerId, boolean onlyFirstVersion) throws SQLException
- Throws:
SQLException
-
addVersion
public void addVersion(Version version) throws MigrationException
Description copied from interface:VersionStorage
Add a version- Specified by:
addVersion
in interfaceVersionStorage
- Parameters:
version
- Version to store (contains the component identifier)- Throws:
MigrationException
- Something went wrong
-
_addVersion
private void _addVersion(Connection connection, Version version) throws SQLException
- Throws:
SQLException
-
removeAllVersions
public void removeAllVersions(String componentIdentifier, VersionConfiguration versionConfiguration) throws MigrationException
Description copied from interface:VersionStorage
Remove all versions for a component identifier- Specified by:
removeAllVersions
in interfaceVersionStorage
- Parameters:
componentIdentifier
- component to clearversionConfiguration
- configuration to use- Throws:
MigrationException
- Something went wrong
-
_initVersionsTableIfNeeded
protected void _initVersionsTableIfNeeded(String dataSourceId) throws MigrationException
Create the versions table if needed- Parameters:
dataSourceId
- the datasource where the table will be created- Throws:
MigrationException
- Something went wrong
-
getConfiguration
public VersionConfiguration getConfiguration(String componentId, Configuration versionConfiguration) throws ConfigurationException, NotMigrableInSafeModeException
Description copied from interface:VersionStorage
Create a specific object containing usefull data for the handler/storage- Specified by:
getConfiguration
in interfaceVersionStorage
- Parameters:
componentId
- id of the componentversionConfiguration
- configuration from the plugin.xml- Returns:
- the confuguration object
- Throws:
ConfigurationException
- something wrong in the configurationNotMigrableInSafeModeException
- Impossible to determine the version
-
-