ArgumentChecker.notNull(request.getPagingRequest(), "request.pagingRequest");
ArgumentChecker.notNull(request.getVersionCorrection(), "request.versionCorrection");
s_logger.debug("search {}", request);
final VersionCorrection vc = request.getVersionCorrection().withLatestFixed(now());
final PositionSearchResult result = new PositionSearchResult(vc);
final ExternalIdSearch securityIdSearch = request.getSecurityIdSearch();
final Collection<ObjectId> positionObjectIds = request.getPositionObjectIds();
final Collection<ObjectId> tradeObjectIds = request.getTradeObjectIds();
if ((positionObjectIds != null && positionObjectIds.size() == 0) ||
(tradeObjectIds != null && tradeObjectIds.size() == 0) ||
(ExternalIdSearch.canMatch(securityIdSearch) == false)) {
result.setPaging(Paging.of(request.getPagingRequest(), 0));
return result;
}
final DbMapSqlParameterSource args = new DbMapSqlParameterSource().addTimestamp("version_as_of_instant", vc.getVersionAsOf()).addTimestamp("corrected_to_instant", vc.getCorrectedTo())
.addValueNullIgnored("min_quantity", request.getMinQuantity()).addValueNullIgnored("max_quantity", request.getMaxQuantity())