コード例 #1
0
  private void readGeospatial(final ODataPubFormat format) {
    final InputStream input =
        getClass().getResourceAsStream("AllGeoTypesSet_-8." + getSuffix(format));
    final ODataEntity entity =
        getClient()
            .getBinder()
            .getODataEntity(
                getClient()
                    .getDeserializer()
                    .toEntry(input, getClient().getResourceFactory().entryClassForFormat(format)));
    assertNotNull(entity);

    boolean found = false;
    for (ODataProperty property : entity.getProperties()) {
      if ("GeogMultiLine".equals(property.getName())) {
        found = true;
        assertTrue(property.hasPrimitiveValue());
        assertEquals(
            EdmSimpleType.GeographyMultiLineString.toString(),
            property.getPrimitiveValue().getTypeName());
      }
    }
    assertTrue(found);

    final ODataEntity written =
        getClient()
            .getBinder()
            .getODataEntity(
                getClient()
                    .getBinder()
                    .getEntry(
                        entity, getClient().getResourceFactory().entryClassForFormat(format)));
    assertEquals(entity, written);
  }
  @Override
  public ODataPropertyUpdateRequest getPropertyPrimitiveValueUpdateRequest(
      final URI targetURI, final ODataProperty property) {

    if (!property.hasPrimitiveValue()) {
      throw new IllegalArgumentException("A primitive value is required");
    }

    final ODataPropertyUpdateRequest req;

    if (client.getConfiguration().isUseXHTTPMethod()) {
      req = new ODataPropertyUpdateRequest(client, HttpMethod.POST, targetURI, property);
      req.setXHTTPMethod(HttpMethod.PUT.name());
    } else {
      req = new ODataPropertyUpdateRequest(client, HttpMethod.PUT, targetURI, property);
    }

    return req;
  }