use of org.openforis.collect.manager.validation.SurveyValidator.SurveyValidationResults in project collect by openforis.
the class SurveyExportParametersVM method validateSurvey.
private void validateSurvey(CollectSurvey survey, SurveyValidator validator, final SuccessHandler successHandler, boolean showWarningConfirm) {
SurveyValidationResults validationResults = validator.validate(survey);
if (validationResults.isOk()) {
successHandler.onSuccess();
} else {
final Window validationResultsPopUp = SurveyValidationResultsVM.showPopUp(validationResults, showWarningConfirm && !validationResults.hasErrors());
validationResultsPopUp.addEventListener(SurveyValidationResultsVM.CONFIRM_EVENT_NAME, new EventListener<ConfirmEvent>() {
public void onEvent(ConfirmEvent event) throws Exception {
successHandler.onSuccess();
closePopUp(validationResultsPopUp);
}
});
}
}
use of org.openforis.collect.manager.validation.SurveyValidator.SurveyValidationResults in project collect by openforis.
the class SurveySelectVM method publishSelectedSurvey.
@Command
public void publishSelectedSurvey(@ContextParam(ContextType.BINDER) final Binder binder) throws IOException {
final CollectSurvey survey = loadSelectedSurvey();
final CollectSurvey publishedSurvey = selectedSurvey.isPublished() ? surveyManager.getByUri(survey.getUri()) : null;
SurveyValidator validator = getSurveyValidator(survey);
SurveyValidationResults validationResults = validator.validateCompatibility(publishedSurvey, survey);
if (validationResults.isOk()) {
askConfirmThenPublishSurvey(survey, binder);
} else {
final Window validationResultsPopUp = SurveyValidationResultsVM.showPopUp(validationResults, !validationResults.hasErrors());
validationResultsPopUp.addEventListener(SurveyValidationResultsVM.CONFIRM_EVENT_NAME, new EventListener<ConfirmEvent>() {
public void onEvent(ConfirmEvent event) throws Exception {
CollectSurvey survey = loadSelectedSurvey();
askConfirmThenPublishSurvey(survey, binder);
closePopUp(validationResultsPopUp);
}
});
}
}
use of org.openforis.collect.manager.validation.SurveyValidator.SurveyValidationResults in project collect by openforis.
the class SurveyEditVM method checkValidity.
/**
* Returns true if the validation didn't give any errors, false if a confirm PopUp will be shown
*/
private boolean checkValidity(boolean showConfirm, final Runnable runIfValid, String confirmButtonLabel, boolean showWarnings) {
SurveyValidator surveyValidator = getSurveyValidator(survey);
ValidationParameters validationParameters = new ValidationParameters();
validationParameters.setWarnOnEmptyCodeLists(showWarnings);
validationParameters.setWarnOnUnusedCodeLists(showWarnings);
SurveyValidationResults results = surveyValidator.validate(survey, validationParameters);
if (results.hasErrors() || results.hasWarnings()) {
final Window validationResultsPopUp = SurveyValidationResultsVM.showPopUp(results, showConfirm, confirmButtonLabel);
validationResultsPopUp.addEventListener(SurveyValidationResultsVM.CONFIRM_EVENT_NAME, new EventListener<ConfirmEvent>() {
public void onEvent(ConfirmEvent event) throws Exception {
runIfValid.run();
closePopUp(validationResultsPopUp);
}
});
return false;
} else {
runIfValid.run();
return true;
}
}
Aggregations