Search in sources :

Example 6 with SqlViewBinding

use of de.metas.ui.web.view.descriptor.SqlViewBinding in project metasfresh-webui-api by metasfresh.

the class SqlViewFactory method createView.

@Override
public IView createView(final CreateViewRequest request) {
    final WindowId windowId = request.getViewId().getWindowId();
    final JSONViewDataType viewType = request.getViewType();
    final ViewProfileId profileId = !ViewProfileId.isNull(request.getProfileId()) ? request.getProfileId() : getDefaultProfileIdByWindowId(windowId);
    final SqlViewBindingKey sqlViewBindingKey = new SqlViewBindingKey(windowId, viewType.getRequiredFieldCharacteristic(), profileId);
    final SqlViewBinding sqlViewBinding = getViewBinding(sqlViewBindingKey);
    final IViewDataRepository viewDataRepository = new SqlViewDataRepository(sqlViewBinding);
    final DefaultView.Builder viewBuilder = DefaultView.builder(viewDataRepository).setViewId(request.getViewId()).setViewType(viewType).setProfileId(profileId).setReferencingDocumentPaths(request.getReferencingDocumentPaths()).setParentViewId(request.getParentViewId()).setParentRowId(request.getParentRowId()).addStickyFilters(request.getStickyFilters()).addStickyFilter(extractReferencedDocumentFilter(windowId, request.getSingleReferencingDocumentPathOrNull())).viewInvalidationAdvisor(sqlViewBinding.getViewInvalidationAdvisor());
    final DocumentFiltersList filters = request.getFilters();
    if (filters.isJson()) {
        viewBuilder.setFiltersFromJSON(filters.getJsonFilters());
    } else {
        viewBuilder.setFilters(filters.getFilters());
    }
    if (request.isUseAutoFilters()) {
        final List<DocumentFilter> autoFilters = createAutoFilters(sqlViewBindingKey);
        viewBuilder.addFiltersIfAbsent(autoFilters);
    }
    if (!request.getFilterOnlyIds().isEmpty()) {
        final String keyColumnName = sqlViewBinding.getSqlViewKeyColumnNamesMap().getSingleKeyColumnName();
        viewBuilder.addStickyFilter(DocumentFilter.inArrayFilter(keyColumnName, keyColumnName, request.getFilterOnlyIds()));
    }
    return viewBuilder.build();
}
Also used : DocumentFiltersList(de.metas.ui.web.document.filter.DocumentFiltersList) SqlViewBinding(de.metas.ui.web.view.descriptor.SqlViewBinding) DocumentFilter(de.metas.ui.web.document.filter.DocumentFilter) WindowId(de.metas.ui.web.window.datatypes.WindowId) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType)

Aggregations

SqlViewBinding (de.metas.ui.web.view.descriptor.SqlViewBinding)6 DocumentFilterDescriptor (de.metas.ui.web.document.filter.DocumentFilterDescriptor)4 WindowId (de.metas.ui.web.window.datatypes.WindowId)4 DocumentFilter (de.metas.ui.web.document.filter.DocumentFilter)3 DocumentFilterDescriptorsProvider (de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider)3 ViewLayout (de.metas.ui.web.view.descriptor.ViewLayout)3 JSONViewDataType (de.metas.ui.web.view.json.JSONViewDataType)3 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)3 SqlDocumentEntityDataBindingDescriptor (de.metas.ui.web.window.descriptor.sql.SqlDocumentEntityDataBindingDescriptor)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)2 Constants (de.metas.handlingunits.attribute.Constants)2 I_M_HU (de.metas.handlingunits.model.I_M_HU)2 IMsgBL (de.metas.i18n.IMsgBL)2 ITranslatableString (de.metas.i18n.ITranslatableString)2 LogManager (de.metas.logging.LogManager)2 DocumentFilterParamDescriptor (de.metas.ui.web.document.filter.DocumentFilterParamDescriptor)2 ImmutableDocumentFilterDescriptorsProvider (de.metas.ui.web.document.filter.ImmutableDocumentFilterDescriptorsProvider)2