Package com.opengamma.master.holiday

Examples of com.opengamma.master.holiday.HolidaySearchRequest


    assertEquals(0, test.getDocuments().size());
  }

  @Test
  public void test_search_currency_oneMatch() {
    HolidaySearchRequest request = new HolidaySearchRequest();
    request.setCurrency(Currency.EUR);
    HolidaySearchResult test = _holMaster.search(request);
   
    assertEquals(1, test.getDocuments().size());
    assert102(test.getDocuments().get(0));
  }
View Full Code Here


    assert102(test.getDocuments().get(0));
  }

  @Test
  public void test_search_currency_twoMatches() {
    HolidaySearchRequest request = new HolidaySearchRequest();
    request.setCurrency(Currency.GBP);
    HolidaySearchResult test = _holMaster.search(request);
   
    assertEquals(2, test.getDocuments().size());
    assert101(test.getDocuments().get(0));
    assert202(test.getDocuments().get(1));
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Test
  public void test_search_holidayIds_none() {
    HolidaySearchRequest request = new HolidaySearchRequest();
    request.setHolidayObjectIds(new ArrayList<ObjectId>());
    HolidaySearchResult test = _holMaster.search(request);
   
    assertEquals(0, test.getDocuments().size());
  }
View Full Code Here

    assertEquals(0, test.getDocuments().size());
  }

  @Test
  public void test_search_holidayIds() {
    HolidaySearchRequest request = new HolidaySearchRequest();
    request.addHolidayObjectId(ObjectId.of("DbHol", "101"));
    request.addHolidayObjectId(ObjectId.of("DbHol", "201"));
    request.addHolidayObjectId(ObjectId.of("DbHol", "9999"));
    HolidaySearchResult test = _holMaster.search(request);
   
    assertEquals(2, test.getDocuments().size());
    assert101(test.getDocuments().get(0));
    assert202(test.getDocuments().get(1));
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Test(enabled = false, description = "Queries the entire database")
  public void test_queryAll() throws Exception {
    final HolidaySearchRequest request = new HolidaySearchRequest();
    request.setPagingRequest(PagingRequest.NONE);
    final int total = getHolidayMaster().search(request).getPaging().getTotalItems();
    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());
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());
View Full Code Here

        System.exit(0);
      }
    }
    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) {
View Full Code Here

   *
   * @param calendar the calendar to add
   */
  private void storeHolidays(final ManageableHoliday calendar) {
    final HolidayMaster master = getToolContext().getHolidayMaster();
    final HolidaySearchRequest request = new HolidaySearchRequest();
    request.setType(calendar.getType());
    switch (calendar.getType()) {
      case CURRENCY:
        request.setCurrency(calendar.getCurrency());
        break;
      default:
        throw new UnsupportedOperationException(calendar.getType().toString());
    }
    final HolidaySearchResult result = master.search(request);
View Full Code Here

  private FlexiBean createSearchResultData(PagingRequest pr, HolidaySearchSortOrder sort, String name, String type, String currencyISO,
      List<String> holidayIdStrs, UriInfo uriInfo) {
    FlexiBean out = createRootData();
   
    HolidaySearchRequest searchRequest = new HolidaySearchRequest();
    searchRequest.setPagingRequest(pr);
    searchRequest.setSortOrder(sort);
    searchRequest.setName(StringUtils.trimToNull(name));
    if (StringUtils.isNotEmpty(type)) {
      searchRequest.setType(HolidayType.valueOf(type));
    }
    if (currencyISO != null) {
      searchRequest.setCurrency(Currency.of(currencyISO));
    }
    MultivaluedMap<String, String> query = uriInfo.getQueryParameters();
    for (int i = 0; query.containsKey("idscheme." + i) && query.containsKey("idvalue." + i); i++) {
      ExternalId id = ExternalId.of(query.getFirst("idscheme." + i), query.getFirst("idvalue." + i));
      if (HolidayType.BANK.name().equals(type)) {
        searchRequest.addRegionExternalId(id);
      } else { // assume settlement/trading
        searchRequest.addExchangeExternalId(id);
      }
    }
    for (String holidayIdStr : holidayIdStrs) {
      searchRequest.addHolidayObjectId(ObjectId.parse(holidayIdStr));
    }
    out.put("searchRequest", searchRequest);
   
    if (data().getUriInfo().getQueryParameters().size() > 0) {
      HolidaySearchResult searchResult = data().getHolidayMaster().search(searchRequest);
View Full Code Here

   * Creates the output root data.
   * @return the output root data, not null
   */
  protected FlexiBean createRootData() {
    FlexiBean out = super.createRootData();
    HolidaySearchRequest searchRequest = new HolidaySearchRequest();
    out.put("searchRequest", searchRequest);
    HolidayMetaDataResult metaData = data().getHolidayMaster().metaData(new HolidayMetaDataRequest());
    out.put("holidayTypes", metaData.getHolidayTypes());
    return out;
  }
View Full Code Here

TOP

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

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.