Search in sources :

Example 1 with TypeDisplayNameComparator

use of org.motechproject.mds.web.comparator.TypeDisplayNameComparator in project motech by motech.

the class AvailableController method getTypes.

@RequestMapping(value = "/available/types", method = RequestMethod.GET)
@ResponseBody
public SelectResult<TypeDto> getTypes(SelectData data) {
    List<TypeDto> list = typeService.getAllTypes();
    // The Long and Date types are available for DDEs exclusively
    list.remove(typeService.findType(Long.class));
    list.remove(typeService.findType(Date.class));
    list.remove(typeService.findType(Relationship.class));
    // The DateTime and LocalDate types from Joda are available for DDEs exclusively
    list.remove(typeService.findType(DateTime.class));
    list.remove(typeService.findType(org.joda.time.LocalDate.class));
    // TextArea type is available only from UI
    list.add(textAreaUIType());
    CollectionUtils.filter(list, new TypeMatcher(data.getTerm(), messageSource));
    Collections.sort(list, new TypeDisplayNameComparator(messageSource));
    return new SelectResult<>(data, list);
}
Also used : SelectResult(org.motechproject.mds.web.SelectResult) Relationship(org.motechproject.mds.domain.Relationship) TypeMatcher(org.motechproject.mds.web.matcher.TypeMatcher) TypeDisplayNameComparator(org.motechproject.mds.web.comparator.TypeDisplayNameComparator) TypeDto(org.motechproject.mds.dto.TypeDto) Date(java.util.Date) DateTime(org.joda.time.DateTime) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Date (java.util.Date)1 DateTime (org.joda.time.DateTime)1 Relationship (org.motechproject.mds.domain.Relationship)1 TypeDto (org.motechproject.mds.dto.TypeDto)1 SelectResult (org.motechproject.mds.web.SelectResult)1 TypeDisplayNameComparator (org.motechproject.mds.web.comparator.TypeDisplayNameComparator)1 TypeMatcher (org.motechproject.mds.web.matcher.TypeMatcher)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1