Package com.opengamma.id

Examples of com.opengamma.id.VersionCorrection


  public void addToFrontCache_allSame() {
    final EHCachingPositionSource cache = new EHCachingPositionSource(Mockito.mock(PositionSource.class), _cacheManager);
    try {
      // Add the same portfolio at the same v/c - original to be returned
      final PortfolioNode root = createPortfolioA1();
      final VersionCorrection vc = VersionCorrection.of(Instant.now(), Instant.now());
      assertSame(cache.addToFrontCache(root, vc), root);
      assertSame(cache.addToFrontCache(createPortfolioA1(), vc), root);
      // Add the same portfolio at a new v/c - original to be identified and returned
      assertSame(cache.addToFrontCache(root, VersionCorrection.ofVersionAsOf(vc.getVersionAsOf().plusSeconds(1))), root);
    } finally {
      cache.shutdown();
    }
  }
View Full Code Here


    final EHCachingPositionSource cache = new EHCachingPositionSource(Mockito.mock(PositionSource.class), _cacheManager);
    try {
      // Add two similar portfolios with different position resolutions; both to be added and returned
      final PortfolioNode root1 = createPortfolioA1();
      final PortfolioNode root2 = createPortfolioA2();
      final VersionCorrection vc = VersionCorrection.of(Instant.now(), Instant.now());
      assertSame(cache.addToFrontCache(root1, vc), root1);
      assertSame(cache.addToFrontCache(root2, VersionCorrection.ofVersionAsOf(vc.getVersionAsOf().plusSeconds(1))), root2);
    } finally {
      cache.shutdown();
    }
  }
View Full Code Here

    final EHCachingPositionSource cache = new EHCachingPositionSource(Mockito.mock(PositionSource.class), _cacheManager);
    try {
      // Add two similar portfolios with some positions (and hence nodes) shared; shared nodes and positions to be reused in returned node
      final PortfolioNode root1 = createPortfolioA1();
      final PortfolioNode root2 = createPortfolioA3();
      final VersionCorrection vc = VersionCorrection.of(Instant.now(), Instant.now());
      assertSame(cache.addToFrontCache(root1, vc), root1);
      final PortfolioNode root2b = cache.addToFrontCache(root2, VersionCorrection.ofVersionAsOf(vc.getVersionAsOf().plusSeconds(1)));
      assertNotSame(root2b, root2);
      assertEquals(root2b.getName(), root2.getName());
      assertEquals(root2b.getParentNodeId(), root2.getParentNodeId());
      assertEquals(root2b.getUniqueId(), root2.getUniqueId());
      assertEquals(root2b.getPositions(), root2.getPositions());
View Full Code Here

    assertEquals(_securityV2, resolvedSecurity);
  }

  @Test(expectedExceptions = DataNotFoundException.class)
  public void testResolveLinkWithUnknownObjectId() {
    VersionCorrection vc = VersionCorrection.of(Instant.ofEpochMilli(123), Instant.ofEpochMilli(123));
    SimpleSecurityResolver resolver = new SimpleSecurityResolver(_securitySource, vc);
    SecurityLink link = new SimpleSecurityLink(UNKNOWN_OID);
    resolver.resolve(link);
  }
View Full Code Here

    assertEquals(_securityV2, security);
  }

  @Test(expectedExceptions = DataNotFoundException.class)
  public void testGetSecurityByUnknownObjectId() {
    VersionCorrection vc = VersionCorrection.of(Instant.ofEpochMilli(123), Instant.ofEpochMilli(123));
    SimpleSecurityResolver resolver = new SimpleSecurityResolver(_securitySource, vc);
    resolver.getSecurity(UNKNOWN_OID);
  }
View Full Code Here

public class ParallelRecompilationInfiniteLatestTest extends AbstractParallelRecompilationTest {

  private static final Logger s_logger = LoggerFactory.getLogger(ParallelRecompilationInfiniteLatestTest.class);

  private CompiledViewDefinitionWithGraphs compiledViewDefinition(final ViewDefinition viewDefinition, final Map<ComputationTargetReference, UniqueId> resolutions) {
    final VersionCorrection versionCorrection = VersionCorrection.of(Instant.now(), Instant.now());
    final DependencyGraph graph = new DependencyGraph("Default");
    final Portfolio portfolio = Mockito.mock(Portfolio.class);
    return new CompiledViewDefinitionWithGraphsImpl(versionCorrection, "view-id", viewDefinition, Collections.singleton(graph), new HashMap<ComputationTargetReference, UniqueId>(resolutions),
        portfolio, 0);
  }
View Full Code Here

  //-------------------------------------------------------------------------
 
  public ManageableHistoricalTimeSeries getTimeSeries(ObjectIdentifiable objectId, VersionCorrection versionCorrection, HistoricalTimeSeriesGetFilter filter) {
   
    final long oid = extractOid(objectId);
    final VersionCorrection vc = versionCorrection.withLatestFixed(now());

    // Set up the basic query arguments
    final DbMapSqlParameterSource args = new DbMapSqlParameterSource()
      .addValue("doc_oid", oid)
      .addTimestamp("version_as_of_instant", vc.getVersionAsOf())
      .addTimestamp("corrected_to_instant", vc.getCorrectedTo())
      .addValue("start_date", DbDateUtils.toSqlDateNullFarPast(filter.getEarliestDate()))
      .addValue("end_date", DbDateUtils.toSqlDateNullFarFuture(filter.getLatestDate()));
    final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
   
    // Get version metadata from the data-points and set up a Manageable HTS accordingly
View Full Code Here

   * @param uniqueId  the unique identifier, not null
   * @param series  the time-series data points, not empty, not null
   */
  protected void insertDataPointsCheckMaxDate(final UniqueId uniqueId, final LocalDateDoubleTimeSeries series) {
    final Long docOid = extractOid(uniqueId);
    final VersionCorrection vc = getMaster().extractTimeSeriesInstants(uniqueId);
    final DbMapSqlParameterSource queryArgs = new DbMapSqlParameterSource()
      .addValue("doc_oid", docOid)
      .addTimestamp("ver_instant", vc.getVersionAsOf())
      .addTimestamp("corr_instant", vc.getCorrectedTo());
    final String sql = getElSqlBundle().getSql("SelectMaxPointDate", queryArgs);
    Date result = getDbConnector().getJdbcTemplate().queryForObject(sql, queryArgs, Date.class);
    if (result != null) {
      LocalDate maxDate = DbDateUtils.fromSqlDateAllowNull(result);
      if (series.getEarliestTime().isAfter(maxDate) == false) {
View Full Code Here

  protected long extractRowId(UniqueId uniqueId) {
    int pos = uniqueId.getVersion().indexOf('P');
    if (pos < 0) {
      return super.extractRowId(uniqueId);
    }
    VersionCorrection vc = getMaster().extractTimeSeriesInstants(uniqueId);
    HistoricalTimeSeriesInfoDocument doc = getMaster().get(uniqueId.getObjectId(), vc)// not very efficient, but works
    return super.extractRowId(doc.getUniqueId());
  }
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @GET
  public Response get(@QueryParam("versionAsOf") String versionAsOf, @QueryParam("correctedTo") String correctedTo) {
    VersionCorrection vc = VersionCorrection.parse(versionAsOf, correctedTo);
    ConventionDocument result = getConventionMaster().get(getUrlConventionId(), vc);
    return responseOkFudge(result);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.id.VersionCorrection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.