From 315614e0128ff403a02a4c5a30e55500c1eb9626 Mon Sep 17 00:00:00 2001 From: Konstantin Krivopustov Date: Thu, 17 Jan 2013 12:17:09 +0000 Subject: [PATCH] Refs #1803 Deprecate LazyCollectionDatasource --- .../desktop/gui/components/filter/Param.java | 1 - .../cuba/gui/components/RowsCount.java | 13 ++++++------ .../components/RuntimePropertiesFrame.java | 1 - .../cuba/gui/data/CollectionDatasource.java | 21 ++++++++++--------- .../com/haulmont/cuba/gui/data/DsBuilder.java | 5 ++--- .../data/impl/LazyCollectionDatasource.java | 4 ++++ .../data/impl/RuntimePropsDatasourceImpl.java | 1 - .../gui/src/com/haulmont/cuba/gui/window.xsd | 9 -------- .../cuba/web/gui/components/filter/Param.java | 1 - 9 files changed, 24 insertions(+), 32 deletions(-) diff --git a/modules/desktop/src/com/haulmont/cuba/desktop/gui/components/filter/Param.java b/modules/desktop/src/com/haulmont/cuba/desktop/gui/components/filter/Param.java index f2db8f42ba..4331d42e29 100644 --- a/modules/desktop/src/com/haulmont/cuba/desktop/gui/components/filter/Param.java +++ b/modules/desktop/src/com/haulmont/cuba/desktop/gui/components/filter/Param.java @@ -354,7 +354,6 @@ public class Param extends AbstractParam { CollectionDatasource ds = new DsBuilder(datasource.getDsContext()) .setMetaClass(metaClass) .setViewName(entityView) - .setFetchMode(CollectionDatasource.FetchMode.AUTO) .buildCollectionDatasource(); ds.setRefreshOnComponentValueChange(true); diff --git a/modules/gui/src/com/haulmont/cuba/gui/components/RowsCount.java b/modules/gui/src/com/haulmont/cuba/gui/components/RowsCount.java index 54a9386556..f9fe3f92f4 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/components/RowsCount.java +++ b/modules/gui/src/com/haulmont/cuba/gui/components/RowsCount.java @@ -1,17 +1,18 @@ /* - * Copyright (c) 2011 Haulmont Technology Ltd. All Rights Reserved. + * Copyright (c) 2013 Haulmont Technology Ltd. All Rights Reserved. * Haulmont Technology proprietary and confidential. * Use is subject to license terms. - - * Author: Konstantin Krivopustov - * Created: 21.02.11 14:52 - * - * $Id$ */ package com.haulmont.cuba.gui.components; import com.haulmont.cuba.gui.data.CollectionDatasource; +/** + * Component that makes a {@link CollectionDatasource} to load data by pages. Usually used inside {@link Table}. + * + * @author krivopustov + * @version $Id$ + */ public interface RowsCount extends Component.BelongToFrame, Component.HasXmlDescriptor { enum State { diff --git a/modules/gui/src/com/haulmont/cuba/gui/components/RuntimePropertiesFrame.java b/modules/gui/src/com/haulmont/cuba/gui/components/RuntimePropertiesFrame.java index aea6afc28a..2c6281e194 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/components/RuntimePropertiesFrame.java +++ b/modules/gui/src/com/haulmont/cuba/gui/components/RuntimePropertiesFrame.java @@ -209,7 +209,6 @@ public class RuntimePropertiesFrame extends AbstractWindow { CollectionDatasource optionsDs = new DsBuilder(datasource.getDsContext()) .setMetaClass(property.getRange().asClass()) .setViewName(View.MINIMAL) - .setFetchMode(CollectionDatasource.FetchMode.AUTO) .buildCollectionDatasource(); optionsDs.refresh(); Action action = pickerField.getAction(PickerField.LookupAction.NAME); diff --git a/modules/gui/src/com/haulmont/cuba/gui/data/CollectionDatasource.java b/modules/gui/src/com/haulmont/cuba/gui/data/CollectionDatasource.java index ea7b6f9884..f596cef21b 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/data/CollectionDatasource.java +++ b/modules/gui/src/com/haulmont/cuba/gui/data/CollectionDatasource.java @@ -27,16 +27,6 @@ import java.util.Map; */ public interface CollectionDatasource, K> extends Datasource { - /** Mode of fetching data from database: {@link #ALL}, {@link #LAZY} */ - enum FetchMode { - /** Datasource will load all data at once */ - ALL, - /** Datasource will try to load data by chunks per UI component request */ - LAZY, - /** ALL or LAZY will be choosen on the basis of PersistenceManager statistics */ - AUTO - } - /** Mode of load data from database: {@link #ALWAYS}, {@link #NEVER} */ enum RefreshMode{ /** Datasource will load data for each refresh */ @@ -347,4 +337,15 @@ public interface CollectionDatasource, K> extends Datasource void pinQuery(); void unpinLastQuery(); } + + /** Mode of fetching data from database: {@link #ALL}, {@link #LAZY} */ + @Deprecated + enum FetchMode { + /** Datasource will load all data at once */ + ALL, + /** Datasource will try to load data by chunks per UI component request */ + LAZY, + /** ALL or LAZY will be choosen on the basis of PersistenceManager statistics */ + AUTO + } } diff --git a/modules/gui/src/com/haulmont/cuba/gui/data/DsBuilder.java b/modules/gui/src/com/haulmont/cuba/gui/data/DsBuilder.java index 9e76e8b418..4084b47a29 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/data/DsBuilder.java +++ b/modules/gui/src/com/haulmont/cuba/gui/data/DsBuilder.java @@ -29,9 +29,6 @@ import org.apache.commons.lang.ObjectUtils; * If you set master and property properties you will get a PropertyDatasource * implementation. * - * If you don't set fetchMode explicitly, lazy implementation may be chosen based on PersistenceManager - * statistics. - * * @author krivopustov * @version $Id$ */ @@ -185,10 +182,12 @@ public class DsBuilder { return this; } + @Deprecated public CollectionDatasource.FetchMode getFetchMode() { return fetchMode; } + @Deprecated public DsBuilder setFetchMode(CollectionDatasource.FetchMode fetchMode) { this.fetchMode = fetchMode; return this; diff --git a/modules/gui/src/com/haulmont/cuba/gui/data/impl/LazyCollectionDatasource.java b/modules/gui/src/com/haulmont/cuba/gui/data/impl/LazyCollectionDatasource.java index 78dc45c201..4e53f8ff5e 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/data/impl/LazyCollectionDatasource.java +++ b/modules/gui/src/com/haulmont/cuba/gui/data/impl/LazyCollectionDatasource.java @@ -24,9 +24,13 @@ import org.perf4j.log4j.Log4JStopWatch; import java.util.*; /** + * DEPRECATED. To restrict data loading use {@link com.haulmont.cuba.gui.components.SearchPickerField} and + * {@link com.haulmont.cuba.gui.components.RowsCount} components with usual {@link CollectionDatasourceImpl}. + * * @author abramov * @version $Id$ */ +@Deprecated public class LazyCollectionDatasource, K> extends AbstractCollectionDatasource diff --git a/modules/gui/src/com/haulmont/cuba/gui/data/impl/RuntimePropsDatasourceImpl.java b/modules/gui/src/com/haulmont/cuba/gui/data/impl/RuntimePropsDatasourceImpl.java index d8f2d5251d..419f504fab 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/data/impl/RuntimePropsDatasourceImpl.java +++ b/modules/gui/src/com/haulmont/cuba/gui/data/impl/RuntimePropsDatasourceImpl.java @@ -168,7 +168,6 @@ public class RuntimePropsDatasourceImpl final CollectionDatasource datasource; datasource = builder - .setFetchMode(CollectionDatasource.FetchMode.ALL) .setRefreshMode(CollectionDatasource.RefreshMode.NEVER) .buildCollectionDatasource(); List options = getOptions(attribute, attributeValue); diff --git a/modules/gui/src/com/haulmont/cuba/gui/window.xsd b/modules/gui/src/com/haulmont/cuba/gui/window.xsd index 1a761ed23c..626d70c08f 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/window.xsd +++ b/modules/gui/src/com/haulmont/cuba/gui/window.xsd @@ -128,14 +128,6 @@ - - - - - - - - @@ -1144,7 +1136,6 @@ - diff --git a/modules/web/src/com/haulmont/cuba/web/gui/components/filter/Param.java b/modules/web/src/com/haulmont/cuba/web/gui/components/filter/Param.java index d78ef38852..94d0d699c1 100644 --- a/modules/web/src/com/haulmont/cuba/web/gui/components/filter/Param.java +++ b/modules/web/src/com/haulmont/cuba/web/gui/components/filter/Param.java @@ -358,7 +358,6 @@ public class Param extends AbstractParam { CollectionDatasource ds = new DsBuilder(datasource.getDsContext()) .setMetaClass(metaClass) .setViewName(entityView) - .setFetchMode(CollectionDatasource.FetchMode.AUTO) .buildCollectionDatasource(); ds.setRefreshOnComponentValueChange(true);