use of org.mifos.dto.domain.AddressDto in project head by mifos.
the class PersonnelServiceFacadeWebTier method createPersonnelInformation.
@Override
public UserDetailDto createPersonnelInformation(CreateOrUpdatePersonnelInformation personnel) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
try {
PersonnelBusinessService personnelBusinessService = new PersonnelBusinessService();
List<RoleBO> roles = new ArrayList<RoleBO>();
for (ListElement element : personnel.getRoles()) {
RoleBO role = personnelBusinessService.getRoleById(new Short(element.getId().shortValue()));
roles.add(role);
}
AddressDto addressDto = personnel.getAddress();
Address address = new Address(addressDto.getLine1(), addressDto.getLine2(), addressDto.getLine3(), addressDto.getCity(), addressDto.getState(), addressDto.getCountry(), addressDto.getZip(), addressDto.getPhoneNumber());
OfficeBO office = officeDao.findOfficeById(personnel.getOfficeId());
Name name = new Name(personnel.getFirstName(), personnel.getMiddleName(), personnel.getSecondLastName(), personnel.getLastName());
verifyFields(personnel.getUserName(), personnel.getGovernmentIdNumber(), personnel.getDob().toDate(), name.getDisplayName());
PersonnelBO newPersonnel = new PersonnelBO(PersonnelLevel.fromInt(personnel.getPersonnelLevelId().intValue()), office, personnel.getTitle(), personnel.getPreferredLocale(), personnel.getPassword(), personnel.getUserName(), personnel.getEmailId(), roles, personnel.getCustomFields(), name, personnel.getGovernmentIdNumber(), personnel.getDob().toDate(), personnel.getMaritalStatus(), personnel.getGender(), personnel.getDateOfJoiningMFI().toDate(), personnel.getDateOfJoiningBranch().toDate(), address, Integer.valueOf(user.getUserId()).shortValue(), personnel.getPasswordExpirationDate().toDate(), null);
transactionHelper.startTransaction();
this.personnelDao.save(newPersonnel);
transactionHelper.flushSession();
newPersonnel.generateGlobalPersonnelNum();
this.personnelDao.save(newPersonnel);
transactionHelper.commitTransaction();
return newPersonnel.toDto();
} catch (PersistenceException e) {
transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} catch (ValidationException e) {
transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e.getValues(), e);
} catch (ServiceException e) {
transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
transactionHelper.closeSession();
}
}
use of org.mifos.dto.domain.AddressDto in project head by mifos.
the class CustomerBO method updateCenterDetails.
public void updateCenterDetails(UserContext userContext, CenterUpdate centerUpdate) throws CustomerException {
this.setUserContext(userContext);
this.setUpdateDetails();
this.setExternalId(centerUpdate.getExternalId());
AddressDto dto = centerUpdate.getAddress();
if (dto != null) {
Address address = new Address(dto.getLine1(), dto.getLine2(), dto.getLine3(), dto.getCity(), dto.getState(), dto.getCountry(), dto.getZip(), dto.getPhoneNumber());
this.updateAddress(address);
}
try {
if (centerUpdate.getMfiJoiningDate() != null) {
DateTime mfiJoiningDate = CalendarUtils.getDateFromString(centerUpdate.getMfiJoiningDate(), userContext.getPreferredLocale());
this.setMfiJoiningDate(mfiJoiningDate.toDate());
}
} catch (InvalidDateException e) {
throw new CustomerException(CustomerConstants.MFI_JOINING_DATE_MANDATORY, e);
}
}
Aggregations