Package liquibase.snapshot
Class DatabaseSnapshot
- java.lang.Object
-
- liquibase.snapshot.DatabaseSnapshot
-
- All Implemented Interfaces:
LiquibaseSerializable
- Direct Known Subclasses:
EmptyDatabaseSnapshot,JdbcDatabaseSnapshot,RestoredDatabaseSnapshot
public abstract class DatabaseSnapshot extends Object implements LiquibaseSerializable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface liquibase.serializer.LiquibaseSerializable
LiquibaseSerializable.SerializationType
-
-
Field Summary
Fields Modifier and Type Field Description static StringALL_CATALOGS_STRING_SCRATCH_KEY-
Fields inherited from interface liquibase.serializer.LiquibaseSerializable
GENERIC_CHANGELOG_EXTENSION_NAMESPACE, GENERIC_SNAPSHOT_EXTENSION_NAMESPACE, STANDARD_CHANGELOG_NAMESPACE, STANDARD_SNAPSHOT_NAMESPACE
-
-
Constructor Summary
Constructors Constructor Description DatabaseSnapshot(DatabaseObject[] examples, Database database)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DatabaseSnapshotclone(DatabaseObject[] examples)Searches the current snapshot content for the given examples.protected SnapshotGeneratorChaincreateGeneratorChain(Class<? extends DatabaseObject> databaseObjectType, Database database)<DatabaseObjectType extends DatabaseObject>
DatabaseObjectTypeget(DatabaseObjectType example)Returns the object described by the passed example if it is already included in this snapshot.<DatabaseObjectType extends DatabaseObject>
Set<DatabaseObjectType>get(Class<DatabaseObjectType> type)Returns all objects of the given type that are already included in this snapshot.DatabasegetDatabase()Map<String,Object>getMetadata()ResultSetCachegetResultSetCache(String key)CompareControl.SchemaComparison[]getSchemaComparisons()ObjectgetScratchData(String key)Deprecated.Will be removed with 4.0StringgetSerializableFieldNamespace(String field)Set<String>getSerializableFields()LiquibaseSerializable.SerializationTypegetSerializableFieldType(String field)ObjectgetSerializableFieldValue(String field)StringgetSerializedObjectName()StringgetSerializedObjectNamespace()SnapshotControlgetSnapshotControl()protected <T extends DatabaseObject>
Tinclude(T example)Include the object described by the passed example object in this snapshot.protected voidinit(DatabaseObject[] examples)protected booleanisWrongCatalog(DatabaseObject fieldValue)protected booleanisWrongSchema(DatabaseObject fieldValue)voidload(ParsedNode parsedNode, ResourceAccessor resourceAccessor)protected voidloadObjects(Map<String,DatabaseObject> objectMap, Map<String,DatabaseObject> allObjects, ParsedNode node, ResourceAccessor resourceAccessor)DatabaseSnapshotmerge(DatabaseSnapshot snapshotToMerge)Method which merges two object snapshot models into oneParsedNodeserialize()voidsetMetadata(Map<String,Object> metadata)voidsetSchemaComparisons(CompareControl.SchemaComparison[] schemaComparisons)ObjectsetScratchData(String key, Object data)
-
-
-
Field Detail
-
ALL_CATALOGS_STRING_SCRATCH_KEY
public static final String ALL_CATALOGS_STRING_SCRATCH_KEY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DatabaseSnapshot
public DatabaseSnapshot(DatabaseObject[] examples, Database database) throws DatabaseException, InvalidExampleException
-
-
Method Detail
-
init
protected void init(DatabaseObject[] examples) throws DatabaseException, InvalidExampleException
-
clone
public DatabaseSnapshot clone(DatabaseObject[] examples)
Searches the current snapshot content for the given examples. Returns a new DatabaseSnapshot containing a clone of every object from the examples array that was found.- Parameters:
examples- The array of snapshot objects to search and clone- Returns:
- a new DatabaseSnapshot object with the clones of the desired objects. If no object is found, an empty DatabaseSnapshot will be returned.
-
merge
public DatabaseSnapshot merge(DatabaseSnapshot snapshotToMerge)
Method which merges two object snapshot models into one- Parameters:
snapshotToMerge- Another object snapshot model- Returns:
- DatabaseSnapshot Merged object model
-
getSnapshotControl
public SnapshotControl getSnapshotControl()
-
getSerializedObjectName
public String getSerializedObjectName()
- Specified by:
getSerializedObjectNamein interfaceLiquibaseSerializable
-
getSerializedObjectNamespace
public String getSerializedObjectNamespace()
- Specified by:
getSerializedObjectNamespacein interfaceLiquibaseSerializable
-
getSerializableFieldNamespace
public String getSerializableFieldNamespace(String field)
- Specified by:
getSerializableFieldNamespacein interfaceLiquibaseSerializable
-
getSerializableFields
public Set<String> getSerializableFields()
- Specified by:
getSerializableFieldsin interfaceLiquibaseSerializable
-
getSerializableFieldValue
public Object getSerializableFieldValue(String field)
- Specified by:
getSerializableFieldValuein interfaceLiquibaseSerializable
-
getSerializableFieldType
public LiquibaseSerializable.SerializationType getSerializableFieldType(String field)
- Specified by:
getSerializableFieldTypein interfaceLiquibaseSerializable
-
getDatabase
public Database getDatabase()
-
getResultSetCache
public ResultSetCache getResultSetCache(String key)
-
include
protected <T extends DatabaseObject> T include(T example) throws DatabaseException, InvalidExampleException
Include the object described by the passed example object in this snapshot. Returns the object snapshot or null if the object does not exist in the database. If the same object was returned by an earlier include() call, the same object instance will be returned.
-
isWrongSchema
protected boolean isWrongSchema(DatabaseObject fieldValue)
-
isWrongCatalog
protected boolean isWrongCatalog(DatabaseObject fieldValue)
-
get
public <DatabaseObjectType extends DatabaseObject> DatabaseObjectType get(DatabaseObjectType example)
Returns the object described by the passed example if it is already included in this snapshot.
-
get
public <DatabaseObjectType extends DatabaseObject> Set<DatabaseObjectType> get(Class<DatabaseObjectType> type)
Returns all objects of the given type that are already included in this snapshot.
-
createGeneratorChain
protected SnapshotGeneratorChain createGeneratorChain(Class<? extends DatabaseObject> databaseObjectType, Database database)
-
load
public void load(ParsedNode parsedNode, ResourceAccessor resourceAccessor) throws ParsedNodeException
- Specified by:
loadin interfaceLiquibaseSerializable- Throws:
ParsedNodeException
-
loadObjects
protected void loadObjects(Map<String,DatabaseObject> objectMap, Map<String,DatabaseObject> allObjects, ParsedNode node, ResourceAccessor resourceAccessor) throws ReflectiveOperationException, ParsedNodeException
-
serialize
public ParsedNode serialize()
- Specified by:
serializein interfaceLiquibaseSerializable
-
getScratchData
public Object getScratchData(String key)
Deprecated.Will be removed with 4.0Used to get and store misc data that should be scoped to the snapshot. Helpful for caching snapshot results.
-
getSchemaComparisons
public CompareControl.SchemaComparison[] getSchemaComparisons()
-
setSchemaComparisons
public void setSchemaComparisons(CompareControl.SchemaComparison[] schemaComparisons)
-
-