From 12c968577d8625e1bf53bbf1a7d9ed4a372d0bfc Mon Sep 17 00:00:00 2001
From: buczekp <buczekp>
Date: Wed, 25 Nov 2009 08:42:11 +0000
Subject: [PATCH] [LMS-1264] added information about external sample name for
 tracked data set

SVN: 13525
---
 .../email/EntityTrackingEmailGenerator.java   | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/email/EntityTrackingEmailGenerator.java b/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/email/EntityTrackingEmailGenerator.java
index 14d26904450..b6ecc853094 100644
--- a/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/email/EntityTrackingEmailGenerator.java
+++ b/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/email/EntityTrackingEmailGenerator.java
@@ -134,6 +134,8 @@ public class EntityTrackingEmailGenerator implements IEntityTrackingEmailGenerat
         private static final String SUBSECTION_SEPARATOR_LINE =
                 createSeparatorLine(SUBSECTION_SEPARATOR_CHAR);
 
+        private final static String EXTERNAL_SAMPLE_NAME_PROPERTY_CODE = "EXTERNAL_SAMPLE_NAME";
+
         private static final String PERMLINK_LABEL = "See details in openBIS";
 
         private static final String GENARATED_CONTENT_TARGET = "{generated-content}";
@@ -242,10 +244,30 @@ public class EntityTrackingEmailGenerator implements IEntityTrackingEmailGenerat
             appendAttribute(sb, "Sequencing sample", String.format("'%s'\n  %s", sequencingSample
                     .getCode(), sequencingSample.getPermlink()));
 
+            // information about external sample name
+            appendAttribute(sb, "External sample name", tryGetSamplePropertyValue(sequencingSample,
+                    EXTERNAL_SAMPLE_NAME_PROPERTY_CODE));
+
             // data set properties
             appendProperties(sb, dataSet.getProperties());
         }
 
+        private static String tryGetSamplePropertyValue(Sample sequencingSample,
+                String externalSampleNamePropertyCode)
+        {
+            String result = null;
+            for (IEntityProperty property : sequencingSample.getProperties())
+            {
+                final String propertyCode = property.getPropertyType().getCode();
+                if (propertyCode.equals(EXTERNAL_SAMPLE_NAME_PROPERTY_CODE))
+                {
+                    result = StringEscapeUtils.unescapeHtml(property.getValue());
+                    break;
+                }
+            }
+            return result;
+        }
+
         // NOTE: Information about properties assigned to entity type are not loaded.
         // If it would be available we could append information about all properties assigned
         // to entity type, not only about properties filled for specific entity. Additionally
-- 
GitLab