/** * Add the given field name to the {@code QuerySpecification#fieldTerms} */ public Builder addSelectTerm(String selectFieldName) { QueryTerm fieldTerm = new QueryTerm(); fieldTerm.propertyName = selectFieldName; fieldTerm.propertyType = TypeName.STRING; if (this.querySpec.selectTerms == null) { this.querySpec.selectTerms = new ArrayList<>(); } this.querySpec.selectTerms.add(fieldTerm); return this; }
/** * Add the given link field name to the {@code QuerySpecification#linkTerms} */ public Builder addLinkTerm(String linkFieldName) { QueryTerm linkTerm = new QueryTerm(); linkTerm.propertyName = linkFieldName; linkTerm.propertyType = TypeName.STRING; if (this.querySpec.linkTerms == null) { this.querySpec.linkTerms = new ArrayList<>(); } this.querySpec.linkTerms.add(linkTerm); return this; }
private Builder order(String fieldName, TypeName fieldType, SortOrder sortOrder) { QueryTerm sortTerm = new QueryTerm(); sortTerm.propertyName = fieldName; sortTerm.propertyType = fieldType; if (this.querySpec.sortTerm == null) { this.querySpec.sortTerm = sortTerm; this.querySpec.sortOrder = sortOrder; } else { sortTerm.sortOrder = sortOrder; if (this.querySpec.additionalSortTerms == null) { this.querySpec.additionalSortTerms = new ArrayList<>(); } this.querySpec.additionalSortTerms.add(sortTerm); } addOption(QueryOption.SORT); return this; }
patchQueryTargetServiceLinksWithExampleLinks(targetServiceURIs); task.querySpec.linkTerms = new ArrayList<>(); QueryTerm linkTerm = new QueryTerm(); linkTerm.propertyName = QueryValidationServiceState.FIELD_NAME_SERVICE_LINK; linkTerm.propertyType = TypeName.STRING;
queryTask.querySpec.options.add(QueryOption.SORT); queryTask.querySpec.sortOrder = QuerySpecification.SortOrder.ASC; queryTask.querySpec.sortTerm = new QueryTask.QueryTerm(); queryTask.querySpec.sortTerm.propertyType = ServiceDocumentDescription.TypeName.STRING; queryTask.querySpec.sortTerm.propertyName = ServiceDocument.FIELD_NAME_SELF_LINK;
List<QueryTerm> queryTerms = new ArrayList<>(selectFields.size()); for (String field : selectFields) { QueryTerm fieldTerm = new QueryTerm(); fieldTerm.propertyName = field; fieldTerm.propertyType = TypeName.STRING; task.querySpec.sortOrder = orderBy.order == ODataOrder.ASC ? SortOrder.ASC : SortOrder.DESC; task.querySpec.sortTerm = new QueryTerm();
patchQueryTargetServiceLinksWithExampleLinks(targetServiceURIs); task.querySpec.linkTerms = new ArrayList<>(); QueryTerm linkTerm = new QueryTerm(); linkTerm.propertyName = QueryValidationServiceState.FIELD_NAME_SERVICE_LINK; linkTerm.propertyType = TypeName.STRING;
querySpec.sortTerm = new QueryTask.QueryTerm(); querySpec.sortTerm.propertyName = "documentVersion"; querySpec.sortTerm.propertyType = ServiceDocumentDescription.TypeName.LONG;
querySpec.sortTerm = new QueryTask.QueryTerm(); querySpec.sortTerm.propertyName = "documentVersion"; querySpec.sortTerm.propertyType = ServiceDocumentDescription.TypeName.LONG;
private List<RequestStatus> getRequestHistory() throws Throwable { String selfLink = UriUtils.buildUriPath(RequestStatusFactoryService.SELF_LINK, requestId); QueryTask historyQuery = QueryUtil.buildPropertyQuery(RequestStatus.class, ServiceDocument.FIELD_NAME_SELF_LINK, selfLink); historyQuery.querySpec.options = EnumSet.of(QueryOption.INCLUDE_ALL_VERSIONS, QueryOption.EXPAND_CONTENT, QueryOption.SORT); historyQuery.querySpec.sortTerm = new QueryTerm(); historyQuery.querySpec.sortTerm.propertyName = ServiceDocument.FIELD_NAME_VERSION; historyQuery.querySpec.sortTerm.propertyType = TypeName.LONG; historyQuery.querySpec.sortOrder = SortOrder.ASC; List<RequestStatus> statusHistory = new ArrayList<>(); host.testStart(1); new ServiceDocumentQuery<RequestStatus>(host, RequestStatus.class).query(historyQuery, (r) -> { if (r.hasException()) { host.failIteration(r.getException()); } else if (r.hasResult()) { statusHistory.add(r.getResult()); } else { host.completeIteration(); } }); host.testWait(); return statusHistory; }
private void verifyOnlySupportSortOnSelfLinkInBroadcast(VerificationHost targetHost, boolean isBroadcast) throws Throwable { QuerySpecification q = new QuerySpecification(); Query kindClause = new Query(); kindClause.setTermPropertyName(ServiceDocument.FIELD_NAME_KIND) .setTermMatchValue(Utils.buildKind(ExampleServiceState.class)); q.query = kindClause; q.options = EnumSet.of(QueryOption.EXPAND_CONTENT, QueryOption.SORT); q.options.add(isBroadcast ? QueryOption.BROADCAST : QueryOption.READ_AFTER_WRITE_CONSISTENCY); q.sortTerm = new QueryTask.QueryTerm(); q.sortTerm.propertyType = TypeName.STRING; q.sortTerm.propertyName = ExampleServiceState.FIELD_NAME_NAME; QueryTask task = QueryTask.create(q); targetHost.testStart(1); URI factoryUri = UriUtils.buildUri(targetHost, ServiceUriPaths.CORE_QUERY_TASKS); Operation startPost = Operation .createPost(factoryUri) .setBody(task) .setCompletion((o, e) -> { validateBroadcastQueryPostFailure(targetHost, o, e); }); targetHost.send(startPost); targetHost.testWait(); }
private void verifyOnlySupportSortOnSelfLinkInBroadcast(VerificationHost targetHost, boolean isBroadcast) throws Throwable { QuerySpecification q = new QuerySpecification(); Query kindClause = new Query(); kindClause.setTermPropertyName(ServiceDocument.FIELD_NAME_KIND) .setTermMatchValue(Utils.buildKind(ExampleServiceState.class)); q.query = kindClause; q.options = EnumSet.of(QueryOption.EXPAND_CONTENT, QueryOption.SORT); q.options.add(isBroadcast ? QueryOption.BROADCAST : QueryOption.READ_AFTER_WRITE_CONSISTENCY); q.sortTerm = new QueryTask.QueryTerm(); q.sortTerm.propertyType = TypeName.STRING; q.sortTerm.propertyName = ExampleServiceState.FIELD_NAME_NAME; QueryTask task = QueryTask.create(q); targetHost.testStart(1); URI factoryUri = UriUtils.buildUri(targetHost, ServiceUriPaths.CORE_QUERY_TASKS); Operation startPost = Operation .createPost(factoryUri) .setBody(task) .setCompletion((o, e) -> { validateBroadcastQueryPostFailure(targetHost, o, e); }); targetHost.send(startPost); targetHost.testWait(); }
/** * Set the term. * * This is only appropriate if you need to query on exactly a single clause and * it is not compatible with the using multiple boolean clauses, as addFieldClause does. * * This assumes you are matching with MatchType.TERM * * @param fieldName the top level field name * @param fieldValue the field value to match * @return */ public Builder setTerm(String fieldName, String fieldValue, MatchType matchType) { this.query.term = new QueryTerm(); this.query.term.propertyName = fieldName; this.query.term.matchValue = fieldValue; this.query.term.matchType = matchType; return this; }
/** * Order group results in specified order by the given {@code fieldName}. * This method implicitly calls {@link #setGroupByTerm(String, TypeName)} * @param fieldName the field name to order results by. * @param fieldType the field type. * @return a reference to this object. */ public Builder groupOrder(String fieldName, TypeName fieldType, SortOrder sortOrder) { QueryTerm sortTerm = new QueryTerm(); setGroupByTerm(fieldName, fieldType); sortTerm.propertyName = fieldName; sortTerm.propertyType = fieldType; this.querySpec.groupSortTerm = sortTerm; this.querySpec.groupSortOrder = sortOrder; return this; }
public static Condition forTag(String key, String value, Enforcement enforcement, Occurance occurrence) { Condition condition = new Condition(); condition.type = Type.TAG; condition.enforcement = enforcement; condition.occurrence = occurrence; QueryTerm term = new QueryTerm(); term.propertyName = key + ((value != null && !value.isEmpty()) ? (":" + value) : ""); term.matchType = MatchType.TERM; condition.expression = term; return condition; } }
/** * Sets the {@code QuerySpecification#groupByTerm} */ public Builder setGroupByTerm(String fieldName, TypeName fieldType) { QueryTerm term = new QueryTerm(); term.propertyName = fieldName; term.propertyType = fieldType; this.querySpec.groupByTerm = term; return this; }
private void allocateTerm() { if (this.term != null) { return; } this.term = new QueryTerm(); }
public static Condition forTag(String key, String value, Enforcement enforcement, Occurance occurrence) { Condition condition = new Condition(); condition.type = Type.TAG; condition.enforcement = enforcement; condition.occurrence = occurrence; QueryTerm term = new QueryTerm(); term.propertyName = key + ((value != null && !value.isEmpty()) ? (":" + value) : ""); term.matchType = MatchType.TERM; condition.expression = term; return condition; } }