use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class ValidationMessageBuilder method getPrettyFormatPath.
public String getPrettyFormatPath(Node<? extends NodeDefinition> node, Locale locale) {
NodeDefinition defn = node.getDefinition();
String label = getPrettyLabelText(defn, locale);
if (defn instanceof EntityDefinition) {
String keyText = getKeyText((Entity) node, locale);
if (StringUtils.isBlank(keyText)) {
label += "[" + (node.getIndex() + 1) + "]";
} else {
label += " " + keyText;
}
}
if (node.getParent() == null || node.getParent().getParent() == null) {
return label;
} else {
return getPrettyFormatPath(node.getParent(), locale) + PRETTY_PATH_SEPARATOR + label;
}
}
use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class DataMarshaller method writeEmptyNodes.
/**
* Writes empty nodes child of an entity if there is a node state specified.
*
* @param serializer
* @param entity
* @throws IOException
*/
private void writeEmptyNodes(XmlSerializer serializer, Entity entity) throws IOException {
EntityDefinition defn = entity.getDefinition();
List<NodeDefinition> childDefns = defn.getChildDefinitions();
for (NodeDefinition childDefn : childDefns) {
if (entity.getCount(childDefn) == 0) {
State childState = entity.getChildState(childDefn);
int childStateInt = childState.intValue();
if (childStateInt > 0) {
String childName = childDefn.getName();
serializer.startTag(null, childName);
serializer.attribute(null, STATE_ATTRIBUTE, Integer.toString(childStateInt));
serializer.endTag(null, childName);
}
}
}
}
use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class DataQueryValidator method validateConditions.
private boolean validateConditions(DataQueryForm target, Errors errors) {
CollectSurvey survey = sessionManager.getActiveSurvey();
NodeDefinition contextNodeDef = survey.getSchema().getDefinitionById(target.getEntityDefinitionId());
NodeDefinition thisNodeDef = survey.getSchema().getDefinitionById(target.getAttributeDefinitionId());
String expression = target.getConditions();
boolean valid = validateBooleanExpression(errors, contextNodeDef, thisNodeDef, CONDITIONS_FIELD, expression);
return valid;
}
use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class SchemaTreeModel method getSiblingsAndSelf.
public List<SurveyObject> getSiblingsAndSelf(SurveyObject obj, boolean sameType) {
List<SurveyObject> result = new ArrayList<SurveyObject>();
TreeNode<SchemaNodeData> treeNode = getTreeNode(obj);
SchemaTreeNode parent = (SchemaTreeNode) treeNode.getParent();
List<TreeNode<SchemaNodeData>> children = parent.getChildren();
for (TreeNode<SchemaNodeData> child : children) {
SurveyObject surveyObject = child.getData().getSurveyObject();
if (sameType && ((obj instanceof UITab && surveyObject instanceof UITab) || (obj instanceof NodeDefinition && surveyObject instanceof NodeDefinition))) {
result.add(surveyObject);
}
}
return result;
}
use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class UITreeModelCreator method createChildNodes.
private List<AbstractNode<SchemaNodeData>> createChildNodes(EntityDefinition entityDefn) {
List<AbstractNode<SchemaNodeData>> childNodes = new ArrayList<AbstractNode<SchemaNodeData>>();
CollectSurvey survey = (CollectSurvey) entityDefn.getSurvey();
UIOptions uiOptions = survey.getUIOptions();
UITab assignedTab = uiOptions.getAssignedTab(entityDefn);
// include node definitions
List<NodeDefinition> childDefns = entityDefn.getChildDefinitions();
Collection<? extends AbstractNode<SchemaNodeData>> schemaTreeNodes = createNodes(assignedTab, childDefns);
childNodes.addAll(schemaTreeNodes);
// include tabs
if (entityDefn.isMultiple() && uiOptions.getLayout(entityDefn) == Layout.FORM) {
List<UITab> tabs = uiOptions.getTabsAssignableToChildren(entityDefn, false);
Collection<? extends AbstractNode<SchemaNodeData>> tabNodes = createNodes(tabs);
childNodes.addAll(tabNodes);
}
return childNodes;
}
Aggregations