예제 #1
0
 @Override
 public void onResponseCode(Request request, Response response) {
   if (response.getStatusCode() == SC_CREATED) {
     String location = response.getHeader("Location");
     String jobId = location.substring(location.lastIndexOf('/') + 1);
     getEventBus()
         .fireEvent(
             NotificationEvent.newBuilder()
                 .info("DataImportationProcessLaunched")
                 .args(jobId)
                 .build());
   } else {
     getEventBus().fireEvent(NotificationEvent.newBuilder().error(response.getText()).build());
   }
 }
예제 #2
0
 @Override
 public void onResponseCode(Request request, Response response) {
   fireEvent(
       NotificationEvent.newBuilder()
           .error(TranslationsUtils.replaceArguments(translations.variableNotFound(), name))
           .build());
 }
 private boolean addValueMapEntry(
     @Nullable Number lower, @Nullable Number upper, String newValue) {
   if (!numberType.addValueMapEntry(derivationHelper, lower, upper, newValue)) {
     fireEvent(NotificationEvent.newBuilder().error(translations.rangeOverlap()).build());
     return false;
   }
   return true;
 }
 @Override
 public void onResponseCode(Request request, Response response) {
   getView().hideDialog();
   getEventBus().fireEvent(new TableIndicesRefreshEvent());
   if (response.getStatusCode() != Response.SC_OK) {
     getEventBus().fireEvent(NotificationEvent.newBuilder().error(response.getText()).build());
   }
 }
 @Override
 public void onResponseCode(Request request, Response response) {
   getEventBus()
       .fireEvent(
           NotificationEvent.newBuilder()
               .error("DataImportFailed")
               .args(response.getText())
               .build());
 }
 @SuppressWarnings("MethodOnlyUsedFromInnerClass")
 private boolean addValueMapEntry(@Nullable String value, String newValue) {
   if (derivationHelper.hasValueMapEntryWithValue(value)) {
     fireEvent(NotificationEvent.newBuilder().error(translations.valueMapAlreadyAdded()).build());
     return false;
   }
   numberType.addValueMapEntry(derivationHelper, value, newValue);
   return true;
 }
예제 #7
0
 @Override
 public void onAddVariablesToView(List<VariableDto> variableDtos) {
   if (variableDtos.isEmpty()) {
     fireEvent(NotificationEvent.newBuilder().error("CopyVariableSelectAtLeastOne").build());
   } else {
     VariablesToViewPresenter variablesToViewPresenter = variablesToViewProvider.get();
     variablesToViewPresenter.initialize(table, variableDtos);
   }
 }
예제 #8
0
    @Override
    public boolean validateComparedDatasourcesReport() {
      if (comparedDatasourcesReportPresenter.getSelectedTables().isEmpty()) {
        getEventBus()
            .fireEvent(NotificationEvent.newBuilder().error("TableSelectionIsRequired").build());
        return false;
      }
      ImportConfig localImportConfig = transientDatasourceHandler.getImportConfig();
      datasourceValuesStepPresenter.setDatasource(
          localImportConfig.getTransientDatasourceName(),
          comparedDatasourcesReportPresenter.getSelectedTables());

      return comparedDatasourcesReportPresenter.canBeSubmitted();
    }
  @SuppressWarnings("unchecked")
  public NotificationEvent build(ClientErrorDto error) {

    if (error.getExtension(JavaScriptErrorDto.ClientErrorDtoExtensions.errors) != null) {
      JsArray<JavaScriptErrorDto> errors =
          (JsArray<JavaScriptErrorDto>)
              error.getExtension(JavaScriptErrorDto.ClientErrorDtoExtensions.errors);

      return NotificationEvent.newBuilder()
          .error("JavascriptError")
          .args(
              errors.get(0).getSourceName(), //
              errors.get(0).getMessage(), //
              String.valueOf(errors.get(0).getLineNumber()), //
              String.valueOf(errors.get(0).getColumnNumber()))
          .build();
    }

    return NotificationEvent.newBuilder()
        .error(error.getStatus())
        .args(error.getArgumentsArray())
        .build();
  }
예제 #10
0
    @Override
    public void onResponseCode(Request request, Response response) {
      fireEvent(NotificationEvent.newBuilder().warn("NoSuchVariable").args(variableName).build());

      PlaceRequest.Builder builder =
          new PlaceRequest.Builder()
              .nameToken(Places.PROJECT)
              .with(ParameterTokens.TOKEN_NAME, datasourceName) //
              .with(
                  ParameterTokens.TOKEN_TAB,
                  ProjectPresenter.Display.ProjectTab.TABLES.toString()) //
              .with(ParameterTokens.TOKEN_PATH, datasourceName + "." + tableName);

      placeManager.revealPlace(builder.build());
    }
 @Override
 public boolean validate() {
   List<String> errorMessages = new ArrayList<>();
   // validate that 1 radio is selected
   if (!getView().rangeSelected()
       && !getView().discreteSelected()
       && !getView().manualSelected()) {
     errorMessages.add(translations.selectDerivationMethod());
   }
   if (getView().rangeSelected()) {
     validateRangeForm(errorMessages);
   }
   if (!errorMessages.isEmpty()) {
     fireEvent(NotificationEvent.newBuilder().error(errorMessages).build());
   }
   return errorMessages.isEmpty();
 }
    @Override
    public void onClick(ClickEvent event) {
      List<String> errorMessages = new ArrayList<>();
      validateValueMappingValues(errorMessages);

      if (errorMessages.isEmpty()) {
        boolean added =
            getView().addRangeSelected()
                ? addValueMapEntry(
                    getView().getLowerValue(), getView().getUpperValue(), getView().getNewValue())
                : addValueMapEntry(
                    numberType.formatNumber(getView().getDiscreteValue()), getView().getNewValue());
        if (added) {
          getView().refreshValuesMapDisplay();
        }
      } else {
        fireEvent(NotificationEvent.newBuilder().error(errorMessages).build());
      }
    }
예제 #13
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())));
    }
  }
예제 #14
0
 @Override
 public void onResource(Response response, VariableDto crossWithVariable) {
   // check cross variable is valid
   VariableDtos.VariableNature nature = VariableDtos.nature(crossWithVariable);
   if (nature == VariableDtos.VariableNature.CATEGORICAL
       || nature == VariableDtos.VariableNature.CONTINUOUS) {
     ContingencyTablePresenter crossVariablePresenter = crossVariableProvider.get();
     crossVariablePresenter.initialize(table, variableDto, crossWithVariable);
     setInSlot(Display.Slots.ContingencyTable, crossVariablePresenter);
   } else {
     fireEvent(
         NotificationEvent.newBuilder()
             .error(
                 TranslationsUtils.replaceArguments(
                     translations.variableNotCategoricalNorContinuous(),
                     crossWithVariable.getName()))
             .build());
   }
 } //
예제 #15
0
 @Override
 public void onResource(Response response, final VariableDto variableDto) {
   // check selected variable is valid
   if (VariableDtos.nature(variableDto) == VariableDtos.VariableNature.CATEGORICAL) {
     ResourceRequestBuilderFactory.<VariableDto>newBuilder() //
         .forResource(
             UriBuilders.DATASOURCE_TABLE_VARIABLE
                 .create()
                 .build(table.getDatasourceName(), table.getName(), crossWithVariableName)) //
         .get() //
         .withCallback(new CrossVariableCallback(variableDto))
         .withCallback(
             new VariableNotFoundCallback(crossWithVariableName), Response.SC_NOT_FOUND) //
         .send();
   } else {
     fireEvent(
         NotificationEvent.newBuilder()
             .error(
                 TranslationsUtils.replaceArguments(
                     translations.variableNotCategorical(), variableDto.getName()))
             .build());
   }
 } //
예제 #16
0
 @Override
 public void onResponseCode(Request request, Response response) {
   fireEvent(
       NotificationEvent.newBuilder().error("TaxonomyNotFound").args(taxonomyName).build());
 }