@@ -0,0 +1,3373 @@
+/**%0A * Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies%0A * %0A * Please see distribution for license.%0A */%0Apackage com.opengamma.bbg.referencedata.impl;%0A%0Aimport java.util.HashMap;%0Aimport java.util.HashSet;%0Aimport java.util.Map;%0Aimport java.util.Set;%0A%0Aimport org.fudgemsg.FudgeMsg;%0Aimport org.fudgemsg.MutableFudgeMsg;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport com.opengamma.bbg.referencedata.ReferenceData;%0Aimport com.opengamma.bbg.referencedata.ReferenceDataProvider;%0Aimport com.opengamma.bbg.referencedata.ReferenceDataProviderGetRequest;%0Aimport com.opengamma.bbg.referencedata.ReferenceDataProviderGetResult;%0Aimport com.opengamma.util.fudgemsg.OpenGammaFudgeContext;%0Aimport com.opengamma.util.tuple.Pair;%0A%0A/**%0A * A decorator for a ReferenceDataProvider that allows you to override the results%0A * from the underlying provider e.g. if you have extra information from another source.%0A */%0Apublic class PatchableReferenceDataProvider extends AbstractReferenceDataProvider %7B%0A%0A  /** Logger. */%0A  private static final Logger s_logger = LoggerFactory.getLogger(PatchableReferenceDataProvider.class);%0A%0A  private Map%3CPair%3CString, String%3E, Object%3E _patches = new HashMap%3CPair%3CString, String%3E, Object%3E();%0A  private Set%3CString%3E _securities = new HashSet%3CString%3E();%0A  private ReferenceDataProvider _underlying;%0A%0A  /**%0A   * Creates an instance.%0A   * %0A   * @param underlying  the underlying source of reference data%0A   */%0A  public PatchableReferenceDataProvider(ReferenceDataProvider underlying) %7B%0A    _underlying = underlying;%0A  %7D%0A%0A  //-------------------------------------------------------------------------%0A  /**%0A   * Sets an override or replacement value.%0A   * %0A   * @param security  the Bloomberg security identifier%0A   * @param field  the Bloomberg field name%0A   * @param result  the object to return as a result (must be possible to Fudge encode with standard OG dictionary)%0A   */%0A  public void setPatch(String security, String field, Object result) %7B%0A    _patches.put(Pair.of(security, field), result);%0A    _securities.add(security);%0A  %7D%0A%0A  //-------------------------------------------------------------------------%0A  @Override%0A  protected ReferenceDataProviderGetResult doBulkGet(ReferenceDataProviderGetRequest request) %7B%0A    ReferenceDataProviderGetResult rawResult = _underlying.getReferenceData(request);%0A    ReferenceDataProviderGetResult newResult = new ReferenceDataProviderGetResult();%0A    %0A    for (ReferenceData refData : rawResult.getReferenceData()) %7B%0A      String identifier = refData.getIdentifier();%0A      if (_securities.contains(identifier)) %7B%0A        FudgeMsg fieldData = refData.getFieldValues();%0A        MutableFudgeMsg alteredFieldData = OpenGammaFudgeContext.getInstance().newMessage(fieldData);%0A        for (String field : request.getFields()) %7B%0A          if (_patches.containsKey(Pair.of(identifier, field))) %7B%0A            if (alteredFieldData.hasField(field)) %7B%0A              alteredFieldData.remove(field);%0A            %7D%0A            alteredFieldData.add(field, _patches.get(Pair.of(identifier, field)));%0A            refData.removeErrors(field);%0A          %7D%0A        %7D%0A        s_logger.debug(%22Patching %7B%7D with %7B%7D%22, new Object%5B%5D %7BfieldData, alteredFieldData %7D);%0A        refData.setFieldValues(alteredFieldData);%0A      %7D%0A      newResult.addReferenceData(refData);%0A    %7D%0A    return newResult;%0A  %7D%0A%0A%7D%0A

Rework marketdata-server - add patchable