Package com.opengamma.master.position

Examples of com.opengamma.master.position.PositionSearchResult


  }

  @Override
  protected Collection<Position> positions(PositionSearchRequest positionSearch) {
    List<Position> result = Lists.newArrayList();
    final PositionSearchResult positions = getPositionMaster().search(positionSearch);
    for (final PositionDocument position : positions.getDocuments()) {
      result.add(position.getPosition().toPosition());
    }
    return result;
  }
View Full Code Here


    // Create the doc search cache and register a position master searcher
    _documentSearchCache = new EHCachingSearchCache(name + "Position", cacheManager, new EHCachingSearchCache.Searcher() {
      @Override
      public ObjectsPair<Integer, List<UniqueId>> search(Bean request, PagingRequest pagingRequest) {
        // Fetch search results from underlying master
        PositionSearchResult result = ((PositionMaster) getUnderlying()).search((PositionSearchRequest)
            EHCachingSearchCache.withPagingRequest(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()));
      }
    });

    // Create the history search cache and register a security master searcher
    _historySearchCache = new EHCachingSearchCache(name + "PositionHistory", cacheManager, new EHCachingSearchCache.Searcher() {
      @Override
      public ObjectsPair<Integer, List<UniqueId>> search(Bean request, PagingRequest pagingRequest) {
        // Fetch search results from underlying master
        PositionHistoryResult result = ((PositionMaster) getUnderlying()).history((PositionHistoryRequest)
            EHCachingSearchCache.withPagingRequest(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 search cache
    PositionSearchRequest defaultSearch = new PositionSearchRequest();
View Full Code Here

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

    PositionSearchResult result = new PositionSearchResult(documents);
    result.setPaging(Paging.of(request.getPagingRequest(), pair.getFirst()));

    final VersionCorrection vc = request.getVersionCorrection().withLatestFixed(Instant.now());
    result.setVersionCorrection(vc);

    // Debug: check result against underlying
    if (EHCachingSearchCache.TEST_AGAINST_UNDERLYING) {
      PositionSearchResult check = ((PositionMaster) getUnderlying()).search(request);
      if (!result.getPaging().equals(check.getPaging())) {
        s_logger.error(_documentSearchCache.getCache().getName()
                           + "\n\tCache:\t" + result.getPaging()
                           + "\n\tUnderlying:\t" + check.getPaging());
      }
      if (!result.getDocuments().equals(check.getDocuments())) {
        System.out.println(_documentSearchCache.getCache().getName() + ": ");
        if (check.getDocuments().size() != result.getDocuments().size()) {
          System.out.println("\tSizes differ (Underlying " + check.getDocuments().size()
                             + "; Cache " + result.getDocuments().size() + ")");
        } else {
          for (int i = 0; i < check.getDocuments().size(); i++) {
            if (!check.getDocuments().get(i).equals(result.getDocuments().get(i))) {
              System.out.println("\tUnderlying\t" + i + ":\t" + check.getDocuments().get(i).getUniqueId());
            }
          }
        }
      }
    }
View Full Code Here

  }

  @POST
  @Path("positionSearches")
  public Response search(PositionSearchRequest request) {
    PositionSearchResult result = getPositionMaster().search(request);
    return responseOkFudge(result);
  }
View Full Code Here

    manPos.addTrade(manTrade);
    PositionDocument posDoc = new PositionDocument(manPos);
    PositionSearchRequest posRequest = new PositionSearchRequest();
    posRequest.addPositionObjectId(UID4);
    posRequest.setVersionCorrection(VC);
    PositionSearchResult posResult = new PositionSearchResult();
    posResult.getDocuments().add(posDoc);
   
    when(mockPortfolio.get(UID)).thenReturn(prtDoc);
    when(mockPosition.search(posRequest)).thenReturn(posResult);
    MasterPositionSource test = new MasterPositionSource(mockPortfolio, mockPosition);
    Portfolio testResult = test.getPortfolio(UID, VC);
View Full Code Here

TOP

Related Classes of com.opengamma.master.position.PositionSearchResult

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.