use of org.openforis.collect.model.FieldSymbol in project collect by openforis.
the class CollectNumberValueUnitValidator method evaluate.
@Override
public ValidationResultFlag evaluate(NumberAttribute<?, ?> attribute) {
CollectRecord record = (CollectRecord) attribute.getRecord();
Step step = record.getStep();
ValidationResultFlag resultFlag = super.evaluate(attribute);
if (resultFlag == ValidationResultFlag.ERROR && step == Step.ENTRY) {
Character unitSymbolChar = attribute.getUnitField().getSymbol();
FieldSymbol unitSymbol = FieldSymbol.valueOf(unitSymbolChar);
if (unitSymbol != null && unitSymbol.isReasonBlank()) {
return ValidationResultFlag.WARNING;
}
}
return resultFlag;
}
use of org.openforis.collect.model.FieldSymbol in project collect by openforis.
the class CollectValidator method isReasonBlankAlwaysSpecified.
static boolean isReasonBlankAlwaysSpecified(Attribute<?, ?> attribute) {
int fieldCount = 0;
// ignore unit for numeric attributes
if (attribute instanceof NumberAttribute || attribute instanceof CodeAttribute) {
fieldCount = 1;
} else if (attribute instanceof NumericRangeAttribute) {
fieldCount = 2;
} else {
fieldCount = attribute.getFieldCount();
}
AttributeDefinition defn = attribute.getDefinition();
CollectSurvey survey = (CollectSurvey) defn.getSurvey();
UIOptions uiOptions = survey.getUIOptions();
for (int i = 0; i < fieldCount; i++) {
Field<?> field = attribute.getField(i);
boolean visible = uiOptions.isVisibleField(defn, field.getName());
if (visible) {
FieldSymbol symbol = FieldSymbol.valueOf(field.getSymbol());
if (symbol == null || !symbol.isReasonBlank()) {
return false;
}
}
}
return true;
}
use of org.openforis.collect.model.FieldSymbol in project collect by openforis.
the class DataHandler method setField.
protected void setField(Field<?> fld) {
String value = getXmlValue();
fld.setValueFromString(value);
String remarks = attributes.get(ATTRIBUTE_REMARKS);
fld.setRemarks(remarks);
String s = attributes.get(ATTRIBUTE_SYMBOL);
if (StringUtils.isNotBlank(s)) {
char c = s.charAt(0);
FieldSymbol fs = FieldSymbol.valueOf(c);
if (fs != null) {
fld.setSymbol(fs.getCode());
}
}
Integer stateValue = getNodeState();
if (stateValue != null && stateValue > 0) {
fld.getState().set(stateValue);
}
fld.getAttribute().updateSummaryInfo();
}
use of org.openforis.collect.model.FieldSymbol in project collect by openforis.
the class CollectNumericRangeUnitValidator method evaluate.
@Override
public ValidationResultFlag evaluate(NumericRangeAttribute<?, ?> attribute) {
CollectRecord record = (CollectRecord) attribute.getRecord();
Step step = record.getStep();
ValidationResultFlag resultFlag = super.evaluate(attribute);
if (resultFlag == ValidationResultFlag.ERROR && step == Step.ENTRY) {
Character unitSymbolChar = attribute.getUnitField().getSymbol();
FieldSymbol unitSymbol = FieldSymbol.valueOf(unitSymbolChar);
if (unitSymbol != null && unitSymbol.isReasonBlank()) {
return ValidationResultFlag.WARNING;
}
}
return resultFlag;
}
Aggregations