Search in sources :

Example 76 with CustomFieldDto

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

the class UserFormBean method validateEnterUserDetailsStep.

@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "REC_CATCH_EXCEPTION", justification = "should be the exception thrown by jodatime but not sure what it is right now.")
public void validateEnterUserDetailsStep(ValidationContext context) {
    MessageContext messages = context.getMessageContext();
    validator.validate(this, messages);
    try {
        this.dateOfBirth = new DateTime().withDate(this.dateOfBirthYear.intValue(), this.dateOfBirthMonth.intValue(), this.dateOfBirthDay.intValue());
    } catch (Exception e) {
        messages.addMessage(new MessageBuilder().error().source("dateOfBrith").code("NotValid.UserFormBean.dateOfBrith").defaultText("dateOfBirth is not valid").build());
    }
    try {
        this.passwordExpirationDate = new DateTime().withDate(this.passwordExpirationDateYear.intValue(), this.passwordExpirationDateMonth.intValue(), this.passwordExpirationDateDay.intValue());
    } catch (Exception e) {
        messages.addMessage(new MessageBuilder().error().source("passwordExpirationDate").code("NotValid.UserFormBean.passwordExpirationDate").defaultText("Password expiration date is not valid").build());
    }
    try {
        this.mfiJoiningDate = new DateTime().withDate(this.mfiJoiningDateYear.intValue(), this.mfiJoiningDateMonth.intValue(), this.mfiJoiningDateDay.intValue());
    } catch (Exception e) {
        messages.addMessage(new MessageBuilder().error().source("mfiJoiningDate").code("NotValid.UserFormBean.mfiJoiningDate").defaultText("mfiJoiningDate is not valid").build());
    }
    if (this.password.trim().isEmpty() || this.confirmedPassword.trim().isEmpty()) {
        messages.addMessage(new MessageBuilder().error().source("password").code("NotEmpty.UserFormBean.password").defaultText("password is not correct.").build());
    } else if (this.password.trim().length() < 6) {
        messages.addMessage(new MessageBuilder().error().source("password").code("Min.UserFormBean.password").defaultText("password must have six characters at least.").build());
    } else if (!this.password.equals(this.confirmedPassword)) {
        messages.addMessage(new MessageBuilder().error().source("password").code("NotEqual.UserFormBean.password").defaultText("password is not correct.").build());
    }
    this.address.validate(messages, "UserFormBean");
    // validate additional fields
    for (CustomFieldDto additionalField : this.customFields) {
        switch(additionalField.getFieldType().intValue()) {
            case 0:
                break;
            case 1:
                validateNumericField(messages, additionalField);
                break;
            case 2:
                validateIfMandatoryField(messages, additionalField);
                break;
            case 3:
                for (DateFieldBean dateFieldBean : this.customDateFields) {
                    if (dateFieldBean.getId().equals(additionalField.getFieldId())) {
                        validateAndBindDateField(messages, additionalField, dateFieldBean);
                    }
                }
                break;
            default:
                break;
        }
    }
    if (messages.hasErrorMessages()) {
        this.prepateForReEdit();
    }
}
Also used : MessageBuilder(org.springframework.binding.message.MessageBuilder) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) MessageContext(org.springframework.binding.message.MessageContext) DateTime(org.joda.time.DateTime)

Example 77 with CustomFieldDto

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

the class TagGeneratorIntegrationTest method createPersonnel.

private PersonnelBO createPersonnel(OfficeBO office, PersonnelLevel personnelLevel) throws Exception {
    List<CustomFieldDto> customFieldDto = new ArrayList<CustomFieldDto>();
    customFieldDto.add(new CustomFieldDto(Short.valueOf("9"), "123456", CustomFieldType.NUMERIC.getValue()));
    Address address = new Address("abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd");
    Name name = new Name("XYZ", null, null, null);
    java.util.Date date = new java.util.Date();
    personnel = new PersonnelBO(personnelLevel, office, Integer.valueOf("1"), Short.valueOf("1"), "ABCD", "XYZ", "xyz@yahoo.com", null, customFieldDto, name, "111111", date, Integer.valueOf("1"), Integer.valueOf("1"), date, date, address, userContext.getId(), new Date(), new HashSet());
    IntegrationTestObjectMother.createPersonnel(personnel);
    return IntegrationTestObjectMother.findPersonnelById(personnel.getPersonnelId());
}
Also used : Address(org.mifos.framework.business.util.Address) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) Date(java.util.Date) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) Date(java.util.Date) Name(org.mifos.framework.business.util.Name) HashSet(java.util.HashSet)

Example 78 with CustomFieldDto

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

the class SystemUserController method translateUserFormBeanToDto.

@SuppressWarnings("PMD")
private CreateOrUpdatePersonnelInformation translateUserFormBeanToDto(final UserFormBean userFormBean) {
    Short officeId = userFormBean.getOfficeId().shortValue();
    String firstName = userFormBean.getFirstName();
    String middleName = userFormBean.getMiddleName();
    String secondLastName = userFormBean.getSecondLastName();
    String lastName = userFormBean.getLastName();
    String governmentIdNumber = userFormBean.getGovernmentId();
    DateTime dateOfBirth = userFormBean.getDateOfBirthAsDateTime();
    DateTime mfiJoiningDate = userFormBean.getMfiJoiningDateAsDateTime();
    DateTime branchJoiningDate = userFormBean.getMfiJoiningDateAsDateTime();
    DateTime passwordExpirationDate = userFormBean.getPasswordExpirationDateAsDateTime();
    String email = userFormBean.getEmail();
    Integer maritalStatus = null;
    if (StringUtils.isNotBlank(userFormBean.getSelectedMaritalStatus())) {
        maritalStatus = Integer.valueOf(userFormBean.getSelectedMaritalStatus());
    }
    Integer gender = Integer.valueOf(userFormBean.getSelectedGender());
    Integer title = null;
    if (StringUtils.isNotBlank(userFormBean.getSelectedUserTitle())) {
        title = Integer.valueOf(userFormBean.getSelectedUserTitle());
    }
    Short personnelLevelId = Short.valueOf(userFormBean.getSelectedUserHierarchy());
    List<ListElement> roles = new ArrayList<ListElement>();
    String[] selectedRoles = userFormBean.getSelectedRoles();
    if (selectedRoles != null) {
        for (String role : selectedRoles) {
            roles.add(new ListElement(Integer.valueOf(role), userFormBean.getSelectedRolesOptions().get(role)));
        }
    }
    AddressBean bean = userFormBean.getAddress();
    AddressDto address = new AddressDto(bean.getAddress1(), bean.getAddress2(), bean.getAddress3(), bean.getCityDistrict(), bean.getState(), bean.getCountry(), bean.getPostalCode(), bean.getTelephoneNumber());
    Short preferredLocale = null;
    if (StringUtils.isNotBlank(userFormBean.getSelectedPreferredLanguage())) {
        preferredLocale = Short.valueOf(userFormBean.getSelectedPreferredLanguage());
    }
    String password = userFormBean.getPassword();
    String username = userFormBean.getUsername();
    // FIXME - add status to screen and support translation from bean to DTO
    // active
    Short personnelStatusId = Short.valueOf("1");
    List<CustomFieldDto> customFields = userFormBean.getCustomFields();
    CreateOrUpdatePersonnelInformation personnel = new CreateOrUpdatePersonnelInformation(userFormBean.getUserId(), personnelLevelId, officeId, title, preferredLocale, password, username, email, roles, customFields, firstName, middleName, lastName, secondLastName, governmentIdNumber, dateOfBirth, maritalStatus, gender, mfiJoiningDate, branchJoiningDate, address, personnelStatusId, passwordExpirationDate);
    return personnel;
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) DateTime(org.joda.time.DateTime) CreateOrUpdatePersonnelInformation(org.mifos.dto.domain.CreateOrUpdatePersonnelInformation) ListElement(org.mifos.dto.screen.ListElement)

Example 79 with CustomFieldDto

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

the class SystemUserController method createPopulatedUserFormBean.

public UserFormBean createPopulatedUserFormBean(final Long userId, final UserFormBean formBean) {
    PersonnelInformationDto personnelInformation = this.personnelServiceFacade.getPersonnelInformationDto(userId, "");
    UserFormBean populatedBean = createUserFormBean(personnelInformation.getOfficeId().longValue(), formBean);
    populatedBean.setUserId(userId);
    populatedBean.setStatusId(personnelInformation.getStatus().getId());
    populatedBean.setDisplayName(personnelInformation.getDisplayName());
    PersonnelDetailsDto details = personnelInformation.getPersonnelDetails();
    populatedBean.setFirstName(details.getFirstName());
    populatedBean.setMiddleName(details.getMiddleName());
    populatedBean.setSecondLastName(details.getSecondLastName());
    populatedBean.setLastName(details.getLastName());
    populatedBean.setGovernmentId(details.getGovernmentIdNumber());
    populatedBean.setEmail(personnelInformation.getEmailId());
    populatedBean.setDateOfBirthDay(details.getDob().getDayOfMonth());
    populatedBean.setDateOfBirthMonth(details.getDob().getMonthOfYear());
    populatedBean.setDateOfBirthYear(details.getDob().getYearOfEra());
    if (details.getDateOfJoiningMFI() != null) {
        populatedBean.setDateOfBirthDay(details.getPasswordExpirationDate().getDayOfMonth());
        populatedBean.setDateOfBirthMonth(details.getPasswordExpirationDate().getMonthOfYear());
        populatedBean.setDateOfBirthYear(details.getPasswordExpirationDate().getYearOfEra());
    }
    if (details.getDateOfJoiningMFI() != null) {
        populatedBean.setMfiJoiningDateDay(details.getDateOfJoiningMFI().getDayOfMonth());
        populatedBean.setMfiJoiningDateMonth(details.getDateOfJoiningMFI().getMonthOfYear());
        populatedBean.setMfiJoiningDateYear(details.getDateOfJoiningMFI().getYearOfEra());
    }
    populatedBean.setSelectedGender(details.getGender().toString());
    if (details.getMaritalStatus() != null) {
        populatedBean.setSelectedMaritalStatus(details.getMaritalStatus().toString());
    }
    if (personnelInformation.getPreferredLanguageId() != null) {
        populatedBean.setSelectedPreferredLanguage(personnelInformation.getPreferredLanguageId().toString());
    }
    AddressDto address = details.getAddress();
    AddressBean bean = populatedBean.getAddress();
    bean.setAddress1(address.getLine1());
    bean.setAddress2(address.getLine2());
    bean.setAddress3(address.getLine3());
    bean.setCityDistrict(address.getCity());
    bean.setState(address.getState());
    bean.setCountry(address.getCountry());
    bean.setPostalCode(address.getZip());
    bean.setTelephoneNumber(address.getPhoneNumber());
    populatedBean.setAddress(bean);
    if (personnelInformation.getTitle() != null) {
        populatedBean.setSelectedUserTitle(personnelInformation.getTitle().toString());
    }
    populatedBean.setSelectedUserHierarchy(personnelInformation.getLevelId().toString());
    Set<ListElement> roles = personnelInformation.getPersonnelRoles();
    String[] selectedRoles = new String[roles.size()];
    int roleIndex = 0;
    for (ListElement listElement : roles) {
        selectedRoles[roleIndex] = listElement.getId().toString();
        roleIndex++;
    }
    populatedBean.setSelectedRoles(selectedRoles);
    populatedBean.setUsername(personnelInformation.getUserName());
    List<CustomFieldDto> currentBeanFields = new ArrayList<CustomFieldDto>();
    List<CustomFieldDto> defaultBeanFields = populatedBean.getCustomFields();
    for (CustomFieldDto customFieldDto : defaultBeanFields) {
        CustomFieldDto matchingField = findMatchingAndSetFieldValue(customFieldDto, personnelInformation.getCustomFields());
        if (matchingField != null) {
            currentBeanFields.add(matchingField);
        }
    }
    populatedBean.setRecentNotes(personnelInformation.getRecentPersonnelNotes());
    populatedBean.setCustomFields(currentBeanFields);
    populatedBean.prepareForPreview();
    populatedBean.prepateForReEdit();
    return populatedBean;
}
Also used : PersonnelInformationDto(org.mifos.dto.screen.PersonnelInformationDto) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) ListElement(org.mifos.dto.screen.ListElement) PersonnelDetailsDto(org.mifos.dto.screen.PersonnelDetailsDto)

Example 80 with CustomFieldDto

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

the class SavingsBOIntegrationTest method getCustomFieldView.

private List<CustomFieldDto> getCustomFieldView() {
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    customFields.add(new CustomFieldDto(new Short("8"), "13", null));
    return customFields;
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList)

Aggregations

CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)86 ArrayList (java.util.ArrayList)48 Test (org.junit.Test)36 UserContext (org.mifos.security.util.UserContext)16 Date (java.util.Date)14 Address (org.mifos.framework.business.util.Address)14 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)13 AddressDto (org.mifos.dto.domain.AddressDto)12 List (java.util.List)10 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)10 SimpleDateFormat (java.text.SimpleDateFormat)9 BusinessActivityEntity (org.mifos.application.master.business.BusinessActivityEntity)9 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)8 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)8 CustomerPositionDto (org.mifos.dto.domain.CustomerPositionDto)8 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)7 MeetingBO (org.mifos.application.meeting.business.MeetingBO)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)6 GroupCustActionForm (org.mifos.customers.group.struts.actionforms.GroupCustActionForm)6 OfficeBO (org.mifos.customers.office.business.OfficeBO)6