// ------------------------------------------------------------------------- @Override public boolean matches(AbstractDocument obj) { if (obj instanceof SecurityDocument == false) { return false; } SecurityDocument document = (SecurityDocument) obj; ManageableSecurity security = document.getSecurity(); if (getObjectIds() != null && getObjectIds().contains(document.getObjectId()) == false) { return false; } if (getExternalIdSearch() != null && getExternalIdSearch().matches(security.getIdentifiers()) == false) { return false; } if (getName() != null && RegexUtils.wildcardMatch(getName(), document.getName()) == false) { return false; } if (getSecurityType() != null && getSecurityType().equals(security.getSecurityType()) == false) { return false; } if (getExternalIdValue() != null) { for (ExternalId identifier : security.getIdentifiers()) { if (RegexUtils.wildcardMatch(getExternalIdValue(), identifier.getValue()) == false) { return false; } } } return true; }
@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; }
public Builder nameLike(String glob) { ArgumentChecker.notEmpty(glob, "glob"); if (_nameLikePattern != null) { throw new IllegalStateException("nameLike() can only be called once"); } if (_names != null) { throw new IllegalStateException( "Can't specify exact name and a regular expression for the name"); } if (_nameMatchPattern != null) { throw new IllegalStateException( "Can't specify exact name and a regular expression for the name"); } _nameLikePattern = RegexUtils.globToPattern(glob); return this; }