use of org.openforis.idm.metamodel.validation.Check in project collect by openforis.
the class DataQueryGenerator method generateValidationCheckQueries.
public List<DataQuery> generateValidationCheckQueries(CollectSurvey survey) {
final List<DataQuery> result = new ArrayList<DataQuery>();
survey.getSchema().traverse(new NodeDefinitionVisitor() {
public void visit(NodeDefinition def) {
if (def instanceof AttributeDefinition) {
for (Check<?> check : ((AttributeDefinition) def).getChecks()) {
DataQuery query = createQuery(def, check);
result.add(query);
}
}
}
});
return result;
}
use of org.openforis.idm.metamodel.validation.Check in project collect by openforis.
the class AttributeDefinitionFormObject method loadFrom.
@Override
public void loadFrom(T source, String languageCode) {
super.loadFrom(source, languageCode);
key = source.isKey();
attributeDefaults = new ArrayList<AttributeDefault>(source.getAttributeDefaults());
CollectSurvey survey = (CollectSurvey) source.getSurvey();
CollectAnnotations annotations = survey.getAnnotations();
phaseToApplyDefaultValue = annotations.getPhaseToApplyDefaultValue(source).name();
editable = annotations.isEditable(source);
measurement = annotations.isMeasurementAttribute(source);
showInMapBalloon = annotations.isShowInMapBalloon(source);
checks = new ArrayList<Check<?>>(source.getChecks());
UIOptions uiOptions = getUIOptions(source);
visibleFields = uiOptions.getVisibleFields(source);
if (source.getReferencedAttribute() != null) {
referencedAttributePath = source.getReferencedAttribute().getPath();
}
}
use of org.openforis.idm.metamodel.validation.Check in project collect by openforis.
the class StateDependencyMap method registerDependencies.
private void registerDependencies(AttributeDefinition attributeDefinition) {
List<AttributeDefault> attributeDefaults = attributeDefinition.getAttributeDefaults();
for (AttributeDefault attributeDefault : attributeDefaults) {
registerDependencies(attributeDefinition, attributeDefault.getCondition(), defaultValueDependencies);
registerDependencies(attributeDefinition, attributeDefault.getExpression(), defaultValueDependencies);
}
List<Check> checks = attributeDefinition.getChecks();
for (Check check : checks) {
registerDependencies(attributeDefinition, check.getCondition(), checkDependencies);
if (check instanceof ComparisonCheck) {
registerDependencies(attributeDefinition, ((ComparisonCheck) check).getEqualsExpression(), checkDependencies);
registerDependencies(attributeDefinition, ((ComparisonCheck) check).getLessThanExpression(), checkDependencies);
registerDependencies(attributeDefinition, ((ComparisonCheck) check).getLessThanOrEqualsExpression(), checkDependencies);
registerDependencies(attributeDefinition, ((ComparisonCheck) check).getGreaterThanExpression(), checkDependencies);
registerDependencies(attributeDefinition, ((ComparisonCheck) check).getGreaterThanOrEqualsExpression(), checkDependencies);
} else if (check instanceof CustomCheck) {
registerDependencies(attributeDefinition, ((CustomCheck) check).getExpression(), checkDependencies);
} else if (check instanceof DistanceCheck) {
registerDependencies(attributeDefinition, ((DistanceCheck) check).getDestinationPointExpression(), checkDependencies);
registerDependencies(attributeDefinition, ((DistanceCheck) check).getMaxDistanceExpression(), checkDependencies);
registerDependencies(attributeDefinition, ((DistanceCheck) check).getMinDistanceExpression(), checkDependencies);
registerDependencies(attributeDefinition, ((DistanceCheck) check).getSourcePointExpression(), checkDependencies);
} else if (check instanceof UniquenessCheck) {
registerDependencies(attributeDefinition, ((UniquenessCheck) check).getExpression(), checkDependencies);
}
}
}
Aggregations