FINERACT-1971: Loan re-aging foundational implementation

This commit is contained in:
Arnold Galovics
2024-02-20 15:43:49 +01:00
committed by Arnold Gálovics
parent 0d06e2bb2c
commit 4d4502fbe0
30 changed files with 1003 additions and 19 deletions
@@ -3656,6 +3656,22 @@ public class CommandWrapperBuilder {
return this;
}
public CommandWrapperBuilder reAge(final Long loanId) {
this.actionName = "REAGE";
this.entityName = "LOAN";
this.loanId = loanId;
this.href = "/loans/" + loanId + "/transactions?command=reAge";
return this;
}
public CommandWrapperBuilder undoReAge(final Long loanId) {
this.actionName = "UNDO_REAGE";
this.entityName = "LOAN";
this.loanId = loanId;
this.href = "/loans/" + loanId + "/transactions?command=undoReAge";
return this;
}
public CommandWrapperBuilder createDelinquencyAction(final Long loanId) {
this.actionName = "CREATE";
this.entityName = "DELINQUENCY_ACTION";
@@ -389,6 +389,19 @@ public final class JsonCommand {
return isChanged;
}
public <T extends Enum<T>> T enumValueOfParameterNamed(String parameterName, Class<T> enumType) {
try {
String value = stringValueOfParameterNamedAllowingNull(parameterName);
if (value != null) {
return Enum.valueOf(enumType, value);
} else {
return null;
}
} catch (IllegalArgumentException e) {
return null;
}
}
public String stringValueOfParameterNamed(final String parameterName) {
final String value = this.fromApiJsonHelper.extractStringNamed(parameterName, this.parsedCommand);
return StringUtils.defaultIfEmpty(value, "");
@@ -62,11 +62,9 @@ public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierSe
@Override
public void notifyPreBusinessEvent(BusinessEvent<?> businessEvent) {
throwExceptionIfBulkEvent(businessEvent);
List<BusinessEventListener> businessEventListeners = preListeners.get(businessEvent.getClass());
if (businessEventListeners != null) {
for (BusinessEventListener eventListener : businessEventListeners) {
eventListener.onBusinessEvent(businessEvent);
}
List<BusinessEventListener> businessEventListeners = findSuitableListeners(preListeners, businessEvent.getClass());
for (BusinessEventListener eventListener : businessEventListeners) {
eventListener.onBusinessEvent(businessEvent);
}
}
@@ -84,11 +82,9 @@ public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierSe
public void notifyPostBusinessEvent(BusinessEvent<?> businessEvent) {
throwExceptionIfBulkEvent(businessEvent);
boolean isExternalEvent = !(businessEvent instanceof NoExternalEvent);
List<BusinessEventListener> businessEventListeners = postListeners.get(businessEvent.getClass());
if (businessEventListeners != null) {
for (BusinessEventListener eventListener : businessEventListeners) {
eventListener.onBusinessEvent(businessEvent);
}
List<BusinessEventListener> businessEventListeners = findSuitableListeners(postListeners, businessEvent.getClass());
for (BusinessEventListener eventListener : businessEventListeners) {
eventListener.onBusinessEvent(businessEvent);
}
if (isExternalEvent && isExternalEventPostingEnabled()) {
// we only want to create external events for operations that were successful, hence the post listener
@@ -102,6 +98,17 @@ public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierSe
}
}
private List<BusinessEventListener> findSuitableListeners(Map<Class, List<BusinessEventListener>> listeners, Class<?> eventClazz) {
List<BusinessEventListener> result = new ArrayList<>();
for (Map.Entry<Class, List<BusinessEventListener>> entry : listeners.entrySet()) {
Class<?> registeredClazz = entry.getKey();
if (registeredClazz.isAssignableFrom(eventClazz)) {
result.addAll(entry.getValue());
}
}
return result;
}
@Override
public <T extends BusinessEvent<?>> void addPostBusinessEventListener(Class<T> eventType, BusinessEventListener<T> listener) {
List<BusinessEventListener> businessEventListeners = postListeners.get(eventType);