liquibase.changelog.ChangeLogParameters Java Examples
The following examples show how to use
liquibase.changelog.ChangeLogParameters.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LiquibaseProcessor.java From quarkus with Apache License 2.0 | 5 votes |
/** * Collect the configured changeLog file for the default and all named datasources. * <p> * A {@link LinkedHashSet} is used to avoid duplications. */ private List<String> getChangeLogs(Collection<String> dataSourceNames, LiquibaseBuildTimeConfig liquibaseBuildConfig) { if (dataSourceNames.isEmpty()) { return Collections.emptyList(); } ChangeLogParameters changeLogParameters = new ChangeLogParameters(); ClassLoaderResourceAccessor classLoaderResourceAccessor = new ClassLoaderResourceAccessor( Thread.currentThread().getContextClassLoader()); ChangeLogParserFactory changeLogParserFactory = ChangeLogParserFactory.getInstance(); Set<String> resources = new LinkedHashSet<>(); // default datasource if (DataSourceUtil.hasDefault(dataSourceNames)) { resources.addAll(findAllChangeLogs(liquibaseBuildConfig.defaultDataSource.changeLog, changeLogParserFactory, classLoaderResourceAccessor, changeLogParameters)); } // named datasources Collection<String> namedDataSourceChangeLogs = dataSourceNames.stream() .filter(n -> !DataSourceUtil.isDefault(n)) .map(liquibaseBuildConfig::getConfigForDataSourceName) .map(c -> c.changeLog) .collect(Collectors.toCollection(LinkedHashSet::new)); for (String namedDataSourceChangeLog : namedDataSourceChangeLogs) { resources.addAll( findAllChangeLogs(namedDataSourceChangeLog, changeLogParserFactory, classLoaderResourceAccessor, changeLogParameters)); } LOGGER.debugf("Liquibase changeLogs: %s", resources); return new ArrayList<>(resources); }
Example #2
Source File: LiquibaseProcessor.java From quarkus with Apache License 2.0 | 5 votes |
/** * Finds all resource files for the given change log file */ private Set<String> findAllChangeLogs(String file, ChangeLogParserFactory changeLogParserFactory, ClassLoaderResourceAccessor classLoaderResourceAccessor, ChangeLogParameters changeLogParameters) { try { ChangeLogParser parser = changeLogParserFactory.getParser(file, classLoaderResourceAccessor); DatabaseChangeLog changelog = parser.parse(file, changeLogParameters, classLoaderResourceAccessor); if (changelog != null) { Set<String> result = new LinkedHashSet<>(); // get all changeSet files for (ChangeSet changeSet : changelog.getChangeSets()) { result.add(changeSet.getFilePath()); // get all parents of the changeSet DatabaseChangeLog parent = changeSet.getChangeLog(); while (parent != null) { result.add(parent.getFilePath()); parent = parent.getParentChangeLog(); } } result.add(changelog.getFilePath()); return result; } } catch (LiquibaseException ex) { throw new IllegalStateException(ex); } return Collections.emptySet(); }
Example #3
Source File: ChangeLogParserTest.java From liquibase-percona with Apache License 2.0 | 4 votes |
private DatabaseChangeLog loadChangeLog(String filename) throws Exception { ChangeLogParserFactory parserFactory = ChangeLogParserFactory.getInstance(); ChangeLogParser parser = parserFactory.getParser(filename, resourceAccessor); return parser.parse(filename, new ChangeLogParameters(), resourceAccessor); }