Search in sources :

Example 6 with NumberAttribute

use of org.openforis.idm.model.NumberAttribute in project collect by openforis.

the class DataMarshallerIntegrationTest method createTestRecord.

private CollectRecord createTestRecord(CollectSurvey survey) {
    RecordBuilder recordBuilder = record(attribute("id", "123_456"), attribute("gps_realtime", "true"), attribute("region", "001"), attribute("district", "XXX"), attribute("crew_no", 10), attribute("map_sheet", "value 1"), attribute("map_sheet", "value 2"), attribute("vehicle_location", new Coordinate(432423423d, 4324324d, "srs")), attribute("gps_model", "TomTom 1.232"), attribute("remarks", "Remarks with UTF-8 character: Í"), entity("time_study", attribute("date", new Date(2011, 2, 14)), attribute("start_time", new Time(8, 15)), attribute("end_time", new Time(15, 29))), entity("time_study", attribute("date", new Date(2011, 2, 15)), attribute("start_time", new Time(8, 32)), attribute("end_time", new Time(11, 20))), entity("plot", attribute("no", new Code("1")), entity("tree", attribute("tree_no", 1), attribute("dbh", 54.2), attribute("total_height", 2.0), attribute("bole_height", (Double) null)), entity("tree", attribute("tree_no", 2), attribute("dbh", 82.8), attribute("total_height", 3.0))), entity("plot", attribute("no", new Code("2")), entity("tree", attribute("tree_no", 1), attribute("dbh", 34.2), attribute("total_height", 2.0)), entity("tree", attribute("tree_no", 2), attribute("dbh", 85.8), attribute("total_height", 4.0))));
    CollectRecord record = recordBuilder.build(survey, "cluster", "2.0");
    User user = userManager.loadByUserName("admin");
    record.setCreatedBy(user);
    record.setModifiedBy(user);
    record.setCreationDate(new GregorianCalendar(2011, 11, 31, 23, 59).getTime());
    record.setModifiedDate(new GregorianCalendar(2012, 2, 3, 9, 30).getTime());
    record.setStep(Step.ENTRY);
    record.setState(State.REJECTED);
    record.updateSummaryFields();
    RecordUpdater recordUpdater = new RecordUpdater();
    recordUpdater.initializeRecord(record);
    Entity cluster = record.getRootEntity();
    recordUpdater.confirmError((Attribute<?, ?>) record.findNodeByPath("/cluster/district"));
    recordUpdater.approveMissingValue(cluster, "accessibility");
    NumberAttribute<?, ?> boleHeight = (NumberAttribute<?, ?>) record.findNodeByPath("/cluster/plot[1]/tree[1]/bole_height");
    recordUpdater.updateAttribute(boleHeight, FieldSymbol.BLANK_ON_FORM);
    recordUpdater.updateRemarks(boleHeight.getNumberField(), "No value specified");
    return record;
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) Entity(org.openforis.idm.model.Entity) User(org.openforis.collect.model.User) RecordBuilder(org.openforis.idm.testfixture.RecordBuilder) GregorianCalendar(java.util.GregorianCalendar) Time(org.openforis.idm.model.Time) Code(org.openforis.idm.model.Code) Date(org.openforis.idm.model.Date) Coordinate(org.openforis.idm.model.Coordinate) NumberAttribute(org.openforis.idm.model.NumberAttribute) RecordUpdater(org.openforis.collect.model.RecordUpdater)

Example 7 with NumberAttribute

use of org.openforis.idm.model.NumberAttribute in project collect by openforis.

the class ModelSerializationTest method createTestRecord.

private CollectRecord createTestRecord(CollectSurvey survey) {
    RecordBuilder recordBuilder = record(attribute("id", new Code("123_456")), attribute("gps_realtime", "true"), attribute("region", "001"), attribute("district", "002"), attribute("crew_no", 10), attribute("map_sheet", "value 1"), attribute("map_sheet", "value 2"), attribute("vehicle_location", new Coordinate(432423423d, 4324324d, "srs")), attribute("gps_model", "TomTom 1.232"), entity("time_study", attribute("date", new Date(2011, 2, 14)), attribute("start_time", new Time(8, 15)), attribute("end_time", new Time(15, 29))), entity("time_study", attribute("date", new Date(2011, 2, 15)), attribute("start_time", new Time(8, 32)), attribute("end_time", new Time(11, 20))), entity("plot", attribute("no", new Code("1")), entity("tree", attribute("tree_no", 1), attribute("dbh", 54.2), attribute("total_height", 2.0), attribute("bole_height", (Double) null)), entity("tree", attribute("tree_no", 2), attribute("dbh", 82.8), attribute("total_height", 3.0))), entity("plot", attribute("no", new Code("2")), entity("tree", attribute("tree_no", 1), attribute("dbh", 34.2), attribute("total_height", 2.0)), entity("tree", attribute("tree_no", 2), attribute("dbh", 85.8), attribute("total_height", 4.0))));
    CollectRecord record = recordBuilder.build(survey, "cluster", "2.0");
    record.setCreationDate(new GregorianCalendar(2011, 11, 31, 23, 59).getTime());
    // record.setCreatedBy("ModelDaoIntegrationTest");
    record.setStep(Step.ENTRY);
    record.updateSummaryFields();
    updater.initializeRecord(record);
    Entity cluster = record.getRootEntity();
    updater.confirmError((Attribute<?, ?>) record.findNodeByPath("/cluster/district"));
    updater.approveMissingValue(cluster, "accessibility");
    NumberAttribute<?, ?> boleHeight = (NumberAttribute<?, ?>) record.findNodeByPath("/cluster/plot[1]/tree[1]/bole_height");
    updater.updateAttribute(boleHeight, FieldSymbol.BLANK_ON_FORM);
    updater.updateRemarks(boleHeight.getNumberField(), "No value specified");
    return record;
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) Entity(org.openforis.idm.model.Entity) Coordinate(org.openforis.idm.model.Coordinate) RecordBuilder(org.openforis.idm.testfixture.RecordBuilder) GregorianCalendar(java.util.GregorianCalendar) NumberAttribute(org.openforis.idm.model.NumberAttribute) Time(org.openforis.idm.model.Time) Code(org.openforis.idm.model.Code) Date(org.openforis.idm.model.Date)

Aggregations

NumberAttribute (org.openforis.idm.model.NumberAttribute)7 Entity (org.openforis.idm.model.Entity)4 GregorianCalendar (java.util.GregorianCalendar)3 CollectRecord (org.openforis.collect.model.CollectRecord)3 CollectSurvey (org.openforis.collect.model.CollectSurvey)3 Code (org.openforis.idm.model.Code)3 Coordinate (org.openforis.idm.model.Coordinate)3 Date (org.openforis.idm.model.Date)3 Time (org.openforis.idm.model.Time)3 RecordBuilder (org.openforis.idm.testfixture.RecordBuilder)3 RecordUpdater (org.openforis.collect.model.RecordUpdater)2 Unit (org.openforis.idm.metamodel.Unit)2 NumericRangeAttribute (org.openforis.idm.model.NumericRangeAttribute)2 ParsingError (org.openforis.collect.io.metadata.parsing.ParsingError)1 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)1 FieldSymbol (org.openforis.collect.model.FieldSymbol)1 NodeChangeSet (org.openforis.collect.model.NodeChangeSet)1 User (org.openforis.collect.model.User)1 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)1 NumericAttributeDefinition (org.openforis.idm.metamodel.NumericAttributeDefinition)1