use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class CenterServiceFacadeWebTier method waiveChargesOverDue.
@Override
public void waiveChargesOverDue(Integer accountId, Integer waiveType) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
AccountBO account = new AccountBusinessService().getAccount(accountId);
account.updateDetails(userContext);
WaiveEnum waiveEnum = WaiveEnum.fromInt(waiveType);
if (account.getPersonnel() != null) {
new AccountBusinessService().checkPermissionForWaiveDue(waiveEnum, account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), account.getPersonnel().getPersonnelId());
} else {
new AccountBusinessService().checkPermissionForWaiveDue(waiveEnum, account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), userContext.getId());
}
this.transactionHelper.startTransaction();
account.waiveAmountOverDue(waiveEnum);
this.customerDao.save(account);
this.transactionHelper.commitTransaction();
} catch (ServiceException e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} catch (ApplicationException e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} finally {
this.transactionHelper.closeSession();
}
}
use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class QGFlowsServiceImpl method applyToAllLoanProducts.
@Override
public void applyToAllLoanProducts(Integer questionGroupId) throws SystemException {
LoanPrdBusinessService loanPrdBusinessService = new LoanPrdBusinessService();
try {
List<LoanOfferingBO> offerings = loanPrdBusinessService.getAllLoanOfferings((short) 1);
if (offerings.size() > 0) {
QuestionGroupReference questionGroupReference = new QuestionGroupReference();
questionGroupReference.setQuestionGroupId(questionGroupId);
for (LoanOfferingBO offering : offerings) {
offering.getQuestionGroups().add(questionGroupReference);
offering.save();
}
StaticHibernateUtil.commitTransaction();
}
} catch (ServiceException e) {
throw new SystemException(e);
} catch (ProductDefinitionException e) {
throw new SystemException(e);
}
}
use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class AuditBusinessService method getAuditLogRecords.
public List<AuditLogView> getAuditLogRecords(Short entityType, Integer entityId) throws ServiceException {
try {
LegacyAuditDao auditPersistence = ApplicationContextProvider.getBean(LegacyAuditDao.class);
PersonnelBusinessService personnelService = new PersonnelBusinessService();
List<AuditLog> auditLogRecords = auditPersistence.getAuditLogRecords(entityType, entityId);
List<AuditLogView> auditLogViewList = new ArrayList<AuditLogView>();
for (AuditLog auditLog : auditLogRecords) {
for (AuditLogRecord auditLogRecord : auditLog.getAuditLogRecords()) {
AuditLogView auditLogView = new AuditLogView();
auditLogView.setDate(auditLog.getUpdatedDate().toString());
Short userId = auditLog.getUpdatedBy();
PersonnelBO personnel = personnelService.getPersonnel(userId);
auditLogView.setUser(personnel.getUserName());
auditLogView.setField(auditLogRecord.getFieldName());
String encryptedPasswordAuditFieldName = AuditConfiguration.getColumnNameForPropertyName(AuditConstants.PERSONNEL, AuditConstants.Audit_PASSWORD);
if ((null != encryptedPasswordAuditFieldName) && (auditLogRecord.getFieldName().equals(encryptedPasswordAuditFieldName.trim()))) {
auditLogView.setOldValue(AuditConstants.HIDDEN_PASSWORD);
auditLogView.setNewValue(AuditConstants.HIDDEN_PASSWORD);
} else {
auditLogView.setOldValue(auditLogRecord.getOldValue());
auditLogView.setNewValue(auditLogRecord.getNewValue());
}
auditLogViewList.add(auditLogView);
}
}
return auditLogViewList;
} catch (PersistenceException e) {
throw new ServiceException(e);
}
}
use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class AuditLogServiceImpl method addAuditLogRegistry.
@Override
public void addAuditLogRegistry(QuestionGroupDetail questionGroupDetail, QuestionGroupDetail oldQuestionGroupDetail, int creatorId, int entityId, String source, String event) {
PersonnelBusinessService pbs = new PersonnelBusinessService();
String modifierName;
if (oldQuestionGroupDetail != null && event.toLowerCase().equals(CREATE)) {
String questionGroupName;
String sectionName;
String fieldName;
String fieldValue;
try {
modifierName = pbs.getPersonnel((short) creatorId).getDisplayName();
} catch (ServiceException e) {
modifierName = "";
}
questionGroupName = questionGroupDetail.getTitle();
AuditLog auditLog = new AuditLog(entityId, EntityType.getEntityValue(source.toUpperCase()), modifierName, new DateTimeService().getCurrentJavaSqlDate(), (short) creatorId);
Set<AuditLogRecord> auditLogRecords = new HashSet<AuditLogRecord>();
for (int sectionPosition = 0; sectionPosition < questionGroupDetail.getSectionDetails().size(); sectionPosition++) {
SectionDetail sectionDetail = questionGroupDetail.getSectionDetails().get(sectionPosition);
sectionName = sectionDetail.getName();
for (int questionPosition = 0; questionPosition < sectionDetail.getQuestions().size(); questionPosition++) {
SectionQuestionDetail sectionQuestionDetail = sectionDetail.getQuestions().get(questionPosition);
fieldName = sectionQuestionDetail.getText();
fieldValue = sectionQuestionDetail.getAnswer();
String oldFieldValue = null;
for (SectionDetail oldSectionDetail : oldQuestionGroupDetail.getSectionDetails()) {
if (oldSectionDetail.getName().equals(sectionName)) {
for (SectionQuestionDetail oldSectionQuestionDetail : oldSectionDetail.getQuestions()) {
if (oldSectionQuestionDetail.getText().equals(fieldName)) {
oldFieldValue = oldSectionQuestionDetail.getAnswer();
break;
}
}
break;
}
}
if (!fieldValue.equals("")) {
if (oldFieldValue != null && !oldFieldValue.equals("")) {
if (!oldFieldValue.equals(fieldValue)) {
auditLogRecords.add(new AuditLogRecord(trimField(questionGroupName + "/" + sectionName + "/" + fieldName, 100), trimField(oldFieldValue, 200), trimField(fieldValue, 200), auditLog));
}
} else {
auditLogRecords.add(new AuditLogRecord(trimField(questionGroupName + "/" + sectionName + "/" + fieldName, 100), "-", trimField(fieldValue, 200), auditLog));
}
}
}
}
if (!auditLogRecords.isEmpty()) {
auditLog.addAuditLogRecords(auditLogRecords);
legacyAuditDao.save(auditLog);
}
}
}
use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class PersonnelBusinessServiceTest method testInvalidConnectionInGetOffice.
@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInGetOffice() throws PersistenceException {
try {
when(officePersistence.getOffice(id)).thenThrow(new PersistenceException("some exception"));
service.getOffice(id);
junit.framework.Assert.fail("should fail because of invalid session");
} catch (ServiceException e) {
}
}
Aggregations