Package com.opengamma.master.holiday

Examples of com.opengamma.master.holiday.ManageableHoliday


        ExternalId regionId = ExternalSchemes.coppClarkRegionId(countryISO + unlocodePart);
        String eventDateStr = row[eventDateIdx];
        LocalDate eventDate =  LocalDate.parse(eventDateStr, DATE_FORMAT);
        HolidayDocument doc = fileMap.get(ccId);
        if (doc == null) {
          doc = new HolidayDocument(new ManageableHoliday(HolidayType.BANK, regionId, EMPTY_DATE_LIST));
          doc.setProviderId(ExternalId.of(COPP_CLARK_SCHEME, ccId));
          fileMap.put(ccId, doc);
        }
        doc.getHoliday().getHolidayDates().add(eventDate);
      }
View Full Code Here


        ExternalId micId = ExternalSchemes.isoMicExchangeId(isoMICCode);
        String eventDateStr = row[eventDateIdx];
        LocalDate eventDate =  LocalDate.parse(eventDateStr, DATE_FORMAT);
        HolidayDocument doc = fileMap.get(ccId);
        if (doc == null) {
          doc = new HolidayDocument(new ManageableHoliday(HolidayType.SETTLEMENT, micId, EMPTY_DATE_LIST));
          doc.setProviderId(ExternalId.of(COPP_CLARK_SCHEME, ccId));
          fileMap.put(ccId, doc);
        }
        doc.getHoliday().getHolidayDates().add(eventDate);
      }
View Full Code Here

        ExternalId micId = ExternalSchemes.isoMicExchangeId(isoMICCode);
        String eventDateStr = row[eventDateIdx];
        LocalDate eventDate =  LocalDate.parse(eventDateStr, DATE_FORMAT);
        HolidayDocument doc = fileMap.get(ccId);
        if (doc == null) {
          doc = new HolidayDocument(new ManageableHoliday(HolidayType.TRADING, micId, EMPTY_DATE_LIST));
          doc.setProviderId(ExternalId.of(COPP_CLARK_SCHEME, ccId));
          fileMap.put(ccId, doc);
        }
        doc.getHoliday().getHolidayDates().add(eventDate);
      }
View Full Code Here

   
    try (Timer.Context context = _insertTimer.time()) {
      final long docId = nextId("hol_holiday_seq");
      final long docOid = (document.getUniqueId() != null ? extractOid(document.getUniqueId()) : docId);
      // the arguments for inserting into the holiday table
      final ManageableHoliday holiday = document.getHoliday();
      final DbMapSqlParameterSource docArgs = 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("provider_scheme",
            document.getProviderId() != null ? document.getProviderId().getScheme().getName() : null,
            Types.VARCHAR)
        .addValue("provider_value",
            document.getProviderId() != null ? document.getProviderId().getValue() : null,
            Types.VARCHAR)
        .addValue("hol_type", holiday.getType().name())
        .addValue("region_scheme",
            holiday.getRegionExternalId() != null ? holiday.getRegionExternalId().getScheme().getName() : null,
            Types.VARCHAR)
        .addValue("region_value",
            holiday.getRegionExternalId() != null ? holiday.getRegionExternalId().getValue() : null,
            Types.VARCHAR)
        .addValue("exchange_scheme",
            holiday.getExchangeExternalId() != null ? holiday.getExchangeExternalId().getScheme().getName() : null,
            Types.VARCHAR)
        .addValue("exchange_value",
            holiday.getExchangeExternalId() != null ? holiday.getExchangeExternalId().getValue() : null,
            Types.VARCHAR)
        .addValue("currency_iso",
            holiday.getCurrency() != null ? holiday.getCurrency().getCode() : null,
            Types.VARCHAR);
      // the arguments for inserting into the date table
      final List<DbMapSqlParameterSource> dateList = new ArrayList<DbMapSqlParameterSource>();
      for (LocalDate date : holiday.getHolidayDates()) {
        final DbMapSqlParameterSource dateArgs = new DbMapSqlParameterSource()
          .addValue("doc_id", docId)
          .addDate("hol_date", date);
        dateList.add(dateArgs);
      }
      final String sqlDoc = getElSqlBundle().getSql("Insert", docArgs);
      final String sqlDate = getElSqlBundle().getSql("InsertDate");
      getJdbcTemplate().update(sqlDoc, docArgs);
      getJdbcTemplate().batchUpdate(sqlDate, dateList.toArray(new DbMapSqlParameterSource[dateList.size()]));
      // set the uniqueId
      final UniqueId uniqueId = createUniqueId(docOid, docId);
      holiday.setUniqueId(uniqueId);
      document.setUniqueId(uniqueId);
      return document;
    }
   
  }
View Full Code Here

   * <p>
   * A more typical loader would open a file (e.g. CSV or XML) and use that to create the {@link Holiday} instances to be stored.
   */
  @Override
  protected void doRun() {
    final ManageableHoliday calendar = new ManageableHoliday();
    calendar.setType(HolidayType.CURRENCY);
    calendar.setCurrency(Currency.GBP);
    calendar.getHolidayDates().add(LocalDate.of(2010, 1, 1));
    calendar.getHolidayDates().add(LocalDate.of(2010, 4, 2));
    calendar.getHolidayDates().add(LocalDate.of(2010, 4, 5));
    calendar.getHolidayDates().add(LocalDate.of(2010, 5, 3));
    calendar.getHolidayDates().add(LocalDate.of(2010, 5, 31));
    calendar.getHolidayDates().add(LocalDate.of(2010, 8, 30));
    calendar.getHolidayDates().add(LocalDate.of(2010, 12, 27));
    calendar.getHolidayDates().add(LocalDate.of(2010, 12, 28));
    storeHolidays(calendar);
  }
View Full Code Here

    ArgumentChecker.notNull(document.getName(), "document.name");
    ArgumentChecker.notNull(document.getHoliday(), "document.holiday");

    final ObjectId objectId = _objectIdSupplier.get();
    final UniqueId uniqueId = objectId.atVersion("");
    final ManageableHoliday holiday = document.getHoliday();
    holiday.setUniqueId(uniqueId);
    document.setUniqueId(uniqueId);
    final Instant now = Instant.now();
    document.setVersionFromInstant(now);
    document.setVersionToInstant(null);
    document.setCorrectionFromInstant(now);
View Full Code Here

  private HolidayDocument addedDoc;

  @BeforeMethod
  public void setUp() {
    master = new InMemoryHolidayMaster();
    ManageableHoliday inputHoliday = new ManageableHoliday(GBP, Collections.singletonList(DATE_MONDAY));
    HolidayDocument inputDoc = new HolidayDocument(inputHoliday);
    addedDoc = master.add(inputDoc);
  }
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Test
  public void testGetHoliday() {
    final ManageableHoliday holiday = new ManageableHoliday(Currency.GBP, new ArrayList<LocalDate>());
    final HolidayDocument result = new HolidayDocument(holiday);
    when(_underlying.get(OID, VersionCorrection.LATEST)).thenReturn(result);
   
    Response test = _resource.get(null, null);
    assertEquals(Status.OK.getStatusCode(), test.getStatus());
View Full Code Here

    assertSame(result, test.getEntity());
  }

  @Test
  public void testUpdateHoliday() {
    final ManageableHoliday holiday = new ManageableHoliday(Currency.GBP, new ArrayList<LocalDate>());
    final HolidayDocument request = new HolidayDocument(holiday);
    request.setUniqueId(OID.atLatestVersion());
   
    final HolidayDocument result = new HolidayDocument(holiday);
    result.setUniqueId(OID.atVersion("1"));
View Full Code Here

  public void test_isHoliday_LocalDateCurrency_holiday() throws Exception {
    HolidayMaster mock = mock(HolidayMaster.class);
    HolidaySearchRequest request = new HolidaySearchRequest(GBP);
    request.setDateToCheck(DATE_MONDAY);
    request.setVersionCorrection(VC);
    ManageableHoliday holiday = new ManageableHoliday(GBP, Collections.singletonList(DATE_MONDAY));
    HolidaySearchResult result = new HolidaySearchResult();
    result.getDocuments().add(new HolidayDocument(holiday));
   
    when(mock.search(request)).thenReturn(result);
    MasterHolidaySource test = new MasterHolidaySource(mock, VC);
View Full Code Here

TOP

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

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.