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

The following examples show how to use org.apache.olingo.odata2.api.uri.expression.PropertyExpression. 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: FilterParserExceptionImpl.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
public static ExpressionParserException createPROPERTY_NAME_NOT_FOUND_IN_TYPE(final EdmStructuralType parentType,
    final PropertyExpression property, final Token token, final String expression)
    throws ExpressionParserInternalError {
  MessageReference msgRef = ExpressionParserException.PROPERTY_NAME_NOT_FOUND_IN_TYPE.create();

  try {
    msgRef.addContent(property.getUriLiteral());
    msgRef.addContent(parentType.getNamespace() + "." + parentType.getName());
    msgRef.addContent(token.getPosition() + 1);
    msgRef.addContent(expression);
  } catch (EdmException e) {
    throw ExpressionParserInternalError.createERROR_ACCESSING_EDM(e);
  }

  return new ExpressionParserException(msgRef);
}
 
Example #2
Source File: CollectionSQLVisitor.java    From DataHubSystem with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Object visitProperty (PropertyExpression property_expression,
   String uri_literal, EdmTyped edm_property)
{
   if (edm_property == null)
      throw new IllegalArgumentException ("Property not found: " +
            uri_literal);

   if (uri_literal.equals (CollectionEntitySet.NAME))
      return new Member("name");

   if (uri_literal.equals (CollectionEntitySet.DESCRIPTION))
      return new Member ("description");

   throw new IllegalArgumentException ("Property not supported: " +
         uri_literal);
}
 
Example #3
Source File: ODataExpressionParser.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private static String getPropertyName(final CommonExpression whereExpression) throws EdmException,
    ODataJPARuntimeException {
  EdmTyped edmProperty = ((PropertyExpression) whereExpression).getEdmProperty();
  EdmMapping mapping;
  if (edmProperty instanceof EdmNavigationProperty) {
    EdmNavigationProperty edmNavigationProperty = (EdmNavigationProperty) edmProperty;
    mapping = edmNavigationProperty.getMapping();
  } else if(edmProperty instanceof EdmProperty) {
    EdmProperty property = (EdmProperty) edmProperty;
    mapping = property.getMapping();
  } else {
    throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, null);
  }

  return mapping != null ? mapping.getInternalName() : edmProperty.getName();
}
 
Example #4
Source File: JPQLSelectContextImplTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private PropertyExpression getPropertyExpressionMockedObj(final ExpressionKind expKind, final String propertyName) {
  PropertyExpression leftOperandPropertyExpresion = EasyMock.createMock(PropertyExpression.class);
  EasyMock.expect(leftOperandPropertyExpresion.getKind()).andReturn(ExpressionKind.PROPERTY);
  EasyMock.expect(leftOperandPropertyExpresion.getPropertyName()).andReturn(propertyName);
  EdmProperty edmtTyped = EasyMock.createMock(EdmProperty.class);
  EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
  EasyMock.expect(mapping.getInternalName()).andStubReturn("field");
  try {
    EasyMock.expect(edmtTyped.getMapping()).andStubReturn(mapping);
  } catch (EdmException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
  EasyMock.expect(leftOperandPropertyExpresion.getEdmProperty()).andReturn(edmtTyped);
  EasyMock.replay(mapping, edmtTyped, leftOperandPropertyExpresion);
  return leftOperandPropertyExpresion;
}
 
Example #5
Source File: JsonVisitor.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public Object visitProperty(final PropertyExpression propertyExpression, final String uriLiteral,
    final EdmTyped edmProperty) {
  try {
    StringWriter writer = new StringWriter();
    JsonStreamWriter jsonStreamWriter = new JsonStreamWriter(writer);
    jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", propertyExpression.getKind().toString())
        .separator().namedStringValue("name", uriLiteral).separator().namedStringValueRaw("type",
            getType(propertyExpression)).endObject();
    writer.flush();
    return writer.toString();
  } catch (final IOException e) {
    return null;
  }
}
 
Example #6
Source File: ODataExpressionParser.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private static EdmMapping getEdmMapping(BinaryExpression binaryExpression) throws EdmException {
  if(binaryExpression!=null && binaryExpression.getLeftOperand() instanceof PropertyExpression){
    PropertyExpression left = (PropertyExpression)binaryExpression.getLeftOperand();
    if(left != null && left.getEdmProperty() instanceof EdmElement){
      EdmElement property = (EdmElement)left.getEdmProperty();
      return property.getMapping();
    }
  }
  return null;
}
 
Example #7
Source File: ODataParser.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Override
public Object visitProperty(PropertyExpression propertyExpression, String uriLiteral, EdmTyped edmProperty) {
    String setter = getActualSetterName(uriLiteral);
    final TypeInfo typeInfo = ODataParser.this.getTypeInfo(setter, null);
    return new TypedProperty(typeInfo, setter);
}
 
Example #8
Source File: SQLVisitor.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public abstract Object visitProperty(PropertyExpression property_expression,
      String uri_literal, EdmTyped edm_property);
 
Example #9
Source File: VisitorTool.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public Object visitProperty(final PropertyExpression literal, final String uriLiteral, final EdmTyped edmProperty) {
  return uriLiteral;
}
 
Example #10
Source File: JPAQueryBuilderTest.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
private UriInfo mockURIInfoForEntitySetWithBinaryFilterExpression
(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());
  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);
  BinaryExpression commonExpression = EasyMock.createMock(BinaryExpression.class);
  EasyMock.expect(commonExpression.getOperator()).andStubReturn(BinaryOperator.EQ);
  EasyMock.expect(commonExpression.getKind()).andStubReturn(ExpressionKind.BINARY);
  MethodExpression methodExp = EasyMock.createMock(MethodExpression.class);
  EasyMock.expect(commonExpression.getLeftOperand()).andStubReturn(methodExp);
  EdmSimpleType type = EasyMock.createMock(EdmSimpleType.class);;
  EasyMock.expect(methodExp.getEdmType()).andStubReturn(type );
  
  LiteralExpression literalValueExp = EasyMock.createMock(LiteralExpression.class);
  EasyMock.expect(commonExpression.getRightOperand()).andStubReturn(literalValueExp);
  EasyMock.expect(literalValueExp.getUriLiteral()).andStubReturn("'a%.b*.c'");
  EasyMock.expect(literalValueExp.getKind()).andStubReturn(ExpressionKind.LITERAL);
  EasyMock.expect(literalValueExp.getEdmType()).andStubReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance());
  
  PropertyExpression propExp = EasyMock.createMock(PropertyExpression.class);
  LiteralExpression literalExp1 = EasyMock.createMock(LiteralExpression.class);
  LiteralExpression literalExp2 = EasyMock.createMock(LiteralExpression.class);
  List<CommonExpression> parameterList = new ArrayList<CommonExpression>();
  if ("substring".equals(methodName)) {
    EasyMock.expect(methodExp.getMethod()).andStubReturn(MethodOperator.SUBSTRING);
    EasyMock.expect(methodExp.getKind()).andStubReturn(ExpressionKind.METHOD);
    EasyMock.expect(methodExp.getParameterCount()).andStubReturn(3);
    EasyMock.expect(propExp.getEdmProperty()).andStubReturn(edmProperty);
    EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY);
    parameterList.add(propExp);
    EasyMock.expect(literalExp1.getUriLiteral()).andStubReturn("1");
    EasyMock.expect(literalExp1.getKind()).andStubReturn(ExpressionKind.LITERAL);
    EasyMock.expect(literalExp1.getEdmType()).andStubReturn(EdmSimpleTypeKind.Int16.getEdmSimpleTypeInstance());
    parameterList.add(literalExp1);
    EasyMock.expect(literalExp2.getUriLiteral()).andStubReturn("2");
    EasyMock.expect(literalExp2.getKind()).andStubReturn(ExpressionKind.LITERAL);
    EasyMock.expect(literalExp2.getEdmType()).andStubReturn(EdmSimpleTypeKind.Int16.getEdmSimpleTypeInstance());
    parameterList.add(literalExp2);
    EasyMock.expect(methodExp.getParameters()).andStubReturn(parameterList);
  } else if ("toLower".equals(methodName)) {
    EasyMock.expect(methodExp.getMethod()).andStubReturn(MethodOperator.TOLOWER);
    EasyMock.expect(methodExp.getKind()).andStubReturn(ExpressionKind.METHOD);
    EasyMock.expect(methodExp.getParameterCount()).andStubReturn(1);
    EasyMock.expect(propExp.getEdmProperty()).andStubReturn(edmProperty);
    EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY);
    parameterList.add(propExp);
    EasyMock.expect(methodExp.getParameters()).andStubReturn(parameterList);
  } else if ("toUpper".equals(methodName)) {
    EasyMock.expect(methodExp.getMethod()).andStubReturn(MethodOperator.TOUPPER);
    EasyMock.expect(methodExp.getKind()).andStubReturn(ExpressionKind.METHOD);
    EasyMock.expect(methodExp.getParameterCount()).andStubReturn(1);
    EasyMock.expect(propExp.getEdmProperty()).andStubReturn(edmProperty);
    EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY);
    parameterList.add(propExp);
    EasyMock.expect(methodExp.getParameters()).andStubReturn(parameterList);
  }
  EasyMock.expect(filterExpression.getExpression()).andStubReturn(commonExpression);
  EasyMock.expect(filterExpression.getKind()).andStubReturn(ExpressionKind.FILTER);
  EasyMock.expect(filterExpression.getExpressionString()).andStubReturn("substring(CompanyName,1,2) eq 'a.b.c'");
  EasyMock.expect(uriInfo.getFilter()).andStubReturn(filterExpression);
  EasyMock.replay(edmEntityType, edmEntitySet, orderbyExpression, filterExpression, 
      commonExpression, literalExp1, literalExp2, propExp, uriInfo, edmProperty, 
      methodExp, literalValueExp);
  return uriInfo;

}
 
Example #11
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 #12
Source File: JPAQueryBuilderTest.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
private UriInfo mockURIInfoWithKeyNavSegAndFilter(EdmMapping mapping) throws EdmException {
  UriInfo uriInfo = EasyMock.createMock(UriInfo.class);
  
  EdmEntityType startEntityType = EasyMock.createMock(EdmEntityType.class);
  EasyMock.expect(startEntityType.getMapping()).andStubReturn(mapping);
  
  EdmEntitySet startEntitySet = EasyMock.createMock(EdmEntitySet.class);
  EasyMock.expect(startEntitySet.getEntityType()).andStubReturn(startEntityType);
  EasyMock.expect(uriInfo.getStartEntitySet()).andStubReturn(startEntitySet);
  
  EdmEntityType targetEntityType = EasyMock.createMock(EdmEntityType.class);
  EasyMock.expect(targetEntityType.getMapping()).andStubReturn((EdmMapping) mockNavEdmMappingForProperty());
  
  EdmEntitySet targetEntitySet = EasyMock.createMock(EdmEntitySet.class);
  EasyMock.expect(targetEntitySet.getEntityType()).andStubReturn(targetEntityType);
  EasyMock.expect(uriInfo.getTargetEntitySet()).andStubReturn(targetEntitySet);
  
  List<KeyPredicate> keyPreds = new ArrayList<KeyPredicate>();
  EdmProperty edmProperty = mockEdmProperty((EdmMapping) mockMappingWithType("uuid"), "uuid");
  keyPreds.add(mockKeyPredicate(edmProperty, "56fe79b1-1c88-465b-b309-33bf8b8f6800"));
  EasyMock.expect(uriInfo.getKeyPredicates()).andStubReturn(keyPreds); 
  
  List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>();
  EasyMock.expect(uriInfo.getNavigationSegments()).andStubReturn(navSegments);
  NavigationSegment navSegment = EasyMock.createMock(NavigationSegment.class);
  EasyMock.expect(navSegment.getEntitySet()).andStubReturn(targetEntitySet);
  List<KeyPredicate> navKeyPreds = new ArrayList<KeyPredicate>();
  EasyMock.expect(navSegment.getKeyPredicates()).andStubReturn(navKeyPreds);
  EdmNavigationProperty navEdmProperty = EasyMock.createMock(EdmNavigationProperty.class);
  EasyMock.expect(navSegment.getNavigationProperty()).andStubReturn(navEdmProperty);
  EasyMock.expect(navEdmProperty.getMapping()).andStubReturn((EdmMapping)mockNavEdmMappingForProperty());
  EasyMock.expect(navEdmProperty.getFromRole()).andStubReturn("Customers");
  EasyMock.expect(navEdmProperty.getToRole()).andStubReturn("SalesOrderHeader");
  EdmAssociation association = EasyMock.createMock(EdmAssociation.class);
  EasyMock.expect(navEdmProperty.getRelationship()).andStubReturn(association);
  EdmAssociationEnd associationEnd = EasyMock.createMock(EdmAssociationEnd.class);
  EasyMock.expect(associationEnd.getEntityType()).andStubReturn(startEntityType);
  EasyMock.expect(association.getEnd("Customers")).andStubReturn(associationEnd);
  navSegments.add(navSegment);
  
  FilterExpression filterExpression = EasyMock.createMock(FilterExpression.class);
  PropertyExpression propExp = EasyMock.createMock(PropertyExpression.class);
  LiteralExpression literalExp = EasyMock.createMock(LiteralExpression.class);
  EasyMock.expect(uriInfo.getFilter()).andStubReturn(filterExpression);
  BinaryExpression commonExpression = EasyMock.createMock(BinaryExpression.class);
  EasyMock.expect(commonExpression.getOperator()).andStubReturn(BinaryOperator.EQ);
  EasyMock.expect(commonExpression.getKind()).andStubReturn(ExpressionKind.BINARY);
  EasyMock.expect(filterExpression.getExpression()).andStubReturn(commonExpression);
  EasyMock.expect(filterExpression.getKind()).andStubReturn(ExpressionKind.FILTER); 
  EasyMock.expect(filterExpression.getExpressionString()).andStubReturn(
      "Customer eq '56fe79b1-1c88-465b-b309-32bf8b8f7800'"); 
  
  EasyMock.expect(commonExpression.getLeftOperand()).andStubReturn(propExp);
  EasyMock.expect(propExp.getEdmProperty()).andStubReturn(mockEdmProperty(
      (EdmMapping) mockMappingWithType("uuid"), "uuid"));
  EasyMock.expect(propExp.getKind()).andStubReturn(ExpressionKind.PROPERTY);
  EasyMock.expect(propExp.getEdmType()).andStubReturn(EdmSimpleTypeKind.Guid.getEdmSimpleTypeInstance());
  
  EasyMock.expect(commonExpression.getRightOperand()).andStubReturn(literalExp);
  EasyMock.expect(literalExp.getUriLiteral()).andStubReturn("guid'56fe79b1-1c88-465b-b309-32bf8b8f7800'");
  EasyMock.expect(literalExp.getKind()).andStubReturn(ExpressionKind.LITERAL);
  EasyMock.expect(literalExp.getEdmType()).andStubReturn(EdmSimpleTypeKind.Guid.getEdmSimpleTypeInstance());
  
  EasyMock.expect(uriInfo.getOrderBy()).andStubReturn(null);
  EasyMock.expect(uriInfo.getTop()).andStubReturn(null);
  EasyMock.expect(uriInfo.getSkip()).andStubReturn(null);
  
  EasyMock.replay(startEntityType, targetEntityType, startEntitySet, targetEntitySet, uriInfo,
      filterExpression, propExp, literalExp, navSegment, navEdmProperty, 
      commonExpression, association, associationEnd);
  return uriInfo;

}
 
Example #13
Source File: IngestFunctionalVisitor.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Object visitProperty(PropertyExpression pe, String uri_literal, EdmTyped prop)
{
   // Returns Transformer<Connection, Object> to provide the requested property `uri_literal`.
   Transformer<Ingest, ? extends Object> res;
   switch (uri_literal)
   {
      case ID:
         res = new Transformer<Ingest, Long>()
         {
            @Override
            public Long transform(Ingest i)
            {
               return i.getId();
            }
         };
         break;

      case FILENAME:
         res = new Transformer<Ingest, String>()
         {
            @Override
            public String transform(Ingest i)
            {
               return i.getFilename();
            }
         };
         break;

      case MD5:
         res = new Transformer<Ingest, String>()
         {
            @Override
            public String transform(Ingest i)
            {
               return i.getMd5();
            }
         };
         break;

      case STATUS:
         res = new Transformer<Ingest, String>()
         {
            @Override
            public String transform(Ingest i)
            {
               return i.getStatusMessage();
            }
         };
         break;

      case STATUS_MESSAGE:
         res = new Transformer<Ingest, String>()
         {
            @Override
            public String transform(Ingest i)
            {
               return i.getStatus().toString();
            }
         };
         break;

      case STATUS_DATE:
         res = new Transformer<Ingest, Date>()
         {
            @Override
            public Date transform(Ingest i)
            {
               return i.getStatusDate();
            }
         };
         break;

      default: throw new UnsupportedOperationException("Unknown property: " + uri_literal);
   }
   return ExecutableExpressionTree.Node.createLeave(res);
}
 
Example #14
Source File: ProductSQLVisitor.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Object visitProperty (PropertyExpression property_expression,
   String uri_literal, EdmTyped edm_property)
{
   if (edm_property == null)
      throw new IllegalArgumentException ("Property not found: " +
            uri_literal);

   Member member = null;
   switch (uri_literal)
   {
      case ItemEntitySet.ID:
      {
         member = new Member ("uuid");
         break;
      }
      case ItemEntitySet.NAME:
      {
         member = new Member ("identifier");
         break;
      }
      case ItemEntitySet.CONTENT_LENGTH:
      {
         member = new Member ("download.size");
         break;
      }
      case ProductEntitySet.CREATION_DATE:
      {
         member = new Member ("created");
         break;
      }
      case ProductEntitySet.INGESTION_DATE:
      {
         member = new Member ("ingestionDate");
         break;
      }
      case ProductEntitySet.CONTENT_GEOMETRY:
      {
         member = new Member ("footPrint");
         break;
      }
      // Not used really, but needed to be here.
      case ProductEntitySet.CONTENT_DATE:
      {
         break; // return null
      }
      case Model.TIME_RANGE_START:
      {
         member = new Member ("contentStart");
         break;
      }
      case Model.TIME_RANGE_END:
      {
         member = new Member ("contentEnd");
         break;
      }

      // non filterable properties
      case ProductEntitySet.EVICTION_DATE:
      case ProductEntitySet.METALINK:
      case ItemEntitySet.CONTENT_TYPE:
      case NodeEntitySet.VALUE:
      case NodeEntitySet.CHILDREN_NUMBER:
      {
         throw new IllegalArgumentException ("Property \"" + uri_literal +
               "\" is not filterable.");
      }

      // Unsupported or invalid properties
      default:
      {
         throw new IllegalArgumentException ("Property not supported: " +
               uri_literal);
      }
   }
   return member;
}
 
Example #15
Source File: ConnectionFunctionalVisitor.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Object visitProperty(PropertyExpression pe, String uri_literal,
   EdmTyped edm_property)
{
   // Returns Transformer<Connection, Object> to provide the requested
   // property `uri_literal`.
   Transformer<Connection, ? extends Object> res;
   switch (uri_literal)
   {
      case ConnectionEntitySet.ID:
         res = new IdProvider();
         break;
      case ConnectionEntitySet.DATE:
         res = new DateProvider();
         break;
      case ConnectionEntitySet.REMOTEIP:
         res = new RemoteIpProvider();
         break;
      case ConnectionEntitySet.REQUEST:
         res = new RequestProvider();
         break;
      case ConnectionEntitySet.DURATION:
         res = new DurationProvider();
         break;
      case ConnectionEntitySet.CONTENT_LENGTH:
         res = new ContentLengthProvider();
         break;
      case ConnectionEntitySet.WRITTEN_CONTENT_LENGTH:
         res = new WrittenContentLengthProvider();
         break;
      case ConnectionEntitySet.STATUS:
         res = new StatusProvider();
         break;
      case ConnectionEntitySet.STATUS_MESSAGE:
         res = new StatusMessageProvider();
         break;

      default:
         throw new UnsupportedOperationException("Unknown property: " + 
            uri_literal);
   }

   return ExecutableExpressionTree.Node.createLeave(res);
}
 
Example #16
Source File: UserSQLVisitor.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Object visitProperty (PropertyExpression property_expression,
   String uri_literal, EdmTyped edm_property)
{
   if (edm_property == null)
      throw new IllegalArgumentException ("Property not found: " +
            uri_literal);

   if (uri_literal.equals (UserEntitySet.USERNAME)) 
      return new Member ("username");

   if (uri_literal.equals (UserEntitySet.COUNTRY))
      return new Member ("country");

   if (uri_literal.equals (UserEntitySet.EMAIL))
      return new Member ("email");

   if (uri_literal.equals (UserEntitySet.FIRSTNAME))
      return new Member ("firstname");

   if (uri_literal.equals (UserEntitySet.LASTNAME))
      return new Member ("lastname");

   if (uri_literal.equals (UserEntitySet.ADDRESS))
      return new Member ("address");

   if (uri_literal.equals (UserEntitySet.PHONE))
      return new Member ("phone");

   if (uri_literal.equals (UserEntitySet.DOMAIN))
      return new Member ("domain");

   if (uri_literal.equals (UserEntitySet.SUBDOMAIN))
      return new Member ("subDomain");

   if (uri_literal.equals (UserEntitySet.USAGE))
      return new Member ("usage");

   if (uri_literal.equals (UserEntitySet.SUBUSAGE))
      return new Member ("subUsage");

   if (uri_literal.equals(UserEntitySet.CREATED))
      return new Member ("created");

   throw new IllegalArgumentException ("Property not supported: " +
         uri_literal);
}
 
Example #17
Source File: FunctionalVisitor.java    From DataHubSystem with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Called for each property in the $filter option.
 * An implementation MUST return an {@link ExecutableExpressionTree.Node}.
 * @param pe PropertyExpression.
 * @param uri_literal name of the property.
 * @param prop Property.
 * @return an {@link ExecutableExpressionTree.Node}.
 */
@Override
public abstract Object visitProperty(PropertyExpression pe, String uri_literal, EdmTyped prop);