use of liquibase.changelog.ChangeLogParameters in project liquibase by liquibase.
the class RegisterChangelogCommandStep method parseChangeLogFile.
private DatabaseChangeLog parseChangeLogFile(String changeLogFile) throws LiquibaseException {
ResourceAccessor resourceAccessor = Scope.getCurrentScope().getResourceAccessor();
ChangeLogParser parser = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor);
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
return parser.parse(changeLogFile, changeLogParameters, resourceAccessor);
}
use of liquibase.changelog.ChangeLogParameters in project liquibase by liquibase.
the class SQLFileChange method getSql.
@Override
@DatabaseChangeProperty(isChangeProperty = false)
public String getSql() {
String sql = super.getSql();
if (sql == null) {
InputStream sqlStream;
try {
sqlStream = openSqlStream();
if (sqlStream == null) {
return null;
}
String content = StreamUtil.readStreamAsString(sqlStream, getEncoding());
if (getChangeSet() != null) {
ChangeLogParameters parameters = getChangeSet().getChangeLogParameters();
if (parameters != null) {
content = parameters.expandExpressions(content, getChangeSet().getChangeLog());
}
}
return content;
} catch (IOException e) {
throw new UnexpectedLiquibaseException(e);
}
} else {
return sql;
}
}
use of liquibase.changelog.ChangeLogParameters in project liquibase by liquibase.
the class LiquibaseRollbackOneUpdateSQL method performLiquibaseTask.
@Override
protected void performLiquibaseTask(Liquibase liquibase) throws LiquibaseException {
//
// Check the Pro license
//
boolean hasProLicense = MavenUtils.checkProLicense(liquibaseProLicenseKey, commandName, getLog());
if (!hasProLicense) {
throw new LiquibaseException("The 'rollbackOneUpdateSQL' command requires a valid Liquibase Pro license. Get a free Pro license key at https://liquibase.com/protrial and add liquibase.pro.licenseKey=<yourKey> into your defaults file or use --pro-license-key=<yourKey> before your command in the CLI.");
}
Database database = liquibase.getDatabase();
CommandScope liquibaseCommand = new CommandScope("internalRollbackOneUpdateSQL");
Map<String, Object> argsMap = getCommandArgsObjectMap(liquibase);
Writer outputWriter = null;
try {
outputWriter = createOutputWriter();
argsMap.put("outputWriter", outputWriter);
} catch (IOException ioe) {
throw new LiquibaseException("Error executing rollbackOneChangeSetSQL. Unable to create output writer.", ioe);
}
ChangeLogParameters clp = new ChangeLogParameters(database);
argsMap.put("changeLogParameters", clp);
if (force != null && !Boolean.parseBoolean(force)) {
throw new LiquibaseException("Invalid value for --force. You must specify 'liquibase.force=true' to use rollbackOneUpdateSQL.");
}
argsMap.put("force", Boolean.TRUE);
argsMap.put("liquibase", liquibase);
for (Map.Entry<String, Object> entry : argsMap.entrySet()) {
liquibaseCommand.addArgumentValue(entry.getKey(), entry.getValue());
}
liquibaseCommand.execute();
}
use of liquibase.changelog.ChangeLogParameters in project liquibase by liquibase.
the class LiquibaseRollbackOneChangeSetMojo method performLiquibaseTask.
@Override
protected void performLiquibaseTask(Liquibase liquibase) throws LiquibaseException {
//
// Call the base class method so that
// Hub settings will be made
//
super.performLiquibaseTask(liquibase);
//
// Check the Pro license
//
boolean hasProLicense = MavenUtils.checkProLicense(liquibaseProLicenseKey, commandName, getLog());
if (!hasProLicense) {
throw new LiquibaseException("The command 'rollbackOneChangeSet' requires a Liquibase Pro License, available at http://www.liquibase.org/download or sales@liquibase.com." + "Add liquibase.pro.licenseKey as a Maven property or add liquibase.pro.licenseKey=<yourKey> into your defaults file.");
}
Database database = liquibase.getDatabase();
CommandScope liquibaseCommand = new CommandScope("internalRollbackOneChangeSet");
Map<String, Object> argsMap = getCommandArgsObjectMap(liquibase);
ChangeLogParameters clp = new ChangeLogParameters(database);
argsMap.put("changeLogParameters", clp);
if (force == null || (force != null && !Boolean.parseBoolean(force))) {
throw new LiquibaseException("Invalid value for --force. You must specify 'liquibase.force=true' to use rollbackOneChangeSet.");
}
argsMap.put("force", Boolean.TRUE);
argsMap.put("liquibase", liquibase);
argsMap.put("liquibaseProLicenseKey", liquibaseProLicenseKey);
for (Map.Entry<String, Object> entry : argsMap.entrySet()) {
liquibaseCommand.addArgumentValue(entry.getKey(), entry.getValue());
}
liquibaseCommand.execute();
}
Aggregations