Examples of EdmType


Examples of org.apache.olingo.odata2.api.edm.EdmType

  @Override
  public ODataResponse executeFunctionImport(final GetFunctionImportUriInfo uriInfo, final String contentType)
      throws ODataException {
    final EdmFunctionImport functionImport = uriInfo.getFunctionImport();
    final EdmType type = functionImport.getReturnType().getType();

    final Object data = dataSource.readData(
        functionImport,
        mapFunctionParameters(uriInfo.getFunctionImportParameters()),
        null);

    if (data == null) {
      throw new ODataNotFoundException(ODataHttpException.COMMON);
    }

    Object value;
    if (type.getKind() == EdmTypeKind.SIMPLE) {
      value = type == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance() ?
          ((BinaryData) data).getData() : data;
    } else if (functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY) {
      List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
      for (final Object typeData : (List<?>) data) {
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmType

    }
  }

  private static String getType(final CommonExpression expression) {
    try {
      final EdmType type = expression.getEdmType();
      return type == null ? null : type.getNamespace() + Edm.DELIMITER + type.getName();
    } catch (final EdmException e) {
      return "EdmException occurred: " + e.getMessage();
    }
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmType

    }
  }

  private EntityPropertyInfo createEntityPropertyInfo(final EdmProperty property) throws EdmException,
      EntityProviderException {
    EdmType type = property.getType();
    if (type instanceof EdmSimpleType) {
      return EntityPropertyInfo.create(property);
    } else if (type instanceof EdmComplexType) {
      EdmComplexType complex = (EdmComplexType) type;
      Map<String, EntityPropertyInfo> recursiveInfos = createPropertyInfoObjects(complex, complex.getPropertyNames());
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmType

    try {
      String etag = null;

      Collection<EntityPropertyInfo> propertyInfos = eia.getETagPropertyInfos();
      for (EntityPropertyInfo propertyInfo : propertyInfos) {
        EdmType edmType = propertyInfo.getType();
        if (edmType instanceof EdmSimpleType) {
          EdmSimpleType edmSimpleType = (EdmSimpleType) edmType;
          if (etag == null) {
            etag =
                edmSimpleType.valueToString(data.get(propertyInfo.getName()), EdmLiteralKind.DEFAULT, propertyInfo
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmType

      if (parameterCount == 1) {
        return combinations.get(0).getReturnType();
      }

      // There are more than 1 possible return type, check if they are equal, if not return null.
      EdmType returnType = combinations.get(0).getReturnType();
      for (int i = 1; i < parameterCount; i++) {
        if (returnType != combinations.get(i)) {
          return null;
        }
      }
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmType

      throw new IllegalStateException();
    }

    @Override
    public ParameterSet validate(final List<EdmType> actualParameterTypes) throws ExpressionParserInternalError {
      EdmType xxx = actualParameterTypes.get(actualParameterTypes.size() - 1);
      return new ParameterSet(xxx, null);
      // return actualParameterTypes.get(actualParameterTypes.size() - 1);
    }
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmType

  @Override
  public ODataResponse writeFunctionImport(final EdmFunctionImport functionImport, final Object data,
      final EntityProviderWriteProperties properties) throws EntityProviderException {
    try {
      final EdmType type = functionImport.getReturnType().getType();
      final boolean isCollection = functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY;

      if (type.getKind() == EdmTypeKind.ENTITY) {
        @SuppressWarnings("unchecked")
        Map<String, Object> map = (Map<String, Object>) data;
        return writeEntry(functionImport.getEntitySet(), map, properties);
      }
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmType

    EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
    EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
    KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
    EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
    EdmType edmType1 = EasyMock.createMock(EdmType.class);
    EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
    EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
    try {
      EasyMock.expect(mapping.getInternalName()).andStubReturn("Field1");
      EasyMock.expect(kpProperty.getMapping()).andStubReturn(mapping);
      EasyMock.expect(kpProperty.getType()).andStubReturn(edmType1);

    } catch (EdmException e2) {
      fail("this should not happen");
    }
    EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
    EasyMock.replay(mapping, edmType1, kpProperty, keyPredicate);
    keyPredicates.add(keyPredicate);
    int i = 0;
    List<OrderExpression> orderList = new ArrayList<OrderExpression>(2);
    do {

      EdmType edmType = EasyMock.createMock(EdmType.class);
      try {
        EasyMock.expect(edmType.getName()).andStubReturn(fields[i]);
        EasyMock.replay(edmType);
      } catch (EdmException e2) {
        fail("Exception not Expected");
      }
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmType

    ODataResponse odataResponse = null;

    if (resultList != null && !resultList.isEmpty()) {
      JPAEntityParser jpaResultParser = new JPAEntityParser();
      EdmType edmType = null;
      EdmFunctionImport functionImport = null;
      Map<String, Object> edmPropertyValueMap = null;
      List<Map<String, Object>> edmEntityList = null;
      Object result = null;
      try {
        EntityProviderWriteProperties feedProperties = null;

        feedProperties =
            EntityProviderWriteProperties.serviceRoot(oDataJPAContext.getODataContext().getPathInfo().getServiceRoot())
                .build();

        functionImport = resultsView.getFunctionImport();
        edmType = functionImport.getReturnType().getType();

        if (edmType.getKind().equals(EdmTypeKind.ENTITY) || edmType.getKind().equals(EdmTypeKind.COMPLEX)) {
          if (functionImport.getReturnType().getMultiplicity().equals(EdmMultiplicity.MANY)) {
            edmEntityList = new ArrayList<Map<String, Object>>();
            for (Object jpaEntity : resultList) {
              edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, (EdmStructuralType) edmType);
              edmEntityList.add(edmPropertyValueMap);
            }
            result = edmEntityList;
          } else {

            Object resultObject = resultList.get(0);
            edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(resultObject, (EdmStructuralType) edmType);

            result = edmPropertyValueMap;
          }

        } else if (edmType.getKind().equals(EdmTypeKind.SIMPLE)) {
          result = resultList.get(0);
        }

        odataResponse =
            EntityProvider.writeFunctionImport(contentType, resultsView.getFunctionImport(), result, feedProperties);
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmType

  @Override
  public ODataResponse executeFunctionImport(final GetFunctionImportUriInfo uriInfo, final String contentType)
      throws ODataException {
    final EdmFunctionImport functionImport = uriInfo.getFunctionImport();
    final EdmType type = functionImport.getReturnType().getType();

    final Object data = dataSource.readData(
        functionImport,
        mapFunctionParameters(uriInfo.getFunctionImportParameters()),
        null);

    if (data == null) {
      throw new ODataNotFoundException(ODataHttpException.COMMON);
    }

    Object value;
    if (type.getKind() == EdmTypeKind.SIMPLE) {
      value = type == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance() ?
          ((BinaryData) data).getData() : data;
    } else if (functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY) {
      List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
      for (final Object typeData : (List<?>) data) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.