Package com.opengamma.master.region

Examples of com.opengamma.master.region.RegionSearchResult


  }

  @POST
  @Path("regionSearches")
  public Response search(RegionSearchRequest request) {
    RegionSearchResult result = getRegionMaster().search(request);
    return responseOkFudge(result);
  }
View Full Code Here


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

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

    // Debug: check result against underlying
    if (EHCachingSearchCache.TEST_AGAINST_UNDERLYING) {
      RegionSearchResult check = ((RegionMaster) getUnderlying()).search(request);
      if (!result.getPaging().equals(check.getPaging())) {
        s_logger.error("_documentSearchCache.getCache().getName() + \" returned paging:\\n\"" + result.getPaging() +
                           "\nbut the underlying master returned paging:\n" + check.getPaging());
      }
      if (!result.getDocuments().equals(check.getDocuments())) {
        s_logger.error(_documentSearchCache.getCache().getName() + " returned documents:\n" + result.getDocuments() +
                           "\nbut the underlying master returned documents:\n" + check.getDocuments());
      }
    }

    return result;
  }
View Full Code Here

    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

      if (request.matches(doc)) {
        list.add(doc);
      }
    }
    Collections.sort(list, RegionDocumentComparator.ASC);
    RegionSearchResult result = new RegionSearchResult();
    result.setPaging(Paging.of(request.getPagingRequest(), list));
    result.getDocuments().addAll(request.getPagingRequest().select(list));
    return result;
  }
View Full Code Here

  @Produces(MediaType.TEXT_HTML)
  public String getHTML() {
    RegionSearchRequest search = new RegionSearchRequest();
    search.setPagingRequest(PagingRequest.ALL)// may need to add paging
    search.setChildrenOfId(data().getRegion().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);
    }
View Full Code Here

  @Produces(MediaType.APPLICATION_JSON)
  public String getJSON() {
    RegionSearchRequest search = new RegionSearchRequest();
    search.setPagingRequest(PagingRequest.ALL)// may need to add paging
    search.setChildrenOfId(data().getRegion().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);
    }
View Full Code Here

      return builder.build();
    }
    RegionSearchRequest search = new RegionSearchRequest();
    search.setPagingRequest(PagingRequest.ALL)// may need to add paging
    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);
    }
View Full Code Here

      searchRequest.addObjectId(ObjectId.parse(regionIdStr));
    }
    out.put("searchRequest", searchRequest);
   
    if (data().getUriInfo().getQueryParameters().size() > 0) {
      RegionSearchResult searchResult = data().getRegionMaster().search(searchRequest);
      out.put("searchResult", searchResult);
      out.put("paging", new WebPaging(searchResult.getPaging(), uriInfo));
    }
    return out;
  }
View Full Code Here

  }

  //-------------------------------------------------------------------------
  public void test_search_oneId_noMatch() {
    RegionSearchRequest request = new RegionSearchRequest(ID_OTHER1);
    RegionSearchResult result = master.search(request);
    assertEquals(0, result.getDocuments().size());
  }
View Full Code Here

TOP

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

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.