use of org.codehaus.jackson.map.ObjectMapper in project head by mifos.
the class GroupRESTController method createGroupMapping.
private ObjectMapper createGroupMapping() {
ObjectMapper om = new ObjectMapper();
om.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);
om.getDeserializationConfig().addMixInAnnotations(CreateGroupCreationDetailDto.class, CreateGroupCreationDetailDtoMixIn.class);
om.getDeserializationConfig().addMixInAnnotations(CreationAddresDto.class, CreationAddresDtoMixIn.class);
om.getDeserializationConfig().addMixInAnnotations(CreationFeeDto.class, CreationFeeDtoMixIn.class);
om.getDeserializationConfig().addMixInAnnotations(CreationMeetingDto.class, CreationMeetingDtoMixIn.class);
om.getJsonFactory().configure(JsonParser.Feature.ALLOW_NUMERIC_LEADING_ZEROS, true);
return om;
}
use of org.codehaus.jackson.map.ObjectMapper in project head by mifos.
the class LoanAccountRESTController method createLoanAccount.
@RequestMapping(value = "/account/loan/create", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> createLoanAccount(@RequestBody String request) throws Throwable {
ObjectMapper om = createLoanAccountMapping();
Map<String, String> map = new HashMap<String, String>();
CreationLoanAccountDto creationDetails = null;
try {
creationDetails = om.readValue(request, CreationLoanAccountDto.class);
} catch (JsonMappingException e) {
e.getCause();
}
loanValidator(creationDetails);
List<QuestionGroupDetail> questionGroups = new ArrayList<QuestionGroupDetail>();
LoanCreationResultDto loanResult = null;
LoanBO loanInfo = null;
CreateLoanAccount loanAccount = createLoan(creationDetails);
if (creationDetails.getGlim()) {
List<GroupMemberAccountDto> memberAccounts = creationDetails.glimsAsGroupMemberAccountDto(creationDetails.getGlimAccounts());
CreateGlimLoanAccount createGroupLoanAccount = new CreateGlimLoanAccount(memberAccounts, creationDetails.getLoanAmount(), loanAccount);
loanResult = loanAccountServiceFacade.createGroupLoanWithIndividualMonitoring(createGroupLoanAccount, questionGroups, null);
List<LoanBO> individuals = loanDao.findIndividualLoans(loanResult.getAccountId());
for (int i = 0; i < individuals.size(); i++) {
map.put("individualCustomer[" + i + "]", individuals.get(i).getCustomer().getDisplayName());
map.put("individualAccount[" + i + "]", individuals.get(i).getGlobalAccountNum());
map.put("individualAmmount[" + i + "]", individuals.get(i).getLoanAmount().toString());
}
} else {
loanResult = loanAccountServiceFacade.createLoan(loanAccount, questionGroups, null);
}
loanInfo = loanDao.findByGlobalAccountNum(loanResult.getGlobalAccountNum());
map.put("status", "success");
map.put("accountNum", loanInfo.getGlobalAccountNum());
map.put("GLIM", creationDetails.getGlim().toString());
map.put("customer", loanInfo.getCustomer().getDisplayName());
map.put("loanAmmount", loanInfo.getLoanAmount().toString());
map.put("noOfInstallments", loanInfo.getNoOfInstallments().toString());
map.put("externalId", loanInfo.getExternalId());
return map;
}
use of org.codehaus.jackson.map.ObjectMapper in project head by mifos.
the class LoanAccountRESTController method createLoanAccountMapping.
private ObjectMapper createLoanAccountMapping() {
ObjectMapper om = new ObjectMapper();
om.getJsonFactory().configure(JsonParser.Feature.ALLOW_NUMERIC_LEADING_ZEROS, true);
om.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);
om.getDeserializationConfig().addMixInAnnotations(CreationLoanAccountDto.class, CreationLoanAccountDtoMixIn.class);
om.getDeserializationConfig().addMixInAnnotations(CreationFeeDto.class, CreationFeeDtoMixIn.class);
om.getDeserializationConfig().addMixInAnnotations(CreationAccountPenaltyDto.class, CreationAccountPenaltyDtoMixIn.class);
om.getDeserializationConfig().addMixInAnnotations(CreationGLIMAccountsDto.class, CreationGLIMAccountsDtoMixIn.class);
return om;
}
use of org.codehaus.jackson.map.ObjectMapper in project head by mifos.
the class RESTApprovalEntity method getApprovalMethod.
@Transient
public ApprovalMethod getApprovalMethod() throws Exception {
if (approvalMethod == null) {
ObjectMapper om = new ObjectMapper();
approvalMethod = om.readValue(getMethodContent(), ApprovalMethod.class);
}
return approvalMethod;
}
use of org.codehaus.jackson.map.ObjectMapper in project head by mifos.
the class CollectionsheetRESTAPITest method verifyCollectionSheet.
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
@Test
public void verifyCollectionSheet() throws Exception {
String type = Type.CENTER_COLLECTIONSHEET;
String by = By.ID;
String value = CENTER_ID;
String actualJSON = helper.getJSONFromUI(type, by, value);
String expectedJSON = helper.getJSONFromDataSet(type, by, value);
ObjectMapper mapper = helper.getObjectMapper();
Assert.assertEquals(mapper.readTree(expectedJSON), mapper.readTree(actualJSON));
String saveCollectionsheetJSON = getTestSaveCollectionsheetJSON();
actualJSON = helper.postJSONFromUI("collectionsheet/save.json", saveCollectionsheetJSON);
expectedJSON = getSumitCollectionSheetResponse();
Assert.assertEquals(mapper.readTree(expectedJSON), mapper.readTree(actualJSON));
actualJSON = helper.getJSONFromUI(type, by, value);
expectedJSON = getEmptyCollectionsheet();
Assert.assertEquals(mapper.readTree(expectedJSON), mapper.readTree(actualJSON));
dateTimeUpdaterRemoteTestingService.setDateTime(new DateTime(2011, 9, 13, 13, 0, 0, 0));
}
Aggregations