From 579c5cf66ad4bdd9058d91135afc6b1af7dc07f1 Mon Sep 17 00:00:00 2001
From: tpylak <tpylak>
Date: Mon, 3 May 2010 08:25:36 +0000
Subject: [PATCH] SE-242 HCS library registration: add starting date to the
 email

SVN: 15713
---
 .../web/server/LibraryRegistrationTask.java   | 25 +++++++++++++------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/LibraryRegistrationTask.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/LibraryRegistrationTask.java
index a4267465a40..98492ed33d6 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/LibraryRegistrationTask.java
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/LibraryRegistrationTask.java
@@ -1,5 +1,6 @@
 package ch.systemsx.cisd.openbis.plugin.screening.client.web.server;
 
+import java.util.Date;
 import java.util.List;
 
 import ch.systemsx.cisd.common.mail.IMailClient;
@@ -54,6 +55,7 @@ class LibraryRegistrationTask implements Runnable
 
     public void run()
     {
+        Date startDate = new Date();
         StringBuilder message = new StringBuilder();
         try
         {
@@ -68,7 +70,7 @@ class LibraryRegistrationTask implements Runnable
         {
             message.append("ERROR: Genes could not be registered!\n");
             message.append(ex.getMessage());
-            sendErrorEmail(message.toString(), email);
+            sendErrorEmail(message, startDate, email);
             return;
         }
         try
@@ -83,7 +85,7 @@ class LibraryRegistrationTask implements Runnable
         {
             message.append("ERROR: Oligos could not be registered!\n");
             message.append(ex.getMessage());
-            sendErrorEmail(message.toString(), email);
+            sendErrorEmail(message, startDate, email);
             return;
         }
         try
@@ -98,21 +100,28 @@ class LibraryRegistrationTask implements Runnable
         {
             message.append("ERROR: Plates and wells could not be registered!\n");
             message.append(ex.getMessage());
-            sendErrorEmail(message.toString(), email);
+            sendErrorEmail(message, startDate, email);
             return;
         }
-        sendSuccessEmail(message.toString(), email);
+        sendSuccessEmail(message, startDate, email);
 
     }
 
-    private void sendErrorEmail(String content, String recipient)
+    private void sendErrorEmail(StringBuilder content, Date startDate, String recipient)
     {
-        sendEmail(UNSUCCESSFUL_LIBRARY_REGISTARION_STATUS, content, recipient);
+        String subject = addDate(UNSUCCESSFUL_LIBRARY_REGISTARION_STATUS, startDate);
+        sendEmail(subject, content.toString(), recipient);
     }
 
-    private void sendSuccessEmail(String content, String recipient)
+    private void sendSuccessEmail(StringBuilder content, Date startDate, String recipient)
     {
-        sendEmail(SUCCESSFUL_LIBRARY_REGISTARION_STATUS, content, recipient);
+        String subject = addDate(SUCCESSFUL_LIBRARY_REGISTARION_STATUS, startDate);
+        sendEmail(subject, content.toString(), recipient);
+    }
+
+    private static String addDate(String subject, Date startDate)
+    {
+        return subject + " (initiated at " + startDate + ")";
     }
 
     private void sendEmail(String subject, String content, String recipient)
-- 
GitLab