use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class PersonAction method translateFormToCreatePersonnelInformationDto.
@SuppressWarnings("unchecked")
private CreateOrUpdatePersonnelInformation translateFormToCreatePersonnelInformationDto(HttpServletRequest request, PersonActionForm personActionForm) throws PageExpiredException, InvalidDateException {
UserContext userContext = getUserContext(request);
PersonnelLevel level = PersonnelLevel.fromInt(getShortValue(personActionForm.getLevel()));
PersonnelStatus personnelStatus = PersonnelStatus.ACTIVE;
if (StringUtils.isNotBlank(personActionForm.getStatus())) {
personnelStatus = PersonnelStatus.getPersonnelStatus(getShortValue(personActionForm.getStatus()));
}
OfficeBO office = (OfficeBO) SessionUtils.getAttribute(PersonnelConstants.OFFICE, request);
if (office == null) {
Short officeId = getShortValue(personActionForm.getOfficeId());
office = this.officeDao.findOfficeById(officeId);
}
Integer title = getIntegerValue(personActionForm.getTitle());
Short preferredLocale = Localization.getInstance().getConfiguredLocaleId();
preferredLocale = getPerefferedLocale(personActionForm, userContext);
Date dob = null;
if (personActionForm.getDob() != null && !personActionForm.getDob().equals("")) {
dob = DateUtils.getDate(personActionForm.getDob());
}
Date dateOfJoiningMFI = null;
if (personActionForm.getDateOfJoiningMFI() != null && !personActionForm.getDateOfJoiningMFI().equals("")) {
dateOfJoiningMFI = DateUtils.getDateAsSentFromBrowser(personActionForm.getDateOfJoiningMFI());
}
Date passwordExpirationDate = null;
if (personActionForm.getPasswordExpirationDate() != null && !personActionForm.getPasswordExpirationDate().equals("")) {
passwordExpirationDate = DateUtils.getDate(personActionForm.getPasswordExpirationDate());
}
List<RoleBO> roles = new ArrayList<RoleBO>();
boolean addFlag = false;
List<RoleBO> selectList = new ArrayList<RoleBO>();
List<RoleBO> masterList = (List<RoleBO>) SessionUtils.getAttribute(PersonnelConstants.ROLEMASTERLIST, request);
if (personActionForm.getPersonnelRoles() != null) {
for (RoleBO role : masterList) {
for (String roleId : personActionForm.getPersonnelRoles()) {
if (roleId != null && role.getId().intValue() == Integer.valueOf(roleId).intValue()) {
selectList.add(role);
addFlag = true;
}
}
}
}
if (addFlag) {
roles = selectList;
}
List<ListElement> roleList = new ArrayList<ListElement>();
for (RoleBO element : roles) {
ListElement listElement = new ListElement(new Integer(element.getId()), element.getName());
roleList.add(listElement);
}
Address address = personActionForm.getAddress();
AddressDto addressDto = new AddressDto(address.getLine1(), address.getLine2(), address.getLine3(), address.getCity(), address.getState(), address.getCountry(), address.getZip(), address.getPhoneNumber());
Long id = null;
if (StringUtils.isNotBlank(personActionForm.getPersonnelId())) {
id = Long.valueOf(personActionForm.getPersonnelId());
}
CreateOrUpdatePersonnelInformation perosonnelInfo = new CreateOrUpdatePersonnelInformation(id, level.getValue(), office.getOfficeId(), title, preferredLocale, personActionForm.getUserPassword(), personActionForm.getLoginName(), personActionForm.getEmailId(), roleList, personActionForm.getCustomFields(), personActionForm.getFirstName(), personActionForm.getMiddleName(), personActionForm.getLastName(), personActionForm.getSecondLastName(), personActionForm.getGovernmentIdNumber(), new DateTime(dob), getIntegerValue(personActionForm.getMaritalStatus()), getIntegerValue(personActionForm.getGender()), new DateTime(dateOfJoiningMFI), new DateTimeService().getCurrentDateTime(), addressDto, personnelStatus.getValue(), new DateTime(passwordExpirationDate));
return perosonnelInfo;
}
use of org.mifos.customers.office.business.OfficeBO 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());
}
use of org.mifos.customers.office.business.OfficeBO 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());
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class GroupServiceFacadeWebTierIntegrationTest method shouldTransferGroupFromOfficeToOffice.
@Test
public void shouldTransferGroupFromOfficeToOffice() {
// setup
boolean centerHierarchyExistsOriginal = ClientRules.getCenterHierarchyExists();
ClientRules.setCenterHierarchyExists(false);
OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
createOfficeHierarchyUnderHeadOffice(headOffice);
Short officeId1 = branch1.getOfficeId();
CustomerDetailsDto group1Details = createGroup("group1", officeId1);
Short officeId2 = branch2.getOfficeId();
CustomerDetailsDto group2Details = createGroup("group2", officeId2);
CustomerDetailsDto newlyCreatedCustomerDetails = createClient(group1Details.getId().toString());
GroupBO group1 = customerDao.findGroupBySystemId(group1Details.getGlobalCustNum());
groupServiceFacade.transferGroupToBranch(group1Details.getGlobalCustNum(), officeId2, group1.getVersionNo());
ClientRules.setCenterHierarchyExists(centerHierarchyExistsOriginal);
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class GroupServiceFacadeWebTierIntegrationTest method shouldCreateGroupWithActivationDateInPast.
@Test
public void shouldCreateGroupWithActivationDateInPast() {
// setup
boolean centerHierarchyExistsOriginal = ClientRules.getCenterHierarchyExists();
MeetingBO meeting = new MeetingBuilder().withStartDate(new DateTime().minusWeeks(2)).build();
MeetingDto meetingDto = meeting.toDto();
String displayName = "testGroup";
String externalId = null;
AddressDto addressDto = null;
PersonnelBO user = IntegrationTestObjectMother.findPersonnelById(Short.valueOf("1"));
Short loanOfficerId = user.getPersonnelId();
List<ApplicableAccountFeeDto> feesToApply = new ArrayList<ApplicableAccountFeeDto>();
Short customerStatus = CustomerStatus.GROUP_ACTIVE.getValue();
boolean trained = false;
DateTime trainedOn = null;
String parentSystemId = null;
OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
// setup
createOfficeHierarchyUnderHeadOffice(headOffice);
Short officeId = branch1.getOfficeId();
DateTime mfiJoiningDate = new DateTime().minusWeeks(2);
DateTime activationDate = new DateTime().minusWeeks(1);
GroupCreationDetail groupCenterDetail = new GroupCreationDetail(displayName, externalId, addressDto, loanOfficerId, feesToApply, customerStatus, trained, trainedOn, parentSystemId, officeId, mfiJoiningDate, activationDate);
// exercise test
ClientRules.setCenterHierarchyExists(false);
CustomerDetailsDto newlyCreatedGroupDetails = groupServiceFacade.createNewGroup(groupCenterDetail, meetingDto);
// verification
ClientRules.setCenterHierarchyExists(centerHierarchyExistsOriginal);
GroupBO group = customerDao.findGroupBySystemId(newlyCreatedGroupDetails.getGlobalCustNum());
Assert.assertThat(new LocalDate(group.getCustomerActivationDate()), is(activationDate.toLocalDate()));
}
Aggregations