use of org.activityinfo.model.type.expr.CalculatedFieldType in project activityinfo by bedatadriven.
the class ActivityLoader method addField.
private void addField(Activity activity, ResultSet rs, Map<Integer, List<EnumItem>> attributes) throws SQLException {
int id = rs.getInt("id");
FormField formField;
if (rs.getString("Type").equals("ENUM")) {
formField = new FormField(CuidAdapter.attributeGroupField(id));
} else {
formField = new FormField(CuidAdapter.indicatorField(id));
}
formField.setLabel(rs.getString("Name"));
formField.setRequired(getMandatory(rs));
formField.setVisible(getVisible(rs));
formField.setDescription(rs.getString("Description"));
formField.setCode(rs.getString("code"));
if (rs.getBoolean("ca") && rs.getString("expr") != null) {
formField.setType(new CalculatedFieldType(rs.getString("expr")));
} else {
switch(rs.getString("Type")) {
default:
case "QUANTITY":
formField.setType(new QuantityType().setUnits(rs.getString("units")).setAggregation(rs.getInt("Aggregation")));
break;
case "BARCODE":
formField.setType(BarcodeType.INSTANCE);
break;
case "FREE_TEXT":
formField.setType(TextType.SIMPLE);
break;
case "NARRATIVE":
formField.setType(NarrativeType.INSTANCE);
break;
case "ENUM":
formField.setType(createEnumType(rs, attributes));
break;
}
}
ActivityField field = new ActivityField(id, rs.getString("category"), formField, rs.getInt("sortOrder"));
field.sortOrder = rs.getInt("sortOrder");
activity.fields.add(field);
}
Aggregations