}
private Note getNoteForDelete(final JsonCommand command) {
final String resourceUrl = getResourceUrlFromCommand(command);// command.getSupportedEntityType();
final Long noteId = command.entityId();
final NoteType type = NoteType.fromApiUrl(resourceUrl);
Long resourceId = null;
Note noteForUpdate = null;
switch (type) {
case CLIENT: {
resourceId = command.getClientId();
noteForUpdate = this.noteRepository.findByClientIdAndId(resourceId, noteId);
}
break;
case GROUP: {
resourceId = command.getGroupId();
noteForUpdate = this.noteRepository.findByGroupIdAndId(resourceId, noteId);
}
break;
case LOAN: {
resourceId = command.getLoanId();
noteForUpdate = this.noteRepository.findByLoanIdAndId(resourceId, noteId);
}
break;
case LOAN_TRANSACTION: {
resourceId = command.subentityId();
noteForUpdate = this.noteRepository.findByLoanTransactionIdAndId(resourceId, noteId);
}
break;
// case SAVING_ACCOUNT: {
// noteForUpdate =
// this.noteRepository.findBySavingAccountIdAndId(resourceId,
// noteId);
// }
// break;
case SAVING_ACCOUNT:
break;
}
if (noteForUpdate == null) { throw new NoteNotFoundException(noteId, resourceId, type.name().toLowerCase()); }
return noteForUpdate;
}