From f0c0ea201ce336d08db5f561decfee66cb4e7129 Mon Sep 17 00:00:00 2001
From: gpawel <gpawel>
Date: Tue, 9 Oct 2012 07:55:13 +0000
Subject: [PATCH] bugfix: adding a way of deleting entities from metaproject by
 tech ids

SVN: 27097
---
 .../v1/GeneralInformationChangingService.java   | 13 +++++++++++++
 ...GeneralInformationChangingServiceLogger.java | 13 ++++++++++++-
 .../v1/IGeneralInformationChangingService.java  | 17 +++++++++++++++++
 3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingService.java
index 50bcd815c28..3577e8e2aa4 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingService.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingService.java
@@ -224,6 +224,19 @@ public class GeneralInformationChangingService extends
                 extractTechIds(materials));
     }
 
+    @Override
+    @Transactional(readOnly = false)
+    @RolesAllowed(RoleWithHierarchy.SPACE_USER)
+    public void removeFromMetaprojectByEntityIds(String sessionToken,
+            @AuthorizationGuard(guardClass = MetaprojectIdPredicate.class)
+            Long metaprojectId, List<Long> experiments, List<Long> samples, List<Long> dataSets,
+            List<Long> materials)
+    {
+        server.removeFromMetaproject(sessionToken, new TechId(metaprojectId),
+                TechId.createList(experiments), TechId.createList(samples),
+                TechId.createList(dataSets), TechId.createList(materials));
+    }
+
     private List<TechId> extractTechIds(Collection<? extends IIdHolder> entitiesOrNull)
     {
         if (entitiesOrNull == null)
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingServiceLogger.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingServiceLogger.java
index eb50c7afb7b..36984fb2c2b 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingServiceLogger.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingServiceLogger.java
@@ -125,7 +125,7 @@ class GeneralInformationChangingServiceLogger extends AbstractServerLogger imple
     {
         logAccess(
                 sessionToken,
-                "addToMetaproject METAPROJECT_ID(%s), EXPERIMENTS(%s), SAMPLES(%s), DATA_SETS(%s), MATERIALS(%s)",
+                "addToMetaprojectByEntityIds METAPROJECT_ID(%s), EXPERIMENTS(%s), SAMPLES(%s), DATA_SETS(%s), MATERIALS(%s)",
                 metaprojectId.toString(), abbreviate(experiments), abbreviate(samples),
                 abbreviate(dataSets), abbreviate(materials));
     }
@@ -142,6 +142,17 @@ class GeneralInformationChangingServiceLogger extends AbstractServerLogger imple
                 abbreviate(dataSets), abbreviate(materials));
     }
 
+    @Override
+    public void removeFromMetaprojectByEntityIds(String sessionToken, Long metaprojectId,
+            List<Long> experiments, List<Long> samples, List<Long> dataSets, List<Long> materials)
+    {
+        logAccess(
+                sessionToken,
+                "removeFromMetaprojectByEntityIds METAPROJECT_ID(%s), EXPERIMENTS(%s), SAMPLES(%s), DATA_SETS(%s), MATERIALS(%s)",
+                metaprojectId.toString(), abbreviate(experiments), abbreviate(samples),
+                abbreviate(dataSets), abbreviate(materials));
+    }
+
     @Override
     public int getMajorVersion()
     {
diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationChangingService.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationChangingService.java
index 6992259ca14..d122d839aff 100644
--- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationChangingService.java
+++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationChangingService.java
@@ -165,4 +165,21 @@ public interface IGeneralInformationChangingService extends IRpcService
     public void removeFromMetaproject(String sessionToken, Long metaprojectId,
             Collection<Experiment> experiments, Collection<Sample> samples,
             Collection<DataSet> dataSets, Collection<Material> materials);
+
+    /**
+     * Removes given entities to existing metaproject.
+     * 
+     * @param metaprojectId Tech Id of metaproject
+     * @param experiments List of experiment ids that should be removed from the metaproject or
+     *            <code>null</code>
+     * @param samples List of sample ids that should be removed from the metaproject or
+     *            <code>null</code>
+     * @param dataSets List of data set ids that should be removed from the metaproject or
+     *            <code>null</code>
+     * @param materials List of material ids that should be removed from the metaproject or
+     *            <code>null</code>
+     * @since 1.3
+     */
+    public void removeFromMetaprojectByEntityIds(String sessionToken, Long metaprojectId,
+            List<Long> experiments, List<Long> samples, List<Long> dataSets, List<Long> materials);
 }
-- 
GitLab