From 3b4fd1e349d6fd5024025d9e8cbb1b76c43ab662 Mon Sep 17 00:00:00 2001 From: pkupczyk <pkupczyk> Date: Mon, 20 Aug 2012 14:32:20 +0000 Subject: [PATCH] SP-241 / BIS-122 : Embedded grids need to persist display settings - In the embedded grids case there can be multiple display settings objects on the client side. As they do not share any state, saving one of these objects may overwrite changes made to the others. To avoid such a situation we do not update the whole display settings object but only chosen parts with the specific grid settings. SVN: 26402 --- .../client/web/client/IClientService.java | 3 +- .../web/client/IClientServiceAsync.java | 5 +- .../client/application/CommonViewContext.java | 9 +-- .../framework/DisplaySettingsManager.java | 62 +++++++++++------- .../web/server/AbstractClientService.java | 8 ++- .../generic/server/AbstractServer.java | 31 +++++++++ .../server/DisplaySettingsProvider.java | 12 ++++ .../generic/shared/AbstractServerLogger.java | 8 +++ .../cisd/openbis/generic/shared/IServer.java | 5 ++ .../AllDisplaySettingsUpdate.java | 58 +++++++++++++++++ .../ColumnDisplaySettingsUpdate.java | 65 +++++++++++++++++++ .../IDisplaySettingsUpdate.java | 31 +++++++++ .../DisplaySettingsManagerTest.java | 10 +-- .../web/server/CommonClientServiceTest.java | 3 +- 14 files changed, 270 insertions(+), 40 deletions(-) create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/displaysettings/AllDisplaySettingsUpdate.java create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/displaysettings/ColumnDisplaySettingsUpdate.java create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/displaysettings/IDisplaySettingsUpdate.java diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IClientService.java index 1c4c7246bf5..abd23d8ad84 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IClientService.java @@ -26,6 +26,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureE import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.CustomImport; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DisplaySettings; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings.IDisplaySettingsUpdate; /** * The basic <i>GWT</i> client service interface. @@ -70,7 +71,7 @@ public interface IClientService extends RemoteService /** * Updates display settings on the server. */ - public void updateDisplaySettings(DisplaySettings displaySettings); + public void updateDisplaySettings(IDisplaySettingsUpdate update); /** * Resets display settings of the logged user to the default settings. diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IClientServiceAsync.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IClientServiceAsync.java index 95c6d57e71a..6ff0dc4c7ab 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IClientServiceAsync.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IClientServiceAsync.java @@ -25,6 +25,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SessionContext; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.CustomImport; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DisplaySettings; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings.IDisplaySettingsUpdate; /** * @author Christian Ribeaud @@ -51,8 +52,8 @@ public interface IClientServiceAsync /** @see IClientService#setBaseURL(String) */ public void setBaseURL(String baseURL, AsyncCallback<SessionContext> callback); - /** @see IClientService#updateDisplaySettings(DisplaySettings) */ - public void updateDisplaySettings(DisplaySettings displaySettings, AsyncCallback<Void> callback); + /** @see IClientService#updateDisplaySettings(IDisplaySettingsUpdate) */ + public void updateDisplaySettings(IDisplaySettingsUpdate update, AsyncCallback<Void> callback); /** @see IClientService#resetDisplaySettings() */ public void resetDisplaySettings(AsyncCallback<DisplaySettings> resetUserSettingsCallback); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/CommonViewContext.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/CommonViewContext.java index 52fdf7258f1..e54c00d67e1 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/CommonViewContext.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/CommonViewContext.java @@ -20,17 +20,18 @@ import java.util.List; import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync; import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.DisplaySettingsManager; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.DisplaySettingsManager.IDisplaySettingsUpdater; import ch.systemsx.cisd.openbis.generic.client.web.client.application.locator.ViewLocatorResolverRegistry; import ch.systemsx.cisd.openbis.generic.client.web.client.application.plugin.IClientPluginFactoryProvider; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.CompositeMessageProvider; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.DictonaryBasedMessageProvider; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IMessageProvider; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.log.IProfilingTable; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.log.ProfilingTable; import ch.systemsx.cisd.openbis.generic.shared.basic.ViewMode; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DisplaySettings; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.WebClientConfiguration; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings.IDisplaySettingsUpdate; /** * The <i>generic</i> {@link IViewContext} implementation. @@ -168,12 +169,12 @@ public final class CommonViewContext implements IViewContext<ICommonClientServic private DisplaySettingsManager createDisplaySettingsManager( final DisplaySettings displaySettings, WebClientConfiguration webClientConfigurationDTO) { - IDelegatedAction settingsUpdater = new IDelegatedAction() + IDisplaySettingsUpdater settingsUpdater = new IDisplaySettingsUpdater() { @Override - public void execute() + public void execute(IDisplaySettingsUpdate update) { - service.updateDisplaySettings(displaySettings, new VoidAsyncCallback<Void>( + service.updateDisplaySettings(update, new VoidAsyncCallback<Void>( CommonViewContext.this)); } }; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/DisplaySettingsManager.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/DisplaySettingsManager.java index e066628e5e4..bb96dfeca57 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/DisplaySettingsManager.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/DisplaySettingsManager.java @@ -33,7 +33,6 @@ import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; import com.extjs.gxt.ui.client.widget.grid.ColumnModel; import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ColumnSetting; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DetailViewConfiguration; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DisplaySettings; @@ -43,6 +42,9 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RealNumberFormatingPara import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SortInfo; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SortInfo.SortDir; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.WebClientConfiguration; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings.AllDisplaySettingsUpdate; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings.ColumnDisplaySettingsUpdate; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings.IDisplaySettingsUpdate; /** * Manager of {@link DisplaySettings}. The manager itself is stateless. It only changes the wrapped @@ -58,36 +60,42 @@ public class DisplaySettingsManager private final DisplaySettings displaySettings; - private final IDelayedUpdater updater; + private final IDisplaySettingsDelayedUpdater updater; private final WebClientConfiguration webClientConfiguration; + public interface IDisplaySettingsUpdater + { + void execute(IDisplaySettingsUpdate update); + } + /** * Private, we need this interface to make tests easier. We wrap {@link DelayedTask} which * requires the access to the browser. */ - public interface IDelayedUpdater + public interface IDisplaySettingsDelayedUpdater { /** Cancels any running timers and starts a new one. */ - void executeDelayed(int delayMs); + void executeDelayed(IDisplaySettingsUpdate update, int delayMs); + } public DisplaySettingsManager(DisplaySettings displaySettings, - IDelegatedAction settingsUpdater, IViewContext<?> viewContext) + IDisplaySettingsUpdater settingsUpdater, IViewContext<?> viewContext) { this(displaySettings, createDelayedUpdater(settingsUpdater, viewContext), viewContext .getModel().getApplicationInfo().getWebClientConfiguration()); } - private static IDelayedUpdater createDelayedUpdater(final IDelegatedAction settingsUpdater, - IViewContext<?> viewContext) + private static IDisplaySettingsDelayedUpdater createDelayedUpdater( + final IDisplaySettingsUpdater settingsUpdater, IViewContext<?> viewContext) { if (viewContext.getModel().isDisplaySettingsSaving() == false) { - return new IDelayedUpdater() + return new IDisplaySettingsDelayedUpdater() { @Override - public void executeDelayed(int delayMs) + public void executeDelayed(IDisplaySettingsUpdate update, int delayMs) { // in simple view mode or anonymous login settings are temporary - don't // save them at all @@ -95,20 +103,20 @@ public class DisplaySettingsManager }; } else { - final DelayedTask delayedTask = new DelayedTask(new Listener<BaseEvent>() - { - @Override - public void handleEvent(BaseEvent event) - { - settingsUpdater.execute(); - } - }); - return new IDelayedUpdater() + return new IDisplaySettingsDelayedUpdater() { @Override - public void executeDelayed(int delayMs) + public void executeDelayed(final IDisplaySettingsUpdate update, + final int delayMs) { - delayedTask.delay(delayMs); + new DelayedTask(new Listener<BaseEvent>() + { + @Override + public void handleEvent(BaseEvent event) + { + settingsUpdater.execute(update); + } + }).delay(delayMs); } }; } @@ -117,7 +125,8 @@ public class DisplaySettingsManager /** * Private, for tests only */ - public DisplaySettingsManager(DisplaySettings displaySettings, final IDelayedUpdater updater, + public DisplaySettingsManager(DisplaySettings displaySettings, + final IDisplaySettingsDelayedUpdater updater, WebClientConfiguration webClientConfiguration) { if (displaySettings == null) @@ -415,7 +424,8 @@ public class DisplaySettingsManager Object modifier) { updateActiveTabSettings(tabGroupDisplayID, selectedTabDisplayID, modifier); - updater.executeDelayed(QUITE_TIME_BEFORE_SETTINGS_SAVED_MS); + updater.executeDelayed(new AllDisplaySettingsUpdate(displaySettings), + QUITE_TIME_BEFORE_SETTINGS_SAVED_MS); } private <C> void storeSettings(String displayTypeID, ColumnModel columnModel, @@ -424,18 +434,20 @@ public class DisplaySettingsManager List<ColumnSetting> columnSettings = createColumnsSettings(columnModel, filteredColumnIds, sortInfo); updateColumnSettings(displayTypeID, columnSettings, modifier); - updater.executeDelayed(delayMs); + updater.executeDelayed(new ColumnDisplaySettingsUpdate(displayTypeID, columnSettings), + delayMs); } public void storeDropDownSettings(String dropDownSettingsID, String newValue) { updateDropDownSettings(dropDownSettingsID, newValue); - updater.executeDelayed(QUITE_TIME_BEFORE_SETTINGS_SAVED_MS); + updater.executeDelayed(new AllDisplaySettingsUpdate(displaySettings), + QUITE_TIME_BEFORE_SETTINGS_SAVED_MS); } public void storeSettings() { - updater.executeDelayed(1); // 0 not allowed + updater.executeDelayed(new AllDisplaySettingsUpdate(displaySettings), 1); // 0 not allowed } private static List<ColumnSetting> createColumnsSettings(ColumnModel columnModel, diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/AbstractClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/AbstractClientService.java index 5a70b641070..4b8708d2f2d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/AbstractClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/AbstractClientService.java @@ -85,6 +85,8 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelColumnHeader; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.WebApp; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.WebClientConfiguration; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings.AllDisplaySettingsUpdate; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings.IDisplaySettingsUpdate; import ch.systemsx.cisd.openbis.generic.shared.dto.SessionContextDTO; import ch.systemsx.cisd.openbis.generic.shared.util.ServerUtils; @@ -636,14 +638,14 @@ public abstract class AbstractClientService implements IClientService, } @Override - public void updateDisplaySettings(DisplaySettings displaySettings) + public void updateDisplaySettings(IDisplaySettingsUpdate displaySettingsUpdate) { try { final String sessionToken = getSessionToken(); IServer server = getServer(); int maxEntityVisits = getWebClientConfiguration().getMaxEntityVisits(); - server.saveDisplaySettings(sessionToken, displaySettings, maxEntityVisits); + server.updateDisplaySettings(sessionToken, displaySettingsUpdate, maxEntityVisits); } catch (InvalidSessionException e) { // ignored @@ -661,7 +663,7 @@ public abstract class AbstractClientService implements IClientService, final String sessionToken = getSessionToken(); IServer server = getServer(); final DisplaySettings defaultSettings = server.getDefaultDisplaySettings(sessionToken); - updateDisplaySettings(defaultSettings); + updateDisplaySettings(new AllDisplaySettingsUpdate(defaultSettings)); return defaultSettings; } catch (InvalidSessionException e) { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java index 5a8eac1d2d1..77a91d3173e 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java @@ -71,6 +71,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSamplesWithTypes; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy.RoleCode; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings.IDisplaySettingsUpdate; import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE; import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.DataStorePE; @@ -705,6 +706,36 @@ public abstract class AbstractServer<T> extends AbstractServiceWithLogger<T> imp } } + @Override + public void updateDisplaySettings(String sessionToken, + IDisplaySettingsUpdate displaySettingsUpdate, int maxEntityVisits) + { + if (displaySettingsUpdate == null) + { + throw new IllegalArgumentException("Display settings update cannot be null"); + } + + try + { + final Session session = getSession(sessionToken); + PersonPE person = session.tryGetPerson(); + if (person != null) + { + synchronized (displaySettingsProvider) + { + DisplaySettings currentDisplaySettings = + displaySettingsProvider.getCurrentDisplaySettings(person); + DisplaySettings newDisplaySettings = + displaySettingsUpdate.update(currentDisplaySettings); + saveDisplaySettings(sessionToken, newDisplaySettings, maxEntityVisits); + } + } + } catch (InvalidSessionException e) + { + // ignore the situation when session is not available + } + } + private void sortAndRemoveMultipleVisits(List<EntityVisit> visits) { Collections.sort(visits, new EntityVisitComparatorByTimeStamp()); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/DisplaySettingsProvider.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/DisplaySettingsProvider.java index e7cd55ec780..e940319feb4 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/DisplaySettingsProvider.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/DisplaySettingsProvider.java @@ -44,6 +44,18 @@ public class DisplaySettingsProvider } } + public synchronized DisplaySettings getCurrentDisplaySettings(PersonPE person) + { + DisplaySettings settings = displaySettingsMap.get(person.getUserId()); + if (settings == null) + { + settings = person.getDisplaySettings(); + displaySettingsMap.put(person.getUserId(), settings); + } + settings = new DisplaySettings(settings); + return settings; + } + @SuppressWarnings("deprecation") public synchronized DisplaySettings getRegularDisplaySettings(PersonPE person) { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerLogger.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerLogger.java index fb09e406edd..32c6a49b3b2 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerLogger.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerLogger.java @@ -33,6 +33,7 @@ import ch.systemsx.cisd.common.spring.IInvocationLoggerContext; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DisplaySettings; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.GridCustomColumn; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings.IDisplaySettingsUpdate; import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSession; import ch.systemsx.cisd.openbis.generic.shared.dto.Session; import ch.systemsx.cisd.openbis.generic.shared.dto.SessionContextDTO; @@ -279,6 +280,13 @@ public abstract class AbstractServerLogger implements IServer logTracking(sessionToken, "save_display_settings", ""); } + @Override + public void updateDisplaySettings(String sessionToken, + IDisplaySettingsUpdate displaySettingsUpdate, int maxEntityVisits) + { + logTracking(sessionToken, "update_display_settings", "UPDATE (%s)", displaySettingsUpdate); + } + @Override public DisplaySettings getDefaultDisplaySettings(String sessionToken) { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IServer.java index 4808ff2dd66..96074055510 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IServer.java @@ -31,6 +31,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DisplaySettings; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.GridCustomColumn; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ServiceVersionHolder; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings.IDisplaySettingsUpdate; import ch.systemsx.cisd.openbis.generic.shared.dto.SessionContextDTO; /** @@ -95,6 +96,10 @@ public interface IServer extends ISessionProvider public void saveDisplaySettings(String sessionToken, DisplaySettings displaySettings, int maxEntityVisits); + @Transactional + public void updateDisplaySettings(String sessionToken, + IDisplaySettingsUpdate displaySettingsUpdate, int maxEntityVisits); + /** * Lists grid custom columns for a given grid id. */ diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/displaysettings/AllDisplaySettingsUpdate.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/displaysettings/AllDisplaySettingsUpdate.java new file mode 100644 index 00000000000..bdf2db02a28 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/displaysettings/AllDisplaySettingsUpdate.java @@ -0,0 +1,58 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DisplaySettings; + +/** + * @author pkupczyk + */ +public class AllDisplaySettingsUpdate implements IDisplaySettingsUpdate +{ + + private static final long serialVersionUID = 1L; + + private DisplaySettings newDisplaySettings; + + // GWT + @SuppressWarnings("unused") + private AllDisplaySettingsUpdate() + { + } + + public AllDisplaySettingsUpdate(DisplaySettings newDisplaySettings) + { + if (newDisplaySettings == null) + { + throw new IllegalArgumentException("New display settings cannot be null"); + } + this.newDisplaySettings = newDisplaySettings; + } + + @Override + public DisplaySettings update(DisplaySettings displaySettings) + { + return newDisplaySettings; + } + + @Override + public String toString() + { + return "update of all display settings"; + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/displaysettings/ColumnDisplaySettingsUpdate.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/displaysettings/ColumnDisplaySettingsUpdate.java new file mode 100644 index 00000000000..a75b7d55518 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/displaysettings/ColumnDisplaySettingsUpdate.java @@ -0,0 +1,65 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings; + +import java.util.List; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ColumnSetting; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DisplaySettings; + +/** + * @author pkupczyk + */ +public class ColumnDisplaySettingsUpdate implements IDisplaySettingsUpdate +{ + + private static final long serialVersionUID = 1L; + + private String displayTypeId; + + private List<ColumnSetting> columnSettings; + + // GWT + @SuppressWarnings("unused") + private ColumnDisplaySettingsUpdate() + { + } + + public ColumnDisplaySettingsUpdate(String displayTypeId, List<ColumnSetting> columnSettings) + { + if (displayTypeId == null) + { + throw new IllegalArgumentException("Display type id cannot be null"); + } + this.displayTypeId = displayTypeId; + this.columnSettings = columnSettings; + } + + @SuppressWarnings("deprecation") + @Override + public DisplaySettings update(DisplaySettings displaySettings) + { + displaySettings.getColumnSettings().put(displayTypeId, columnSettings); + return displaySettings; + } + + @Override + public String toString() + { + return "update of column settings for: " + displayTypeId; + } +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/displaysettings/IDisplaySettingsUpdate.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/displaysettings/IDisplaySettingsUpdate.java new file mode 100644 index 00000000000..2ed5cea0ce4 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/displaysettings/IDisplaySettingsUpdate.java @@ -0,0 +1,31 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings; + +import java.io.Serializable; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DisplaySettings; + +/** + * @author pkupczyk + */ +public interface IDisplaySettingsUpdate extends Serializable +{ + + public DisplaySettings update(DisplaySettings displaySettings); + +} diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/clientnonjs/DisplaySettingsManagerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/clientnonjs/DisplaySettingsManagerTest.java index ba0f81d5325..91640c2ca31 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/clientnonjs/DisplaySettingsManagerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/clientnonjs/DisplaySettingsManagerTest.java @@ -35,11 +35,12 @@ import com.extjs.gxt.ui.client.widget.grid.ColumnModel; import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.DisplaySettingsManager; import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.DisplaySettingsManager.GridDisplaySettings; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.DisplaySettingsManager.IDelayedUpdater; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.DisplaySettingsManager.IDisplaySettingsDelayedUpdater; import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.IDisplaySettingsGetter; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ColumnSetting; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DisplaySettings; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.WebClientConfiguration; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings.IDisplaySettingsUpdate; /** * @author Franz-Josef Elmer @@ -81,7 +82,7 @@ public class DisplaySettingsManagerTest extends AssertJUnit private Mockery context; - private IDelayedUpdater updater; + private IDisplaySettingsDelayedUpdater updater; private IDisplaySettingsGetter grid; @@ -97,7 +98,7 @@ public class DisplaySettingsManagerTest extends AssertJUnit public void setUp() { context = new Mockery(); - updater = context.mock(IDelayedUpdater.class); + updater = context.mock(IDisplaySettingsDelayedUpdater.class); grid = context.mock(IDisplaySettingsGetter.class); displaySettings = new DisplaySettings(); webClientConfiguration = new WebClientConfiguration(); @@ -266,7 +267,8 @@ public class DisplaySettingsManagerTest extends AssertJUnit allowing(grid).getSortState(); will(returnValue(null)); - one(updater).executeDelayed(with(any(Integer.class))); + one(updater).executeDelayed(with(any(IDisplaySettingsUpdate.class)), + with(any(Integer.class))); } }); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientServiceTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientServiceTest.java index ad857582c1f..7d39f646fdd 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientServiceTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientServiceTest.java @@ -73,6 +73,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Vocabulary; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.builders.DataSetBuilder; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.displaysettings.AllDisplaySettingsUpdate; import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.DataStorePE; import ch.systemsx.cisd.openbis.generic.shared.dto.FileFormatTypePE; @@ -552,7 +553,7 @@ public final class CommonClientServiceTest extends AbstractClientServiceTest one(commonServer).saveDisplaySettings(SESSION_TOKEN, displaySettings, 20); } }); - commonClientService.updateDisplaySettings(displaySettings); + commonClientService.updateDisplaySettings(new AllDisplaySettingsUpdate(displaySettings)); context.assertIsSatisfied(); } -- GitLab