Search in sources :

Example 1 with Cardinality

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());
}
Also used : Cardinality(org.activityinfo.model.type.Cardinality) EnumType(org.activityinfo.model.type.enumerated.EnumType) EnumItem(org.activityinfo.model.type.enumerated.EnumItem) FormField(org.activityinfo.model.form.FormField)

Example 2 with Cardinality

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);
}
Also used : Cardinality(org.activityinfo.model.type.Cardinality) EnumType(org.activityinfo.model.type.enumerated.EnumType) EnumItem(org.activityinfo.model.type.enumerated.EnumItem)

Aggregations

Cardinality (org.activityinfo.model.type.Cardinality)2 EnumItem (org.activityinfo.model.type.enumerated.EnumItem)2 EnumType (org.activityinfo.model.type.enumerated.EnumType)2 FormField (org.activityinfo.model.form.FormField)1