use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class MetaModelExpressionTest method testParentExpression.
@Test
public void testParentExpression() {
Schema schema = survey.getSchema();
EntityDefinition clusterDefn = schema.getRootEntityDefinition("cluster");
EntityDefinition plotDefn = (EntityDefinition) clusterDefn.getChildDefinition("plot");
NodeDefinition plotNoDefn = plotDefn.getChildDefinition("no");
SchemaPathExpression expression = new SchemaPathExpression("parent()");
NodeDefinition resultDefn = expression.evaluate(plotDefn, plotNoDefn);
Assert.assertEquals(clusterDefn, resultDefn);
}
use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class AbstractExpression method getReferencedNodeDefinition.
private NodeDefinition getReferencedNodeDefinition(NodeDefinition context, NodeDefinition thisNodeDef, String path) throws InvalidExpressionException {
StringTokenizer tokenizer = new StringTokenizer(path, String.valueOf(Path.SEPARATOR));
NodeDefinition currentContext = context;
while (tokenizer.hasMoreTokens()) {
String pathSection = tokenizer.nextToken();
if (currentContext instanceof AttributeDefinition && pathSection.startsWith("@")) {
if (tokenizer.hasMoreTokens()) {
String message = String.format("cannot have nested levels inside %s", currentContext.getPath());
throw new InvalidExpressionException(message, compiledExpression.toString());
}
checkPropertyExists((AttributeDefinition) currentContext, pathSection);
return currentContext;
} else {
currentContext = getChildDefinition(currentContext, thisNodeDef, pathSection);
}
}
return currentContext;
}
use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class Path method pathOf.
public static Path pathOf(NodeDefinition defn) {
NodeDefinition parent = defn.getParentDefinition();
String name = defn.getName();
PathElement elem = new PathElement(name);
if (parent == null) {
return new Path(elem, true);
} else {
Path parentPath = Path.pathOf(parent);
return parentPath.append(elem);
}
}
use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class UIOptionsTest method testTabSetAssociation.
@Test
public void testTabSetAssociation() throws InvalidPathException {
UITabSet clusterTabSet = uiOptions.getTabSet("cluster");
assertNotNull(clusterTabSet);
assertEquals("cluster", clusterTabSet.getName());
EntityDefinition cluster = schema.getRootEntityDefinition("cluster");
clusterTabSet = uiOptions.getAssignedRootTabSet(cluster);
assertEquals("cluster", clusterTabSet.getName());
EntityDefinition plot = (EntityDefinition) cluster.getChildDefinition("plot");
UITab assignedTab = uiOptions.getAssignedTab(plot);
assertEquals("plot", assignedTab.getName());
NodeDefinition tree = plot.getChildDefinition("tree");
assignedTab = uiOptions.getAssignedTab(tree);
assertEquals("tree", assignedTab.getName());
UITabSet assignedToParentTabSet = uiOptions.getAssignedTabSet(plot);
assertEquals("plot", assignedToParentTabSet.getName());
assignedToParentTabSet = uiOptions.getAssignedTabSet(cluster);
assertEquals("cluster", assignedToParentTabSet.getName());
}
use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class SchemaVM method getSelectedNodeParentTab.
private UITab getSelectedNodeParentTab() {
UITab parentTab;
SurveyObject selectedSurveyObject = selectedTreeNode.getSurveyObject();
if (selectedSurveyObject instanceof UITab) {
parentTab = (UITab) selectedSurveyObject;
} else {
UIOptions uiOptions = survey.getUIOptions();
parentTab = uiOptions.getAssignedTab((NodeDefinition) selectedSurveyObject);
}
return parentTab;
}
Aggregations