diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/Row.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/Row.java index 2f46ca99bc007241d2b3eafa9ab6369430d37961..78e51adfe6bce8451a8c1a63c8d1307cc128efb3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/Row.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/Row.java @@ -69,15 +69,17 @@ public final class Row<T> } return columnDefinition.getComparableValue(row); } - + /** * Returns all column definitions which have a property with specified key. * + * @param propertyKeyOrNull The key of the property. If <code>null</code> all column definitions + * are returned. * @return an empty list if no column definition found. */ - public List<ColumnDefinition> colDefs(String propertyKey) + public List<ColumnDefinition> colDefs(String propertyKeyOrNull) { - List<ColumnDefinition> definitions = definitionsByProperties.get(propertyKey); + List<ColumnDefinition> definitions = definitionsByProperties.get(propertyKeyOrNull); if (definitions == null) { definitions = new ArrayList<ColumnDefinition>(); @@ -85,13 +87,12 @@ public final class Row<T> for (Entry<String, IColumnDefinition<T>> entry : entries) { IColumnDefinition<T> columnDefinition = entry.getValue(); - String property = columnDefinition.tryToGetProperty(propertyKey); - if (property != null) + if (propertyKeyOrNull == null || columnDefinition.tryToGetProperty(propertyKeyOrNull) != null) { definitions.add(new ColumnDefinition(columnDefinition)); } } - definitionsByProperties.put(propertyKey, definitions); + definitionsByProperties.put(propertyKeyOrNull, definitions); } return Collections.unmodifiableList(definitions); } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/RowTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/RowTest.java index e1ff6eb9105e04198a8d141699483763c83c39b1..e23c84612de09f6aee8768ecb67c94775433d276 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/RowTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/RowTest.java @@ -175,6 +175,17 @@ public class RowTest extends AssertJUnit context.assertIsSatisfied(); } + @Test + public void testColDefsWithNullArgument() + { + List<ColumnDefinition> defs = row.colDefs(null); + + assertEquals(2, defs.size()); + assertUnmodifiable(defs); + + context.assertIsSatisfied(); + } + @Test public void testCols() {