Example usage for org.springframework.beans.factory.config YamlMapFactoryBean YamlMapFactoryBean

List of usage examples for org.springframework.beans.factory.config YamlMapFactoryBean YamlMapFactoryBean

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config YamlMapFactoryBean YamlMapFactoryBean.

Prototype

YamlMapFactoryBean

Source Link

Usage

From source file:opensnap.security.SecurityChannelInterceptor.java

public void loadConfiguration(String filename) {
    YamlMapFactoryBean factory = new YamlMapFactoryBean();
    factory.setResources(new ClassPathResource[] { new ClassPathResource(filename) });
    this.securityDefinitions = factory.getObject();
}

From source file:io.pivotal.spring.xd.jdbcgpfdist.support.ControlFileFactoryBean.java

@SuppressWarnings({ "unchecked" })
private ControlFile parseYaml() {
    ControlFile cf = new ControlFile();
    YamlMapFactoryBean factory = new YamlMapFactoryBean();
    factory.setResources(controlFileResource);
    Map<String, Object> yaml = factory.getObject();

    // main map//w w  w  . j a  va 2s.c o m
    for (Entry<String, Object> e0 : yaml.entrySet()) {
        if (e0.getKey().toLowerCase().equals("gpload")) {
            if (e0.getValue() instanceof Map) {
                Map<String, Object> gploadMap = (Map<String, Object>) e0.getValue();

                // GPLOAD map
                for (Entry<String, Object> e1 : gploadMap.entrySet()) {
                    if (e1.getKey().toLowerCase().equals("output")) {

                        // GPLOAD.OUTPUT list
                        if (e1.getValue() instanceof List) {
                            for (Object v : (List<?>) e1.getValue()) {
                                if (v instanceof Map) {
                                    Map<String, Object> tableMap = (Map<String, Object>) v;
                                    for (Entry<String, Object> e2 : tableMap.entrySet()) {
                                        if (e2.getKey().toLowerCase().equals("table")) {
                                            if (e2.getValue() instanceof String) {
                                                cf.setGploadOutputTable((String) e2.getValue());
                                            }
                                        } else if (e2.getKey().toLowerCase().equals("mode")) {
                                            if (e2.getValue() instanceof String) {
                                                cf.setGploadOutputMode(ControlFile.OutputMode
                                                        .valueOf(((String) e2.getValue()).toUpperCase()));
                                            }
                                        } else if (e2.getKey().toLowerCase().equals("match_columns")) {
                                            if (e2.getValue() instanceof List) {
                                                cf.setGploadOutputMatchColumns(((List<String>) e2.getValue()));
                                            }
                                        } else if (e2.getKey().toLowerCase().equals("update_columns")) {
                                            if (e2.getValue() instanceof List) {
                                                cf.setGploadOutputUpdateColumns(((List<String>) e2.getValue()));
                                            }
                                        } else if (e2.getKey().toLowerCase().equals("update_condition")) {
                                            if (e2.getValue() instanceof String) {
                                                cf.setGploadOutputUpdateCondition((String) e2.getValue());
                                            }
                                        }
                                    }

                                }
                            }
                        }
                    } else if (e1.getKey().toLowerCase().equals("input")) {
                        if (e1.getValue() instanceof List) {
                            for (Object v : (List<?>) e1.getValue()) {
                                if (v instanceof Map) {
                                    Map<String, Object> tableMap = (Map<String, Object>) v;
                                    for (Entry<String, Object> e2 : tableMap.entrySet()) {
                                        if (e2.getKey().toLowerCase().equals("delimiter")) {
                                            if (e2.getValue() instanceof Character) {
                                                cf.setGploadInputDelimiter((Character) e2.getValue());
                                            } else if (e2.getValue() instanceof String) {
                                                if (((String) e2.getValue()).length() == 1) {
                                                    cf.setGploadInputDelimiter(
                                                            ((String) e2.getValue()).charAt(0));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    } else if (e1.getKey().toLowerCase().equals("sql")) {
                        if (e1.getValue() instanceof List) {
                            for (Object v : (List<?>) e1.getValue()) {
                                if (v instanceof Map) {
                                    Map<String, Object> sqlMap = (Map<String, Object>) v;
                                    for (Entry<String, Object> e2 : sqlMap.entrySet()) {
                                        if (e2.getKey().toLowerCase().equals("before")) {
                                            if (e2.getValue() instanceof String) {
                                                cf.addGploadSqlBefore((String) e2.getValue());
                                            }
                                        } else if (e2.getKey().toLowerCase().equals("after")) {
                                            if (e2.getValue() instanceof String) {
                                                cf.addGploadSqlAfter((String) e2.getValue());
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } else if (e0.getKey().toLowerCase().equals("database")) {
            if (e0.getValue() instanceof String) {
                cf.setDatabase((String) e0.getValue());
            }
        } else if (e0.getKey().toLowerCase().equals("user")) {
            if (e0.getValue() instanceof String) {
                cf.setUser((String) e0.getValue());
            }
        } else if (e0.getKey().toLowerCase().equals("password")) {
            if (e0.getValue() instanceof String) {
                cf.setPassword((String) e0.getValue());
            }
        } else if (e0.getKey().toLowerCase().equals("host")) {
            if (e0.getValue() instanceof String) {
                cf.setHost((String) e0.getValue());
            }
        } else if (e0.getKey().toLowerCase().equals("port")) {
            if (e0.getValue() instanceof Integer) {
                cf.setPort((Integer) e0.getValue());
            }
        }
    }
    return cf;
}

From source file:org.obiba.mica.micaConfig.service.TaxonomyConfigService.java

private Taxonomy readTaxonomyFromYaml(String yamlResourcePath) {
    YamlMapFactoryBean factory = new YamlMapFactoryBean();
    factory.setResources(new ClassPathResource(yamlResourcePath));

    return mapper.convertValue(factory.getObject(), Taxonomy.class);
}

From source file:ren.hankai.cordwood.core.Preferences.java

/**
 * ???/*  ww w .  j  a  va  2s.  c om*/
 *
 * @author hankai
 * @since Jun 27, 2016 10:09:35 PM
 */
private static Map<String, Object> getSystemPrefs() {
    if (parameters == null) {
        parameters = new HashMap<>();
        final YamlMapFactoryBean bean = new YamlMapFactoryBean();
        bean.setResources(new FileSystemResource(Preferences.getConfigDir() + "/system.yml"));
        parameters.putAll(bean.getObject());
    }
    return parameters;
}