Exemplo n.º 1
0
 private Entity readEntityInternal(final UriInfoResource uriInfo, final EdmEntitySet entitySet)
     throws DataProvider.DataProviderException {
   // This method will extract the key values and pass them to the data provider
   final UriResourceEntitySet resourceEntitySet =
       (UriResourceEntitySet) uriInfo.getUriResourceParts().get(0);
   return dataProvider.read(entitySet, resourceEntitySet.getKeyPredicates());
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * com.rohitghatol.spring.odata.edm.providers.EntityProvider#getEntitySet
   * (org.apache.olingo.server.api.uri.UriInfo)
   */
  @Override
  public EntitySet getEntitySet(UriInfo uriInfo) {
    List<UriResource> resourcePaths = uriInfo.getUriResourceParts();

    UriResourceEntitySet uriResourceEntitySet =
        (UriResourceEntitySet)
            resourcePaths.get(0); // in our example, the first segment is the EntitySet

    EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();

    EntitySet entitySet = getData(edmEntitySet);

    return entitySet;
  }
Exemplo n.º 3
0
  public static EdmEntitySet getEdmEntitySet(UriInfoResource uriInfo)
      throws ODataApplicationException {

    List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
    // To get the entity set we have to interpret all URI segments
    if (!(resourcePaths.get(0) instanceof UriResourceEntitySet)) {
      // Here we should interpret the whole URI but in this example we do not support navigation so
      // we throw an
      // exception
      throw new ODataApplicationException(
          "Invalid resource type for first segment.",
          HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),
          Locale.ENGLISH);
    }

    UriResourceEntitySet uriResource = (UriResourceEntitySet) resourcePaths.get(0);

    return uriResource.getEntitySet();
  }