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();
}
}
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());
}
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;
}
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;
}
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;
}
Aggregations