Search in sources :

Example 1 with CreateGroupCreationDetailDto

use of org.mifos.application.servicefacade.CreateGroupCreationDetailDto in project head by mifos.

the class GroupRESTController method createGroup.

@RequestMapping(value = "group/create", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> createGroup(@RequestBody String request) throws Throwable {
    ObjectMapper om = createGroupMapping();
    CreateGroupCreationDetailDto creationDetail = null;
    MeetingBO meetingBO = null;
    try {
        creationDetail = om.readValue(request, CreateGroupCreationDetailDto.class);
    } catch (JsonMappingException e) {
        throw e.getCause();
    }
    validate(creationDetail);
    meetingBO = (MeetingBO) creationDetail.getMeeting().toBO();
    GroupCreationDetail group = createGroup(creationDetail);
    CustomerDetailsDto groupDetails = groupServiceFacade.createNewGroup(group, meetingBO.toDto());
    GroupInformationDto groupInfo = groupServiceFacade.getGroupInformationDto(groupDetails.getGlobalCustNum());
    Map<String, String> map = new HashMap<String, String>();
    map.put("status", "success");
    map.put("globalCusNum", groupInfo.getGroupDisplay().getGlobalCustNum());
    map.put("accountNum", groupInfo.getCustomerAccountSummary().getGlobalAccountNum());
    map.put("address", groupInfo.getAddress().getDisplayAddress());
    map.put("city", groupInfo.getAddress().getCity());
    map.put("state", groupInfo.getAddress().getState());
    map.put("country", groupInfo.getAddress().getCountry());
    map.put("postal code", groupInfo.getAddress().getZip());
    map.put("phone", groupInfo.getAddress().getPhoneNumber());
    map.put("dispalyName", groupInfo.getGroupDisplay().getDisplayName());
    map.put("externalId", groupInfo.getGroupDisplay().getExternalId());
    map.put("loanOfficer", groupInfo.getGroupDisplay().getLoanOfficerName());
    return map;
}
Also used : HashMap(java.util.HashMap) MeetingBO(org.mifos.application.meeting.business.MeetingBO) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) CreateGroupCreationDetailDto(org.mifos.application.servicefacade.CreateGroupCreationDetailDto) GroupCreationDetail(org.mifos.dto.domain.GroupCreationDetail) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) GroupInformationDto(org.mifos.dto.screen.GroupInformationDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

HashMap (java.util.HashMap)1 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1 CreateGroupCreationDetailDto (org.mifos.application.servicefacade.CreateGroupCreationDetailDto)1 CustomerDetailsDto (org.mifos.dto.domain.CustomerDetailsDto)1 GroupCreationDetail (org.mifos.dto.domain.GroupCreationDetail)1 GroupInformationDto (org.mifos.dto.screen.GroupInformationDto)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1