Search in sources :

Example 1 with FieldConverter

use of org.activityinfo.store.hrd.FieldConverter in project activityinfo by bedatadriven.

the class FormRecordEntity method setFieldValues.

public void setFieldValues(FormClass formClass, Map<ResourceId, FieldValue> values) {
    if (fieldValues == null) {
        fieldValues = new EmbeddedEntity();
    }
    for (FormField field : formClass.getFields()) {
        if (values.containsKey(field.getId())) {
            FieldValue value = values.get(field.getId());
            if (value == null) {
                fieldValues.removeProperty(field.getName());
            } else {
                FieldConverter converter = FieldConverters.forType(field.getType());
                fieldValues.setUnindexedProperty(field.getName(), converter.toHrdProperty(value));
            }
        }
    }
}
Also used : FieldConverter(org.activityinfo.store.hrd.FieldConverter) FieldValue(org.activityinfo.model.type.FieldValue) EmbeddedEntity(com.google.appengine.api.datastore.EmbeddedEntity) FormField(org.activityinfo.model.form.FormField)

Aggregations

EmbeddedEntity (com.google.appengine.api.datastore.EmbeddedEntity)1 FormField (org.activityinfo.model.form.FormField)1 FieldValue (org.activityinfo.model.type.FieldValue)1 FieldConverter (org.activityinfo.store.hrd.FieldConverter)1