当前位置: 首页>>代码示例>>Java>>正文


Java FilterOption类代码示例

本文整理汇总了Java中org.apache.olingo.server.api.uri.queryoption.FilterOption的典型用法代码示例。如果您正苦于以下问题:Java FilterOption类的具体用法?Java FilterOption怎么用?Java FilterOption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FilterOption类属于org.apache.olingo.server.api.uri.queryoption包,在下文中一共展示了FilterOption类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyOptionsToEntityCollection

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
private void applyOptionsToEntityCollection(final EntityCollection entitySet,
    final EdmBindingTarget edmBindingTarget,
    final FilterOption filterOption, final OrderByOption orderByOption, final CountOption countOption,
    final SkipOption skipOption, final TopOption topOption, final ExpandOption expandOption,
    final UriInfoResource uriInfo, final Edm edm)
    throws ODataApplicationException {

  FilterHandler.applyFilterSystemQuery(filterOption, entitySet, uriInfo, edm);
  OrderByHandler.applyOrderByOption(orderByOption, entitySet, uriInfo, edm);
  CountHandler.applyCountSystemQueryOption(countOption, entitySet);
  SkipHandler.applySkipSystemQueryHandler(skipOption, entitySet);
  TopHandler.applyTopSystemQueryOption(topOption, entitySet);

  // Apply nested expand system query options to remaining entities
  if (expandOption != null) {
    for (final Entity entity : entitySet.getEntities()) {
      applyExpandOptionToEntity(entity, edmBindingTarget, expandOption, uriInfo, edm);
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:ExpandSystemQueryOptionHandler.java

示例2: applyFilterSystemQuery

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
/**
 * This method applies filter query option to the given entity collection.
 *
 * @param filterOption Filter option
 * @param entitySet    Entity collection
 * @param edmEntitySet Entity set
 * @throws ODataApplicationException
 */
public static void applyFilterSystemQuery(final FilterOption filterOption, final EntityCollection entitySet,
                                          final EdmBindingTarget edmEntitySet) throws ODataApplicationException {
    try {
        final Iterator<Entity> iter = entitySet.getEntities().iterator();
        while (iter.hasNext()) {
            final VisitorOperand operand =
                    filterOption.getExpression().accept(new ExpressionVisitorImpl(iter.next(), edmEntitySet));
            final TypedOperand typedOperand = operand.asTypedOperand();

            if (typedOperand.is(ODataConstants.primitiveBoolean)) {
                if (Boolean.FALSE.equals(typedOperand.getTypedValue(Boolean.class))) {
                    iter.remove();
                }
            } else {
                throw new ODataApplicationException(
                        "Invalid filter expression. Filter expressions must return a value of " +
                        "type Edm.Boolean", HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
            }
        }

    } catch (ExpressionVisitException e) {
        throw new ODataApplicationException("Exception in filter evaluation",
                                            HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
    }
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:34,代码来源:QueryHandler.java

示例3: toQueryBuilder

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
private static QueryBuilder toQueryBuilder(FilterOption filterOption)
    throws ODataApplicationException {

  if (filterOption == null) {
    return QueryBuilders.matchAllQuery();
  }

  try {
    return (QueryBuilder) filterOption.getExpression()
        .accept(new ElasticsearchExpressionVisitor());
  } catch (ExpressionVisitException e) {
    throw new ODataApplicationException(
        "accept failed", HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), null, e);
  }
}
 
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:16,代码来源:EntityRepository.java

示例4: filterClause

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
private SparqlExpressionVisitor filterClause(FilterOption filter, RdfEntityType entityType, String nextTargetKey)
		throws ODataApplicationException, ExpressionVisitException {
	SparqlExpressionVisitor sparqlExpressionVisitor = new SparqlExpressionVisitor(rdfModel, rdfModelToMetadata,
			entityType, nextTargetKey);
	if (filter != null) {
		Expression filterExpression = filter.getExpression();
		final Object visitorResult;
		final String result;
		visitorResult = filterExpression.accept(sparqlExpressionVisitor);
		result = new String((String) visitorResult);
		sparqlExpressionVisitor.setConditionString(result);
	}
	return sparqlExpressionVisitor;
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:15,代码来源:SparqlFilterClausesBuilder.java

示例5: applyFilterSystemQuery

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
public static void applyFilterSystemQuery(final FilterOption filterOption, final EntityCollection entitySet,
    final UriInfoResource uriInfo, final Edm edm) throws ODataApplicationException {

  if (filterOption == null) {
    return;
  }

  try {
    final Iterator<Entity> iter = entitySet.getEntities().iterator();

    while (iter.hasNext()) {
      final VisitorOperand operand = filterOption.getExpression()
          .accept(new ExpressionVisitorImpl(iter.next(), uriInfo, edm));
      final TypedOperand typedOperand = operand.asTypedOperand();

      if (typedOperand.is(primBoolean)) {
        if (Boolean.FALSE.equals(typedOperand.getTypedValue(Boolean.class))) {
          iter.remove();
        }
      } else {
        throw new ODataApplicationException(
            "Invalid filter expression. Filter expressions must return a value of type Edm.Boolean",
            HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
      }
    }

  } catch (ExpressionVisitException e) {
    throw new ODataApplicationException("Exception in filter evaluation",
        HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:32,代码来源:FilterHandler.java

示例6: parse

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
public FilterOption parse(UriTokenizer tokenizer, final EdmType referencedType,
    final Collection<String> crossjoinEntitySetNames, final Map<String, AliasQueryOption> aliases)
    throws UriParserException, UriValidationException {
  final Expression filterExpression = new ExpressionParser(edm, odata)
      .parse(tokenizer, referencedType, crossjoinEntitySetNames, aliases);
  final EdmType type = ExpressionParser.getType(filterExpression);
  if (type == null || type.equals(odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean))) {
    return new FilterOptionImpl().setExpression(filterExpression);
  } else {
    throw new UriParserSemanticException("Filter expressions must be boolean.",
        UriParserSemanticException.MessageKeys.TYPES_NOT_COMPATIBLE,
        "Edm.Boolean", type.getFullQualifiedName().getFullQualifiedNameAsString());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:15,代码来源:FilterParser.java

示例7: parseFilterOption

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
private void parseFilterOption(FilterOption filterOption, final EdmType contextType,
    final List<String> entitySetNames, final Map<String, AliasQueryOption> aliases)
    throws UriParserException, UriValidationException {
  if (filterOption != null) {
    final String optionValue = filterOption.getText();
    UriTokenizer filterTokenizer = new UriTokenizer(optionValue);
    // The referring type could be a primitive type or a structured type.
    ((FilterOptionImpl) filterOption).setExpression(
        new FilterParser(edm, odata).parse(filterTokenizer, contextType, entitySetNames, aliases)
            .getExpression());
    checkOptionEOF(filterTokenizer, filterOption.getName(), optionValue);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:14,代码来源:Parser.java

示例8: applyFilterQueryOption

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
private List<Entity> applyFilterQueryOption(List<Entity> entityList, FilterOption filterOption)
    throws ODataApplicationException {

  if (filterOption != null) {
    try {
      Iterator<Entity> entityIterator = entityList.iterator();

      // Evaluate the expression for each entity
      // If the expression is evaluated to "true", keep the entity otherwise remove it from the entityList
      while (entityIterator.hasNext()) {
        // To evaluate the the expression, create an instance of the Filter Expression Visitor and pass
        // the current entity to the constructor
        Entity currentEntity = entityIterator.next();
        Expression filterExpression = filterOption.getExpression();
        FilterExpressionVisitor expressionVisitor = new FilterExpressionVisitor(currentEntity);

        // Start evaluating the expression
        Object visitorResult = filterExpression.accept(expressionVisitor);

        // The result of the filter expression must be of type Edm.Boolean
        if (visitorResult instanceof Boolean) {
          if (!Boolean.TRUE.equals(visitorResult)) {
            // The expression evaluated to false (or null), so we have to remove the currentEntity from entityList
            entityIterator.remove();
          }
        } else {
          throw new ODataApplicationException("A filter expression must evaulate to type Edm.Boolean",
              HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ENGLISH);
        }
      }

    } catch (ExpressionVisitException e) {
      throw new ODataApplicationException("Exception in filter evaluation",
          HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ENGLISH);
    }
  }
  
  return entityList;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:40,代码来源:DemoEntityCollectionProcessor.java

示例9: appendFilter

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
public void appendFilter(String alias,FilterOption filterOption) throws ODataApplicationException {
	if(filterOption != null) {
		try {
			appendFilter(alias,filterOption.getExpression());
		} catch (ExpressionVisitException e) {
			throw internalError(e);
		}
	}
}
 
开发者ID:jbaliuka,项目名称:sql-analytic,代码行数:10,代码来源:ReadCommand.java

示例10: visit

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
@Override
public void visit(FilterOption info) {
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:4,代码来源:DefaultODataResourceURLHierarchyVisitor.java

示例11: visit

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
@Override
public void visit(FilterOption info) {
	ODataExpressionToSQLVisitor visitor = new ODataExpressionToSQLVisitor(this, this.prepared, getUriInfo());
	this.criteria = (Criteria)visitor.getExpression(info.getExpression());
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:6,代码来源:ODataSQLBuilder.java

示例12: Serialize

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
public static String Serialize(final FilterOption filter)
    throws ExpressionVisitException, ODataApplicationException {

  Expression expression = filter.getExpression();
  return expression.accept(new FilterTreeToText());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:7,代码来源:FilterTreeToText.java

示例13: setFilter

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
public FilterValidator setFilter(final FilterOption filter) {
  this.filter = filter;
  assertNotNull("FilterValidator: no filter found", filter.getExpression());
  setExpression(filter.getExpression());
  return this;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:7,代码来源:FilterValidator.java

示例14: goFilter

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
public FilterValidator goFilter() {
  final FilterOption filter = uriInfo.getFilterOption();
  assertNotNull("no filter found", filter);
  return new FilterValidator().setValidator(this).setFilter(filter);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:6,代码来源:TestUriValidator.java

示例15: appendCommonJsonObjects

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
private void appendCommonJsonObjects(JsonGenerator gen,
    final CountOption countOption, final SkipOption skipOption, final TopOption topOption,
    final FilterOption filterOption, final OrderByOption orderByOption,
    final SelectOption selectOption, final ExpandOption expandOption, final SearchOption searchOption,
    final ApplyOption applyOption)
    throws IOException {
  if (countOption != null) {
    gen.writeBooleanField("isCount", countOption.getValue());
  }

  if (skipOption != null) {
    gen.writeNumberField("skip", skipOption.getValue());
  }

  if (topOption != null) {
    gen.writeNumberField("top", topOption.getValue());
  }

  if (filterOption != null) {
    gen.writeFieldName("filter");
    appendExpressionJson(gen, filterOption.getExpression());
  }

  if (orderByOption != null && !orderByOption.getOrders().isEmpty()) {
    gen.writeFieldName("orderby");
    gen.writeStartObject();
    gen.writeStringField("nodeType", "orderCollection");
    gen.writeFieldName("orders");
    appendOrderByItemsJson(gen, orderByOption.getOrders());
    gen.writeEndObject();
  }

  if (selectOption != null && !selectOption.getSelectItems().isEmpty()) {
    gen.writeFieldName("select");
    appendSelectedPropertiesJson(gen, selectOption.getSelectItems());
  }

  if (expandOption != null && !expandOption.getExpandItems().isEmpty()) {
    gen.writeFieldName("expand");
    appendExpandedPropertiesJson(gen, expandOption.getExpandItems());
  }

  if (searchOption != null) {
    gen.writeFieldName("search");
    appendSearchJson(gen, searchOption.getSearchExpression());
  }

  if (applyOption != null) {
    gen.writeFieldName("apply");
    appendApplyItemsJson(gen, applyOption.getApplyItems());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:53,代码来源:DebugTabUri.java


注:本文中的org.apache.olingo.server.api.uri.queryoption.FilterOption类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。