Class NamedRecordMigrationStrategy
java.lang.Object
com.inductiveautomation.ignition.gateway.config.migration.NamedRecordMigrationStrategy
- All Implemented Interfaces:
IdbMigrationStrategy
Migrates records that are identified by unique name. The ID field of the record will be discarded and the name
will become the last path component of the resource path.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.inductiveautomation.ignition.gateway.config.migration.IdbMigrationStrategy
IdbMigrationStrategy.MigrationResult
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final SFieldString
protected final SFieldBoolean
protected final RecordEncodingDelegate
protected final org.slf4j.Logger
protected final RecordMeta<? extends PersistentRecord>
protected final SFieldString
protected final ResourceType
Fields inherited from interface com.inductiveautomation.ignition.gateway.config.migration.IdbMigrationStrategy
MIGRATION_ACTOR
-
Constructor Summary
ConstructorsConstructorDescriptionNamedRecordMigrationStrategy
(RecordMeta<? extends PersistentRecord> meta, ResourceType resourceType) NamedRecordMigrationStrategy
(RecordMeta<? extends PersistentRecord> meta, ResourceType resourceType, RecordEncodingDelegate encodingDelegate) NamedRecordMigrationStrategy
(RecordMeta<? extends PersistentRecord> meta, SFieldString nameField, SFieldString descriptionField, SFieldBoolean enabledField, ResourceType resourceType, RecordEncodingDelegate encodingDelegate) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
encodeResource
(RecordEncodingContext context, ResourceBuilder builder) protected String
By default, resources will be added toConfigurationManager.CORE
, override this as necessary to change the default behavior.protected String
getName
(PersistentRecord persistentRecord) List<SRecordMeta<? extends SRecordInstance>>
protected boolean
isEnabled
(PersistentRecord persistentRecord) migrate
(MigrationContext context) Migrate records from the internal database to the configuration resource collection.protected Optional<ChangeOperation>
migrateRecord
(MigrationContext context, String name, PersistentRecord persistentRecord) toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.inductiveautomation.ignition.gateway.config.migration.IdbMigrationStrategy
getTableNames
-
Field Details
-
log
protected final org.slf4j.Logger log -
meta
-
resourceType
-
nameField
-
descriptionField
-
enabledField
-
encodingDelegate
-
-
Constructor Details
-
NamedRecordMigrationStrategy
public NamedRecordMigrationStrategy(RecordMeta<? extends PersistentRecord> meta, ResourceType resourceType) -
NamedRecordMigrationStrategy
public NamedRecordMigrationStrategy(RecordMeta<? extends PersistentRecord> meta, ResourceType resourceType, RecordEncodingDelegate encodingDelegate) -
NamedRecordMigrationStrategy
public NamedRecordMigrationStrategy(RecordMeta<? extends PersistentRecord> meta, SFieldString nameField, @Nullable SFieldString descriptionField, @Nullable SFieldBoolean enabledField, ResourceType resourceType, RecordEncodingDelegate encodingDelegate)
-
-
Method Details
-
migrate
public IdbMigrationStrategy.MigrationResult migrate(MigrationContext context) throws MigrationException Description copied from interface:IdbMigrationStrategy
Migrate records from the internal database to the configuration resource collection. To do this, use the given session to issue anSQuery
to find the records you want to migrate. Then compile a list ofChangeOperation
that will be applied to the config resource collection to add the appropriate resources.- Specified by:
migrate
in interfaceIdbMigrationStrategy
- Parameters:
context
- aMigrationContext
which provides methods for accessing aPersistenceSession
to query the internal DB as well as aConfigurationManager
for accessing the new config resource APIs- Returns:
- A list of change operations that will be applied to the config resource collection.
- Throws:
MigrationException
- If an error occurs during migration.
-
migrateRecord
protected Optional<ChangeOperation> migrateRecord(MigrationContext context, String name, PersistentRecord persistentRecord) -
getName
-
isEnabled
-
encodeResource
-
getCollectionName
By default, resources will be added toConfigurationManager.CORE
, override this as necessary to change the default behavior. -
getRecordMetas
- Specified by:
getRecordMetas
in interfaceIdbMigrationStrategy
- Returns:
- The record metas that this strategy migrates, if any. If this strategy does not migrate records, return
an empty list. Also note that any record metas returned here will automatically be applied to the
SchemaUpdater.updatePersistentRecords(Iterable)
, so you do not need to do this again in yourGatewayModuleHook
setup() method.
-
toString
-