use of de.metas.ui.web.process.descriptor.ProcessParamLookupValuesProvider in project metasfresh-webui-api by metasfresh.
the class WEBUI_Picking_PickQtyToNewHU method getM_HU_PI_Item_Products.
/**
* @return a list of PI item products that match the selected shipment schedule's product and partner, sorted by name.
*/
@ProcessParamLookupValuesProvider(parameterName = PARAM_M_HU_PI_Item_Product_ID, dependsOn = {}, numericKey = true, lookupTableName = I_M_HU_PI_Item_Product.Table_Name)
private LookupValuesList getM_HU_PI_Item_Products() {
final Properties ctx = getCtx();
// can't be null
final I_M_ShipmentSchedule shipmentSchedule = getView().getCurrentShipmentSchedule();
return WEBUI_ProcessHelper.retrieveHUPIItemProducts(ctx, shipmentSchedule.getM_Product(), shipmentSchedule.getC_BPartner(), // includeVirtualItem = true..similar case as with production
true);
}
use of de.metas.ui.web.process.descriptor.ProcessParamLookupValuesProvider in project metasfresh-webui-api by metasfresh.
the class WebuiProcessClassInfo method createParamLookupValuesProvider.
//
//
// ----
//
//
/**
* @return parameterName and provider
*/
private static Map.Entry<String, LookupDescriptorProvider> createParamLookupValuesProvider(final Method method) {
final ProcessParamLookupValuesProvider ann = method.getAnnotation(ProcessParamLookupValuesProvider.class);
if (!LookupValuesList.class.isAssignableFrom(method.getReturnType())) {
throw new AdempiereException("Method's return type shall be " + LookupValuesList.class + ": " + method);
}
final ImmutableList<Function<LookupDataSourceContext, Object>> parameterValueProviders = Stream.of(method.getParameterTypes()).map(parameterType -> {
final Function<LookupDataSourceContext, Object> parameterValueProvider;
if (LookupDataSourceContext.class.isAssignableFrom(parameterType)) {
parameterValueProvider = evalCtx -> evalCtx;
} else {
throw new AdempiereException("Parameter " + parameterType + " not supported for " + method);
}
return parameterValueProvider;
}).collect(ImmutableList.toImmutableList());
// FIXME: holding a hard reference to method may introduce ClassLoader memory leaks
final Method methodToInvoke = method;
final LookupDescriptor lookupDescriptor = ListLookupDescriptor.builder().setLookupTableName(ann.lookupTableName()).setDependsOnFieldNames(ann.dependsOn()).setLookupSourceType(ann.lookupSource()).setLookupValues(ann.numericKey(), evalCtx -> retriveLookupValues(methodToInvoke, parameterValueProviders, evalCtx)).build();
final LookupDescriptorProvider lookupDescriptorProvider = LookupDescriptorProvider.singleton(lookupDescriptor);
return GuavaCollectors.entry(ann.parameterName(), lookupDescriptorProvider);
}
Aggregations