Package com.opengamma.master.region

Examples of com.opengamma.master.region.RegionDocument


  }

  @POST
  @Path("regions")
  public Response add(@Context UriInfo uriInfo, RegionDocument request) {
    RegionDocument result = getRegionMaster().add(request);
    URI createdUri = (new DataRegionResource()).uriVersion(uriInfo.getBaseUri(), result.getUniqueId());
    return responseCreatedFudge(createdUri, result);
  }
View Full Code Here


            region.getParentRegionIds().add(entry.getKey());
          }
        }
       
        // store
        RegionDocument doc = getRegionMaster().add(new RegionDocument(region));
        if (rowSubRegions.size() > 0) {
          subRegions.put(doc.getUniqueId(), rowSubRegions);
        }
        regions.put(name, region);
      }
      for (Set<String> set : subRegions.values()) {
        if (set.size() > 0) {
View Full Code Here

    }
  }

  private void store(Set<ManageableRegion> regions) {
    for (ManageableRegion region : regions) {
      RegionDocument doc = new RegionDocument();
      doc.setRegion(region);
      RegionSearchRequest request = new RegionSearchRequest();
      request.addExternalIds(region.getExternalIdBundle());
      RegionSearchResult result = _regionMaster.search(request);
      if (result.getDocuments().size() == 0) {
        _regionMaster.add(doc);
      } else {
        RegionDocument existing = result.getFirstDocument();
        if (existing.getRegion().getName().equals(doc.getRegion().getName()) == false ||
            existing.getRegion().getFullName().equals(doc.getRegion().getFullName()) == false) {
          existing.getRegion().setName(doc.getRegion().getName());
          existing.getRegion().setFullName(doc.getRegion().getFullName());
          _regionMaster.update(existing);
        }
      }
    }
  }
View Full Code Here

  //-------------------------------------------------------------------------
  @Override
  public RegionDocument get(final ObjectIdentifiable objectId, final VersionCorrection versionCorrection) {
    ArgumentChecker.notNull(objectId, "objectId");
    ArgumentChecker.notNull(versionCorrection, "versionCorrection");
    final RegionDocument document = _store.get(objectId.getObjectId());
    if (document == null) {
      throw new DataNotFoundException("Region not found: " + objectId);
    }
    return document;
  }
View Full Code Here

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

    final UniqueId uniqueId = document.getUniqueId();
    final Instant now = Instant.now();
    final RegionDocument storedDocument = _store.get(uniqueId.getObjectId());
    if (storedDocument == null) {
      throw new DataNotFoundException("Region not found: " + uniqueId);
    }
    document.setVersionFromInstant(now);
    document.setVersionToInstant(null);
    document.setCorrectionFromInstant(now);
    document.setCorrectionToInstant(null);
    if (_store.replace(uniqueId.getObjectId(), storedDocument, document) == false) {
      throw new IllegalArgumentException("Concurrent modification");
    }
    _changeManager.entityChanged(ChangeType.CHANGED, document.getObjectId(), storedDocument.getVersionFromInstant(), document.getVersionToInstant(), now);
    return document;
  }
View Full Code Here

  public RegionHistoryResult history(final RegionHistoryRequest request) {
    ArgumentChecker.notNull(request, "request");
    ArgumentChecker.notNull(request.getObjectId(), "request.objectId");

    final RegionHistoryResult result = new RegionHistoryResult();
    final RegionDocument doc = get(request.getObjectId(), VersionCorrection.LATEST);
    if (doc != null) {
      result.getDocuments().add(doc);
    }
    result.setPaging(Paging.ofAll(result.getDocuments()));
    return result;
View Full Code Here

  @Path("{regionId}")
  public WebRegionResource findRegion(@PathParam("regionId") String idStr) {
    data().setUriRegionId(idStr);
    UniqueId oid = UniqueId.parse(idStr);
    try {
      RegionDocument doc = data().getRegionMaster().get(oid);
      data().setRegion(doc);
    } catch (DataNotFoundException ex) {
      RegionHistoryRequest historyRequest = new RegionHistoryRequest(oid);
      historyRequest.setPagingRequest(PagingRequest.ONE);
      RegionHistoryResult historyResult = data().getRegionMaster().history(historyRequest);
View Full Code Here

   * Creates the output root data.
   * @return the output root data, not null
   */
  protected FlexiBean createRootData() {
    FlexiBean out = super.createRootData();
    RegionDocument doc = data().getRegion();
    out.put("regionDoc", doc);
    out.put("region", doc.getRegion());
    out.put("deleted", !doc.isLatest());
    out.put("regionParents", data().getRegionParents());
    out.put("regionChildren", data().getRegionChildren());
    return out;
  }
View Full Code Here

    search.setChildrenOfId(data().getVersioned().getUniqueId());
    RegionSearchResult children = data().getRegionMaster().search(search);
    data().setRegionChildren(children.getDocuments());

    for (UniqueId parentId : data().getRegion().getRegion().getParentRegionIds()) {
      RegionDocument parent = data().getRegionMaster().get(parentId);
      data().getRegionParents().add(parent);
    }
   
    FlexiBean out = createRootData();
    String json = getFreemarker().build(JSON_DIR + "region.ftl", out);
View Full Code Here

   * Creates the output root data.
   * @return the output root data, not null
   */
  protected FlexiBean createRootData() {
    FlexiBean out = super.createRootData();
    RegionDocument latestDoc = data().getRegion();
    RegionDocument versionedRegion = data().getVersioned();
    out.put("latestRegionDoc", latestDoc);
    out.put("latestRegion", latestDoc.getRegion());
    out.put("regionDoc", versionedRegion);
    out.put("region", versionedRegion.getRegion());
    out.put("deleted", !latestDoc.isLatest());
    out.put("regionParents", data().getRegionParents());
    out.put("regionChildren", data().getRegionChildren());
    return out;
  }
View Full Code Here

TOP

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

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.