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

import org.fudgemsg.FudgeFieldContainer;
import org.fudgemsg.MutableFudgeFieldContainer;
import org.fudgemsg.mapping.FudgeBuilder;
import org.fudgemsg.mapping.FudgeDeserializationContext;
import org.fudgemsg.mapping.FudgeSerializationContext;

import com.opengamma.engine.position.Portfolio;
import com.opengamma.engine.position.PortfolioImpl;
import com.opengamma.engine.position.PortfolioNode;
import com.opengamma.engine.position.PortfolioNodeImpl;
import com.opengamma.id.UniqueIdentifier;

/**
 * Fudge message builder for {@code Portfolio}.
 */
public class PortfolioBuilder implements FudgeBuilder<Portfolio> {

  public static final String FIELD_IDENTIFIER = "identifier";
  public static final String FIELD_NAME = "name";
  public static final String FIELD_ROOT = "root";

  @Override
  public MutableFudgeFieldContainer buildMessage(FudgeSerializationContext context, Portfolio portfolio) {
    final MutableFudgeFieldContainer message = context.newMessage ();
    context.objectToFudgeMsg(message, FIELD_IDENTIFIER, null, portfolio.getUniqueIdentifier());
    message.add(FIELD_NAME, portfolio.getName());
    context.objectToFudgeMsg(message, FIELD_ROOT, null, portfolio.getUniqueIdentifier());
    return message;
  }

  @Override
  public Portfolio buildObject(FudgeDeserializationContext context, FudgeFieldContainer message) {
    final UniqueIdentifier id = context.fieldValueToObject(UniqueIdentifier.class, message.getByName(FIELD_IDENTIFIER));
    final String name = message.getFieldValue(String.class, message.getByName(FIELD_NAME));
    final PortfolioNode node = context.fieldValueToObject(PortfolioNode.class, message.getByName(FIELD_ROOT));<commit_msg>Fixes error in one of the tests in OG-Integration<commit_after>/**
 * Copyright (C) 2009 - 2010 by OpenGamma Inc.
 *
 * Please see distribution for license.
 */
package com.opengamma.engine.view.server;

import org.fudgemsg.FudgeFieldContainer;
import org.fudgemsg.MutableFudgeFieldContainer;
import org.fudgemsg.mapping.FudgeBuilder;
import org.fudgemsg.mapping.FudgeDeserializationContext;
import org.fudgemsg.mapping.FudgeSerializationContext;

import com.opengamma.engine.position.Portfolio;
import com.opengamma.engine.position.PortfolioImpl;
import com.opengamma.engine.position.PortfolioNode;
import com.opengamma.engine.position.PortfolioNodeImpl;
import com.opengamma.id.UniqueIdentifier;

/**
 * Fudge message builder for {@code Portfolio}.
 */
public class PortfolioBuilder implements FudgeBuilder<Portfolio> {

  public static final String FIELD_IDENTIFIER = "identifier";
  public static final String FIELD_NAME = "name";
  public static final String FIELD_ROOT = "root";

  @Override
  public MutableFudgeFieldContainer buildMessage(FudgeSerializationContext context, Portfolio portfolio) {
    final MutableFudgeFieldContainer message = context.newMessage ();
    context.objectToFudgeMsg(message, FIELD_IDENTIFIER, null, portfolio.getUniqueIdentifier());
    message.add(FIELD_NAME, portfolio.getName());
    context.objectToFudgeMsg(message, FIELD_ROOT, null, portfolio.getRootNode ());
    return message;
  }

  @Override
  public Portfolio buildObject(FudgeDeserializationContext context, FudgeFieldContainer message) {
    final UniqueIdentifier id = context.fieldValueToObject(UniqueIdentifier.class, message.getByName(FIELD_IDENTIFIER));
    final String name = message.getFieldValue(String.class, message.getByName(FIELD_NAME));
    final PortfolioNode node = context.fieldValueToObject(PortfolioNode.class, message.getByName(FIELD_ROOT));
{'fraction_non_alphanumeric': 0.08845009467135516, 'fraction_numerical': 0.004327833378414931, 'mean_word_length': 6.29388560157791, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4552827', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1046, 'n_words': 225}