mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
RDAP: Factor out a utility method
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=134700128
This commit is contained in:
parent
bf75c4ca48
commit
e5c0854ae6
2 changed files with 38 additions and 40 deletions
|
@ -168,7 +168,9 @@ public abstract class RdapActionBase implements Runnable {
|
|||
*
|
||||
* @param clazz the type of resource to be queried
|
||||
* @param filterField the database field of interest
|
||||
* @param partialStringQuery the details of the search string
|
||||
* @param partialStringQuery the details of the search string; if there is no wildcard, an
|
||||
* equality query is used; if there is a wildcard, a range query is used instead; there
|
||||
* should not be a search suffix
|
||||
* @param resultSetMaxSize the maximum number of results to return
|
||||
* @return the results of the query
|
||||
*/
|
||||
|
@ -177,12 +179,20 @@ public abstract class RdapActionBase implements Runnable {
|
|||
String filterField,
|
||||
RdapSearchPattern partialStringQuery,
|
||||
int resultSetMaxSize) {
|
||||
checkArgument(partialStringQuery.getHasWildcard(), "search string doesn't have wildcard");
|
||||
return ofy().load()
|
||||
.type(clazz)
|
||||
.filter(filterField + " >=", partialStringQuery.getInitialString())
|
||||
.filter(filterField + " <", partialStringQuery.getNextInitialString())
|
||||
.filter("deletionTime", END_OF_TIME)
|
||||
.limit(resultSetMaxSize);
|
||||
if (!partialStringQuery.getHasWildcard()) {
|
||||
return ofy().load()
|
||||
.type(clazz)
|
||||
.filter(filterField, partialStringQuery.getInitialString())
|
||||
.filter("deletionTime", END_OF_TIME)
|
||||
.limit(resultSetMaxSize);
|
||||
} else {
|
||||
checkArgument(partialStringQuery.getSuffix() == null, "Unexpected search string suffix");
|
||||
return ofy().load()
|
||||
.type(clazz)
|
||||
.filter(filterField + " >=", partialStringQuery.getInitialString())
|
||||
.filter(filterField + " <", partialStringQuery.getNextInitialString())
|
||||
.filter("deletionTime", END_OF_TIME)
|
||||
.limit(resultSetMaxSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue