use of org.mifos.dto.domain.AddressDto in project head by mifos.
the class PersonnelServiceFacadeWebTier method getPersonnelInformationDto.
@Override
public PersonnelInformationDto getPersonnelInformationDto(final Long userId, final String globalNumber) {
PersonnelBO personnel = null;
if (userId != null) {
personnel = personnelDao.findPersonnelById(userId.shortValue());
} else {
personnel = personnelDao.findByGlobalPersonnelNum(globalNumber);
}
if (personnel == null) {
throw new MifosRuntimeException("personnel not found for id" + userId);
}
String displayName = personnel.getDisplayName();
PersonnelStatusEntity personnelStatus = personnel.getStatus();
String statusName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(personnelStatus.getLookUpValue());
ListElement status = new ListElement(new Integer(personnelStatus.getId()), statusName);
boolean locked = personnel.isLocked();
PersonnelDetailsEntity personnelDetailsEntity = personnel.getPersonnelDetails();
Address address = personnelDetailsEntity.getAddress();
AddressDto addressDto = new AddressDto(address.getLine1(), address.getLine2(), address.getLine3(), address.getCity(), address.getState(), address.getCountry(), address.getZip(), address.getPhoneNumber());
Name name = personnelDetailsEntity.getName();
PersonnelDetailsDto personnelDetails = new PersonnelDetailsDto(personnelDetailsEntity.getGovernmentIdNumber(), new DateTime(personnelDetailsEntity.getDob()).toDateMidnight().toDateTime(), personnelDetailsEntity.getMaritalStatus(), personnelDetailsEntity.getGender(), new DateTime(personnelDetailsEntity.getDateOfJoiningMFI()).toDateMidnight().toDateTime(), new DateTime(personnelDetailsEntity.getDateOfJoiningBranch()).toDateMidnight().toDateTime(), new DateTime(personnelDetailsEntity.getDateOfLeavingBranch()).toDateMidnight().toDateTime(), addressDto, name.getFirstName(), name.getMiddleName(), name.getSecondLastName(), name.getLastName(), new DateTime(personnelDetailsEntity.getPersonnel().getPasswordExpirationDate()).toDateMidnight().toDateTime());
String emailId = personnel.getEmailId();
Short preferredLocale = personnel.getPreferredLocale();
String languageName = Localization.getInstance().getDisplayName(preferredLocale);
if (preferredLocale != null) {
languageName = Localization.getInstance().getDisplayName(preferredLocale);
}
PersonnelLevelEntity level = personnel.getLevel();
OfficeBO office = personnel.getOffice();
Integer title = personnel.getTitle();
Set<PersonnelRoleEntity> personnelRoleEntities = personnel.getPersonnelRoles();
Set<ListElement> personnelRoles = new LinkedHashSet<ListElement>();
for (PersonnelRoleEntity entity : personnelRoleEntities) {
ListElement element = new ListElement(entity.getRole().getId().intValue(), entity.getRole().getName());
personnelRoles.add(element);
}
Short personnelId = personnel.getPersonnelId();
String userName = personnel.getUserName();
Set<PersonnelCustomFieldEntity> personnelCustomFields = personnel.getCustomFields();
Set<CustomFieldDto> customFields = new LinkedHashSet<CustomFieldDto>();
for (PersonnelCustomFieldEntity fieldDef : personnelCustomFields) {
customFields.add(new CustomFieldDto(fieldDef.getFieldId(), fieldDef.getFieldValue()));
}
Set<PersonnelNotesEntity> personnelNotesEntity = personnel.getPersonnelNotes();
Set<PersonnelNoteDto> personnelNotes = new LinkedHashSet<PersonnelNoteDto>();
for (PersonnelNotesEntity entity : personnelNotesEntity) {
personnelNotes.add(new PersonnelNoteDto(new DateTime(entity.getCommentDate()), entity.getComment(), entity.getPersonnelName()));
}
return new PersonnelInformationDto(personnel.getPersonnelId().intValue(), personnel.getGlobalPersonnelNum(), displayName, status, locked, personnelDetails, emailId, languageName, preferredLocale.intValue(), level.getId(), office.getOfficeId().intValue(), office.getOfficeName(), title, personnelRoles, personnelId, userName, customFields, personnelNotes, personnel.getPasswordExpirationDate());
}
use of org.mifos.dto.domain.AddressDto in project head by mifos.
the class GroupServiceFacadeWebTier method createNewGroup.
@Override
public CustomerDetailsDto createNewGroup(GroupCreationDetail groupCreationDetail, MeetingDto meetingDto) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
OfficeBO userOffice = this.officeDao.findOfficeById(userContext.getBranchId());
userContext.setBranchGlobalNum(userOffice.getGlobalOfficeNum());
GroupBO group;
try {
List<AccountFeesEntity> feesForCustomerAccount = convertFeeViewsToAccountFeeEntities(groupCreationDetail.getFeesToApply());
PersonnelBO formedBy = this.personnelDao.findPersonnelById(groupCreationDetail.getLoanOfficerId());
Short officeId;
String groupName = groupCreationDetail.getDisplayName();
CustomerStatus customerStatus = CustomerStatus.fromInt(groupCreationDetail.getCustomerStatus());
String externalId = groupCreationDetail.getExternalId();
boolean trained = groupCreationDetail.isTrained();
DateTime trainedOn = groupCreationDetail.getTrainedOn();
DateTime mfiJoiningDate = groupCreationDetail.getMfiJoiningDate();
DateTime activationDate = groupCreationDetail.getActivationDate();
AddressDto dto = groupCreationDetail.getAddressDto();
Address address = null;
if (dto != null) {
address = new Address(dto.getLine1(), dto.getLine2(), dto.getLine3(), dto.getCity(), dto.getState(), dto.getCountry(), dto.getZip(), dto.getPhoneNumber());
}
MeetingBO groupMeeting = null;
if (meetingDto != null) {
groupMeeting = new MeetingFactory().create(meetingDto);
groupMeeting.setUserContext(userContext);
}
if (ClientRules.getCenterHierarchyExists()) {
CenterBO parentCustomer = this.customerDao.findCenterBySystemId(groupCreationDetail.getParentSystemId());
// loanOfficerId = parentCustomer.getPersonnel().getPersonnelId();
officeId = parentCustomer.getOffice().getOfficeId();
groupMeeting = parentCustomer.getCustomerMeetingValue();
group = GroupBO.createGroupWithCenterAsParent(userContext, groupName, formedBy, parentCustomer, address, externalId, trained, trainedOn, customerStatus, mfiJoiningDate, activationDate);
} else {
// create group without center as parent
Short loanOfficerId = groupCreationDetail.getLoanOfficerId() != null ? groupCreationDetail.getLoanOfficerId() : userContext.getId();
officeId = groupCreationDetail.getOfficeId();
OfficeBO office = this.officeDao.findOfficeById(groupCreationDetail.getOfficeId());
PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(loanOfficerId);
int numberOfCustomersInOfficeAlready = customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(officeId);
group = GroupBO.createGroupAsTopOfCustomerHierarchy(userContext, groupName, formedBy, groupMeeting, loanOfficer, office, address, externalId, trained, trainedOn, customerStatus, numberOfCustomersInOfficeAlready, mfiJoiningDate, activationDate);
}
try {
personnelDao.checkAccessPermission(userContext, group.getOfficeId(), group.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
this.customerService.createGroup(group, groupMeeting, feesForCustomerAccount);
return new CustomerDetailsDto(group.getCustomerId(), group.getGlobalCustNum());
} catch (CustomerException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.dto.domain.AddressDto in project head by mifos.
the class GroupServiceFacadeWebTier method retrieveGroupDetailsForUpdate.
@Override
public CenterDto retrieveGroupDetailsForUpdate(String globalCustNum) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
List<PersonnelDto> activeLoanOfficersForBranch = new ArrayList<PersonnelDto>();
GroupBO group = this.customerDao.findGroupBySystemId(globalCustNum);
Short officeId = group.getOffice().getOfficeId();
String searchId = group.getSearchId();
Short loanOfficerId = extractLoanOfficerId(group);
boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
if (!isCenterHierarchyExists) {
CenterCreation centerCreation = new CenterCreation(officeId, userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
activeLoanOfficersForBranch = personnelDao.findActiveLoanOfficersForOffice(centerCreation);
}
List<CustomerDto> customerList = customerDao.findClientsThatAreNotCancelledOrClosed(searchId, officeId);
List<CustomerPositionDto> customerPositionDtos = generateCustomerPositionViews(group, userContext.getLocaleId());
DateTime mfiJoiningDate = new DateTime();
String mfiJoiningDateAsString = "";
if (group.getMfiJoiningDate() != null) {
mfiJoiningDate = new DateTime(group.getMfiJoiningDate());
mfiJoiningDateAsString = DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), group.getMfiJoiningDate().toString());
}
AddressDto address = null;
if (group.getAddress() != null) {
address = Address.toDto(group.getAddress());
}
return new CenterDto(loanOfficerId, group.getCustomerId(), group.getGlobalCustNum(), mfiJoiningDate, mfiJoiningDateAsString, group.getExternalId(), address, customerPositionDtos, customerList, activeLoanOfficersForBranch, isCenterHierarchyExists);
}
use of org.mifos.dto.domain.AddressDto in project head by mifos.
the class PictureFormFile method updatePersonalInfo.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updatePersonalInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ClientCustActionForm actionForm = (ClientCustActionForm) form;
ClientBO clientInSession = getClientFromSession(request);
Integer oldClientVersionNumber = clientInSession.getVersionNo();
Integer customerId = clientInSession.getCustomerId();
String clientStatus = clientInSession.getCustomerStatus().getName();
List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
short loanOfficerId = clientInSession.getCreatedBy();
final String clientSystemId = clientInSession.getGlobalCustNum();
ClientPersonalInfoDto clientPersonalInfo = this.clientServiceFacade.retrieveClientPersonalInfoForUpdate(clientSystemId, clientStatus, loanOfficerId);
AddressDto address = null;
if (actionForm.getAddress() != null) {
address = Address.toDto(actionForm.getAddress());
}
if (clientPersonalInfo.getCustomerDetail() != null) {
if (clientPersonalInfo.getCustomerDetail().getAddress() != null) {
if (clientPersonalInfo.getCustomerDetail().getAddress().getPhoneNumber() != null && (!clientPersonalInfo.getCustomerDetail().getAddress().getPhoneNumber().equals(address.getPhoneNumber()))) {
UserContext userContext = getUserContext(request);
if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
}
} else if (clientPersonalInfo.getCustomerDetail().getAddress().getPhoneNumber() == null && address.getPhoneNumber() != null && !address.getPhoneNumber().equals("")) {
UserContext userContext = getUserContext(request);
if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
}
}
} else if (address.getPhoneNumber() != null && !address.getPhoneNumber().equals("")) {
UserContext userContext = getUserContext(request);
if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
}
}
} else if (address.getPhoneNumber() != null && !address.getPhoneNumber().equals("")) {
UserContext userContext = getUserContext(request);
if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
}
}
ClientNameDetailDto spouseFather = null;
if (!ClientRules.isFamilyDetailsRequired()) {
spouseFather = actionForm.getSpouseName();
}
InputStream picture = null;
if (actionForm.getPicture() != null && StringUtils.isNotBlank(actionForm.getPicture().getFileName())) {
picture = actionForm.getCustomerPicture();
}
ClientNameDetailDto clientNameDetails = actionForm.getClientName();
ClientPersonalDetailDto clientDetail = actionForm.getClientDetailView();
String governmentId = actionForm.getGovernmentId();
String clientDisplayName = actionForm.getClientName().getDisplayName();
String dateOfBirth = actionForm.getDateOfBirth();
ClientPersonalInfoUpdate personalInfo = new ClientPersonalInfoUpdate(customerId, oldClientVersionNumber, customFields, address, clientDetail, clientNameDetails, spouseFather, picture, governmentId, clientDisplayName, dateOfBirth);
this.clientServiceFacade.updateClientPersonalInfo(personalInfo, clientStatus, loanOfficerId);
return mapping.findForward(ActionForwards.updatePersonalInfo_success.toString());
}
use of org.mifos.dto.domain.AddressDto in project head by mifos.
the class CenterCustAction method create.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
CenterCustActionForm actionForm = (CenterCustActionForm) form;
MeetingBO meeting = (MeetingBO) SessionUtils.getAttribute(CustomerConstants.CUSTOMER_MEETING, request);
LocalDate mfiJoiningDate = new LocalDate(CalendarUtils.getDateFromString(actionForm.getMfiJoiningDate(), getUserContext(request).getPreferredLocale()));
Address address = actionForm.getAddress();
AddressDto addressDto = Address.toDto(address);
MeetingDto meetingDto = meeting.toDto();
List<CreateAccountFeeDto> accountFeesToBeApplied = new ArrayList<CreateAccountFeeDto>();
List<ApplicableAccountFeeDto> feesToBeApplied = actionForm.getFeesToApply();
for (ApplicableAccountFeeDto feeDto : feesToBeApplied) {
accountFeesToBeApplied.add(new CreateAccountFeeDto(feeDto.getFeeId(), feeDto.getAmount()));
}
try {
CenterCreationDetail centerCreationDetail = new CenterCreationDetail(mfiJoiningDate, actionForm.getDisplayName(), actionForm.getExternalId(), addressDto, actionForm.getLoanOfficerIdValue(), actionForm.getOfficeIdValue(), accountFeesToBeApplied);
CustomerDetailsDto centerDetails = this.centerServiceFacade.createNewCenter(centerCreationDetail, meetingDto);
createCenterQuestionnaire.saveResponses(request, actionForm, centerDetails.getId());
actionForm.setCustomerId(centerDetails.getId().toString());
actionForm.setGlobalCustNum(centerDetails.getGlobalCustNum());
} catch (BusinessRuleException e) {
throw new ApplicationException(e.getMessageKey(), e.getMessageValues());
}
return mapping.findForward(ActionForwards.create_success.toString());
}
Aggregations