diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java index 04b47ec0b1f5a1098ba2c5821088d82f44313fc4..ad586b95b58d4af61b50ac84e15f5f201d2a3c1c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java @@ -184,7 +184,7 @@ public abstract class Dict public static final String BUTTON_SHOW_DETAILS = "button_show_details"; - public static final String BUTTON_EXPORT_TABLE = "button_exportTable"; + public static final String BUTTON_EXPORT_TABLE = "button_export_visible"; public static final String BUTTON_LOGIN_LABEL = "login_buttonLabel"; @@ -192,14 +192,6 @@ public abstract class Dict public static final String BUTTON_HOME_LABEL = "home_buttonLabel"; - public static final String EXPORT_ALL_COLUMNS = "export_all_columns"; - - public static final String EXPORT_VISIBLE_COLUMNS = "export_visible_columns"; - - public static final String TOOLTIP_EXPORT_ALL_COLUMNS = "tooltip_export_all_columns"; - - public static final String TOOLTIP_EXPORT_VISIBLE_COLUMNS = "tooltip_export_visible_columns"; - // // LoginWidget // diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/TypedTableGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/TypedTableGrid.java index c4ea1a2fdc7fee89dddccb0459dd387c41e8ab44..8dea63b03418006d5036c7c898071ea2955936af 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/TypedTableGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/TypedTableGrid.java @@ -123,6 +123,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IC import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IDisplayTypeIDProvider; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IDisposableComponent; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.PendingFetchManager; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.TableExportType; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.expressions.filter.FilterToolbar; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.listener.OpenEntityDetailsTabHelper; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.listener.OpenEntityEditorTabClickListener; @@ -1191,10 +1192,17 @@ public abstract class TypedTableGrid<T extends Serializable> extends LayoutConta final TypedTableGrid<T> delegate = this; return new IBrowserGridActionInvoker() { + @Override - public void export(boolean allColumns) + public boolean supportsExportForUpdate() { - delegate.export(allColumns); + return delegate.supportsExportForUpdate(); + } + + @Override + public void export(TableExportType type) + { + delegate.export(type); } @Override @@ -1231,6 +1239,11 @@ public abstract class TypedTableGrid<T extends Serializable> extends LayoutConta }; } + protected boolean supportsExportForUpdate() + { + return false; + } + protected void showFiltersBar() { // always show filters under modifications @@ -1791,6 +1804,11 @@ public abstract class TypedTableGrid<T extends Serializable> extends LayoutConta } } + protected EntityKind getEntityKindOrNull() + { + return null; + } + private IDataRefreshCallback createRefreshCallback( IDataRefreshCallback externalRefreshCallbackOrNull) { @@ -1876,9 +1894,9 @@ public abstract class TypedTableGrid<T extends Serializable> extends LayoutConta * * @param allColumns whether all columns should be exported */ - private void export(boolean allColumns) + private void export(TableExportType type) { - export(allColumns, new ExportEntitiesCallback(viewContext)); + export(type, new ExportEntitiesCallback(viewContext)); } /** @@ -1902,10 +1920,10 @@ public abstract class TypedTableGrid<T extends Serializable> extends LayoutConta } // @Private - for tests - public final void export(boolean allColumns, final AbstractAsyncCallback<String> callback) + public final void export(TableExportType type, final AbstractAsyncCallback<String> callback) { final TableExportCriteria<TableModelRowWithObject<T>> exportCriteria = - createTableExportCriteria(allColumns); + createTableExportCriteria(type); prepareExportEntities(exportCriteria, callback); } @@ -1913,23 +1931,26 @@ public abstract class TypedTableGrid<T extends Serializable> extends LayoutConta // for visible columns protected final TableExportCriteria<TableModelRowWithObject<T>> createTableExportCriteria() { - return createTableExportCriteria(false); + return createTableExportCriteria(TableExportType.VISIBLE); } private final TableExportCriteria<TableModelRowWithObject<T>> createTableExportCriteria( - boolean allColumns) + TableExportType type) { assert columnDefinitions != null : "refresh before exporting!"; assert resultSetKeyOrNull != null : "refresh before exporting, resultSetKey is null!"; final List<IColumnDefinition<TableModelRowWithObject<T>>> columnDefs = - allColumns ? new ArrayList<IColumnDefinition<TableModelRowWithObject<T>>>( - columnDefinitions) : getVisibleColumns(columnDefinitions); + TableExportType.VISIBLE.equals(type) ? getVisibleColumns(columnDefinitions) + : new ArrayList<IColumnDefinition<TableModelRowWithObject<T>>>( + columnDefinitions); SortInfo sortInfo = getGridSortInfo(); + EntityKind entityKindForUpdateOrNull = + TableExportType.FOR_UPDATE.equals(type) ? getEntityKindOrNull() : null; final TableExportCriteria<TableModelRowWithObject<T>> exportCriteria = new TableExportCriteria<TableModelRowWithObject<T>>(resultSetKeyOrNull, sortInfo, - filterToolbar.getFilters(), columnDefs, columnDefinitions, - getGridDisplayTypeID()); + filterToolbar.getFilters(), entityKindForUpdateOrNull, columnDefs, + columnDefinitions, getGridDisplayTypeID()); return exportCriteria; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/AbstractExternalDataGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/AbstractExternalDataGrid.java index ee03c2f7d1f985e7ada2c69ba1fb1891fb281c63..15ebc1980dec7510d33b765548f9267ac4a579e0 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/AbstractExternalDataGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/AbstractExternalDataGrid.java @@ -49,9 +49,11 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.listene import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedActionWithResult; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.TextToolItem; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.CommonGridColumnIDs; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DefaultResultSetConfig; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DisplayedOrSelectedDatasetCriteria; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ExternalDataGridColumnIDs; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TableExportCriteria; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TypedTableResultSet; import ch.systemsx.cisd.openbis.generic.shared.basic.DatasetImageOverviewUtilities; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind.ObjectKind; @@ -108,6 +110,21 @@ public abstract class AbstractExternalDataGrid extends AbstractEntityGrid<Extern }); } + @Override + protected boolean supportsExportForUpdate() + { + return true; + } + + @Override + protected void listTableRows( + DefaultResultSetConfig<String, TableModelRowWithObject<ExternalData>> resultSetConfig, + AbstractAsyncCallback<TypedTableResultSet<ExternalData>> callback) + { + // TODO Auto-generated method stub + + } + // adds show, show-details and invalidate buttons protected void extendBottomToolbar() { @@ -181,7 +198,7 @@ public abstract class AbstractExternalDataGrid extends AbstractEntityGrid<Extern */ private ICriteriaProvider<PropertyTypesCriteria> createCriteriaProvider() { - final EntityKind entityKind = getEntityKind(); + final EntityKind entityKind = getEntityKindOrNull(); return new PropertyTypesCriteriaProvider(viewContext, entityKind) { @Override @@ -373,7 +390,7 @@ public abstract class AbstractExternalDataGrid extends AbstractEntityGrid<Extern } @Override - protected EntityKind getEntityKind() + protected EntityKind getEntityKindOrNull() { return EntityKind.DATA_SET; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetTypeGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetTypeGrid.java index b99bedf17509d894f2611d56038b7e8e5e648386..5d0fa118f8409c0714f221ab8f5fd9bd5c96171b 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetTypeGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetTypeGrid.java @@ -85,7 +85,7 @@ public class DataSetTypeGrid extends AbstractEntityTypeGrid<DataSetType> } @Override - protected EntityKind getEntityKind() + protected EntityKind getEntityKindOrNull() { return EntityKind.DATA_SET; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/entity_type/AbstractEntityTypeGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/entity_type/AbstractEntityTypeGrid.java index 8b4db03e2af5012db9ed7eb408cf9de9310a6810..a778a85f46a4c130547c08bbf71faf7dd3fef252 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/entity_type/AbstractEntityTypeGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/entity_type/AbstractEntityTypeGrid.java @@ -56,8 +56,6 @@ abstract public class AbstractEntityTypeGrid<T extends EntityType> extends Typed { protected IDelegatedAction postRegistrationCallback; - abstract protected EntityKind getEntityKind(); - abstract protected void register(T entityType, AsyncCallback<Void> registrationCallback); protected AbstractEntityTypeGrid(IViewContext<ICommonClientServiceAsync> viewContext, @@ -73,14 +71,14 @@ abstract public class AbstractEntityTypeGrid<T extends EntityType> extends Typed @Override public String getGridDisplayTypeID() { - return createGridDisplayTypeID("-" + getEntityKind().toString()); + return createGridDisplayTypeID("-" + getEntityKindOrNull().toString()); } private void extendBottomToolbar() { addEntityOperationsLabel(); - final EntityKind entityKind = getEntityKind(); + final EntityKind entityKind = getEntityKindOrNull(); addButton(new TextToolItem(viewContext.getMessage(Dict.ADD_NEW_TYPE_BUTTON), new SelectionListener<ButtonEvent>() { @@ -97,7 +95,8 @@ abstract public class AbstractEntityTypeGrid<T extends EntityType> extends Typed { @Override - public void invoke(BaseEntityModel<TableModelRowWithObject<T>> selectedItem, + public void invoke( + BaseEntityModel<TableModelRowWithObject<T>> selectedItem, boolean keyPressed) { T entityType = selectedItem.getBaseObject().getObjectOrNull(); @@ -115,7 +114,7 @@ abstract public class AbstractEntityTypeGrid<T extends EntityType> extends Typed protected void deleteEntityTypes(List<String> types, AsyncCallback<Void> callback) { - viewContext.getCommonService().deleteEntityTypes(getEntityKind(), types, callback); + viewContext.getCommonService().deleteEntityTypes(getEntityKindOrNull(), types, callback); } private Button createDeleteButton(final IViewContext<ICommonClientServiceAsync> context) @@ -238,7 +237,7 @@ abstract public class AbstractEntityTypeGrid<T extends EntityType> extends Typed { return Arrays.asList(EntityTypeGridColumnIDs.CODE); } - + @Override public DatabaseModificationKind[] getRelevantModifications() { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentBrowserGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentBrowserGrid.java index 187f3451d0ebb82298ab30c91600c45427a583b3..9faac3ad7ca5e455f907dffbeac5a7cec9408e29 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentBrowserGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentBrowserGrid.java @@ -173,6 +173,12 @@ public class ExperimentBrowserGrid extends AbstractEntityGrid<Experiment> setId(BROWSER_ID); } + @Override + protected boolean supportsExportForUpdate() + { + return true; + } + private void linkProject() { registerListenerAndLinkGenerator(ExperimentBrowserGridColumnIDs.PROJECT, @@ -389,7 +395,7 @@ public class ExperimentBrowserGrid extends AbstractEntityGrid<Experiment> } @Override - protected EntityKind getEntityKind() + protected EntityKind getEntityKindOrNull() { return EntityKind.EXPERIMENT; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentTypeGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentTypeGrid.java index 5599055654a12b3741f6e260d10135f1beb71aaa..344f8a1f8b4f448f88ac15b13aebcb3fb8c9d972 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentTypeGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentTypeGrid.java @@ -78,7 +78,7 @@ public class ExperimentTypeGrid extends AbstractEntityTypeGrid<ExperimentType> } @Override - protected EntityKind getEntityKind() + protected EntityKind getEntityKindOrNull() { return EntityKind.EXPERIMENT; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractEntityGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractEntityGrid.java index 9167dc537c00cbb551159b0f581ce32db9c3a7c5..64d3fd36ac0c9a2a09696f7462db87696c8ab7db 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractEntityGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractEntityGrid.java @@ -60,8 +60,6 @@ public abstract class AbstractEntityGrid<E extends IEntityInformationHolderWithP super(viewContext, browserId, displayTypeIDGenerator); } - protected abstract EntityKind getEntityKind(); - @Override protected boolean isEditable(BaseEntityModel<TableModelRowWithObject<E>> model, String columnID) { @@ -83,7 +81,7 @@ public abstract class AbstractEntityGrid<E extends IEntityInformationHolderWithP protected void applyModifications(BaseEntityModel<TableModelRowWithObject<E>> model, List<IModification> modifications) { - final EntityKind entityKind = getEntityKind(); + final EntityKind entityKind = getEntityKindOrNull(); final TechId entityId = new TechId(model.getBaseObject().getId()); final EntityPropertyUpdates updates = new EntityPropertyUpdates(entityKind, entityId); for (IModification modification : modifications) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/BrowserGridPagingToolBar.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/BrowserGridPagingToolBar.java index e5ad449fb1d32af8ee2de003f51e021f29671fa4..72274baba03f8222fa2d1a020b5d33c491d5cf99 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/BrowserGridPagingToolBar.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/BrowserGridPagingToolBar.java @@ -18,8 +18,11 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import com.extjs.gxt.ui.client.data.LoadEvent; @@ -328,7 +331,7 @@ public final class BrowserGridPagingToolBar extends PagingToolBar @Override public void componentSelected(ButtonEvent ce) { - invoker.export(false); + invoker.export(TableExportType.VISIBLE); } }); return button; @@ -336,11 +339,12 @@ public final class BrowserGridPagingToolBar extends PagingToolBar private static class ExportButtonMenu extends SplitButton { - private final IMessageProvider messageProvider; + private static final String TOOLTIP_EXPORT_PREFIX = "tooltip_export_"; - private final CheckMenuItem exportVisibleColumnsMenuItem; + private final Map<TableExportType, CheckMenuItem> exportMenuItems = + new HashMap<TableExportType, CheckMenuItem>(); - private final CheckMenuItem exportAllColumnsMenuItem; + private final IMessageProvider messageProvider; public ExportButtonMenu(final IMessageProvider messageProvider, final IBrowserGridActionInvoker invoker) @@ -349,65 +353,69 @@ public final class BrowserGridPagingToolBar extends PagingToolBar this.messageProvider = messageProvider; final Menu exportMenu = new Menu(); - exportVisibleColumnsMenuItem = - new CheckMenuItem(messageProvider.getMessage(Dict.EXPORT_VISIBLE_COLUMNS)); - exportAllColumnsMenuItem = - new CheckMenuItem(messageProvider.getMessage(Dict.EXPORT_ALL_COLUMNS)); - - exportVisibleColumnsMenuItem.setToolTip(messageProvider - .getMessage(Dict.TOOLTIP_EXPORT_VISIBLE_COLUMNS)); - exportAllColumnsMenuItem.setToolTip(messageProvider - .getMessage(Dict.TOOLTIP_EXPORT_ALL_COLUMNS)); - - exportVisibleColumnsMenuItem.setGroup("exportType"); - exportAllColumnsMenuItem.setGroup("exportType"); - - exportMenu.add(exportVisibleColumnsMenuItem); - exportMenu.add(exportAllColumnsMenuItem); - - setMenu(exportMenu); - - addSelectionListener(new SelectionListener<ButtonEvent>() - { - @Override - public void componentSelected(ButtonEvent be) - { - invoker.export(isExportAllColumns()); - } - }); SelectionListener<MenuEvent> menuEventListener = new SelectionListener<MenuEvent>() { @Override public void componentSelected(MenuEvent ce) { - boolean isExportAllColumns = isExportAllColumns(); - invoker.export(isExportAllColumns); - setText(messageProvider.getMessage(Dict.BUTTON_EXPORT_TABLE) - + (isExportAllColumns ? " All" : "")); + TableExportType selectedType = getSelectedType(); + invoker.export(selectedType); + setText(messageProvider.getMessage("button_export_" + + selectedType.toString().toLowerCase())); updateTooltip(); } - }; - exportVisibleColumnsMenuItem.addSelectionListener(menuEventListener); - exportAllColumnsMenuItem.addSelectionListener(menuEventListener); + Set<TableExportType> types = + new HashSet<TableExportType>(Arrays.asList(TableExportType.values())); + if (invoker.supportsExportForUpdate() == false) + { + types.remove(TableExportType.FOR_UPDATE); + } + for (TableExportType exportType : types) + { + String typeAsString = exportType.toString().toLowerCase(); + CheckMenuItem exportMenuItem = + new CheckMenuItem(messageProvider.getMessage("export_" + typeAsString)); + exportMenuItem.setToolTip(messageProvider.getMessage(TOOLTIP_EXPORT_PREFIX + + typeAsString)); + exportMenuItem.setGroup("exportType"); + exportMenuItem.addSelectionListener(menuEventListener); + exportMenuItems.put(exportType, exportMenuItem); + exportMenu.add(exportMenuItem); + } + setMenu(exportMenu); + exportMenuItems.get(TableExportType.VISIBLE).setChecked(true); + addSelectionListener(new SelectionListener<ButtonEvent>() + { + @Override + public void componentSelected(ButtonEvent be) + { + invoker.export(getSelectedType()); + } + }); - // select export visible columns by default - exportVisibleColumnsMenuItem.setChecked(true); } - private boolean isExportAllColumns() + private TableExportType getSelectedType() { - return exportAllColumnsMenuItem.isChecked(); + Set<Entry<TableExportType, CheckMenuItem>> entrySet = exportMenuItems.entrySet(); + for (Entry<TableExportType, CheckMenuItem> entry : entrySet) + { + if (entry.getValue().isChecked()) + { + return entry.getKey(); + } + } + return TableExportType.VISIBLE; } private void updateTooltip() { - String enabledButtonMessageKey = - isExportAllColumns() ? Dict.TOOLTIP_EXPORT_ALL_COLUMNS - : Dict.TOOLTIP_EXPORT_VISIBLE_COLUMNS; - String title = messageProvider.getMessage(enabledButtonMessageKey); - GWTUtils.setToolTip(this, title); + GWTUtils.setToolTip( + ExportButtonMenu.this, + messageProvider.getMessage(TOOLTIP_EXPORT_PREFIX + + getSelectedType().toString().toLowerCase())); } @Override diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/IBrowserGridActionInvoker.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/IBrowserGridActionInvoker.java index 77c0809b0a34a01a11212848fe07a2dadc9ab3f3..d1a6e730169e484e99c8af54f6277baf15035d76 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/IBrowserGridActionInvoker.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/IBrowserGridActionInvoker.java @@ -5,7 +5,9 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid; */ public interface IBrowserGridActionInvoker { - void export(boolean allColumns); + boolean supportsExportForUpdate(); + + void export(TableExportType type); void refresh(); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/TableExportType.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/TableExportType.java new file mode 100644 index 0000000000000000000000000000000000000000..9729eb49ea90de3fcadb64403c643017ef2d9a85 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/TableExportType.java @@ -0,0 +1,27 @@ +/* + * 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.client.web.client.application.ui.grid; + +/** + * Enumeration of possible table export types. + * + * @author Franz-Josef Elmer + */ +public enum TableExportType +{ + VISIBLE, ALL, FOR_UPDATE; +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGrid.java index 3dab47b71c98771615848242c0f1bcd206cc59f3..f904649646fcd54f65a6c60c9d296e5c2ca6bf90 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGrid.java @@ -31,6 +31,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework. import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.TypedTableGrid; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IBrowserGridActionInvoker; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IDisposableComponent; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.TableExportType; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DefaultResultSetConfig; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ResultSetFetchConfig; @@ -208,6 +209,12 @@ public class ManagedPropertyGrid extends TypedTableGrid<ReportRowModel> return new IBrowserGridActionInvoker() { + @Override + public boolean supportsExportForUpdate() + { + return false; + } + @Override public void toggleFilters(boolean show) { @@ -221,9 +228,9 @@ public class ManagedPropertyGrid extends TypedTableGrid<ReportRowModel> } @Override - public void export(boolean allColumns) + public void export(TableExportType type) { - delegate.export(allColumns); + delegate.export(type); } @Override diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/material/MaterialBrowserGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/material/MaterialBrowserGrid.java index 48961953748e862aecbe214fb4cdb383e8ad3f8c..a6730f7c1bc1c1e3281488a328a447dea3ba3363 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/material/MaterialBrowserGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/material/MaterialBrowserGrid.java @@ -327,7 +327,7 @@ public class MaterialBrowserGrid extends AbstractEntityGrid<Material> } @Override - protected EntityKind getEntityKind() + protected EntityKind getEntityKindOrNull() { return EntityKind.MATERIAL; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/material/MaterialTypeGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/material/MaterialTypeGrid.java index db9f10073c4f66af7d3992f9771bae68c03004a9..322dd40fca4af48f8d96d7dd5dffbee183808715 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/material/MaterialTypeGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/material/MaterialTypeGrid.java @@ -78,7 +78,7 @@ public class MaterialTypeGrid extends AbstractEntityTypeGrid<MaterialType> } @Override - protected EntityKind getEntityKind() + protected EntityKind getEntityKindOrNull() { return EntityKind.MATERIAL; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserGrid.java index e39848020f230b2462b0f888b23d7a21c25501a4..606bf4e35aa149b4055b01f4df962aaba8c83384 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserGrid.java @@ -385,6 +385,12 @@ public class SampleBrowserGrid extends AbstractEntityGrid<Sample> linkProject(); } + @Override + protected boolean supportsExportForUpdate() + { + return true; + } + @Override public String getGridDisplayTypeID() { @@ -459,7 +465,7 @@ public class SampleBrowserGrid extends AbstractEntityGrid<Sample> } @Override - protected EntityKind getEntityKind() + protected EntityKind getEntityKindOrNull() { return EntityKind.SAMPLE; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleTypeGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleTypeGrid.java index 1aec99f38aafb7298cdd156ea742fbacd185d1c3..0e40afdd667883db596bd2c36ec08a3aeb0858ed 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleTypeGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleTypeGrid.java @@ -96,7 +96,7 @@ public class SampleTypeGrid extends AbstractEntityTypeGrid<SampleType> } @Override - protected EntityKind getEntityKind() + protected EntityKind getEntityKindOrNull() { return EntityKind.SAMPLE; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/TableExportCriteria.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/TableExportCriteria.java index 7811768e7a6c1781f5c213f8124d3c670a758c69..2dc8f280ddc1e1e1219c576b86d46b446327afcd 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/TableExportCriteria.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/TableExportCriteria.java @@ -22,6 +22,7 @@ import java.util.Set; import com.google.gwt.user.client.rpc.IsSerializable; import ch.systemsx.cisd.openbis.generic.shared.basic.IColumnDefinition; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SortInfo; /** @@ -40,6 +41,8 @@ public class TableExportCriteria<T/* exported entity */> implements IsSerializab /** @see IResultSetConfig#getFilters() */ private GridFilters<T> filters; + private EntityKind entityKindForUpdateOrNull; + // which columns should be exported private List<IColumnDefinition<T>> columnDefs; @@ -58,17 +61,23 @@ public class TableExportCriteria<T/* exported entity */> implements IsSerializab } public TableExportCriteria(String resultSetKey, SortInfo sortInfo, GridFilters<T> filters, - List<IColumnDefinition<T>> columnDefs, Set<IColumnDefinition<T>> availableColumns, - String gridDisplayId) + EntityKind entityKindForUpdateOrNull, List<IColumnDefinition<T>> columnDefs, + Set<IColumnDefinition<T>> availableColumns, String gridDisplayId) { this.resultSetKey = resultSetKey; this.sortInfo = sortInfo; this.filters = filters; + this.entityKindForUpdateOrNull = entityKindForUpdateOrNull; this.columnDefs = columnDefs; this.availableColumns = availableColumns; this.gridDisplayId = gridDisplayId; } + public EntityKind getEntityKindForUpdateOrNull() + { + return entityKindForUpdateOrNull; + } + /** * Uniquely identifies a result set on the server side. */ 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 4093fadf2a268eec80202b5613cf2cc61798a8db..b117f41d7c6a3d294567d903fce31daf4d6c2d2e 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 @@ -99,6 +99,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.server.resultset.SampleTypePr import ch.systemsx.cisd.openbis.generic.client.web.server.resultset.ScriptProvider; import ch.systemsx.cisd.openbis.generic.client.web.server.resultset.SpacesProvider; import ch.systemsx.cisd.openbis.generic.client.web.server.resultset.TableDataProviderFactory; +import ch.systemsx.cisd.openbis.generic.client.web.server.resultset.TableForUpdateExporter; import ch.systemsx.cisd.openbis.generic.client.web.server.resultset.VocabulariesProvider; import ch.systemsx.cisd.openbis.generic.client.web.server.resultset.VocabularyTermsProvider; import ch.systemsx.cisd.openbis.generic.client.web.server.translator.ResultSetTranslator; @@ -280,6 +281,12 @@ public final class CommonClientService extends AbstractClientService implements getSessionToken(); final TableExportCriteria<T> exportCriteria = getAndRemoveExportCriteria(exportDataKey); final GridRowModels<T> entities = fetchCachedEntities(exportCriteria); + EntityKind entityKindForUpdate = exportCriteria.getEntityKindForUpdateOrNull(); + if (entityKindForUpdate != null) + { + return TableForUpdateExporter.getExportTableForUpdate(entities, entityKindForUpdate, + lineSeparator); + } ITableDataProvider dataProvider = TableDataProviderFactory.createDataProvider(entities, exportCriteria.getColumnDefs()); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/IBasicTableDataProvider.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/IBasicTableDataProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..05fcb94ed1fd4d034dc372eb861bddcfd8271c23 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/IBasicTableDataProvider.java @@ -0,0 +1,40 @@ +/* + * 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.client.web.server; + +import java.util.List; + +/** + * + * + * @author Franz-Josef Elmer + */ +public interface IBasicTableDataProvider +{ + + /** + * Returns all rows. + */ + public List<List<? extends Comparable<?>>> getRows(); + + /** + * Returns a list of column titles. The order is the same as the order of row values returned + * by {@link #getRows()}. + */ + public List<String> getAllColumnTitles(); + +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/ITableDataProvider.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/ITableDataProvider.java index c5a1797db85141f8bd51bc860cb673f66a158d12..21fc9f91d17f72809551d77bd38c312029cd39d7 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/ITableDataProvider.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/ITableDataProvider.java @@ -19,19 +19,16 @@ package ch.systemsx.cisd.openbis.generic.client.web.server.calculator; import java.util.Collection; import java.util.List; +import ch.systemsx.cisd.openbis.generic.client.web.server.IBasicTableDataProvider; + /** * Interface to access table data and meta data. Used by calculator classes. * * @author Franz-Josef Elmer */ -public interface ITableDataProvider +public interface ITableDataProvider extends IBasicTableDataProvider { - /** - * Returns all rows. - */ - public List<List<? extends Comparable<?>>> getRows(); - /** * Returns the value of specified column in the list of specified row values. * @@ -44,12 +41,6 @@ public interface ITableDataProvider */ public Collection<String> getAllColumnIDs(); - /** - * Returns a list of column titles. The order is the same as the order of row values returned - * by {@link #getRows()}. - */ - public List<String> getAllColumnTitles(); - /** * Returns the property of specified key for specified column. */ diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/TableForUpdateExporter.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/TableForUpdateExporter.java new file mode 100644 index 0000000000000000000000000000000000000000..1e7bfd4fd62d636bfe59fdef75905b7df4937e45 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/TableForUpdateExporter.java @@ -0,0 +1,270 @@ +/* + * 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.client.web.server.resultset; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.TreeMap; + +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.GridRowModels; +import ch.systemsx.cisd.openbis.generic.client.web.server.IBasicTableDataProvider; +import ch.systemsx.cisd.openbis.generic.client.web.server.util.TSVRenderer; +import ch.systemsx.cisd.openbis.generic.shared.basic.GridRowModel; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ContainerDataSet; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewDataSet; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewExperiment; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; +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.TypedTableModel; +import ch.systemsx.cisd.openbis.generic.shared.util.TypedTableModelBuilder; + +/** + * @author Franz-Josef Elmer + */ +public class TableForUpdateExporter +{ + + @SuppressWarnings("unchecked") + public static String getExportTableForUpdate(GridRowModels<?> rows, EntityKind entityKind, + String lineSeparator) + { + switch (entityKind) + { + case EXPERIMENT: + return getExperimentTableForUpdate( + (GridRowModels<TableModelRowWithObject<Experiment>>) rows, lineSeparator); + case SAMPLE: + return getSampleTableForUpdate( + (GridRowModels<TableModelRowWithObject<Sample>>) rows, lineSeparator); + case DATA_SET: + return getDataSetTableForUpdate( + (GridRowModels<TableModelRowWithObject<ExternalData>>) rows, lineSeparator); + case MATERIAL: + return "Export of materials for update is currently not supported."; + } + throw new IllegalArgumentException("Unspecified entity kind."); + } + + public static String getExperimentTableForUpdate( + GridRowModels<TableModelRowWithObject<Experiment>> rows, String lineSeparator) + { + TypedTableModelBuilder<Experiment> builder = new TypedTableModelBuilder<Experiment>(); + builder.addColumn(NewExperiment.IDENTIFIER_COLUMN); + builder.addColumn("project"); + for (GridRowModel<TableModelRowWithObject<Experiment>> row : rows) + { + Experiment experiment = row.getOriginalObject().getObjectOrNull(); + builder.addRow(experiment); + builder.column(NewExperiment.IDENTIFIER_COLUMN).addString(experiment.getIdentifier()); + addProperties(builder, experiment.getProperties()); + } + return TSVRenderer.createTable(new Adapter<Experiment>(builder), lineSeparator); + } + + public static String getSampleTableForUpdate( + GridRowModels<TableModelRowWithObject<Sample>> rows, String lineSeparator) + { + Map<String, List<Sample>> samples = new TreeMap<String, List<Sample>>(); + for (GridRowModel<TableModelRowWithObject<Sample>> row : rows) + { + Sample sample = row.getOriginalObject().getObjectOrNull(); + String sampleType = sample.getSampleType().getCode(); + List<Sample> sampleList = samples.get(sampleType); + if (sampleList == null) + { + sampleList = new ArrayList<Sample>(); + samples.put(sampleType, sampleList); + } + sampleList.add(sample); + } + + StringBuilder builder = new StringBuilder(); + Set<Entry<String, List<Sample>>> entrySet = samples.entrySet(); + for (Entry<String, List<Sample>> entry : entrySet) + { + if (samples.size() > 1) + { + builder.append("[").append(entry.getKey()).append("]\n"); + } + builder.append(getTableForSamples(entry, lineSeparator)); + } + return builder.toString(); + } + + private static String getTableForSamples(Map.Entry<String, List<Sample>> entry, + String lineSeparator) + { + TypedTableModelBuilder<Sample> builder = new TypedTableModelBuilder<Sample>(); + builder.addColumn(NewSample.IDENTIFIER_COLUMN); + builder.addColumn(NewSample.CONTAINER); + builder.addColumn(NewSample.PARENTS); + builder.addColumn(NewSample.EXPERIMENT); + List<Sample> samples = entry.getValue(); + Collections.sort(samples, new Comparator<Sample>() + { + @Override + public int compare(Sample s1, Sample s2) + { + return s1.getIdentifier().compareTo(s2.getIdentifier()); + } + }); + for (Sample sample : samples) + { + builder.addRow(sample); + builder.column(NewSample.IDENTIFIER_COLUMN).addString(sample.getIdentifier()); + Sample container = sample.getContainer(); + if (container != null) + { + builder.column(NewSample.CONTAINER).addString(container.getIdentifier()); + } + Set<Sample> parents = sample.getParents(); + if (parents != null && parents.isEmpty() == false) + { + StringBuilder sb = new StringBuilder(); + for (Sample parent : parents) + { + if (sb.length() > 0) + { + sb.append(","); + } + sb.append(parent.getIdentifier()); + } + builder.column(NewSample.PARENTS).addString(sb.toString()); + } + Experiment experiment = sample.getExperiment(); + if (experiment != null) + { + builder.column(NewSample.EXPERIMENT).addString(experiment.getIdentifier()); + } + addProperties(builder, sample.getProperties()); + } + return TSVRenderer.createTable(new Adapter<Sample>(builder), lineSeparator); + } + + public static String getDataSetTableForUpdate( + GridRowModels<TableModelRowWithObject<ExternalData>> rows, String lineSeparator) + { + TypedTableModelBuilder<ExternalData> builder = new TypedTableModelBuilder<ExternalData>(); + builder.addColumn(NewDataSet.CODE); + builder.addColumn(NewDataSet.CONTAINER); + builder.addColumn(NewDataSet.PARENTS); + builder.addColumn(NewDataSet.EXPERIMENT); + builder.addColumn(NewDataSet.SAMPLE); + for (GridRowModel<TableModelRowWithObject<ExternalData>> row : rows) + { + ExternalData dataSet = row.getOriginalObject().getObjectOrNull(); + builder.addRow(dataSet); + builder.column(NewDataSet.CODE).addString(dataSet.getCode()); + ContainerDataSet container = dataSet.tryGetContainer(); + if (container != null) + { + builder.column(NewDataSet.CONTAINER).addString(container.getCode()); + } + Collection<ExternalData> parents = dataSet.getParents(); + if (parents != null && parents.isEmpty() == false) + { + StringBuilder sb = new StringBuilder(); + for (ExternalData parent : parents) + { + if (sb.length() > 0) + { + sb.append(","); + } + sb.append(parent.getCode()); + } + builder.column(NewDataSet.PARENTS).addString(sb.toString()); + } + builder.column(NewDataSet.EXPERIMENT) + .addString(dataSet.getExperiment().getIdentifier()); + Sample sample = dataSet.getSample(); + if (sample != null) + { + builder.column(NewDataSet.SAMPLE).addString(sample.getIdentifier()); + } + addProperties(builder, dataSet.getProperties()); + } + return TSVRenderer.createTable(new Adapter<ExternalData>(builder), lineSeparator); + } + + private static void addProperties(TypedTableModelBuilder<?> builder, + List<IEntityProperty> properties) + { + builder.columnGroup("").addPropertiesForUpdate(filterUpdatableProperties(properties)); + } + + private static List<IEntityProperty> filterUpdatableProperties(List<IEntityProperty> properties) + { + List<IEntityProperty> filteredProperties = new ArrayList<IEntityProperty>(); + for (IEntityProperty property : properties) + { + if (property.isDynamic() == false && property.isDynamic() == false) + { + filteredProperties.add(property); + } + } + return filteredProperties; + } + + private static final class Adapter<T extends Serializable> implements IBasicTableDataProvider + { + private TypedTableModel<T> model; + + Adapter(TypedTableModelBuilder<T> builder) + { + model = builder.getModel(); + } + + @Override + public List<String> getAllColumnTitles() + { + List<TableModelColumnHeader> headers = model.getHeader(); + List<String> titles = new ArrayList<String>(); + for (TableModelColumnHeader header : headers) + { + titles.add(header.getId()); + } + return titles; + } + + @Override + public List<List<? extends Comparable<?>>> getRows() + { + List<TableModelRowWithObject<T>> rows = model.getRows(); + List<List<? extends Comparable<?>>> result = + new ArrayList<List<? extends Comparable<?>>>(); + for (TableModelRowWithObject<T> row : rows) + { + result.add(row.getValues()); + } + return result; + } + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/TSVRenderer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/TSVRenderer.java index 329c7cce429607ee5cdb760c6dce3fb8f9ad2330..40bd940a010400fe728c1a32cb2f801efe85e887 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/TSVRenderer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/TSVRenderer.java @@ -20,7 +20,7 @@ import java.util.List; import org.apache.commons.lang.StringUtils; -import ch.systemsx.cisd.openbis.generic.client.web.server.calculator.ITableDataProvider; +import ch.systemsx.cisd.openbis.generic.client.web.server.IBasicTableDataProvider; /** * Creates list of lines with tab separated columns; @@ -37,12 +37,12 @@ public class TSVRenderer * @param dataProvider Provider of headers and values * @param lineSeparator character used as a lineSeparator separator */ - public static String createTable(ITableDataProvider dataProvider, String lineSeparator) + public static String createTable(IBasicTableDataProvider dataProvider, String lineSeparator) { return new TSVRenderer(lineSeparator).createTable(dataProvider); } - private String createTable(ITableDataProvider dataProvider) + private String createTable(IBasicTableDataProvider dataProvider) { StringBuffer sb = new StringBuffer(); appendHeader(dataProvider.getAllColumnTitles(), sb); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/DataSetTable.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/DataSetTable.java index 7583a25e526d11856903d1131bb058bc7968e29c..4027668bb93ef657dd4a2420608a9112d66ba23c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/DataSetTable.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/DataSetTable.java @@ -832,6 +832,8 @@ public final class DataSetTable extends AbstractDataSetBusinessObject implements archivingAction.execute(sessionToken, service, descriptions, userEmailOrNull); } catch (Exception e) { + operationLog.error("Operation failed for the following data sets failed: " + + CollectionUtils.abbreviate(Code.extractCodes(datasets), 10), e); clearPendingStatuses(datasets, iterator, archivingAction.getStatusToRestoreOnFailure()); throw UserFailureException diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/util/IColumnGroup.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/util/IColumnGroup.java index eb3c3e7ed6e248fb87dde1d385f448b3761321c7..11cfb08d6fa0969eb2471696c7131f410fd4cbc6 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/util/IColumnGroup.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/util/IColumnGroup.java @@ -80,5 +80,12 @@ public interface IColumnGroup * type code to determine the column id. The property type label is used as column title. */ public void addProperties(String idPrefix, Collection<IEntityProperty> properties); - + + /** + * Adds all specified properties such that the table can be used for batch update. The original + * property type code determines the column id. For vocabulary terms only the code is added as + * value. + */ + public void addPropertiesForUpdate(Collection<IEntityProperty> properties); + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/util/TypedTableModelBuilder.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/util/TypedTableModelBuilder.java index 13b825c2b7fbcdd3b8953e465903ffcca9649024..9aa34fd06c3ec42215d68cd7a8de6901a90f2d8b 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/util/TypedTableModelBuilder.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/util/TypedTableModelBuilder.java @@ -177,7 +177,7 @@ public class TypedTableModelBuilder<T extends Serializable> { for (EntityTypePropertyType<?> propertyType : propertyTypes) { - IColumn column = addColumn(idPrefix, propertyType.getPropertyType()); + IColumn column = addColumn(idPrefix, propertyType.getPropertyType(), false); column.property(entityType.getCode(), Boolean.TRUE.toString()); setEditableFlag(column, propertyType.getPropertyType()); setVocabulary(column, propertyType.getPropertyType().getVocabulary()); @@ -196,14 +196,18 @@ public class TypedTableModelBuilder<T extends Serializable> { for (PropertyType propertyType : propertyTypes) { - addColumn(idPrefix, propertyType); + addColumn(idPrefix, propertyType, false); } } - private IColumn addColumn(String idPrefix, PropertyType propertyType) + private IColumn addColumn(String idPrefix, PropertyType propertyType, + boolean useOriginalPropertyTypeCode) { String label = propertyType.getLabel(); - String code = idPrefix + TableCellUtil.getPropertyTypeCode(propertyType); + String code = + idPrefix + + (useOriginalPropertyTypeCode ? propertyType.getCode() : TableCellUtil + .getPropertyTypeCode(propertyType)); DataTypeCode dataType = propertyType.getDataType().getCode(); IColumn column = column(code).withTitle(label).withDataType(dataType); return column; @@ -217,21 +221,35 @@ public class TypedTableModelBuilder<T extends Serializable> @Override public void addProperties(String idPrefix, Collection<IEntityProperty> properties) + { + addProperties(idPrefix, properties, false); + } + + @Override + public void addPropertiesForUpdate(Collection<IEntityProperty> properties) + { + addProperties("", properties, true); + } + + private void addProperties(String idPrefix, Collection<IEntityProperty> properties, + boolean forUpdate) { for (IEntityProperty property : properties) { PropertyType propertyType = property.getPropertyType(); - IColumn column = addColumn(idPrefix, propertyType); + IColumn column = addColumn(idPrefix, propertyType, forUpdate); DataTypeCode dataType = propertyType.getDataType().getCode(); ISerializableComparable value; switch (dataType) { case MATERIAL: - Material material = property.getMaterial(); if (material == null) // if not yet calculated dynamic property { value = new StringTableCell(""); + } else if (forUpdate) + { + value = new StringTableCell(material.getIdentifier()); } else { value = @@ -244,13 +262,22 @@ public class TypedTableModelBuilder<T extends Serializable> if (vocabularyTerm == null) // if not yet calculated dynamic property { value = new StringTableCell(""); + } else if (forUpdate) + { + value = new StringTableCell(vocabularyTerm.getCode()); } else { value = new VocabularyTermTableCell(vocabularyTerm); } break; default: - value = DataTypeUtils.convertTo(dataType, property.tryGetAsString()); + if (forUpdate) + { + value = new StringTableCell(property.tryGetAsString()); + } else + { + value = DataTypeUtils.convertTo(dataType, property.tryGetAsString()); + } } setEditableFlag(column, propertyType); setDynamicFlag(column, property); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js index 332eaf5b166397353dbb1f4c1ed21ff21dfe00a5..3aa5e2ab661811f09c6247970cd33735c82c031c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js @@ -160,7 +160,6 @@ var common = { button_submit: "Submit", button_refresh: "Refresh", button_show: "Show", - button_exportTable: "Export", button_show_details: "Show Details", button_browse: "Browse", button_view: "View", @@ -191,10 +190,15 @@ var common = { tooltip_vocabulary_managed_internally: "This operation is not available for a vocabulary that is managed internally.", - export_all_columns: "All Columns", - export_visible_columns: "Visible Columns", - tooltip_export_all_columns: "Export the table with all (visible and hidden) columns to an Excel file", - tooltip_export_visible_columns: "Export the table with visible columns to an Excel file", + export_all: "All Columns", + export_visible: "Visible Columns", + export_for_update: "For Batch Update", + tooltip_export_all: "Export the table with all (visible and hidden) columns to an Excel file", + tooltip_export_visible: "Export the table with visible columns to an Excel file", + tooltip_export_for_update: "Export the table such that it can be used for Batch Update", + button_export_visible: "Export", + button_export_all: "Export All", + button_export_for_update: "Export For Update", // // LoginWidget diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/ExportSamplesTestCommand.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/ExportSamplesTestCommand.java index 44d8443bd0ed9a747c32f93cff4ce5a87f5f0dff..d3b4e6a7d69740679e2a92debe53e485dc830126 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/ExportSamplesTestCommand.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/ExportSamplesTestCommand.java @@ -23,6 +23,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAs import ch.systemsx.cisd.openbis.generic.client.web.client.application.Client; import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.AbstractEntityGrid; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.TableExportType; import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.AbstractDefaultTestCommand; import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.GWTTestUtil; import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.ITestCommand; @@ -61,7 +62,8 @@ public class ExportSamplesTestCommand extends AbstractDefaultTestCommand // we do not create view context earlier (e.g. in the class constructor), because we have to // wait until client is loaded and viewContext is available. IViewContext<ICommonClientServiceAsync> viewContext = getViewContext(); - sampleBrowserGrid.export(false, new PrepareExportSamplesCallbackTest(viewContext)); + sampleBrowserGrid.export(TableExportType.VISIBLE, new PrepareExportSamplesCallbackTest( + viewContext)); } private IViewContext<ICommonClientServiceAsync> getViewContext()