use of org.activityinfo.store.query.server.Updater in project activityinfo by bedatadriven.
the class MySqlUpdateTest method updateSiteSetValueToBlank.
@Test
public void updateSiteSetValueToBlank() throws JsonMappingException {
RecordUpdate changeObject = new RecordUpdate();
changeObject.setRecordId("s0000000001");
changeObject.setFormId(activityFormClass(1).asString());
changeObject.setFieldValue("BENE", Json.createNull());
changeObject.setFieldValue("comments", Json.createNull());
Updater updater = updater();
updater.executeChange(changeObject);
query(activityFormClass(1), "_id", "BENE", "comments");
assertThat(column("_id"), hasValues("s0000000001", "s0000000002", "s0000000003"));
assertThat(column("BENE"), hasValues(null, 3600, 10000));
assertThat(column("comments"), hasValues((String) null, null, null));
}
use of org.activityinfo.store.query.server.Updater in project activityinfo by bedatadriven.
the class MySqlUpdateTest method deleteSiteWithMonthlyReports.
@Test
public void deleteSiteWithMonthlyReports() {
query(CuidAdapter.reportingPeriodFormClass(3), "_id", "site", CuidAdapter.indicatorField(5).asString());
assertThat(column("site"), hasValues("s0000000009", "s0000000009", "s0000000009"));
RecordUpdate changeObject = new RecordUpdate();
changeObject.setRecordId("s0000000009");
changeObject.setFormId(activityFormClass(3).asString());
changeObject.setDeleted(true);
newRequest();
Updater updater = updater();
updater.executeChange(changeObject);
newRequest();
query(CuidAdapter.reportingPeriodFormClass(3), "_id", "site", CuidAdapter.indicatorField(5).asString());
assertThat(column("site"), hasValues(new String[0]));
}
use of org.activityinfo.store.query.server.Updater in project activityinfo by bedatadriven.
the class MySqlUpdateTest method updateLocation.
@Test
public void updateLocation() throws SQLException {
ResourceId recordId = CuidAdapter.cuid(LOCATION_DOMAIN, 1);
ResourceId formId = CuidAdapter.locationFormClass(1);
RecordUpdate update = new RecordUpdate();
update.setFormId(formId);
update.setRecordId(recordId);
update.setFieldValue(CuidAdapter.field(formId, CuidAdapter.NAME_FIELD), TextValue.valueOf("New Name"));
Updater updater = updater();
updater.executeChange(update);
newRequest();
FormStorage formStorage = catalog.getForm(formId).get();
FormRecord record = formStorage.get(recordId).get();
FormInstance typedRecord = FormInstance.toFormInstance(formStorage.getFormClass(), record);
GeoPoint point = (GeoPoint) typedRecord.get(CuidAdapter.field(formId, CuidAdapter.GEOMETRY_FIELD));
assertThat(point, not(nullValue()));
}
use of org.activityinfo.store.query.server.Updater in project activityinfo by bedatadriven.
the class MySqlUpdateTest method deleteSite.
@Test
public void deleteSite() {
RecordUpdate changeObject = new RecordUpdate();
changeObject.setRecordId("s0000000001");
changeObject.setFormId(activityFormClass(1).asString());
changeObject.setDeleted(true);
Updater updater = updater();
updater.executeChange(changeObject);
newRequest();
query(activityFormClass(1), "_id");
assertThat(column("_id"), hasValues("s0000000002", "s0000000003"));
}
Aggregations