From 4ed1d14b1a07f79f3aafcbc15f79af8e9f81f91e Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Wed, 10 Mar 2010 07:02:50 +0000 Subject: [PATCH] LMS-1431 IResultSetConfig extended with a method which provides the IDs of all columns which should be presented in the GUI. CachedResultSetManager extended with a private method which gathers all columns needed for presentation and/or filtering. SVN: 15091 --- .../ui/grid/AbstractBrowserGrid.java | 17 +++++----- .../client/dto/DefaultResultSetConfig.java | 25 +++++++++++++++ .../web/client/dto/IResultSetConfig.java | 5 +++ .../web/server/CommonClientService.java | 1 + .../resultset/CachedResultSetManager.java | 32 +++++++++++++++++++ 5 files changed, 71 insertions(+), 9 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java index 223f9b2c945..4d66dd37309 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java @@ -528,8 +528,7 @@ public abstract class AbstractBrowserGrid<T/* Entity */, M extends BaseEntityMod ResultSetFetchConfig.createFetchFromCache(resultSetKeyOrNull); } final DefaultResultSetConfig<String, T> resultSetConfig = - createPagingConfig(loadConfig, columnDefinitions, filterToolbar.getFilters(), - pendingFetchConfigOrNull, getGridDisplayTypeID(), viewContext); + createPagingConfig(loadConfig, filterToolbar.getFilters(), getGridDisplayTypeID()); debug("create a refresh callback " + pendingFetchConfigOrNull); final ListEntitiesCallback listCallback = new ListEntitiesCallback(viewContext, callback, resultSetConfig); @@ -582,10 +581,9 @@ public abstract class AbstractBrowserGrid<T/* Entity */, M extends BaseEntityMod return filters; } - private static <T> DefaultResultSetConfig<String, T> createPagingConfig( - PagingLoadConfig loadConfig, Set<IColumnDefinition<T>> availableColumns, - GridFilters<T> filters, ResultSetFetchConfig<String> cacheConfig, String gridDisplayId, - IViewContext<ICommonClientServiceAsync> viewContext) + private DefaultResultSetConfig<String, T> createPagingConfig( + PagingLoadConfig loadConfig, GridFilters<T> filters, + String gridDisplayId) { int limit = loadConfig.getLimit(); int offset = loadConfig.getOffset(); @@ -594,11 +592,12 @@ public abstract class AbstractBrowserGrid<T/* Entity */, M extends BaseEntityMod DefaultResultSetConfig<String, T> resultSetConfig = new DefaultResultSetConfig<String, T>(); resultSetConfig.setLimit(limit); resultSetConfig.setOffset(offset); - SortInfo<T> translatedSortInfo = translateSortInfo(sortInfo, availableColumns); - resultSetConfig.setAvailableColumns(availableColumns); + SortInfo<T> translatedSortInfo = translateSortInfo(sortInfo, columnDefinitions); + resultSetConfig.setAvailableColumns(columnDefinitions); + resultSetConfig.setPresentedColumns(getVisibleColumns(columnDefinitions)); resultSetConfig.setSortInfo(translatedSortInfo); resultSetConfig.setFilters(filters); - resultSetConfig.setCacheConfig(cacheConfig); + resultSetConfig.setCacheConfig(pendingFetchConfigOrNull); resultSetConfig.setGridDisplayId(gridDisplayId); resultSetConfig.setCustomColumnErrorMessageLong(viewContext.getDisplaySettingsManager() .isDisplayCustomColumnDebuggingErrorMessages()); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/DefaultResultSetConfig.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/DefaultResultSetConfig.java index b7d87f02c30..3ce91108275 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/DefaultResultSetConfig.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/DefaultResultSetConfig.java @@ -16,6 +16,8 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.dto; +import java.util.HashSet; +import java.util.List; import java.util.Set; import com.google.gwt.user.client.rpc.IsSerializable; @@ -39,6 +41,8 @@ public class DefaultResultSetConfig<K, T> implements IResultSetConfig<K, T>, IsS private ResultSetFetchConfig<K> cacheConfig = ResultSetFetchConfig.createComputeAndCache(); private Set<IColumnDefinition<T>> availableColumns; + + private Set<String> idsOfPresentedColumns; private GridFilters<T> filters = GridFilters.createEmptyFilter(); @@ -87,11 +91,32 @@ public class DefaultResultSetConfig<K, T> implements IResultSetConfig<K, T>, IsS this.availableColumns = availableColumns; } + public Set<String> getIDsOfPresentedColumns() + { + return idsOfPresentedColumns; + } + + public void setPresentedColumns(List<IColumnDefinition<T>> presentedColumns) + { + Set<String> ids = new HashSet<String>(); + for (IColumnDefinition<T> columnDefinition : presentedColumns) + { + ids.add(columnDefinition.getIdentifier()); + } + setIDsOfPresentedColumns(ids); + } + + private void setIDsOfPresentedColumns(Set<String> idsOfPresentedColumns) + { + this.idsOfPresentedColumns = idsOfPresentedColumns; + } + public final void copyPagingConfig(DefaultResultSetConfig<K, T> resultSetConfig) { setLimit(resultSetConfig.getLimit()); setOffset(resultSetConfig.getOffset()); setAvailableColumns(resultSetConfig.getAvailableColumns()); + setIDsOfPresentedColumns(resultSetConfig.getIDsOfPresentedColumns()); setSortInfo(resultSetConfig.getSortInfo()); setFilters(resultSetConfig.getFilters()); setCacheConfig(resultSetConfig.getCacheConfig()); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/IResultSetConfig.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/IResultSetConfig.java index 7b8598750cd..5aa2dafbcd9 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/IResultSetConfig.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/IResultSetConfig.java @@ -54,6 +54,11 @@ public interface IResultSetConfig<K, T> * include custom columns only if this information was already fetched. */ public Set<IColumnDefinition<T>> getAvailableColumns(); + + /** + * Returns the IDs of those columns which will be shown at the client. + */ + public Set<String> getIDsOfPresentedColumns(); /** * Returns the sort info. diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java index a66e9ceb3ed..44cd677bd02 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java @@ -210,6 +210,7 @@ public final class CommonClientService extends AbstractClientService implements criteria.setCacheConfig(ResultSetFetchConfig.createFetchFromCache(exportCriteria .getResultSetKey())); criteria.setAvailableColumns(exportCriteria.getAvailableColumns()); + criteria.setPresentedColumns(exportCriteria.getColumnDefs()); criteria.setGridDisplayId(exportCriteria.getGridDisplayId()); return criteria; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/CachedResultSetManager.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/CachedResultSetManager.java index fdcb552bb2c..f8b1182826c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/CachedResultSetManager.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/CachedResultSetManager.java @@ -323,6 +323,8 @@ public final class CachedResultSetManager<K> implements IResultSetManager<K>, Se { assert resultConfig != null : "Unspecified result configuration"; assert dataProvider != null : "Unspecified data retriever"; + Set<String> ids = gatherAllColumnIDs(resultConfig); + debug("All columns needed:"+ids); ResultSetFetchConfig<K> cacheConfig = resultConfig.getCacheConfig(); ResultSetFetchMode mode = cacheConfig.getMode(); debug("getResultSet(cache config = " + cacheConfig + ")"); @@ -358,6 +360,36 @@ public final class CachedResultSetManager<K> implements IResultSetManager<K>, Se } } + private <T> Set<String> gatherAllColumnIDs(final IResultSetConfig<K, T> resultConfig) + { + Set<String> ids = new HashSet<String>(); + ids.addAll(resultConfig.getIDsOfPresentedColumns()); + GridFilters<T> filters = resultConfig.getFilters(); + List<GridColumnFilterInfo<T>> filterInfos = filters.tryGetFilterInfos(); + if (filterInfos != null) + { + for (GridColumnFilterInfo<T> filterInfo : filterInfos) + { + ids.add(filterInfo.getFilteredField().getIdentifier()); + } + } + CustomFilterInfo<T> customFilterInfo = filters.tryGetCustomFilterInfo(); + if (customFilterInfo != null) + { + String expression = customFilterInfo.getExpression(); + Set<IColumnDefinition<T>> availableColumns = resultConfig.getAvailableColumns(); + for (IColumnDefinition<T> columnDefinition : availableColumns) + { + String identifier = columnDefinition.getIdentifier(); + if (expression.indexOf(identifier) >= 0) + { + ids.add(identifier); + } + } + } + return ids; + } + private <T> IResultSet<K, T> calculateResultSetAndSave(final String sessionToken, final IResultSetConfig<K, T> resultConfig, final IOriginalDataProvider<T> dataProvider) { -- GitLab