From 9ffb116072d716ee3bfdc97e4a3e5e42c94f18e7 Mon Sep 17 00:00:00 2001
From: felmer <felmer>
Date: Mon, 27 Jun 2011 13:11:12 +0000
Subject: [PATCH] LMS-2138 listAnalysisProcedure implemented. MatLab:
 listDataSets extended.

SVN: 21847
---
 .../api/v1/impl/OpenbisServiceFacade.java     |  2 +-
 .../api/v1/filter/AndDataSetFilter.java       | 64 +++++++++++++++
 .../shared/api/v1/filter/IDataSetFilter.java  | 33 ++++++++
 .../filter/PropertiesBasedDataSetFilter.java  | 77 +++++++++++++++++++
 .../api/v1/filter/TypeBasedDataSetFilter.java | 55 +++++++++++++
 .../shared/api/v1/dto/DataSetBuilder.java     | 59 ++++++++++++++
 .../PropertiesBasedDataSetFilterTest.java     | 55 +++++++++++++
 .../v1/filter/TypeBasedDataSetFilterTest.java | 40 ++++++++++
 screening/source/java/OpenBISScreeningML.java | 55 ++++++++++++-
 .../v1/IScreeningOpenbisServiceFacade.java    | 42 +++++++++-
 .../api/v1/ScreeningClientApiTester.java      | 24 ++++++
 .../api/v1/ScreeningOpenbisServiceFacade.java | 63 ++++++++++++---
 .../shared/basic/dto/ScreeningConstants.java  |  2 +
 .../java/OpenBISScreeningMLTest.java          | 55 ++++++++++++-
 .../v1/ScreeningOpenbisServiceFacadeTest.java | 61 +++++++++++++--
 15 files changed, 660 insertions(+), 27 deletions(-)
 create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/AndDataSetFilter.java
 create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/IDataSetFilter.java
 create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/PropertiesBasedDataSetFilter.java
 create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/TypeBasedDataSetFilter.java
 create mode 100644 openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataSetBuilder.java
 create mode 100644 openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/PropertiesBasedDataSetFilterTest.java
 create mode 100644 openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/TypeBasedDataSetFilterTest.java

diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/v1/impl/OpenbisServiceFacade.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/v1/impl/OpenbisServiceFacade.java
index ef575db4f20..a34e70e8c72 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/v1/impl/OpenbisServiceFacade.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/v1/impl/OpenbisServiceFacade.java
@@ -93,7 +93,7 @@ public class OpenbisServiceFacade implements IOpenbisServiceFacade
     /**
      * ctor.
      */
-    OpenbisServiceFacade(String sessionToken, IGeneralInformationService service,
+    public OpenbisServiceFacade(String sessionToken, IGeneralInformationService service,
             IDssComponent dssComponent)
     {
         this.sessionToken = sessionToken;
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/AndDataSetFilter.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/AndDataSetFilter.java
new file mode 100644
index 00000000000..4e34ca0537b
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/AndDataSetFilter.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011 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.api.v1.filter;
+
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet;
+
+/**
+ * Combining filters by logical AND.
+ *
+ * @author Franz-Josef Elmer
+ */
+public class AndDataSetFilter implements IDataSetFilter
+{
+    private final IDataSetFilter[] dataSetFilters;
+
+    public AndDataSetFilter(IDataSetFilter... dataSetFilters)
+    {
+        this.dataSetFilters = dataSetFilters;
+    }
+
+    public boolean pass(DataSet dataSet)
+    {
+        for (IDataSetFilter filter : dataSetFilters)
+        {
+            if (filter.pass(dataSet) == false)
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public String toString()
+    {
+        StringBuilder builder = new StringBuilder();
+        for (IDataSetFilter filter : dataSetFilters)
+        {
+            if (builder.length() > 0)
+            {
+                builder.append(" AND ");
+            }
+            builder.append(filter);
+        }
+        return builder.toString();
+    }
+    
+    
+
+}
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/IDataSetFilter.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/IDataSetFilter.java
new file mode 100644
index 00000000000..49a3f931d7b
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/IDataSetFilter.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011 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.api.v1.filter;
+
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet;
+
+
+/**
+ * Interface filters of {@link DataSet} instances.
+ *
+ * @author Franz-Josef Elmer
+ */
+public interface IDataSetFilter
+{
+    /**
+     * Returns <code>true</code> if the specified data set passes the filter.
+     */
+    public boolean pass(DataSet dataSet);
+}
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/PropertiesBasedDataSetFilter.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/PropertiesBasedDataSetFilter.java
new file mode 100644
index 00000000000..ccceb1521ee
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/PropertiesBasedDataSetFilter.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2011 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.api.v1.filter;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet;
+
+
+/**
+ * Filter based on data set properties.
+ *
+ * @author Franz-Josef Elmer
+ */
+public class PropertiesBasedDataSetFilter implements IDataSetFilter
+{
+    private final Map<String, String> map;
+
+    public PropertiesBasedDataSetFilter(Map<String, String> properties)
+    {
+        map = properties;
+    }
+
+    public boolean pass(DataSet dataSet)
+    {
+        HashMap<String, String> properties = dataSet.getProperties();
+        Set<Entry<String, String>> entrySet = map.entrySet();
+        for (Entry<String, String> entry : entrySet)
+        {
+            String key = entry.getKey();
+            String value = entry.getValue();
+            if (value.equals(properties.get(key)) == false)
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public String toString()
+    {
+        Set<Entry<String, String>> entrySet = map.entrySet();
+        List<Entry<String, String>> sortedEntries = new ArrayList<Entry<String, String>>(entrySet);
+        Collections.sort(sortedEntries, new Comparator<Entry<String, String>>()
+            {
+                public int compare(Entry<String, String> o1, Entry<String, String> o2)
+                {
+                    return o1.getKey().compareTo(o2.getKey());
+                }
+            });
+        return "Properties:" + sortedEntries;
+    }
+
+    
+}
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/TypeBasedDataSetFilter.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/TypeBasedDataSetFilter.java
new file mode 100644
index 00000000000..ecd97dca034
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/TypeBasedDataSetFilter.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2011 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.api.v1.filter;
+
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet;
+
+
+/**
+ * Filter which will be passed only by data sets with a data set type code matching a certain
+ * regular expression.
+ * 
+ * @author Franz-Josef Elmer
+ */
+public class TypeBasedDataSetFilter implements IDataSetFilter
+{
+    private final String datasetTypeCodePattern;
+
+    /**
+     * Creates an instance for the specified regular expression.
+     */
+    public TypeBasedDataSetFilter(String datasetTypeCodePattern)
+    {
+        this.datasetTypeCodePattern = datasetTypeCodePattern;
+    }
+
+    /**
+     * Return <code>true</code> if the data set type code of the specified data set matches the
+     * regular expression provided as constructor argument.
+     */
+    public boolean pass(DataSet dataSet)
+    {
+        return dataSet.getDataSetTypeCode().matches(datasetTypeCodePattern);
+    }
+
+    @Override
+    public String toString()
+    {
+        return "Type:" + datasetTypeCodePattern;
+    }
+}
+
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataSetBuilder.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataSetBuilder.java
new file mode 100644
index 00000000000..0882b12f8bf
--- /dev/null
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataSetBuilder.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011 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.api.v1.dto;
+
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet.DataSetInitializer;
+
+/**
+ * Builder of {@link DataSet} instances.
+ *
+ * @author Franz-Josef Elmer
+ */
+public class DataSetBuilder
+{
+    private DataSetInitializer initializer = new DataSetInitializer();
+    
+    public DataSet getDataSet()
+    {
+        return new DataSet(initializer);
+    }
+    
+    public DataSetBuilder code(String code)
+    {
+        initializer.setCode(code);
+        return this;
+    }
+    
+    public DataSetBuilder type(String type)
+    {
+        initializer.setDataSetTypeCode(type);
+        return this;
+    }
+    
+    public DataSetBuilder experiment(String experimentIdentifier)
+    {
+        initializer.setExperimentIdentifier(experimentIdentifier);
+        return this;
+    }
+    
+    public DataSetBuilder property(String key, String value)
+    {
+        initializer.getProperties().put(key, value);
+        return this;
+    }
+    
+}
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/PropertiesBasedDataSetFilterTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/PropertiesBasedDataSetFilterTest.java
new file mode 100644
index 00000000000..d4a0ee46a4e
--- /dev/null
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/PropertiesBasedDataSetFilterTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2011 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.api.v1.filter;
+
+import java.util.HashMap;
+
+import org.testng.AssertJUnit;
+import org.testng.annotations.Test;
+
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetBuilder;
+
+/**
+ * 
+ *
+ * @author Franz-Josef Elmer
+ */
+public class PropertiesBasedDataSetFilterTest extends AssertJUnit
+{
+    @Test
+    public void testNoProperties()
+    {
+        IDataSetFilter filter = new PropertiesBasedDataSetFilter(new HashMap<String, String>());
+        
+        DataSetBuilder builder = new DataSetBuilder().code("A").type("A").experiment("E");
+        assertEquals(true, filter.pass(builder.getDataSet()));
+        assertEquals(true, filter.pass(builder.property("a", "alpha").getDataSet()));
+    }
+    
+    @Test
+    public void testWithProperties()
+    {
+        HashMap<String, String> properties = new HashMap<String, String>();
+        properties.put("a", "alpha");
+        PropertiesBasedDataSetFilter filter = new PropertiesBasedDataSetFilter(properties);
+        
+        DataSetBuilder builder = new DataSetBuilder().code("A").type("A").experiment("E");
+        assertEquals(false, filter.pass(builder.getDataSet()));
+        assertEquals(true, filter.pass(builder.property("a", "alpha").getDataSet()));
+        assertEquals(false, filter.pass(builder.property("a", "beta").getDataSet()));
+    }
+}
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/TypeBasedDataSetFilterTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/TypeBasedDataSetFilterTest.java
new file mode 100644
index 00000000000..6013c718040
--- /dev/null
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/filter/TypeBasedDataSetFilterTest.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2011 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.api.v1.filter;
+
+import org.testng.AssertJUnit;
+import org.testng.annotations.Test;
+
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetBuilder;
+
+/**
+ * 
+ *
+ * @author Franz-Josef Elmer
+ */
+public class TypeBasedDataSetFilterTest extends AssertJUnit
+{
+    @Test
+    public void test()
+    {
+        IDataSetFilter filter = new TypeBasedDataSetFilter(".*ANA");
+        DataSetBuilder builder = new DataSetBuilder().code("ds1").experiment("/S/P/E");
+        assertEquals(true, filter.pass(builder.type("MY-ANA").getDataSet()));
+        assertEquals(false, filter.pass(builder.type("MY-ANA2").getDataSet()));
+        assertEquals(false, filter.pass(builder.type("HELLO").getDataSet()));
+    }
+}
diff --git a/screening/source/java/OpenBISScreeningML.java b/screening/source/java/OpenBISScreeningML.java
index d0857889e8c..ebce71368e0 100644
--- a/screening/source/java/OpenBISScreeningML.java
+++ b/screening/source/java/OpenBISScreeningML.java
@@ -37,6 +37,9 @@ import ch.systemsx.cisd.openbis.dss.client.api.v1.IDataSetDss;
 import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.FileInfoDssDTO;
 import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetMetadataDTO;
 import ch.systemsx.cisd.openbis.generic.client.cli.Login;
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.filter.AndDataSetFilter;
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.filter.PropertiesBasedDataSetFilter;
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.filter.TypeBasedDataSetFilter;
 import ch.systemsx.cisd.openbis.plugin.screening.client.api.v1.IScreeningOpenbisServiceFacade;
 import ch.systemsx.cisd.openbis.plugin.screening.client.api.v1.IScreeningOpenbisServiceFacadeFactory;
 import ch.systemsx.cisd.openbis.plugin.screening.client.api.v1.ScreeningOpenbisServiceFacade.IImageOutputStreamProvider;
@@ -685,7 +688,7 @@ public class OpenBISScreeningML
         }
         return result;
     }
-
+    
     /**
      * Loads data sets for specified plate code. For each data set the path to the root of the data
      * set is returned. If it is possible the path points directly into the data set store. No data
@@ -716,11 +719,53 @@ public class OpenBISScreeningML
      */
     public static Object[][] loadDataSets(String augmentedPlateCode, String dataSetTypeCodePattern,
             String overrideStoreRootPathOrNull)
+    {
+        return loadDataSets(augmentedPlateCode, dataSetTypeCodePattern, new Object[0][],
+                overrideStoreRootPathOrNull);
+    }
+
+    /**
+     * Loads data sets for specified plate code. For each data set the path to the root of the data
+     * set is returned. If it is possible the path points directly into the data set store. No data
+     * is copied. Otherwise the data is retrieved from the data store server.<br>
+     * If the same dataset is loaded for the second time in one session it will be immediately
+     * returned from the local cache.
+     * <p>
+     * Matlab example:
+     * 
+     * <pre>
+     * % Load all data sets of plate P005 in space SPACE
+     * properties = {'ANALYSIS_PROCEDURE' AX87}
+     * dsinfo = OpenBISScreeningML.loadDataSets('/SPACE/P005', 'HCS_ANALYSIS_CELL_FEATURES_CC_MAT', properties, '/mount/openbis-store')
+     * % Get the data set codes
+     * dsinfo(:,1)
+     * % Get root path of first data set (assuming there is at least one)
+     * dsginfo(1,2)
+     * </pre>
+     * 
+     * @param augmentedPlateCode The augmented plate code.
+     * @param dataSetTypeCodePattern only data sets of the type which matches the specified pattern
+     *            will be returned. To fetch all data sets specify ".*".
+     * @param properties Only data set with specified property values will be returned. This is a
+     *            two dimensional array where the first column contains the property codes and the
+     *            second column the corresponding property values.
+     * @return Each row contains information about one data set:
+     * @param overrideStoreRootPathOrNull A path, in the context of the local file system mounts, to
+     *            the DSS' store root. If null, paths are returned in the context of the DSS' file
+     *            system mounts.
+     *         <p>
+     *         <code>{ data set code, data set root path  }</code>
+     */
+    public static Object[][] loadDataSets(String augmentedPlateCode,
+            final String dataSetTypeCodePattern, final Object[][] properties,
+            String overrideStoreRootPathOrNull)
     {
         checkLoggedIn();
         Plate plateIdentifier = getPlate(augmentedPlateCode);
-
-        List<IDataSetDss> dataSets = openbis.getDataSets(plateIdentifier, dataSetTypeCodePattern);
+        List<IDataSetDss> dataSets =
+                openbis.getDataSets(plateIdentifier, new AndDataSetFilter(new TypeBasedDataSetFilter(
+                        dataSetTypeCodePattern), new PropertiesBasedDataSetFilter(
+                        createMap(properties))));
         Object[][] result = new Object[dataSets.size()][];
         try
         {
@@ -805,7 +850,9 @@ public class OpenBISScreeningML
         checkLoggedIn();
         Plate plateIdentifier = getPlate(augmentedPlateCode);
 
-        List<IDataSetDss> dataSets = openbis.getDataSets(plateIdentifier, dataSetTypeCodePattern);
+        List<IDataSetDss> dataSets =
+                openbis.getDataSets(plateIdentifier, new TypeBasedDataSetFilter(
+                        dataSetTypeCodePattern));
         Object[][][] result = new Object[dataSets.size()][][];
         for (int i = 0; i < dataSets.size(); i++)
         {
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/IScreeningOpenbisServiceFacade.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/IScreeningOpenbisServiceFacade.java
index 40e9a0c8b98..c8749648af5 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/IScreeningOpenbisServiceFacade.java
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/IScreeningOpenbisServiceFacade.java
@@ -25,6 +25,8 @@ import ch.systemsx.cisd.base.image.IImageTransformerFactory;
 import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException;
 import ch.systemsx.cisd.openbis.dss.client.api.v1.IDataSetDss;
 import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetMetadataDTO;
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.filter.IDataSetFilter;
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.filter.TypeBasedDataSetFilter;
 import ch.systemsx.cisd.openbis.plugin.screening.client.api.v1.ScreeningOpenbisServiceFacade.IImageOutputStreamProvider;
 import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.ExperimentIdentifier;
 import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureVectorDataset;
@@ -62,7 +64,7 @@ public interface IScreeningOpenbisServiceFacade
 
     /** Closes connection with the server. After calling this method this facade cannot be used. */
     public void logout();
-
+    
     /**
      * Removes all images loaded by {@link #loadImageWellCaching(PlateImageReference, ImageSize)}
      * and {@link #loadThumbnailImageWellCaching(PlateImageReference)} from the image cache, thus
@@ -162,18 +164,32 @@ public interface IScreeningOpenbisServiceFacade
     public void updateWellProperties(WellIdentifier wellIdentifier, Map<String, String> properties);
 
     /**
-     * Get proxies to the data sets owned by specified well.
+     * Gets proxies to the data sets owned by specified well.
      * 
+     * @deprecated use {@link #getDataSets(WellIdentifier, IDataSetFilter)} with
+     *             {@link TypeBasedDataSetFilter}.
      * @param datasetTypeCodePattern only datasets of the type which matche the specified pattern
      *            will be returned. To fetch all datasets specify ".*".
      * @throws IllegalStateException Thrown if the user has not yet been authenticated.
      * @throws EnvironmentFailureException Thrown in cases where it is not possible to connect to
      *             the server.
      */
+    @Deprecated
     public List<IDataSetDss> getDataSets(WellIdentifier wellIdentifier,
             String datasetTypeCodePattern) throws IllegalStateException,
             EnvironmentFailureException;
     
+    /**
+     * Gets proxies to the data sets owned by specified well and passing specified filter..
+     * 
+     * @throws IllegalStateException Thrown if the user has not yet been authenticated.
+     * @throws EnvironmentFailureException Thrown in cases where it is not possible to connect to
+     *             the server.
+     */
+    public List<IDataSetDss> getDataSets(WellIdentifier wellIdentifier,
+            IDataSetFilter dataSetFilter) throws IllegalStateException,
+            EnvironmentFailureException;
+    
     public IDataSetDss getDataSet(String dataSetCode) throws IllegalStateException,
             EnvironmentFailureException;
 
@@ -195,18 +211,32 @@ public interface IScreeningOpenbisServiceFacade
             EnvironmentFailureException, IOException;
 
     /**
-     * Get proxies to the data sets of the specified type owned by specified plate.
+     * Gets proxies to the data sets of the specified type owned by specified plate.
      * 
+     * @deprecated use {@link #getDataSets(PlateIdentifier, IDataSetFilter)} with
+     *             {@link TypeBasedDataSetFilter}.
      * @param datasetTypeCodePattern only datasets of the type which matche the specified pattern
      *            will be returned. To fetch all datasets specify ".*".
      * @throws IllegalStateException Thrown if the user has not yet been authenticated.
      * @throws EnvironmentFailureException Thrown in cases where it is not possible to connect to
      *             the server.
      */
+    @Deprecated
     public List<IDataSetDss> getDataSets(PlateIdentifier plateIdentifier,
             String datasetTypeCodePattern) throws IllegalStateException,
             EnvironmentFailureException;
 
+    /**
+     * Gets proxies to the data sets owned by specified plate and passing specified filter.
+     * 
+     * @throws IllegalStateException Thrown if the user has not yet been authenticated.
+     * @throws EnvironmentFailureException Thrown in cases where it is not possible to connect to
+     *             the server.
+     */
+    public List<IDataSetDss> getDataSets(PlateIdentifier plateIdentifier,
+            IDataSetFilter dataSetFilter) throws IllegalStateException,
+            EnvironmentFailureException;
+    
     /**
      * Upload a new data set to the DSS for a plate.
      * 
@@ -575,5 +605,11 @@ public interface IScreeningOpenbisServiceFacade
     public List<PlateWellMaterialMapping> listPlateMaterialMapping(
             List<? extends PlateIdentifier> plates,
             MaterialTypeIdentifier materialTypeIdentifierOrNull);
+    
+    /**
+     * Returns an alphabetically sorted list of analysis procedure codes of all data sets of the
+     * specified experiment.
+     */
+    public List<String> listAnalysisProcedures(ExperimentIdentifier experimentIdentifier);
 
 }
\ No newline at end of file
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningClientApiTester.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningClientApiTester.java
index a04792d5873..1f6e8468f1d 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningClientApiTester.java
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningClientApiTester.java
@@ -54,6 +54,7 @@ import org.apache.log4j.PropertyConfigurator;
 
 import ch.systemsx.cisd.openbis.dss.client.api.v1.IDataSetDss;
 import ch.systemsx.cisd.openbis.plugin.screening.client.api.v1.ScreeningOpenbisServiceFacade.IImageOutputStreamProvider;
+import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.ExperimentIdentifier;
 import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.IDatasetIdentifier;
 import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.ImageDatasetReference;
 import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.ImageSize;
@@ -163,6 +164,15 @@ public class ScreeningClientApiTester
                         loadOverlays();
                     }
                 });
+            JMenuItem listAnalysisProceduresMenuItem = new JMenuItem("List Analysis Procedures...");
+            callApiMenu.add(listAnalysisProceduresMenuItem);
+            listAnalysisProceduresMenuItem.addActionListener(new ActionListener()
+                {
+                    public void actionPerformed(ActionEvent e)
+                    {
+                        listAnalysisProcedures();
+                    }
+                });
         }
         
         void setUp(String[] args)
@@ -261,6 +271,20 @@ public class ScreeningClientApiTester
             validate(panel);
         }
         
+        private void listAnalysisProcedures()
+        {
+            Form form = new Form(this, "Analysis Procedures for an Experiment");
+            List<ExperimentIdentifier> experiments = facade.listExperiments();
+            JComboBox experimentComboBox =
+                    new JComboBox(experiments.toArray(new ExperimentIdentifier[0]));
+            form.addField("Experiment", experimentComboBox);
+            form.showForm();
+            List<String> analysisProcedures =
+                    facade.listAnalysisProcedures((ExperimentIdentifier) experimentComboBox
+                            .getSelectedItem());
+            JOptionPane.showMessageDialog(this, "Analysis Procedures: " + analysisProcedures);
+        }
+        
         private void loadImagesByDataSetCode()
         {
             Form form = new Form(this, "Parameters for Loading Images by Data Set");
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningOpenbisServiceFacade.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningOpenbisServiceFacade.java
index 54f661b6076..76b665ad1ef 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningOpenbisServiceFacade.java
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningOpenbisServiceFacade.java
@@ -39,6 +39,12 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationChangin
 import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService;
 import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet;
 import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample;
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria;
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause;
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClauseAttribute;
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchSubCriteria;
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.filter.IDataSetFilter;
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.filter.TypeBasedDataSetFilter;
 import ch.systemsx.cisd.openbis.plugin.screening.client.api.v1.WellImageCache.CachedImage;
 import ch.systemsx.cisd.openbis.plugin.screening.client.api.v1.WellImageCache.WellImages;
 import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.IScreeningApiServer;
@@ -63,6 +69,7 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateWellMate
 import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateWellReferenceWithDatasets;
 import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.WellIdentifier;
 import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.WellPosition;
+import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.ScreeningConstants;
 
 /**
  * A client side facade of openBIS and Datastore Server API.
@@ -89,7 +96,7 @@ public class ScreeningOpenbisServiceFacade implements IScreeningOpenbisServiceFa
                 return new DssServiceRpcScreeningHolder(serverUrl);
             }
         };
-
+        
     private final IScreeningApiServer openbisScreeningServer;
 
     private final IGeneralInformationService generalInformationService;
@@ -119,6 +126,7 @@ public class ScreeningOpenbisServiceFacade implements IScreeningOpenbisServiceFa
 
     private IDssServiceFactory dssServiceCache;
 
+
     /**
      * Creates a service facade which communicates with the openBIS server at the specified URL.
      * Authenticates the user.
@@ -243,7 +251,7 @@ public class ScreeningOpenbisServiceFacade implements IScreeningOpenbisServiceFa
         checkASMinimalMinorVersion("logoutScreening");
         openbisScreeningServer.logoutScreening(sessionToken);
     }
-
+    
     public void clearWellImageCache()
     {
         imageCache.clear();
@@ -408,12 +416,16 @@ public class ScreeningOpenbisServiceFacade implements IScreeningOpenbisServiceFa
     public List<IDataSetDss> getDataSets(WellIdentifier wellIdentifier,
             String datasetTypeCodePattern) throws IllegalStateException,
             EnvironmentFailureException
+    {
+        return getDataSets(wellIdentifier, new TypeBasedDataSetFilter(datasetTypeCodePattern));
+    }
+
+    public List<IDataSetDss> getDataSets(WellIdentifier wellIdentifier, IDataSetFilter dataSetFilter)
+            throws IllegalStateException, EnvironmentFailureException
     {
         final Sample wellSample = getWellSample(wellIdentifier);
-        return getDataSets(wellSample, datasetTypeCodePattern);
+        return getDataSets(wellSample, dataSetFilter);
     }
-    
-    
 
     public IDataSetDss getDataSet(String dataSetCode) throws IllegalStateException,
             EnvironmentFailureException
@@ -429,22 +441,28 @@ public class ScreeningOpenbisServiceFacade implements IScreeningOpenbisServiceFa
      *             the server.
      */
     public List<IDataSetDss> getDataSets(PlateIdentifier plateIdentifier,
-            String datasetTypeCodePattern) throws IllegalStateException,
+            final String datasetTypeCodePattern) throws IllegalStateException,
             EnvironmentFailureException
+    {
+        return getDataSets(plateIdentifier, new TypeBasedDataSetFilter(datasetTypeCodePattern));
+    }
+
+    public List<IDataSetDss> getDataSets(PlateIdentifier plateIdentifier,
+            IDataSetFilter dataSetFilter) throws IllegalStateException, EnvironmentFailureException
     {
         checkASMinimalMinorVersion("getPlateSample", PlateIdentifier.class);
         Sample sample = openbisScreeningServer.getPlateSample(sessionToken, plateIdentifier);
-        return getDataSets(sample, datasetTypeCodePattern);
+        return getDataSets(sample, dataSetFilter);
     }
 
-    private List<IDataSetDss> getDataSets(final Sample sample, final String datasetTypeCodePattern)
+    private List<IDataSetDss> getDataSets(final Sample sample, IDataSetFilter filter)
     {
         final List<DataSet> dataSets =
                 generalInformationService.listDataSetsForSample(sessionToken, sample, true);
         final List<IDataSetDss> result = new ArrayList<IDataSetDss>();
         for (DataSet dataSet : dataSets)
         {
-            if (dataSet.getDataSetTypeCode().matches(datasetTypeCodePattern))
+            if (filter.pass(dataSet))
             {
                 result.add(dssComponent.getDataSet(dataSet.getCode()));
             }
@@ -1378,6 +1396,33 @@ public class ScreeningOpenbisServiceFacade implements IScreeningOpenbisServiceFa
                 materialTypeIdentifierOrNull);
     }
 
+    public List<String> listAnalysisProcedures(ExperimentIdentifier experimentIdentifier)
+    {
+        SearchCriteria searchCriteria = new SearchCriteria();
+        SearchCriteria experimentCriteria = new SearchCriteria();
+        experimentCriteria.addMatchClause(MatchClause.createAttributeMatch(
+                MatchClauseAttribute.CODE, experimentIdentifier.getExperimentCode()));
+        experimentCriteria.addMatchClause(MatchClause.createAttributeMatch(
+                MatchClauseAttribute.PROJECT, experimentIdentifier.getProjectCode()));
+        experimentCriteria.addMatchClause(MatchClause.createAttributeMatch(
+                MatchClauseAttribute.SPACE, experimentIdentifier.getSpaceCode()));
+        searchCriteria.addSubCriteria(SearchSubCriteria.createExperimentCriteria(experimentCriteria));
+        List<DataSet> dataSets = generalInformationService.searchForDataSets(sessionToken, searchCriteria);
+        Set<String> procedures = new HashSet<String>();
+        for (DataSet dataSet : dataSets)
+        {
+            HashMap<String, String> properties = dataSet.getProperties();
+            String analysisProcedure = properties.get(ScreeningConstants.ANALYSIS_PROCEDURE);
+            if (analysisProcedure != null)
+            {
+                procedures.add(analysisProcedure);
+            }
+        }
+        ArrayList<String> result = new ArrayList<String>(procedures);
+        Collections.sort(result);
+        return result;
+    }
+    
     // --------- helpers -----------
 
     private static final class WrappedIOException extends RuntimeException
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/basic/dto/ScreeningConstants.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/basic/dto/ScreeningConstants.java
index 14accb1d7b2..492c3c19f02 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/basic/dto/ScreeningConstants.java
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/basic/dto/ScreeningConstants.java
@@ -130,6 +130,8 @@ public class ScreeningConstants
 
     /** Used to import Qiagen siRNA libraries. */
     public static final String LIBRARY_PLUGIN_TYPE_CODE = "LIBRARY";
+    
+    public static final String ANALYSIS_PROCEDURE = "ANALYSIS_PROCEDURE";
 
     // --- !!!!!! It's discouraged to use this constant, try hard not to do that !!!!!!!! ---
 
diff --git a/screening/sourceTest/java/OpenBISScreeningMLTest.java b/screening/sourceTest/java/OpenBISScreeningMLTest.java
index 45961ee6522..9bcc84c3e41 100644
--- a/screening/sourceTest/java/OpenBISScreeningMLTest.java
+++ b/screening/sourceTest/java/OpenBISScreeningMLTest.java
@@ -44,6 +44,7 @@ import ch.systemsx.cisd.openbis.dss.client.api.v1.IDataSetDss;
 import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.FileInfoDssDTO;
 import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetMetadataDTO;
 import ch.systemsx.cisd.openbis.generic.client.cli.Login;
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.filter.IDataSetFilter;
 import ch.systemsx.cisd.openbis.plugin.screening.client.api.v1.IScreeningOpenbisServiceFacade;
 import ch.systemsx.cisd.openbis.plugin.screening.client.api.v1.IScreeningOpenbisServiceFacadeFactory;
 import ch.systemsx.cisd.openbis.plugin.screening.client.api.v1.ScreeningOpenbisServiceFacade.IImageOutputStreamProvider;
@@ -539,10 +540,11 @@ public class OpenBISScreeningMLTest extends AbstractFileSystemTestCase
     @Test
     public void testListDataSetsFiles()
     {
+        final RecordingMatcher<IDataSetFilter> filterMatcher = new RecordingMatcher<IDataSetFilter>();
         context.checking(new Expectations()
             {
                 {
-                    one(openbis).getDataSets(p1, ".*");
+                    one(openbis).getDataSets(with(p1), with(filterMatcher));
                     will(returnValue(Arrays.asList(ds1, ds2)));
                     
                     one(ds1).listFiles("/", true);
@@ -561,7 +563,8 @@ public class OpenBISScreeningMLTest extends AbstractFileSystemTestCase
             });
         
         Object[][][] files = OpenBISScreeningML.listDataSetsFiles(p1.getAugmentedCode(), ".*");
-        
+
+        assertEquals("Type:.*", filterMatcher.recordedObject().toString());
         assertEquals("ds1", files[0][0][0]);
         assertEquals("[a, a/b]", Arrays.asList(files[0][1]).toString());
         assertEquals("ds2", files[1][0][0]);
@@ -600,11 +603,12 @@ public class OpenBISScreeningMLTest extends AbstractFileSystemTestCase
         ds2Folder.mkdirs();
         final String datasetTypePattern = "blablaCode";
         final String mountPoint = "/mount/openbis/store";
+        final RecordingMatcher<IDataSetFilter> filterMatcher = new RecordingMatcher<IDataSetFilter>();
         context.checking(new Expectations()
             {
                 {
-                    one(openbis).getDataSets(new Plate("PLATE-1", "S", "s-1", eId1),
-                            datasetTypePattern);
+                    one(openbis).getDataSets(with(new Plate("PLATE-1", "S", "s-1", eId1)),
+                            with(filterMatcher));
                     will(returnValue(Arrays.asList(ds1, ds2)));
 
                     one(ds1).getCode();
@@ -621,6 +625,7 @@ public class OpenBISScreeningMLTest extends AbstractFileSystemTestCase
         Object[][] result =
                 OpenBISScreeningML.loadDataSets("/S/PLATE-1", datasetTypePattern, mountPoint);
 
+        assertEquals("Type:blablaCode AND Properties:[]", filterMatcher.recordedObject().toString());
         assertEquals("ds-1", result[0][0]);
         assertEquals(ds1Folder.getPath(), result[0][1]);
         assertEquals("ds-2", result[1][0]);
@@ -629,6 +634,48 @@ public class OpenBISScreeningMLTest extends AbstractFileSystemTestCase
         context.assertIsSatisfied();
     }
 
+    @Test
+    public void testLoadDataSetsFilteredOnProperties()
+    {
+        final File dataSetFolder =
+            new File(OpenBISScreeningML.tempDir, OpenBISScreeningML.DATASETS_FOLDER);
+        final File ds1Folder = new File(dataSetFolder, "ds-1");
+        File ds2Folder = new File(dataSetFolder, "ds-2");
+        ds2Folder.mkdirs();
+        final String datasetTypePattern = "blablaCode";
+        final String mountPoint = "/mount/openbis/store";
+        final RecordingMatcher<IDataSetFilter> filterMatcher = new RecordingMatcher<IDataSetFilter>();
+        context.checking(new Expectations()
+        {
+            {
+                one(openbis).getDataSets(with(new Plate("PLATE-1", "S", "s-1", eId1)),
+                        with(filterMatcher));
+                will(returnValue(Arrays.asList(ds1, ds2)));
+                
+                one(ds1).getCode();
+                will(returnValue("ds-1"));
+                
+                one(ds1).getLinkOrCopyOfContents(mountPoint, dataSetFolder);
+                will(returnValue(ds1Folder));
+                
+                one(ds2).getCode();
+                will(returnValue("ds-2"));
+            }
+        });
+        
+        Object[][] properties = new Object[][] {new Object[] {"a", "alpha"}, new Object[] {"b", "beta"}};
+        Object[][] result =
+            OpenBISScreeningML.loadDataSets("/S/PLATE-1", datasetTypePattern, properties, mountPoint);
+        
+        assertEquals("Type:blablaCode AND Properties:[a=alpha, b=beta]", filterMatcher.recordedObject().toString());
+        assertEquals("ds-1", result[0][0]);
+        assertEquals(ds1Folder.getPath(), result[0][1]);
+        assertEquals("ds-2", result[1][0]);
+        assertEquals(ds2Folder.getPath(), result[1][1]);
+        assertEquals(2, result.length);
+        context.assertIsSatisfied();
+    }
+    
     @Test
     public void testUpdateDataSet()
     {
diff --git a/screening/sourceTest/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningOpenbisServiceFacadeTest.java b/screening/sourceTest/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningOpenbisServiceFacadeTest.java
index e2b1b00da0b..c0d4c2fb367 100644
--- a/screening/sourceTest/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningOpenbisServiceFacadeTest.java
+++ b/screening/sourceTest/java/ch/systemsx/cisd/openbis/plugin/screening/client/api/v1/ScreeningOpenbisServiceFacadeTest.java
@@ -54,6 +54,8 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet;
 import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet.DataSetInitializer;
 import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample;
 import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample.SampleInitializer;
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria;
+import ch.systemsx.cisd.openbis.generic.shared.api.v1.filter.IDataSetFilter;
 import ch.systemsx.cisd.openbis.plugin.screening.client.api.v1.ScreeningOpenbisServiceFacade.IImageOutputStreamProvider;
 import ch.systemsx.cisd.openbis.plugin.screening.server.ScreeningServer;
 import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.IScreeningApiServer;
@@ -74,6 +76,7 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateImageRef
 import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.PlateWellReferenceWithDatasets;
 import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.WellIdentifier;
 import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.WellPosition;
+import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.ScreeningConstants;
 
 /**
  * @author Franz-Josef Elmer
@@ -120,7 +123,7 @@ public class ScreeningOpenbisServiceFacadeTest extends AbstractFileSystemTestCas
 
     private IDssServiceFactory dssServiceFactory;
 
-    private ScreeningOpenbisServiceFacade facade;
+    private IScreeningOpenbisServiceFacade facade;
 
     private ImageDatasetReference i1id;
 
@@ -142,6 +145,8 @@ public class ScreeningOpenbisServiceFacadeTest extends AbstractFileSystemTestCas
 
     private IDataSetDss ds1Proxy;
 
+    private IDataSetFilter filter;
+
     @BeforeMethod
     public void beforeMethod()
     {
@@ -152,6 +157,7 @@ public class ScreeningOpenbisServiceFacadeTest extends AbstractFileSystemTestCas
         dssComponent = context.mock(IDssComponent.class);
         ds1Proxy = context.mock(IDataSetDss.class);
         dssServiceFactory = context.mock(IDssServiceFactory.class);
+        filter = context.mock(IDataSetFilter.class);
         i1id = new ImageDatasetReference(DATA_SET1, null, URL1, null, null, null, null, null, null);
         i2id = new ImageDatasetReference(DATA_SET2, null, URL2, null, null, null, null, null, null);
         f1id = context.mock(IFeatureVectorDatasetIdentifier.class, "f1id");
@@ -508,6 +514,42 @@ public class ScreeningOpenbisServiceFacadeTest extends AbstractFileSystemTestCas
 
         context.assertIsSatisfied();
     }
+    
+    @Test
+    public void testListAnalysisProcedures()
+    {
+        final ExperimentIdentifier experimentIdentifier = ExperimentIdentifier.createFromAugmentedCode("/S/P/E");
+        final RecordingMatcher<SearchCriteria> searchCriteriaMatcher = new RecordingMatcher<SearchCriteria>();
+        context.checking(new Expectations()
+            {
+                {
+                    one(generalInformationService).searchForDataSets(with(SESSION_TOKEN),
+                            with(searchCriteriaMatcher));
+                    DataSetInitializer ds1 = new DataSetInitializer();
+                    ds1.setCode("ds1");
+                    ds1.getProperties().put(ScreeningConstants.ANALYSIS_PROCEDURE, "FZ-87");
+                    ds1.setExperimentIdentifier(experimentIdentifier.toString());
+                    ds1.setDataSetTypeCode("my-type");
+                    DataSetInitializer ds2 = new DataSetInitializer();
+                    ds2.setCode("ds2");
+                    ds2.getProperties().put(ScreeningConstants.ANALYSIS_PROCEDURE, "ALPHA-42");
+                    ds2.setExperimentIdentifier(experimentIdentifier.toString());
+                    ds2.setDataSetTypeCode("my-type");
+                    will(returnValue(Arrays.asList(new DataSet(ds1), new DataSet(ds2))));
+                }
+            });
+        
+        List<String> procedures = facade.listAnalysisProcedures(experimentIdentifier);
+        
+        assertEquals("[ALPHA-42, FZ-87]", procedures.toString());
+        assertEquals("SearchCriteria[MATCH_ALL_CLAUSES,[],"
+                + "[SearchSubCriteria[EXPERIMENT,SearchCriteria[MATCH_ALL_CLAUSES,"
+                + "[SearchCriteria.AttributeMatchClause[ATTRIBUTE,CODE,E], "
+                + "SearchCriteria.AttributeMatchClause[ATTRIBUTE,PROJECT,P], "
+                + "SearchCriteria.AttributeMatchClause[ATTRIBUTE,SPACE,S]],[]]]]]",
+                searchCriteriaMatcher.recordedObject().toString());
+        context.assertIsSatisfied();
+    }
 
     @Test
     public void testGetDataSetsOfAWell()
@@ -523,15 +565,18 @@ public class ScreeningOpenbisServiceFacadeTest extends AbstractFileSystemTestCas
                     one(generalInformationService).listDataSetsForSample(SESSION_TOKEN, sample,
                             true);
                     DataSetInitializer initializer1 = dataSetInitializer(DATA_SET1);
-                    will(returnValue(Arrays.asList(new DataSet(initializer1))));
+                    DataSet dataSet = new DataSet(initializer1);
+                    will(returnValue(Arrays.asList(dataSet)));
 
                     one(dssComponent).getDataSet(DATA_SET1);
                     will(returnValue(ds1Proxy));
+                    
+                    one(filter).pass(dataSet);
+                    will(returnValue(true));
                 }
             });
 
-        List<IDataSetDss> dataSets =
-                facade.getDataSets(wellIdentifier, ".*" + MY_DATA_SET_TYPE + ".*");
+        List<IDataSetDss> dataSets = facade.getDataSets(wellIdentifier, filter);
 
         assertSame(ds1Proxy, dataSets.get(0));
         assertEquals(1, dataSets.size());
@@ -552,14 +597,18 @@ public class ScreeningOpenbisServiceFacadeTest extends AbstractFileSystemTestCas
                     one(generalInformationService).listDataSetsForSample(SESSION_TOKEN, sample,
                             true);
                     DataSetInitializer initializer1 = dataSetInitializer(DATA_SET1);
-                    will(returnValue(Arrays.asList(new DataSet(initializer1))));
+                    DataSet dataSet = new DataSet(initializer1);
+                    will(returnValue(Arrays.asList(dataSet)));
 
                     one(dssComponent).getDataSet(DATA_SET1);
                     will(returnValue(ds1Proxy));
+                    
+                    one(filter).pass(dataSet);
+                    will(returnValue(true));
                 }
             });
 
-        List<IDataSetDss> dataSets = facade.getDataSets(plateIdentifier, MY_DATA_SET_TYPE);
+        List<IDataSetDss> dataSets = facade.getDataSets(plateIdentifier, filter);
 
         assertSame(ds1Proxy, dataSets.get(0));
         assertEquals(1, dataSets.size());
-- 
GitLab