From 5d2a5e01d3e1992dc232aa15b409f90138513e17 Mon Sep 17 00:00:00 2001
From: kaloyane <kaloyane>
Date: Mon, 16 May 2011 11:49:15 +0000
Subject: [PATCH] [LMS-2104]: added a "container" column to the DataSetTypeGrid
 + a "container" checkbox in the data set registration dialog

SVN: 21309
---
 .../client/web/client/application/Dict.java       |  4 ++++
 .../application/ui/data/DataSetTypeGrid.java      | 15 +++++++++++++++
 .../web/client/dto/DataSetTypeGridColumnIDs.java  |  3 +++
 .../web/server/resultset/DataSetTypeProvider.java |  5 +++++
 .../generic/server/business/bo/EntityTypeBO.java  |  1 +
 .../shared/translator/SimpleDataSetHelper.java    |  2 ++
 .../cisd/openbis/public/common-dictionary.js      |  9 ++++-----
 7 files changed, 34 insertions(+), 5 deletions(-)

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 16d4dcd98f1..7a5fe71dc8c 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
@@ -1070,6 +1070,10 @@ public abstract class Dict
 
     public static final String DATA_VIEW = "data_view";
 
+    public static final String CONTAINER_TYPE = "container_type";
+
+    public static final String CONTAINER_TYPE_TOOLTIP = "container_type_tooltip";
+
     public static final String MAIN_DATA_SET_PATH = "main_data_set_path";
 
     public static final String MAIN_DATA_SET_PATH_TOOLTIP = "main_data_set_path_tooltip";
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 bb70d96c9e6..83fd9f88d04 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
@@ -29,6 +29,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.help.HelpP
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.TypedTableGrid;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.entity_type.AbstractEntityTypeGrid;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.entity_type.AddTypeDialog;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.field.CheckBoxField;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.field.DescriptionField;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IDisposableComponent;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.AbstractRegistrationDialog;
@@ -166,7 +167,12 @@ public class DataSetTypeGrid extends AbstractEntityTypeGrid<DataSetType>
 
                 private TextField<String> mainDataSetPathField;
 
+                private CheckBoxField containerTypeField;
+
                 {
+                    containerTypeField = createContainerField();
+                    addField(containerTypeField);
+                    
                     mainDataSetPatternField = createMainDataSetPatternField();
                     addField(mainDataSetPatternField);
 
@@ -183,6 +189,7 @@ public class DataSetTypeGrid extends AbstractEntityTypeGrid<DataSetType>
                 {
                     dataSetType.setMainDataSetPath(mainDataSetPathField.getValue());
                     dataSetType.setMainDataSetPattern(mainDataSetPatternField.getValue());
+                    dataSetType.setContainerType(containerTypeField.getValue());
                     DataSetTypeGrid.this.register(dataSetType, registrationCallback);
                 }
 
@@ -214,4 +221,12 @@ public class DataSetTypeGrid extends AbstractEntityTypeGrid<DataSetType>
         mainDataSetPathField.setEmptyText(viewContext.getMessage(Dict.MAIN_DATA_SET_PATH_EXAMPLE));
         return mainDataSetPathField;
     }
+
+    private CheckBoxField createContainerField()
+    {
+        String label = viewContext.getMessage(Dict.CONTAINER_TYPE);
+        CheckBoxField containerTypeField = new CheckBoxField(label, false);
+        GWTUtils.setToolTip(containerTypeField, viewContext.getMessage(Dict.CONTAINER_TYPE_TOOLTIP));
+        return containerTypeField;
+    }
 }
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/DataSetTypeGridColumnIDs.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/DataSetTypeGridColumnIDs.java
index c66fef36d32..4d513fe3dae 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/DataSetTypeGridColumnIDs.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/DataSetTypeGridColumnIDs.java
@@ -24,5 +24,8 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.dto;
 public class DataSetTypeGridColumnIDs extends EntityTypeGridColumnIDs
 {
     public static final String MAIN_DATA_SET_PATH = "MAIN_DATA_SET_PATH";
+
     public static final String MAIN_DATA_SET_PATTERN = "MAIN_DATA_SET_PATTERN";
+
+    public static final String CONTAINER_TYPE = "CONTAINER_TYPE";
 }
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/DataSetTypeProvider.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/DataSetTypeProvider.java
index 42e4b541822..6b05105f81f 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/DataSetTypeProvider.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/DataSetTypeProvider.java
@@ -16,12 +16,14 @@
 
 package ch.systemsx.cisd.openbis.generic.client.web.server.resultset;
 
+import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.DataSetTypeGridColumnIDs.CONTAINER_TYPE;
 import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.DataSetTypeGridColumnIDs.MAIN_DATA_SET_PATH;
 import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.DataSetTypeGridColumnIDs.MAIN_DATA_SET_PATTERN;
 
 import java.util.List;
 
 import ch.systemsx.cisd.openbis.generic.shared.ICommonServer;
+import ch.systemsx.cisd.openbis.generic.shared.basic.SimpleYesNoRenderer;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType;
 import ch.systemsx.cisd.openbis.generic.shared.util.TypedTableModelBuilder;
 
@@ -46,6 +48,7 @@ public class DataSetTypeProvider extends EntityTypeProvider<DataSetType>
     @Override
     protected void addMoreColumns(TypedTableModelBuilder<DataSetType> builder)
     {
+        builder.addColumn(CONTAINER_TYPE);
         builder.addColumn(MAIN_DATA_SET_PATH).hideByDefault();
         builder.addColumn(MAIN_DATA_SET_PATTERN).hideByDefault();
     }
@@ -53,6 +56,8 @@ public class DataSetTypeProvider extends EntityTypeProvider<DataSetType>
     @Override
     protected void addMoreCells(TypedTableModelBuilder<DataSetType> builder, DataSetType type)
     {
+        builder.column(CONTAINER_TYPE)
+                .addString(SimpleYesNoRenderer.render(type.isContainerType()));
         builder.column(MAIN_DATA_SET_PATH).addString(type.getMainDataSetPath());
         builder.column(MAIN_DATA_SET_PATTERN).addString(type.getMainDataSetPattern());
     }
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/EntityTypeBO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/EntityTypeBO.java
index 8c8cc1a4823..981e09aff45 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/EntityTypeBO.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/EntityTypeBO.java
@@ -109,6 +109,7 @@ public final class EntityTypeBO extends AbstractBusinessObject implements IEntit
         dataSetTypePE.setDatabaseInstance(getHomeDatabaseInstance());
         dataSetTypePE.setMainDataSetPath(entityType.getMainDataSetPath());
         dataSetTypePE.setMainDataSetPattern(entityType.getMainDataSetPattern());
+        dataSetTypePE.setContainerType(entityType.isContainerType());
 
         this.entityKind = EntityKind.DATA_SET;
         this.entityTypePE = dataSetTypePE;
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/SimpleDataSetHelper.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/SimpleDataSetHelper.java
index 6b69599010e..9cfc5f5545b 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/SimpleDataSetHelper.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/SimpleDataSetHelper.java
@@ -48,6 +48,7 @@ public class SimpleDataSetHelper
         return result;
     }
 
+    // TODO KE: use DataPE ?
     private static SimpleDataSetInformationDTO translate(ExternalDataPE data)
     {
         SimpleDataSetInformationDTO result = new SimpleDataSetInformationDTO();
@@ -77,6 +78,7 @@ public class SimpleDataSetHelper
         return result;
     }
     
+    // TODO KE: will this work ?
     public static SimpleDataSetInformationDTO translate(DatasetDescription datasetDescription)
     {
         SimpleDataSetInformationDTO result = new SimpleDataSetInformationDTO();
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 15c98b42d0d..c26a1989c75 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
@@ -46,6 +46,8 @@ var common = {
   delete_progress_message: "Deleting {0}(s)...",
   add_attachment: "Add attachment...",
   data_view: "Data View",
+  container_type: "Container",
+  container_type_tooltip: "Container data sets do not contain any data in the data store itself. They can be thought as of grouping of other container or non-container data sets.",
   main_data_set_path: "Main Data Set Path",
   main_data_set_path_tooltip: "The path (relative to the top directory of a data set) that will be used as a starting point of 'main data set' lookup.\nExample: 'original/images/'",
   main_data_set_path_example: "for example: original/images/",
@@ -187,6 +189,7 @@ var common = {
   space: "Space",
   groups: "Spaces",
   project: "Project",
+  container_dataset: "Container",
   experiment: "Experiment",
   experiment_identifier: "Experiment Identifier",
   generated_from: "Parent {0}",
@@ -215,9 +218,7 @@ var common = {
   //
   // DataSet Browser
   //
-  
-  container_dataset: "Container",
-  order_in_container: "Order in Container",
+  
   children_datasets: "Children",
   no_datasets_selected: "No Data Sets were selected.",
   datasets_from_different_stores_selected: "Data Sets from different Data Stores were selected, so no operation can be performed on all of them.",
@@ -532,8 +533,6 @@ var common = {
   //
   parents: "Parents",
   parents_empty: "List of parent data set codes separated by commas (\",\") or one code per line.",
-  contained_data_sets: "Contains Data Sets",
-  contained_data_sets_empty: "List of contained data set codes separated by commas (\",\") or one code per line.",
   
  //
  // Vocabulary Browser
-- 
GitLab