Search in sources :

Example 16 with ValueListElement

use of org.mifos.dto.domain.ValueListElement in project head by mifos.

the class LegacyMasterDaoIntegrationTest method foundStringInCustomValueList.

private boolean foundStringInCustomValueList(final String CustomValueListName, final String searchString) throws Exception {
    List<ValueListElement> salutations = legacyMasterDao.findValueListElements(CustomValueListName);
    boolean foundString = false;
    for (ValueListElement entity : salutations) {
        if (entity.getName().compareTo(searchString) == 0) {
            foundString = true;
        }
    }
    return foundString;
}
Also used : ValueListElement(org.mifos.dto.domain.ValueListElement)

Example 17 with ValueListElement

use of org.mifos.dto.domain.ValueListElement in project head by mifos.

the class LegacyMasterDaoIntegrationTest method testUpdateValueListElement.

@Test
public void testUpdateValueListElement() throws Exception {
    // get a CustomValueListElementDto (as a BusinessActivityEntity)
    List<ValueListElement> salutations = legacyMasterDao.findValueListElements(MasterConstants.SALUTATION);
    ValueListElement first = salutations.get(0);
    Integer id = first.getId();
    String originalName = first.getName();
    // update it
    final String UPDATED_NAME = "Mister";
    first.setName(UPDATED_NAME);
    // save it
    legacyMasterDao.updateValueListElementForLocale(id, UPDATED_NAME);
    StaticHibernateUtil.flushSession();
    // get the element back
    // and verify that it has the new value
    salutations.clear();
    salutations = legacyMasterDao.findValueListElements(MasterConstants.SALUTATION);
    for (ValueListElement entity : salutations) {
        if (entity.getId() == id) {
            Assert.assertEquals(entity.getName(), UPDATED_NAME);
        }
    }
    // restore it
    legacyMasterDao.updateValueListElementForLocale(id, originalName);
    StaticHibernateUtil.flushSession();
}
Also used : ValueListElement(org.mifos.dto.domain.ValueListElement) Test(org.junit.Test)

Example 18 with ValueListElement

use of org.mifos.dto.domain.ValueListElement in project head by mifos.

the class LegacyMasterDaoIntegrationTest method findValueListElementId.

private Integer findValueListElementId(final LegacyMasterDao legacyMasterDao, final String CustomValueListName, final String searchString) throws Exception {
    List<ValueListElement> salutations = legacyMasterDao.findValueListElements(CustomValueListName);
    Integer elementId = null;
    for (ValueListElement entity : salutations) {
        if (entity.getName().compareTo(searchString) == 0) {
            elementId = entity.getId();
        }
    }
    return elementId;
}
Also used : ValueListElement(org.mifos.dto.domain.ValueListElement)

Example 19 with ValueListElement

use of org.mifos.dto.domain.ValueListElement in project head by mifos.

the class HomePageController method showPopulatedForm.

@RequestMapping(method = RequestMethod.GET)
@ModelAttribute("customerSearch")
public ModelAndView showPopulatedForm(HttpServletRequest request, HttpServletResponse response, @ModelAttribute("customerSearch") CustomerSearchFormBean customerSearchFormBean) throws MifosException, PersistenceException {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "home", request);
    modelAndView.addObject("include_page", new IncludePage(request, response));
    Short userId = (short) user.getUserId();
    UserDetailDto userDetails = this.centerServiceFacade.retrieveUsersDetails(userId);
    modelAndView.addObject("customerSearch", customerSearchFormBean);
    boolean isCenterHierarchyExists = configurationServiceFacade.getBooleanConfig("ClientRules.CenterHierarchyExists");
    modelAndView.addObject("isCenterHierarchyExists", isCenterHierarchyExists);
    if (sitePreferenceHelper.isMobile(request)) {
        List<ValueListElement> availibleClientGenders = clientServiceFacade.getClientGenders();
        modelAndView.addObject("availibleClientGenders", availibleClientGenders);
        HashMap<String, ArrayList<CustomerStatusDetailDto>> customerStates = new HashMap<String, ArrayList<CustomerStatusDetailDto>>();
        customerStates.putAll(customerSearchServiceFacade.getAvailibleCustomerStates());
        modelAndView.addObject("availibleCustomerStates", customerStates);
    }
    if (userDetails.isLoanOfficer()) {
        loadLoanOfficerCustomersHierarchyForSelectedDay(userId, modelAndView, customerSearchFormBean);
        modelAndView.addObject("isLoanOfficer", true);
    } else {
        modelAndView.addObject("isLoanOfficer", false);
    }
    return modelAndView;
}
Also used : CustomerStatusDetailDto(org.mifos.dto.screen.CustomerStatusDetailDto) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) UserDetailDto(org.mifos.dto.domain.UserDetailDto) IncludePage(freemarker.ext.servlet.IncludePage) ValueListElement(org.mifos.dto.domain.ValueListElement) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with ValueListElement

use of org.mifos.dto.domain.ValueListElement 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());
}
Also used : PersonnelDetailsEntity(org.mifos.customers.personnel.business.PersonnelDetailsEntity) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) PersonnelLevelEntity(org.mifos.customers.personnel.business.PersonnelLevelEntity) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) PersonnelStatusEntity(org.mifos.customers.personnel.business.PersonnelStatusEntity) PersonActionForm(org.mifos.customers.personnel.struts.actionforms.PersonActionForm) 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) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) ValueListElement(org.mifos.dto.domain.ValueListElement) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

ValueListElement (org.mifos.dto.domain.ValueListElement)32 ArrayList (java.util.ArrayList)25 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)10 UserContext (org.mifos.security.util.UserContext)10 HashMap (java.util.HashMap)8 LoanAccountDetailsDto (org.mifos.dto.domain.LoanAccountDetailsDto)8 CustomerStatusDetailDto (org.mifos.dto.screen.CustomerStatusDetailDto)8 MessageLookup (org.mifos.application.master.MessageLookup)7 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)7 LoanBO (org.mifos.accounts.loan.business.LoanBO)6 MifosRuntimeException (org.mifos.core.MifosRuntimeException)6 ClientBO (org.mifos.customers.client.business.ClientBO)6 LocalDate (org.joda.time.LocalDate)5 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)5 PersonnelLevelEntity (org.mifos.customers.personnel.business.PersonnelLevelEntity)4 CustSearchActionForm (org.mifos.customers.struts.actionforms.CustSearchActionForm)4 ApplicationException (org.mifos.framework.exceptions.ApplicationException)4 MifosUser (org.mifos.security.MifosUser)4 RoleBO (org.mifos.security.rolesandpermission.business.RoleBO)4 Date (java.util.Date)3