diff --git a/src/main/java/it/gov/pagopa/admissibility/drools/transformer/extra_filter/ExtraFilter2DroolsUtils.java b/src/main/java/it/gov/pagopa/admissibility/drools/transformer/extra_filter/ExtraFilter2DroolsUtils.java index 51ac56e5..d9695788 100644 --- a/src/main/java/it/gov/pagopa/admissibility/drools/transformer/extra_filter/ExtraFilter2DroolsUtils.java +++ b/src/main/java/it/gov/pagopa/admissibility/drools/transformer/extra_filter/ExtraFilter2DroolsUtils.java @@ -72,48 +72,49 @@ private static List buildExtraFilterFields(final Class claz final List out = new ArrayList<>(); final Set fieldsAdded = new HashSet<>(); - ReflectionUtils.doWithMethods(clazz, m -> checkIfGetter2AnalyzeAndRetrieveFieldInfo(m, path, castPath, class2subclass, path2ignore, maxDepth, out, fieldsAdded), + ReflectionUtils.doWithMethods(clazz, m -> checkIfGetter2AnalyzeAndRetrieveFieldInfo(m, class2subclass, path2ignore, maxDepth, out, fieldsAdded, + generateExtraFilterField(path, castPath)), m -> m.getParameterTypes().length == 0 && (m.getName().startsWith("get") || m.getName().startsWith("is"))); return out; } - private static void checkIfGetter2AnalyzeAndRetrieveFieldInfo(Method m, String path, Class castPath, Map, List>> class2subclass, Set path2ignore, int maxDepth, List out, Set fieldsAdded) { - Class fieldType = m.getReturnType(); - if (class2notAnalyze.stream().anyMatch(c -> c.isAssignableFrom(fieldType))) { + private static ExtraFilterField generateExtraFilterField(String path, Class castPath){ + ExtraFilterField eff = new ExtraFilterField(); + eff.setPath(path); + eff.setCastPath(castPath); + return eff; + } + + private static void checkIfGetter2AnalyzeAndRetrieveFieldInfo(Method m, Map, List>> class2subclass, Set path2ignore, int maxDepth, List out, Set fieldsAdded, ExtraFilterField eff) { + eff.setType(m.getReturnType()); + if (class2notAnalyze.stream().anyMatch(c -> c.isAssignableFrom(eff.getType()))) { return; } - String fieldName = StringUtils.uncapitalize(m.getName().replaceFirst("^(?:get|is)", "")); - String fullFieldName = path != null ? String.format("%s.%s", path, fieldName) : fieldName; - if (!Modifier.isStatic(m.getModifiers()) && !fieldsAdded.contains(fullFieldName) && (path2ignore == null || !path2ignore.contains(fullFieldName))) { - extractFieldInfo(path, castPath, class2subclass, path2ignore, maxDepth, out, fieldsAdded, fieldType, fieldName, fullFieldName); + eff.setName(StringUtils.uncapitalize(m.getName().replaceFirst("^(?:get|is)", ""))); + eff.setField(eff.getPath() != null ? String.format("%s.%s", eff.getPath(), eff.getName()) : eff.getName()); + if (!Modifier.isStatic(m.getModifiers()) && !fieldsAdded.contains(eff.getField()) && (path2ignore == null || !path2ignore.contains(eff.getField()))) { + extractFieldInfo(class2subclass, path2ignore, maxDepth, out, fieldsAdded, eff); } } - private static void extractFieldInfo(String path, Class castPath, Map, List>> class2subclass, Set path2ignore, int maxDepth, List out, Set fieldsAdded, Class fieldType, String fieldName, String fullFieldName) { - ExtraFilterField eff = new ExtraFilterField(); - eff.setPath(path); - eff.setName(fieldName); - eff.setField(fullFieldName); - eff.setType(fieldType); - eff.setCastPath(castPath); - + private static void extractFieldInfo(Map, List>> class2subclass, Set path2ignore, int maxDepth, List out, Set fieldsAdded, ExtraFilterField eff) { out.add(eff); - fieldsAdded.add(fullFieldName); + fieldsAdded.add(eff.getField()); - List> subclasses = class2subclass == null ? null : class2subclass.get(fieldType); + List> subclasses = class2subclass == null ? null : class2subclass.get(eff.getType()); if (!CollectionUtils.isEmpty(subclasses)) { eff.setToCast(true); eff.setSubclasses(subclasses); for (Class s : subclasses) { - if (fieldType.isAssignableFrom(s)) { - out.addAll(buildExtraFilterFields(s, String.format("%s(%s)%s", path == null ? "" : String.format("%s.", path), s.getName(), fieldName), s, class2subclass, path2ignore, maxDepth)); + if (eff.getType().isAssignableFrom(s)) { + out.addAll(buildExtraFilterFields(s, String.format("%s(%s)%s", eff.getPath() == null ? "" : String.format("%s.", eff.getPath()), s.getName(), eff.getName()), s, class2subclass, path2ignore, maxDepth)); } else { - throw new IllegalArgumentException(String.format("The configured class '%s' is not a subclass of '%s'", s.getName(), fieldType)); + throw new IllegalArgumentException(String.format("The configured class '%s' is not a subclass of '%s'", s.getName(), eff.getType())); } } - } else if (!fieldType.isPrimitive() && class2notExplore.stream().noneMatch(c -> c.isAssignableFrom(fieldType))) { - out.addAll(buildExtraFilterFields(fieldType, fullFieldName, null, class2subclass, path2ignore, maxDepth)); + } else if (!eff.getType().isPrimitive() && class2notExplore.stream().noneMatch(c -> c.isAssignableFrom(eff.getType()))) { + out.addAll(buildExtraFilterFields(eff.getType(), eff.getField(), null, class2subclass, path2ignore, maxDepth)); } } } diff --git a/src/main/java/it/gov/pagopa/admissibility/service/onboarding/check/OnboardingConsensusCheck.java b/src/main/java/it/gov/pagopa/admissibility/service/onboarding/check/OnboardingConsensusCheck.java index 864a3f8c..636f573a 100644 --- a/src/main/java/it/gov/pagopa/admissibility/service/onboarding/check/OnboardingConsensusCheck.java +++ b/src/main/java/it/gov/pagopa/admissibility/service/onboarding/check/OnboardingConsensusCheck.java @@ -37,24 +37,7 @@ private String checkConsensusErrors(OnboardingDTO onboardingRequest) { return OnboardingConstants.REJECTION_REASON_CONSENSUS_PDND_FAIL; } - /* - if (!CollectionUtils.isEmpty(onboardingRequest.getSelfDeclarationList())) { - return selfDeclarationListCheck(onboardingRequest.getSelfDeclarationList()); - } - */ - return null; - } - - //Handle multi and boolean criteria - /* - private String selfDeclarationListCheck(Map selfDeclarationList) { - for (Map.Entry selfDeclaration : selfDeclarationList.entrySet()) { - if (Boolean.FALSE.equals(selfDeclaration.getValue())) { - return String.format(OnboardingConstants.REJECTION_REASON_CONSENSUS_CHECK_SELF_DECLARATION_FAIL_FORMAT, selfDeclaration.getKey()); - } - } return null; } - */ } diff --git a/src/main/java/it/gov/pagopa/common/config/HealthIndicatorLogger.java b/src/main/java/it/gov/pagopa/common/config/HealthIndicatorLogger.java index df80a49f..78588ca6 100644 --- a/src/main/java/it/gov/pagopa/common/config/HealthIndicatorLogger.java +++ b/src/main/java/it/gov/pagopa/common/config/HealthIndicatorLogger.java @@ -1,7 +1,6 @@ package it.gov.pagopa.common.config; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.actuate.health.Status; @@ -13,8 +12,11 @@ @Service public class HealthIndicatorLogger implements HealthIndicator { - @Autowired - private List healthIndicatorList; + private final List healthIndicatorList; + + public HealthIndicatorLogger(List healthIndicatorList) { + this.healthIndicatorList = healthIndicatorList; + } @Override public Health health() {