Example usage for org.apache.commons.configuration2 ImmutableHierarchicalConfiguration getBoolean

List of usage examples for org.apache.commons.configuration2 ImmutableHierarchicalConfiguration getBoolean

Introduction

In this page you can find the example usage for org.apache.commons.configuration2 ImmutableHierarchicalConfiguration getBoolean.

Prototype

boolean getBoolean(String key, boolean defaultValue);

Source Link

Document

Get a boolean associated with the given configuration key.

Usage

From source file:com.gs.obevo.impl.AbstractEnvironmentEnricher.java

private Schema convertCfgToSchema(ImmutableHierarchicalConfiguration object, final Platform systemDbPlatform,
        final int schemaNameValidation) {
    String schemaName = object.getString("name");
    if (schemaNameValidation >= 2) {
        validateSchemaName(schemaName);// w w  w  . ja  va 2s. c  om
    }
    boolean readOnly = object.getBoolean("readOnly", false);

    MutableSetMultimap<String, String> excludedNameMap = Multimaps.mutable.set.empty();

    ImmutableList<ImmutableHierarchicalConfiguration> excludes = iterConfig(object, "excludes");
    if (!excludes.isEmpty()) {
        if (excludes.size() > 1) {
            throw new IllegalArgumentException("Only expecting 1 excludes element under <schema>");
        }
        ImmutableHierarchicalConfiguration excludesConfig = excludes.get(0);
        if (excludesConfig != null) {
            for (ChangeType changeType : systemDbPlatform.getChangeTypes()) {
                ImmutableList<String> excludedNames = iterListString(excludesConfig,
                        changeType.getName().toLowerCase());
                if (excludedNames.notEmpty()) {
                    excludedNameMap.putAll(changeType.getName(), excludedNames);
                }

                ImmutableList<String> excludedPatterns = iterListString(excludesConfig,
                        changeType.getName().toLowerCase() + "Pattern");
                if (excludedPatterns.notEmpty()) {
                    throw new IllegalArgumentException(
                            "The <objectType>Pattern element is deprecated. Use just the <objectType> element w/ wildcards (% or *)");
                }
            }

            if (iterListString(excludesConfig, "procedure").notEmpty()
                    || iterListString(excludesConfig, "procedurePattern").notEmpty()) {
                throw new IllegalArgumentException(
                        "The procedure and procedurePattern elements are no longer supported. Use <sp> only, with wildcards (% or *) if  needed");
            }
        }
    }

    return new Schema(schemaName,
            systemDbPlatform.getObjectExclusionPredicateBuilder().add(excludedNameMap.toImmutable()), readOnly);
}

From source file:com.gs.obevo.impl.AbstractEnvironmentEnricher.java

private void enrich(Environment dbEnv, ImmutableHierarchicalConfiguration envCfg, FileObject sourcePath,
        Platform systemDbPlatform) {//from w w  w  .  j av a 2s  . co m
    ImmutableList<String> sourceDirs = iterString(envCfg, "sourceDirs");
    ImmutableSet<String> acceptedExtensions = iterString(envCfg, "acceptedExtensions").toSet().toImmutable();
    FileObject rootDir = sourcePath.getType() == FileType.FILE ? sourcePath.getParent() : sourcePath;

    // Use coreSourcePath and additionalSourceDirs here (instead of setSourceDirs) to facilitate any external integrations
    dbEnv.setCoreSourcePath(rootDir);
    dbEnv.setAdditionalSourceDirs(sourceDirs);
    dbEnv.setAcceptedExtensions(acceptedExtensions);

    dbEnv.setCleanBuildAllowed(envCfg.getBoolean("cleanBuildAllowed", false));

    MutableMap<String, String> tokens = iterConfig(envCfg, "tokens.token")
            .toMap(new Function<ImmutableHierarchicalConfiguration, String>() {
                @Override
                public String valueOf(ImmutableHierarchicalConfiguration tok) {
                    return tok.getString("key");
                }
            }, new Function<ImmutableHierarchicalConfiguration, String>() {
                @Override
                public String valueOf(ImmutableHierarchicalConfiguration tok) {
                    return tok.getString("value");
                }
            });
    dbEnv.setTokens(tokens.toImmutable());

    dbEnv.setRollbackDetectionEnabled(envCfg.getBoolean("rollbackDetectionEnabled", true));

    Integer metadataLineReaderVersion = envCfg.getInteger("metadataLineReaderVersion", null);
    if (metadataLineReaderVersion != null) {
        dbEnv.setMetadataLineReaderVersion(metadataLineReaderVersion);
    }

    dbEnv.setForceEnvInfraSetup(envCfg.getBoolean("forceEnvInfraSetup", null));

    String sourceEncoding = envCfg.getString("sourceEncoding");
    if (sourceEncoding != null) {
        dbEnv.setSourceEncoding(sourceEncoding);
    }
    Integer legacyDirectoryStructureEnabledVersion = envCfg.getInteger("legacyDirectoryStructureEnabled", null);
    if (legacyDirectoryStructureEnabledVersion != null) {
        dbEnv.setLegacyDirectoryStructureEnabledVersion(legacyDirectoryStructureEnabledVersion);
    }

    enrichSchemas(dbEnv, envCfg, systemDbPlatform);
}