Search in sources :

Example 1 with EntityMatcher

use of org.motechproject.mds.web.matcher.EntityMatcher in project motech by motech.

the class EntityController method getEntities.

@RequestMapping(value = "/selectEntities", method = RequestMethod.GET)
@PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS)
@ResponseBody
public SelectResult<EntityDto> getEntities(SelectData data) {
    List<EntityDto> list = entityService.listEntities();
    CollectionUtils.filter(list, new EntityMatcher(data.getTerm()));
    Collections.sort(list, new EntityNameComparator());
    return new SelectResult<>(data, list);
}
Also used : EntityDto(org.motechproject.mds.dto.EntityDto) SelectResult(org.motechproject.mds.web.SelectResult) EntityMatcher(org.motechproject.mds.web.matcher.EntityMatcher) EntityNameComparator(org.motechproject.mds.web.comparator.EntityNameComparator) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

EntityDto (org.motechproject.mds.dto.EntityDto)1 SelectResult (org.motechproject.mds.web.SelectResult)1 EntityNameComparator (org.motechproject.mds.web.comparator.EntityNameComparator)1 EntityMatcher (org.motechproject.mds.web.matcher.EntityMatcher)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1