<commit_before>/**
 * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
 * 
 * Please see distribution for license.
 */
package com.opengamma.web.spring;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

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

import com.opengamma.OpenGammaRuntimeException;
import com.opengamma.core.config.ConfigSource;
import com.opengamma.engine.function.config.FunctionConfiguration;
import com.opengamma.engine.function.config.ParameterizedFunctionConfiguration;
import com.opengamma.engine.function.config.RepositoryConfiguration;
import com.opengamma.engine.function.config.RepositoryConfigurationSource;
import com.opengamma.engine.function.config.SimpleRepositoryConfigurationSource;
import com.opengamma.engine.function.config.StaticFunctionConfiguration;
import com.opengamma.financial.analytics.model.volatility.surface.ForexCallDeltaVolatilitySurfaceFunction;
import com.opengamma.financial.analytics.model.volatility.surface.ForexStrangleRiskReversalVolatilitySurfaceFunction;
import com.opengamma.financial.analytics.model.volatility.surface.InterpolatedVolatilitySurfaceFunction;
import com.opengamma.financial.analytics.volatility.VolatilitySurfaceSpecificationFunction;
import com.opengamma.financial.analytics.volatility.surface.ConfigDBFuturePriceCurveDefinitionSource;
import com.opengamma.financial.analytics.volatility.surface.ConfigDBFuturePriceCurveSpecificationSource;
import com.opengamma.financial.analytics.volatility.surface.ConfigDBVolatilitySurfaceDefinitionSource;
import com.opengamma.financial.analytics.volatility.surface.ConfigDBVolatilitySurfaceSpecificationSource;
import com.opengamma.financial.analytics.volatility.surface.EquityFutureOptionVolatilitySurfaceDataFunction;
import com.opengamma.financial.analytics.volatility.surface.EquityOptionVolatilitySurfaceDataFunctionDeprecated;
import com.opengamma.financial.analytics.volatility.surface.FuturePriceCurveDefinition;
import com.opengamma.financial.analytics.volatility.surface.FuturePriceCurveSpecification;
import com.opengamma.financial.analytics.volatility.surface.Grid2DInterpolatedVolatilitySurfaceFunctionDeprecated;
import com.opengamma.financial.analytics.volatility.surface.IRFutureOptionVolatilitySurfaceDataFunction;
import com.opengamma.financial.analytics.volatility.surface.InterpolatedVolatilitySurfaceDefaultPropertiesFunction;
import com.opengamma.financial.analytics.volatility.surface.RawEquityOptionVolatilitySurfaceDataFunction;
import com.opengamma.financial.analytics.volatility.surface.RawFXVolatilitySurfaceDataFunction;
import com.opengamma.financial.analytics.volatility.surface.RawIRFutureOptionVolatilitySurfaceDataFunction;
import com.opengamma.financial.analytics.volatility.surface.RawSwaptionATMVolatilitySurfaceDataFunction;
import com.opengamma.financial.analytics.volatility.surface.SwaptionATMVolatilitySurfaceDataFunction;
import com.opengamma.financial.analytics.volatility.surface.VolatilitySurfaceDefinition;
import com.opengamma.financial.analytics.volatility.surface.VolatilitySurfaceSpecification;
import com.opengamma.master.config.ConfigMaster;
import com.opengamma.master.config.impl.MasterConfigSource;
import com.opengamma.util.SingletonFactoryBean;

/**
 * Creates function repository configuration for surface supplying functions.
 * 
 * Note [PLAT-1094] - the functions should really be built by scanning the surfaces and currencies available. 
 */
public class DemoSurfaceFunctionConfiguration extends SingletonFactoryBean<RepositoryConfigurationSource> {
  private static final Logger s_logger = LoggerFactory.getLogger(DemoSurfaceFunctionConfiguration.class);
  
  private ConfigMaster _configMaster;
  private ConfigDBVolatilitySurfaceDefinitionSource _volSurfaceDefinitionSource;
  private ConfigDBVolatilitySurfaceSpecificationSource _volSurfaceSpecificationSource;
  private ConfigDBFuturePriceCurveDefinitionSource _priceCurveDefinitionSource;
  private ConfigDBFuturePriceCurveSpecificationSource _priceCurveSpecificationSource;

  public void setConfigMaster(final ConfigMaster configMaster) {
    _configMaster = configMaster;
    // I've injected the master so we can do the more complex querying when we're ready.
    ConfigSource configSource = new MasterConfigSource(_configMaster);
    _volSurfaceDefinitionSource = new ConfigDBVolatilitySurfaceDefinitionSource(configSource);
    _volSurfaceSpecificationSource = new ConfigDBVolatilitySurfaceSpecificationSource(configSource);
    _priceCurveDefinitionSource = new ConfigDBFuturePriceCurveDefinitionSource(configSource);
    _priceCurveSpecificationSource = new ConfigDBFuturePriceCurveSpecificationSource(configSource);
  }
  
  public RepositoryConfiguration constructRepositoryConfiguration() {
    final List<FunctionConfiguration> configs = new ArrayList<FunctionConfiguration>();
    addConfigFor(configs, VolatilitySurfaceSpecificationFunction.class.getName());
    addConfigFor(configs, RawIRFutureOptionVolatilitySurfaceDataFunction.class.getName());    
    addConfigFor(configs, RawFXVolatilitySurfaceDataFunction.class.getName());
    addConfigFor(configs, RawSwaptionATMVolatilitySurfaceDataFunction.class.getName());
    addConfigFor(configs, RawEquityOptionVolatilitySurfaceDataFunction.class.getName());
    addConfigFor(configs, IRFutureOptionVolatilitySurfaceDataFunction.class.getName());
    addConfigFor(configs, EquityFutureOptionVolatilitySurfaceDataFunction.class.getName());
    addConfigFor(configs, EquityOptionVolatilitySurfaceDataFunctionDeprecated.class.getName(), new String[] {"DEFAULT", "EQUITY_OPTION", "DEFAULT"});
    addConfigFor(configs, Grid2DInterpolatedVolatilitySurfaceFunctionDeprecated.class.getName(), new String[] {"DEFAULT", "EQUITY_OPTION", "DoubleQuadratic", "FlatExtrapolator", "FlatExtrapolator", 
      "DoubleQuadratic", "FlatExtrapolator", "FlatExtrapolator"});
    addConfigFor(configs, ForexStrangleRiskReversalVolatilitySurfaceFunction.class.getName());<commit_msg>Rename of EquityFutureOptionVol.. to EquityOptionVol.. after deprecation of older version<commit_after>/**
 * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
 * 
 * Please see distribution for license.
 */
package com.opengamma.web.spring;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

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

import com.opengamma.OpenGammaRuntimeException;
import com.opengamma.core.config.ConfigSource;
import com.opengamma.engine.function.config.FunctionConfiguration;
import com.opengamma.engine.function.config.ParameterizedFunctionConfiguration;
import com.opengamma.engine.function.config.RepositoryConfiguration;
import com.opengamma.engine.function.config.RepositoryConfigurationSource;
import com.opengamma.engine.function.config.SimpleRepositoryConfigurationSource;
import com.opengamma.engine.function.config.StaticFunctionConfiguration;
import com.opengamma.financial.analytics.model.volatility.surface.ForexCallDeltaVolatilitySurfaceFunction;
import com.opengamma.financial.analytics.model.volatility.surface.ForexStrangleRiskReversalVolatilitySurfaceFunction;
import com.opengamma.financial.analytics.model.volatility.surface.InterpolatedVolatilitySurfaceFunction;
import com.opengamma.financial.analytics.volatility.VolatilitySurfaceSpecificationFunction;
import com.opengamma.financial.analytics.volatility.surface.ConfigDBFuturePriceCurveDefinitionSource;
import com.opengamma.financial.analytics.volatility.surface.ConfigDBFuturePriceCurveSpecificationSource;
import com.opengamma.financial.analytics.volatility.surface.ConfigDBVolatilitySurfaceDefinitionSource;
import com.opengamma.financial.analytics.volatility.surface.ConfigDBVolatilitySurfaceSpecificationSource;
import com.opengamma.financial.analytics.volatility.surface.EquityOptionVolatilitySurfaceDataFunction;
import com.opengamma.financial.analytics.volatility.surface.EquityOptionVolatilitySurfaceDataFunctionDeprecated;
import com.opengamma.financial.analytics.volatility.surface.FuturePriceCurveDefinition;
import com.opengamma.financial.analytics.volatility.surface.FuturePriceCurveSpecification;
import com.opengamma.financial.analytics.volatility.surface.Grid2DInterpolatedVolatilitySurfaceFunctionDeprecated;
import com.opengamma.financial.analytics.volatility.surface.IRFutureOptionVolatilitySurfaceDataFunction;
import com.opengamma.financial.analytics.volatility.surface.InterpolatedVolatilitySurfaceDefaultPropertiesFunction;
import com.opengamma.financial.analytics.volatility.surface.RawEquityOptionVolatilitySurfaceDataFunction;
import com.opengamma.financial.analytics.volatility.surface.RawFXVolatilitySurfaceDataFunction;
import com.opengamma.financial.analytics.volatility.surface.RawIRFutureOptionVolatilitySurfaceDataFunction;
import com.opengamma.financial.analytics.volatility.surface.RawSwaptionATMVolatilitySurfaceDataFunction;
import com.opengamma.financial.analytics.volatility.surface.SwaptionATMVolatilitySurfaceDataFunction;
import com.opengamma.financial.analytics.volatility.surface.VolatilitySurfaceDefinition;
import com.opengamma.financial.analytics.volatility.surface.VolatilitySurfaceSpecification;
import com.opengamma.master.config.ConfigMaster;
import com.opengamma.master.config.impl.MasterConfigSource;
import com.opengamma.util.SingletonFactoryBean;

/**
 * Creates function repository configuration for surface supplying functions.
 * 
 * Note [PLAT-1094] - the functions should really be built by scanning the surfaces and currencies available. 
 */
public class DemoSurfaceFunctionConfiguration extends SingletonFactoryBean<RepositoryConfigurationSource> {
  private static final Logger s_logger = LoggerFactory.getLogger(DemoSurfaceFunctionConfiguration.class);
  
  private ConfigMaster _configMaster;
  private ConfigDBVolatilitySurfaceDefinitionSource _volSurfaceDefinitionSource;
  private ConfigDBVolatilitySurfaceSpecificationSource _volSurfaceSpecificationSource;
  private ConfigDBFuturePriceCurveDefinitionSource _priceCurveDefinitionSource;
  private ConfigDBFuturePriceCurveSpecificationSource _priceCurveSpecificationSource;

  public void setConfigMaster(final ConfigMaster configMaster) {
    _configMaster = configMaster;
    // I've injected the master so we can do the more complex querying when we're ready.
    ConfigSource configSource = new MasterConfigSource(_configMaster);
    _volSurfaceDefinitionSource = new ConfigDBVolatilitySurfaceDefinitionSource(configSource);
    _volSurfaceSpecificationSource = new ConfigDBVolatilitySurfaceSpecificationSource(configSource);
    _priceCurveDefinitionSource = new ConfigDBFuturePriceCurveDefinitionSource(configSource);
    _priceCurveSpecificationSource = new ConfigDBFuturePriceCurveSpecificationSource(configSource);
  }
  
  public RepositoryConfiguration constructRepositoryConfiguration() {
    final List<FunctionConfiguration> configs = new ArrayList<FunctionConfiguration>();
    addConfigFor(configs, VolatilitySurfaceSpecificationFunction.class.getName());
    addConfigFor(configs, RawIRFutureOptionVolatilitySurfaceDataFunction.class.getName());    
    addConfigFor(configs, RawFXVolatilitySurfaceDataFunction.class.getName());
    addConfigFor(configs, RawSwaptionATMVolatilitySurfaceDataFunction.class.getName());
    addConfigFor(configs, RawEquityOptionVolatilitySurfaceDataFunction.class.getName());
    addConfigFor(configs, IRFutureOptionVolatilitySurfaceDataFunction.class.getName());
    addConfigFor(configs, EquityOptionVolatilitySurfaceDataFunction.class.getName());
    addConfigFor(configs, EquityOptionVolatilitySurfaceDataFunctionDeprecated.class.getName(), new String[] {"DEFAULT", "EQUITY_OPTION", "DEFAULT"});
    addConfigFor(configs, Grid2DInterpolatedVolatilitySurfaceFunctionDeprecated.class.getName(), new String[] {"DEFAULT", "EQUITY_OPTION", "DoubleQuadratic", "FlatExtrapolator", "FlatExtrapolator", 
      "DoubleQuadratic", "FlatExtrapolator", "FlatExtrapolator"});
    addConfigFor(configs, ForexStrangleRiskReversalVolatilitySurfaceFunction.class.getName());
{'fraction_non_alphanumeric': 0.07300593276203032, 'fraction_numerical': 0.001977587343441002, 'mean_word_length': 8.932078559738134, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6544696', 'n_tokens_mistral': 3284, 'n_tokens_neox': 3152, 'n_words': 462}