Search in sources :

Example 6 with ListElement

use of org.mifos.dto.screen.ListElement in project head by mifos.

the class OffAction method create.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    OffActionForm offActionForm = (OffActionForm) form;
    OfficeDto officeDto = new OfficeDto(getShortValue(offActionForm.getOfficeLevel()), getShortValue(offActionForm.getParentOfficeId()), offActionForm.getCustomFields(), offActionForm.getOfficeName(), offActionForm.getShortName(), Address.toDto(offActionForm.getAddress()));
    ListElement element = officeServiceFacade.createOffice(OperationMode.REMOTE_SERVER.getValue(), officeDto);
    offActionForm.setOfficeId(element.getId().toString());
    offActionForm.setGlobalOfficeNum(element.getName());
    createGroupQuestionnaire.saveResponses(request, offActionForm, element.getId());
    return mapping.findForward(ActionForwards.create_success.toString());
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) ListElement(org.mifos.dto.screen.ListElement) OffActionForm(org.mifos.customers.office.struts.actionforms.OffActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 7 with ListElement

use of org.mifos.dto.screen.ListElement in project head by mifos.

the class LoanAccountServiceFacadeWebTier method retrieveAccountStatuses.

@Override
public AccountStatusDto retrieveAccountStatuses(Long loanAccountId) {
    LoanBO loanAccount = this.loanDao.findById(loanAccountId.intValue());
    try {
        List<ListElement> loanStatesList = new ArrayList<ListElement>();
        AccountStateMachines.getInstance().initializeLoanStates();
        List<AccountStateEntity> statusList = AccountStateMachines.getInstance().getLoanStatusList(loanAccount.getAccountState());
        for (AccountStateEntity accountState : statusList) {
            loanStatesList.add(new ListElement(accountState.getId().intValue(), accountState.getName()));
        }
        return new AccountStatusDto(loanStatesList);
    } catch (StatesInitializationException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : AccountStatusDto(org.mifos.dto.domain.AccountStatusDto) ChangeAccountStatusDto(org.mifos.dto.screen.ChangeAccountStatusDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) ValueListElement(org.mifos.dto.domain.ValueListElement) ListElement(org.mifos.dto.screen.ListElement) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 8 with ListElement

use of org.mifos.dto.screen.ListElement 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 9 with ListElement

use of org.mifos.dto.screen.ListElement in project head by mifos.

the class SavingsServiceFacadeWebTier method retrieveDepositWithdrawalReferenceData.

@Override
public DepositWithdrawalReferenceDto retrieveDepositWithdrawalReferenceData(Long savingsId, Integer customerId) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    try {
        SavingsBO savingsAccount = savingsDao.findById(savingsId);
        String depositDue = savingsAccount.getTotalPaymentDue(customerId).toString();
        String withdrawalDue = "0";
        List<ListElement> clients = new ArrayList<ListElement>();
        if (savingsAccount.isGroupModelWithIndividualAccountability()) {
            List<CustomerBO> activeAndOnHoldClients = new CustomerPersistence().getActiveAndOnHoldChildren(savingsAccount.getCustomer().getSearchId(), savingsAccount.getCustomer().getOfficeId(), CustomerLevel.CLIENT);
            for (CustomerBO client : activeAndOnHoldClients) {
                clients.add(new ListElement(client.getCustomerId(), client.getDisplayName()));
            }
        }
        List<AccountActionEntity> trxnTypes = new ArrayList<AccountActionEntity>();
        trxnTypes.add(new AccountBusinessService().getAccountAction(AccountActionTypes.SAVINGS_DEPOSIT.getValue(), userContext.getLocaleId()));
        trxnTypes.add(new AccountBusinessService().getAccountAction(AccountActionTypes.SAVINGS_WITHDRAWAL.getValue(), userContext.getLocaleId()));
        List<ListElement> transactionTypes = new ArrayList<ListElement>();
        for (AccountActionEntity accountActionEntity : trxnTypes) {
            LookUpValueEntity lookupValue = accountActionEntity.getLookUpValue();
            String messageText = lookupValue.getMessageText();
            if (StringUtils.isBlank(messageText)) {
                messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
            }
            transactionTypes.add(new ListElement(accountActionEntity.getId().intValue(), messageText));
        }
        List<ListElement> depositPaymentTypes = retrieveDepositPaymentTypes(userContext);
        List<ListElement> withdrawalPaymentTypes = new ArrayList<ListElement>();
        List<PaymentTypeEntity> withdrawalPaymentEntityTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(userContext.getLocaleId(), TrxnTypes.savings_withdrawal.getValue());
        for (PaymentTypeEntity paymentTypeEntity : withdrawalPaymentEntityTypes) {
            LookUpValueEntity lookupValue = paymentTypeEntity.getLookUpValue();
            String messageText = lookupValue.getMessageText();
            if (StringUtils.isBlank(messageText)) {
                messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
            }
            withdrawalPaymentTypes.add(new ListElement(paymentTypeEntity.getId().intValue(), messageText));
        }
        boolean backDatedTransactionsAllowed = AccountingRules.isBackDatedTxnAllowed();
        LocalDate defaultTransactionDate = new LocalDate();
        return new DepositWithdrawalReferenceDto(transactionTypes, depositPaymentTypes, withdrawalPaymentTypes, clients, backDatedTransactionsAllowed, defaultTransactionDate, depositDue, withdrawalDue);
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) LocalDate(org.joda.time.LocalDate) AccountActionEntity(org.mifos.accounts.business.AccountActionEntity) PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) ListElement(org.mifos.dto.screen.ListElement) PersistenceException(org.mifos.framework.exceptions.PersistenceException) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) DepositWithdrawalReferenceDto(org.mifos.dto.screen.DepositWithdrawalReferenceDto) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 10 with ListElement

use of org.mifos.dto.screen.ListElement in project head by mifos.

the class SavingsServiceFacadeWebTier method retrieveDepositPaymentTypes.

private List<ListElement> retrieveDepositPaymentTypes(UserContext userContext) {
    try {
        List<ListElement> depositPaymentTypes = new ArrayList<ListElement>();
        List<PaymentTypeEntity> acceptedPaymentEntityTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(userContext.getLocaleId(), TrxnTypes.savings_deposit.getValue());
        for (PaymentTypeEntity paymentTypeEntity : acceptedPaymentEntityTypes) {
            LookUpValueEntity lookupValue = paymentTypeEntity.getLookUpValue();
            String messageText = lookupValue.getMessageText();
            if (StringUtils.isBlank(messageText)) {
                messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
            }
            depositPaymentTypes.add(new ListElement(paymentTypeEntity.getId().intValue(), messageText));
        }
        return depositPaymentTypes;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) ArrayList(java.util.ArrayList) ListElement(org.mifos.dto.screen.ListElement) PersistenceException(org.mifos.framework.exceptions.PersistenceException) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

ListElement (org.mifos.dto.screen.ListElement)41 ArrayList (java.util.ArrayList)20 LinkedHashMap (java.util.LinkedHashMap)17 MifosRuntimeException (org.mifos.core.MifosRuntimeException)14 ValueListElement (org.mifos.dto.domain.ValueListElement)7 PersistenceException (org.mifos.framework.exceptions.PersistenceException)7 AddressDto (org.mifos.dto.domain.AddressDto)5 StatesInitializationException (org.mifos.framework.exceptions.StatesInitializationException)5 MifosUser (org.mifos.security.MifosUser)5 UserContext (org.mifos.security.util.UserContext)5 DateTime (org.joda.time.DateTime)4 OfficeBO (org.mifos.customers.office.business.OfficeBO)4 RoleBO (org.mifos.security.rolesandpermission.business.RoleBO)4 BusinessRuleException (org.mifos.service.BusinessRuleException)4 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)3 CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)3 CreateOrUpdatePersonnelInformation (org.mifos.dto.domain.CreateOrUpdatePersonnelInformation)3 Address (org.mifos.framework.business.util.Address)3 LocalDate (org.joda.time.LocalDate)2 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)2