org.apache.olingo.odata2.api.uri.expression.MemberExpression Java Examples

The following examples show how to use org.apache.olingo.odata2.api.uri.expression.MemberExpression. 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: SQLVisitor.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Object visitMember(MemberExpression member_expression, Object path, Object property)
{
   /* The property shall be handled inside visitProperty method in
    * ODataSQLVisitor implementation */
   return property;
}
 
Example #2
Source File: DebugInfoUri.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private void appendExpression(final CommonExpression expression, final Writer writer) throws IOException {
  final ExpressionKind kind = expression.getKind();
  writer.append("<span class=\"kind\">")
      .append(kind.toString())
      .append("</span> <span class=\"literal\">")
      .append(kind == ExpressionKind.MEMBER ? ((MemberExpression) expression).getProperty().getUriLiteral() :
          expression.getUriLiteral())
      .append("</span>, type <span class=\"type\">")
      .append(expression.getEdmType().toString())
      .append("</span>");
  if (kind == ExpressionKind.UNARY) {
    writer.append("<ul class=\"expr\"><li>");
    appendExpression(((UnaryExpression) expression).getOperand(), writer);
    writer.append("</li></ul>");
  } else if (kind == ExpressionKind.BINARY) {
    writer.append("<ol class=\"expr\"><li>");
    appendExpression(((BinaryExpression) expression).getLeftOperand(), writer);
    writer.append("</li><li>");
    appendExpression(((BinaryExpression) expression).getRightOperand(), writer);
    writer.append("</li></ol>");
  } else if (kind == ExpressionKind.METHOD) {
    final MethodExpression methodExpression = (MethodExpression) expression;
    if (methodExpression.getParameterCount() > 0) {
      writer.append("<ol class=\"expr\">");
      for (final CommonExpression parameter : methodExpression.getParameters()) {
        writer.append("<li>");
        appendExpression(parameter, writer);
        writer.append("</li>");
      }
      writer.append("</ol>");
    }
  } else if (kind == ExpressionKind.MEMBER) {
    writer.append("<ul class=\"expr\"><li>");
    appendExpression(((MemberExpression) expression).getPath(), writer);
    writer.append("</li></ul>");
  }
}
 
Example #3
Source File: JsonVisitor.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public Object visitMember(final MemberExpression memberExpression, final Object path, final Object property) {
  try {
    StringWriter writer = new StringWriter();
    JsonStreamWriter jsonStreamWriter = new JsonStreamWriter(writer);
    jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", memberExpression.getKind().toString()).separator()
        .namedStringValueRaw("type", getType(memberExpression)).separator().name("source").unquotedValue(
            path.toString()).separator().name("path").unquotedValue(property.toString()).endObject();
    writer.flush();
    return writer.toString();
  } catch (final IOException e) {
    return null;
  }
}
 
Example #4
Source File: FunctionalVisitor.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Object visitMember(MemberExpression me, Object path, Object property)
{
   // Not used
   return property;
}
 
Example #5
Source File: JPAQueryBuilderTest.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
private UriInfo mockURIInfoForEntitySet(EdmMapping mapping, String methodName) throws EdmException {
  
  UriInfo uriInfo = EasyMock.createMock(UriInfo.class);
  List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>();
  EasyMock.expect(uriInfo.getNavigationSegments()).andStubReturn(navSegments);
  EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
  EasyMock.expect(edmEntityType.getMapping()).andStubReturn(mapping);
  EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
  EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
  EasyMock.expect(uriInfo.getTargetEntitySet()).andStubReturn(edmEntitySet);
  EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
  EasyMock.expect(edmProperty.getMapping()).andStubReturn((EdmMapping)mockEdmMappingForProperty());
  
  EdmProperty edmProperty1 = EasyMock.createMock(EdmProperty.class);
  EasyMock.expect(edmProperty1.getMapping()).andStubReturn((EdmMapping)mockEdmMappingForProperty1());
  
  EdmNavigationProperty navEdmProperty = EasyMock.createMock(EdmNavigationProperty.class);
  EasyMock.expect(navEdmProperty.getMapping()).andStubReturn((EdmMapping)mockNavEdmMappingForProperty());
  
  OrderByExpression orderbyExpression = EasyMock.createMock(OrderByExpression.class);
  List<OrderExpression> orders = new ArrayList<OrderExpression>();
  EasyMock.expect(orderbyExpression.getOrders()).andStubReturn(orders);
  EasyMock.expect(uriInfo.getOrderBy()).andStubReturn(orderbyExpression);
  FilterExpression filterExpression = EasyMock.createMock(FilterExpression.class);
  MethodExpression commonExpression = EasyMock.createMock(MethodExpression.class);
  EasyMock.expect(commonExpression.getKind()).andStubReturn(ExpressionKind.METHOD);
  PropertyExpression propExp = EasyMock.createMock(PropertyExpression.class);
  LiteralExpression literalExp = EasyMock.createMock(LiteralExpression.class);
  MemberExpression memberExp = EasyMock.createMock(MemberExpression.class);
  List<CommonExpression> parameterList = new ArrayList<CommonExpression>();
  
  PropertyExpression navPropExp = EasyMock.createMock(PropertyExpression.class);
  if ("substringof".equals(methodName)) {
    EasyMock.expect(commonExpression.getMethod()).andStubReturn(MethodOperator.SUBSTRINGOF);
    EasyMock.expect(commonExpression.getParameterCount()).andStubReturn(2);
    EasyMock.expect(literalExp.getUriLiteral()).andStubReturn("'a.b.c'");
    EasyMock.expect(literalExp.getKind()).andStubReturn(ExpressionKind.LITERAL);
    EasyMock.expect(literalExp.getEdmType()).andStubReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance());
    parameterList.add(literalExp);
    EasyMock.expect(propExp.getEdmProperty()).andStubReturn(edmProperty);
    EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY);
    parameterList.add(propExp);
  } else if ("startsWith".equals(methodName)) {
    EasyMock.expect(commonExpression.getMethod()).andStubReturn(MethodOperator.STARTSWITH);
    EasyMock.expect(commonExpression.getParameterCount()).andStubReturn(2);
    EasyMock.expect(propExp.getEdmProperty()).andStubReturn(edmProperty);
    EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY);
    parameterList.add(propExp);
    EasyMock.expect(literalExp.getUriLiteral()).andStubReturn("'a.b.c'");
    EasyMock.expect(literalExp.getKind()).andStubReturn(ExpressionKind.LITERAL);
    EasyMock.expect(literalExp.getEdmType()).andStubReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance());
    parameterList.add(literalExp);
  } else if ("endsWith".equals(methodName)) {
    EasyMock.expect(commonExpression.getMethod()).andStubReturn(MethodOperator.ENDSWITH);
    EasyMock.expect(commonExpression.getParameterCount()).andStubReturn(2);
    EasyMock.expect(propExp.getEdmProperty()).andStubReturn(edmProperty);
    EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY);
    parameterList.add(propExp);
    EasyMock.expect(literalExp.getUriLiteral()).andStubReturn("'a.b.c'");
    EasyMock.expect(literalExp.getKind()).andStubReturn(ExpressionKind.LITERAL);
    EasyMock.expect(literalExp.getEdmType()).andStubReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance());
    parameterList.add(literalExp);
  } else if ("substringof_1".equals(methodName)) {
    EasyMock.expect(commonExpression.getMethod()).andStubReturn(MethodOperator.SUBSTRINGOF);
    EasyMock.expect(commonExpression.getParameterCount()).andStubReturn(2);
    EasyMock.expect(literalExp.getUriLiteral()).andStubReturn("'a.b.c'");
    EasyMock.expect(literalExp.getKind()).andStubReturn(ExpressionKind.LITERAL);
    EasyMock.expect(literalExp.getEdmType()).andStubReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance());
    parameterList.add(literalExp);
    EasyMock.expect(memberExp.getKind()).andStubReturn(ExpressionKind.MEMBER);
    EasyMock.expect(memberExp.getProperty()).andStubReturn(propExp);
    
    EasyMock.expect(memberExp.getPath()).andStubReturn(navPropExp);
    EasyMock.expect(navPropExp.getKind()).andStubReturn(ExpressionKind.PROPERTY);
    EasyMock.expect(navPropExp.getEdmProperty()).andStubReturn(navEdmProperty);
    EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY);
    EasyMock.expect(propExp.getEdmProperty()).andStubReturn(edmProperty1);
    
    parameterList.add(propExp);
  }
  
  EasyMock.expect(commonExpression.getParameters()).andStubReturn(parameterList);
  
  EasyMock.expect(filterExpression.getExpression()).andStubReturn(commonExpression);
  EasyMock.expect(filterExpression.getKind()).andStubReturn(ExpressionKind.FILTER);
  EasyMock.expect(filterExpression.getExpressionString()).andStubReturn("substringof('a.b.c',Id)");
  EasyMock.expect(uriInfo.getFilter()).andStubReturn(filterExpression);
  EasyMock.replay(edmEntityType, edmEntitySet, orderbyExpression, filterExpression, 
      commonExpression, literalExp, propExp, uriInfo, edmProperty, memberExp,
      edmProperty1, navEdmProperty);
  return uriInfo;

}
 
Example #6
Source File: VisitorTool.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public Object visitMember(final MemberExpression memberExpression, final Object source, final Object path) {
  return "{" + source.toString() + "/" + path.toString() + "}";
}
 
Example #7
Source File: ODataParser.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Override
public Object visitMember(MemberExpression memberExpression, Object path, Object property) {
    throw new SearchParseException("Unsupported operation visitMember: "
        + memberExpression + "," + path + "," + property);
}