Search in sources :

Example 1 with JavaProcess

use of de.metas.process.JavaProcess in project metasfresh-webui-api by metasfresh.

the class WebuiProcessClassInfo method retriveLookupValues.

private static final LookupValuesList retriveLookupValues(final Method method, final List<Function<LookupDataSourceContext, Object>> parameterValueProviders, final LookupDataSourceContext evalCtx) {
    Check.assumeNotNull(method, "Parameter method is not null");
    final JavaProcess processClassInstance = JavaProcess.currentInstance();
    final Object[] methodParams = parameterValueProviders.stream().map(paramValueProvider -> paramValueProvider.apply(evalCtx)).toArray();
    try {
        if (!method.isAccessible()) {
            method.setAccessible(true);
        }
        final LookupValuesList lookupValues = (LookupValuesList) method.invoke(processClassInstance, methodParams);
        return lookupValues;
    } catch (IllegalAccessException | InvocationTargetException e) {
        final Throwable cause = AdempiereException.extractCause(e);
        throw new AdempiereException("Failed invoking " + method + " using " + methodParams, cause);
    } catch (final Exception e) {
        throw AdempiereException.wrapIfNeeded(e);
    }
}
Also used : LogManager(de.metas.logging.LogManager) LoadingCache(com.google.common.cache.LoadingCache) GuavaCollectors(org.adempiere.util.GuavaCollectors) LookupDescriptorProvider(de.metas.ui.web.window.descriptor.LookupDescriptorProvider) Function(java.util.function.Function) ProcessClassInfo(de.metas.process.ProcessClassInfo) ListLookupDescriptor(de.metas.ui.web.window.descriptor.ListLookupDescriptor) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) PanelLayoutType(de.metas.ui.web.window.datatypes.PanelLayoutType) Method(java.lang.reflect.Method) Nullable(javax.annotation.Nullable) Logger(org.slf4j.Logger) LookupDataSourceContext(de.metas.ui.web.window.model.lookup.LookupDataSourceContext) ImmutableMap(com.google.common.collect.ImmutableMap) Set(java.util.Set) MoreObjects(com.google.common.base.MoreObjects) JavaProcess(de.metas.process.JavaProcess) InvocationTargetException(java.lang.reflect.InvocationTargetException) CacheLoader(com.google.common.cache.CacheLoader) List(java.util.List) Stream(java.util.stream.Stream) AdempiereException(org.adempiere.exceptions.AdempiereException) Check(org.adempiere.util.Check) ProcessParamLookupValuesProvider(de.metas.ui.web.process.descriptor.ProcessParamLookupValuesProvider) ReflectionUtils(org.reflections.ReflectionUtils) CacheBuilder(com.google.common.cache.CacheBuilder) AdempiereException(org.adempiere.exceptions.AdempiereException) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) AdempiereException(org.adempiere.exceptions.AdempiereException) JavaProcess(de.metas.process.JavaProcess)

Aggregations

MoreObjects (com.google.common.base.MoreObjects)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 CacheLoader (com.google.common.cache.CacheLoader)1 LoadingCache (com.google.common.cache.LoadingCache)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 LogManager (de.metas.logging.LogManager)1 JavaProcess (de.metas.process.JavaProcess)1 ProcessClassInfo (de.metas.process.ProcessClassInfo)1 ProcessParamLookupValuesProvider (de.metas.ui.web.process.descriptor.ProcessParamLookupValuesProvider)1 LookupValuesList (de.metas.ui.web.window.datatypes.LookupValuesList)1 PanelLayoutType (de.metas.ui.web.window.datatypes.PanelLayoutType)1 ListLookupDescriptor (de.metas.ui.web.window.descriptor.ListLookupDescriptor)1 LookupDescriptor (de.metas.ui.web.window.descriptor.LookupDescriptor)1 LookupDescriptorProvider (de.metas.ui.web.window.descriptor.LookupDescriptorProvider)1 LookupDataSourceContext (de.metas.ui.web.window.model.lookup.LookupDataSourceContext)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 List (java.util.List)1 Map (java.util.Map)1