use of org.openforis.idm.model.DateAttribute in project collect by openforis.
the class CSVDataImportProcessIntegrationTest method singleEntityTest.
@Test
public void singleEntityTest() throws Exception {
{
CollectRecord record = createTestRecord(survey, "10_114");
recordDao.insert(record);
}
EntityDefinition clusterDefn = survey.getSchema().getRootEntityDefinition("cluster");
EntityDefinition plotDefn = (EntityDefinition) clusterDefn.getChildDefinition("plot");
CSVDataImportProcess process = importCSVFile(VALID_SINGLE_ENTITY_TEST_CSV, plotDefn.getId());
ReferenceDataImportStatus<ParsingError> status = process.getStatus();
assertTrue(status.isComplete());
assertTrue(status.getSkippedRows().isEmpty());
assertEquals(3, status.getProcessed());
{
CollectRecord reloadedRecord = loadRecord("10_114");
Entity reloadedCluster = reloadedRecord.getRootEntity();
{
Entity plot = reloadedCluster.findChildEntitiesByKeys("plot", "1", "A").get(0);
Entity timeStudy = (Entity) plot.getChild("time_study");
DateAttribute date = (DateAttribute) timeStudy.getChild("date");
assertEquals(new Date(2012, 2, 15), date.getValue());
}
{
Entity plot = reloadedCluster.findChildEntitiesByKeys("plot", "2", "B").get(0);
Entity timeStudy = (Entity) plot.getChild("time_study");
DateAttribute date = (DateAttribute) timeStudy.getChild("date");
assertEquals(new Date(2013, 5, 18), date.getValue());
}
}
}
use of org.openforis.idm.model.DateAttribute in project collect by openforis.
the class DateAttributeMapper method setFields.
@Override
void setFields(Node<?> node, InsertSetStep<?> insert) {
Date value = ((DateAttribute) node).getValue();
if (value != null) {
insert.set(DATA.NUMBER1, toNumeric(value.getYear()));
insert.set(DATA.NUMBER2, toNumeric(value.getMonth()));
insert.set(DATA.NUMBER3, toNumeric(value.getDay()));
}
}
Aggregations