Search in sources :

Example 61 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.

the class CenterRESTController method getCenterChargesByNumber.

@RequestMapping(value = "center/num-{globalCustNum}/charges", method = RequestMethod.GET)
@ResponseBody
public CustomerChargesDetailsDto getCenterChargesByNumber(@PathVariable String globalCustNum) {
    CenterBO centerBO = customerDao.findCenterBySystemId(globalCustNum);
    CustomerChargesDetailsDto centerCharges = centerServiceFacade.retrieveChargesDetails(centerBO.getCustomerId());
    centerCharges.addActivities(centerServiceFacade.retrieveRecentActivities(centerBO.getCustomerId(), 3));
    return centerCharges;
}
Also used : CustomerChargesDetailsDto(org.mifos.dto.domain.CustomerChargesDetailsDto) CenterBO(org.mifos.customers.center.business.CenterBO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 62 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.

the class CollectionSheetRESTController method saveCollectionSheet.

@RequestMapping(value = "/collectionsheet/save", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> saveCollectionSheet(@RequestBody JSONSaveCollectionsheet request) throws Throwable {
    Map<String, Object> map = new HashMap<String, Object>();
    ObjectMapper om = createObjectMapper();
    List<InvalidSaveCollectionSheetReason> reasons = new ArrayList<InvalidSaveCollectionSheetReason>();
    CollectionSheetErrorsDto errors = null;
    SaveCollectionSheetDto saveCollectionSheetDto = null;
    try {
        saveCollectionSheetDto = om.readValue(request.getJson(), SaveCollectionSheetDto.class);
    } catch (JsonMappingException e) {
        if (e.getCause() instanceof SaveCollectionSheetException) {
            reasons.addAll(((SaveCollectionSheetException) e.getCause()).getInvalidSaveCollectionSheetReasons());
        } else {
            throw e.getCause();
        }
    }
    if (saveCollectionSheetDto != null) {
        try {
            errors = collectionSheetServiceFacade.saveCollectionSheet(saveCollectionSheetDto);
            map.put("errors", errors != null ? errors.getErrorText() : null);
        } catch (MifosRuntimeException e) {
            map.put("errors", e.getMessage());
        }
    }
    map.put("invalidCollectionSheet", reasons);
    return map;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SaveCollectionSheetDto(org.mifos.application.servicefacade.SaveCollectionSheetDto) InvalidSaveCollectionSheetReason(org.mifos.application.servicefacade.InvalidSaveCollectionSheetReason) SaveCollectionSheetException(org.mifos.application.servicefacade.SaveCollectionSheetException) CollectionSheetErrorsDto(org.mifos.application.servicefacade.CollectionSheetErrorsDto) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) MifosRuntimeException(org.mifos.core.MifosRuntimeException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 63 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.

the class CustomerRESTController method getApplicableFees.

@RequestMapping(value = "/customer/num-{globalCustNum}/fees", method = RequestMethod.GET)
@ResponseBody
public Map<String, Map<String, String>> getApplicableFees(@PathVariable String globalCustNum) throws Exception {
    CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
    Integer accountId = customerBO.getCustomerAccount().getAccountId();
    List<ApplicableCharge> applicableCharges = this.accountServiceFacade.getApplicableFees(accountId);
    Map<String, Map<String, String>> map = new HashMap<String, Map<String, String>>();
    for (ApplicableCharge applicableCharge : applicableCharges) {
        Map<String, String> feeMap = new HashMap<String, String>();
        feeMap.put("feeId", applicableCharge.getFeeId());
        feeMap.put("amountOrRate", applicableCharge.getAmountOrRate());
        feeMap.put("formula", applicableCharge.getFormula());
        feeMap.put("periodicity", applicableCharge.getPeriodicity());
        feeMap.put("paymentType", applicableCharge.getPaymentType());
        feeMap.put("isRateType", applicableCharge.getIsRateType());
        map.put(applicableCharge.getFeeName(), feeMap);
    }
    return map;
}
Also used : HashMap(java.util.HashMap) ApplicableCharge(org.mifos.dto.domain.ApplicableCharge) CustomerBO(org.mifos.customers.business.CustomerBO) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 64 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping 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)

Example 65 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.

the class GroupRESTController method getGroupChargesByNumber.

@RequestMapping(value = "group/num-{globalCustNum}/charges", method = RequestMethod.GET)
@ResponseBody
public CustomerChargesDetailsDto getGroupChargesByNumber(@PathVariable String globalCustNum) {
    GroupBO groupBO = customerDao.findGroupBySystemId(globalCustNum);
    CustomerChargesDetailsDto groupCharges = centerServiceFacade.retrieveChargesDetails(groupBO.getCustomerId());
    groupCharges.addActivities(centerServiceFacade.retrieveRecentActivities(groupBO.getCustomerId(), 3));
    return groupCharges;
}
Also used : CustomerChargesDetailsDto(org.mifos.dto.domain.CustomerChargesDetailsDto) GroupBO(org.mifos.customers.group.business.GroupBO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1964 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)459 ModelAndView (org.springframework.web.servlet.ModelAndView)413 ApiOperation (io.swagger.annotations.ApiOperation)305 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)234 ArrayList (java.util.ArrayList)197 HashMap (java.util.HashMap)155 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)124 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)124 IOException (java.io.IOException)97 ResponseEntity (org.springframework.http.ResponseEntity)92 Date (java.util.Date)83 Aggregation (org.springframework.data.mongodb.core.aggregation.Aggregation)80 DBObject (com.mongodb.DBObject)71 BasicDBObject (com.mongodb.BasicDBObject)67 InputStream (java.io.InputStream)66 Aggregation.newAggregation (org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation)64 HttpServletResponse (javax.servlet.http.HttpServletResponse)59 User (org.hisp.dhis.user.User)59 List (java.util.List)53