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

Examples of org.apache.olingo.odata2.api.edm.provider.FunctionImport


  @Override
  public FunctionImport getFunctionImport(final String entityContainer, final String name) throws ODataException {
    if (ENTITY_CONTAINER_1.equals(entityContainer)) {
      if (FUNCTION_IMPORT_1.equals(name)) {
        return new FunctionImport().setName(name)
            .setReturnType(new ReturnType().setTypeName(ENTITY_TYPE_1_1).setMultiplicity(EdmMultiplicity.MANY))
            .setEntitySet(ENTITY_SET_1_1)
            .setHttpMethod("GET")
            .setParameters(Arrays.asList(
                new FunctionImportParameter().setName("q").setType(EdmSimpleTypeKind.String)
                    .setFacets(new Facets().setNullable(true))));

      } else if (FUNCTION_IMPORT_2.equals(name)) {
        return new FunctionImport().setName(name)
            .setReturnType(new ReturnType().setTypeName(COMPLEX_TYPE_1).setMultiplicity(EdmMultiplicity.MANY))
            .setHttpMethod("GET");

      } else if (FUNCTION_IMPORT_3.equals(name)) {
        return new FunctionImport().setName(name)
            .setReturnType(
                new ReturnType().setTypeName(EdmSimpleTypeKind.String.getFullQualifiedName()).setMultiplicity(
                    EdmMultiplicity.MANY))
            .setHttpMethod("GET");

      } else if (FUNCTION_IMPORT_4.equals(name)) {
        return new FunctionImport().setName(name)
            .setReturnType(
                new ReturnType().setTypeName(EdmSimpleTypeKind.Int16.getFullQualifiedName()).setMultiplicity(
                    EdmMultiplicity.ONE))
            .setHttpMethod("GET");

      } else if (FUNCTION_IMPORT_5.equals(name)) {
        return new FunctionImport().setName(name)
            .setReturnType(new ReturnType().setTypeName(COMPLEX_TYPE_1).setMultiplicity(EdmMultiplicity.ONE))
            .setHttpMethod("GET");

      } else if (FUNCTION_IMPORT_6.equals(name)) {
        return new FunctionImport().setName(name)
            .setReturnType(
                new ReturnType().setTypeName(EdmSimpleTypeKind.Binary.getFullQualifiedName()).setMultiplicity(
                    EdmMultiplicity.ONE))
            .setHttpMethod("GET")
            .setParameters(Arrays.asList(
                new FunctionImportParameter().setName("Id").setType(EdmSimpleTypeKind.String)
                    .setFacets(new Facets().setNullable(false))));

      } else if (FUNCTION_IMPORT_7.equals(name)) {
        return new FunctionImport().setName(name)
            .setReturnType(new ReturnType().setTypeName(ENTITY_TYPE_1_1).setMultiplicity(EdmMultiplicity.ZERO_TO_ONE))
            .setEntitySet(ENTITY_SET_1_1)
            .setHttpMethod("GET");
      }
    }
View Full Code Here


  @Override
  public FunctionImport getFunctionImport(final String entityContainer, final String name) throws ODataException {
    if (ENTITY_CONTAINER.equals(entityContainer)) {
      if (FUNCTION_IMPORT.equals(name)) {
        return new FunctionImport().setName(name)
            .setReturnType(new ReturnType().setTypeName(ENTITY_TYPE_1_1).setMultiplicity(EdmMultiplicity.MANY))
            .setHttpMethod("GET");
      }
    }
    return null;
View Full Code Here

    if (ENTITY_CONTAINER_1.equals(entityContainer)) {
      if (FUNCTION_IMPORT_1.equals(name)) {
        final List<FunctionImportParameter> parameters = new ArrayList<FunctionImportParameter>();
        parameters.add(new FunctionImportParameter().setName("q").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(true)));
        return new FunctionImport().setName(name)
            .setReturnType(new ReturnType().setTypeName(ENTITY_TYPE_1_1).setMultiplicity(EdmMultiplicity.MANY))
            .setEntitySet(ENTITY_SET_1_1)
            .setHttpMethod("GET")
            .setParameters(parameters);

      } else if (FUNCTION_IMPORT_2.equals(name)) {
        return new FunctionImport().setName(name)
            .setReturnType(new ReturnType().setTypeName(COMPLEX_TYPE_1).setMultiplicity(EdmMultiplicity.MANY))
            .setHttpMethod("GET");

      } else if (FUNCTION_IMPORT_3.equals(name)) {
        return new FunctionImport().setName(name)
            .setReturnType(
                new ReturnType().setTypeName(EdmSimpleTypeKind.String.getFullQualifiedName()).setMultiplicity(
                    EdmMultiplicity.MANY))
            .setHttpMethod("GET");

      } else if (FUNCTION_IMPORT_4.equals(name)) {
        return new FunctionImport().setName(name)
            .setReturnType(
                new ReturnType().setTypeName(EdmSimpleTypeKind.Int16.getFullQualifiedName()).setMultiplicity(
                    EdmMultiplicity.ONE))
            .setHttpMethod("GET");

      } else if (FUNCTION_IMPORT_5.equals(name)) {
        return new FunctionImport().setName(name)
            .setReturnType(new ReturnType().setTypeName(COMPLEX_TYPE_1).setMultiplicity(EdmMultiplicity.ONE))
            .setHttpMethod("GET");

      } else if (FUNCTION_IMPORT_6.equals(name)) {
        final List<FunctionImportParameter> parameters = new ArrayList<FunctionImportParameter>();
        parameters.add(new FunctionImportParameter().setName("Id").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(false)));
        return new FunctionImport().setName(name)
            .setReturnType(
                new ReturnType().setTypeName(EdmSimpleTypeKind.Binary.getFullQualifiedName()).setMultiplicity(
                    EdmMultiplicity.ONE))
            .setHttpMethod("GET")
            .setParameters(parameters);

      } else if (FUNCTION_IMPORT_7.equals(name)) {
        return new FunctionImport().setName(name)
            .setReturnType(
                new ReturnType().setTypeName(new FullQualifiedName(NAMESPACE_1, "Employee")).setMultiplicity(
                    EdmMultiplicity.ZERO_TO_ONE))
            .setEntitySet(ENTITY_SET_1_1)
            .setHttpMethod("GET");
View Full Code Here

    parameters.add(parameter);

    parameter = new FunctionImportParameter().setName("fooParameter3").setType(EdmSimpleTypeKind.String);
    parameters.add(parameter);

    FunctionImport functionImportFoo =
        new FunctionImport().setName("foo").setHttpMethod("GET").setReturnType(fooReturnType).setEntitySet(
            "fooEntitySet").setParameters(parameters);
    when(edmProvider.getFunctionImport("Container", "foo")).thenReturn(functionImportFoo);
    edmFunctionImport = new EdmFunctionImportImplProv(edmImplProv, functionImportFoo, edmEntityContainer);

    FunctionImport functionImportBar = new FunctionImport().setName("bar").setHttpMethod("GET");
    when(edmProvider.getFunctionImport("Container", "bar")).thenReturn(functionImportBar);
    edmFunctionImportWithoutParameters =
        new EdmFunctionImportImplProv(edmImplProv, functionImportBar, edmEntityContainer);

  }
View Full Code Here

    AssociationSet associationSet = new AssociationSet().setName("4711");
    FullQualifiedName assocFQName = new FullQualifiedName("AssocNs", "AssocName");
    when(edmProvider.getAssociationSet("Container1", assocFQName, "foo", "fromRole")).thenReturn(associationSet);

    FunctionImport functionImportFoo = new FunctionImport().setName("foo");
    when(edmProvider.getFunctionImport("Container1", "foo")).thenReturn(functionImportFoo);

    FunctionImport functionImportBar = new FunctionImport().setName("foo");
    when(edmProvider.getFunctionImport("Container1", "foo")).thenReturn(functionImportBar);

    edmEntityContainer = new EdmEntityContainerImplProv(edmImplProv, entityContainer);
  }
View Full Code Here

  }

  private FunctionImport readFunctionImport(final XMLStreamReader reader)
      throws XMLStreamException, EntityProviderException {
    reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_FUNCTION_IMPORT);
    FunctionImport function = new FunctionImport();
    List<FunctionImportParameter> functionParameters = new ArrayList<FunctionImportParameter>();
    List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>();

    function.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME));
    function.setHttpMethod(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08,
        XmlMetadataConstants.EDM_FUNCTION_IMPORT_HTTP_METHOD));
    function.setEntitySet(reader.getAttributeValue(null, XmlMetadataConstants.EDM_ENTITY_SET));
    ReturnType returnType = new ReturnType();
    String returnTypeString = reader.getAttributeValue(null, XmlMetadataConstants.EDM_FUNCTION_IMPORT_RETURN);
    if (returnTypeString != null) {
      if (returnTypeString.startsWith("Collection") || returnTypeString.startsWith("collection")) {
        returnType.setMultiplicity(EdmMultiplicity.MANY);
        returnTypeString = returnTypeString.substring(returnTypeString.indexOf("(") + 1, returnTypeString.length() - 1);
      }
      FullQualifiedName fqName = extractFQName(returnTypeString);
      returnType.setTypeName(fqName);
      function.setReturnType(returnType);
    }
    function.setAnnotationAttributes(readAnnotationAttribute(reader));
    while (reader.hasNext()
        && !(reader.isEndElement() && edmNamespace.equals(reader.getNamespaceURI())
        && XmlMetadataConstants.EDM_FUNCTION_IMPORT.equals(reader.getLocalName()))) {
      reader.next();
      if (reader.isStartElement()) {
        extractNamespaces(reader);
        currentHandledStartTagName = reader.getLocalName();
        if (XmlMetadataConstants.EDM_FUNCTION_PARAMETER.equals(currentHandledStartTagName)) {
          functionParameters.add(readFunctionImportParameter(reader));
        } else {
          annotationElements.add(readAnnotationElement(reader));
        }
      }
    }
    if (!annotationElements.isEmpty()) {
      function.setAnnotationElements(annotationElements);
    }
    function.setParameters(functionParameters);
    return function;
  }
View Full Code Here

    List<Schema> schemas = aep.getSchemas();
    assertEquals(1, schemas.size());
    EntityContainerInfo info = aep.getEntityContainerInfo(ModelSharedConstants.CONTAINER_1);
    assertTrue(info.isDefaultEntityContainer());

    FunctionImport funImp = aep.getFunctionImport(ModelSharedConstants.CONTAINER_1, "NoImport");
    assertNull(funImp);

    final FullQualifiedName associationFqn = new FullQualifiedName(
        ModelSharedConstants.NAMESPACE_1, "NoAssociation");
    Association noAssociation = aep.getAssociation(associationFqn);
View Full Code Here

    return entitySets;
  }

  private static List<FunctionImport> createFunctionImports() {
    List<FunctionImport> functionImports = new ArrayList<FunctionImport>();
    FunctionImport functionImport = new FunctionImport();
    functionImport.setName(FUNCTION_IMPORT_NAME_ONE);
    functionImports.add(functionImport);
    functionImport = new FunctionImport();
    functionImport.setName(FUNCTION_IMPORT_NAME_TWO);
    functionImports.add(functionImport);
    return functionImports;
  }
View Full Code Here

    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();

    assertEquals(functionImportList.size(), 1);

    FunctionImport functionImport = functionImportList.get(0);
    assertEquals(functionImport.getName(), "method3");
    assertNotNull(functionImport.getMapping());

    ReturnType returnType = functionImport.getReturnType();
    assertNotNull(returnType);
    assertEquals(EdmMultiplicity.ONE, returnType.getMultiplicity());
    assertEquals(returnType.getTypeName().toString(), EdmSimpleTypeKind.Int32.getFullQualifiedName().toString());
  }
View Full Code Here

    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();

    assertEquals(functionImportList.size(), 1);

    FunctionImport functionImport = functionImportList.get(0);
    assertEquals(functionImport.getName(), "method7");
    assertNotNull(functionImport.getMapping());
    JPAEdmMapping mapping = (JPAEdmMapping) functionImport.getMapping();
    assertEquals(JPACustomProcessorMock.class, mapping.getJPAType());

    ReturnType returnType = functionImport.getReturnType();
    assertNotNull(returnType);
    assertEquals(EdmMultiplicity.ONE, returnType.getMultiplicity());
    assertEquals(returnType.getTypeName().toString(), ODataJPAContextMock.PERSISTENCE_UNIT_NAME + "."
        + JPACustomProcessorMock.edmName);
  }
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.edm.provider.FunctionImport

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.