Exemplo n.º 1
0
 @Override
 public void onFilterUpdate(String filter) {
   if (Strings.isNullOrEmpty(filter)) {
     getView().setVocabularies(taxonomy.getVocabulariesArray());
   } else {
     JsArray<VocabularyDto> filtered = JsArrays.create();
     for (VocabularyDto vocabulary : JsArrays.toIterable(taxonomy.getVocabulariesArray())) {
       if (vocabularyMatches(vocabulary, filter)) {
         filtered.push(vocabulary);
       }
     }
     getView().setVocabularies(filtered);
   }
 }
Exemplo n.º 2
0
  @Override
  public void onDeleteAttribute(List<JsArray<AttributeDto>> selectedItems) {
    VariableDto dto = getVariableDto();

    JsArray<AttributeDto> filteredAttributes = JsArrays.create().cast();
    List<AttributeDto> allAttributes = JsArrays.toList(dto.getAttributesArray());

    for (AttributeDto attribute : allAttributes) {
      boolean keep = true;
      for (JsArray<AttributeDto> toRemove : selectedItems) {
        if (attribute.getName().equals(toRemove.get(0).getName())
            && attribute.getNamespace().equals(toRemove.get(0).getNamespace())) {
          keep = false;
          break;
        }
      }

      if (keep) {
        filteredAttributes.push(attribute);
      }
    }

    dto.setAttributesArray(filteredAttributes);

    UriBuilder uriBuilder =
        table.hasViewLink()
            ? UriBuilders.DATASOURCE_VIEW_VARIABLE.create()
            : UriBuilders.DATASOURCE_TABLE_VARIABLE.create();

    ResourceRequestBuilderFactory.newBuilder() //
        .forResource(
            uriBuilder.build(table.getDatasourceName(), table.getName(), variable.getName())) //
        .withResourceBody(VariableDto.stringify(dto)) //
        .withCallback(
            SC_OK,
            new ResponseCodeCallback() {
              @Override
              public void onResponseCode(Request request, Response response) {
                fireEvent(new VariableRefreshEvent());
              }
            }) //
        .withCallback(SC_BAD_REQUEST, new ErrorResponseCallback(getView().asWidget())) //
        .put()
        .send();
  }
Exemplo n.º 3
0
  @Override
  public void onDeleteVariables(List<VariableDto> variableDtos) {
    if (variableDtos.isEmpty()) {
      fireEvent(NotificationEvent.newBuilder().error("DeleteVariableSelectAtLeastOne").build());
    } else {
      JsArrayString variableNames = JsArrays.create().cast();
      for (VariableDto variable : variableDtos) {
        variableNames.push(variable.getName());
      }

      deleteVariablesConfirmation = new RemoveVariablesRunnable(variableNames);

      fireEvent(
          ConfirmationRequiredEvent.createWithMessages(
              deleteVariablesConfirmation,
              translationMessages.removeVariables(),
              translationMessages.confirmRemoveVariables(variableNames.length())));
    }
  }
 public Request compare(
     String sourceDatasourceName,
     @SuppressWarnings("ParameterHidesMemberVariable") String targetDatasourceName,
     DatasourceCreatedCallback datasourceCreatedCallback,
     DatasourceFactoryDto factory,
     DatasourceDto datasourceResource) {
   this.targetDatasourceName = targetDatasourceName;
   getView().clearDisplay();
   authorizedComparedTables = JsArrays.create();
   String resourceUri =
       UriBuilder.create()
           .segment("datasource", sourceDatasourceName, "compare", targetDatasourceName)
           .build();
   return ResourceRequestBuilderFactory.<DatasourceCompareDto>newBuilder() //
       .forResource(resourceUri) //
       .get() //
       .withCallback(
           new DatasourceCompareResourceCallback(
               datasourceCreatedCallback, factory, datasourceResource)) //
       .withCallback(SC_INTERNAL_SERVER_ERROR, new CompareErrorRequestCallback()) //
       .send();
 }
Exemplo n.º 5
0
 @Override
 protected JsArray<AttributeDto> getAttributes(AttributeDto object) {
   JsArray<AttributeDto> attrs = JsArrays.create();
   attrs.push(object);
   return attrs;
 }