Search in sources :

Example 1 with CountryInstance

use of org.activityinfo.store.mysql.metadata.CountryInstance in project activityinfo by bedatadriven.

the class GetSitesHandler method buildLocationQuery.

private QueryModel buildLocationQuery(QueryModel query, FormTree formTree, FormClass form) {
    Optional<FormField> potentialLocationField = form.getFieldIfPresent(CuidAdapter.field(form.getId(), CuidAdapter.LOCATION_FIELD));
    if (potentialLocationField.isPresent()) {
        FormField locationField = potentialLocationField.get();
        // Location binding will take care of the details wrt geo fields/admin field
        addBinding(new LocationFieldBinding(locationField), query, formTree);
    } else {
        // country form, get country instance from ActivityLoader
        CountryInstance country = getCountryInstance(form.getId());
        if (country != null) {
            addBinding(new CountryFieldBinding(country), query, formTree);
        }
    }
    return query;
}
Also used : CountryInstance(org.activityinfo.store.mysql.metadata.CountryInstance) FormField(org.activityinfo.model.form.FormField)

Aggregations

FormField (org.activityinfo.model.form.FormField)1 CountryInstance (org.activityinfo.store.mysql.metadata.CountryInstance)1