use of org.mifos.accounts.servicefacade.UserContextFactory in project head by mifos.
the class CheckListServiceFacadeWebTier method createCustomerChecklist.
@Override
public void createCustomerChecklist(Short levelId, Short stateId, String checklistName, List<String> checklistDetails) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
CustomerLevel level = CustomerLevel.getLevel(levelId);
CustomerLevelEntity customerLevelEntity = new CustomerLevelEntity(level);
CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(stateId);
try {
hibernateTransactionHelper.startTransaction();
CustomerCheckListBO customerCheckListBO = new CustomerCheckListBO(customerLevelEntity, customerStatusEntity, checklistName, CheckListConstants.STATUS_ACTIVE, checklistDetails, userContext.getLocaleId(), userContext.getId());
customerDao.save(customerCheckListBO);
hibernateTransactionHelper.commitTransaction();
} catch (CheckListException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} finally {
hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.accounts.servicefacade.UserContextFactory in project head by mifos.
the class CheckListServiceFacadeWebTier method updateCustomerChecklist.
@Override
public void updateCustomerChecklist(Short checklistId, Short levelId, Short stateId, Short checklistStatus, String checklistName, List<String> details) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
CustomerLevelEntity customerLevelEntity = new CustomerLevelEntity(CustomerLevel.getLevel(levelId));
CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(stateId);
try {
hibernateTransactionHelper.startTransaction();
CustomerCheckListBO customerCheckList = (CustomerCheckListBO) new CheckListPersistence().getCheckList(checklistId);
customerCheckList.update(customerLevelEntity, customerStatusEntity, checklistName, checklistStatus, details, userContext.getLocaleId(), userContext.getId());
customerDao.save(customerCheckList);
hibernateTransactionHelper.commitTransaction();
} catch (CheckListException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} catch (PersistenceException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.accounts.servicefacade.UserContextFactory in project head by mifos.
the class CheckListServiceFacadeWebTier method createAccountChecklist.
@Override
public void createAccountChecklist(Short productId, Short stateId, String checklistName, List<String> checklistDetails) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
try {
ProductTypeEntity productTypeEntity = null;
for (ProductTypeEntity prdTypeEntity : new ProductCategoryBusinessService().getProductTypes()) {
if (productId.equals(prdTypeEntity.getProductTypeID())) {
productTypeEntity = prdTypeEntity;
break;
}
}
hibernateTransactionHelper.startTransaction();
AccountStateEntity accountStateEntity = new AccountStateEntity(AccountState.fromShort(stateId));
AccountCheckListBO accountCheckListBO = new AccountCheckListBO(productTypeEntity, accountStateEntity, checklistName, CheckListConstants.STATUS_ACTIVE, checklistDetails, userContext.getLocaleId(), userContext.getId());
customerDao.save(accountCheckListBO);
hibernateTransactionHelper.commitTransaction();
} catch (ServiceException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} catch (CheckListException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} finally {
hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.accounts.servicefacade.UserContextFactory in project head by mifos.
the class CollectionSheetServiceFacadeWebTier method getCollectionSheet.
@Override
public CollectionSheetDto getCollectionSheet(Integer customerId, LocalDate meetingDate) {
MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(mifosUser);
CustomerBO customerBO = this.customerDao.findCustomerById(customerId);
try {
personnelDao.checkAccessPermission(userContext, customerBO.getOfficeId(), customerBO.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
return collectionSheetService.retrieveCollectionSheet(customerId, meetingDate);
}
use of org.mifos.accounts.servicefacade.UserContextFactory in project head by mifos.
the class AdminServiceFacadeWebTier method createProductCategory.
@Override
public void createProductCategory(CreateOrUpdateProductCategory productCategoryDto) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
this.loanProductDao.validateNameIsAvailableForCategory(productCategoryDto.getProductCategoryName(), productCategoryDto.getProductTypeEntityId());
HibernateTransactionHelper transactionHelper = new HibernateTransactionHelperForStaticHibernateUtil();
try {
// FIXME - delegate to globalNumberGenerationStrategy
StringBuilder globalPrdOfferingNum = new StringBuilder();
globalPrdOfferingNum.append(userContext.getBranchId());
globalPrdOfferingNum.append("-");
Short maxPrdID = legacyProductCategoryDao.getMaxPrdCategoryId();
globalPrdOfferingNum.append(StringUtils.leftPad(String.valueOf(maxPrdID != null ? maxPrdID + 1 : ProductDefinitionConstants.DEFAULTMAX), 3, '0'));
String globalNumber = globalPrdOfferingNum.toString();
ProductTypeEntity productType = new ProductTypeEntity(productCategoryDto.getProductTypeEntityId());
ProductCategoryBO productCategoryBO = new ProductCategoryBO(productType, productCategoryDto.getProductCategoryName(), productCategoryDto.getProductCategoryDesc(), globalNumber);
transactionHelper.startTransaction();
this.loanProductDao.save(productCategoryBO);
transactionHelper.commitTransaction();
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
} catch (Exception e) {
transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
transactionHelper.closeSession();
}
}
Aggregations