Search in sources :

Example 1 with Check

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;
}
Also used : ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) Check(org.openforis.idm.metamodel.validation.Check) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) NodeDefinitionVisitor(org.openforis.idm.metamodel.NodeDefinitionVisitor)

Example 2 with Check

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();
    }
}
Also used : UIOptions(org.openforis.collect.metamodel.ui.UIOptions) AttributeDefault(org.openforis.idm.metamodel.AttributeDefault) Check(org.openforis.idm.metamodel.validation.Check) CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 3 with Check

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);
        }
    }
}
Also used : CustomCheck(org.openforis.idm.metamodel.validation.CustomCheck) DistanceCheck(org.openforis.idm.metamodel.validation.DistanceCheck) UniquenessCheck(org.openforis.idm.metamodel.validation.UniquenessCheck) AttributeDefault(org.openforis.idm.metamodel.AttributeDefault) CustomCheck(org.openforis.idm.metamodel.validation.CustomCheck) UniquenessCheck(org.openforis.idm.metamodel.validation.UniquenessCheck) Check(org.openforis.idm.metamodel.validation.Check) DistanceCheck(org.openforis.idm.metamodel.validation.DistanceCheck) ComparisonCheck(org.openforis.idm.metamodel.validation.ComparisonCheck) ComparisonCheck(org.openforis.idm.metamodel.validation.ComparisonCheck)

Aggregations

Check (org.openforis.idm.metamodel.validation.Check)3 AttributeDefault (org.openforis.idm.metamodel.AttributeDefault)2 ArrayList (java.util.ArrayList)1 CollectAnnotations (org.openforis.collect.metamodel.CollectAnnotations)1 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)1 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)1 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)1 NodeDefinitionVisitor (org.openforis.idm.metamodel.NodeDefinitionVisitor)1 ComparisonCheck (org.openforis.idm.metamodel.validation.ComparisonCheck)1 CustomCheck (org.openforis.idm.metamodel.validation.CustomCheck)1 DistanceCheck (org.openforis.idm.metamodel.validation.DistanceCheck)1 UniquenessCheck (org.openforis.idm.metamodel.validation.UniquenessCheck)1