Search in sources :

Example 6 with CustomFieldDefinitionEntity

use of org.mifos.application.master.business.CustomFieldDefinitionEntity in project head by mifos.

the class PersonAction method load.

@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    PersonActionForm personActionForm = (PersonActionForm) form;
    Short officeId = getShortValue(personActionForm.getOfficeId());
    OfficeBO office = this.officeDao.findOfficeById(officeId);
    SessionUtils.setAttribute(PersonnelConstants.OFFICE, office, request);
    personActionForm.clear();
    //Shahid - keeping the previous session objects for the sake of existing tests, once fully converted to spring
    //then we can get rid of the session objects made redundant by the dto
    DefinePersonnelDto definePersonnelDto = this.personnelServiceFacade.retrieveInfoForNewUserDefinition(officeId);
    SessionUtils.setAttribute("definePersonnelDto", definePersonnelDto, request);
    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();
    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> customFieldDefs1 = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs1, request);
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    personActionForm.setCustomFields(customFields);
    if (office.getOfficeLevel() != OfficeLevel.BRANCHOFFICE) {
        for (MasterDataEntity level : personnelLevels) {
            if (level.getId().equals(PersonnelLevel.LOAN_OFFICER.getValue())) {
                personnelLevels.remove(level);
                break;
            }
        }
    }
    personActionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    personActionForm.setDateOfJoiningMFI(DateUtils.makeDateAsSentFromBrowser());
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) DefinePersonnelDto(org.mifos.dto.screen.DefinePersonnelDto) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) OfficeBO(org.mifos.customers.office.business.OfficeBO) ValueListElement(org.mifos.dto.domain.ValueListElement) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 7 with CustomFieldDefinitionEntity

use of org.mifos.application.master.business.CustomFieldDefinitionEntity in project head by mifos.

the class PersonAction method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    PersonActionForm personActionForm = (PersonActionForm) form;
    String globalId = request.getParameter("globalPersonnelNum");
    if (globalId == null) {
        globalId = personActionForm.getGlobalPersonnelNum();
    }
    PersonnelInformationDto personnelInformationDto = this.personnelServiceFacade.getPersonnelInformationDto(null, globalId);
    SessionUtils.removeThenSetAttribute("personnelInformationDto", personnelInformationDto, request);
    // John W - for other actions downstream (like edit) business_key set (until all actions refactored)
    PersonnelBO personnelBO = this.personnelDao.findPersonnelById(personnelInformationDto.getPersonnelId());
    SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, personnelBO, request);
    String url = String.format("PersonAction.do?globalPersonnelNum=%s", personnelBO.getGlobalPersonnelNum());
    SessionUtils.removeThenSetAttribute("currentPageUrl", url, request);
    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> customFieldDefs1 = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs1, request);
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    personActionForm.setCustomFields(customFields);
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : PersonnelInformationDto(org.mifos.dto.screen.PersonnelInformationDto) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MessageLookup(org.mifos.application.master.MessageLookup) ValueListElement(org.mifos.dto.domain.ValueListElement) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 8 with CustomFieldDefinitionEntity

use of org.mifos.application.master.business.CustomFieldDefinitionEntity in project head by mifos.

the class OffAction method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    OffActionForm actionForm = (OffActionForm) form;
    if (StringUtils.isBlank(actionForm.getOfficeId())) {
        throw new OfficeException(OfficeConstants.KEYGETFAILED);
    }
    OfficeDto officeDto = this.officeServiceFacade.retrieveOfficeById(Short.valueOf(actionForm.getOfficeId()));
    actionForm.clear();
    List<CustomFieldDefinitionEntity> customFieldDefs = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs, request);
    actionForm.populate(officeDto);
    SessionUtils.setAttribute(OfficeConstants.OFFICE_DTO, officeDto, request);
    setCurrentPageUrl(request, officeDto);
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : OfficeException(org.mifos.customers.office.exceptions.OfficeException) OfficeDto(org.mifos.dto.domain.OfficeDto) ArrayList(java.util.ArrayList) OffActionForm(org.mifos.customers.office.struts.actionforms.OffActionForm) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 9 with CustomFieldDefinitionEntity

use of org.mifos.application.master.business.CustomFieldDefinitionEntity in project head by mifos.

the class OffAction method edit.

@TransactionDemarcate(joinToken = true)
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    OffActionForm offActionForm = (OffActionForm) form;
    OfficeDto sessionOffice = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
    OfficeBO office = this.officeDao.findOfficeById(sessionOffice.getOfficeId());
    checkVersionMismatch(sessionOffice.getVersionNum(), office.getVersionNo());
    String officeLevel = request.getParameter("officeLevel");
    OfficeDetailsForEdit officeDetailsForEdit = this.officeServiceFacade.retrieveOfficeDetailsForEdit(officeLevel);
    if (StringUtils.isNotBlank(officeLevel)) {
        offActionForm.setOfficeLevel(officeLevel);
        List<OfficeDetailsDto> parents = this.officeServiceFacade.retrieveActiveParentOffices(Short.valueOf(officeLevel));
        OfficeDto office1 = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
        if (offActionForm.getInput() != null && offActionForm.getInput().equals("edit") && office1 != null) {
            for (int i = 0; i < parents.size(); i++) {
                OfficeDetailsDto view = parents.get(i);
                if (view.getOfficeId().equals(office1.getOfficeId())) {
                    parents.remove(view);
                }
            }
        }
        SessionUtils.setCollectionAttribute(OfficeConstants.PARENTS, parents, request);
    }
    offActionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    SessionUtils.setCollectionAttribute(OfficeConstants.OFFICELEVELLIST, officeDetailsForEdit.getConfiguredOfficeLevels(), request);
    SessionUtils.setCollectionAttribute(OfficeConstants.OFFICESTATUSLIST, officeDetailsForEdit.getStatusList(), request);
    List<CustomFieldDefinitionEntity> customFieldDefs = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs, request);
    return mapping.findForward(ActionForwards.edit_success.toString());
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) OffActionForm(org.mifos.customers.office.struts.actionforms.OffActionForm) OfficeDetailsForEdit(org.mifos.dto.screen.OfficeDetailsForEdit) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) OfficeBO(org.mifos.customers.office.business.OfficeBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 10 with CustomFieldDefinitionEntity

use of org.mifos.application.master.business.CustomFieldDefinitionEntity in project head by mifos.

the class CustomerCustomFieldEntity method toDto.

public static List<CustomFieldDto> toDto(Set<CustomerCustomFieldEntity> customFieldEntities, List<CustomFieldDefinitionEntity> customFieldDefs, UserContext userContext) {
    Locale locale = userContext.getPreferredLocale();
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    for (CustomFieldDefinitionEntity customFieldDef : customFieldDefs) {
        for (CustomerCustomFieldEntity customFieldEntity : customFieldEntities) {
            if (customFieldDef.getFieldId().equals(customFieldEntity.getFieldId())) {
                CustomFieldDto customFieldDto;
                if (customFieldDef.getFieldType().equals(CustomFieldType.DATE.getValue())) {
                    customFieldDto = new CustomFieldDto(customFieldEntity.getFieldId(), DateUtils.getUserLocaleDate(locale, customFieldEntity.getFieldValue()), customFieldDef.getFieldType());
                } else {
                    customFieldDto = new CustomFieldDto(customFieldEntity.getFieldId(), customFieldEntity.getFieldValue(), customFieldDef.getFieldType());
                }
                customFieldDto.setMandatory(customFieldDef.isMandatory());
                customFieldDto.setMandatoryString(customFieldDef.getMandatoryStringValue());
                customFieldDto.setLookUpEntityType(customFieldDef.getEntityName());
                customFields.add(customFieldDto);
            }
        }
    }
    return customFields;
}
Also used : Locale(java.util.Locale) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity)

Aggregations

CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)14 ArrayList (java.util.ArrayList)13 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)12 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)7 UserContext (org.mifos.security.util.UserContext)7 ValueListElement (org.mifos.dto.domain.ValueListElement)6 MessageLookup (org.mifos.application.master.MessageLookup)5 LoanBO (org.mifos.accounts.loan.business.LoanBO)4 LoanAccountActionForm (org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 ApplicationException (org.mifos.framework.exceptions.ApplicationException)4 HashSet (java.util.HashSet)3 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)3 SavingsActionForm (org.mifos.accounts.savings.struts.actionforms.SavingsActionForm)3 OfficeBO (org.mifos.customers.office.business.OfficeBO)3 PersonnelLevelEntity (org.mifos.customers.personnel.business.PersonnelLevelEntity)3 PersonActionForm (org.mifos.customers.personnel.struts.actionforms.PersonActionForm)3 LoanAccountDetailsDto (org.mifos.dto.domain.LoanAccountDetailsDto)3 LoanActivityDto (org.mifos.dto.domain.LoanActivityDto)3 LoanInformationDto (org.mifos.dto.screen.LoanInformationDto)3