<commit_before>/**
 * Copyright (C) 2009 - 2010 by OpenGamma Inc.
 *
 * Please see distribution for license.
 */
package com.opengamma.financial.analytics.ircurve;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.opengamma.config.ConfigDocument;
import com.opengamma.config.ConfigMaster;
import com.opengamma.config.ConfigTypeMaster;
import com.opengamma.core.common.Currency;

/**
 * Populates the yield curve configuration.
 */
public class YieldCurveConfigPopulator {
  private static final Logger s_logger = LoggerFactory.getLogger(YieldCurveConfigPopulator.class);

  public YieldCurveConfigPopulator(ConfigMaster cfgMaster) {
    populateCurveConfigMaster(cfgMaster);
  }
  
  public static ConfigMaster populateCurveConfigMaster(ConfigMaster cfgMaster) {
    ConfigTypeMaster<YieldCurveDefinition> curveDefinitionMaster = cfgMaster.typed(YieldCurveDefinition.class);
    populateCurveDefinitionConfigMaster(curveDefinitionMaster);
    ConfigTypeMaster<CurveSpecificationBuilderConfiguration> curveSpecificationBuilderConfigMaster = cfgMaster.typed(CurveSpecificationBuilderConfiguration.class);
    populateCurveSpecificationBuilderConfigMaster(curveSpecificationBuilderConfigMaster);
    return cfgMaster;
  }
  
  private static void dumpDefinition(YieldCurveDefinition curveDefinition) {
    s_logger.warn("Curve Definition");
    s_logger.warn("  Name:" + curveDefinition.getName());
    s_logger.warn("  Currency:" + curveDefinition.getCurrency());
    s_logger.warn("  Strips:");
    for (FixedIncomeStrip strip : curveDefinition.getStrips()) {
      s_logger.warn("    " + strip);
    }
  }

  public static void populateCurveDefinitionConfigMaster(ConfigTypeMaster<YieldCurveDefinition> configRepo) {
    Map<String, Map<Currency, YieldCurveDefinition>> standardCurveDefinitions = CurveDefinitionAndSpecifications.buildStandardCurveDefintions();
    for (Map.Entry<String, Map<Currency, YieldCurveDefinition>> entry : standardCurveDefinitions.entrySet()) {
      String curveName = entry.getKey();
      Map<Currency, YieldCurveDefinition> definitions = entry.getValue();
      for (Map.Entry<Currency, YieldCurveDefinition> currencyEntry : definitions.entrySet()) {
        Currency ccy = currencyEntry.getKey();
        YieldCurveDefinition definition = currencyEntry.getValue();
        ConfigDocument<YieldCurveDefinition> document = new ConfigDocument<YieldCurveDefinition>();
        document.setName(curveName + "_" + ccy.getISOCode());
        document.setValue(definition);<commit_msg>Change diagnostic printing from WARN to DEBUG.<commit_after>/**
 * Copyright (C) 2009 - 2010 by OpenGamma Inc.
 *
 * Please see distribution for license.
 */
package com.opengamma.financial.analytics.ircurve;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.opengamma.config.ConfigDocument;
import com.opengamma.config.ConfigMaster;
import com.opengamma.config.ConfigTypeMaster;
import com.opengamma.core.common.Currency;

/**
 * Populates the yield curve configuration.
 */
public class YieldCurveConfigPopulator {
  private static final Logger s_logger = LoggerFactory.getLogger(YieldCurveConfigPopulator.class);

  public YieldCurveConfigPopulator(ConfigMaster cfgMaster) {
    populateCurveConfigMaster(cfgMaster);
  }
  
  public static ConfigMaster populateCurveConfigMaster(ConfigMaster cfgMaster) {
    ConfigTypeMaster<YieldCurveDefinition> curveDefinitionMaster = cfgMaster.typed(YieldCurveDefinition.class);
    populateCurveDefinitionConfigMaster(curveDefinitionMaster);
    ConfigTypeMaster<CurveSpecificationBuilderConfiguration> curveSpecificationBuilderConfigMaster = cfgMaster.typed(CurveSpecificationBuilderConfiguration.class);
    populateCurveSpecificationBuilderConfigMaster(curveSpecificationBuilderConfigMaster);
    return cfgMaster;
  }
  
  private static void dumpDefinition(YieldCurveDefinition curveDefinition) {
    s_logger.debug("Curve Definition");
    s_logger.debug("  Name:" + curveDefinition.getName());
    s_logger.debug("  Currency:" + curveDefinition.getCurrency());
    s_logger.debug("  Strips:");
    for (FixedIncomeStrip strip : curveDefinition.getStrips()) {
      s_logger.debug("    " + strip);
    }
  }

  public static void populateCurveDefinitionConfigMaster(ConfigTypeMaster<YieldCurveDefinition> configRepo) {
    Map<String, Map<Currency, YieldCurveDefinition>> standardCurveDefinitions = CurveDefinitionAndSpecifications.buildStandardCurveDefintions();
    for (Map.Entry<String, Map<Currency, YieldCurveDefinition>> entry : standardCurveDefinitions.entrySet()) {
      String curveName = entry.getKey();
      Map<Currency, YieldCurveDefinition> definitions = entry.getValue();
      for (Map.Entry<Currency, YieldCurveDefinition> currencyEntry : definitions.entrySet()) {
        Currency ccy = currencyEntry.getKey();
        YieldCurveDefinition definition = currencyEntry.getValue();
        ConfigDocument<YieldCurveDefinition> document = new ConfigDocument<YieldCurveDefinition>();
        document.setName(curveName + "_" + ccy.getISOCode());
        document.setValue(definition);
{'fraction_non_alphanumeric': 0.09195178849144635, 'fraction_numerical': 0.0038880248833592537, 'mean_word_length': 5.716710182767624, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7064796', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1416, 'n_words': 253}