@Override public Config getAdditionalConfiguration() { if (additionalConfiguration == null) { return new Config(); } else { return additionalConfiguration; } }
public final void setAdditionalConfiguration(final Config additionalConfiguration) { // Make a defensive copy this.additionalConfiguration = new Config(additionalConfiguration); }
public CommandLineArgumentsParser(final String[] args) { this.args = requireNonNull(args, "No arguments provided"); optionsMap = new Config(); nonOptionArguments = new ArrayList<>(); }
public CommandLineArgumentsParser(final String[] args) { this.args = requireNonNull(args, "No arguments provided"); optionsMap = new Config(); nonOptionArguments = new ArrayList<>(); }
/** * Gets the complete bundled database configuration set. This is * useful in building the SchemaCrawler options. */ public final Config getConfig() { if (configResource == null) { return new Config(); } return PropertiesUtility.loadConfig(configResource); }
public SchemaRetrievalOptionsBuilder withInformationSchemaViews(final Map<String, String> informationSchemaViews) { informationSchemaViewsBuilder .fromConfig(new Config(informationSchemaViews)); return this; }
/** * Loads a properties file. * * @param inputResource * Config resource. * @return Config */ public static Config loadConfig(final InputResource inputResource) { final Properties properties = loadProperties(inputResource); return new Config(properties); }
public SchemaRetrievalOptionsBuilder withInformationSchemaViews(final Map<String, String> informationSchemaViews) { informationSchemaViewsBuilder .fromConfig(new Config(informationSchemaViews)); return this; }
@Override public Config toConfig() { final Config config = new Config(); config.setStringValue(SC_INPUT_ENCODING, inputEncodingCharset.name()); config.setStringValue(SC_OUTPUT_ENCODING, outputEncodingCharset.name()); return config; }
@Override public OperationOptionsBuilder fromConfig(final Config map) { if (map == null) { return this; } super.fromConfig(map); final Config config = new Config(map); isShowLobs = config.getBooleanValue(SHOW_LOBS, false); return this; }
protected BaseSchemaCrawlerCommand(final String command) { if (isBlank(command)) { throw new IllegalArgumentException("No command specified"); } this.command = command; schemaCrawlerOptions = SchemaCrawlerOptionsBuilder .newSchemaCrawlerOptions(); outputOptions = OutputOptionsBuilder.newOutputOptions(); additionalConfiguration = new Config(); }
public SchemaCrawlerExecutable(final String command) { if (isBlank(command)) { throw new IllegalArgumentException("No command specified"); } this.command = command; schemaCrawlerOptions = SchemaCrawlerOptionsBuilder .newSchemaCrawlerOptions(); outputOptions = OutputOptionsBuilder.newOutputOptions(); additionalConfiguration = new Config(); }
@Override public OutputOptionsBuilder fromConfig(final Config config) { final Config configProperties; if (config == null) { configProperties = new Config(); } else { configProperties = config; } this .withInputEncoding(configProperties.getStringValue(SC_INPUT_ENCODING, UTF_8.name())) .withOutputEncoding(configProperties.getStringValue(SC_OUTPUT_ENCODING, UTF_8.name())); return this; }
/** * Loads a properties file from a CLASSPATH resource. * * @param resource * A CLASSPATH resource. * @return Config loaded from classpath resource * @throws IOException * On an exception */ protected static Config loadConfigFromClasspathResource(final String resource) throws IOException { final InputStream stream = DatabaseTestUtility.class .getResourceAsStream(resource); requireNonNull(stream, "Could not load config from resource, " + resource); final Reader reader = new InputStreamReader(stream, StandardCharsets.UTF_8); final Properties properties = new Properties(); try (final BufferedReader bufferedReader = new BufferedReader(reader);) { properties.load(bufferedReader); } return new Config(properties); }
@Override public ConnectionOptions createConnectionOptions() throws SchemaCrawlerException { requireNonNull(databaseFile, "Database file not loaded"); final Config config = new Config(); config.put("server", "sqlite"); config.put("database", databaseFile.toString()); try { final ConnectionOptions connectionOptions = new SQLiteDatabaseConnector() .newDatabaseConnectionOptions(new SingleUseUserCredentials(), config); return connectionOptions; } catch (final IOException e) { throw new SchemaCrawlerException("Cannot read datad database file, " + databaseFile, e); } }
@Override public ConnectionOptions createConnectionOptions() throws SchemaCrawlerException { try { requireNonNull(postgreSQL, "Database server not started"); final Config config = new Config(); config.put("url", getConnectionUrl()); final UserCredentials userCredentials = new SingleUseUserCredentials(getUser(), getPassword()); final ConnectionOptions connectionOptions = new DatabaseConnectionOptions(userCredentials, config); return connectionOptions; } catch (final Throwable e) { throw new SchemaCrawlerException("Cannot read file, " + databaseFile, e); } }
private void run(final TestContext testContext, final DatabaseConnectionInfo connectionInfo, final Map<String, String> argsMap, final Map<String, String> config, final String command) throws Exception { argsMap.put("noinfo", Boolean.TRUE.toString()); argsMap.put("schemas", ".*\\.(?!FOR_LINT).*"); argsMap.put("infolevel", "maximum"); final Config runConfig = new Config(); final Config informationSchema = loadHsqldbConfig(); runConfig.putAll(informationSchema); if (config != null) { runConfig.putAll(config); } assertThat(outputOf(commandlineExecution(connectionInfo, command, argsMap, runConfig, TextOutputFormat.text)), hasSameContentAs(classpathResource(COMMAND_LINE_OUTPUT + testContext.testMethodName() + ".txt"))); }
@Test public void overrideMetadataRetrievalStrategy(final TestContext testContext, final DatabaseConnectionInfo connectionInfo) throws Exception { clean(METADATA_RETRIEVAL_STRATEGY_OUTPUT); final SchemaTextDetailType schemaTextDetailType = SchemaTextDetailType.schema; final InfoLevel infoLevel = InfoLevel.minimum; final OutputFormat outputFormat = TextOutputFormat.text; final Config config = new Config(); config.put("schemacrawler.schema.retrieval.strategy.tables", MetadataRetrievalStrategy.data_dictionary_all.name()); final Map<String, String> argsMap = new HashMap<>(); argsMap.put("infolevel", infoLevel.name()); argsMap.put("noinfo", "true"); // Check that System.err has an error assertThat(outputOf(commandlineExecution(connectionInfo, schemaTextDetailType.name(), argsMap, config, outputFormat)), hasNoContent()); final String errorLog = err.getFileContents(); assertThat(errorLog, containsString("No tables SQL provided")); }
@Override public Config toConfig() { final Config config = new Config(); config.setBooleanValue(NO_FOOTER, isNoFooter); config.setBooleanValue(NO_HEADER, isNoHeader); config.setBooleanValue(NO_SCHEMACRAWLER_INFO, isNoSchemaCrawlerInfo); config.setBooleanValue(SHOW_DATABASE_INFO, isShowDatabaseInfo); config.setBooleanValue(SHOW_JDBC_DRIVER_INFO, isShowJdbcDriverInfo); config.setBooleanValue(APPEND_OUTPUT, isAppendOutput); config.setBooleanValue(SHOW_UNQUALIFIED_NAMES, isShowUnqualifiedNames); config.setBooleanValue(SORT_ALPHABETICALLY_TABLES, isAlphabeticalSortForTables); config.setBooleanValue(SORT_ALPHABETICALLY_TABLE_COLUMNS, isAlphabeticalSortForTableColumns); config.setBooleanValue(SORT_ALPHABETICALLY_ROUTINES, isAlphabeticalSortForRoutines); config.setBooleanValue(SORT_ALPHABETICALLY_ROUTINE_COLUMNS, isAlphabeticalSortForRoutineColumns); config.setBooleanValue(NO_SCHEMA_COLORS, isNoSchemaColors); config.setEnumValue(IDENTIFIER_QUOTING_STRATEGY, identifierQuotingStrategy); return config; }
@Override public B fromConfig(final Config map) { if (map == null) { return (B) this; } super.fromConfig(map); final Config config = new Config(map); isShowStandardColumnTypeNames = config .getBooleanValue(SHOW_STANDARD_COLUMN_TYPE_NAMES); isShowOrdinalNumbers = config.getBooleanValue(SHOW_ORDINAL_NUMBERS); isShowRowCounts = config.getBooleanValue(SHOW_ROW_COUNTS); isHideForeignKeyNames = config.getBooleanValue(HIDE_FOREIGN_KEY_NAMES); isHidePrimaryKeyNames = config.getBooleanValue(HIDE_PRIMARY_KEY_NAMES); isHideIndexNames = config.getBooleanValue(HIDE_INDEX_NAMES); isHideTriggerNames = config.getBooleanValue(HIDE_TRIGGER_NAMES); isHideRoutineSpecificNames = config .getBooleanValue(HIDE_ROUTINE_SPECIFIC_NAMES); isHideTableConstraintNames = config.getBooleanValue(HIDE_CONSTRAINT_NAMES); isHideRemarks = config.getBooleanValue(HIDE_REMARKS); isShowWeakAssociations = config.getBooleanValue(SHOW_WEAK_ASSOCIATIONS); isAlphabeticalSortForForeignKeys = config .getBooleanValue(SC_SORT_ALPHABETICALLY_TABLE_FOREIGNKEYS); isAlphabeticalSortForIndexes = config .getBooleanValue(SC_SORT_ALPHABETICALLY_TABLE_INDEXES); return (B) this; }