From bf1e9ad2103fec9f8c8ae2a1734743f6c9c60df9 Mon Sep 17 00:00:00 2001
From: tpylak <tpylak>
Date: Fri, 4 Nov 2011 17:36:36 +0000
Subject: [PATCH] LMS-2562 minor: improve toString method

SVN: 23548
---
 .../shared/dto/DataSetInformation.java        | 14 ++------
 .../generic/shared/utils/ToStringUtil.java    | 34 +++++++++++++++++++
 2 files changed, 36 insertions(+), 12 deletions(-)
 create mode 100644 datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/ToStringUtil.java

diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/DataSetInformation.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/DataSetInformation.java
index 9714de514dd..3b38a0914e6 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/DataSetInformation.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/DataSetInformation.java
@@ -23,9 +23,9 @@ import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
 
-import ch.systemsx.cisd.common.Constants;
 import ch.systemsx.cisd.common.types.BooleanOrUnknown;
 import ch.systemsx.cisd.openbis.dss.generic.shared.utils.SpeedUtils;
+import ch.systemsx.cisd.openbis.dss.generic.shared.utils.ToStringUtil;
 import ch.systemsx.cisd.openbis.generic.shared.IServer;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment;
@@ -395,8 +395,6 @@ public class DataSetInformation implements Serializable
         }
         appendNameAndObject(buffer, "Experiment Identifier", getExperimentIdentifier());
         appendNameAndObject(buffer, "Sample Identifier", getSampleIdentifier());
-        appendNameAndObject(buffer, "Producer Code", getProducerCode());
-        appendNameAndObject(buffer, "Production Date", formatDate(getProductionDate()));
         final List<String> parentDataSetCodes = getParentDataSetCodes();
         if (parentDataSetCodes.isEmpty() == false)
         {
@@ -408,17 +406,9 @@ public class DataSetInformation implements Serializable
         return buffer.toString();
     }
 
-    private static String formatDate(Date productionDate)
-    {
-        return productionDate == null ? "" : Constants.DATE_FORMAT.get().format(productionDate);
-    }
-
     protected static final void appendNameAndObject(final StringBuilder buffer, final String name,
             final Object object)
     {
-        if (object != null)
-        {
-            buffer.append(name).append("::").append(object).append(";");
-        }
+        ToStringUtil.appendNameAndObject(buffer, name, object);
     }
 }
\ No newline at end of file
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/ToStringUtil.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/ToStringUtil.java
new file mode 100644
index 00000000000..c133976ae2d
--- /dev/null
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/ToStringUtil.java
@@ -0,0 +1,34 @@
+/*
+ * 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.dss.generic.shared.utils;
+
+/**
+ * @author Tomasz Pylak
+ */
+public class ToStringUtil
+{
+    /** Helps in implementing toString() methods */
+    public static final void appendNameAndObject(final StringBuilder buffer, final String name,
+            final Object object)
+    {
+        if (object != null)
+        {
+            buffer.append(name).append("::").append(object).append(";");
+        }
+    }
+
+}
-- 
GitLab