@Override
  public void onSaveScript() {
    VariableDuplicationHelper variableDuplicationHelper = new VariableDuplicationHelper(variable);
    VariableDto newVariable = variableDuplicationHelper.getDerivedVariable();
    VariableDtos.setScript(newVariable, scriptEditorPresenter.getScript());
    newVariable.setValueType(scriptEditorPresenter.getValueEntityType().getLabel());
    newVariable.setIsRepeatable(scriptEditorPresenter.isRepeatable());

    compileScript(newVariable);
  }
 @Override
 public VariableDto getVariableDto(String script) {
   VariableDto variableDto = VariableDto.create();
   variableDto.setName(variableName.getValue());
   variableDto.setIsRepeatable(repeatableCheckbox.getValue());
   if (repeatableCheckbox.getValue()) variableDto.setOccurrenceGroup(occurrenceGroup.getValue());
   variableDto.setValueType(valueType.getValue(valueType.getSelectedIndex()));
   variableDto.setEntityType(entityType);
   variableDto.setMimeType(mimeType.getValue());
   variableDto.setUnit(unit.getValue());
   VariableDtos.setScript(variableDto, script);
   return variableDto;
 }
 private void updateDerivedVariableDisplay() {
   // if table is a view, check for a script attribute
   if (table == null || !table.hasViewLink()) {
     getView().setDerivedVariable(false, "");
     return;
   }
   String script = VariableDtos.getScript(variable);
   getView().setDerivedVariable(true, script);
   scriptEditorPresenter.setTable(table);
   scriptEditorPresenter.setScript(script);
   scriptEditorPresenter.setRepeatable(variable.getIsRepeatable());
   scriptEditorPresenter.setValueEntityType(variable.getValueType());
   scriptEditorPresenter.setCategories(variable.getCategoriesArray());
 }
  private void findDerivedFromVariable() {
    String derivedFromUri = VariableDtos.getDerivedFrom(getDerivedVariable());
    if (derivedFromUri == null) {
      loadTables();
    } else {
      ResponseCodeCallback failureCallback =
          new ResponseCodeCallback() {

            @Override
            public void onResponseCode(Request request, Response response) {
              loadTables();
            }
          };

      ResourceRequestBuilderFactory.<VariableDto>newBuilder()
          .forResource(derivedFromUri)
          .get()
          .withCallback(
              new ResourceCallback<VariableDto>() {
                @Override
                public void onResource(Response response, VariableDto derivedFromVariable) {
                  preSelectedVariable = derivedFromVariable.getName();

                  ResourceRequestBuilderFactory.<TableDto>newBuilder()
                      .forResource(derivedFromVariable.getParentLink().getLink())
                      .get()
                      .withCallback(
                          new ResourceCallback<TableDto>() {
                            @Override
                            public void onResource(Response response, TableDto tableDto) {
                              table = tableDto;
                              loadTables();
                            }
                          })
                      .send();
                }
              }) //
          .withCallback(Response.SC_NOT_FOUND, failureCallback) //
          .withCallback(Response.SC_FORBIDDEN, failureCallback) //
          .withCallback(Response.SC_INTERNAL_SERVER_ERROR, failureCallback) //
          .withCallback(Response.SC_BAD_REQUEST, failureCallback) //
          .send();
    }
  }
示例#5
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());
   }
 } //
示例#6
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());
   }
 } //
 private void onVariableSelection() {
   setOriginalVariable(variablesByName.get(getView().getSelectedVariable()));
   VariableDtos.setDerivedFrom(getDerivedVariable(), getOriginalVariable());
 }