From 1ee27ffe6c32f66556508c77eb56bc7e42a4969e Mon Sep 17 00:00:00 2001
From: felmer <felmer>
Date: Wed, 27 Jan 2010 08:42:20 +0000
Subject: [PATCH] SE-191 introducing method listDatastoreServiceDescriptions

SVN: 14478
---
 .../phosphonetx/server/RawDataService.java    | 27 +++++++++++++++++++
 .../server/RawDataServiceLogger.java          |  7 +++++
 .../phosphonetx/shared/IRawDataService.java   |  8 ++++++
 .../plugin/phosphonetx/RawDataTestClient.java |  7 +++++
 4 files changed, 49 insertions(+)

diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/RawDataService.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/RawDataService.java
index cb6a0c32bb1..600dcbfc98d 100644
--- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/RawDataService.java
+++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/RawDataService.java
@@ -16,15 +16,22 @@
 
 package ch.systemsx.cisd.openbis.plugin.phosphonetx.server;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 
 import ch.systemsx.cisd.authentication.ISessionManager;
 import ch.systemsx.cisd.common.exceptions.UserFailureException;
 import ch.systemsx.cisd.openbis.generic.server.AbstractServer;
 import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataStoreServiceKind;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample;
+import ch.systemsx.cisd.openbis.generic.shared.dto.DataStorePE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.DataStoreServicePE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.Session;
 import ch.systemsx.cisd.openbis.generic.shared.dto.SessionContextDTO;
+import ch.systemsx.cisd.openbis.generic.shared.translator.DataStoreServiceTranslator;
 import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IRawDataService;
 import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IRawDataServiceInternal;
 
@@ -67,6 +74,26 @@ public class RawDataService extends AbstractServer<IRawDataService> implements I
         }
     }
 
+    public List<DatastoreServiceDescription> listDataStoreServices(String sessionToken)
+    {
+        checkSession(sessionToken);
+
+        List<DatastoreServiceDescription> result = new ArrayList<DatastoreServiceDescription>();
+        List<DataStorePE> dataStores = getDAOFactory().getDataStoreDAO().listDataStores();
+        for (DataStorePE dataStore : dataStores)
+        {
+            Set<DataStoreServicePE> services = dataStore.getServices();
+            for (DataStoreServicePE dataStoreService : services)
+            {
+                if (dataStoreService.getKind() == DataStoreServiceKind.PROCESSING)
+                {
+                    result.add(DataStoreServiceTranslator.translate(dataStoreService));
+                }
+            }
+        }
+        return result;
+    }
+
     public void processingRawData(String sessionToken, String userID, String dataSetProcessingKey,
             long[] rawDataSampleIDs)
     {
diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/RawDataServiceLogger.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/RawDataServiceLogger.java
index 7af4229bcac..b9175d98d38 100644
--- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/RawDataServiceLogger.java
+++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/RawDataServiceLogger.java
@@ -20,6 +20,7 @@ import java.util.List;
 
 import ch.systemsx.cisd.authentication.ISessionManager;
 import ch.systemsx.cisd.openbis.generic.server.AbstractServerLogger;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample;
 import ch.systemsx.cisd.openbis.generic.shared.dto.Session;
 import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IRawDataService;
@@ -44,6 +45,12 @@ class RawDataServiceLogger extends AbstractServerLogger implements IRawDataServi
         return null;
     }
 
+    public List<DatastoreServiceDescription> listDataStoreServices(String sessionToken)
+    {
+        logAccess(sessionToken, "list_data_store_services", "");
+        return null;
+    }
+
     public void processingRawData(String sessionToken, String userID, String dataSetProcessingKey,
             long[] rawDataSampleIDs)
     {
diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/IRawDataService.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/IRawDataService.java
index 9160444ef8c..7a77e5161ee 100644
--- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/IRawDataService.java
+++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/IRawDataService.java
@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
 import ch.systemsx.cisd.openbis.generic.shared.IServer;
 import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RoleSet;
 import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RolesAllowed;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample;
 
 /**
@@ -40,6 +41,13 @@ public interface IRawDataService extends IServer
     @RolesAllowed(RoleSet.INSTANCE_ADMIN_OBSERVER)
     public List<Sample> listRawDataSamples(String sessionToken, String userID);
 
+    /**
+     * Lists all processing DSS services.
+     */
+    @Transactional(readOnly = true)
+    @RolesAllowed(RoleSet.INSTANCE_ADMIN_OBSERVER)
+    public List<DatastoreServiceDescription> listDataStoreServices(String sessionToken);
+    
     /**
      * Processes the data sets of specified samples by the DSS processing plug-in of specified key
      * for the specified user. Implementations should check that the specified user is allowed
diff --git a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/RawDataTestClient.java b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/RawDataTestClient.java
index 6b4ef6d7726..706d02de2a6 100644
--- a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/RawDataTestClient.java
+++ b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/RawDataTestClient.java
@@ -20,6 +20,7 @@ import java.util.List;
 
 import ch.systemsx.cisd.common.exceptions.UserFailureException;
 import ch.systemsx.cisd.common.spring.HttpInvokerUtils;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample;
 import ch.systemsx.cisd.openbis.generic.shared.dto.SessionContextDTO;
 import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IRawDataService;
@@ -45,6 +46,12 @@ public class RawDataTestClient
                 System.out.println("User: " + user);
                 SessionContextDTO session = service.tryToAuthenticate("test", "a");
                 String sessionToken = session.getSessionToken();
+                List<DatastoreServiceDescription> services = service.listDataStoreServices(sessionToken);
+                for (DatastoreServiceDescription datastoreServiceDescription : services)
+                {
+                    System.out.print(datastoreServiceDescription.getLabel()+" ");
+                }
+                System.out.println();
                 List<Sample> samples = service.listRawDataSamples(sessionToken, user);
                 for (Sample sample : samples)
                 {
-- 
GitLab