Skip to content

Commit

Permalink
PAGOPA-1778 aggregating duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
FedericoRuzzier committed May 29, 2024
1 parent a33328b commit c542b1f
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ private Iterable<ValidBundle> findValidBundlesMulti(PaymentOptionMulti paymentOp
}

// add filter for PSP blacklist
if (!CollectionUtils.isEmpty(pspBlacklist)) {
var pspNotIn = notIn(ID_PSP_PARAM, pspBlacklist);
queryResult = and(queryResult, pspNotIn);
}
queryResult = blackListCriteria(queryResult);

// execute the query
return cosmosTemplate.find(new CosmosQuery(queryResult), ValidBundle.class, "validbundles");
Expand Down Expand Up @@ -250,10 +247,7 @@ private Iterable<ValidBundle> findValidBundles(PaymentOption paymentOption, bool
}

// add filter for PSP blacklist
if (!CollectionUtils.isEmpty(pspBlacklist)) {
var pspNotIn = notIn(ID_PSP_PARAM, pspBlacklist);
queryResult = and(queryResult, pspNotIn);
}
queryResult = blackListCriteria(queryResult);

// execute the query
return cosmosTemplate.find(new CosmosQuery(queryResult), ValidBundle.class, "validbundles");
Expand Down Expand Up @@ -419,4 +413,13 @@ private Criteria getPspFilterCriteria(
}
return queryTmp != null ? and(queryResult, queryTmp) : queryResult;
}

private Criteria blackListCriteria(Criteria queryResult) {
// add filter for PSP blacklist
if (!CollectionUtils.isEmpty(pspBlacklist)) {
var pspNotIn = notIn(ID_PSP_PARAM, pspBlacklist);
queryResult = and(queryResult, pspNotIn);
}
return queryResult;
}
}

0 comments on commit c542b1f

Please sign in to comment.