Search in sources :

Example 1 with FieldReference

use of org.adempiere.util.reflect.FieldReference in project metasfresh-webui-api by metasfresh.

the class ViewColumnHelper method createClassViewColumnDescriptor.

private static ClassViewColumnDescriptor createClassViewColumnDescriptor(final Field field) {
    final ViewColumn viewColumnAnn = field.getAnnotation(ViewColumn.class);
    final String fieldName = !Check.isEmpty(viewColumnAnn.fieldName(), true) ? viewColumnAnn.fieldName().trim() : field.getName();
    final String captionKey = !Check.isEmpty(viewColumnAnn.captionKey()) ? viewColumnAnn.captionKey() : fieldName;
    final ImmutableMap<JSONViewDataType, ClassViewColumnLayoutDescriptor> layoutsByViewType = Stream.of(viewColumnAnn.layouts()).map(layoutAnn -> ClassViewColumnLayoutDescriptor.builder().viewType(layoutAnn.when()).displayed(layoutAnn.displayed()).seqNo(layoutAnn.seqNo()).build()).collect(GuavaCollectors.toImmutableMapByKey(ClassViewColumnLayoutDescriptor::getViewType));
    return ClassViewColumnDescriptor.builder().fieldName(fieldName).caption(Services.get(IMsgBL.class).translatable(captionKey)).widgetType(viewColumnAnn.widgetType()).editorRenderMode(viewColumnAnn.editor()).allowSorting(viewColumnAnn.sorting()).fieldReference(FieldReference.of(field)).layoutsByViewType(layoutsByViewType).restrictToMediaTypes(ImmutableSet.copyOf(viewColumnAnn.restrictToMediaTypes())).build();
}
Also used : LoadingCache(com.google.common.cache.LoadingCache) Getter(lombok.Getter) Singular(lombok.Singular) GuavaCollectors(org.adempiere.util.GuavaCollectors) Values(de.metas.ui.web.window.datatypes.Values) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType) DocumentLayoutElementDescriptor(de.metas.ui.web.window.descriptor.DocumentLayoutElementDescriptor) Value(lombok.Value) LinkedHashMap(java.util.LinkedHashMap) UtilityClass(lombok.experimental.UtilityClass) ImmutableList(com.google.common.collect.ImmutableList) ToString(lombok.ToString) FieldReference(org.adempiere.util.reflect.FieldReference) JSONNullValue(de.metas.ui.web.window.datatypes.json.JSONNullValue) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) ITranslatableString(de.metas.i18n.ITranslatableString) NonNull(lombok.NonNull) ViewEditorRenderMode(de.metas.ui.web.window.descriptor.ViewEditorRenderMode) Set(java.util.Set) MediaType(de.metas.ui.web.window.datatypes.MediaType) Field(java.lang.reflect.Field) EqualsAndHashCode(lombok.EqualsAndHashCode) ExecutionException(java.util.concurrent.ExecutionException) CacheLoader(com.google.common.cache.CacheLoader) Services(org.adempiere.util.Services) DocumentLayoutElementFieldDescriptor(de.metas.ui.web.window.descriptor.DocumentLayoutElementFieldDescriptor) List(java.util.List) IViewRow(de.metas.ui.web.view.IViewRow) Stream(java.util.stream.Stream) Builder(lombok.Builder) AdempiereException(org.adempiere.exceptions.AdempiereException) Check(de.metas.printing.esb.base.util.Check) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) IMsgBL(de.metas.i18n.IMsgBL) ReflectionUtils(org.reflections.ReflectionUtils) CacheBuilder(com.google.common.cache.CacheBuilder) Comparator(java.util.Comparator) IMsgBL(de.metas.i18n.IMsgBL) ToString(lombok.ToString) ITranslatableString(de.metas.i18n.ITranslatableString) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType)

Aggregations

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 ImmutableSet (com.google.common.collect.ImmutableSet)1 IMsgBL (de.metas.i18n.IMsgBL)1 ITranslatableString (de.metas.i18n.ITranslatableString)1 Check (de.metas.printing.esb.base.util.Check)1 IViewRow (de.metas.ui.web.view.IViewRow)1 JSONViewDataType (de.metas.ui.web.view.json.JSONViewDataType)1 MediaType (de.metas.ui.web.window.datatypes.MediaType)1 Values (de.metas.ui.web.window.datatypes.Values)1 JSONNullValue (de.metas.ui.web.window.datatypes.json.JSONNullValue)1 DocumentFieldWidgetType (de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)1 DocumentLayoutElementDescriptor (de.metas.ui.web.window.descriptor.DocumentLayoutElementDescriptor)1 DocumentLayoutElementFieldDescriptor (de.metas.ui.web.window.descriptor.DocumentLayoutElementFieldDescriptor)1 ViewEditorRenderMode (de.metas.ui.web.window.descriptor.ViewEditorRenderMode)1 Field (java.lang.reflect.Field)1 Comparator (java.util.Comparator)1