Examples of EdmFunctionImport


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

    super(type);
  }

  @Test
  public void singleSimpleType() throws Exception {
    final EdmFunctionImport functionImport =
        MockFacade.getMockEdm().getDefaultEntityContainer().getFunctionImport("MaximalAge");

    final ODataResponse response =
        createAtomEntityProvider().writeFunctionImport(functionImport, employeeData.get("Age"), DEFAULT_PROPERTIES);
    assertNotNull(response);
View Full Code Here

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

    assertXpathEvaluatesTo("52", "/d:MaximalAge/text()", xml);
  }

  @Test
  public void singleComplexType() throws Exception {
    final EdmFunctionImport functionImport =
        MockFacade.getMockEdm().getDefaultEntityContainer().getFunctionImport("MostCommonLocation");

    final ODataResponse response =
        createAtomEntityProvider()
            .writeFunctionImport(functionImport, employeeData.get("Location"), DEFAULT_PROPERTIES);
View Full Code Here

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

    assertXpathEvaluatesTo("Duckburg", "/d:MostCommonLocation/d:City/d:CityName/text()", xml);
  }

  @Test
  public void collectionOfSimpleTypes() throws Exception {
    final EdmFunctionImport functionImport =
        MockFacade.getMockEdm().getDefaultEntityContainer().getFunctionImport("AllUsedRoomIds");

    final ODataResponse response =
        createAtomEntityProvider()
            .writeFunctionImport(functionImport, Arrays.asList("1", "2", "3"), DEFAULT_PROPERTIES);
View Full Code Here

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

    assertXpathEvaluatesTo("3", "/d:AllUsedRoomIds/d:element[3]/text()", xml);
  }

  @Test
  public void collectionOfComplexTypes() throws Exception {
    final EdmFunctionImport functionImport =
        MockFacade.getMockEdm().getDefaultEntityContainer().getFunctionImport("AllLocations");

    final ODataResponse response =
        createAtomEntityProvider().writeFunctionImport(functionImport, Arrays.asList(employeeData.get("Location")),
            DEFAULT_PROPERTIES);
View Full Code Here

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

    assertXpathEvaluatesTo("Duckburg", "/d:AllLocations/d:element/d:City/d:CityName/text()", xml);
  }

  @Test
  public void singleEntityType() throws Exception {
    final EdmFunctionImport functionImport =
        MockFacade.getMockEdm().getDefaultEntityContainer().getFunctionImport("OldestEmployee");

    final ODataResponse response =
        createAtomEntityProvider().writeFunctionImport(functionImport, employeeData, DEFAULT_PROPERTIES);
    assertNotNull(response);
View Full Code Here

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

  @Override
  public ODataResponse build(final GetFunctionImportUriInfo resultsView, final Object result)
      throws ODataJPARuntimeException {

    try {
      final EdmFunctionImport functionImport = resultsView.getFunctionImport();
      final EdmSimpleType type = (EdmSimpleType) functionImport.getReturnType().getType();

      if (result != null) {
        ODataResponse response = null;

        final String value = type.valueToString(result, EdmLiteralKind.DEFAULT, null);
View Full Code Here

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

    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);
            }
View Full Code Here

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

  }

  @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) {
        values.add(getStructuralTypeValueMap(typeData, (EdmStructuralType) type));
      }
      value = values;
View Full Code Here

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

  }

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

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

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

    assertEquals(HttpStatusCodes.NO_CONTENT, result.getStatus());
  }

  @Test
  public void writeFunctionImport() throws Exception {
    final EdmFunctionImport function =
        MockFacade.getMockEdm().getDefaultEntityContainer().getFunctionImport("MaximalAge");
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("MaximalAge", 99);
    final ODataResponse result =
        new ProviderFacadeImpl().writeFunctionImport(HttpContentType.APPLICATION_JSON, function, properties, null);
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.