@Test public void test() throws IOException { FormTree formTree = assertResolves(formTreeBuilder.apply(HOUSEHOLD_SURVEY_FORM_CLASS)); FormTreePrettyPrinter.print(formTree); importModel = new ImportModel(formTree); // Step 1: User pastes in data to import PastedTable source = new PastedTable( Resources.toString( getResource("org/activityinfo/core/shared/importing/qis.csv"), Charsets.UTF_8)); source.parseAllRows(); assertThat(source.getRows().size(), equalTo(63)); importModel.setSource(source); importer = new Importer( resourceLocator, formTree, FieldImportStrategies.get(JvmConverterFactory.get())); dumpList("COLUMNS", source.getColumns()); // Step 2: User maps imported columns to FormFields dumpList("FIELDS", importer.getImportTargets()); importModel.setColumnAction(columnIndex("MEMBER_NO_ADULT_FEMALE"), target("NumAdultMale")); importModel.setColumnAction(columnIndex("MEMBER_NO_ADULT_FEMALE"), target("NumAdultFemale")); importModel.setColumnAction(columnIndex("_CREATION_DATE"), target("Start Date")); importModel.setColumnAction(columnIndex("_SUBMISSION_DATE"), target("End Date")); importModel.setColumnAction(columnIndex("district"), target("District Name")); importModel.setColumnAction(columnIndex("upazila"), target("Upzilla Name")); importModel.setColumnAction(columnIndex("Partner"), target("Partner Name")); // Step 3: Validate for user ValidatedRowTable validatedResult = assertResolves(importer.validateRows(importModel)); showValidationGrid(validatedResult); assertResolves(importer.persist(importModel)); // AND... verify Filter filter = new Filter(); filter.addRestriction(DimensionType.AdminLevel, MODHUPUR); SiteResult sites = execute(new GetSites(filter)); assertThat(sites.getTotalLength(), equalTo(1)); SiteDTO site = sites.getData().get(0); assertThat(site.getDate1(), equalTo(new LocalDate(2012, 12, 19))); assertThat(site.getDate2(), equalTo(new LocalDate(2012, 12, 19))); }
@Override public void updateForm(SiteDTO m) { commentField.setValue(m.getComments()); }
@Override public void updateModel(SiteDTO m) { m.setComments(commentField.getValue()); }