use of org.mifos.customers.personnel.business.PersonnelRoleEntity in project head by mifos.
the class LegacyPersonnelDao method getActiveBranchManagersUnderOffice.
@SuppressWarnings("unchecked")
public List<PersonnelBO> getActiveBranchManagersUnderOffice(Short officeId, final RoleBO role) throws PersistenceException {
Map<String, Object> params = new HashMap<String, Object>();
params.put(CustomerSearchConstants.OFFICEID, officeId);
params.put(CustomerSearchConstants.PERSONNELSTATUSID, PersonnelStatus.ACTIVE.getValue());
List activeBranchManagers = executeNamedQuery(NamedQueryConstants.GET_ACTIVE_BRANCH_MANAGER_UNDER_OFFICE, params);
return (List<PersonnelBO>) CollectionUtils.select(activeBranchManagers, new Predicate() {
@Override
public boolean evaluate(Object object) {
Set<PersonnelRoleEntity> applicableRoles = ((PersonnelBO) object).getPersonnelRoles();
return CollectionUtils.exists(applicableRoles, new Predicate() {
@Override
public boolean evaluate(Object object) {
return ((PersonnelRoleEntity) object).getRole().equals(role);
}
});
}
});
}
use of org.mifos.customers.personnel.business.PersonnelRoleEntity in project head by mifos.
the class PersonnelDaoHibernate method findAuthenticatedUserByUsername.
@SuppressWarnings("unchecked")
@Override
public MifosUser findAuthenticatedUserByUsername(String username) {
PersonnelBO user = findPersonnelByUsername(username);
if (user == null) {
return null;
}
Set<Short> activityIds = new HashSet<Short>();
Set<Short> roleIds = new HashSet<Short>();
for (PersonnelRoleEntity personnelRole : user.getPersonnelRoles()) {
RoleBO role = personnelRole.getRole();
roleIds.add(role.getId());
activityIds.addAll(role.getActivityIds());
}
byte[] password = user.getEncryptedPassword();
boolean enabled = user.isActive();
boolean accountNonExpired = !user.isLocked();
boolean credentialsNonExpired = true;
boolean accountNonLocked = !user.isLocked();
List<GrantedAuthority> authorities = getGrantedActivityAuthorities(activityIds);
return new MifosUser(user.getPersonnelId(), user.getOffice().getOfficeId(), user.getLevelEnum().getValue(), new ArrayList<Short>(roleIds), username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities, user.getPreferredLocale());
}
use of org.mifos.customers.personnel.business.PersonnelRoleEntity 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.PersonnelRoleEntity in project head by mifos.
the class PersonAction method manage.
@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
PersonActionForm actionform = (PersonActionForm) form;
actionform.clear();
PersonnelBO personnelInSession = (PersonnelBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
PersonnelBO personnel = this.personnelDao.findPersonnelById(personnelInSession.getPersonnelId());
List<ValueListElement> titles = this.customerDao.retrieveTitles();
List<ValueListElement> genders = this.customerDao.retrieveGenders();
List<ValueListElement> maritalStatuses = this.customerDao.retrieveMaritalStatuses();
List<ValueListElement> languages = Localization.getInstance().getLocaleForUI();
List<RoleBO> roles = legacyRolesPermissionsDao.getRoles();
List<PersonnelLevelEntity> personnelLevels = this.customerDao.retrievePersonnelLevels();
for (PersonnelLevelEntity personnelLevelEntity : personnelLevels) {
String messageTextLookup = ApplicationContextProvider.getBean(MessageLookup.class).lookup(personnelLevelEntity.getLookUpValue().getPropertiesKey());
personnelLevelEntity.setName(messageTextLookup);
}
SessionUtils.setCollectionAttribute(PersonnelConstants.TITLE_LIST, titles, request);
SessionUtils.setCollectionAttribute(PersonnelConstants.PERSONNEL_LEVEL_LIST, personnelLevels, request);
SessionUtils.setCollectionAttribute(PersonnelConstants.GENDER_LIST, genders, request);
SessionUtils.setCollectionAttribute(PersonnelConstants.MARITAL_STATUS_LIST, maritalStatuses, request);
SessionUtils.setCollectionAttribute(PersonnelConstants.LANGUAGE_LIST, languages, request);
SessionUtils.setCollectionAttribute(PersonnelConstants.ROLES_LIST, roles, request);
SessionUtils.setCollectionAttribute(PersonnelConstants.ROLEMASTERLIST, roles, request);
List<CustomFieldDefinitionEntity> customFieldDefs = new ArrayList<CustomFieldDefinitionEntity>();
SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs, request);
UserContext userContext = getUserContext(request);
List<PersonnelStatusEntity> statuses = legacyMasterDao.findMasterDataEntitiesWithLocale(PersonnelStatusEntity.class);
for (PersonnelStatusEntity personnelStatusEntity : statuses) {
String messageTextLookup = ApplicationContextProvider.getBean(MessageLookup.class).lookup(personnelStatusEntity.getLookUpValue().getPropertiesKey());
personnelStatusEntity.setName(messageTextLookup);
}
SessionUtils.setCollectionAttribute(PersonnelConstants.STATUS_LIST, statuses, request);
OfficeBO loggedInOffice = this.officeDao.findOfficeById(userContext.getBranchId());
List<OfficeDetailsDto> officeHierarchy = new OfficePersistence().getChildOffices(loggedInOffice.getSearchId());
SessionUtils.setCollectionAttribute(PersonnelConstants.OFFICE_LIST, officeHierarchy, request);
actionform.setPersonnelId(personnel.getPersonnelId().toString());
if (personnel.getOffice() != null) {
actionform.setOfficeId(personnel.getOffice().getOfficeId().toString());
}
if (personnel.getTitle() != null) {
actionform.setTitle(personnel.getTitle().toString());
}
if (personnel.getLevel() != null) {
actionform.setLevel(personnel.getLevelEnum().getValue().toString());
}
if (personnel.getStatus() != null) {
actionform.setStatus(personnel.getStatus().getId().toString());
}
actionform.setLoginName(personnel.getUserName());
actionform.setGlobalPersonnelNum(personnel.getGlobalPersonnelNum());
actionform.setCustomFields(new ArrayList<CustomFieldDto>());
if (personnel.getPersonnelDetails() != null) {
PersonnelDetailsEntity personnelDetails = personnel.getPersonnelDetails();
actionform.setFirstName(personnelDetails.getName().getFirstName());
actionform.setMiddleName(personnelDetails.getName().getMiddleName());
actionform.setSecondLastName(personnelDetails.getName().getSecondLastName());
actionform.setLastName(personnelDetails.getName().getLastName());
if (personnelDetails.getGender() != null) {
actionform.setGender(personnelDetails.getGender().toString());
}
if (personnelDetails.getMaritalStatus() != null) {
actionform.setMaritalStatus(personnelDetails.getMaritalStatus().toString());
}
actionform.setAddress(personnelDetails.getAddress());
if (personnelDetails.getDateOfJoiningMFI() != null) {
actionform.setDateOfJoiningMFI(DateUtils.makeDateAsSentFromBrowser(personnelDetails.getDateOfJoiningMFI()));
}
if (personnelDetails.getDob() != null) {
actionform.setDob(DateUtils.makeDateAsSentFromBrowser(personnelDetails.getDob()));
}
}
actionform.setEmailId(personnel.getEmailId());
if (personnel.getPreferredLocale() != null) {
actionform.setPreferredLocale(personnel.getPreferredLocale());
}
if (personnel.getPasswordExpirationDate() != null) {
actionform.setPasswordExpirationDate(DateUtils.makeDateAsSentFromBrowser(personnel.getPasswordExpirationDate()));
}
List<RoleBO> selectList = new ArrayList<RoleBO>();
for (PersonnelRoleEntity personnelRole : personnel.getPersonnelRoles()) {
selectList.add(personnelRole.getRole());
}
SessionUtils.setCollectionAttribute(PersonnelConstants.PERSONNEL_ROLES_LIST, selectList, request);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, personnel, request);
return mapping.findForward(ActionForwards.manage_success.toString());
}
Aggregations