• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FilterOption类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: parseTrafo

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
private ApplyItem parseTrafo(EdmStructuredType referencedType) throws UriParserException, UriValidationException {
  if (tokenizer.next(TokenKind.AggregateTrafo)) {
    return parseAggregateTrafo(referencedType);

  } else if (tokenizer.next(TokenKind.IDENTITY)) {
    return new IdentityImpl();

  } else if (tokenizer.next(TokenKind.ComputeTrafo)) {
    return parseComputeTrafo(referencedType);

  } else if (tokenizer.next(TokenKind.ConcatMethod)) {
    return parseConcatTrafo(referencedType);

  } else if (tokenizer.next(TokenKind.ExpandTrafo)) {
    return new ExpandImpl().setExpandOption(parseExpandTrafo(referencedType));

  } else if (tokenizer.next(TokenKind.FilterTrafo)) {
    final FilterOption filterOption = new FilterParser(edm, odata)
        .parse(tokenizer, referencedType, crossjoinEntitySetNames, aliases);
    ParserHelper.requireNext(tokenizer, TokenKind.CLOSE);
    return new FilterImpl().setFilterOption(filterOption);

  } else if (tokenizer.next(TokenKind.GroupByTrafo)) {
    return parseGroupByTrafo(referencedType);

  } else if (tokenizer.next(TokenKind.SearchTrafo)) {
    final SearchOption searchOption = new SearchParser().parse(tokenizer);
    ParserHelper.requireNext(tokenizer, TokenKind.CLOSE);
    return new SearchImpl().setSearchOption(searchOption);

  } else if (tokenizer.next(TokenKind.QualifiedName)) {
    return parseCustomFunction(new FullQualifiedName(tokenizer.getText()), referencedType);

  } else {
    final TokenKind kind = ParserHelper.next(tokenizer,
        TokenKind.BottomCountTrafo, TokenKind.BottomPercentTrafo, TokenKind.BottomSumTrafo,
        TokenKind.TopCountTrafo, TokenKind.TopPercentTrafo, TokenKind.TopSumTrafo);
    if (kind == null) {
      throw new UriParserSyntaxException("Invalid apply expression syntax.",
          UriParserSyntaxException.MessageKeys.SYNTAX);
    } else {
      return parseBottomTop(kind, referencedType);
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:46,代码来源:ApplyParser.java


示例17: getFilterOption

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
@Override
public FilterOption getFilterOption() {
  return filterOption;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:5,代码来源:FilterImpl.java


示例18: setFilterOption

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
public FilterImpl setFilterOption(final FilterOption filterOption) {
  this.filterOption = filterOption;
  return this;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:5,代码来源:FilterImpl.java


示例19: getFilterOption

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
@Override
public FilterOption getFilterOption() {
  return (FilterOption) systemQueryOptions.get(SystemQueryOptionKind.FILTER);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:5,代码来源:UriInfoImpl.java


示例20: readEntityCollection

import org.apache.olingo.server.api.uri.queryoption.FilterOption; //导入依赖的package包/类
public void readEntityCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, 
    ContentType responseFormat) throws ODataApplicationException, SerializerException {

	// 1st: retrieve the requested EntitySet from the uriInfo (representation of the parsed URI)
	List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
	// in our example, the first segment is the EntitySet
	UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0); 
	EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();

	// 2nd: fetch the data from backend for this requested EntitySetName and deliver as EntitySet
	EntityCollection entityCollection = storage.readEntitySetData(edmEntitySet);
	
	// 3rd: Check if filter system query option is provided and apply the expression if necessary
	FilterOption filterOption = uriInfo.getFilterOption();
	if(filterOption != null) {
		// Apply $filter system query option
		try {
		      List<Entity> entityList = entityCollection.getEntities();
		      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);
		    }
	}
	
	// 4th: create a serializer based on the requested format (json)
	ODataSerializer serializer = odata.createSerializer(responseFormat);

	// and serialize the content: transform from the EntitySet object to InputStream
	EdmEntityType edmEntityType = edmEntitySet.getEntityType();
	ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).build();

	final String id = request.getRawBaseUri() + "/" + edmEntitySet.getName();
	EntityCollectionSerializerOptions opts = EntityCollectionSerializerOptions.with()
			.contextURL(contextUrl).id(id).build();
	SerializerResult serializerResult = serializer.entityCollection(serviceMetadata, edmEntityType, entityCollection,
			opts);

	InputStream serializedContent = serializerResult.getContent();

	// 5th: configure the response object: set the body, headers and status code
	response.setContent(serializedContent);
	response.setStatusCode(HttpStatusCode.OK.getStatusCode());
	response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:71,代码来源:DemoEntityCollectionProcessor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SetPolicy类代码示例发布时间:2022-05-23
下一篇:
Java ParticleSystem类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap