Package com.opengamma.master.holiday

Examples of com.opengamma.master.holiday.HolidaySearchResult


  //-------------------------------------------------------------------------
  @Test
  public void test_search_versionAsOf_below() {
    HolidaySearchRequest request = new HolidaySearchRequest();
    request.setVersionCorrection(VersionCorrection.ofVersionAsOf(_version1Instant.minusSeconds(5)));
    HolidaySearchResult test = _holMaster.search(request);
   
    assertEquals(0, test.getDocuments().size());
  }
View Full Code Here


  @Test
  public void test_search_versionAsOf_mid() {
    HolidaySearchRequest request = new HolidaySearchRequest();
    request.setVersionCorrection(VersionCorrection.ofVersionAsOf(_version1Instant.plusSeconds(5)));
    HolidaySearchResult test = _holMaster.search(request);
   
    assertEquals(3, test.getDocuments().size());
    assert101(test.getDocuments().get(0));
    assert102(test.getDocuments().get(1));
    assert201(test.getDocuments().get(2))// old version
  }
View Full Code Here

  @Test
  public void test_search_versionAsOf_above() {
    HolidaySearchRequest request = new HolidaySearchRequest();
    request.setVersionCorrection(VersionCorrection.ofVersionAsOf(_version2Instant.plusSeconds(5)));
    HolidaySearchResult test = _holMaster.search(request);
   
    assertEquals(3, test.getDocuments().size());
    assert101(test.getDocuments().get(0));
    assert102(test.getDocuments().get(1));
    assert202(test.getDocuments().get(2))// new version
  }
View Full Code Here

    final int pages = (total / PAGE_SIZE) + 1;
    for (int page = 1; page <= pages; page++) {
      request.setPagingRequest(PagingRequest.ofPage(page, PAGE_SIZE));
      System.out.println("Checking holiday master, page " + request.getPagingRequest());
      try {
        final HolidaySearchResult result = getHolidayMaster().search(request);
        for (final HolidayDocument doc : result.getDocuments()) {
          assertNotNull(doc);
          assertNotNull(doc.getUniqueId());
          assertNotNull(doc.getHoliday());
        }
      } catch (final RuntimeException ex) {
View Full Code Here

  public static NonVersionedRedisHolidaySource createPopulated(NonVersionedRedisHolidaySource redisHolidaySource) {
    ArgumentChecker.notNull(redisHolidaySource, "redisHolidaySource");
    final InMemoryHolidayMaster inMemoryHolidayMaster = new InMemoryHolidayMaster();
    createPopulated(inMemoryHolidayMaster);
   
    HolidaySearchResult holidaySearchResult = inMemoryHolidayMaster.search(new HolidaySearchRequest());
    List<ManageableHoliday> holidays = holidaySearchResult.getHolidays();
   
    for (ManageableHoliday manageableHoliday : holidays) {
      SimpleHoliday simpleHoliday = new SimpleHoliday();
      simpleHoliday.setCurrency(manageableHoliday.getCurrency());
      simpleHoliday.setExchangeExternalId(manageableHoliday.getExchangeExternalId());
View Full Code Here

    }
    for (HolidayDocument doc : map.values()) {
      Collections.sort(doc.getHoliday().getHolidayDates());
      HolidaySearchRequest search = new HolidaySearchRequest(doc.getHoliday().getType());
      search.setProviderId(doc.getProviderId());
      HolidaySearchResult result = _holidayMaster.search(search);
      if (result.getDocuments().size() == 0) {
        // add new data
        _holidayMaster.add(doc);
      } else if (result.getDocuments().size() == 1) {
        // update existing data
        HolidayDocument existing = result.getFirstDocument();
        doc.setUniqueId(existing.getUniqueId());
        doc.getHoliday().setUniqueId(existing.getUniqueId());
        mergeDates(existing, doc);
        // only update if changed
        doc.setVersionFromInstant(null);
View Full Code Here

    ArgumentChecker.notNull(request.getPagingRequest(), "request.pagingRequest");
    ArgumentChecker.notNull(request.getVersionCorrection(), "request.versionCorrection");
    s_logger.debug("search {}", request);
   
    final VersionCorrection vc = request.getVersionCorrection().withLatestFixed(now());
    final HolidaySearchResult result = new HolidaySearchResult(vc);
   
    ExternalIdSearch regionSearch = request.getRegionExternalIdSearch();
    ExternalIdSearch exchangeSearch = request.getExchangeExternalIdSearch();
    String currencyISO = (request.getCurrency() != null ? request.getCurrency().getCode() : null);
    if ((request.getHolidayObjectIds() != null && request.getHolidayObjectIds().size() == 0) ||
        ExternalIdSearch.canMatch(regionSearch) == false ||
        ExternalIdSearch.canMatch(exchangeSearch) == false) {
      result.setPaging(Paging.of(request.getPagingRequest(), 0));
      return result;
    }
   
    final DbMapSqlParameterSource args = new DbMapSqlParameterSource()
      .addTimestamp("version_as_of_instant", vc.getVersionAsOf())
View Full Code Here

        request.setCurrency(calendar.getCurrency());
        break;
      default:
        throw new UnsupportedOperationException(calendar.getType().toString());
    }
    final HolidaySearchResult result = master.search(request);
    if (result.getFirstDocument() != null) {
      //System.out.println("Updating " + calendar.getType());
      final HolidayDocument document = result.getFirstDocument();
      document.setHoliday(calendar);
      master.update(document);
    } else {
      //System.out.println("Adding " + calendar.getType());
      master.add(new HolidayDocument(calendar));
View Full Code Here

      searchRequest.addHolidayObjectId(ObjectId.parse(holidayIdStr));
    }
    out.put("searchRequest", searchRequest);
   
    if (data().getUriInfo().getQueryParameters().size() > 0) {
      HolidaySearchResult searchResult = data().getHolidayMaster().search(searchRequest);
      out.put("searchResult", searchResult);
      out.put("paging", new WebPaging(searchResult.getPaging(), uriInfo));
    }
    return out;
  }
View Full Code Here

    // Create the doc search cache and register a holiday master searcher
    _documentSearchCache = new EHCachingSearchCache(name + "Holiday", cacheManager, new EHCachingSearchCache.Searcher() {
      @Override
      public ObjectsPair<Integer, List<UniqueId>> search(Bean request, PagingRequest pagingRequest) {
        // Fetch search results from underlying master
        HolidaySearchResult result = ((HolidayMaster) getUnderlying()).search((HolidaySearchRequest)
            EHCachingSearchCache.withPagingRequest(request, pagingRequest));

        // Cache the result documents
        EHCachingSearchCache.cacheDocuments(result.getDocuments(), getUidToDocumentCache());

        // Return the list of result UniqueIds
        return new ObjectsPair<>(result.getPaging().getTotalItems(),
                                 EHCachingSearchCache.extractUniqueIds(result.getDocuments()));
      }
    });

    // Create the history search cache and register a security master searcher
    _historySearchCache = new EHCachingSearchCache(name + "HolidayHistory", cacheManager, new EHCachingSearchCache.Searcher() {
      @Override
      public ObjectsPair<Integer, List<UniqueId>> search(Bean request, PagingRequest pagingRequest) {
        // Fetch search results from underlying master
        HolidayHistoryResult result = ((HolidayMaster) getUnderlying()).history((HolidayHistoryRequest)
            EHCachingSearchCache.withPagingRequest(request, pagingRequest));

        // Cache the result documents
        EHCachingSearchCache.cacheDocuments(result.getDocuments(), getUidToDocumentCache());

        // Return the list of result UniqueIds
        return new ObjectsPair<>(result.getPaging().getTotalItems(),
                                 EHCachingSearchCache.extractUniqueIds(result.getDocuments()));
      }
    });
   
    // Prime search cache
    HolidaySearchRequest defaultSearch = new HolidaySearchRequest();
View Full Code Here

TOP

Related Classes of com.opengamma.master.holiday.HolidaySearchResult

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.