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