Examples of HolidayDocument


Examples of com.opengamma.master.holiday.HolidayDocument

  @Test
  public void test_update_getUpdateGet() {
    Instant now = Instant.now(_holMaster.getClock());
   
    UniqueId uniqueId = UniqueId.of("DbHol", "101", "0");
    HolidayDocument base = _holMaster.get(uniqueId);
    ManageableHoliday holiday = new ManageableHoliday(Currency.USD, Arrays.asList(LocalDate.of(2010, 6, 9)));
    holiday.setUniqueId(uniqueId);
    HolidayDocument input = new HolidayDocument(holiday);
   
    HolidayDocument updated = _holMaster.update(input);
    assertEquals(false, base.getUniqueId().equals(updated.getUniqueId()));
    assertEquals(now, updated.getVersionFromInstant());
    assertEquals(null, updated.getVersionToInstant());
    assertEquals(now, updated.getCorrectionFromInstant());
    assertEquals(null, updated.getCorrectionToInstant());
    assertEquals(input.getHoliday(), updated.getHoliday());
   
    HolidayDocument old = _holMaster.get(uniqueId);
    assertEquals(base.getUniqueId(), old.getUniqueId());
    assertEquals(base.getVersionFromInstant(), old.getVersionFromInstant());
    assertEquals(now, old.getVersionToInstant())// old version ended
    assertEquals(base.getCorrectionFromInstant(), old.getCorrectionFromInstant());
    assertEquals(base.getCorrectionToInstant(), old.getCorrectionToInstant());
    assertEquals(base.getHoliday(), old.getHoliday());
   
    HolidayHistoryRequest search = new HolidayHistoryRequest(base.getUniqueId(), null, now);
    HolidayHistoryResult searchResult = _holMaster.history(search);
    assertEquals(2, searchResult.getDocuments().size());
  }
View Full Code Here

Examples of com.opengamma.master.holiday.HolidayDocument

  @Test
  public void test_update_rollback() {
    DbHolidayMaster w = new DbHolidayMaster(_holMaster.getDbConnector());
    w.setElSqlBundle(ElSqlBundle.of(new ElSqlConfig("TestRollback"), DbHolidayMaster.class));
    final HolidayDocument base = _holMaster.get(UniqueId.of("DbHol", "101", "0"));
    UniqueId uniqueId = UniqueId.of("DbHol", "101", "0");
    ManageableHoliday holiday = new ManageableHoliday(Currency.USD, Arrays.asList(LocalDate.of(2010, 6, 9)));
    holiday.setUniqueId(uniqueId);
    HolidayDocument input = new HolidayDocument(holiday);
    try {
      w.update(input);
      Assert.fail();
    } catch (BadSqlGrammarException ex) {
      // expected
    }
    final HolidayDocument test = _holMaster.get(UniqueId.of("DbHol", "101", "0"));
   
    assertEquals(base, test);
  }
View Full Code Here

Examples of com.opengamma.master.holiday.HolidayDocument

        holiday.setExchangeExternalId(ExternalId.of(exchangeScheme, exchangeValue));
      }
      if (currencyISO != null) {
        holiday.setCurrency(Currency.of(currencyISO));
      }
      HolidayDocument doc = new HolidayDocument(holiday);
      doc.setVersionFromInstant(DbDateUtils.fromSqlTimestamp(versionFrom));
      doc.setVersionToInstant(DbDateUtils.fromSqlTimestampNullFarFuture(versionTo));
      doc.setCorrectionFromInstant(DbDateUtils.fromSqlTimestamp(correctionFrom));
      doc.setCorrectionToInstant(DbDateUtils.fromSqlTimestampNullFarFuture(correctionTo));
      doc.setUniqueId(uniqueId);
      doc.setName(name);
      if (providerScheme != null && providerValue != null) {
        doc.setProviderId(ExternalId.of(providerScheme, providerValue));
      }
      _holiday = doc.getHoliday();
      _documents.add(doc);
    }
View Full Code Here

Examples of com.opengamma.master.holiday.HolidayDocument

        String countryISO = row[isoCountryIdx].trim();
        String currencyISO = row[isoCurrencyIdx].trim();
        Currency currency = Currency.of(currencyISO)// validates format
        String eventDateStr = row[eventDateIdx];
        LocalDate eventDate =  LocalDate.parse(eventDateStr, DATE_FORMAT);
        HolidayDocument doc = fileMap.get(ccId);
        if (doc == null) {
          currency = fixEuro(currency, countryISO);
          doc = new HolidayDocument(new ManageableHoliday(currency, EMPTY_DATE_LIST));
          doc.setProviderId(ExternalId.of(COPP_CLARK_SCHEME, ccId));
          fileMap.put(ccId, doc);
        }
        doc.getHoliday().getHolidayDates().add(eventDate);
      }
      merge(combinedMap, fileMap);
    }
    mergeWithDatabase(combinedMap);
  }
View Full Code Here

Examples of com.opengamma.master.holiday.HolidayDocument

        String countryISO = row[isoCountryIdx].trim();
        String unlocodePart = row[unlocodeIdx].trim();
        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);
      }
      merge(combinedMap, fileMap);
    }
    mergeWithDatabase(combinedMap);
  }
View Full Code Here

Examples of com.opengamma.master.holiday.HolidayDocument

        String ccId = row[ccIdx].trim();
        String isoMICCode = row[isoMICCodeIdx].trim();
        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);
      }
      merge(combinedMap, fileMap);
    }
    mergeWithDatabase(combinedMap);
  }
View Full Code Here

Examples of com.opengamma.master.holiday.HolidayDocument

        String ccId = row[ccIdx].trim();
        String isoMICCode = row[isoMICCodeIdx].trim();
        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);
      }
      merge(combinedMap, fileMap);
    }
    mergeWithDatabase(combinedMap);
  }
View Full Code Here

Examples of com.opengamma.master.holiday.HolidayDocument

  }

  //-------------------------------------------------------------------------
  private void merge(Map<String, HolidayDocument> combinedMap, Map<String, HolidayDocument> newMap) {
    for (String id : newMap.keySet()) {
      HolidayDocument newDoc = newMap.get(id);
      Collections.sort(newDoc.getHoliday().getHolidayDates());
      HolidayDocument combinedDoc = combinedMap.get(id);
      if (combinedDoc == null) {
        combinedMap.put(id, newDoc);
      } else {
        mergeDates(combinedDoc, newDoc);
        combinedMap.put(id, newDoc);
View Full Code Here

Examples of com.opengamma.master.holiday.HolidayDocument

      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);
        doc.setVersionToInstant(null);
        doc.setCorrectionFromInstant(null);
        doc.setCorrectionToInstant(null);
        existing.setVersionFromInstant(null);
        existing.setVersionToInstant(null);
        existing.setCorrectionFromInstant(null);
        existing.setCorrectionToInstant(null);
        if (doc.equals(existing) == false) {  // only update if changed
          _holidayMaster.update(doc);
        }
      } else {
        throw new IllegalStateException("Multiple rows in database for Copp Clark ID: " + doc.getProviderId().getValue() + " " + doc.getHoliday().getType());
View Full Code Here

Examples of com.opengamma.master.holiday.HolidayDocument

        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
TOP
Copyright © 2018 www.massapi.com. 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.