コード例 #1
0
  /**
   * Inserts a new document.
   *
   * @param document the document, not null
   * @return the new document, not null
   */
  @Override
  protected MarketDataSnapshotDocument insert(final MarketDataSnapshotDocument document) {
    ArgumentChecker.notNull(document.getSnapshot(), "document.snapshot");
    ArgumentChecker.notNull(document.getName(), "document.name");

    final ManageableMarketDataSnapshot marketDataSnaphshot = document.getSnapshot();
    final long docId = nextId("snp_snapshot_seq");
    final long docOid =
        (document.getUniqueId() != null ? extractOid(document.getUniqueId()) : docId);
    // set the uniqueId (needs to go in Fudge message)
    final UniqueId uniqueId = createUniqueId(docOid, docId);
    marketDataSnaphshot.setUniqueId(uniqueId);
    document.setUniqueId(uniqueId);

    // the arguments for inserting into the marketDataSnaphshot table
    FudgeMsgEnvelope env = FUDGE_CONTEXT.toFudgeMsg(marketDataSnaphshot);
    byte[] bytes = FUDGE_CONTEXT.toByteArray(env.getMessage());
    final DbMapSqlParameterSource marketDataSnaphshotArgs =
        new DbMapSqlParameterSource()
            .addValue("doc_id", docId)
            .addValue("doc_oid", docOid)
            .addTimestamp("ver_from_instant", document.getVersionFromInstant())
            .addTimestampNullFuture("ver_to_instant", document.getVersionToInstant())
            .addTimestamp("corr_from_instant", document.getCorrectionFromInstant())
            .addTimestampNullFuture("corr_to_instant", document.getCorrectionToInstant())
            .addValue("name", document.getName())
            .addValue("detail", new SqlLobValue(bytes, getDialect().getLobHandler()), Types.BLOB);

    final String sql = getElSqlBundle().getSql("Insert", marketDataSnaphshotArgs);
    getJdbcTemplate().update(sql, marketDataSnaphshotArgs);
    return document;
  }
コード例 #2
0
 private void testFudgeMessage(final ManageableTrade obj) {
   final FudgeSerializer serializer = new FudgeSerializer(s_fudgeContext);
   FudgeMsg msg = serializer.objectToFudgeMsg(obj);
   s_logger.debug("ManageableTrade {}", obj);
   s_logger.debug("Encoded to {}", msg);
   final byte[] bytes = s_fudgeContext.toByteArray(msg);
   msg = s_fudgeContext.deserialize(bytes).getMessage();
   s_logger.debug("Serialised to {}", msg);
   final ManageableTrade decoded = s_fudgeContext.fromFudgeMsg(ManageableTrade.class, msg);
   s_logger.debug("Decoded to {}", decoded);
   if (!obj.equals(decoded)) {
     s_logger.warn("Expected {}", obj);
     s_logger.warn("Received {}", decoded);
     fail();
   }
 }
  public void fudgeEncoding() {
    List<HistoricalTimeSeriesRatingRule> rules = new ArrayList<HistoricalTimeSeriesRatingRule>();
    rules.add(HistoricalTimeSeriesRatingRule.of(DATA_SOURCE_NAME, "BLOOMBERG", 2));
    rules.add(HistoricalTimeSeriesRatingRule.of(DATA_SOURCE_NAME, "REUTERS", 1));
    rules.add(HistoricalTimeSeriesRatingRule.of(DATA_PROVIDER_NAME, "CMPL", 3));
    HistoricalTimeSeriesRating inputConfig = HistoricalTimeSeriesRating.of(rules);

    FudgeSerializer serializationContext = new FudgeSerializer(s_fudgeContext);
    MutableFudgeMsg inputMsg = serializationContext.objectToFudgeMsg(inputConfig);
    FudgeMsg outputMsg =
        s_fudgeContext.deserialize(s_fudgeContext.toByteArray(inputMsg)).getMessage();
    assertNotNull(outputMsg);
    assertEquals(3, outputMsg.getNumFields());

    FudgeDeserializer deserializationContext = new FudgeDeserializer(s_fudgeContext);
    HistoricalTimeSeriesRating outputConfig =
        deserializationContext.fudgeMsgToObject(HistoricalTimeSeriesRating.class, outputMsg);

    assertEquals(inputConfig, outputConfig);
  }