Search in sources :

Example 1 with PersonnelStatusEntity

use of org.mifos.customers.personnel.business.PersonnelStatusEntity 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 PersonnelStatusEntity

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

the class AuditConfiguration method fetchMasterData.

private void fetchMasterData(String entityName, Short localeId, String classPath) throws SystemException {
    Class clazz = null;
    try {
        clazz = Thread.currentThread().getContextClassLoader().loadClass(classPath);
    } catch (ClassNotFoundException e) {
        throw new SystemException(e);
    }
    List<MasterDataEntity> masterDataList = legacyMasterDao.findMasterDataEntities(clazz);
    for (MasterDataEntity masterDataEntity : masterDataList) {
        if (masterDataEntity instanceof PersonnelStatusEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
            ((PersonnelStatusEntity) masterDataEntity).setName(name);
        }
        if (masterDataEntity instanceof PersonnelLevelEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
            ((PersonnelLevelEntity) masterDataEntity).setName(name);
        }
        if (masterDataEntity instanceof OfficeLevelEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
            ((OfficeLevelEntity) masterDataEntity).setName(name);
        }
        if (masterDataEntity instanceof OfficeStatusEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
            ((OfficeStatusEntity) masterDataEntity).setName(name);
        }
        valueMap.put(masterDataEntity.getId().toString(), masterDataEntity.getName());
    }
}
Also used : SystemException(org.mifos.framework.exceptions.SystemException) MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) MessageLookup(org.mifos.application.master.MessageLookup) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) OfficeStatusEntity(org.mifos.customers.office.business.OfficeStatusEntity) PersonnelStatusEntity(org.mifos.customers.personnel.business.PersonnelStatusEntity) OfficeLevelEntity(org.mifos.customers.office.business.OfficeLevelEntity)

Example 3 with PersonnelStatusEntity

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

the class FeeServiceFacadeWebTier method listToMap.

private Map<Short, String> listToMap(List<? extends MasterDataEntity> masterDataEntityList) {
    Map<Short, String> idNameMap = new HashMap<Short, String>();
    for (MasterDataEntity masterDataEntity : masterDataEntityList) {
        if (masterDataEntity instanceof PersonnelStatusEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
            ((PersonnelStatusEntity) masterDataEntity).setName(name);
        }
        if (masterDataEntity instanceof PersonnelLevelEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
            ((PersonnelLevelEntity) masterDataEntity).setName(name);
        }
        idNameMap.put(masterDataEntity.getId(), masterDataEntity.getName());
    }
    return idNameMap;
}
Also used : HashMap(java.util.HashMap) MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) MessageLookup(org.mifos.application.master.MessageLookup) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) PersonnelStatusEntity(org.mifos.customers.personnel.business.PersonnelStatusEntity)

Example 4 with PersonnelStatusEntity

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

the class CollectionSheetServiceFacadeWebTier method convertToPaymentTypesListItemDto.

private List<ListItem<Short>> convertToPaymentTypesListItemDto(final List<? extends MasterDataEntity> paymentTypesList) {
    List<ListItem<Short>> paymentTypesDtoList = new ArrayList<ListItem<Short>>();
    for (MasterDataEntity paymentType : paymentTypesList) {
        if (paymentType instanceof PersonnelStatusEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(paymentType.getLookUpValue());
            ((PersonnelStatusEntity) paymentType).setName(name);
        }
        if (paymentType instanceof PersonnelLevelEntity) {
            String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(paymentType.getLookUpValue());
            ((PersonnelLevelEntity) paymentType).setName(name);
        }
        paymentTypesDtoList.add(new ListItem<Short>(paymentType.getId(), paymentType.getName()));
    }
    return paymentTypesDtoList;
}
Also used : MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) MessageLookup(org.mifos.application.master.MessageLookup) ArrayList(java.util.ArrayList) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) PersonnelStatusEntity(org.mifos.customers.personnel.business.PersonnelStatusEntity)

Example 5 with PersonnelStatusEntity

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

the class InterceptHelper method hibernateMeta.

public Map hibernateMeta(Object object, String state) {
    logger.debug("object : " + object);
    ClassMetadata customMeta = StaticHibernateUtil.getSessionFactory().getClassMetadata(object.getClass());
    Object[] propertyValues = customMeta.getPropertyValues(object, EntityMode.POJO);
    String[] propertyNames = customMeta.getPropertyNames();
    Type[] propertyTypes = customMeta.getPropertyTypes();
    if (state.equalsIgnoreCase(AuditConstants.TRANSACTIONBEGIN)) {
        // locale=((BusinessObject)object).getUserContext().getMfiLocale();
        locale = ((AbstractBusinessObject) object).getUserContext().getCurrentLocale();
        // localeId=((BusinessObject)object).getUserContext().getMfiLocaleId();
        localeId = ((AbstractBusinessObject) object).getUserContext().getLocaleId();
        logger.debug("initial path class: " + AuditConfiguration.getEntityToClassPath(object.getClass().getName()));
        entityName = AuditConfiguration.getEntityToClassPath(object.getClass().getName());
        entityId = Integer.valueOf(customMeta.getIdentifier(object, EntityMode.POJO).toString());
    }
    setPrimaryKeyValues(customMeta, object, customMeta.getIdentifierPropertyName(), state);
    for (int i = 0; i < propertyNames.length; i++) {
        if (!propertyTypes[i].isEntityType() && !propertyTypes[i].isCollectionType() && !propertyTypes[i].isComponentType()) {
            if (state.equalsIgnoreCase(AuditConstants.TRANSACTIONBEGIN)) {
                String name = propertyNames[i];
                if (AuditConfiguration.checkForPropertyName(entityName, name, localeId)) {
                    String value = AuditConfiguration.getValueOfCorrespondingId(entityName, name, propertyValues[i], localeId);
                    initialValues.put(propertyNames[i], value);
                } else {
                    if (propertyValues[i] instanceof Calendar && propertyValues[i] != null) {
                        initialValues.put(propertyNames[i], ((Calendar) propertyValues[i]).getTime());
                    } else if (propertyValues[i] instanceof byte[] && propertyValues[i] != null) {
                        initialValues.put(propertyNames[i], new String((byte[]) propertyValues[i]));
                    } else if (propertyValues[i] instanceof Date && propertyValues[i] != null) {
                        try {
                            Date date = (Date) propertyValues[i];
                            initialValues.put(propertyNames[i], DateUtils.getUserLocaleDate(locale, new java.sql.Date(date.getTime()).toString()));
                        } catch (Exception e) {
                            initialValues.put(propertyNames[i], propertyValues[i].toString());
                        }
                    } else {
                        initialValues.put(propertyNames[i], propertyValues[i]);
                    }
                }
                String columnName = AuditConfiguration.getColumnNameForPropertyName(entityName, name);
                if (columnName != null && !columnName.equals("")) {
                    columnNames.put(propertyNames[i], columnName);
                } else {
                    columnNames.put(propertyNames[i], propertyNames[i]);
                }
            } else {
                String name = propertyNames[i];
                logger.debug("c hibernateMeta " + name + " : " + propertyValues[i]);
                if (AuditConfiguration.checkForPropertyName(entityName, name, localeId)) {
                    String value = AuditConfiguration.getValueOfCorrespondingId(entityName, name, propertyValues[i], localeId);
                    changedValues.put(propertyNames[i], value);
                } else {
                    if (propertyValues[i] instanceof Calendar && propertyValues[i] != null) {
                        changedValues.put(propertyNames[i], ((Calendar) propertyValues[i]).getTime());
                    } else if (propertyValues[i] instanceof byte[] && propertyValues[i] != null) {
                        changedValues.put(propertyNames[i], new String((byte[]) propertyValues[i]));
                    } else if (propertyValues[i] instanceof Date && propertyValues[i] != null) {
                        try {
                            Date date = (Date) propertyValues[i];
                            changedValues.put(propertyNames[i], DateUtils.getUserLocaleDate(locale, new java.sql.Date(date.getTime()).toString()));
                        } catch (Exception e) {
                            changedValues.put(propertyNames[i], propertyValues[i].toString());
                        }
                    } else {
                        changedValues.put(propertyNames[i], propertyValues[i]);
                    }
                }
                String columnName = AuditConfiguration.getColumnNameForPropertyName(entityName, name);
                if (columnName != null && !columnName.equals("")) {
                    columnNames.put(propertyNames[i], columnName);
                } else {
                    columnNames.put(propertyNames[i], propertyNames[i]);
                }
            }
        }
        if (propertyTypes[i].isEntityType() && !propertyTypes[i].isComponentType() && propertyValues[i] instanceof MasterDataEntity && AuditConfiguration.isObjectToBeLogged(entityName, propertyNames[i], null)) {
            String personnelStatusName = AuditConstants.PERSONNELSTATUSPATH;
            String personnelLevelName = AuditConstants.PERSONNELLEVELPATH;
            if (propertyValues[i].getClass().getName().startsWith(personnelStatusName)) {
                Short id = ((PersonnelStatusEntity) propertyValues[i]).getId();
                populateValueForObjectsOfTypeMasterDataEntity(id, state, propertyNames[i]);
            } else if (propertyValues[i].getClass().getName().startsWith(personnelLevelName)) {
                Short id = ((PersonnelLevelEntity) propertyValues[i]).getId();
                populateValueForObjectsOfTypeMasterDataEntity(id, state, propertyNames[i]);
            } else {
                populateValueForObjectsOfTypeMasterDataEntity(propertyValues[i], state, propertyNames[i]);
            }
        }
        // Reading Collection Types
        if (propertyTypes[i].isCollectionType() && AuditConfiguration.isObjectToBeLogged(entityName, propertyNames[i], null) && AuditConfiguration.isObjectPropertiesToBeMerged(entityName, propertyNames[i], null)) {
            populateAndMergeCollectionTypes(state, propertyValues[i], propertyNames[i], null);
        }
        if (propertyTypes[i].isCollectionType() && AuditConfiguration.isObjectToBeLogged(entityName, propertyNames[i], null) && !AuditConfiguration.isObjectPropertiesToBeMerged(entityName, propertyNames[i], null)) {
            Iterator iterator = ((Set) propertyValues[i]).iterator();
            while (iterator.hasNext()) {
                Object obj = iterator.next();
                if (obj != null) {
                    if (obj instanceof LoanOfferingFeesEntity) {
                        LoanOfferingFeesEntity loanOfferingFeesEntity = (LoanOfferingFeesEntity) obj;
                        if (propertyNames[i].equalsIgnoreCase("loanOfferingFees") && loanOfferingFeesEntity.getPrdOfferingFeeId() != null) {
                            readLoanOfferingFeesCollection(loanOfferingFeesEntity, state);
                        } else {
                            readFurtherMetaForCollectionType(obj, propertyNames[i], state);
                        }
                    } else {
                        readFurtherMetaForCollectionType(obj, propertyNames[i], state);
                    }
                }
            }
        }
        if (propertyTypes[i].isEntityType() && !propertyTypes[i].isComponentType() && !(propertyValues[i] instanceof MasterDataEntity) && AuditConfiguration.isObjectToBeLogged(entityName, propertyNames[i], null)) {
            Object obj = propertyValues[i];
            if (obj != null) {
                readFurtherMeta(obj, propertyNames[i], state);
            }
        }
        // Reading further Money type
        if (!propertyTypes[i].isEntityType() && propertyTypes[i].isComponentType() && !(propertyValues[i] instanceof MasterDataEntity) && (propertyValues[i] instanceof Money)) {
            Object obj1 = propertyValues[i];
            if (obj1 != null) {
                readFurtherMoneyType(obj1, propertyNames[i], state);
            }
        }
        // Reading further component type
        if (!propertyTypes[i].isEntityType() && propertyTypes[i].isComponentType() && !(propertyValues[i] instanceof MasterDataEntity) && AuditConfiguration.isObjectToBeLogged(entityName, propertyNames[i], null)) {
            Object obj1 = propertyValues[i];
            if (obj1 != null) {
                readFurtherComponenetMeta(obj1, propertyNames[i], state, propertyTypes[i]);
            }
        }
    }
    if (state.equalsIgnoreCase(AuditConstants.TRANSACTIONBEGIN)) {
        return initialValues;
    } else {
        return changedValues;
    }
}
Also used : ClassMetadata(org.hibernate.metadata.ClassMetadata) Set(java.util.Set) LoanOfferingFeesEntity(org.mifos.accounts.productdefinition.business.LoanOfferingFeesEntity) AbstractBusinessObject(org.mifos.framework.business.AbstractBusinessObject) MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) Calendar(java.util.Calendar) Date(java.util.Date) PersonnelStatusEntity(org.mifos.customers.personnel.business.PersonnelStatusEntity) Money(org.mifos.framework.util.helpers.Money) ComponentType(org.hibernate.type.ComponentType) Type(org.hibernate.type.Type) Iterator(java.util.Iterator) AbstractBusinessObject(org.mifos.framework.business.AbstractBusinessObject)

Aggregations

PersonnelStatusEntity (org.mifos.customers.personnel.business.PersonnelStatusEntity)8 PersonnelLevelEntity (org.mifos.customers.personnel.business.PersonnelLevelEntity)7 MessageLookup (org.mifos.application.master.MessageLookup)5 MasterDataEntity (org.mifos.application.master.business.MasterDataEntity)4 ArrayList (java.util.ArrayList)3 OfficeBO (org.mifos.customers.office.business.OfficeBO)3 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)3 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 PersonnelDetailsEntity (org.mifos.customers.personnel.business.PersonnelDetailsEntity)2 PersonnelRoleEntity (org.mifos.customers.personnel.business.PersonnelRoleEntity)2 AddressDto (org.mifos.dto.domain.AddressDto)2 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)2 ValueListElement (org.mifos.dto.domain.ValueListElement)2 Address (org.mifos.framework.business.util.Address)2 RoleBO (org.mifos.security.rolesandpermission.business.RoleBO)2 UserContext (org.mifos.security.util.UserContext)2 Calendar (java.util.Calendar)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1