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;
}
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);
}
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;
}
}
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;
}
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);
}
}
Aggregations