Search in sources :

Example 41 with Address

use of org.mifos.framework.business.util.Address 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();
    }
}
Also used : PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) ValidationException(org.mifos.framework.exceptions.ValidationException) Address(org.mifos.framework.business.util.Address) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) AddressDto(org.mifos.dto.domain.AddressDto) Name(org.mifos.framework.business.util.Name) BusinessRuleException(org.mifos.service.BusinessRuleException) ServiceException(org.mifos.framework.exceptions.ServiceException) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ValueListElement(org.mifos.dto.domain.ValueListElement) ListElement(org.mifos.dto.screen.ListElement) PersistenceException(org.mifos.framework.exceptions.PersistenceException) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 42 with Address

use of org.mifos.framework.business.util.Address 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);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) Address(org.mifos.framework.business.util.Address) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) AddressDto(org.mifos.dto.domain.AddressDto) DateTime(org.joda.time.DateTime)

Aggregations

Address (org.mifos.framework.business.util.Address)42 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)22 ArrayList (java.util.ArrayList)17 OfficeBO (org.mifos.customers.office.business.OfficeBO)17 AddressDto (org.mifos.dto.domain.AddressDto)16 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)14 DateTime (org.joda.time.DateTime)11 Date (java.util.Date)10 MifosRuntimeException (org.mifos.core.MifosRuntimeException)10 UserContext (org.mifos.security.util.UserContext)9 MeetingBO (org.mifos.application.meeting.business.MeetingBO)8 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)8 MifosUser (org.mifos.security.MifosUser)8 BusinessRuleException (org.mifos.service.BusinessRuleException)8 CustomerException (org.mifos.customers.exceptions.CustomerException)7 Name (org.mifos.framework.business.util.Name)7 HashSet (java.util.HashSet)5 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)5 ClientBO (org.mifos.customers.client.business.ClientBO)5 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)5