Package com.opengamma.master.region

Examples of com.opengamma.master.region.RegionHistoryResult


    // Create the history search cache and register a security master searcher
    _historySearchCache = new EHCachingSearchCache(name + "RegionHistory", cacheManager, new EHCachingSearchCache.Searcher() {
      @Override
      public ObjectsPair<Integer, List<UniqueId>> search(Bean request, PagingRequest pagingRequest) {
        // Fetch search results from underlying master
        RegionHistoryResult result = ((RegionMaster) getUnderlying()).history((RegionHistoryRequest)
            EHCachingSearchCache.withPagingRequest((RegionHistoryRequest) request, pagingRequest));

        // Cache the result documents
        EHCachingSearchCache.cacheDocuments(result.getDocuments(), getUidToDocumentCache());

        // Return the list of result UniqueIds
        return new ObjectsPair<>(result.getPaging().getTotalItems(),
                                 EHCachingSearchCache.extractUniqueIds(result.getDocuments()));
      }
    });

    // Prime document search cache
    RegionSearchRequest defaultSearch = new RegionSearchRequest();
View Full Code Here


    List<RegionDocument> documents = new ArrayList<>();
    for (UniqueId uniqueId : pair.getSecond()) {
      documents.add(get(uniqueId));
    }

    RegionHistoryResult result = new RegionHistoryResult(documents);
    result.setPaging(Paging.of(request.getPagingRequest(), pair.getFirst()));
    return result;
  }
View Full Code Here

  @Override
  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

  public Response history(@Context UriInfo uriInfo) {
    RegionHistoryRequest request = RestUtils.decodeQueryParams(uriInfo, RegionHistoryRequest.class);
    if (getUrlId().equals(request.getObjectId()) == false) {
      throw new IllegalArgumentException("Document objectId does not match URI");
    }
    RegionHistoryResult result = getMaster().history(request);
    return responseOkFudge(result);
  }
View Full Code Here

  //-------------------------------------------------------------------------
  @GET
  public String getHTML() {
    RegionHistoryRequest request = new RegionHistoryRequest(data().getRegion().getUniqueId());
    RegionHistoryResult result = data().getRegionMaster().history(request);
   
    FlexiBean out = createRootData();
    out.put("versionsResult", result);
    out.put("versions", result.getRegions());
    return getFreemarker().build(HTML_DIR + "regionversions.ftl", out);
  }
View Full Code Here

      @QueryParam("pgNum") Integer pgNum,
      @QueryParam("pgSze") Integer pgSze) {
    PagingRequest pr = buildPagingRequest(pgIdx, pgNum, pgSze);
    RegionHistoryRequest request = new RegionHistoryRequest(data().getRegion().getUniqueId());
    request.setPagingRequest(pr);
    RegionHistoryResult result = data().getRegionMaster().history(request);
   
    FlexiBean out = createRootData();
    out.put("versionsResult", result);
    out.put("versions", result.getRegions());
    out.put("paging", new WebPaging(result.getPaging(), data().getUriInfo()));
    String json = getFreemarker().build(JSON_DIR + "regionversions.ftl", out);
    return Response.ok(json).build();
  }
View Full Code Here

      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);
      if (historyResult.getDocuments().size() == 0) {
        return null;
      }
      data().setRegion(historyResult.getFirstDocument());
    }
    return new WebRegionResource(this);
  }
View Full Code Here

TOP

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

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.