Search in sources :

Example 71 with EntityDefinition

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

the class UIOptionsTest method testDetachedNodeAssignableTabs.

// @Test
public void testDetachedNodeAssignableTabs() throws InvalidPathException {
    EntityDefinition clusterDefn = schema.getRootEntityDefinition("cluster");
    EntityDefinition plotDefn = (EntityDefinition) clusterDefn.getChildDefinition("plot");
    List<UITab> assignableTabs = uiOptions.getTabsAssignableToChildren(plotDefn);
    assertEquals(6, assignableTabs.size());
    UITab treeTab = assignableTabs.get(2);
    assertEquals("tree", treeTab.getName());
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition)

Example 72 with EntityDefinition

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

the class CalculatedAttributeDependencyGraphTest method testChainWithMultiplePaths.

@Test
public void testChainWithMultiplePaths() {
    EntityDefinition rootEntityDef = rootEntity.getDefinition();
    Attribute<?, ?> qty = attribute(rootEntity, "qty");
    calculatedAttributeDefinition(rootEntityDef, "t1", "qty + 1");
    calculatedAttributeDefinition(rootEntityDef, "t2", "t1 + qty");
    Attribute<?, ?> t2 = calculatedAttribute(rootEntity, "t2", "qty + t1");
    Attribute<?, ?> t1 = calculatedAttribute(rootEntity, "t1", "qty + 1");
    assertDependents(qty, t1, t2);
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) Test(org.junit.Test)

Example 73 with EntityDefinition

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

the class CalculatedAttributeDependencyGraphTest method testAggregateFunctionsInSameEntity.

@Test
public void testAggregateFunctionsInSameEntity() {
    Entity plot = entity(rootEntity, "plot");
    EntityDefinition treeDef = entityDefinition(plot.getDefinition(), "tree");
    attributeDefinition(treeDef, "dbh");
    Entity tree1 = entity(plot, "tree");
    Attribute<?, ?> dbh1 = attribute(tree1, "dbh");
    Attribute<?, ?> dbhsum1 = calculatedAttribute(tree1, "dbhsum", "sum(parent()/tree/dbh)");
    Entity tree2 = entity(plot, "tree");
    Attribute<?, ?> dbh2 = attribute(tree2, "dbh");
    Attribute<?, ?> dbhsum2 = calculatedAttribute(tree2, "dbhsum", "sum(parent()/tree/dbh)");
    assertCalculatedDependentsInAnyOrder(dbh1, dbhsum1, dbhsum2);
    assertCalculatedDependentsInAnyOrder(dbh2, dbhsum1, dbhsum2);
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) Test(org.junit.Test)

Example 74 with EntityDefinition

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

the class CalculatedAttributeDependencyGraphTest method testAddDetachedEntity.

@Test
public void testAddDetachedEntity() {
    EntityDefinition plotDef = entityDefinition(rootEntity.getDefinition(), "plot");
    Entity plot = (Entity) plotDef.createNode();
    Attribute<?, ?> plotNo = attribute(plot, "plot_no");
    Attribute<?, ?> total = calculatedAttribute(plot, "total", "plot_no + 1");
    rootEntity.add(plot);
    assertDependents(plotNo, total);
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) Test(org.junit.Test)

Example 75 with EntityDefinition

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

the class CalculatedAttributeDependencyGraphTest method testAggregateFunctionWithFilter.

@Test
public void testAggregateFunctionWithFilter() {
    Entity plot = entity(rootEntity, "plot");
    EntityDefinition treeDef = entityDefinition(plot.getDefinition(), "tree");
    attributeDefinition(treeDef, "dbh");
    Entity tree1 = entity(plot, "tree");
    Attribute<?, ?> dbh1 = attribute(tree1, "dbh");
    Entity tree2 = entity(plot, "tree");
    Attribute<?, ?> dbh2 = attribute(tree2, "dbh");
    Attribute<?, ?> total = calculatedAttribute(plot, "total", "sum(tree[idm:position() = 2]/dbh)");
    assertDependents(dbh1, total);
    assertDependents(dbh2, total);
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) Test(org.junit.Test)

Aggregations

EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)235 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)70 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)47 Schema (org.openforis.idm.metamodel.Schema)46 ArrayList (java.util.ArrayList)44 Test (org.junit.Test)38 Entity (org.openforis.idm.model.Entity)36 CollectRecord (org.openforis.collect.model.CollectRecord)30 CollectSurvey (org.openforis.collect.model.CollectSurvey)28 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)24 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)24 ParsingError (org.openforis.collect.io.metadata.parsing.ParsingError)19 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)18 UITab (org.openforis.collect.metamodel.ui.UITab)16 NumberAttributeDefinition (org.openforis.idm.metamodel.NumberAttributeDefinition)14 NumericAttributeDefinition (org.openforis.idm.metamodel.NumericAttributeDefinition)13 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)12 RecordFilter (org.openforis.collect.model.RecordFilter)11 SurveyObject (org.openforis.idm.metamodel.SurveyObject)10 BooleanAttributeDefinition (org.openforis.idm.metamodel.BooleanAttributeDefinition)9