Search in sources :

Example 31 with NodeDefinition

use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.

the class CodeListsVM method getReferences.

protected List<NodeDefinition> getReferences(CodeList item) {
    List<NodeDefinition> references = new ArrayList<NodeDefinition>();
    Schema schema = survey.getSchema();
    List<EntityDefinition> rootEntities = schema.getRootEntityDefinitions();
    Stack<NodeDefinition> stack = new Stack<NodeDefinition>();
    stack.addAll(rootEntities);
    while (!stack.isEmpty()) {
        NodeDefinition defn = stack.pop();
        if (defn instanceof EntityDefinition) {
            stack.addAll(((EntityDefinition) defn).getChildDefinitions());
        } else if (defn instanceof CodeAttributeDefinition) {
            CodeList list = ((CodeAttributeDefinition) defn).getList();
            if (list.equals(item)) {
                references.add(defn);
            }
        }
        ;
    }
    return references;
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) CodeList(org.openforis.idm.metamodel.CodeList) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) Schema(org.openforis.idm.metamodel.Schema) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) ArrayList(java.util.ArrayList) Stack(java.util.Stack)

Example 32 with NodeDefinition

use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.

the class AttributeDefaultFormValidator method validateCondition.

private void validateCondition(ValidationContext ctx) {
    NodeDefinition contextNode = getContextNode(ctx);
    validateBooleanExpressionField(ctx, contextNode, CONDITION_FIELD);
}
Also used : NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 33 with NodeDefinition

use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.

the class NodeDefinitionFormValidator method validateNameUniqueness.

protected boolean validateNameUniqueness(ValidationContext ctx) {
    NodeDefinition editedNode = getEditedNode(ctx);
    String name = (String) getValue(ctx, NAME_FIELD);
    if (!isNameUnique(ctx, editedNode, name)) {
        String message = Labels.getLabel(NODE_NAME_ALREADY_DEFINED_MESSAGE_KEY);
        addInvalidMessage(ctx, NAME_FIELD, message);
        return false;
    } else {
        return true;
    }
}
Also used : NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 34 with NodeDefinition

use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.

the class CheckFormValidator method validateNestedExpressionsInMessage.

private boolean validateNestedExpressionsInMessage(ValidationContext ctx) {
    NodeDefinition nodeDef = getContextNode(ctx);
    String message = getValue(ctx, MESSAGE_FIELD, true);
    if (StringUtils.isBlank(message)) {
        return true;
    }
    Check<?> check = getEditedCheck(ctx);
    List<String> expressions = check.extractExpressionsFromMessage(message);
    for (String expr : expressions) {
        boolean result = validateExpression(ctx, ExpressionType.VALUE, MESSAGE_FIELD, nodeDef.getParentEntityDefinition(), nodeDef, expr);
        if (!result) {
            return false;
        }
    }
    return true;
}
Also used : NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 35 with NodeDefinition

use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.

the class ComparisonCheckFormValidator method internalValidate.

@Override
protected void internalValidate(ValidationContext ctx) {
    super.internalValidate(ctx);
    if (validateGreaterOrLessRequireness(ctx)) {
        NodeDefinition contextDefn = getContextNode(ctx);
        validateValueExpressionField(ctx, contextDefn, GREATER_THAN_FIELD);
        validateValueExpressionField(ctx, contextDefn, LESS_THAN_FIELD);
    }
}
Also used : NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Aggregations

NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)173 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)70 ArrayList (java.util.ArrayList)42 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)27 Schema (org.openforis.idm.metamodel.Schema)24 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)22 CollectSurvey (org.openforis.collect.model.CollectSurvey)20 Entity (org.openforis.idm.model.Entity)19 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)16 NodeDefinitionVisitor (org.openforis.idm.metamodel.NodeDefinitionVisitor)14 UITab (org.openforis.collect.metamodel.ui.UITab)12 NumericAttributeDefinition (org.openforis.idm.metamodel.NumericAttributeDefinition)11 Survey (org.openforis.idm.metamodel.Survey)11 Test (org.junit.Test)10 DateAttributeDefinition (org.openforis.idm.metamodel.DateAttributeDefinition)9 ModelVersion (org.openforis.idm.metamodel.ModelVersion)9 BooleanAttributeDefinition (org.openforis.idm.metamodel.BooleanAttributeDefinition)8 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)8 NumberAttributeDefinition (org.openforis.idm.metamodel.NumberAttributeDefinition)8 Node (org.openforis.idm.model.Node)8