use of org.motechproject.mds.domain.UIDisplayFieldComparator in project motech by motech.
the class EntityServiceImpl method getEntityFieldsByClassName.
private List<FieldDto> getEntityFieldsByClassName(String className, boolean forUI) {
Entity entity = allEntities.retrieveByClassName(className);
assertEntityExists(entity, className);
List<Field> fields = new ArrayList<>(entity.getFields());
Collections.sort(fields, new UIDisplayFieldComparator());
return toFieldDtos(entity, fields, forUI);
}
use of org.motechproject.mds.domain.UIDisplayFieldComparator in project motech by motech.
the class EntityServiceImpl method getFields.
private List<FieldDto> getFields(Long entityId, boolean forDraft, boolean forUi) {
Entity entity = (forDraft) ? getEntityDraft(entityId) : allEntities.retrieveById(entityId);
assertEntityExists(entity, entityId);
// the returned collection is unmodifiable
List<Field> fields = new ArrayList<>(entity.getFields());
// for data browser purposes, we sort the fields by their ui display order
if (!forDraft) {
Collections.sort(fields, new UIDisplayFieldComparator());
}
// if it's for the UI, then we add combobox options
List<FieldDto> fieldDtos = toFieldDtos(entity, fields, forUi);
return addNonPersistentFieldsData(fieldDtos, entity);
}
Aggregations