Search in sources :

Example 71 with NodeDefinition

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

the class RecordUpdater method updateMinCount.

private Collection<NodePointer> updateMinCount(Collection<NodePointer> nodePointers) {
    List<NodePointer> updatedPointers = new ArrayList<NodePointer>();
    for (NodePointer nodePointer : nodePointers) {
        Entity entity = nodePointer.getEntity();
        NodeDefinition childDef = nodePointer.getChildDefinition();
        Integer oldCount = entity.getMinCount(childDef);
        int newCount = calculateMinCount(nodePointer);
        entity.setMinCount(childDef, newCount);
        if (oldCount == null || oldCount.intValue() != newCount) {
            updatedPointers.add(nodePointer);
        }
    }
    return updatedPointers;
}
Also used : Entity(org.openforis.idm.model.Entity) ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) NodePointer(org.openforis.idm.model.NodePointer)

Example 72 with NodeDefinition

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

the class RecordUpdater method getChildNodePointers.

private List<NodePointer> getChildNodePointers(Entity entity) {
    ModelVersion version = entity.getRecord().getVersion();
    List<NodePointer> pointers = new ArrayList<NodePointer>();
    EntityDefinition definition = entity.getDefinition();
    for (NodeDefinition childDef : definition.getChildDefinitionsInVersion(version)) {
        pointers.add(new NodePointer(entity, childDef));
    }
    return pointers;
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) ModelVersion(org.openforis.idm.metamodel.ModelVersion) NodePointer(org.openforis.idm.model.NodePointer)

Example 73 with NodeDefinition

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

the class RecordValidationCache method getTotalMissingCount.

protected int getTotalMissingCount(Map<Integer, Set<NodeDefinition>> nodeDefsByEntityId) {
    int result = 0;
    Set<Integer> keySet = nodeDefsByEntityId.keySet();
    for (Integer id : keySet) {
        Entity entity = (Entity) record.getNodeByInternalId(id);
        Set<NodeDefinition> nodeDefs = nodeDefsByEntityId.get(id);
        for (NodeDefinition childDef : nodeDefs) {
            int missingCount = entity.getMissingCount(childDef);
            result += missingCount;
        }
    }
    return result;
}
Also used : Entity(org.openforis.idm.model.Entity) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 74 with NodeDefinition

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

the class UIModelObject method getNodeDefinition.

protected NodeDefinition getNodeDefinition(int id) {
    UIConfiguration uiConfiguration = getUIConfiguration();
    if (uiConfiguration == null || uiConfiguration.getSurvey() == null) {
        throw new IllegalStateException("UIConfiguration not initialized correctly");
    }
    CollectSurvey survey = uiConfiguration.getSurvey();
    Schema schema = survey.getSchema();
    NodeDefinition result = schema.getDefinitionById(id);
    return result;
}
Also used : Schema(org.openforis.idm.metamodel.Schema) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 75 with NodeDefinition

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

the class UIOptions method isUnassigned.

/**
 * Returns true if the specified tab is not assigned to one of the descendants of the specified rootEntity
 */
public boolean isUnassigned(UITab tab, EntityDefinition rootEntity) {
    Deque<NodeDefinition> stack = new LinkedList<NodeDefinition>();
    stack.add(rootEntity);
    while (!stack.isEmpty()) {
        NodeDefinition childDefn = stack.pop();
        UITab assignedTab = getAssignedTab(childDefn, false);
        if (tab == assignedTab) {
            return false;
        }
        if (childDefn instanceof EntityDefinition) {
            List<NodeDefinition> nestedChildDefns = ((EntityDefinition) childDefn).getChildDefinitions();
            for (NodeDefinition nestedChildDefn : nestedChildDefns) {
                stack.push(nestedChildDefn);
            }
        }
    }
    return true;
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) LinkedList(java.util.LinkedList)

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