Search in sources :

Example 6 with RecordUpdate

use of org.activityinfo.model.resource.RecordUpdate in project activityinfo by bedatadriven.

the class MySqlUpdateTest method updateAdminEntity.

@Test
public void updateAdminEntity() throws JsonMappingException {
    RecordUpdate changeObject = new RecordUpdate();
    changeObject.setRecordId(entity(21).asString());
    changeObject.setFormId(adminLevelFormClass(2).asString());
    changeObject.setFieldValue("name", "Nouveau Irumu");
    Updater updater = updater();
    updater.setEnforcePermissions(false);
    updater.executeChange(changeObject);
    query(adminLevelFormClass(2), "_id", "name");
    assertThat(column("_id"), hasValues("z0000000010", "z0000000011", "z0000000012", "z0000000013", "z0000000021"));
    assertThat(column("name"), hasValues("Bukavu", "Walungu", "Shabunda", "Kalehe", "Nouveau Irumu"));
}
Also used : RecordUpdate(org.activityinfo.model.resource.RecordUpdate) TypedRecordUpdate(org.activityinfo.store.spi.TypedRecordUpdate) Updater(org.activityinfo.store.query.server.Updater) Test(org.junit.Test)

Example 7 with RecordUpdate

use of org.activityinfo.model.resource.RecordUpdate in project activityinfo by bedatadriven.

the class MySqlUpdateTest method createSite.

@Test
public void createSite() throws JsonMappingException {
    RecordUpdate changeObject = new RecordUpdate();
    changeObject.setRecordId("s0000000013");
    changeObject.setFormId(activityFormClass(1).asString());
    changeObject.setFieldValue("partner", partnerRecordId(1).asString());
    changeObject.setFieldValue("date1", "2015-01-01");
    changeObject.setFieldValue("date2", "2015-01-01");
    changeObject.setFieldValue("BENE", 45000);
    changeObject.setFieldValue("location", locationInstanceId(3).asString());
    Updater updater = updater();
    updater.executeChange(changeObject);
    query(activityFormClass(1), "_id", "partner.label", "BENE");
    assertThat(column("_id"), hasValues("s0000000001", "s0000000002", "s0000000003", "s0000000013"));
    assertThat(column("partner.label"), hasValues("NRC", "NRC", "Solidarites", "NRC"));
    assertThat(column("BENE"), hasValues(1500, 3600, 10000, 45000));
}
Also used : RecordUpdate(org.activityinfo.model.resource.RecordUpdate) TypedRecordUpdate(org.activityinfo.store.spi.TypedRecordUpdate) Updater(org.activityinfo.store.query.server.Updater) Test(org.junit.Test)

Example 8 with RecordUpdate

use of org.activityinfo.model.resource.RecordUpdate in project activityinfo by bedatadriven.

the class MySqlUpdateTest method creatingActivitiesWithNullaryLocations.

@Test
public void creatingActivitiesWithNullaryLocations() {
    int newId = new KeyGenerator().generateInt();
    RecordUpdate change = new RecordUpdate();
    change.setRecordId(cuid(SITE_DOMAIN, newId).asString());
    change.setFormId(activityFormClass(ADVOCACY).asString());
    change.setFieldValue("partner", partnerRecordId(1).asString());
    change.setFieldValue("date1", "2015-01-01");
    change.setFieldValue("date2", "2015-01-31");
    Updater updater = updater();
    updater.executeChange(change);
    query(activityFormClass(ADVOCACY), "_id", "partner");
}
Also used : RecordUpdate(org.activityinfo.model.resource.RecordUpdate) TypedRecordUpdate(org.activityinfo.store.spi.TypedRecordUpdate) Updater(org.activityinfo.store.query.server.Updater) KeyGenerator(org.activityinfo.model.legacy.KeyGenerator) GeoPoint(org.activityinfo.model.type.geo.GeoPoint) Test(org.junit.Test)

Example 9 with RecordUpdate

use of org.activityinfo.model.resource.RecordUpdate in project activityinfo by bedatadriven.

the class MySqlUpdateTest method deleteAdminEntity.

@Test
public void deleteAdminEntity() {
    RecordUpdate changeObject = new RecordUpdate();
    changeObject.setRecordId(entity(21).asString());
    changeObject.setFormId(adminLevelFormClass(2).asString());
    changeObject.setDeleted(true);
    Updater updater = updater();
    updater.setEnforcePermissions(false);
    updater.executeChange(changeObject);
    query(adminLevelFormClass(2), "_id", "name");
    assertThat(column("name"), hasValues("Bukavu", "Walungu", "Shabunda", "Kalehe"));
}
Also used : RecordUpdate(org.activityinfo.model.resource.RecordUpdate) TypedRecordUpdate(org.activityinfo.store.spi.TypedRecordUpdate) Updater(org.activityinfo.store.query.server.Updater) Test(org.junit.Test)

Example 10 with RecordUpdate

use of org.activityinfo.model.resource.RecordUpdate in project activityinfo by bedatadriven.

the class MySqlUpdateTest method updateSite.

@Test
public void updateSite() throws JsonMappingException {
    RecordUpdate changeObject = new RecordUpdate();
    changeObject.setRecordId("s0000000001");
    changeObject.setFormId(activityFormClass(1).asString());
    changeObject.setFieldValue("partner", partnerRecordId(2).asString());
    Updater updater = updater();
    updater.executeChange(changeObject);
    query(activityFormClass(1), "_id", "partner.label", "BENE");
    assertThat(column("_id"), hasValues("s0000000001", "s0000000002", "s0000000003"));
    assertThat(column("partner.label"), hasValues("Solidarites", "NRC", "Solidarites"));
    assertThat(column("BENE"), hasValues(1500, 3600, 10000));
}
Also used : RecordUpdate(org.activityinfo.model.resource.RecordUpdate) TypedRecordUpdate(org.activityinfo.store.spi.TypedRecordUpdate) Updater(org.activityinfo.store.query.server.Updater) Test(org.junit.Test)

Aggregations

RecordUpdate (org.activityinfo.model.resource.RecordUpdate)21 Test (org.junit.Test)14 TypedRecordUpdate (org.activityinfo.store.spi.TypedRecordUpdate)12 Updater (org.activityinfo.store.query.server.Updater)11 KeyGenerator (org.activityinfo.model.legacy.KeyGenerator)3 ResourceId (org.activityinfo.model.resource.ResourceId)3 RecordRef (org.activityinfo.model.type.RecordRef)3 GeoPoint (org.activityinfo.model.type.geo.GeoPoint)3 HashMap (java.util.HashMap)2 FormInstance (org.activityinfo.model.form.FormInstance)2 RecordTransaction (org.activityinfo.model.resource.RecordTransaction)2 RecordTransactionBuilder (org.activityinfo.model.resource.RecordTransactionBuilder)2 FieldInput (org.activityinfo.ui.client.input.model.FieldInput)2 FormInputModel (org.activityinfo.ui.client.input.model.FormInputModel)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Map (java.util.Map)1 JsOverlay (jsinterop.annotations.JsOverlay)1 FieldMapping (org.activityinfo.geoadmin.merge2.view.mapping.FieldMapping)1