Merge pull request #501 from johnw65/externalIds

mifosx-567 ensure duplicate externalId for staff and loan generate valid ...
This commit is contained in:
John Woodlock
2013-08-01 06:41:46 -07:00
2 changed files with 9 additions and 4 deletions
@@ -98,7 +98,7 @@ public class StaffWritePlatformServiceJpaRepositoryImpl implements StaffWritePla
}
if (!changesOnly.isEmpty()) {
this.staffRepository.save(staffForUpdate);
this.staffRepository.saveAndFlush(staffForUpdate);
}
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(staffId)
@@ -140,6 +140,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
@Override
public CommandProcessingResult submitApplication(final JsonCommand command) {
try {
final AppUser currentUser = context.authenticatedUser();
this.fromApiJsonDeserializer.validateForCreate(command.json());
@@ -201,8 +202,12 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
.withGroupId(newLoanApplication.getGroupId()) //
.withLoanId(newLoanApplication.getId()) //
.build();
} catch (DataIntegrityViolationException dve) {
handleDataIntegrityIssues(command, dve);
return CommandProcessingResult.empty();
}
}
@Transactional
@Override
public CommandProcessingResult modifyApplication(final Long loanId, final JsonCommand command) {
@@ -379,8 +384,8 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
logAsErrorUnexpectedDataIntegrityException(dve);
throw new PlatformDataIntegrityException("error.msg.unknown.data.integrity.issue", "Unknown data integrity issue with resource.");
}
}
private void logAsErrorUnexpectedDataIntegrityException(final DataIntegrityViolationException dve) {
logger.error(dve.getMessage(), dve);
}