Search in sources :

Example 36 with NodeDefinition

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

the class UniquenessCheckFormValidator method validateExpression.

private boolean validateExpression(ValidationContext ctx) {
    if (validateRequired(ctx, EXPRESSION_FIELD)) {
        ExpressionValidator expressionValidator = getExpressionValidator(ctx);
        NodeDefinition contextNode = getContextNode(ctx);
        String expression = getValue(ctx, EXPRESSION_FIELD);
        ExpressionValidationResult result = expressionValidator.validateUniquenessExpression(contextNode.getParentDefinition(), contextNode, expression);
        if (result.isError()) {
            String message = Strings.firstNotBlank(result.getDetailedMessage(), result.getMessage());
            addInvalidMessage(ctx, EXPRESSION_FIELD, getMessage(INVALID_EXPRESSION_MESSAGE_KEY, message));
            return false;
        }
    }
    return true;
}
Also used : NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) ExpressionValidator(org.openforis.idm.metamodel.expression.ExpressionValidator) ExpressionValidationResult(org.openforis.idm.metamodel.expression.ExpressionValidator.ExpressionValidationResult)

Example 37 with NodeDefinition

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

the class GeoDataController method processNodes.

private void processNodes(CollectSurvey survey, Integer recordOffset, Integer maxNumberOfRecords, int attributeId, NodeProcessor nodeProcessor) throws Exception {
    NodeDefinition nodeDef = survey.getSchema().getDefinitionById(attributeId);
    RecordFilter filter = new RecordFilter(survey);
    filter.setOffset(recordOffset);
    filter.setMaxNumberOfRecords(maxNumberOfRecords);
    List<CollectRecordSummary> summaries = recordManager.loadSummaries(filter);
    for (CollectRecordSummary summary : summaries) {
        CollectRecord record = recordManager.load(survey, summary.getId(), summary.getStep(), false);
        List<Node<?>> nodes = record.findNodesByPath(nodeDef.getPath());
        for (Node<?> node : nodes) {
            nodeProcessor.process(node);
        }
    }
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) CollectRecordSummary(org.openforis.collect.model.CollectRecordSummary) Node(org.openforis.idm.model.Node) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) RecordFilter(org.openforis.collect.model.RecordFilter)

Example 38 with NodeDefinition

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

the class SchemaLayoutVM method getRootTabSet.

protected UITabSet getRootTabSet(Treeitem treeItem) {
    if (treeItem != null) {
        TreeNode<NodeDefinition> treeNode = treeItem.getValue();
        NodeDefinition nodeDefn = treeNode.getData();
        UIOptions uiOptions = survey.getUIOptions();
        EntityDefinition rootEntity = nodeDefn.getRootEntity();
        return uiOptions.getAssignedRootTabSet(rootEntity);
    } else {
        return null;
    }
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 39 with NodeDefinition

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

the class SchemaLayoutVM method listOfNodesDropHandler.

@Listen("onDrop = tree#nodesTree")
public void listOfNodesDropHandler(DropEvent evt) {
    Component dragged = evt.getDragged();
    if (dragged instanceof Listitem) {
        NodeDefinition node = ((Listitem) dragged).getValue();
        CollectSurvey survey = getSurvey();
        UIOptions uiOpts = survey.getUIOptions();
        UITab oldTab = uiOpts.getAssignedTab(node, false);
        uiOpts.removeTabAssociation(node);
        if (oldTab != null) {
            postNodePerTabChangedCommand(oldTab);
        }
    }
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) Listitem(org.zkoss.zul.Listitem) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) Component(org.zkoss.zk.ui.Component) CollectSurvey(org.openforis.collect.model.CollectSurvey) Listen(org.zkoss.zk.ui.select.annotation.Listen)

Example 40 with NodeDefinition

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

the class CalculatedAttributeFormulaFormValidator method validateCondition.

private void validateCondition(ValidationContext ctx) {
    NodeDefinition contextNode = getAttributeDefinition(ctx);
    validateBooleanExpression(ctx, contextNode, CONDITION_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