use of org.activityinfo.model.form.FormField 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;
}
use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.
the class LocationFieldBinding method buildAdminBindings.
private void buildAdminBindings(FormClass locationForm, FormTree formTree, int adminFieldIndex) {
Optional<FormField> potentialAdminField = locationForm.getFieldIfPresent(CuidAdapter.field(locationForm.getId(), adminFieldIndex));
if (potentialAdminField.isPresent()) {
FormField adminField = potentialAdminField.get();
Iterator<ResourceId> adminLevelRange = getRange(adminField);
while (adminLevelRange.hasNext()) {
ResourceId adminLevelId = adminLevelRange.next();
buildLocationBindings(formTree.getFormClass(adminLevelId), formTree);
}
}
}
use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.
the class XFormBuilder method gps.
private OdkField gps(FormField original) {
FormField formField = new FormField(gpsFieldId);
formField.setType(GeoPointType.INSTANCE);
formField.setLabel("GPS coordinates (" + original.getLabel() + ")");
return new OdkField(formField, factory.get(formField.getType()));
}
use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.
the class ItemSetBuilder method findRanges.
private Set<ResourceId> findRanges(ResourceId formClassId) {
FormClass formClass = locator.getFormClass(formClassId);
Set<ResourceId> rangeClassIds = Sets.newHashSet();
for (FormField field : formClass.getFields()) {
if (field.getType() instanceof ReferenceType) {
rangeClassIds.addAll(((ReferenceType) field.getType()).getRange());
}
}
return rangeClassIds;
}
use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.
the class GcsBlobFieldStorageServiceTest method addAttachmentField.
private FormClass addAttachmentField(int activityId, ResourceId attachmentFieldId) {
FormClass formClass = assertResolves(locator.getFormClass(CuidAdapter.activityFormClass(activityId)));
formClass.addElement(new FormField(attachmentFieldId).setLabel("Attachment").setType(AttachmentType.TYPE_CLASS.createType()).setVisible(true));
assertResolves(locator.persist(formClass));
// re-fetch
return assertResolves(locator.getFormClass(formClass.getId()));
}
Aggregations