From 64f06616bee752758582ce4c581a5a38e6cd5bfe Mon Sep 17 00:00:00 2001
From: felmer <felmer>
Date: Mon, 10 Jan 2011 11:23:05 +0000
Subject: [PATCH] LMS-1957 Introducing DatasetDescriptionBuilder

SVN: 19332
---
 .../standard/DataSetCopierForUsersTest.java   | 13 ++-
 .../builders/DatasetDescriptionBuilder.java   | 82 +++++++++++++++++++
 2 files changed, 87 insertions(+), 8 deletions(-)
 create mode 100644 openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/dto/builders/DatasetDescriptionBuilder.java

diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetCopierForUsersTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetCopierForUsersTest.java
index effd4476e0b..8ec98f8921a 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetCopierForUsersTest.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetCopierForUsersTest.java
@@ -43,6 +43,7 @@ import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ProcessingStatu
 import ch.systemsx.cisd.openbis.dss.generic.shared.DataSetProcessingContext;
 import ch.systemsx.cisd.openbis.generic.shared.Constants;
 import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription;
+import ch.systemsx.cisd.openbis.generic.shared.dto.builders.DatasetDescriptionBuilder;
 
 /**
  * @author Franz-Josef Elmer
@@ -95,14 +96,10 @@ public class DataSetCopierForUsersTest extends AbstractFileSystemTestCase
         properties = new Properties();
         properties.setProperty("ssh-executable", sshExecutableDummy.getPath());
         properties.setProperty("rsync-executable", rsyncExecutableDummy.getPath());
-        ds = new DatasetDescription();
-        ds.setDatasetCode("ds1");
-        ds.setDataSetLocation(DS_LOCATION);
-        ds.setSampleCode("s");
-        ds.setGroupCode("g");
-        ds.setProjectCode("p");
-        ds.setExperimentCode("e");
-        ds.setDatabaseInstanceCode("i");
+        DatasetDescriptionBuilder dsb =
+                new DatasetDescriptionBuilder("ds1").location(DS_LOCATION).sample("s").space("g")
+                        .project("p").experiment("e").databaseInstance("i");
+        ds = dsb.getDatasetDescription();
         File ds1Folder = new File(storeRoot, DS_LOCATION + "/original");
         ds1Folder.mkdirs();
         dsData = new File(ds1Folder, "data.txt");
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/dto/builders/DatasetDescriptionBuilder.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/dto/builders/DatasetDescriptionBuilder.java
new file mode 100644
index 00000000000..fe4faa8691b
--- /dev/null
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/dto/builders/DatasetDescriptionBuilder.java
@@ -0,0 +1,82 @@
+/*
+ * 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.dto.builders;
+
+import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription;
+
+/**
+ * Builder for instances of {@link DatasetDescription}.
+ *
+ * @author Franz-Josef Elmer
+ */
+public class DatasetDescriptionBuilder
+{
+    private final DatasetDescription datasetDescription;
+    
+    public DatasetDescriptionBuilder(String code)
+    {
+        datasetDescription = new DatasetDescription();
+        datasetDescription.setDatasetCode(code);
+    }
+    
+    public DatasetDescriptionBuilder type(String dataSetTypeCode)
+    {
+        datasetDescription.setDatasetTypeCode(dataSetTypeCode);
+        return this;
+    }
+    
+    public DatasetDescriptionBuilder location(String location)
+    {
+        datasetDescription.setDataSetLocation(location);
+        return this;
+    }
+    
+    public DatasetDescriptionBuilder sample(String sampleCode)
+    {
+        datasetDescription.setSampleCode(sampleCode);
+        return this;
+    }
+    
+    public DatasetDescriptionBuilder databaseInstance(String databaseInstanceCode)
+    {
+        datasetDescription.setDatabaseInstanceCode(databaseInstanceCode);
+        return this;
+    }
+    
+    public DatasetDescriptionBuilder space(String spaceCode)
+    {
+        datasetDescription.setGroupCode(spaceCode);
+        return this;
+    }
+    
+    public DatasetDescriptionBuilder project(String projectCode)
+    {
+        datasetDescription.setProjectCode(projectCode);
+        return this;
+    }
+    
+    public DatasetDescriptionBuilder experiment(String experimentCode)
+    {
+        datasetDescription.setExperimentCode(experimentCode);
+        return this;
+    }
+    
+    public DatasetDescription getDatasetDescription()
+    {
+        return datasetDescription;
+    }
+}
-- 
GitLab