Package org.apache.olingo.odata2.api.edm

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


    if (functionImportParameters == null) {
      return Collections.emptyMap();
    } else {
      Map<String, Object> parameterMap = new HashMap<String, Object>();
      for (final String parameterName : functionImportParameters.keySet()) {
        final EdmLiteral literal = functionImportParameters.get(parameterName);
        final EdmSimpleType type = literal.getType();
        parameterMap.put(parameterName, type.valueOfString(literal.getLiteral(), EdmLiteralKind.DEFAULT, null, type
            .getDefaultType()));
      }
      return parameterMap;
    }
  }
View Full Code Here


*
*/
public class EdmSimpleTypeFacadeTest extends BaseTest {

  public static void parse(final String literal, final EdmSimpleType expectedType) throws EdmLiteralException {
    final EdmLiteral uriLiteral = EdmSimpleTypeKind.parseUriLiteral(literal);
    assertNotNull(uriLiteral);
    if (!expectedType.equals(EdmNull.getInstance())) {
      assertNotNull(uriLiteral.getLiteral());
      assertTrue(uriLiteral.getLiteral().length() > 0);
    }
    assertNotNull(uriLiteral.getType());
    assertEquals(expectedType, uriLiteral.getType());
  }
View Full Code Here

   * @throws UriSyntaxException
   * @throws EdmException
   */
  private void parseLiteral(final String literal, final EdmSimpleTypeKind typeKind, final String expectedLiteral)
      throws UriSyntaxException, EdmException {
    final EdmLiteral uriLiteral = EdmSimpleTypeKind.parseUriLiteral(literal);

    assertTrue(typeKind.getEdmSimpleTypeInstance().isCompatible(uriLiteral.getType()));
    assertEquals(expectedLiteral, uriLiteral.getLiteral());
  }
View Full Code Here

    parseWrongLiteralContent("time'3'", EdmLiteralException.LITERALFORMAT);
  }

  private void parseIncompatibleLiteralContent(final String literal, final EdmSimpleTypeKind typeKind)
      throws EdmLiteralException {
    final EdmLiteral uriLiteral = EdmSimpleTypeKind.parseUriLiteral(literal);
    assertFalse(typeKind.getEdmSimpleTypeInstance().isCompatible(uriLiteral.getType()));
  }
View Full Code Here

        return null;
      } else {
        Object[] args = new Object[edmArguements.size()];
        int i = 0;
        for (String paramName : functionImport.getParameterNames()) {
          EdmLiteral literal = edmArguements.get(paramName);
          EdmParameter parameter = functionImport.getParameter(paramName);
          JPAEdmMapping mapping = (JPAEdmMapping) parameter.getMapping();
          args[i] = convertArguement(literal, parameter.getFacets(), mapping.getJPAType());
          i++;
        }
View Full Code Here

    if (functionImportParameters == null) {
      return Collections.emptyMap();
    } else {
      Map<String, Object> parameterMap = new HashMap<String, Object>();
      for (final String parameterName : functionImportParameters.keySet()) {
        final EdmLiteral literal = functionImportParameters.get(parameterName);
        final EdmSimpleType type = literal.getType();
        parameterMap.put(parameterName, type.valueOfString(literal.getLiteral(), EdmLiteralKind.DEFAULT, null, type
            .getDefaultType()));
      }
      return parameterMap;
    }
  }
View Full Code Here

    if (functionImportParameters == null) {
      return Collections.emptyMap();
    } else {
      Map<String, Object> parameterMap = new HashMap<String, Object>();
      for (final String parameterName : functionImportParameters.keySet()) {
        final EdmLiteral literal = functionImportParameters.get(parameterName);
        final EdmSimpleType type = literal.getType();
        parameterMap.put(parameterName, type.valueOfString(literal.getLiteral(), EdmLiteralKind.DEFAULT, null, type
            .getDefaultType()));
      }
      return parameterMap;
    }
  }
View Full Code Here

            break;

        case URI3:
            // complex property
            final List<EdmProperty> complexPropertyPath = uriInfo.getPropertyPath();
            final EdmProperty complexProperty = complexPropertyPath.get(complexPropertyPath.size() - 1);
            response = (T) EntityProvider.readProperty(getContentType(),
                complexProperty, content, EntityProviderReadProperties.init().build());
            break;

        case URI4:
        case URI5:
            // simple property
            final List<EdmProperty> simplePropertyPath = uriInfo.getPropertyPath();
            final EdmProperty simpleProperty = simplePropertyPath.get(simplePropertyPath.size() - 1);
            if (uriInfo.isValue()) {
                response = (T) EntityProvider.readPropertyValue(simpleProperty, content);
            } else {
                response = (T) EntityProvider.readProperty(getContentType(),
                    simpleProperty, content, EntityProviderReadProperties.init().build());
View Full Code Here

                        case URI4:
                        case URI5:
                            // simple property
                            // get the response content as Object for $value or Map<String, Object> otherwise
                            final List<EdmProperty> simplePropertyPath = uriInfo.getPropertyPath();
                            final EdmProperty simpleProperty = simplePropertyPath.get(simplePropertyPath.size() - 1);
                            if (uriInfo.isValue()) {
                                responseHandler.onResponse(
                                    (T) EntityProvider.readPropertyValue(simpleProperty,
                                        result.getEntity().getContent()));
                            } else {
                                responseHandler.onResponse(
                                    (T) EntityProvider.readProperty(getContentType(), simpleProperty,
                                        result.getEntity().getContent(),
                                        EntityProviderReadProperties.init().build()));
                            }
                            break;

                        case URI3:
                            // complex property
                            // get the response content as Map<String, Object>
                            final List<EdmProperty> complexPropertyPath = uriInfo.getPropertyPath();
                            final EdmProperty complexProperty = complexPropertyPath.get(complexPropertyPath.size() - 1);
                            responseHandler.onResponse((T)EntityProvider.readProperty(getContentType(),
                                                                                      complexProperty, result
                                                                                          .getEntity()
                                                                                          .getContent(),
                                                                                      EntityProviderReadProperties
View Full Code Here

        switch (uriInfo.getUriType()) {
        case URI4:
        case URI5:
            // simple property
            final List<EdmProperty> simplePropertyPath = uriInfo.getPropertyPath();
            final EdmProperty simpleProperty = simplePropertyPath.get(simplePropertyPath.size() - 1);
            responseContentType = simpleProperty.getMimeType();
            if (uriInfo.isValue()) {
                response = EntityProvider.writePropertyValue(simpleProperty, content);
                responseContentType = ContentType.TEXT_PLAIN_CS_UTF_8.toString();
            } else {
                response = EntityProvider.writeProperty(getContentType(), simpleProperty, content);
            }
            break;

        case URI3:
            // complex property
            final List<EdmProperty> complexPropertyPath = uriInfo.getPropertyPath();
            final EdmProperty complexProperty = complexPropertyPath.get(complexPropertyPath.size() - 1);
            response = EntityProvider.writeProperty(responseContentType, complexProperty, content);
            break;

        case URI7A:
            // $links with 0..1 cardinality property
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.edm.EdmLiteral

Copyright © 2018 www.massapicom. 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.