public void run() { liquigraph.runMigrations(configuration); } }
/** * Triggers migration execution, according to the specified {@link org.liquigraph.core.configuration.Configuration} * instance. * * @param configuration configuration of the changelog location and graph connection parameters * @see org.liquigraph.core.configuration.ConfigurationBuilder to create {@link org.liquigraph.core.configuration.Configuration instances} */ public void runMigrations(Configuration configuration) { migrationRunner.runMigrations(configuration); } }
public Collection<Changeset> computeChangesetsToInsert(ExecutionContexts executionContexts, Collection<Changeset> declaredChangesets, Collection<Changeset> persistedChangesets) { return diff(executionContexts, declaredChangesets, persistedChangesets); }
@Override public void afterPropertiesSet() { final Configuration configuration = new ConfigurationBuilder() .withDataSource(dataSource) .withChangelogLoader(changelogLoader) .withMasterChangelogLocation(changeLog) .withExecutionContexts(asList(executionContexts)) .withRunMode() .build(); new Liquigraph().runMigrations(configuration); } }
public void runMigrations(Configuration configuration) { Collection<Changeset> declaredChangesets = parseChangesets(configuration.changelogLoader(), configuration.masterChangelog()); Supplier<Connection> connectionSupplier = new ConnectionSupplier(configuration); try (Connection writeConnection = connectionSupplier.get()) { Collection<Changeset> persistedChangesets = readPersistedChangesets(declaredChangesets, writeConnection); Collection<Changeset> changelog = changelogDiffMaker.computeChangesetsToInsert( configuration.executionContexts(), declaredChangesets, persistedChangesets ); writeApplicableChangesets(configuration, writeConnection, connectionSupplier, changelog); } catch (SQLException e) { LOGGER.error(e.getMessage(), e); } }
@Inject public LiquigraphClient(Configuration configuration) { this.configuration = configuration; liquigraph = new Liquigraph(); }
@VisibleForTesting Liquigraph(LiquigraphJdbcConnector connector) { migrationRunner = new MigrationRunner( connector, new ChangelogParser(new XmlSchemaValidator(), new ChangelogPreprocessor(new ImportResolver())), new ChangelogGraphReader(), new ChangelogDiffMaker(), new ConditionExecutor(), new ConditionPrinter(), new PersistedChangesetValidator() ); }
private static Collection<Changeset> diff(ExecutionContexts executionContexts, Collection<Changeset> declaredChangesets, Collection<Changeset> persistedChangesets) { return from(declaredChangesets) .filter(BY_ANY_EXECUTION_CONTEXT(executionContexts)) .filter(executionFilter(persistedChangesets)) .toList(); }
private Collection<Changeset> readPersistedChangesets(Collection<Changeset> declaredChangesets, Connection writeConnection) { Collection<Changeset> persistedChangesets = changelogReader.read(writeConnection); Collection<String> errors = persistedChangesetValidator.validate(declaredChangesets, persistedChangesets); if (!errors.isEmpty()) { throw new IllegalArgumentException(formatErrorMessage(errors)); } return persistedChangesets; }
@Override public final void execute() throws MojoExecutionException, MojoFailureException { String directory = project.getBuild().getDirectory(); try { Configuration configuration = withExecutionMode(new ConfigurationBuilder() .withClassLoader(ProjectClassLoader.getClassLoader(project)) .withExecutionContexts(executionContexts(executionContexts)) .withMasterChangelogLocation(changelog) .withUsername(username) .withPassword(password) .withUri(jdbcUri)) .build(); getLog().info("Generating Cypher output file in directory: " + directory); new Liquigraph().runMigrations(configuration); } catch (Exception e) { throw new MojoExecutionException(e.getMessage(), e); } }
@Provides public Liquigraph provideLiquigraph() { return new Liquigraph(); }
public static void main(String[] args) { LiquigraphCli cli = new LiquigraphCli(); JCommander commander = new JCommander(cli, args); commander.setProgramName("liquigraph"); if (cli.help) { commander.usage(); return; } if (cli.version) { printVersion(); return; } ConfigurationBuilder builder = new ConfigurationBuilder() .withMasterChangelogLocation(fileName(cli.changelog)) .withUri(cli.graphDbUri) .withUsername(cli.username) .withPassword(cli.password) .withExecutionContexts(executionContexts(cli.executionContexts)) .withClassLoader(classloader(parentFolder(cli.changelog), cli.dryRunOutputDirectory)); String outputDirectory = cli.dryRunOutputDirectory; if (outputDirectory != null) { builder.withDryRunMode(Paths.get(outputDirectory)); } else { builder.withRunMode(); } new Liquigraph().runMigrations( builder.build() ); }