(ExternalIdSearch.canMatch(externalIdSearch) == false)) {
result.setPaging(Paging.of(request.getPagingRequest(), 0));
return result;
}
final DbMapSqlParameterSource args = new DbMapSqlParameterSource();
args.addTimestamp("version_as_of_instant", vc.getVersionAsOf());
args.addTimestamp("corrected_to_instant", vc.getCorrectedTo());
args.addValueNullIgnored("name", getDialect().sqlWildcardAdjustValue(request.getName()));
args.addValueNullIgnored("data_field", getDialect().sqlWildcardAdjustValue(request.getDataField()));
args.addValueNullIgnored("data_source", getDialect().sqlWildcardAdjustValue(request.getDataSource()));
args.addValueNullIgnored("data_provider", getDialect().sqlWildcardAdjustValue(request.getDataProvider()));
args.addValueNullIgnored("observation_time", getDialect().sqlWildcardAdjustValue(request.getObservationTime()));
args.addDateNullIgnored("id_validity_date", request.getValidityDate());
args.addValueNullIgnored("external_id_value", getDialect().sqlWildcardAdjustValue(request.getExternalIdValue()));
if (externalIdSearch != null) {
int i = 0;
for (ExternalId id : externalIdSearch) {
args.addValue("key_scheme" + i, id.getScheme().getName());
args.addValue("key_value" + i, id.getValue());
i++;
}
}
if (externalIdSearch != null && externalIdSearch.alwaysMatches() == false) {
int i = 0;
for (ExternalId id : externalIdSearch) {
args.addValue("key_scheme" + i, id.getScheme().getName());
args.addValue("key_value" + i, id.getValue());
i++;
}
args.addValue("sql_search_external_ids_type", externalIdSearch.getSearchType());
args.addValue("sql_search_external_ids", sqlSelectIdKeys(externalIdSearch));
args.addValue("id_search_size", externalIdSearch.getExternalIds().size());
}
if (objectIds != null) {
StringBuilder buf = new StringBuilder(objectIds.size() * 10);
for (ObjectId objectId : objectIds) {
checkScheme(objectId);
buf.append(extractOid(objectId)).append(", ");
}
buf.setLength(buf.length() - 2);
args.addValue("sql_search_object_ids", buf.toString());
}
args.addValue("paging_offset", request.getPagingRequest().getFirstItem());
args.addValue("paging_fetch", request.getPagingRequest().getPagingSize());
String[] sql = {getElSqlBundle().getSql("Search", args), getElSqlBundle().getSql("SearchCount", args)};
doSearch(request.getPagingRequest(), sql, args, new HistoricalTimeSeriesDocumentExtractor(), result);
return result;
}