コード例 #1
0
 public ODataEntity findEntity(EdmEntitySet entitySet, ODataKey key) {
   Map<String, Object> entityMap = findEntity(entitySet.getName(), key.toKeyString(false));
   ODataConsumerContext context =
       ODataConsumerContextHelper.initContext(
           consumer, entitySet.getName(), null, key.toKeyString(false));
   return ODataConvertor.convertTo(ODataEntity.class, context, entityMap);
 }
コード例 #2
0
  public Map<String, Object> findEntity(String entityType, Object key) {

    if (config.isVerifyMetadata()) verifier.hasEntityType(entityType);

    ODataConsumerContext context =
        ODataConsumerContextHelper.initEntityTypeContext(consumer, entityType, key);

    Request request =
        new FindEntityRequest(context, config.getProducerUrl())
            .setEntitySet(context.getEntitySet().getName())
            .setId(context.getEntityKey().toKeyString(false));

    Response response = request.send();

    if (response.getStatus() == ODataResponseStatus.OK) {

      return response.convertToEntityMap(context);

    } else throw response.convertToError(context);
  }