@Override
  public PortfolioSearchResult search(PortfolioSearchRequest request) {
    ArgumentChecker.notNull(request, "request");
    Collection<PortfolioDocument> docsToCheck = null;

    if ((request.getName() != null) && !RegexUtils.containsWildcard(request.getName())) {
      docsToCheck = _portfoliosByName.get(request.getName());
    } else {
      docsToCheck = _store.values();
    }
    if (docsToCheck == null) {
      docsToCheck = Collections.emptySet();
    }

    final List<PortfolioDocument> list = new ArrayList<PortfolioDocument>();
    for (PortfolioDocument doc : docsToCheck) {
      if (request.matches(doc)) {
        PortfolioDocument docToAdd = isCloneResults() ? clonePortfolioDocument(doc) : doc;
        list.add(docToAdd);
      }
    }
    final PortfolioSearchResult result = new PortfolioSearchResult();
    result.setPaging(Paging.of(request.getPagingRequest(), list));
    result.getDocuments().addAll(request.getPagingRequest().select(list));
    return result;
  }
Example #2
0
 /**
  * Creates an instance.
  *
  * @param uids the list of Uids to add, not null
  */
 public UidsResult(List<UniqueId> uids) {
   _uids.addAll(uids);
   _paging = Paging.ofAll(uids);
 }