Search in sources :

Example 1 with PersonnelNotesEntity

use of org.mifos.customers.personnel.business.PersonnelNotesEntity 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());
}
Also used : PersonnelDetailsEntity(org.mifos.customers.personnel.business.PersonnelDetailsEntity) LinkedHashSet(java.util.LinkedHashSet) PersonnelInformationDto(org.mifos.dto.screen.PersonnelInformationDto) Address(org.mifos.framework.business.util.Address) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) DateTime(org.joda.time.DateTime) PersonnelStatusEntity(org.mifos.customers.personnel.business.PersonnelStatusEntity) Name(org.mifos.framework.business.util.Name) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelRoleEntity(org.mifos.customers.personnel.business.PersonnelRoleEntity) MessageLookup(org.mifos.application.master.MessageLookup) PersonnelCustomFieldEntity(org.mifos.customers.personnel.business.PersonnelCustomFieldEntity) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) AddressDto(org.mifos.dto.domain.AddressDto) PersonnelNoteDto(org.mifos.dto.screen.PersonnelNoteDto) PersonnelNotesEntity(org.mifos.customers.personnel.business.PersonnelNotesEntity) ValueListElement(org.mifos.dto.domain.ValueListElement) ListElement(org.mifos.dto.screen.ListElement) PersonnelDetailsDto(org.mifos.dto.screen.PersonnelDetailsDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with PersonnelNotesEntity

use of org.mifos.customers.personnel.business.PersonnelNotesEntity in project head by mifos.

the class CenterServiceFacadeWebTier method addNoteToPersonnel.

@Override
public void addNoteToPersonnel(Short personnelId, String comment) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    try {
        PersonnelBO personnel = this.personnelDao.findPersonnelById(personnelId);
        PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
        if (personnel != null) {
            checkPermissionForAddingNotesToPersonnel(userContext, personnel.getOffice().getOfficeId(), personnel.getPersonnelId());
        }
        this.transactionHelper.startTransaction();
        PersonnelNotesEntity personnelNote = new PersonnelNotesEntity(comment, loggedInUser, personnel);
        personnel.addNotes(userContext.getId(), personnelNote);
        this.personnelDao.save(personnel);
        this.transactionHelper.commitTransaction();
    } catch (Exception e) {
        this.transactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        this.transactionHelper.closeSession();
    }
}
Also used : PersonnelNotesEntity(org.mifos.customers.personnel.business.PersonnelNotesEntity) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) AccountException(org.mifos.accounts.exceptions.AccountException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) BusinessRuleException(org.mifos.service.BusinessRuleException) CustomerException(org.mifos.customers.exceptions.CustomerException) ServiceException(org.mifos.framework.exceptions.ServiceException) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 3 with PersonnelNotesEntity

use of org.mifos.customers.personnel.business.PersonnelNotesEntity in project head by mifos.

the class LegacyPersonnelDaoIntegrationTest method testGetAllPersonnelNotes.

@Test
public void testGetAllPersonnelNotes() throws Exception {
    office = TestObjectFactory.getOffice(TestObjectFactory.HEAD_OFFICE);
    branchOffice = TestObjectFactory.getOffice(TestObjectFactory.SAMPLE_BRANCH_OFFICE);
    createdBranchOffice = TestObjectFactory.createOffice(OfficeLevel.BRANCHOFFICE, office, "Office_BRanch1", "OFB");
    StaticHibernateUtil.flushSession();
    createdBranchOffice = (OfficeBO) StaticHibernateUtil.getSessionTL().get(OfficeBO.class, createdBranchOffice.getOfficeId());
    createPersonnel(branchOffice, PersonnelLevel.LOAN_OFFICER);
    Assert.assertEquals(branchOffice.getOfficeId(), personnel.getOffice().getOfficeId());
    createInitialObjects(branchOffice.getOfficeId(), personnel.getPersonnelId());
    PersonnelNotesEntity personnelNotes = new PersonnelNotesEntity("Personnel notes created", legacyPersonnelDao.getPersonnel(PersonnelConstants.SYSTEM_USER), personnel);
    personnel.addNotes(PersonnelConstants.SYSTEM_USER, personnelNotes);
    StaticHibernateUtil.flushSession();
    StaticHibernateUtil.flushSession();
    client = (ClientBO) StaticHibernateUtil.getSessionTL().get(ClientBO.class, client.getCustomerId());
    group = (GroupBO) StaticHibernateUtil.getSessionTL().get(GroupBO.class, group.getCustomerId());
    center = (CenterBO) StaticHibernateUtil.getSessionTL().get(CenterBO.class, center.getCustomerId());
    personnel = (PersonnelBO) StaticHibernateUtil.getSessionTL().get(PersonnelBO.class, personnel.getPersonnelId());
    createdBranchOffice = (OfficeBO) StaticHibernateUtil.getSessionTL().get(OfficeBO.class, createdBranchOffice.getOfficeId());
    Assert.assertEquals(1, legacyPersonnelDao.getAllPersonnelNotes(personnel.getPersonnelId()).getSize());
}
Also used : PersonnelNotesEntity(org.mifos.customers.personnel.business.PersonnelNotesEntity) Test(org.junit.Test)

Aggregations

PersonnelNotesEntity (org.mifos.customers.personnel.business.PersonnelNotesEntity)3 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 LinkedHashSet (java.util.LinkedHashSet)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 MessageLookup (org.mifos.application.master.MessageLookup)1 CustomerException (org.mifos.customers.exceptions.CustomerException)1 OfficeBO (org.mifos.customers.office.business.OfficeBO)1 PersonnelCustomFieldEntity (org.mifos.customers.personnel.business.PersonnelCustomFieldEntity)1 PersonnelDetailsEntity (org.mifos.customers.personnel.business.PersonnelDetailsEntity)1 PersonnelLevelEntity (org.mifos.customers.personnel.business.PersonnelLevelEntity)1 PersonnelRoleEntity (org.mifos.customers.personnel.business.PersonnelRoleEntity)1 PersonnelStatusEntity (org.mifos.customers.personnel.business.PersonnelStatusEntity)1 AddressDto (org.mifos.dto.domain.AddressDto)1 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)1 ValueListElement (org.mifos.dto.domain.ValueListElement)1 ListElement (org.mifos.dto.screen.ListElement)1 PersonnelDetailsDto (org.mifos.dto.screen.PersonnelDetailsDto)1