Class SqlVersionStorage
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.core.migration.version.storage.SqlVersionStorage
- All Implemented Interfaces:
VersionStorage
,LogEnabled
,PluginAware
,Initializable
,Serviceable
public class SqlVersionStorage
extends AbstractLogEnabled
implements VersionStorage, Serviceable, PluginAware, Initializable
SQL implementation of
VersionStorage
, to manage the list of versions in a database-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
AVersionConfiguration
with a SQL datasource id -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateVersion
(String componentId, MigrationEngine.MigrationComponent component, VersionConfiguration storageConfiguration, Map<String, Object> additionalValues) Creates a new version object, used to initialize the migration process.createVersionConfiguration
(Configuration versionConfiguration) Create a specific object containing useful data for the handler/storagegetId()
Get the unique identifiergetVersions
(String componentId, VersionConfiguration configuration, MigrationEngine.MigrationComponent component) Get the history of all versions for a component identifiervoid
void
removeAllVersions
(String componentIdentifier, VersionConfiguration versionConfiguration) Remove all versions for a component identifiervoid
removeVersion
(String componentId, String versionNumber, VersionConfiguration configuration) Removes a stored versionvoid
service
(ServiceManager manager) void
setPluginInfo
(String pluginName, String featureName, String id) Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.void
storeVersion
(Version version) Add a versionMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Constructor Details
-
SqlVersionStorage
public SqlVersionStorage()
-
-
Method Details
-
setPluginInfo
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getId
Description copied from interface:VersionStorage
Get the unique identifier- Specified by:
getId
in interfaceVersionStorage
- Returns:
- The identifier
-
getVersions
public List<Version> getVersions(String componentId, VersionConfiguration configuration, MigrationEngine.MigrationComponent component) throws MigrationException Description copied from interface:VersionStorage
Get the history of all versions for a component identifier- Specified by:
getVersions
in interfaceVersionStorage
- Parameters:
componentId
- the component idconfiguration
- configuration for this storagecomponent
- the context component- Returns:
- list of all versions for this component
- Throws:
MigrationException
- Something went wrong
-
createVersion
public Version createVersion(String componentId, MigrationEngine.MigrationComponent component, VersionConfiguration storageConfiguration, Map<String, Object> additionalValues) throws MigrationExceptionDescription copied from interface:VersionStorage
Creates a new version object, used to initialize the migration process. This version is actually NOT stored.
Depending of the context, the createdVersion
could have the "0" number (ie. all actions should be executed), ornull
number (ie. only initialization action should be executed and the actual version number set to the highest available).- Specified by:
createVersion
in interfaceVersionStorage
- Parameters:
componentId
- the component idcomponent
- the context componentstorageConfiguration
- configuration for this storageadditionalValues
- all specific values used by upgrade actions- Returns:
- the newly created Version
- Throws:
MigrationException
- Impossible to create the version
-
storeVersion
Description copied from interface:VersionStorage
Add a version- Specified by:
storeVersion
in interfaceVersionStorage
- Parameters:
version
- Version to store (contains the component identifier)- Throws:
MigrationException
- Something went wrong
-
removeVersion
public void removeVersion(String componentId, String versionNumber, VersionConfiguration configuration) throws MigrationException Description copied from interface:VersionStorage
Removes a stored version- Specified by:
removeVersion
in interfaceVersionStorage
- Parameters:
componentId
- the componentversionNumber
- the version to removeconfiguration
- the associated configuration- Throws:
MigrationException
- Something went wrong
-
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
-
createVersionConfiguration
public VersionConfiguration createVersionConfiguration(Configuration versionConfiguration) throws ConfigurationException, NotMigrableInSafeModeException Description copied from interface:VersionStorage
Create a specific object containing useful data for the handler/storage- Specified by:
createVersionConfiguration
in interfaceVersionStorage
- Parameters:
versionConfiguration
- configuration from the plugin.xml- Returns:
- the confuguration object
- Throws:
ConfigurationException
- something wrong in the configurationNotMigrableInSafeModeException
- it it's impossible to configure the versions in safe mode
-