Search in sources :

Example 1 with CreateCenterDetailsDto

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

the class CenterRESTController method createCenter.

@RequestMapping(value = "/center/create", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> createCenter(@RequestBody String request) throws Throwable {
    ObjectMapper om = createCenterMaping();
    CreateCenterDetailsDto creationDetail = null;
    MeetingBO meetingBO = null;
    try {
        creationDetail = om.readValue(request, CreateCenterDetailsDto.class);
    } catch (JsonMappingException e) {
        throw e.getCause();
    }
    validate(creationDetail);
    meetingBO = (MeetingBO) creationDetail.getMeeting().toBO();
    CenterCreationDetail center = createCenter(creationDetail);
    CustomerDetailsDto details = this.centerServiceFacade.createNewCenter(center, meetingBO.toDto());
    CenterInformationDto centerInfo = this.centerServiceFacade.getCenterInformationDto(details.getGlobalCustNum());
    Map<String, String> map = new HashMap<String, String>();
    map.put("status", "success");
    map.put("globalCustNum", centerInfo.getCenterDisplay().getGlobalCustNum());
    map.put("accountNum", centerInfo.getCustomerAccountSummary().getGlobalAccountNum());
    map.put("name", center.getDisplayName());
    map.put("externalId", center.getExternalId());
    map.put("mfiDate", center.getMfiJoiningDate().toString());
    map.put("address", center.getAddressDto().getDisplayAddress());
    map.put("city", center.getAddressDto().getCity());
    map.put("state", center.getAddressDto().getState());
    map.put("country", center.getAddressDto().getCountry());
    map.put("postal code", center.getAddressDto().getZip());
    map.put("phone", center.getAddressDto().getPhoneNumber());
    return map;
}
Also used : CenterCreationDetail(org.mifos.dto.domain.CenterCreationDetail) HashMap(java.util.HashMap) MeetingBO(org.mifos.application.meeting.business.MeetingBO) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) CreateCenterDetailsDto(org.mifos.application.servicefacade.CreateCenterDetailsDto) CenterInformationDto(org.mifos.dto.domain.CenterInformationDto) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) 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 CreateCenterDetailsDto (org.mifos.application.servicefacade.CreateCenterDetailsDto)1 CenterCreationDetail (org.mifos.dto.domain.CenterCreationDetail)1 CenterInformationDto (org.mifos.dto.domain.CenterInformationDto)1 CustomerDetailsDto (org.mifos.dto.domain.CustomerDetailsDto)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1