ResourceRequestBuilder<? extends JavaScriptObject> createResourceRequestBuilder(
      TableCompareDto tableCompareDto, JsArray<VariableDto> variables) {
    TableDto compared = tableCompareDto.getCompared();
    if (!tableCompareDto.hasWithTable()) {
      // new table
      TableDto newTableDto = TableDto.create();
      newTableDto.setName(compared.getName());
      newTableDto.setEntityType(compared.getEntityType());
      newTableDto.setVariablesArray(variables);
      UriBuilder ub = UriBuilder.create().segment("datasource", targetDatasourceName, "tables");
      return ResourceRequestBuilderFactory.newBuilder()
          .post()
          .forResource(ub.build())
          .withResourceBody(stringify(newTableDto));
    }

    UriBuilder uriBuilder =
        tableCompareDto.getWithTable().hasViewLink() //
            ? UriBuilders.DATASOURCE_VIEW_VARIABLES.create() //
            : UriBuilders.DATASOURCE_TABLE_VARIABLES.create();

    return ResourceRequestBuilderFactory.newBuilder() //
        .forResource(uriBuilder.build(targetDatasourceName, compared.getName())) //
        .withResourceBody(stringify(variables)) //
        .post();
  }
Пример #2
0
    private String getUri() {
      UriBuilder uriBuilder =
          tableIsView()
              ? UriBuilders.DATASOURCE_VIEW_VARIABLES.create()
              : UriBuilders.DATASOURCE_TABLE_VARIABLES.create();

      for (int i = nb_deleted, added = 0;
          i < variableNames.length() && added < BATCH_SIZE;
          i++, added++) {
        uriBuilder.query("variable", variableNames.get(i));
      }

      return uriBuilder.build(table.getDatasourceName(), table.getName());
    }