use of org.activityinfo.server.endpoint.odk.OdkField 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.server.endpoint.odk.OdkField in project activityinfo by bedatadriven.
the class XFormBuilder method createBindings.
private Collection<Bind> createBindings() {
List<Bind> bindings = Lists.newArrayList();
bindings.add(instanceIdBinding());
bindings.add(startDate());
bindings.add(endDate());
for (OdkField field : fields) {
// with the start/end date of interview
if (isLocation(formClass, field.getModel())) {
bindings.add(locationNameField());
bindings.add(gpsField());
} else if (!dateFields.contains(field.getModel().getId())) {
Bind bind = new Bind();
bind.setNodeSet(field.getAbsoluteFieldName());
bind.setType(field.getBuilder().getModelBindType());
bind.setConstraint(field.getBuilder().getConstraint().orNull());
// TODO Fix this
// bind.calculate = formField.getExpression();
bind.setRelevant(xPathBuilder.build(field.getModel().getRelevanceConditionExpression()));
if (field.getModel().isRequired()) {
bind.setRequired(XPathBuilder.TRUE);
}
bindings.add(bind);
}
}
return bindings;
}
use of org.activityinfo.server.endpoint.odk.OdkField in project activityinfo by bedatadriven.
the class XFormBuilder method createInstance.
private Instance createInstance() {
InstanceElement data = new InstanceElement("data");
data.setId(formClass.getId().asString());
data.addChild(new InstanceElement("meta", new InstanceElement("instanceID"), new InstanceElement("userID", userId)));
data.addChild(new InstanceElement("field_" + startDateFieldId.asString()));
data.addChild(new InstanceElement("field_" + endDateFieldId.asString()));
for (OdkField field : fields) {
if (isLocation(formClass, field.getModel())) {
data.addChild(new InstanceElement("field_" + locationNameFieldId.asString()));
data.addChild(new InstanceElement("field_" + gpsFieldId.asString()));
} else if (!dateFields.contains(field.getModel().getId())) {
data.addChild(new InstanceElement(field.getRelativeFieldName()));
}
}
return new Instance(data);
}
use of org.activityinfo.server.endpoint.odk.OdkField in project activityinfo by bedatadriven.
the class XFormBuilder method locationName.
private OdkField locationName(FormField original) {
FormField formField = new FormField(locationNameFieldId);
formField.setType(TextType.SIMPLE);
formField.setLabel(original.getLabel());
formField.setRequired(original.isRequired());
return new OdkField(formField, factory.get(formField.getType()));
}