From 654cf03ae286a23a0cda186cf06604f70ca8fb9b Mon Sep 17 00:00:00 2001
From: felmer <felmer>
Date: Mon, 5 Sep 2011 06:43:03 +0000
Subject: [PATCH] show not more than 5 entities per entity kind in column
 'Entities' of the trash can view

SVN: 22772
---
 .../server/resultset/DeletionsProvider.java   | 20 +++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/DeletionsProvider.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/DeletionsProvider.java
index 6ebb3551322..97e5d5ab11f 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/DeletionsProvider.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/DeletionsProvider.java
@@ -17,8 +17,8 @@
 package ch.systemsx.cisd.openbis.generic.client.web.server.resultset;
 
 import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.DeletionGridColumnIDs.DELETER;
-import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.DeletionGridColumnIDs.ENTITIES;
 import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.DeletionGridColumnIDs.DELETION_DATE;
+import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.DeletionGridColumnIDs.ENTITIES;
 import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.DeletionGridColumnIDs.REASON;
 
 import java.util.List;
@@ -37,6 +37,8 @@ import ch.systemsx.cisd.openbis.generic.shared.util.TypedTableModelBuilder;
  */
 public class DeletionsProvider extends AbstractCommonTableModelProvider<Deletion>
 {
+    private static final int MAX_NUMBER = 5;
+
     public DeletionsProvider(ICommonServer commonServer, String sessionToken)
     {
         super(commonServer, sessionToken);
@@ -92,19 +94,29 @@ public class DeletionsProvider extends AbstractCommonTableModelProvider<Deletion
         }
         return builder.toString();
     }
-    
+
     private String createList(List<IEntityInformationHolderWithProperties> deletedEntities,
             EntityKind entityKind)
     {
         StringBuilder builder = new StringBuilder();
+        int count = 0;
         for (IEntityInformationHolderWithProperties entity : deletedEntities)
         {
             if (entity.getEntityKind() == entityKind)
             {
-                builder.append("  ").append(entity.getIdentifier()).append(" (");
-                builder.append(entity.getEntityType().getCode()).append(")\n");
+                if (count < MAX_NUMBER)
+                {
+                    builder.append("  ").append(entity.getIdentifier()).append(" (");
+                    builder.append(entity.getEntityType().getCode()).append(")\n");
+                }
+                count++;
             }
         }
+        int numberOfAdditionalEntities = count - MAX_NUMBER;
+        if (numberOfAdditionalEntities > 0)
+        {
+            builder.append("  and ").append(numberOfAdditionalEntities).append(" more");
+        }
         return builder.toString();
     }
 
-- 
GitLab