use of org.openforis.idm.model.Entity in project collect by openforis.
the class RecordDao method fillRecordStoreQueryFromObject.
protected void fillRecordStoreQueryFromObject(StoreQuery<?> q, CollectRecord r) {
Entity rootEntity = r.getRootEntity();
EntityDefinition rootEntityDefn = rootEntity.getDefinition();
int rootEntityDefnId = rootEntityDefn.getId();
q.addValue(OFC_RECORD.SURVEY_ID, r.getSurvey().getId());
q.addValue(OFC_RECORD.ROOT_ENTITY_DEFINITION_ID, rootEntityDefnId);
q.addValue(OFC_RECORD.DATE_CREATED, toTimestamp(r.getCreationDate()));
q.addValue(OFC_RECORD.CREATED_BY_ID, getUserId(r.getCreatedBy()));
q.addValue(OFC_RECORD.DATE_MODIFIED, toTimestamp(r.getModifiedDate()));
q.addValue(OFC_RECORD.MODIFIED_BY_ID, getUserId(r.getModifiedBy()));
q.addValue(OFC_RECORD.MODEL_VERSION, r.getVersion() != null ? r.getVersion().getName() : null);
q.addValue(OFC_RECORD.STEP, r.getStep().getStepNumber());
q.addValue(OFC_RECORD.STATE, r.getState() != null ? r.getState().getCode() : null);
q.addValue(OFC_RECORD.DATA_SEQ_NUM, r.getDataWorkflowSequenceNumber());
q.addValue(OFC_RECORD.OWNER_ID, getUserId(r.getOwner()));
q.addValue(OFC_RECORD.SKIPPED, r.getSkipped());
q.addValue(OFC_RECORD.MISSING, r.getMissing());
q.addValue(OFC_RECORD.ERRORS, r.getErrors());
q.addValue(OFC_RECORD.WARNINGS, r.getWarnings());
addValuesToQuery(q, RECORD_KEY_FIELDS, r.getRootEntityKeyValues());
addValuesToQuery(q, RECORD_COUNT_FIELDS, r.getEntityCounts());
addValuesToQuery(q, RECORD_QUALIFIER_FIELDS, r.getQualifierValues());
addValuesToQuery(q, RECORD_SUMMARY_FIELDS, r.getDataSummaryValues());
}
use of org.openforis.idm.model.Entity in project collect by openforis.
the class DataMarshaller method writeState.
private void writeState(XmlSerializer serializer, Node<?> node) throws IOException {
Entity parent = node.getParent();
if (parent != null) {
State s = parent.getChildState(node.getDefinition());
int state = s.intValue();
if (state > 0) {
serializer.attribute(null, STATE_ATTRIBUTE, Integer.toString(state));
}
}
}
use of org.openforis.idm.model.Entity in project collect by openforis.
the class MissingValueApproveRequestProxy method toNodeUpdateRequest.
@Override
public MissingValueApproveRequest toNodeUpdateRequest(CollectRecord record) {
MissingValueApproveRequest opts = new NodeUpdateRequest.MissingValueApproveRequest();
Entity parentEntity = (Entity) record.getNodeByInternalId(parentEntityId);
opts.setParentEntity(parentEntity);
opts.setNodeName(nodeName);
return opts;
}
use of org.openforis.idm.model.Entity 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.Entity in project collect by openforis.
the class CSVDataImportJobIntegrationTest method createMissingParentEntityTest.
@Test
public void createMissingParentEntityTest() throws Exception {
{
CollectRecord record = createTestRecord(survey, "10_111");
recordDao.insert(record);
}
{
CollectRecord record = createTestRecord(survey, "10_114");
recordDao.insert(record);
}
EntityDefinition clusterDefn = survey.getSchema().getRootEntityDefinition("cluster");
EntityDefinition plotDefn = (EntityDefinition) clusterDefn.getChildDefinition("plot");
EntityDefinition treeDefn = (EntityDefinition) plotDefn.getChildDefinition("tree");
CSVDataImportJob process = importCSVFile(MISSING_PARENT_ENTITY_TEST_CSV, treeDefn.getId(), true, false, null, true);
assertTrue(process.isCompleted());
assertTrue(process.getParsingErrors().isEmpty());
{
CollectRecord reloadedRecord = loadRecord("10_111");
Entity cluster = reloadedRecord.getRootEntity();
Entity plot = (Entity) cluster.getChild("plot", 0);
assertEquals(3, plot.getCount("tree"));
Entity tree = (Entity) plot.getChild("tree", 2);
IntegerAttribute treeNo = (IntegerAttribute) tree.getChild("tree_no");
assertEquals(Integer.valueOf(2), treeNo.getValue().getValue());
IntegerAttribute stemNo = (IntegerAttribute) tree.getChild("stem_no");
assertEquals(Integer.valueOf(2), stemNo.getValue().getValue());
RealAttribute dbh = (RealAttribute) tree.getChild("dbh");
assertEquals(Double.valueOf(200), dbh.getValue().getValue());
}
}
Aggregations