use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class AttributeDefinitionFormValidator method validateReferencedAttribute.
private void validateReferencedAttribute(ValidationContext ctx) {
String referencedAttributePath = getValue(ctx, REFERENCED_ATTRIBUTE_PATH_FIELD, false);
if (StringUtils.isNotBlank(referencedAttributePath)) {
AttributeDefinition attrDef = (AttributeDefinition) getEditedNode(ctx);
CollectSurvey survey = attrDef.getSurvey();
AttributeDefinition referencedAttribute = (AttributeDefinition) survey.getSchema().getDefinitionByPath(referencedAttributePath);
if (referencedAttribute == null) {
addInvalidMessage(ctx, REFERENCED_ATTRIBUTE_PATH_FIELD, Labels.getLabel(REFERENCED_ATTRIBUTE_DELETED_MESSAGE_KEY));
} else {
SurveyValidationResult validationResult = new SurveyValidator().validateReferencedKeyAttribute(attrDef, referencedAttribute);
if (validationResult.getFlag() == Flag.ERROR) {
addInvalidMessage(ctx, REFERENCED_ATTRIBUTE_PATH_FIELD, Labels.getLabel(validationResult.getMessageKey(), validationResult.getMessageArgs()));
}
}
}
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class SRSFormValidator method validateWKT.
private boolean validateWKT(ValidationContext ctx) {
String wkt = (String) getValue(ctx, WKT_FIELD);
CollectSurvey survey = getSurvey(ctx);
SurveyContext context = survey.getContext();
CoordinateOperations coordinateOperations = context.getCoordinateOperations();
try {
coordinateOperations.validateWKT(wkt);
return true;
} catch (Exception e) {
String message = Labels.getLabel("survey.srs.validation.error.invalid_wkt", new String[] { e.getMessage() });
addInvalidMessage(ctx, WKT_FIELD, message);
return false;
}
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class SurveyFileFormValidator method loadSurveyFilesDifferentFromThis.
private List<SurveyFile> loadSurveyFilesDifferentFromThis(ValidationContext ctx) {
List<SurveyFile> result = new ArrayList<SurveyFile>();
SurveyFileVM vm = getVM(ctx);
CollectSurvey survey = vm.getSurvey();
SurveyManager surveyManager = getSurveyManager(ctx);
List<SurveyFile> surveyFiles = surveyManager.loadSurveyFileSummaries(survey);
SurveyFile editedSurveyFile = vm.getEditedItem();
for (SurveyFile surveyFile : surveyFiles) {
if (!surveyFile.getId().equals(editedSurveyFile.getId())) {
result.add(surveyFile);
}
}
return result;
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class UnitFormValidator method validateNameUniqueness.
protected boolean validateNameUniqueness(ValidationContext ctx) {
SurveyObjectBaseVM<Unit> viewModel = getVM(ctx);
Unit editedItem = viewModel.getEditedItem();
CollectSurvey survey = viewModel.getSurvey();
String name = (String) getValue(ctx, NAME_FIELD);
Unit existingItem = survey.getUnit(name);
if (existingItem != null && existingItem.getId() != editedItem.getId()) {
String message = Labels.getLabel(ITEM_NAME_ALREADY_DEFINED_MESSAGE_KEY);
addInvalidMessage(ctx, NAME_FIELD, message);
return false;
} else {
return true;
}
}
use of org.openforis.collect.model.CollectSurvey in project collect by openforis.
the class NodeDefinitionFormObject method getUIOptions.
protected UIOptions getUIOptions(NodeDefinition nodeDefn) {
CollectSurvey survey = (CollectSurvey) nodeDefn.getSurvey();
UIOptions uiOptions = survey.getUIOptions();
return uiOptions;
}
Aggregations