use of org.motechproject.mds.web.SelectResult in project motech by motech.
the class EntityControllerTest method shouldReturnRecordsSortedByName.
@Test
public void shouldReturnRecordsSortedByName() throws Exception {
List<EntityDto> expected = new ArrayList<>();
expected.add(new EntityDto(9005L, "org.motechproject.appointments.api.model.Appointment", "MOTECH Appointments API", SecurityMode.EVERYONE, null));
expected.add(new EntityDto(9006L, "org.motechproject.ivr.domain.CallDetailRecord", "MOTECH IVR API", SecurityMode.EVERYONE, null));
expected.add(new EntityDto(9008L, "org.motechproject.messagecampaign.domain.campaign.Campaign", "MOTECH Message Campaign", SecurityMode.EVERYONE, null));
expected.add(new EntityDto(9001L, "org.motechproject.openmrs.ws.resource.model.Patient", "MOTECH OpenMRS Web Services", "navio", SecurityMode.EVERYONE, null));
expected.add(new EntityDto(9003L, "org.motechproject.openmrs.ws.resource.model.Patient", "MOTECH OpenMRS Web Services", "accra", SecurityMode.EVERYONE, null));
expected.add(new EntityDto(9002L, "org.motechproject.openmrs.ws.resource.model.Person", "MOTECH OpenMRS Web Services", "navio", SecurityMode.EVERYONE, null));
expected.add(new EntityDto(9004L, "org.motechproject.openmrs.ws.resource.model.Person", "MOTECH OpenMRS Web Services", "accra", SecurityMode.EVERYONE, null));
expected.add(new EntityDto(9007L, "org.motechproject.mds.entity.Voucher", SecurityMode.EVERYONE, null));
SelectResult expectedResult = new SelectResult(new SelectData(null, 1, 10), expected);
controller.perform(get("/selectEntities").param("term", "").param("page", String.valueOf(1)).param("pageLimit", String.valueOf(10))).andExpect(status().isOk()).andExpect(content().string(new ObjectMapper().writeValueAsString(expectedResult)));
}
use of org.motechproject.mds.web.SelectResult 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);
}
use of org.motechproject.mds.web.SelectResult 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);
}
Aggregations