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);
}