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());
}
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();
}
}
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());
}
Aggregations