use of org.adempiere.ad.service.impl.LookupDAO.SQLNamePairIterator in project metasfresh-webui-api by metasfresh.
the class GenericSqlLookupDataSourceFetcher method retrieveEntities.
/**
* @param evalCtx
* @return lookup values list
* @see #getRetrieveEntriesParameters()
*/
@Override
public LookupValuesList retrieveEntities(final LookupDataSourceContext evalCtx) {
final String sqlForFetching = sqlForFetchingExpression.evaluate(evalCtx, OnVariableNotFound.Fail);
final String adLanguage = isTranslatable ? evalCtx.getAD_Language() : null;
try (final SQLNamePairIterator data = new SQLNamePairIterator(sqlForFetching, numericKey, entityTypeIndex)) {
Map<String, String> debugProperties = null;
if (WindowConstants.isProtocolDebugging()) {
debugProperties = new LinkedHashMap<>();
debugProperties.put("debug-sql", sqlForFetching);
debugProperties.put("debug-params", evalCtx.toString());
}
final LookupValuesList values = data.fetchAll().stream().filter(evalCtx::acceptItem).map(namePair -> LookupValue.fromNamePair(namePair, adLanguage)).collect(LookupValuesList.collect(debugProperties));
logger.trace("Returning values={} (executed sql: {})", values, sqlForFetching);
return values;
}
}
Aggregations