FINERACT-2326: Refractor redundant and some deprecated code as per new Java 21 style

This commit is contained in:
Aman-Mittal
2025-12-08 13:49:44 +01:00
committed by Adam Saghy
parent 399789ba42
commit dce3c66def
29 changed files with 117 additions and 232 deletions
@@ -70,25 +70,14 @@ public enum ChargeCalculationType {
} }
public static ChargeCalculationType fromInt(final Integer chargeCalculation) { public static ChargeCalculationType fromInt(final Integer chargeCalculation) {
ChargeCalculationType chargeCalculationType = ChargeCalculationType.INVALID; return switch (chargeCalculation) {
switch (chargeCalculation) { case 1 -> FLAT;
case 1: case 2 -> PERCENT_OF_AMOUNT;
chargeCalculationType = FLAT; case 3 -> PERCENT_OF_AMOUNT_AND_INTEREST;
break; case 4 -> PERCENT_OF_INTEREST;
case 2: case 5 -> PERCENT_OF_DISBURSEMENT_AMOUNT;
chargeCalculationType = PERCENT_OF_AMOUNT; default -> INVALID;
break; };
case 3:
chargeCalculationType = PERCENT_OF_AMOUNT_AND_INTEREST;
break;
case 4:
chargeCalculationType = PERCENT_OF_INTEREST;
break;
case 5:
chargeCalculationType = PERCENT_OF_DISBURSEMENT_AMOUNT;
break;
}
return chargeCalculationType;
} }
public boolean isPercentageOfAmount() { public boolean isPercentageOfAmount() {
@@ -56,36 +56,21 @@ public final class FeignParts {
} }
String ext = fileName.substring(dotPos + 1).toLowerCase(); String ext = fileName.substring(dotPos + 1).toLowerCase();
switch (ext) { return switch (ext) {
case "jpg": case "jpg", "jpeg" -> "image/jpeg";
case "jpeg": case "png" -> "image/png";
return "image/jpeg"; case "tif", "tiff" -> "image/tiff";
case "png": case "gif" -> "image/gif";
return "image/png"; case "pdf" -> "application/pdf";
case "tif": case "docx" -> "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
case "tiff": case "doc" -> "application/msword";
return "image/tiff"; case "xlsx" -> "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
case "gif": case "xls" -> "application/vnd.ms-excel";
return "image/gif"; case "odt" -> "application/vnd.oasis.opendocument.text";
case "pdf": case "ods" -> "application/vnd.oasis.opendocument.spreadsheet";
return "application/pdf"; case "txt" -> "text/plain";
case "docx": default -> "application/octet-stream";
return "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; };
case "doc":
return "application/msword";
case "xlsx":
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
case "xls":
return "application/vnd.ms-excel";
case "odt":
return "application/vnd.oasis.opendocument.text";
case "ods":
return "application/vnd.oasis.opendocument.spreadsheet";
case "txt":
return "text/plain";
default:
return "application/octet-stream";
}
} }
/** /**
@@ -24,8 +24,8 @@ import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper; import jakarta.ws.rs.ext.ExceptionMapper;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.fineract.infrastructure.core.exception.ErrorHandler; import org.apache.fineract.infrastructure.core.exception.ErrorHandler;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -43,8 +43,9 @@ public class DefaultExceptionMapper implements FineractExceptionMapper, Exceptio
@Override @Override
public Response toResponse(RuntimeException exception) { public Response toResponse(RuntimeException exception) {
log.warn("Exception occurred", ErrorHandler.findMostSpecificException(exception)); log.warn("Exception occurred", ErrorHandler.findMostSpecificException(exception));
return Response.status(SC_INTERNAL_SERVER_ERROR) return Response.status(SC_INTERNAL_SERVER_ERROR)
.entity(Map.of("Exception", ObjectUtils.defaultIfNull(exception.getMessage(), "No error message available"))) .entity(Map.of("Exception", Objects.requireNonNullElse(exception.getMessage(), "No error message available")))
.type(MediaType.APPLICATION_JSON).build(); .type(MediaType.APPLICATION_JSON).build();
} }
} }
@@ -98,9 +98,8 @@ public class DataSourcePerTenantServiceFactory {
// https://github.com/brettwooldridge/HikariCP/wiki/MBean-(JMX)-Monitoring-and-Management // https://github.com/brettwooldridge/HikariCP/wiki/MBean-(JMX)-Monitoring-and-Management
config.setRegisterMbeans(true); config.setRegisterMbeans(true);
meterRegistry.ifPresent(registry -> { meterRegistry.ifPresent(registry -> config
config.setMetricsTrackerFactory(new TenantConnectionPoolMetricsTrackerFactory(tenant.getTenantIdentifier(), registry)); .setMetricsTrackerFactory(new TenantConnectionPoolMetricsTrackerFactory(tenant.getTenantIdentifier(), registry)));
});
// https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration // https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration
// These are the properties for each Tenant DB; the same configuration // These are the properties for each Tenant DB; the same configuration
@@ -59,15 +59,11 @@ public enum DaysInMonthType {
public static DaysInMonthType fromInt(final Integer type) { public static DaysInMonthType fromInt(final Integer type) {
DaysInMonthType repaymentFrequencyType = DaysInMonthType.INVALID; DaysInMonthType repaymentFrequencyType = DaysInMonthType.INVALID;
if (type != null) { if (type != null) {
switch (type) { repaymentFrequencyType = switch (type) {
case 1: case 1 -> DaysInMonthType.ACTUAL;
repaymentFrequencyType = DaysInMonthType.ACTUAL; case 30 -> DaysInMonthType.DAYS_30;
break; default -> repaymentFrequencyType;
case 30: };
repaymentFrequencyType = DaysInMonthType.DAYS_30;
break;
}
} }
return repaymentFrequencyType; return repaymentFrequencyType;
} }
@@ -63,20 +63,13 @@ public enum DaysInYearType {
public static DaysInYearType fromInt(final Integer type) { public static DaysInYearType fromInt(final Integer type) {
DaysInYearType repaymentFrequencyType = DaysInYearType.INVALID; DaysInYearType repaymentFrequencyType = DaysInYearType.INVALID;
if (type != null) { if (type != null) {
switch (type) { repaymentFrequencyType = switch (type) {
case 1: case 1 -> DaysInYearType.ACTUAL;
repaymentFrequencyType = DaysInYearType.ACTUAL; case 360 -> DaysInYearType.DAYS_360;
break; case 364 -> DaysInYearType.DAYS_364;
case 360: case 365 -> DaysInYearType.DAYS_365;
repaymentFrequencyType = DaysInYearType.DAYS_360; default -> repaymentFrequencyType;
break; };
case 364:
repaymentFrequencyType = DaysInYearType.DAYS_364;
break;
case 365:
repaymentFrequencyType = DaysInYearType.DAYS_365;
break;
}
} }
return repaymentFrequencyType; return repaymentFrequencyType;
} }
@@ -42,7 +42,7 @@ public class DelinquencyEffectivePauseHelperImpl implements DelinquencyEffective
.collect(Collectors.groupingBy(LoanDelinquencyAction::getAction)); .collect(Collectors.groupingBy(LoanDelinquencyAction::getAction));
List<LoanDelinquencyActionData> effective = new ArrayList<>(); List<LoanDelinquencyActionData> effective = new ArrayList<>();
List<LoanDelinquencyAction> pauses = partitioned.get(DelinquencyAction.PAUSE); List<LoanDelinquencyAction> pauses = partitioned.get(DelinquencyAction.PAUSE);
if (pauses != null && pauses.size() > 0) { if (pauses != null && !pauses.isEmpty()) {
for (LoanDelinquencyAction loanDelinquencyAction : pauses) { for (LoanDelinquencyAction loanDelinquencyAction : pauses) {
Optional<LoanDelinquencyAction> resume = findMatchingResume(loanDelinquencyAction, partitioned.get(RESUME)); Optional<LoanDelinquencyAction> resume = findMatchingResume(loanDelinquencyAction, partitioned.get(RESUME));
LoanDelinquencyActionData loanDelinquencyActionData = new LoanDelinquencyActionData(loanDelinquencyAction); LoanDelinquencyActionData loanDelinquencyActionData = new LoanDelinquencyActionData(loanDelinquencyAction);
@@ -91,7 +91,7 @@ public class DelinquencyEffectivePauseHelperImpl implements DelinquencyEffective
} }
private Optional<LoanDelinquencyAction> findMatchingResume(LoanDelinquencyAction pause, List<LoanDelinquencyAction> resumes) { private Optional<LoanDelinquencyAction> findMatchingResume(LoanDelinquencyAction pause, List<LoanDelinquencyAction> resumes) {
if (resumes != null && resumes.size() > 0) { if (resumes != null && !resumes.isEmpty()) {
for (LoanDelinquencyAction resume : resumes) { for (LoanDelinquencyAction resume : resumes) {
if (!pause.getStartDate().isAfter(resume.getStartDate()) && !resume.getStartDate().isAfter(pause.getEndDate())) { if (!pause.getStartDate().isAfter(resume.getStartDate()) && !resume.getStartDate().isAfter(pause.getEndDate())) {
return Optional.of(resume); return Optional.of(resume);
@@ -337,11 +337,9 @@ public class DelinquencyReadPlatformServiceImpl implements DelinquencyReadPlatfo
isCurrentDateBeforeInstallmentAndLoanPeriod = DateUtils.isEqual(currentBusinessDate, installment.getDueDate()) isCurrentDateBeforeInstallmentAndLoanPeriod = DateUtils.isEqual(currentBusinessDate, installment.getDueDate())
&& DateUtils.isBefore(currentBusinessDate, expectedMaturityDate); && DateUtils.isBefore(currentBusinessDate, expectedMaturityDate);
} }
if (isCurrentDateBeforeInstallmentAndLoanPeriod) { if (isCurrentDateBeforeInstallmentAndLoanPeriod && installment.isNotFullyPaidOff()) {
if (installment.isNotFullyPaidOff()) { nextUnpaidInstallmentDate = installment.getDueDate();
nextUnpaidInstallmentDate = installment.getDueDate(); break;
break;
}
} }
} }
return nextUnpaidInstallmentDate; return nextUnpaidInstallmentDate;
@@ -127,7 +127,7 @@ public class DelinquencyWritePlatformServiceHelper {
changes.put("current", loanDelinquencyTag.getDelinquencyRange()); changes.put("current", loanDelinquencyTag.getDelinquencyRange());
} }
} }
if (loanDelinquencyTagHistory.size() > 0) { if (!loanDelinquencyTagHistory.isEmpty()) {
this.loanDelinquencyTagRepository.saveAllAndFlush(loanDelinquencyTagHistory); this.loanDelinquencyTagRepository.saveAllAndFlush(loanDelinquencyTagHistory);
// if installment level delinquency is enabled event will be raised at installment level calculation, no // if installment level delinquency is enabled event will be raised at installment level calculation, no
// need to raise the event here // need to raise the event here
@@ -173,10 +173,10 @@ public class DelinquencyWritePlatformServiceHelper {
private void removeDelinquencyTagsForNonExistingInstallments(Long loanId) { private void removeDelinquencyTagsForNonExistingInstallments(Long loanId) {
List<LoanInstallmentDelinquencyTag> currentLoanInstallmentDelinquencyTags = loanInstallmentDelinquencyTagRepository List<LoanInstallmentDelinquencyTag> currentLoanInstallmentDelinquencyTags = loanInstallmentDelinquencyTagRepository
.findByLoanId(loanId); .findByLoanId(loanId);
if (currentLoanInstallmentDelinquencyTags != null && currentLoanInstallmentDelinquencyTags.size() > 0) { if (currentLoanInstallmentDelinquencyTags != null && !currentLoanInstallmentDelinquencyTags.isEmpty()) {
List<Long> loanInstallmentTagsForDelete = currentLoanInstallmentDelinquencyTags.stream() List<Long> loanInstallmentTagsForDelete = currentLoanInstallmentDelinquencyTags.stream()
.filter(tag -> tag.getInstallment() == null).map(tag -> tag.getId()).toList(); .filter(tag -> tag.getInstallment() == null).map(tag -> tag.getId()).toList();
if (loanInstallmentTagsForDelete.size() > 0) { if (!loanInstallmentTagsForDelete.isEmpty()) {
loanInstallmentDelinquencyTagRepository.deleteAllLoanInstallmentsTagsByIds(loanInstallmentTagsForDelete); loanInstallmentDelinquencyTagRepository.deleteAllLoanInstallmentsTagsByIds(loanInstallmentTagsForDelete);
} }
} }
@@ -260,7 +260,7 @@ public class DelinquencyWritePlatformServiceHelper {
} }
if (installmentDelinquencyTags.size() > 0) { if (!installmentDelinquencyTags.isEmpty()) {
loanInstallmentDelinquencyTagRepository.saveAllAndFlush(installmentDelinquencyTags); loanInstallmentDelinquencyTagRepository.saveAllAndFlush(installmentDelinquencyTags);
} }
return isDelinquencyRangeChanged; return isDelinquencyRangeChanged;
@@ -291,7 +291,7 @@ public class DelinquencyWritePlatformServiceImpl implements DelinquencyWritePlat
@Override @Override
public void cleanLoanDelinquencyTags(Loan loan) { public void cleanLoanDelinquencyTags(Loan loan) {
List<LoanDelinquencyTagHistory> loanDelinquencyTags = this.loanDelinquencyTagRepository.findByLoan(loan); List<LoanDelinquencyTagHistory> loanDelinquencyTags = this.loanDelinquencyTagRepository.findByLoan(loan);
if (loanDelinquencyTags != null && loanDelinquencyTags.size() > 0) { if (loanDelinquencyTags != null && !loanDelinquencyTags.isEmpty()) {
this.loanDelinquencyTagRepository.deleteAll(loanDelinquencyTags); this.loanDelinquencyTagRepository.deleteAll(loanDelinquencyTags);
} }
} }
@@ -362,9 +362,7 @@ public class DelinquencyWritePlatformServiceImpl implements DelinquencyWritePlat
private void setDelinquencyBucketMappings(DelinquencyBucket delinquencyBucket, DelinquencyBucketData data) { private void setDelinquencyBucketMappings(DelinquencyBucket delinquencyBucket, DelinquencyBucketData data) {
List<Long> rangeIds = new ArrayList<>(); List<Long> rangeIds = new ArrayList<>();
data.getRanges().forEach(dataRange -> { data.getRanges().forEach(dataRange -> rangeIds.add(dataRange.getId()));
rangeIds.add(dataRange.getId());
});
List<DelinquencyRange> ranges = repositoryRange.findAllById(rangeIds); List<DelinquencyRange> ranges = repositoryRange.findAllById(rangeIds);
validateDelinquencyRanges(ranges); validateDelinquencyRanges(ranges);
@@ -383,11 +381,9 @@ public class DelinquencyWritePlatformServiceImpl implements DelinquencyWritePlat
DelinquencyRange prevDelinquencyRange = null; DelinquencyRange prevDelinquencyRange = null;
for (DelinquencyRange delinquencyRange : ranges) { for (DelinquencyRange delinquencyRange : ranges) {
if (prevDelinquencyRange != null) { if (prevDelinquencyRange != null && isOverlapped(prevDelinquencyRange, delinquencyRange)) {
if (isOverlapped(prevDelinquencyRange, delinquencyRange)) { final String errorMessage = "The delinquency ranges age days values are overlaped";
final String errorMessage = "The delinquency ranges age days values are overlaped"; throw new DelinquencyBucketAgesOverlapedException(errorMessage, prevDelinquencyRange, delinquencyRange);
throw new DelinquencyBucketAgesOverlapedException(errorMessage, prevDelinquencyRange, delinquencyRange);
}
} }
prevDelinquencyRange = delinquencyRange; prevDelinquencyRange = delinquencyRange;
} }
@@ -153,7 +153,7 @@ public class DefaultLoanLifecycleStateMachine implements LoanLifecycleStateMachi
} }
break; break;
case LOAN_CHARGE_PAYMENT: case LOAN_CHARGE_PAYMENT:
case LOAN_REPAYMENT_OR_WAIVER: case LOAN_REPAYMENT_OR_WAIVER, LOAN_CHARGEBACK:
if (anyOfAllowedWhenComingFrom(from, LoanStatus.CLOSED_OBLIGATIONS_MET, LoanStatus.OVERPAID)) { if (anyOfAllowedWhenComingFrom(from, LoanStatus.CLOSED_OBLIGATIONS_MET, LoanStatus.OVERPAID)) {
newState = activeTransition(); newState = activeTransition();
} }
@@ -217,11 +217,6 @@ public class DefaultLoanLifecycleStateMachine implements LoanLifecycleStateMachi
newState = activeTransition(); newState = activeTransition();
} }
break; break;
case LOAN_CHARGEBACK:
if (anyOfAllowedWhenComingFrom(from, LoanStatus.CLOSED_OBLIGATIONS_MET, LoanStatus.OVERPAID)) {
newState = activeTransition();
}
break;
case LOAN_CHARGE_ADJUSTMENT: case LOAN_CHARGE_ADJUSTMENT:
if (from.hasStateOf(LoanStatus.CLOSED_OBLIGATIONS_MET)) { if (from.hasStateOf(LoanStatus.CLOSED_OBLIGATIONS_MET)) {
newState = overpaidTransition(); newState = overpaidTransition();
@@ -86,7 +86,7 @@ public class CreditAllocationsValidator {
} }
private boolean hasLoanProductCreditAllocationRule(List<LoanProductCreditAllocationRule> rules) { private boolean hasLoanProductCreditAllocationRule(List<LoanProductCreditAllocationRule> rules) {
return rules != null && rules.size() > 0; return rules != null && !rules.isEmpty();
} }
private void raiseValidationError(String globalisationMessageCode, String msg) { private void raiseValidationError(String globalisationMessageCode, String msg) {
@@ -94,9 +94,7 @@ public class CreditAllocationsJsonParserTest {
private static List<Pair<Integer, AllocationType>> createAllocationTypeList() { private static List<Pair<Integer, AllocationType>> createAllocationTypeList() {
AtomicInteger i = new AtomicInteger(1); AtomicInteger i = new AtomicInteger(1);
List<Pair<Integer, AllocationType>> list = EnumSet.allOf(AllocationType.class).stream().map(p -> Pair.of(i.getAndIncrement(), p)) return EnumSet.allOf(AllocationType.class).stream().map(p -> Pair.of(i.getAndIncrement(), p)).toList();
.toList();
return list;
} }
public Map<String, Object> createCreditAllocationEntry(String transactionType, List<String> orderedRules) { public Map<String, Object> createCreditAllocationEntry(String transactionType, List<String> orderedRules) {
@@ -117,9 +115,8 @@ public class CreditAllocationsJsonParserTest {
private JsonCommand createJsonCommand(Map<String, Object> jsonMap) throws JsonProcessingException { private JsonCommand createJsonCommand(Map<String, Object> jsonMap) throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonMap); String json = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonMap);
JsonCommand command = JsonCommand.from(json, JsonParser.parseString(json), fromJsonHelper, null, 1L, 2L, 3L, 4L, null, null, null, return JsonCommand.from(json, JsonParser.parseString(json), fromJsonHelper, null, 1L, 2L, 3L, 4L, null, null, null, null, null,
null, null, null, null, null, null); null, null, null, null);
return command;
} }
} }
@@ -68,8 +68,7 @@ public enum EntityAccountType {
} }
public static EntityAccountType fromInt(final int i) { public static EntityAccountType fromInt(final int i) {
final EntityAccountType type = intToEnumMap.get(Integer.valueOf(i)); return intToEnumMap.get(i);
return type;
} }
public static int getMinValue() { public static int getMinValue() {
@@ -82,7 +81,7 @@ public enum EntityAccountType {
@Override @Override
public String toString() { public String toString() {
return name().toString(); return name();
} }
public boolean isClientAccount() { public boolean isClientAccount() {
@@ -94,9 +94,7 @@ public final class EmailConfigurationValidator {
public boolean isValidEmail(String email) { public boolean isValidEmail(String email) {
// this is the easiest check // this is the easiest check
if (email == null) { if (email == null || email.endsWith(".")) {
return false;
} else if (email.endsWith(".")) {
return false; return false;
} }
@@ -104,10 +102,6 @@ public final class EmailConfigurationValidator {
Matcher emailMatcher = EMAIL_PATTERN.matcher(email); Matcher emailMatcher = EMAIL_PATTERN.matcher(email);
// check if the Matcher matches the email pattern // check if the Matcher matches the email pattern
if (!emailMatcher.matches()) { return emailMatcher.matches();
return false;
}
return true;
} }
} }
@@ -262,11 +262,7 @@ public final class EmailDataValidator {
Matcher emailMatcher = EMAIL_PATTERN.matcher(email); Matcher emailMatcher = EMAIL_PATTERN.matcher(email);
// check if the Matcher matches the email pattern // check if the Matcher matches the email pattern
if (!emailMatcher.matches()) { return emailMatcher.matches();
return false;
}
return true;
} }
/** /**
@@ -36,17 +36,12 @@ public enum EmailCampaignStatus {
public static EmailCampaignStatus fromInt(final Integer statusValue) { public static EmailCampaignStatus fromInt(final Integer statusValue) {
EmailCampaignStatus enumeration = EmailCampaignStatus.INVALID; EmailCampaignStatus enumeration = EmailCampaignStatus.INVALID;
switch (statusValue) { enumeration = switch (statusValue) {
case 100: case 100 -> EmailCampaignStatus.PENDING;
enumeration = EmailCampaignStatus.PENDING; case 300 -> EmailCampaignStatus.ACTIVE;
break; case 600 -> EmailCampaignStatus.CLOSED;
case 300: default -> enumeration;
enumeration = EmailCampaignStatus.ACTIVE; };
break;
case 600:
enumeration = EmailCampaignStatus.CLOSED;
break;
}
return enumeration; return enumeration;
} }
@@ -41,19 +41,12 @@ public enum EmailCampaignType {
} }
public static EmailCampaignType fromInt(final Integer typeValue) { public static EmailCampaignType fromInt(final Integer typeValue) {
EmailCampaignType type = null; return switch (typeValue) {
switch (typeValue) { case 1 -> DIRECT;
case 1: case 2 -> SCHEDULE;
type = DIRECT; case 3 -> TRIGGERED;
break; default -> null;
case 2: };
type = SCHEDULE;
break;
case 3:
type = TRIGGERED;
break;
}
return type;
} }
public boolean isDirect() { public boolean isDirect() {
@@ -32,20 +32,13 @@ public enum EmailMessageStatusType {
public static EmailMessageStatusType fromInt(final Integer statusValue) { public static EmailMessageStatusType fromInt(final Integer statusValue) {
EmailMessageStatusType enumeration = EmailMessageStatusType.INVALID; EmailMessageStatusType enumeration = EmailMessageStatusType.INVALID;
switch (statusValue) { enumeration = switch (statusValue) {
case 100: case 100 -> EmailMessageStatusType.PENDING;
enumeration = EmailMessageStatusType.PENDING; case 200 -> EmailMessageStatusType.SENT;
break; case 300 -> EmailMessageStatusType.DELIVERED;
case 200: case 400 -> EmailMessageStatusType.FAILED;
enumeration = EmailMessageStatusType.SENT; default -> enumeration;
break; };
case 300:
enumeration = EmailMessageStatusType.DELIVERED;
break;
case 400:
enumeration = EmailMessageStatusType.FAILED;
break;
}
return enumeration; return enumeration;
} }
@@ -117,8 +117,6 @@ public class EmailCampaignDomainServiceImpl implements EmailCampaignDomainServic
} }
private List<EmailCampaign> retrieveEmailCampaigns(String paramValue) { private List<EmailCampaign> retrieveEmailCampaigns(String paramValue) {
List<EmailCampaign> emailCampaigns = emailCampaignRepository.findActiveEmailCampaigns("%" + paramValue + "%", return emailCampaignRepository.findActiveEmailCampaigns("%" + paramValue + "%", SmsCampaignTriggerType.TRIGGERED.getValue());
SmsCampaignTriggerType.TRIGGERED.getValue());
return emailCampaigns;
} }
} }
@@ -62,7 +62,7 @@ public final class EmailMessageJobEmailServiceImpl implements EmailMessageJobEma
mimeMessageHelper.setText(emailMessageWithAttachmentData.getText(), true); mimeMessageHelper.setText(emailMessageWithAttachmentData.getText(), true);
mimeMessageHelper.setSubject(emailMessageWithAttachmentData.getSubject()); mimeMessageHelper.setSubject(emailMessageWithAttachmentData.getSubject());
final List<File> attachments = emailMessageWithAttachmentData.getAttachments(); final List<File> attachments = emailMessageWithAttachmentData.getAttachments();
if (attachments != null && attachments.size() > 0) { if (attachments != null && !attachments.isEmpty()) {
for (final File attachment : attachments) { for (final File attachment : attachments) {
if (attachment != null) { if (attachment != null) {
mimeMessageHelper.addAttachment(attachment.getName(), attachment); mimeMessageHelper.addAttachment(attachment.getName(), attachment);
@@ -36,7 +36,7 @@ public class DeleteDatatableCommandHandler implements NewCommandSourceHandler {
@Transactional @Transactional
@Override @Override
public CommandProcessingResult processCommand(final JsonCommand command) { public CommandProcessingResult processCommand(final JsonCommand command) {
final String datatableName = command.getUrl().replaceAll("/datatables/", ""); final String datatableName = command.getUrl().replace("/datatables/", "");
datatableWriteService.deleteDatatable(datatableName); datatableWriteService.deleteDatatable(datatableName);
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withResourceIdAsString(datatableName).build(); return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withResourceIdAsString(datatableName).build();
} }
@@ -121,10 +121,10 @@ public class EntityDatatableChecksReadPlatformServiceImpl implements EntityDatat
tableRequiredBeforeAction = this.entityDatatableChecksRepository.findByEntityStatusAndProduct(entity, status, productId); tableRequiredBeforeAction = this.entityDatatableChecksRepository.findByEntityStatusAndProduct(entity, status, productId);
} }
if (tableRequiredBeforeAction == null || tableRequiredBeforeAction.size() < 1) { if (tableRequiredBeforeAction == null || tableRequiredBeforeAction.isEmpty()) {
tableRequiredBeforeAction = this.entityDatatableChecksRepository.findByEntityStatusAndNoProduct(entity, status); tableRequiredBeforeAction = this.entityDatatableChecksRepository.findByEntityStatusAndNoProduct(entity, status);
} }
if (tableRequiredBeforeAction != null && tableRequiredBeforeAction.size() > 0) { if (tableRequiredBeforeAction != null && !tableRequiredBeforeAction.isEmpty()) {
List<DatatableData> ret = new ArrayList<>(); List<DatatableData> ret = new ArrayList<>();
for (EntityDatatableChecks t : tableRequiredBeforeAction) { for (EntityDatatableChecks t : tableRequiredBeforeAction) {
ret.add(this.datatableReadService.retrieveDatatable(t.getDatatableName())); ret.add(this.datatableReadService.retrieveDatatable(t.getDatatableName()));
@@ -37,34 +37,28 @@ public class DropdownReadPlatformServiceImpl implements DropdownReadPlatformServ
@Override @Override
public List<EnumOptionData> retrievePeriodFrequencyTypeOptions() { public List<EnumOptionData> retrievePeriodFrequencyTypeOptions() {
final List<EnumOptionData> loanTermFrequencyOptions = Arrays.asList(termFrequencyType(PeriodFrequencyType.DAYS, "frequency"), return Arrays.asList(termFrequencyType(PeriodFrequencyType.DAYS, "frequency"),
termFrequencyType(PeriodFrequencyType.WEEKS, "frequency"), termFrequencyType(PeriodFrequencyType.MONTHS, "frequency"), termFrequencyType(PeriodFrequencyType.WEEKS, "frequency"), termFrequencyType(PeriodFrequencyType.MONTHS, "frequency"),
termFrequencyType(PeriodFrequencyType.YEARS, "frequency"), termFrequencyType(PeriodFrequencyType.WHOLE_TERM, "frequency")); termFrequencyType(PeriodFrequencyType.YEARS, "frequency"), termFrequencyType(PeriodFrequencyType.WHOLE_TERM, "frequency"));
return loanTermFrequencyOptions;
} }
@Override @Override
public List<EnumOptionData> retrieveConditionTypeOptions() { public List<EnumOptionData> retrieveConditionTypeOptions() {
final List<EnumOptionData> loanTermFrequencyOptions = Arrays.asList(conditionType(ConditionType.EQUAL, "condition"), return Arrays.asList(conditionType(ConditionType.EQUAL, "condition"), conditionType(ConditionType.NOT_EQUAL, "condition"),
conditionType(ConditionType.NOT_EQUAL, "condition"), conditionType(ConditionType.GRETERTHAN, "condition"), conditionType(ConditionType.GRETERTHAN, "condition"), conditionType(ConditionType.LESSTHAN, "condition"));
conditionType(ConditionType.LESSTHAN, "condition"));
return loanTermFrequencyOptions;
} }
@Override @Override
public List<EnumOptionData> retrieveDaysInMonthTypeOptions() { public List<EnumOptionData> retrieveDaysInMonthTypeOptions() {
final List<EnumOptionData> daysInMonthTypeOptions = Arrays.asList(daysInMonthType(DaysInMonthType.ACTUAL), return Arrays.asList(daysInMonthType(DaysInMonthType.ACTUAL), daysInMonthType(DaysInMonthType.DAYS_30));
daysInMonthType(DaysInMonthType.DAYS_30));
return daysInMonthTypeOptions;
} }
@Override @Override
public List<EnumOptionData> retrieveDaysInYearTypeOptions() { public List<EnumOptionData> retrieveDaysInYearTypeOptions() {
final List<EnumOptionData> daysInYearTypeOptions = Arrays.asList(daysInYearType(DaysInYearType.ACTUAL), return Arrays.asList(daysInYearType(DaysInYearType.ACTUAL), daysInYearType(DaysInYearType.DAYS_360),
daysInYearType(DaysInYearType.DAYS_360), daysInYearType(DaysInYearType.DAYS_364), daysInYearType(DaysInYearType.DAYS_365)); daysInYearType(DaysInYearType.DAYS_364), daysInYearType(DaysInYearType.DAYS_365));
return daysInYearTypeOptions;
} }
} }
@@ -440,9 +440,7 @@ public class DepositAccountAssembler {
final DepositRecurringDetail depositRecurringDetail = DepositRecurringDetail.createFrom(isMandatoryDeposit, allowWithdrawal, final DepositRecurringDetail depositRecurringDetail = DepositRecurringDetail.createFrom(isMandatoryDeposit, allowWithdrawal,
adjustAdvanceTowardsFuturePayments); adjustAdvanceTowardsFuturePayments);
final DepositAccountRecurringDetail depositAccountRecurringDetail = DepositAccountRecurringDetail.createNew(recurringDepositAmount, return DepositAccountRecurringDetail.createNew(recurringDepositAmount, depositRecurringDetail, null, isCalendarInherited);
depositRecurringDetail, null, isCalendarInherited);
return depositAccountRecurringDetail;
} }
public Collection<SavingsAccountTransactionDTO> assembleBulkMandatorySavingsAccountTransactionDTOs(final JsonCommand command, public Collection<SavingsAccountTransactionDTO> assembleBulkMandatorySavingsAccountTransactionDTOs(final JsonCommand command,
@@ -747,16 +747,12 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
private void checkClientOrGroupActive(final SavingsAccount account) { private void checkClientOrGroupActive(final SavingsAccount account) {
final Client client = account.getClient(); final Client client = account.getClient();
if (client != null) { if (client != null && client.isNotActive()) {
if (client.isNotActive()) { throw new ClientNotActiveException(client.getId());
throw new ClientNotActiveException(client.getId());
}
} }
final Group group = account.group(); final Group group = account.group();
if (group != null) { if (group != null && group.isNotActive()) {
if (group.isNotActive()) { throw new GroupNotActiveException(group.getId());
throw new GroupNotActiveException(group.getId());
}
} }
} }
@@ -729,19 +729,17 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
private void checkClientOrGroupActive(final SavingsAccount account) { private void checkClientOrGroupActive(final SavingsAccount account) {
final Client client = account.getClient(); final Client client = account.getClient();
if (client != null) { if (client != null && client.isNotActive()) {
if (client.isNotActive()) { throw new ClientNotActiveException(client.getId());
throw new ClientNotActiveException(client.getId());
}
} }
final Group group = account.group(); final Group group = account.group();
if (group != null) { if (group != null && group.isNotActive()) {
if (group.isNotActive()) { if (group.isCenter()) {
if (group.isCenter()) { throw new CenterNotActiveException(group.getId());
throw new CenterNotActiveException(group.getId());
}
throw new GroupNotActiveException(group.getId());
} }
throw new GroupNotActiveException(group.getId());
} }
} }
} }
@@ -67,8 +67,7 @@ public class DeviceRegistrationApiResource {
Long clientId = json.get(DeviceRegistrationApiConstants.clientIdParamName).getAsLong(); Long clientId = json.get(DeviceRegistrationApiConstants.clientIdParamName).getAsLong();
String registrationId = json.get(DeviceRegistrationApiConstants.registrationIdParamName).getAsString(); String registrationId = json.get(DeviceRegistrationApiConstants.registrationIdParamName).getAsString();
DeviceRegistration deviceRegistration = this.deviceRegistrationWritePlatformService.registerDevice(clientId, registrationId); DeviceRegistration deviceRegistration = this.deviceRegistrationWritePlatformService.registerDevice(clientId, registrationId);
String response = gson.toJson(deviceRegistration.getId()); return gson.toJson(deviceRegistration.getId());
return response;
} }
@GET @GET
@@ -125,8 +124,7 @@ public class DeviceRegistrationApiResource {
String registrationId = json.get(DeviceRegistrationApiConstants.registrationIdParamName).getAsString(); String registrationId = json.get(DeviceRegistrationApiConstants.registrationIdParamName).getAsString();
DeviceRegistration deviceRegistration = this.deviceRegistrationWritePlatformService.updateDeviceRegistration(id, clientId, DeviceRegistration deviceRegistration = this.deviceRegistrationWritePlatformService.updateDeviceRegistration(id, clientId,
registrationId); registrationId);
String response = gson.toJson(deviceRegistration.getId()); return gson.toJson(deviceRegistration.getId());
return response;
} }
@DELETE @DELETE
@@ -299,10 +299,7 @@ public class DepositProductAssembler {
} }
} }
DepositPreClosureDetail preClosureDetail = DepositPreClosureDetail.createFrom(preClosurePenalApplicable, preClosurePenalInterest, return DepositPreClosureDetail.createFrom(preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestType);
preClosurePenalInterestType);
return preClosureDetail;
} }
public DepositPreClosureDetail assemblePreClosureDetail(final JsonCommand command, DepositPreClosureDetail produPreClosureDetail) { public DepositPreClosureDetail assemblePreClosureDetail(final JsonCommand command, DepositPreClosureDetail produPreClosureDetail) {
@@ -334,10 +331,7 @@ public class DepositProductAssembler {
preClosurePenalInterestType = preClosurePenalInterestOnTypeId == null ? null preClosurePenalInterestType = preClosurePenalInterestOnTypeId == null ? null
: PreClosurePenalInterestOnType.fromInt(preClosurePenalInterestOnTypeId); : PreClosurePenalInterestOnType.fromInt(preClosurePenalInterestOnTypeId);
DepositPreClosureDetail preClosureDetail1 = DepositPreClosureDetail.createFrom(preClosurePenalApplicable, preClosurePenalInterest, return DepositPreClosureDetail.createFrom(preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestType);
preClosurePenalInterestType);
return preClosureDetail1;
} }
public DepositTermDetail assembleDepositTermDetail(final JsonCommand command) { public DepositTermDetail assembleDepositTermDetail(final JsonCommand command) {
@@ -355,10 +349,8 @@ public class DepositProductAssembler {
final SavingsPeriodFrequencyType inMultiplesOfDepositTermType = (inMultiplesOfDepositTermTypeId == null) ? null final SavingsPeriodFrequencyType inMultiplesOfDepositTermType = (inMultiplesOfDepositTermTypeId == null) ? null
: SavingsPeriodFrequencyType.fromInt(inMultiplesOfDepositTermTypeId); : SavingsPeriodFrequencyType.fromInt(inMultiplesOfDepositTermTypeId);
final DepositTermDetail depositTermDetail = DepositTermDetail.createFrom(minDepositTerm, maxDepositTerm, minDepositTermType, return DepositTermDetail.createFrom(minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType,
maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType); inMultiplesOfDepositTerm, inMultiplesOfDepositTermType);
return depositTermDetail;
} }
public DepositTermDetail assembleDepositTermDetail(final JsonCommand command, final DepositTermDetail prodDepositTermDetail) { public DepositTermDetail assembleDepositTermDetail(final JsonCommand command, final DepositTermDetail prodDepositTermDetail) {
@@ -415,10 +407,8 @@ public class DepositProductAssembler {
final SavingsPeriodFrequencyType inMultiplesOfDepositTermType = (inMultiplesOfDepositTermTypeId == null) ? null final SavingsPeriodFrequencyType inMultiplesOfDepositTermType = (inMultiplesOfDepositTermTypeId == null) ? null
: SavingsPeriodFrequencyType.fromInt(inMultiplesOfDepositTermTypeId); : SavingsPeriodFrequencyType.fromInt(inMultiplesOfDepositTermTypeId);
final DepositTermDetail depositTermDetail = DepositTermDetail.createFrom(minDepositTerm, maxDepositTerm, minDepositTermType, return DepositTermDetail.createFrom(minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType,
maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType); inMultiplesOfDepositTerm, inMultiplesOfDepositTermType);
return depositTermDetail;
} }
public DepositRecurringDetail assembleRecurringDetail(final JsonCommand command) { public DepositRecurringDetail assembleRecurringDetail(final JsonCommand command) {
@@ -438,10 +428,7 @@ public class DepositProductAssembler {
adjustAdvanceTowardsFuturePayments = false; adjustAdvanceTowardsFuturePayments = false;
} }
final DepositRecurringDetail depositRecurringDetail = DepositRecurringDetail.createFrom(isMandatoryDeposit, allowWithdrawal, return DepositRecurringDetail.createFrom(isMandatoryDeposit, allowWithdrawal, adjustAdvanceTowardsFuturePayments);
adjustAdvanceTowardsFuturePayments);
return depositRecurringDetail;
} }
public Set<Charge> assembleListOfSavingsProductCharges(final JsonCommand command, final String savingsProductCurrencyCode) { public Set<Charge> assembleListOfSavingsProductCharges(final JsonCommand command, final String savingsProductCurrencyCode) {
@@ -510,10 +497,7 @@ public class DepositProductAssembler {
depositAmount = command.bigDecimalValueOfParameterNamed(depositAmountParamName); depositAmount = command.bigDecimalValueOfParameterNamed(depositAmountParamName);
} }
final DepositProductAmountDetails depositRecurringDetail = new DepositProductAmountDetails(minDepositAmount, depositAmount, return new DepositProductAmountDetails(minDepositAmount, depositAmount, maxDepositAmount);
maxDepositAmount);
return depositRecurringDetail;
} }
public TaxGroup assembleTaxGroup(final JsonCommand command) { public TaxGroup assembleTaxGroup(final JsonCommand command) {