com.googlecode.objectify.cmd.Query Java Examples
The following examples show how to use
com.googlecode.objectify.cmd.Query.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RdapNameserverSearchAction.java From nomulus with Apache License 2.0 | 6 votes |
/** Searches for nameservers by IP address, returning a JSON array of nameserver info maps. */ private NameserverSearchResponse searchByIp(InetAddress inetAddress) { // Add 1 so we can detect truncation. int querySizeLimit = getStandardQuerySizeLimit(); Query<HostResource> query = queryItems( HostResource.class, "inetAddresses", inetAddress.getHostAddress(), Optional.empty(), cursorString, getDeletedItemHandling(), querySizeLimit); return makeSearchResults( getMatchingResources(query, shouldIncludeDeleted(), querySizeLimit), CursorType.ADDRESS); }
Example #2
Source File: OteStats.java From nomulus with Apache License 2.0 | 6 votes |
/** * Records data on what actions have been performed by the four numbered OT&E variants of the * registrar name. * * <p>Stops when it notices that all tests have passed. */ private OteStats recordRegistrarHistory(String registrarName) { ImmutableCollection<String> clientIds = OteAccountBuilder.createClientIdToTldMap(registrarName).keySet(); Query<HistoryEntry> query = ofy() .load() .type(HistoryEntry.class) .filter("clientId in", clientIds) .order("modificationTime"); for (HistoryEntry historyEntry : query) { try { record(historyEntry); } catch (XmlException e) { throw new RuntimeException("Couldn't parse history entry " + Key.create(historyEntry), e); } // Break out early if all tests were passed. if (wereAllTestsPassed()) { break; } } return this; }
Example #3
Source File: RdapSearchActionBase.java From nomulus with Apache License 2.0 | 6 votes |
/** * Handles searches using a simple string rather than an {@link RdapSearchPattern}. * * <p>Since the filter is not an inequality, we can support also checking a cursor string against * a different field (which involves an inequality on that field). * * @param clazz the type of resource to be queried * @param filterField the database field of interest * @param queryString the search string * @param cursorField the field which should be compared to the cursor string, or empty() if the * key should be compared to a key created from the cursor string * @param cursorString if a cursor is present, this parameter should specify the cursor string, to * skip any results up to and including the string; empty() if there is no cursor * @param deletedItemHandling whether to include or exclude deleted items * @param resultSetMaxSize the maximum number of results to return * @return the query object */ static <T extends EppResource> Query<T> queryItems( Class<T> clazz, String filterField, String queryString, Optional<String> cursorField, Optional<String> cursorString, DeletedItemHandling deletedItemHandling, int resultSetMaxSize) { if (queryString.length() < RdapSearchPattern.MIN_INITIAL_STRING_LENGTH) { throw new UnprocessableEntityException( String.format( "Initial search string must be at least %d characters", RdapSearchPattern.MIN_INITIAL_STRING_LENGTH)); } Query<T> query = ofy().load().type(clazz).filter(filterField, queryString); if (cursorString.isPresent()) { if (cursorField.isPresent()) { query = query.filter(cursorField.get() + " >", cursorString.get()); } else { query = query.filterKey(">", Key.create(clazz, cursorString.get())); } } return setOtherQueryAttributes(query, deletedItemHandling, resultSetMaxSize); }
Example #4
Source File: FeedbackResponseCommentsDb.java From teammates with GNU General Public License v2.0 | 6 votes |
/** * Deletes comments using {@link AttributesDeletionQuery}. */ public void deleteFeedbackResponseComments(AttributesDeletionQuery query) { Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, query); Query<FeedbackResponseComment> entitiesToDelete = load().project(); if (query.isCourseIdPresent()) { entitiesToDelete = entitiesToDelete.filter("courseId =", query.getCourseId()); } if (query.isFeedbackSessionNamePresent()) { entitiesToDelete = entitiesToDelete.filter("feedbackSessionName =", query.getFeedbackSessionName()); } if (query.isQuestionIdPresent()) { entitiesToDelete = entitiesToDelete.filter("feedbackQuestionId =", query.getQuestionId()); } if (query.isResponseIdPresent()) { entitiesToDelete = entitiesToDelete.filter("feedbackResponseId =", query.getResponseId()); } List<Key<FeedbackResponseComment>> keysToDelete = entitiesToDelete.keys().list(); deleteDocument(Const.SearchIndex.FEEDBACK_RESPONSE_COMMENT, keysToDelete.stream().map(key -> String.valueOf(key.getId())).toArray(String[]::new)); deleteEntity(keysToDelete.toArray(new Key<?>[0])); }
Example #5
Source File: FeedbackResponsesDb.java From teammates with GNU General Public License v2.0 | 6 votes |
/** * Deletes responses using {@link AttributesDeletionQuery}. */ public void deleteFeedbackResponses(AttributesDeletionQuery query) { Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, query); Query<FeedbackResponse> entitiesToDelete = load().project(); if (query.isCourseIdPresent()) { entitiesToDelete = entitiesToDelete.filter("courseId =", query.getCourseId()); } if (query.isFeedbackSessionNamePresent()) { entitiesToDelete = entitiesToDelete.filter("feedbackSessionName =", query.getFeedbackSessionName()); } if (query.isQuestionIdPresent()) { entitiesToDelete = entitiesToDelete.filter("feedbackQuestionId =", query.getQuestionId()); } deleteEntity(entitiesToDelete.keys().list().toArray(new Key<?>[0])); }
Example #6
Source File: RdapDomainSearchAction.java From nomulus with Apache License 2.0 | 6 votes |
/** * Searches for domains by nameserver address, returning a JSON array of domain info maps. * * <p>This is a two-step process: get a list of host references by IP address, and then look up * domains by host reference. * * <p>In theory, we could have any number of hosts using the same IP address. To make sure we get * all the associated domains, we have to retrieve all of them, and use them to look up domains. * This could open us up to a kind of DoS attack if huge number of hosts are defined on a single * IP. To avoid this, fetch only the first {@link #maxNameserversInFirstStage} nameservers. In all * normal circumstances, this should be orders of magnitude more than there actually are. But it * could result in us missing some domains. * * <p>The includeDeleted parameter does NOT cause deleted nameservers to be searched, only deleted * domains which used to be connected to an undeleted nameserver. */ private DomainSearchResponse searchByNameserverIp(final InetAddress inetAddress) { Query<HostResource> query = queryItems( HostResource.class, "inetAddresses", inetAddress.getHostAddress(), Optional.empty(), Optional.empty(), DeletedItemHandling.EXCLUDE, maxNameserversInFirstStage); Optional<String> desiredRegistrar = getDesiredRegistrar(); if (desiredRegistrar.isPresent()) { query = query.filter("currentSponsorClientId", desiredRegistrar.get()); } return searchByNameserverRefs( StreamSupport.stream(query.keys().spliterator(), false) .map(key -> VKey.from(key)) .collect(toImmutableSet())); }
Example #7
Source File: RdapDomainSearchAction.java From nomulus with Apache License 2.0 | 6 votes |
/** Searches for domains by domain name with a TLD suffix. */ private DomainSearchResponse searchByDomainNameByTld(String tld) { // Even though we are not searching on fullyQualifiedDomainName, we want the results to come // back ordered by name, so we are still in the same boat as // searchByDomainNameWithInitialString, unable to perform an inequality query on deletion time. // Don't use queryItems, because it doesn't handle pending deletes. int querySizeLimit = RESULT_SET_SIZE_SCALING_FACTOR * rdapResultSetMaxSize; Query<DomainBase> query = ofy() .load() .type(DomainBase.class) .filter("tld", tld); if (cursorString.isPresent()) { query = query.filter("fullyQualifiedDomainName >", cursorString.get()); } query = query.order("fullyQualifiedDomainName").limit(querySizeLimit); return makeSearchResults(getMatchingResources(query, true, querySizeLimit)); }
Example #8
Source File: CursorIterator.java From teammates with GNU General Public License v2.0 | 6 votes |
/** * Fetches entities in batches and puts them into the buffer. */ private void batchFetching() { Query<T> newQuery = this.query.limit(BUFFER_SIZE); if (this.cursor != null) { newQuery = newQuery.startAt(this.cursor); } QueryResultIterator<T> iterator = newQuery.iterator(); boolean shouldContinue = false; while (iterator.hasNext()) { shouldContinue = true; this.buffer.offer(iterator.next()); } if (shouldContinue) { this.cursor = iterator.getCursor(); } }
Example #9
Source File: FeedbackQuestionsDb.java From teammates with GNU General Public License v2.0 | 5 votes |
/** * Deletes questions using {@link AttributesDeletionQuery}. */ public void deleteFeedbackQuestions(AttributesDeletionQuery query) { Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, query); Query<FeedbackQuestion> entitiesToDelete = load().project(); if (query.isCourseIdPresent()) { entitiesToDelete = entitiesToDelete.filter("courseId =", query.getCourseId()); } if (query.isFeedbackSessionNamePresent()) { entitiesToDelete = entitiesToDelete.filter("feedbackSessionName =", query.getFeedbackSessionName()); } deleteEntity(entitiesToDelete.keys().list().toArray(new Key<?>[0])); }
Example #10
Source File: FeedbackSessionsDb.java From teammates with GNU General Public License v2.0 | 5 votes |
/** * Deletes sessions using {@link AttributesDeletionQuery}. */ public void deleteFeedbackSessions(AttributesDeletionQuery query) { Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, query); Query<FeedbackSession> entitiesToDelete = load().project(); if (query.isCourseIdPresent()) { entitiesToDelete = entitiesToDelete.filter("courseId =", query.getCourseId()); } deleteEntity(entitiesToDelete.keys().list().toArray(new Key<?>[0])); }
Example #11
Source File: ConferenceQueryForm.java From ud859 with GNU General Public License v3.0 | 5 votes |
/** * Returns an Objectify Query object for the specified filters. * * @return an Objectify Query. */ @ApiResourceProperty(ignored = AnnotationBoolean.TRUE) public Query<Conference> getQuery() { // First check the feasibility of inequality filters. checkFilters(); Query<Conference> query = ofy().load().type(Conference.class); if (inequalityFilter == null) { // Order by name. query = query.order("name"); } else { // If we have any inequality filters, order by the field first. query = query.order(inequalityFilter.field.getFieldName()); query = query.order("name"); } for (Filter filter : this.filters) { // Applies filters in order. if (filter.field.fieldType == FieldType.STRING) { query = query.filter(String.format("%s %s", filter.field.getFieldName(), filter.operator.getQueryOperator()), filter.value); } else if (filter.field.fieldType == FieldType.INTEGER) { query = query.filter(String.format("%s %s", filter.field.getFieldName(), filter.operator.getQueryOperator()), Integer.parseInt(filter.value)); } } LOG.info(query.toString()); return query; }
Example #12
Source File: RdapNameserverSearchAction.java From nomulus with Apache License 2.0 | 5 votes |
/** * Searches for nameservers by name with a prefix and wildcard. * * <p>There are no pending deletes for hosts, so we can call {@link * RdapSearchActionBase#queryItems}. */ private NameserverSearchResponse searchByNameUsingPrefix(RdapSearchPattern partialStringQuery) { // Add 1 so we can detect truncation. int querySizeLimit = getStandardQuerySizeLimit(); Query<HostResource> query = queryItems( HostResource.class, "fullyQualifiedHostName", partialStringQuery, cursorString, getDeletedItemHandling(), querySizeLimit); return makeSearchResults( getMatchingResources(query, shouldIncludeDeleted(), querySizeLimit), CursorType.NAME); }
Example #13
Source File: ConferenceApi.java From ud859 with GNU General Public License v3.0 | 5 votes |
/** Code to add at the start of querying for conferences **/ @ApiMethod( name = "queryConferences_nofilters", path = "queryConferences_nofilters", httpMethod = HttpMethod.POST ) public List<Conference> queryConferences_nofilters() { // Find all entities of type Conference Query<Conference> query = ofy().load().type(Conference.class).order("name"); return query.list(); }
Example #14
Source File: ConferenceApi.java From ud859 with GNU General Public License v3.0 | 5 votes |
public List<Conference> filterPlayground() { // Query<Conference> query = ofy().load().type(Conference.class).order("name"); Query<Conference> query = ofy().load().type(Conference.class); /* // Filter on city query = query.filter("city =", "London"); // query = query.filter("city =", "Default City"); // Add a filter for topic = "Medical Innovations" query = query.filter("topics =", "Medical Innovations"); // Add a filter for maxAttendees query = query.filter("maxAttendees >", 8); query = query.filter("maxAttendees <", 10).order("maxAttendees").order("name"); // Add a filter for month {unindexed composite query} // Find conferences in June query = query.filter("month =", 6); */ // multiple sort orders query = query.filter("city =", "Tokyo").filter("seatsAvailable <", 10). filter("seatsAvailable >" , 0).order("seatsAvailable").order("name"). order("month"); return query.list(); }
Example #15
Source File: ConferenceQueryForm.java From ud859 with GNU General Public License v3.0 | 5 votes |
/** * Returns an Objectify Query object for the specified filters. * * @return an Objectify Query. */ @ApiResourceProperty(ignored = AnnotationBoolean.TRUE) public Query<Conference> getQuery() { // First check the feasibility of inequality filters. checkFilters(); Query<Conference> query = ofy().load().type(Conference.class); if (inequalityFilter == null) { // Order by name. query = query.order("name"); } else { // If we have any inequality filters, order by the field first. query = query.order(inequalityFilter.field.getFieldName()); query = query.order("name"); } for (Filter filter : this.filters) { // Applies filters in order. if (filter.field.fieldType == FieldType.STRING) { query = query.filter(String.format("%s %s", filter.field.getFieldName(), filter.operator.getQueryOperator()), filter.value); } else if (filter.field.fieldType == FieldType.INTEGER) { query = query.filter(String.format("%s %s", filter.field.getFieldName(), filter.operator.getQueryOperator()), Integer.parseInt(filter.value)); } } LOG.info(query.toString()); return query; }
Example #16
Source File: ConferenceQueryForm.java From ud859 with GNU General Public License v3.0 | 5 votes |
/** * Returns an Objectify Query object for the specified filters. * * @return an Objectify Query. */ @ApiResourceProperty(ignored = AnnotationBoolean.TRUE) public Query<Conference> getQuery() { // First check the feasibility of inequality filters. checkFilters(); Query<Conference> query = ofy().load().type(Conference.class); if (inequalityFilter == null) { // Order by name. query = query.order("name"); } else { // If we have any inequality filters, order by the field first. query = query.order(inequalityFilter.field.getFieldName()); query = query.order("name"); } for (Filter filter : this.filters) { // Applies filters in order. if (filter.field.fieldType == FieldType.STRING) { query = query.filter(String.format("%s %s", filter.field.getFieldName(), filter.operator.getQueryOperator()), filter.value); } else if (filter.field.fieldType == FieldType.INTEGER) { query = query.filter(String.format("%s %s", filter.field.getFieldName(), filter.operator.getQueryOperator()), Integer.parseInt(filter.value)); } } LOG.info(query.toString()); return query; }
Example #17
Source File: ConferenceApi.java From ud859 with GNU General Public License v3.0 | 5 votes |
public List<Conference> filterPlayground() { // Query<Conference> query = ofy().load().type(Conference.class).order("name"); Query<Conference> query = ofy().load().type(Conference.class); /* // Filter on city query = query.filter("city =", "London"); // query = query.filter("city =", "Default City"); // Add a filter for topic = "Medical Innovations" query = query.filter("topics =", "Medical Innovations"); // Add a filter for maxAttendees query = query.filter("maxAttendees >", 8); query = query.filter("maxAttendees <", 10).order("maxAttendees").order("name"); // Add a filter for month {unindexed composite query} // Find conferences in June query = query.filter("month =", 6); */ // multiple sort orders query = query.filter("city =", "Tokyo").filter("seatsAvailable <", 10). filter("seatsAvailable >" , 0).order("seatsAvailable").order("name"). order("month"); return query.list(); }
Example #18
Source File: ConferenceApi.java From ud859 with GNU General Public License v3.0 | 5 votes |
@ApiMethod( name = "queryConferences_nofilters", path = "queryConferences_nofilters", httpMethod = HttpMethod.POST ) public List<Conference> queryConferences_nofilters() { // Find all entities of type Conference Query<Conference> query = ofy().load().type(Conference.class).order("name"); return query.list(); }
Example #19
Source File: PollFlowUtils.java From nomulus with Apache License 2.0 | 5 votes |
/** Returns a query for poll messages for the logged in registrar which are not in the future. */ public static Query<PollMessage> getPollMessagesQuery(String clientId, DateTime now) { return ofy().load() .type(PollMessage.class) .filter("clientId", clientId) .filter("eventTime <=", now.toDate()) .order("eventTime"); }
Example #20
Source File: EppResourceUtils.java From nomulus with Apache License 2.0 | 5 votes |
/** * Returns a query for domains or applications that reference a specified contact or host. * * <p>This is an eventually consistent query. * * @param key the referent key * @param now the logical time of the check */ public static Query<DomainBase> queryForLinkedDomains( Key<? extends EppResource> key, DateTime now) { boolean isContactKey = key.getKind().equals(Key.getKind(ContactResource.class)); return ofy() .load() .type(DomainBase.class) .filter(isContactKey ? "allContacts.contact" : "nsHosts", key) .filter("deletionTime >", now); }
Example #21
Source File: RdapSearchActionBase.java From nomulus with Apache License 2.0 | 5 votes |
static <T extends EppResource> Query<T> setOtherQueryAttributes( Query<T> query, DeletedItemHandling deletedItemHandling, int resultSetMaxSize) { if (deletedItemHandling != DeletedItemHandling.INCLUDE) { query = query.filter("deletionTime", END_OF_TIME); } return query.limit(resultSetMaxSize); }
Example #22
Source File: RdapSearchActionBase.java From nomulus with Apache License 2.0 | 5 votes |
/** Handles searches by key using a simple string. */ static <T extends EppResource> Query<T> queryItemsByKey( Class<T> clazz, String queryString, DeletedItemHandling deletedItemHandling, int resultSetMaxSize) { if (queryString.length() < RdapSearchPattern.MIN_INITIAL_STRING_LENGTH) { throw new UnprocessableEntityException( String.format( "Initial search string must be at least %d characters", RdapSearchPattern.MIN_INITIAL_STRING_LENGTH)); } Query<T> query = ofy().load().type(clazz).filterKey("=", Key.create(clazz, queryString)); return setOtherQueryAttributes(query, deletedItemHandling, resultSetMaxSize); }
Example #23
Source File: RdapSearchActionBase.java From nomulus with Apache License 2.0 | 5 votes |
/** Handles searches where the field to be searched is the key. */ static <T extends EppResource> Query<T> queryItemsByKey( Class<T> clazz, RdapSearchPattern partialStringQuery, Optional<String> cursorString, DeletedItemHandling deletedItemHandling, int resultSetMaxSize) { if (partialStringQuery.getInitialString().length() < RdapSearchPattern.MIN_INITIAL_STRING_LENGTH) { throw new UnprocessableEntityException( String.format( "Initial search string must be at least %d characters", RdapSearchPattern.MIN_INITIAL_STRING_LENGTH)); } Query<T> query = ofy().load().type(clazz); if (!partialStringQuery.getHasWildcard()) { query = query.filterKey("=", Key.create(clazz, partialStringQuery.getInitialString())); } else { // Ignore the suffix; the caller will need to filter on the suffix, if any. query = query .filterKey(">=", Key.create(clazz, partialStringQuery.getInitialString())) .filterKey("<", Key.create(clazz, partialStringQuery.getNextInitialString())); } if (cursorString.isPresent()) { query = query.filterKey(">", Key.create(clazz, cursorString.get())); } return setOtherQueryAttributes(query, deletedItemHandling, resultSetMaxSize); }
Example #24
Source File: RdapDomainSearchAction.java From nomulus with Apache License 2.0 | 5 votes |
/** Searches for domains by domain name with an initial string, wildcard and possible suffix. */ private DomainSearchResponse searchByDomainNameWithInitialString( final RdapSearchPattern partialStringQuery) { // We can't query for undeleted domains as part of the query itself; that would require an // inequality query on deletion time, and we are already using inequality queries on // fullyQualifiedDomainName. So we instead pick an arbitrary limit of // RESULT_SET_SIZE_SCALING_FACTOR times the result set size limit, fetch up to that many, and // weed out all deleted domains. If there still isn't a full result set's worth of domains, we // give up and return just the ones we found. Don't use queryItems, because it checks that the // initial string is at least a certain length, which we don't need in this case. Query the // domains directly, rather than the foreign keys, because then we have an index on TLD if we // need it. int querySizeLimit = RESULT_SET_SIZE_SCALING_FACTOR * rdapResultSetMaxSize; Query<DomainBase> query = ofy() .load() .type(DomainBase.class) .filter("fullyQualifiedDomainName <", partialStringQuery.getNextInitialString()) .filter("fullyQualifiedDomainName >=", partialStringQuery.getInitialString()); if (cursorString.isPresent()) { query = query.filter("fullyQualifiedDomainName >", cursorString.get()); } if (partialStringQuery.getSuffix() != null) { query = query.filter("tld", partialStringQuery.getSuffix()); } query = query.limit(querySizeLimit); // Always check for visibility, because we couldn't look at the deletionTime in the query. return makeSearchResults(getMatchingResources(query, true, querySizeLimit)); }
Example #25
Source File: RdapSearchActionBase.java From nomulus with Apache License 2.0 | 5 votes |
/** * Handles prefix searches in cases where, if we need to filter out deleted items, there are no * pending deletes. * * <p>In such cases, it is sufficient to check whether {@code deletionTime} is equal to * {@code END_OF_TIME}, because any other value means it has already been deleted. This allows us * to use an equality query for the deletion time. * * @param clazz the type of resource to be queried * @param filterField the database field of interest * @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; the * initial string should not be empty, and any search suffix will be ignored, so the caller * must filter the results if a suffix is specified * @param cursorString if a cursor is present, this parameter should specify the cursor string, to * skip any results up to and including the string; empty() if there is no cursor * @param deletedItemHandling whether to include or exclude deleted items * @param resultSetMaxSize the maximum number of results to return * @return the query object */ static <T extends EppResource> Query<T> queryItems( Class<T> clazz, String filterField, RdapSearchPattern partialStringQuery, Optional<String> cursorString, DeletedItemHandling deletedItemHandling, int resultSetMaxSize) { if (partialStringQuery.getInitialString().length() < RdapSearchPattern.MIN_INITIAL_STRING_LENGTH) { throw new UnprocessableEntityException( String.format( "Initial search string must be at least %d characters", RdapSearchPattern.MIN_INITIAL_STRING_LENGTH)); } Query<T> query = ofy().load().type(clazz); if (!partialStringQuery.getHasWildcard()) { query = query.filter(filterField, partialStringQuery.getInitialString()); } else { // Ignore the suffix; the caller will need to filter on the suffix, if any. query = query .filter(filterField + " >=", partialStringQuery.getInitialString()) .filter(filterField + " <", partialStringQuery.getNextInitialString()); } if (cursorString.isPresent()) { query = query.filter(filterField + " >", cursorString.get()); } return setOtherQueryAttributes(query, deletedItemHandling, resultSetMaxSize); }
Example #26
Source File: ConferenceQueryForm.java From ud859 with GNU General Public License v3.0 | 5 votes |
/** * Returns an Objectify Query object for the specified filters. * * @return an Objectify Query. */ @ApiResourceProperty(ignored = AnnotationBoolean.TRUE) public Query<Conference> getQuery() { // First check the feasibility of inequality filters. checkFilters(); Query<Conference> query = ofy().load().type(Conference.class); if (inequalityFilter == null) { // Order by name. query = query.order("name"); } else { // If we have any inequality filters, order by the field first. query = query.order(inequalityFilter.field.getFieldName()); query = query.order("name"); } for (Filter filter : this.filters) { // Applies filters in order. if (filter.field.fieldType == FieldType.STRING) { query = query.filter(String.format("%s %s", filter.field.getFieldName(), filter.operator.getQueryOperator()), filter.value); } else if (filter.field.fieldType == FieldType.INTEGER) { query = query.filter(String.format("%s %s", filter.field.getFieldName(), filter.operator.getQueryOperator()), Integer.parseInt(filter.value)); } } LOG.info(query.toString()); return query; }
Example #27
Source File: RdapDomainSearchAction.java From nomulus with Apache License 2.0 | 5 votes |
/** * Assembles a list of {@link HostResource} keys by name. * * <p>Nameserver query strings with wildcards are allowed to have a suffix after the wildcard, * which must be a domain. If the domain is not specified, or is not an existing domain in one of * our TLDs, the wildcard must be preceded by at least two characters (e.g. "ns*"), to avoid * queries for all nameservers in the system. If the suffix specifies an existing domain, the * initial string is not required (e.g. "*.example.tld" is valid), because we can look up the * domain and just list all of its subordinate hosts. */ private Iterable<VKey<HostResource>> getNameserverRefsByLdhName( final RdapSearchPattern partialStringQuery) { // Handle queries without a wildcard. if (!partialStringQuery.getHasWildcard()) { return getNameserverRefsByLdhNameWithoutWildcard(partialStringQuery); } // Handle queries with a wildcard and suffix (specifying a suprerordinate domain). if (partialStringQuery.getSuffix() != null) { return getNameserverRefsByLdhNameWithSuffix(partialStringQuery); } // If there's no suffix, query the host resources. Query the resources themselves, rather than // the foreign key indexes, because then we have an index on fully qualified host name and // deletion time, so we can check the deletion status in the query itself. The initial string // must be present, to avoid querying every host in the system. This restriction is enforced by // {@link queryItems}. // // Only return the first maxNameserversInFirstStage nameservers. This could result in an // incomplete result set if a search asks for something like "ns*", but we need to enforce a // limit in order to avoid arbitrarily long-running queries. Query<HostResource> query = queryItems( HostResource.class, "fullyQualifiedHostName", partialStringQuery, Optional.empty(), DeletedItemHandling.EXCLUDE, maxNameserversInFirstStage); Optional<String> desiredRegistrar = getDesiredRegistrar(); if (desiredRegistrar.isPresent()) { query = query.filter("currentSponsorClientId", desiredRegistrar.get()); } return StreamSupport.stream(query.keys().spliterator(), false) .map(key -> VKey.from(key)) .collect(toImmutableSet()); }
Example #28
Source File: SingleAccountGoogleIdMigrationScript.java From teammates with GNU General Public License v2.0 | 4 votes |
@Override protected Query<Account> getFilterQuery() { return ofy().load().type(Account.class).filterKey(Key.create(Account.class, fromAccountGoogleId)); }
Example #29
Source File: DataMigrationForInstructorFeedbackResponseComments.java From teammates with GNU General Public License v2.0 | 4 votes |
@Override protected Query<FeedbackResponseComment> getFilterQuery() { return ofy().load().type(FeedbackResponseComment.class); }
Example #30
Source File: DataMigrationForSanitizedDataInInstructorAttributes.java From teammates with GNU General Public License v2.0 | 4 votes |
@Override protected Query<Instructor> getFilterQuery() { return ofy().load().type(Instructor.class); }