Search in sources :

Example 1 with OdkField

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()));
}
Also used : OdkField(org.activityinfo.server.endpoint.odk.OdkField) FormField(org.activityinfo.model.form.FormField)

Example 2 with OdkField

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;
}
Also used : OdkField(org.activityinfo.server.endpoint.odk.OdkField)

Example 3 with OdkField

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);
}
Also used : OdkField(org.activityinfo.server.endpoint.odk.OdkField)

Example 4 with OdkField

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()));
}
Also used : OdkField(org.activityinfo.server.endpoint.odk.OdkField) FormField(org.activityinfo.model.form.FormField)

Aggregations

OdkField (org.activityinfo.server.endpoint.odk.OdkField)4 FormField (org.activityinfo.model.form.FormField)2