use of org.openforis.idm.model.TextAttribute in project collect by openforis.
the class CSVDataImportJobIntegrationTest method validTest.
@Test
public void validTest() throws Exception {
{
CollectRecord record = createTestRecord(survey, "10_111");
recordDao.insert(record);
assertEquals(Integer.valueOf(0), record.getErrors());
}
{
CollectRecord record = createTestRecord(survey, "10_114");
recordDao.insert(record);
}
EntityDefinition clusterDefn = survey.getSchema().getRootEntityDefinition("cluster");
CSVDataImportJob process = importCSVFile(VALID_TEST_CSV, clusterDefn.getId());
assertTrue(process.isCompleted());
assertTrue(process.getParsingErrors().isEmpty());
{
CollectRecord reloadedRecord = loadRecord("10_111");
assertEquals(Integer.valueOf(1), reloadedRecord.getErrors());
Entity cluster = reloadedRecord.getRootEntity();
RealAttribute plotDirection = (RealAttribute) cluster.getChild("plot_direction");
RealValue plotDirectionVal = plotDirection.getValue();
assertEquals(Double.valueOf(50d), plotDirectionVal.getValue());
RealAttribute plotDistance = (RealAttribute) cluster.getChild("plot_distance");
RealValue plotDistanceVal = plotDistance.getValue();
assertEquals(Double.valueOf(200d), plotDistanceVal.getValue());
assertEquals(meterUnit, plotDistanceVal.getUnit());
TextAttribute gpsModel = (TextAttribute) cluster.getChild("gps_model");
assertEquals("GPS MAP 62S", gpsModel.getValue().getValue());
assertEquals(2, cluster.getCount("map_sheet"));
{
TextAttribute mapSheet = (TextAttribute) cluster.getChild("map_sheet", 0);
assertEquals("new map sheet 1", mapSheet.getValue().getValue());
}
{
TextAttribute mapSheet = (TextAttribute) cluster.getChild("map_sheet", 1);
assertEquals("new map sheet 2", mapSheet.getValue().getValue());
}
}
{
CollectRecord reloadedRecord = loadRecord("10_114");
Entity cluster = reloadedRecord.getRootEntity();
RealAttribute plotDirection = (RealAttribute) cluster.getChild("plot_direction");
RealValue plotDirectionVal = plotDirection.getValue();
assertEquals(Double.valueOf(40d), plotDirectionVal.getValue());
RealAttribute plotDistance = (RealAttribute) cluster.getChild("plot_distance");
RealValue plotDistanceVal = plotDistance.getValue();
assertEquals(Double.valueOf(0.3d), plotDistanceVal.getValue());
assertEquals(kilometerUnit, plotDistanceVal.getUnit());
TextAttribute gpsModel = (TextAttribute) cluster.getChild("gps_model");
assertEquals("GPS MAP 62S", gpsModel.getValue().getValue());
}
}
use of org.openforis.idm.model.TextAttribute in project collect by openforis.
the class TextAttributeMapper method setFields.
@Override
void setFields(Node<?> node, InsertSetStep<?> insert) {
TextAttribute t = (TextAttribute) node;
String value = t.getValue();
insert.set(Data.DATA.TEXT1, value);
}
use of org.openforis.idm.model.TextAttribute in project collect by openforis.
the class ComparisonCheckTest method testTextLtConstant.
@Test
public void testTextLtConstant() {
ComparisonCheck check = new ComparisonCheck();
check.setLessThanExpression("-1");
TextAttribute mapSheet = EntityBuilder.addValue(cluster, "map_sheet", "1");
ValidationResultFlag result = check.evaluate(mapSheet);
assertEquals(ERROR, result);
}
use of org.openforis.idm.model.TextAttribute in project collect by openforis.
the class ComparisonCheckTest method testTextGtConstant.
@Test
public void testTextGtConstant() throws Exception {
ComparisonCheck check = new ComparisonCheck();
check.setGreaterThanExpression("-1");
TextAttribute mapSheet = EntityBuilder.addValue(cluster, "map_sheet", "1");
ValidationResultFlag result = check.evaluate(mapSheet);
assertEquals(OK, result);
}
use of org.openforis.idm.model.TextAttribute in project collect by openforis.
the class RecordUpdaterTest method testInitializeCalculatedAttributeInNestedNode.
@Test
public void testInitializeCalculatedAttributeInNestedNode() {
record(rootEntityDef(entityDef("details", attributeDef("accessibility")), entityDef("tree", attributeDef("angle"), attributeDef("height").calculated("number(angle) * 2"), attributeDef("double_height").calculated("number(height) * 2", "parent()/details/accessibility = 'true'")).multiple()), entity("details", NodeBuilder.attribute("accessibility", "true")), entity("tree", NodeBuilder.attribute("angle", "10")));
TextAttribute doubleHeight = record.findNodeByPath("/root/tree[1]/double_height");
assertEquals("40.0", ((TextValue) doubleHeight.getValue()).getValue());
}
Aggregations