Package com.opengamma.master.region

Examples of com.opengamma.master.region.ManageableRegion


        String countryISO = StringUtils.trimToNull(row[countryColumnIdx]);
        String currencyISO = StringUtils.trimToNull(row[currencyColumnIdx]);
        Set<String> rowSubRegions = new HashSet<String>(Arrays.asList(row[subRegionsColumnIdx].split(";")));
        rowSubRegions = trim(rowSubRegions);
       
        ManageableRegion region = new ManageableRegion();
        region.setClassification(classification);
        region.setName(name);
        region.setFullName(fullName);
        if (countryISO != null) {
          region.setCountry(Country.of(countryISO));
          region.addExternalId(ExternalSchemes.financialRegionId(countryISO))// TODO: looks odd
        }
        if (currencyISO != null) {
          region.setCurrency(Currency.of(currencyISO));
        }
        if (sovereignity != null) {
          ManageableRegion parent = regions.get(sovereignity);
          if (parent == null) {
            throw new OpenGammaRuntimeException("Cannot find parent '" + sovereignity + "'  for '" + name + "'");
          }
          region.getParentRegionIds().add(parent.getUniqueId());
        }
        for (Entry<UniqueId, Set<String>> entry : subRegions.entrySet()) {
          if (entry.getValue().remove(name)) {
            region.getParentRegionIds().add(entry.getKey());
          }
View Full Code Here


            StringUtils.isEmpty(unlocodePart) || unlocode.length() != 5 ||
            countryISO.equals("XZ") || "=".equals(type) || required.remove(unlocode) == false) {
          continue;
        }
       
        ManageableRegion region = createRegion(name, fullName, countryISO);
        region.addExternalId(ExternalSchemes.unLocode20102RegionId(unlocode));
        regions.add(region);
      }
    } catch (Exception ex) {
      String detail = (name != null ? " while processing " + name : "");
      throw new OpenGammaRuntimeException("Unable to read UN/LOCODEs" + detail, ex);
View Full Code Here

    }
    return regions;
  }

  private ManageableRegion createRegion(String name, String fullName, String countryISO) {
    ManageableRegion region = new ManageableRegion();
    region.setClassification(RegionClassification.MUNICIPALITY);
    region.setName(name);
    region.setFullName(fullName);
    addParent(region, countryISO);
    return region;
  }
View Full Code Here

  }

  private void addParent(ManageableRegion region, String countryISO) {
    RegionSearchRequest request = new RegionSearchRequest();
    request.addCountry(Country.of(countryISO));
    ManageableRegion parent = _regionMaster.search(request).getFirstRegion();
    if (parent == null) {
      throw new OpenGammaRuntimeException("Cannot find parent '" + countryISO + "'  for '" + region.getName() + "'");
    }
    region.getParentRegionIds().add(parent.getUniqueId());
  }
View Full Code Here

      } else {
        region.addExternalId(ExternalSchemes.coppClarkRegionId(unLocode));
      }
    }
    for (Entry<String, String> entry : COPP_CLARK_ADDITIONS.entrySet()) {
      ManageableRegion region = createRegion(entry.getValue(), entry.getValue(), entry.getKey().substring(0, 2));
      region.addExternalId(ExternalSchemes.coppClarkRegionId(entry.getKey()));
      regions.add(region);
    }
  }
View Full Code Here

    ArgumentChecker.notNull(document, "document");
    ArgumentChecker.notNull(document.getRegion(), "document.region");

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

    quotedSpread = Double.valueOf(buySellProtection == BuySellProtection.SELL ? -quotedSpread : quotedSpread);
    return new QuotedSpread(quote.getCoupon(), quotedSpread);
  }

  public static ManageableRegion getTestRegion() {
    final ManageableRegion region = new ManageableRegion();
    region.setUniqueId(UniqueId.parse("Dummy~region"));
    region.setName("United States");
    region.setCurrency(Currency.USD);
    region.setCountry(Country.US);
    region.setTimeZone(ZoneId.of("America/New_York"));
    region.setExternalIdBundle(ExternalIdBundle.of(ExternalId.parse("dummy~region")));
    return region;
  }
View Full Code Here

    return Double.valueOf(cs01 * notional * ONE_BPS);
  }


  public static ManageableRegion getTestRegion() {
    final ManageableRegion region = new ManageableRegion();
    region.setUniqueId(UniqueId.parse("Dummy~region"));
    region.setName("United States");
    region.setCurrency(Currency.USD);
    region.setCountry(Country.US);
    region.setTimeZone(ZoneId.of("America/New_York"));
    region.setExternalIdBundle(ExternalIdBundle.of(ExternalId.parse("dummy~region")));
    return region;
  }
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Test
  public void testAddRegion() {
    final ManageableRegion target = new ManageableRegion();
    target.setFullName("Bananaville");
    final RegionDocument request = new RegionDocument(target);
   
    final RegionDocument result = new RegionDocument(target);
    result.setUniqueId(UID);
    when(_underlying.add(same(request))).thenReturn(result);
View Full Code Here

    URI uri = addRegion(name, fullName, classification, countryISO, currencyISO, timeZoneId);
    return Response.created(uri).build();
  }

  private URI addRegion(String name, String fullName, RegionClassification classification, String countryISO, String currencyISO, String timeZoneId) {
    ManageableRegion region = new ManageableRegion();
    region.getParentRegionIds().add(data().getRegion().getUniqueId());
    region.setName(name);
    region.setFullName(fullName);
    region.setClassification(classification);
    region.setCountry(countryISO != null ? Country.of(countryISO) : null);
    region.setCurrency(currencyISO != null ? Currency.of(currencyISO) : null);
    region.setTimeZone(timeZoneId != null ? ZoneId.of(timeZoneId) : null);
    RegionDocument doc = new RegionDocument(region);
    RegionDocument added = data().getRegionMaster().add(doc);
    return WebRegionResource.uri(data(), added.getUniqueId());
  }
View Full Code Here

TOP

Related Classes of com.opengamma.master.region.ManageableRegion

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.