Search in sources :

Example 1 with UIDisplayFieldComparator

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);
}
Also used : MdsEntity(org.motechproject.mds.domain.MdsEntity) Entity(org.motechproject.mds.domain.Entity) MdsVersionedEntity(org.motechproject.mds.domain.MdsVersionedEntity) Field(org.motechproject.mds.domain.Field) ArrayList(java.util.ArrayList) UIDisplayFieldComparator(org.motechproject.mds.domain.UIDisplayFieldComparator)

Example 2 with UIDisplayFieldComparator

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);
}
Also used : MdsEntity(org.motechproject.mds.domain.MdsEntity) Entity(org.motechproject.mds.domain.Entity) MdsVersionedEntity(org.motechproject.mds.domain.MdsVersionedEntity) Field(org.motechproject.mds.domain.Field) ArrayList(java.util.ArrayList) UIDisplayFieldComparator(org.motechproject.mds.domain.UIDisplayFieldComparator) LookupFieldDto(org.motechproject.mds.dto.LookupFieldDto) FieldDto(org.motechproject.mds.dto.FieldDto)

Aggregations

ArrayList (java.util.ArrayList)2 Entity (org.motechproject.mds.domain.Entity)2 Field (org.motechproject.mds.domain.Field)2 MdsEntity (org.motechproject.mds.domain.MdsEntity)2 MdsVersionedEntity (org.motechproject.mds.domain.MdsVersionedEntity)2 UIDisplayFieldComparator (org.motechproject.mds.domain.UIDisplayFieldComparator)2 FieldDto (org.motechproject.mds.dto.FieldDto)1 LookupFieldDto (org.motechproject.mds.dto.LookupFieldDto)1