use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class PictureFormFile method retrievePicture.
@TransactionDemarcate(joinToken = true)
public ActionForward retrievePicture(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
ClientBO clientBO = getClientFromSession(request);
ClientPhotoService cps = ApplicationContextProvider.getBean(ClientPhotoService.class);
ClientPhoto cp = cps.read(clientBO.getCustomerId().longValue());
InputStream in = null;
if (cp != null) {
in = new ByteArrayInputStream(cps.getData(cp));
response.setContentType(cp.getImageInfo().getContentType());
} else {
in = ClientPhotoService.class.getResourceAsStream("/org/mifos/image/nopicture.png");
response.setContentType("image/png");
}
in.mark(0);
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
// 4K buffer buf, 0, buf.length
byte[] by = new byte[1024 * 4];
int index = in.read(by, 0, 1024 * 4);
while (index != -1) {
out.write(by, 0, index);
index = in.read(by, 0, 1024 * 4);
}
out.flush();
out.close();
in.reset();
String forward = ClientConstants.CUSTOMER_PICTURE_PAGE;
return mapping.findForward(forward);
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class PictureFormFile method updateMfiInfo.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updateMfiInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ClientCustActionForm actionForm = (ClientCustActionForm) form;
ClientBO clientInSession = getClientFromSession(request);
Integer clientId = clientInSession.getCustomerId();
Integer oldVersionNumber = clientInSession.getVersionNo();
boolean trained = false;
if (trainedValue(actionForm) != null && trainedValue(actionForm).equals(YesNoFlag.YES.getValue())) {
trained = true;
}
DateTime trainedDate = null;
try {
java.sql.Date inputDate = trainedDate(actionForm);
if (inputDate != null) {
trainedDate = new DateTime(trainedDate(actionForm));
}
} catch (InvalidDateException e) {
throw new CustomerException(ClientConstants.TRAINED_DATE_MANDATORY);
}
Short personnelId = Short.valueOf("-1");
if (groupFlagValue(actionForm).equals(YesNoFlag.NO.getValue())) {
if (actionForm.getLoanOfficerIdValue() != null) {
personnelId = actionForm.getLoanOfficerIdValue();
}
} else if (groupFlagValue(actionForm).equals(YesNoFlag.YES.getValue())) {
// TODO for an urgent fix this reads client to get personnelId.
// Client is read again in updateClientMfiInfo. Refactor to only read in
// updateClientMfiInfo.
ClientBO client = (ClientBO) this.customerDao.findCustomerById(clientId);
personnelId = client.getPersonnel().getPersonnelId();
}
ClientMfiInfoUpdate clientMfiInfoUpdate = new ClientMfiInfoUpdate(clientId, oldVersionNumber, personnelId, externalId(actionForm), trained, trainedDate);
this.clientServiceFacade.updateClientMfiInfo(clientMfiInfoUpdate);
return mapping.findForward(ActionForwards.updateMfiInfo_success.toString());
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class GroupTransferAction method removeGroupMemberShip.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward removeGroupMemberShip(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
GroupTransferActionForm actionForm = (GroupTransferActionForm) form;
CustomerBO customerBOInSession = (CustomerBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
ClientBO client = this.customerDao.findClientBySystemId(customerBOInSession.getGlobalCustNum());
checkVersionMismatch(customerBOInSession.getVersionNo(), client.getVersionNo());
Short loanOfficerId = null;
if (StringUtils.isNotBlank(actionForm.getAssignedLoanOfficerId())) {
loanOfficerId = Short.valueOf(actionForm.getAssignedLoanOfficerId());
}
this.clientServiceFacade.removeGroupMembership(customerBOInSession.getGlobalCustNum(), loanOfficerId, actionForm.getComment());
return mapping.findForward(ActionForwards.view_client_details_page.toString());
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class GroupTransferAction method loadGrpMemberShip.
@TransactionDemarcate(joinToken = true)
public ActionForward loadGrpMemberShip(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
GroupTransferActionForm actionForm = (GroupTransferActionForm) form;
actionForm.setComment(null);
ClientBO clientInSession = (ClientBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
ClientRemovalFromGroupDto clientRemovalFromGroupDetail = this.clientServiceFacade.retreiveClientDetailsForRemovalFromGroup(clientInSession.getGlobalCustNum());
actionForm.setAssignedLoanOfficerId(clientRemovalFromGroupDetail.getLoanOfficerId().toString());
actionForm.setIsActive(clientRemovalFromGroupDetail.isActive() ? Constants.YES : Constants.NO);
ClientBO client = this.customerDao.findClientBySystemId(clientInSession.getGlobalCustNum());
SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
SessionUtils.setCollectionAttribute(OfficeConstants.OFFICESBRANCHOFFICESLIST, clientRemovalFromGroupDetail.getActiveBranches(), request);
SessionUtils.setAttribute(CollectionSheetEntryConstants.ISCENTERHIERARCHYEXISTS, clientRemovalFromGroupDetail.isCenterHierarchyExists() ? Constants.YES : Constants.NO, request);
SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, clientRemovalFromGroupDetail.getLoanOfficers(), request);
return mapping.findForward(ActionForwards.loadGrpMemberShip_success.toString());
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class ClientBuilder method buildForUnitTests.
public ClientBO buildForUnitTests() {
ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1).shortValue(), Integer.valueOf(1).shortValue(), Integer.valueOf(1).shortValue());
this.clientDetailEntity = new ClientDetailEntity();
this.clientDetailEntity.updateClientDetails(clientPersonalDetailDto);
ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto();
clientNameDetailDto.setNames("first_name,middle_name,last_name,second_last_name".split(","));
this.clientNameDetailEntity = new ClientNameDetailEntity(null, null, clientNameDetailDto);
if (underBranch) {
ClientBO client = ClientBO.createNewOutOfGroupHierarchy(userContext, name, customerStatus, mfiJoiningDate, office, loanOfficer, meeting, formedBy, clientNameDetailEntity, dateOfBirth, governmentId, trained, trainedDate, groupFlag, clientFirstName, clientLastName, secondLastName, spouseFatherNameDetailEntity, clientDetailEntity, associatedOfferings, externalId, address, 10);
client.setVersionNo(versionNumber);
return client;
}
if (parentCustomer == null) {
CenterBO center = new CenterBuilder().withLoanOfficer(loanOfficer).with(meeting).with(office).build();
parentCustomer = new GroupBuilder().withParentCustomer(center).build();
}
ClientBO client = ClientBO.createNewInGroupHierarchy(userContext, name, customerStatus, mfiJoiningDate, parentCustomer, formedBy, clientNameDetailEntity, dateOfBirth, governmentId, trained, trainedDate, groupFlag, clientFirstName, clientLastName, secondLastName, spouseFatherNameDetailEntity, clientDetailEntity, associatedOfferings, externalId, address, new LocalDate(activationDate));
client.setVersionNo(versionNumber);
return client;
}
Aggregations