Examples of EdmProperty


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

        isAbstract = true;
      }

      Field[] fields = aClass.getDeclaredFields();
      for (Field field : fields) {
        EdmProperty ep = field.getAnnotation(EdmProperty.class);
        if (ep != null) {
          properties.add(createProperty(ep, field, namespace));
          EdmKey eti = field.getAnnotation(EdmKey.class);
          if (eti != null) {
            keyProperties.add(createKeyProperty(ep, field));
View Full Code Here

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

            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

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

                        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

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

        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

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

    return navigationProperty;
  }

  public static EdmProperty mockEdmProperty(final String entityName, final String propertyName) throws EdmException {
    EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);

    if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MINT) ||
        propertyName.equals(JPATypeMock.PROPERTY_NAME_MSTRING) ||
        propertyName.equals(JPATypeMock.PROPERTY_NAME_MDATETIME) ||
        propertyName.equals(JPATypeMock.PROPERTY_NAME_MBLOB) ||
        propertyName.equals(JPATypeMock.PROPERTY_NAME_CLOB) ||
        propertyName.equals(JPATypeMock.PROPERTY_NAME_MCARRAY) ||
        propertyName.equals(JPATypeMock.PROPERTY_NAME_MC) ||
        propertyName.equals(JPATypeMock.PROPERTY_NAME_MCHAR) ||
        propertyName.equals(JPATypeMock.PROPERTY_NAME_MCHARARRAY) ||
        propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT) ||
        propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT) ||
        propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID) ||
        propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MLONG) ||
        propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTE) ||
        propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE) ||
        propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY)) {

      EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
      EasyMock.expect(edmProperty.getType()).andReturn(edmType).anyTimes();
      EasyMock.expect(edmType.getKind()).andReturn(EdmTypeKind.SIMPLE).anyTimes();
      if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MSTRING) ||
          propertyName.equals(JPATypeMock.PROPERTY_NAME_MCARRAY) ||
          propertyName.equals(JPATypeMock.PROPERTY_NAME_MC) ||
          propertyName.equals(JPATypeMock.PROPERTY_NAME_MCHAR) ||
          propertyName.equals(JPATypeMock.PROPERTY_NAME_MCHARARRAY)) {
        EasyMock.<Class<?>> expect(edmType.getDefaultType()).andReturn(String.class).anyTimes();
      } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MBLOB)) {
        EasyMock.<Class<?>> expect(edmType.getDefaultType()).andReturn(Blob.class).anyTimes();
      } else {
        EasyMock.<Class<?>> expect(edmType.getDefaultType()).andReturn(Integer.class).anyTimes();
      }

      EasyMock.expect(edmType.isCompatible(EasyMock.isA(EdmSimpleType.class))).andReturn(true).anyTimes();
      EasyMock.replay(edmType);
      EasyMock.expect(edmProperty.getName()).andReturn(propertyName).anyTimes();
      EasyMock.expect(edmProperty.getMapping()).andReturn((EdmMapping) mockEdmMapping(entityName, propertyName, null))
          .anyTimes();

    } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE) ||
        propertyName.equals(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)) {
      EdmComplexType complexType = mockComplexType(propertyName);

      EasyMock.expect(edmProperty.getType()).andReturn(complexType).anyTimes();
      EasyMock.expect(edmProperty.getName()).andReturn(propertyName).anyTimes();
      EasyMock.expect(edmProperty.getMapping()).andReturn((EdmMapping) mockEdmMapping(null, propertyName, null))
          .anyTimes();

    }

    EasyMock.replay(edmProperty);
View Full Code Here

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

  @Test
  public void readIntegerProperty() throws Exception {
    String xml = "<Age xmlns=\"" + Edm.NAMESPACE_D_2007_08 + "\">67</Age>";
    XMLStreamReader reader = createReaderForTest(xml, true);
    final EdmProperty property =
        (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");

    Map<String, Object> resultMap = new XmlPropertyConsumer().readProperty(reader, property, false, null);

    assertEquals(Integer.valueOf(67), resultMap.get("Age"));
View Full Code Here

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

  @Test
  public void readIntegerPropertyAsLong() throws Exception {
    String xml = "<Age xmlns=\"" + Edm.NAMESPACE_D_2007_08 + "\">67</Age>";
    XMLStreamReader reader = createReaderForTest(xml, true);
    final EdmProperty property =
        (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");

    Map<String, Object> typeMappings = createTypeMappings("Age", Long.class);
    Map<String, Object> resultMap = new XmlPropertyConsumer().readProperty(reader, property, false, typeMappings,
        null);
View Full Code Here

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

  @Test
  public void readIntegerPropertyWithNullMapping() throws Exception {
    String xml = "<Age xmlns=\"" + Edm.NAMESPACE_D_2007_08 + "\">67</Age>";
    XMLStreamReader reader = createReaderForTest(xml, true);
    final EdmProperty property =
        (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");

    Map<String, Object> typeMappings = null;
    Map<String, Object> resultMap = new XmlPropertyConsumer().readProperty(reader, property, false, typeMappings,
        null);
View Full Code Here

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

  @Test
  public void readIntegerPropertyWithEmptyMapping() throws Exception {
    String xml = "<Age xmlns=\"" + Edm.NAMESPACE_D_2007_08 + "\">67</Age>";
    XMLStreamReader reader = createReaderForTest(xml, true);
    final EdmProperty property =
        (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");

    Map<String, Object> typeMappings = new HashMap<String, Object>();
    Map<String, Object> resultMap = new XmlPropertyConsumer().readProperty(reader, property, false, typeMappings,
        null);
View Full Code Here

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

  @Test
  public void readStringProperty() throws Exception {
    String xml = "<EmployeeName xmlns=\"" + Edm.NAMESPACE_D_2007_08 + "\">Max Mustermann</EmployeeName>";
    XMLStreamReader reader = createReaderForTest(xml, true);
    final EdmProperty property =
        (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("EmployeeName");

    Map<String, Object> resultMap = new XmlPropertyConsumer().readProperty(reader, property, false, null);

    assertEquals("Max Mustermann", resultMap.get("EmployeeName"));
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.