use of org.mifos.dto.domain.AddressDto in project head by mifos.
the class OfficeServiceFacadeWebTier method createOffice.
@Override
public ListElement createOffice(Short operationMode, OfficeDto officeDto) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
OfficeLevel level = OfficeLevel.getOfficeLevel(officeDto.getLevelId());
OfficeBO parentOffice = officeDao.findOfficeById(officeDto.getParentId());
AddressDto addressDto = officeDto.getAddress();
Address address = new Address(addressDto.getLine1(), addressDto.getLine2(), addressDto.getLine3(), addressDto.getCity(), addressDto.getState(), addressDto.getCountry(), addressDto.getZip(), addressDto.getPhoneNumber());
try {
OfficeBO officeBO = new OfficeBO(userContext, level, parentOffice, officeDto.getCustomFields(), officeDto.getName(), officeDto.getOfficeShortName(), address, OperationMode.fromInt(operationMode.intValue()));
OfficePersistence officePersistence = new OfficePersistence();
if (officePersistence.isOfficeNameExist(officeDto.getName())) {
throw new OfficeValidationException(OfficeConstants.OFFICENAMEEXIST);
}
if (officePersistence.isOfficeShortNameExist(officeDto.getOfficeShortName())) {
throw new OfficeValidationException(OfficeConstants.OFFICESHORTNAMEEXIST);
}
String searchId = generateSearchId(parentOffice);
officeBO.setSearchId(searchId);
String globalOfficeNum = generateOfficeGlobalNo();
officeBO.setGlobalOfficeNum(globalOfficeNum);
StaticHibernateUtil.startTransaction();
this.officeDao.save(officeBO);
StaticHibernateUtil.commitTransaction();
//Shahid - this is hackish solution to return officeId and globalOfficeNum via ListElement, it should be fixed, at least
//a proper data storage class can be created
ListElement element = new ListElement(new Integer(officeBO.getOfficeId()), officeBO.getGlobalOfficeNum());
// if we are here it means office created sucessfully
// we need to update hierarchy manager cache
OfficeSearch os = new OfficeSearch(officeBO.getOfficeId(), officeBO.getSearchId(), officeBO.getParentOffice().getOfficeId());
List<OfficeSearch> osList = new ArrayList<OfficeSearch>();
osList.add(os);
EventManger.postEvent(Constants.CREATE, osList, SecurityConstants.OFFICECHANGEEVENT);
return element;
} catch (OfficeValidationException e) {
StaticHibernateUtil.rollbackTransaction();
throw new BusinessRuleException(e.getMessage());
} catch (PersistenceException e) {
StaticHibernateUtil.rollbackTransaction();
throw new MifosRuntimeException(e);
} catch (OfficeException e) {
StaticHibernateUtil.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} finally {
StaticHibernateUtil.closeSession();
}
}
use of org.mifos.dto.domain.AddressDto in project head by mifos.
the class OfficeServiceFacadeWebTier method retrieveOfficeById.
@Override
public OfficeDto retrieveOfficeById(Short id) {
OfficeBO officeBO = officeDao.findOfficeById(id);
List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
Short parentOfficeId = null;
String parentOffineName = null;
if (officeBO.getParentOffice() != null) {
parentOfficeId = officeBO.getParentOffice().getOfficeId();
parentOffineName = officeBO.getParentOffice().getOfficeName();
}
Address address = officeBO.getAddress() != null ? officeBO.getAddress().getAddress() : null;
AddressDto addressDto = address != null ? Address.toDto(officeBO.getAddress().getAddress()) : null;
String officeLevelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeBO.getLevel().getLookUpValue());
String officeStatusName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeBO.getStatus().getLookUpValue());
OfficeDto officeDto = new OfficeDto(officeBO.getOfficeId(), officeBO.getOfficeName(), officeBO.getSearchId(), officeBO.getShortName(), officeBO.getGlobalOfficeNum(), parentOfficeId, officeBO.getStatus().getId(), officeBO.getLevel().getId(), parentOffineName, officeBO.getVersionNo(), officeStatusName, officeLevelName, addressDto, customFields);
return officeDto;
}
use of org.mifos.dto.domain.AddressDto in project head by mifos.
the class CenterServiceFacadeWebTier method retrieveCenterDetailsForUpdate.
@Override
public CenterDto retrieveCenterDetailsForUpdate(Integer centerId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
CustomerBO center = customerDao.findCustomerById(centerId);
Short officeId = center.getOffice().getOfficeId();
String searchId = center.getSearchId();
Short loanOfficerId = extractLoanOfficerId(center);
CenterCreation centerCreation = new CenterCreation(officeId, userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
List<PersonnelDto> activeLoanOfficersForBranch = personnelDao.findActiveLoanOfficersForOffice(centerCreation);
List<CustomerDto> customerList = customerDao.findClientsThatAreNotCancelledOrClosed(searchId, officeId);
List<CustomerPositionDto> customerPositionDtos = generateCustomerPositionViews(center, userContext.getLocaleId());
DateTime mfiJoiningDate = new DateTime();
String mfiJoiningDateAsString = "";
if (center.getMfiJoiningDate() != null) {
mfiJoiningDate = new DateTime(center.getMfiJoiningDate());
mfiJoiningDateAsString = DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), center.getMfiJoiningDate().toString());
}
AddressDto address = null;
if (center.getAddress() != null) {
address = Address.toDto(center.getAddress());
}
return new CenterDto(loanOfficerId, center.getCustomerId(), center.getGlobalCustNum(), mfiJoiningDate, mfiJoiningDateAsString, center.getExternalId(), address, customerPositionDtos, customerList, activeLoanOfficersForBranch, true);
}
use of org.mifos.dto.domain.AddressDto 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.dto.domain.AddressDto in project head by mifos.
the class PictureFormFile method create.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ClientCustActionForm actionForm = (ClientCustActionForm) form;
MeetingBO meeting = (MeetingBO) SessionUtils.getAttribute(CustomerConstants.CUSTOMER_MEETING, request);
List<SavingsDetailDto> allowedSavingProducts = getSavingsOfferingsFromSession(request);
if (ClientRules.isFamilyDetailsRequired()) {
actionForm.setFamilyDateOfBirth();
actionForm.constructFamilyDetails();
}
List<Short> selectedSavingProducts = actionForm.getSelectedOfferings();
String clientName = actionForm.getClientName().getDisplayName();
Short clientStatus = actionForm.getStatusValue().getValue();
java.sql.Date mfiJoiningDate = DateUtils.getDateAsSentFromBrowser(actionForm.getMfiJoiningDate());
String externalId = actionForm.getExternalId();
AddressDto address = null;
if (actionForm.getAddress() != null) {
address = Address.toDto(actionForm.getAddress());
}
Short formedBy = actionForm.getFormedByPersonnelValue();
java.sql.Date dateOfBirth = DateUtils.getDateAsSentFromBrowser(actionForm.getDateOfBirth());
String governmentId = actionForm.getGovernmentId();
boolean trained = isTrained(actionForm.getTrainedValue());
java.sql.Date trainedDate = DateUtils.getDateAsSentFromBrowser(actionForm.getTrainedDate());
Short groupFlagValue = actionForm.getGroupFlagValue();
ClientNameDetailDto clientNameDetailDto = actionForm.getClientName();
ClientPersonalDetailDto clientPersonalDetailDto = actionForm.getClientDetailView();
ClientNameDetailDto spouseFatherName = actionForm.getSpouseName();
InputStream picture = actionForm.getCustomerPicture();
String parentGroupId = actionForm.getParentGroupId();
List<ClientNameDetailDto> familyNames = actionForm.getFamilyNames();
List<ClientFamilyDetailDto> familyDetails = actionForm.getFamilyDetails();
Short loanOfficerId = actionForm.getLoanOfficerIdValue();
Short officeId = actionForm.getOfficeIdValue();
// only applies when status is active
LocalDate activationDateAsToday = new LocalDate();
ClientCreationDetail clientCreationDetail = new ClientCreationDetail(selectedSavingProducts, clientName, clientStatus, mfiJoiningDate, externalId, address, formedBy, dateOfBirth, governmentId, trained, trainedDate, groupFlagValue, clientNameDetailDto, clientPersonalDetailDto, spouseFatherName, picture, actionForm.getFeesToApply(), parentGroupId, familyNames, familyDetails, loanOfficerId, officeId, activationDateAsToday);
MeetingDto meetingDto = null;
if (meeting != null) {
meetingDto = meeting.toDto();
}
CustomerDetailsDto clientDetails = this.clientServiceFacade.createNewClient(clientCreationDetail, meetingDto, allowedSavingProducts);
List<FormFile> formFiles = actionForm.getFiles();
List<UploadedFileDto> filesMetadata = actionForm.getFilesMetadata();
for (int i = 0; i < formFiles.size(); i++) {
if (formFiles.get(i).getFileSize() != 0) {
InputStream inputStream = formFiles.get(i).getInputStream();
UploadedFileDto fileMetadata = filesMetadata.get(i);
clientServiceFacade.uploadFile(clientDetails.getId(), inputStream, fileMetadata);
}
}
actionForm.setCustomerId(clientDetails.getId().toString());
actionForm.setGlobalCustNum(clientDetails.getGlobalCustNum());
actionForm.setEditFamily("notEdit");
createClientQuestionnaire.saveResponses(request, actionForm, clientDetails.getId());
return mapping.findForward(ActionForwards.create_success.toString());
}
Aggregations