Search in sources :

Example 1 with SnapshotListener

use of liquibase.snapshot.SnapshotListener in project liquibase by liquibase.

the class InternalSnapshotCommandStep method run.

@Override
public void run(CommandResultsBuilder resultsBuilder) throws Exception {
    CommandScope commandScope = resultsBuilder.getCommandScope();
    Database database = commandScope.getArgumentValue(DATABASE_ARG);
    SnapshotListener snapshotListener = commandScope.getArgumentValue(SNAPSHOT_LISTENER_ARG);
    CatalogAndSchema[] schemas = commandScope.getArgumentValue(SCHEMAS_ARG);
    InternalSnapshotCommandStep.logUnsupportedDatabase(database, this.getClass());
    SnapshotControl snapshotControl = new SnapshotControl(database);
    snapshotControl.setSnapshotListener(snapshotListener);
    if (schemas == null) {
        schemas = new CatalogAndSchema[] { database.getDefaultSchema() };
    }
    ObjectQuotingStrategy originalQuotingStrategy = database.getObjectQuotingStrategy();
    database.setObjectQuotingStrategy(ObjectQuotingStrategy.QUOTE_ALL_OBJECTS);
    DatabaseSnapshot snapshot;
    try {
        snapshot = SnapshotGeneratorFactory.getInstance().createSnapshot(schemas, database, snapshotControl);
    } finally {
        database.setObjectQuotingStrategy(originalQuotingStrategy);
    }
    snapshot.setMetadata(this.getSnapshotMetadata());
    resultsBuilder.addResult("snapshot", snapshot);
}
Also used : Database(liquibase.database.Database) CatalogAndSchema(liquibase.CatalogAndSchema) SnapshotControl(liquibase.snapshot.SnapshotControl) DatabaseSnapshot(liquibase.snapshot.DatabaseSnapshot) SnapshotListener(liquibase.snapshot.SnapshotListener) ObjectQuotingStrategy(liquibase.database.ObjectQuotingStrategy)

Aggregations

CatalogAndSchema (liquibase.CatalogAndSchema)1 Database (liquibase.database.Database)1 ObjectQuotingStrategy (liquibase.database.ObjectQuotingStrategy)1 DatabaseSnapshot (liquibase.snapshot.DatabaseSnapshot)1 SnapshotControl (liquibase.snapshot.SnapshotControl)1 SnapshotListener (liquibase.snapshot.SnapshotListener)1