Search in sources :

Example 1 with SqlInsert

use of org.activityinfo.store.mysql.update.SqlInsert in project activityinfo by bedatadriven.

the class LocationFormStorage method add.

@Override
public void add(TypedRecordUpdate update) {
    long newVersion = incrementVersion();
    int locationId = CuidAdapter.getLegacyIdFromCuid(update.getRecordId());
    SqlInsert insert = SqlInsert.insertInto("location");
    insert.value("locationTypeId", locationTypeId);
    insert.value("locationId", locationId);
    insert.value("timeEdited", System.currentTimeMillis());
    insert.value("version", newVersion);
    insert.value("name", getName(update), 50);
    insert.value("axe", getAxe(update), 50);
    GeoPoint point = (GeoPoint) update.getChangedFieldValues().get(pointFieldId);
    if (point != null) {
        insert.value("x", point.getLongitude());
        insert.value("y", point.getLatitude());
    }
    insert.execute(executor);
    Set<Integer> adminEntities = fetchParents(getAdminEntities(update));
    insertAdminLinks(locationId, adminEntities);
}
Also used : GeoPoint(org.activityinfo.model.type.geo.GeoPoint) SqlInsert(org.activityinfo.store.mysql.update.SqlInsert) GeoPoint(org.activityinfo.model.type.geo.GeoPoint)

Aggregations

GeoPoint (org.activityinfo.model.type.geo.GeoPoint)1 SqlInsert (org.activityinfo.store.mysql.update.SqlInsert)1