Examples of EdmFunctionImport


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

      }
    }

    private FunctionImport buildFunctionImport(final Method method) throws ODataJPAModelException {

      EdmFunctionImport edmAnnotationFunctionImport = method.getAnnotation(EdmFunctionImport.class);
      if (edmAnnotationFunctionImport != null && edmAnnotationFunctionImport.returnType() != null) {
        return buildEdmFunctionImport(method, edmAnnotationFunctionImport);
      }

      return null;
    }
View Full Code Here

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

      }
    }

    private FunctionImport buildFunctionImport(final Method method) throws ODataJPAModelException {

      EdmFunctionImport edmAnnotationFunctionImport = method.getAnnotation(EdmFunctionImport.class);
      if (edmAnnotationFunctionImport != null && edmAnnotationFunctionImport.returnType() != null) {
        return buildEdmFunctionImport(method, edmAnnotationFunctionImport);
      }

      return null;
    }
View Full Code Here

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

    }

    @SuppressWarnings("deprecation")
    private FunctionImport buildFunctionImport(final Method method) throws ODataJPAModelException {

      EdmFunctionImport edmAnnotationFunctionImport = method.getAnnotation(EdmFunctionImport.class);
      if (edmAnnotationFunctionImport != null && edmAnnotationFunctionImport.returnType() != null) {
        return buildEdmFunctionImport(method, edmAnnotationFunctionImport);
      }

      org.apache.olingo.odata2.api.annotation.edm.FunctionImport annotation =
          method.getAnnotation(org.apache.olingo.odata2.api.annotation.edm.FunctionImport.class);
View Full Code Here

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

    return edmEntitySet;
  }

  @Override
  public EdmFunctionImport getFunctionImport(final String name) throws EdmException {
    EdmFunctionImport edmFunctionImport = edmFunctionImports.get(name);
    if (edmFunctionImport != null) {
      return edmFunctionImport;
    }

    FunctionImport functionImport;
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

    createProperty("Name", EdmSimpleTypeKind.String, buildingType);
    createProperty("Image", EdmSimpleTypeKind.Binary, buildingType);
    when(buildingType.getNavigationPropertyNames()).thenReturn(Arrays.asList("nb_Rooms"));
    createNavigationProperty("nb_Rooms", EdmMultiplicity.MANY, buildingEntitySet, roomEntitySet);

    EdmFunctionImport employeeSearchFunctionImport =
        createFunctionImportMock(defaultContainer, "EmployeeSearch", employeeType, EdmMultiplicity.MANY);
    when(employeeSearchFunctionImport.getEntitySet()).thenReturn(employeeEntitySet);
    EdmParameter employeeSearchParameter = mock(EdmParameter.class);
    when(employeeSearchParameter.getType()).thenReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance());
    when(employeeSearchFunctionImport.getParameterNames()).thenReturn(Arrays.asList("q"));
    when(employeeSearchFunctionImport.getParameter("q")).thenReturn(employeeSearchParameter);
    createFunctionImportMock(defaultContainer, "AllLocations", locationComplexType, EdmMultiplicity.MANY);
    createFunctionImportMock(defaultContainer, "AllUsedRoomIds", EdmSimpleTypeKind.String.getEdmSimpleTypeInstance(),
        EdmMultiplicity.MANY);
    createFunctionImportMock(defaultContainer, "MaximalAge", EdmSimpleTypeKind.Int16.getEdmSimpleTypeInstance(),
        EdmMultiplicity.ONE);
    createFunctionImportMock(defaultContainer, "MostCommonLocation", locationComplexType, EdmMultiplicity.ONE);
    EdmFunctionImport managerPhotoFunctionImport =
        createFunctionImportMock(defaultContainer, "ManagerPhoto", EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance(),
            EdmMultiplicity.ONE);
    EdmParameter managerPhotoParameter = mock(EdmParameter.class);
    when(managerPhotoParameter.getType()).thenReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance());
    EdmFacets managerPhotoParameterFacets = mock(EdmFacets.class);
    when(managerPhotoParameterFacets.isNullable()).thenReturn(false);
    when(managerPhotoParameter.getFacets()).thenReturn(managerPhotoParameterFacets);
    when(managerPhotoFunctionImport.getParameterNames()).thenReturn(Arrays.asList("Id"));
    when(managerPhotoFunctionImport.getParameter("Id")).thenReturn(managerPhotoParameter);
    EdmFunctionImport oldestEmployeeFunctionImport =
        createFunctionImportMock(defaultContainer, "OldestEmployee", employeeType, EdmMultiplicity.ONE);
    when(oldestEmployeeFunctionImport.getEntitySet()).thenReturn(employeeEntitySet);

    EdmEntityContainer specificContainer = mock(EdmEntityContainer.class);
    when(specificContainer.getEntitySet("Employees")).thenReturn(employeeEntitySet);
    when(specificContainer.getName()).thenReturn("Container1");
View Full Code Here

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

      final EdmType type, final EdmMultiplicity multiplicity) throws EdmException {
    EdmTyped returnType = mock(EdmTyped.class);
    when(returnType.getType()).thenReturn(type);
    when(returnType.getMultiplicity()).thenReturn(multiplicity);

    EdmFunctionImport functionImport = mock(EdmFunctionImport.class);
    when(functionImport.getName()).thenReturn(name);
    when(functionImport.getReturnType()).thenReturn(returnType);
    when(functionImport.getHttpMethod()).thenReturn(ODataHttpMethod.GET.name());

    when(container.getFunctionImport(name)).thenReturn(functionImport);

    return functionImport;
  }
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
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.