Exemplo n.º 1
0
  @Override
  public void crossJoin(DataRequest request, List<String> entitySetNames, ODataResponse response)
      throws ODataLibraryException, ODataApplicationException {

    final ODataSQLBuilder visitor =
        new ODataSQLBuilder(
            this.odata,
            getClient().getMetadataStore(),
            this.prepared,
            true,
            request.getODataRequest().getRawBaseUri(),
            this.serviceMetadata,
            this.nameGenerator);
    visitor.visit(request.getUriInfo());

    try {
      Query query = visitor.selectQuery();
      BaseResponse queryResponse = executeQuery(request, request.isCountRequest(), visitor, query);
      ContextURL.Builder builder =
          new ContextURL.Builder().asCollection().entitySetOrSingletonOrType("Edm.ComplexType");

      EdmComplexResponse complexResponse =
          EdmComplexResponse.getInstance(request, builder.build(), false, response);
      sendResults(request, visitor, queryResponse, complexResponse);
    } catch (Exception e) {
      throw new ODataApplicationException(
          e.getMessage(),
          HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(),
          Locale.getDefault(),
          e);
    }
  }
Exemplo n.º 2
0
  @Override
  public void upsertEntity(
      DataRequest request, Entity entity, boolean merge, String entityETag, EntityResponse response)
      throws ODataLibraryException, ODataApplicationException {

    final ODataSQLBuilder visitor =
        new ODataSQLBuilder(
            this.odata,
            getClient().getMetadataStore(),
            this.prepared,
            true,
            request.getODataRequest().getRawBaseUri(),
            this.serviceMetadata,
            this.nameGenerator);
    visitor.visit(request.getUriInfo());

    final EntityCollectionResponse queryResponse;
    try {
      Query query = visitor.selectQuery();
      queryResponse =
          (EntityCollectionResponse)
              executeQuery(request, request.isCountRequest(), visitor, query);
    } catch (Exception e) {
      throw new ODataApplicationException(
          e.getMessage(),
          HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(),
          Locale.getDefault(),
          e);
    }

    if (!queryResponse.getEntities().isEmpty()) {
      updateEntity(request, entity, merge, entityETag, response);
    } else {
      createEntity(request, entity, response);
    }
  }