public VisitorOperand visitMember()

in lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java [211:308]


  public VisitorOperand visitMember(final Member member) throws ExpressionVisitException,
      ODataApplicationException {

    final List<UriResource> uriResourceParts = member.getResourcePath().getUriResourceParts();

    // UriResourceParts contains at least one UriResource.
    final UriResource initialPart = uriResourceParts.get(0);
    if (initialPart instanceof UriResourceProperty) {
      EdmProperty currentEdmProperty = ((UriResourceProperty) initialPart).getProperty();
      Property currentProperty = entity.getProperty(currentEdmProperty.getName());
      for (int i = 1; i < uriResourceParts.size(); i++) {
        if (currentProperty.isComplex()) {
          if (uriResourceParts.get(i) instanceof UriResourceLambdaAny) {
            UriResourceLambdaAny any = ((UriResourceLambdaAny) uriResourceParts.get(i));
            if (any.getExpression() instanceof Binary) {
              Binary expression = (Binary) any.getExpression();
              if (currentProperty.isCollection()) {
                final List<ComplexValue> complex = (List<ComplexValue>) currentProperty.asCollection();
                Iterator<ComplexValue> itr = complex.iterator();
                while (itr.hasNext()) {
                  final ComplexValue value = itr.next();
                  VisitorOperand operand = expression.accept(new ExpressionVisitorImpl(value, uriInfo, edm));
                  final TypedOperand typedOperand = operand.asTypedOperand();
                  if (typedOperand.is(OData.newInstance().createPrimitiveTypeInstance
                      (EdmPrimitiveTypeKind.Boolean))) {
                    if (Boolean.TRUE.equals(typedOperand.getTypedValue(Boolean.class))) {
                      return operand;
                    }
                  }
                }
              } 
            }
          } else {
            currentEdmProperty = ((UriResourceProperty) uriResourceParts.get(i)).getProperty();
            final List<Property> complex = currentProperty.asComplex().getValue();
            for (final Property innerProperty : complex) {
              if (innerProperty.getName().equals(currentEdmProperty.getName())) {
                currentProperty = innerProperty;
                break;
              }
            }
          }
        }
      }
      return new TypedOperand(currentProperty.getValue(), currentEdmProperty.getType(), currentEdmProperty);
    } else if (initialPart instanceof UriResourceFunction) {
      final EdmFunction function = ((UriResourceFunction) initialPart).getFunction();
      if (uriResourceParts.size() > 1) {
        return throwNotImplemented();
      }
      final EdmType type = function.getReturnType().getType();
      final DataProvider dataProvider = new DataProvider(OData.newInstance(), edm);
      final List<UriParameter> parameters = ((UriResourceFunction) initialPart).getParameters();
      return new TypedOperand(
        type.getKind() == EdmTypeKind.ENTITY ?
            function.getReturnType().isCollection() ?
                dataProvider.readFunctionEntityCollection(function, parameters, uriInfo) :
                dataProvider.readFunctionEntity(function, parameters, uriInfo) :
            dataProvider.readFunctionPrimitiveComplex(function, parameters, uriInfo),
        type);

    } else if (initialPart instanceof UriResourceLambdaVariable) {
      EdmComplexType complexType = (EdmComplexType) ((UriResourceLambdaVarImpl)initialPart).getTypeFilter();
      EdmProperty currentEdmProperty = ((UriResourceProperty) uriResourceParts.get(1)).getProperty();
      Property currentProperty = null;
      List<Property> properties = complexValue.getValue();
      for (final Property innerProperty : properties) {
        if (innerProperty.getName().equals(currentEdmProperty.getName()) && 
            complexType.getProperty(innerProperty.getName()) != null) {
          currentProperty = innerProperty;
          break;
        }
      }
      return new TypedOperand(currentProperty == null ? null : currentProperty.getValue(), 
          currentEdmProperty.getType(), currentEdmProperty);
    } else if (initialPart instanceof UriResourceNavigation) {
      EdmNavigationProperty currentEdmNavProperty = ((UriResourceNavigation) initialPart).getProperty();
      EdmProperty currentEdmProperty = null;
      Link link = entity.getNavigationLink(currentEdmNavProperty.getName());
      Entity inlineEntity = link != null ? link.getInlineEntity() : null;
      Property currentProperty = null;
      for (int i = 1; i < uriResourceParts.size(); i++) {
        currentEdmProperty = ((UriResourceProperty) uriResourceParts.get(i)).getProperty();
        if (null != inlineEntity) {
          for (Property property : inlineEntity.getProperties()) {
            if (property.getName().equalsIgnoreCase(currentEdmProperty.getName())) {
              currentProperty = property;
              break;
            } 
          }
        }
      }
      return new TypedOperand(currentProperty != null ? currentProperty.getValue() : null, 
          currentEdmProperty.getType(), currentEdmProperty);
    } else {
      return throwNotImplemented();
    }
  }