use of org.activityinfo.model.type.Cardinality in project activityinfo by bedatadriven.
the class AttributeGroupDTO method asFormField.
@Override
public FormField asFormField() {
Cardinality cardinality = isMultipleAllowed() ? Cardinality.MULTIPLE : Cardinality.SINGLE;
List<EnumItem> values = Lists.newArrayList();
for (AttributeDTO attribute : getAttributes()) {
values.add(new EnumItem(CuidAdapter.attributeId(attribute.getId()), attribute.getName()));
}
return new FormField(CuidAdapter.attributeGroupField(getId())).setLabel(getName()).setType(new EnumType(cardinality, values)).setRequired(isMandatory());
}
use of org.activityinfo.model.type.Cardinality in project activityinfo by bedatadriven.
the class ActivityLoader method createEnumType.
private EnumType createEnumType(ResultSet rs, Map<Integer, List<EnumItem>> attributes) throws SQLException {
Cardinality cardinality;
if (rs.getBoolean("multipleAllowed")) {
cardinality = Cardinality.MULTIPLE;
} else {
cardinality = Cardinality.SINGLE;
}
List<EnumItem> enumValues = attributes.get(rs.getInt("id"));
if (enumValues == null) {
enumValues = Lists.newArrayList();
}
return new EnumType(cardinality, enumValues);
}
Aggregations