Search in sources :

Example 1 with CreateClientCreationDetail

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

the class ClientRESTController method createClient.

@RequestMapping(value = "client/create", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> createClient(@RequestBody String request) throws Throwable {
    ObjectMapper om = createClientMapping();
    CreateClientCreationDetail creationDetail = null;
    MeetingBO meetingBO = null;
    try {
        creationDetail = om.readValue(request, CreateClientCreationDetail.class);
    } catch (JsonMappingException e) {
        e.getCause();
    }
    validate(creationDetail);
    meetingBO = (MeetingBO) creationDetail.getMeeting().toBO();
    ClientCreationDetail client = createClient(creationDetail);
    CustomerDetailsDto clientDetails = clientServiceFacade.createNewClient(client, meetingBO.toDto(), null);
    ClientInformationDto clientInfo = clientServiceFacade.getClientInformationDto(clientDetails.getGlobalCustNum());
    Map<String, String> map = new HashMap<String, String>();
    map.put("status", "success");
    map.put("globalCustNum", clientInfo.getClientDisplay().getGlobalCustNum());
    map.put("accountNum", clientInfo.getCustomerAccountSummary().getGlobalAccountNum());
    map.put("address", clientInfo.getAddress().getDisplayAddress());
    map.put("city", clientInfo.getAddress().getCity());
    map.put("state", clientInfo.getAddress().getState());
    map.put("country", clientInfo.getAddress().getCountry());
    map.put("postal code", clientInfo.getAddress().getZip());
    map.put("phone", clientInfo.getAddress().getPhoneNumber());
    map.put("dispalyName", clientInfo.getClientDisplay().getDisplayName());
    map.put("externalId", clientInfo.getClientDisplay().getExternalId());
    map.put("loanOfficer", clientInfo.getClientDisplay().getLoanOfficerName());
    return map;
}
Also used : CreateClientCreationDetail(org.mifos.application.servicefacade.CreateClientCreationDetail) CreateClientCreationDetail(org.mifos.application.servicefacade.CreateClientCreationDetail) ClientCreationDetail(org.mifos.dto.domain.ClientCreationDetail) HashMap(java.util.HashMap) MeetingBO(org.mifos.application.meeting.business.MeetingBO) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) ClientInformationDto(org.mifos.dto.screen.ClientInformationDto) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) 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 CreateClientCreationDetail (org.mifos.application.servicefacade.CreateClientCreationDetail)1 ClientCreationDetail (org.mifos.dto.domain.ClientCreationDetail)1 CustomerDetailsDto (org.mifos.dto.domain.CustomerDetailsDto)1 ClientInformationDto (org.mifos.dto.screen.ClientInformationDto)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1