From 636df1f31cc185753c84a9fdde66c22ce2fe4dc3 Mon Sep 17 00:00:00 2001
From: jakubs <jakubs>
Date: Wed, 6 Apr 2016 13:14:05 +0000
Subject: [PATCH] SSDM-3224: add ability to fetch entities by perm id from
 dropboxes - v1

SVN: 36098
---
 .../api/v1/impl/SearchService.java            | 26 +++++++++++
 .../api/internal/v1/ISearchService.java       | 45 +++++++++++--------
 2 files changed, 53 insertions(+), 18 deletions(-)

diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/SearchService.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/SearchService.java
index 338cb8b26a3..e6b964a31d8 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/SearchService.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/SearchService.java
@@ -35,6 +35,7 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.IMaterialImmu
 import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.IMetaprojectAssignments;
 import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.IMetaprojectContent;
 import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.IMetaprojectImmutable;
+import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.IProjectImmutable;
 import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.IPropertyAssignmentImmutable;
 import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.ISampleImmutable;
 import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.ISearchService;
@@ -306,4 +307,29 @@ public class SearchService implements ISearchService
                 openBisService.listMetaprojectsForEntity(Translator.translate(entity.getEntityId()));
         return ConversionUtils.convertToMetaprojectsImmutable(metaprojects);
     }
+
+    @Override
+    public IExperimentImmutable getExperimentByPermId(String permId)
+    {
+        ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment experimentOrNull =
+                openBisService.tryGetExperimentByPermId(permId);
+        return (null == experimentOrNull) ? null : new ExperimentImmutable(experimentOrNull);
+    }
+
+    @Override
+    public ISampleImmutable getSampleByPermId(String permId)
+    {
+        ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sampleOrNull =
+                openBisService.tryGetSampleByPermId(permId);
+        return (null == sampleOrNull) ? null : new SampleImmutable(sampleOrNull);
+    }
+
+    @Override
+    public IProjectImmutable getProjectByPermId(String permId)
+    {
+        ch.systemsx.cisd.openbis.generic.shared.basic.dto.Project projectOrNull =
+                openBisService.tryGetProjectByPermId(permId);
+        return (null == projectOrNull) ? null : new ProjectImmutable(projectOrNull);
+    }
+
 }
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/internal/v1/ISearchService.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/internal/v1/ISearchService.java
index c43c337d4f4..ffb6288c0c7 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/internal/v1/ISearchService.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/internal/v1/ISearchService.java
@@ -34,8 +34,7 @@ public interface ISearchService
     public List<IExperimentImmutable> listExperiments(String projectIdentifier);
 
     /**
-     * List all data sets with a given value for a particular property, optionally restricted to a
-     * specific type.
+     * List all data sets with a given value for a particular property, optionally restricted to a specific type.
      * 
      * @param property The property of interest.
      * @param value The value the property should have. This may contain wildcards.
@@ -45,12 +44,10 @@ public interface ISearchService
             String typeOrNull);
 
     /**
-     * List all data sets with a given value for a particular property, optionally restricted to a
-     * specific type.
+     * List all data sets with a given value for a particular property, optionally restricted to a specific type.
      * 
      * @param property The property of interest.
-     * @param value The value the property should have. This may contain wildcards if
-     *            <var>escape</var> is set to <code>false</code>.
+     * @param value The value the property should have. This may contain wildcards if <var>escape</var> is set to <code>false</code>.
      * @param escape If <code>true</code>, escape the <var>value</var> to search for it verbatimly.
      * @return A list of matching data sets.
      */
@@ -58,8 +55,7 @@ public interface ISearchService
             String typeOrNull, boolean escape);
 
     /**
-     * List all samples with a given value for a particular property, optionally restricted to a
-     * specific type.
+     * List all samples with a given value for a particular property, optionally restricted to a specific type.
      * 
      * @param property The property of interest.
      * @param value The value the property should have. This may contain wildcards.
@@ -68,12 +64,10 @@ public interface ISearchService
     public List<ISampleImmutable> searchForSamples(String property, String value, String typeOrNull);
 
     /**
-     * List all samples with a given value for a particular property, optionally restricted to a
-     * specific type.
+     * List all samples with a given value for a particular property, optionally restricted to a specific type.
      * 
      * @param property The property of interest.
-     * @param value The value the property should have. This may contain wildcards if
-     *            <var>escape</var> is set to <code>false</code>.
+     * @param value The value the property should have. This may contain wildcards if <var>escape</var> is set to <code>false</code>.
      * @param escape If <code>true</code>, escape the <var>value</var> to search for it verbatimly.
      * @return A list of matching samples.
      */
@@ -97,23 +91,21 @@ public interface ISearchService
     public List<ISampleImmutable> searchForSamples(SearchCriteria searchCriteria);
 
     /**
-     * @param identifierCollection a collection containing the identifiers of the matching
-     *            materials. Identifiers that do not exist in the openBIS database are ignored.
+     * @param identifierCollection a collection containing the identifiers of the matching materials. Identifiers that do not exist in the openBIS
+     *            database are ignored.
      * @return a list of materials matching the specified collection.
      */
     public List<IMaterialImmutable> listMaterials(MaterialIdentifierCollection identifierCollection);
 
     /**
-     * @return a controlled vocabulary with the given code. Returns null if the vocabulary with
-     *         given code is not found.
+     * @return a controlled vocabulary with the given code. Returns null if the vocabulary with given code is not found.
      * @deprecated use {@link #getVocabulary(String)} instead
      */
     @Deprecated
     public IVocabularyImmutable searchForVocabulary(String code);
 
     /**
-     * @return a controlled vocabulary with the given code. Returns null if the vocabulary with
-     *         given code is not found.
+     * @return a controlled vocabulary with the given code. Returns null if the vocabulary with given code is not found.
      */
     public IVocabularyImmutable getVocabulary(String code);
 
@@ -151,4 +143,21 @@ public interface ISearchService
      * @return metaprojects for current user, which are assigned to the given entity
      */
     public List<IMetaprojectImmutable> listMetaprojectsForEntity(IMetaprojectContent entity);
+
+    /**
+     * Get a sample from the openBIS AS by its perm id. Returns null if the sample does not exist.
+     * 
+     * @return A sample or null
+     */
+    ISampleImmutable getSampleByPermId(String permId);
+
+    /**
+     * Get a project from the openBIS AS by its perm id.
+     */
+    IProjectImmutable getProjectByPermId(String permId);
+
+    /**
+     * Get an experiment from the openBIS AS by its perm id.
+     */
+    IExperimentImmutable getExperimentByPermId(String permId);
 }
-- 
GitLab