Skip to content
Snippets Groups Projects
Commit fdcf4b42 authored by buczekp's avatar buczekp
Browse files

[LMS-1264] added email template usage

SVN: 13498
parent 3ebd8510
No related branches found
No related tags found
No related merge requests found
This is an automatically generated email notification from openBIS about creation of
samples and data sets for which you are a contact person/principal investigator/affiliation contact.
{generated-content}
Kind regards,
CISD Team
\ No newline at end of file
...@@ -41,30 +41,23 @@ public class EntityTrackingEmailGenerator implements IEntityTrackingEmailGenerat ...@@ -41,30 +41,23 @@ public class EntityTrackingEmailGenerator implements IEntityTrackingEmailGenerat
private static final String NOTIFICATION_EMAIL_SUBJECT = "notification-email-subject"; private static final String NOTIFICATION_EMAIL_SUBJECT = "notification-email-subject";
private static final String NOTIFICATION_EMAIL_BEGINNING = "notification-email-beginning";
private static final String NOTIFICATION_EMAIL_ENDING = "notification-email-ending";
private static final String AFFILIATION_NOTIFICATION_EMAIL_CONTACT_SUFFIX = private static final String AFFILIATION_NOTIFICATION_EMAIL_CONTACT_SUFFIX =
"-affiliation-notification-email-contact"; "-affiliation-notification-email-contact";
private final String subject;
private final String from; private final String from;
private final String replyTo; private final String replyTo;
private final String beginning; private final String subject;
private final String ending; private final String template;
public EntityTrackingEmailGenerator(Properties properties) public EntityTrackingEmailGenerator(Properties properties, String template)
{ {
subject = PropertyUtils.getMandatoryProperty(properties, NOTIFICATION_EMAIL_SUBJECT); this.from = PropertyUtils.getMandatoryProperty(properties, NOTIFICATION_EMAIL_FROM);
from = PropertyUtils.getMandatoryProperty(properties, NOTIFICATION_EMAIL_FROM); this.replyTo = PropertyUtils.getMandatoryProperty(properties, NOTIFICATION_EMAIL_REPLY_TO);
replyTo = PropertyUtils.getMandatoryProperty(properties, NOTIFICATION_EMAIL_REPLY_TO); this.subject = PropertyUtils.getMandatoryProperty(properties, NOTIFICATION_EMAIL_SUBJECT);
beginning = PropertyUtils.getMandatoryProperty(properties, NOTIFICATION_EMAIL_BEGINNING); this.template = template;
ending = PropertyUtils.getMandatoryProperty(properties, NOTIFICATION_EMAIL_ENDING);
final Map<String, String> recipientsByAffiliation = final Map<String, String> recipientsByAffiliation =
retrieveRecipientsByAffiliation(properties); retrieveRecipientsByAffiliation(properties);
...@@ -108,7 +101,7 @@ public class EntityTrackingEmailGenerator implements IEntityTrackingEmailGenerat ...@@ -108,7 +101,7 @@ public class EntityTrackingEmailGenerator implements IEntityTrackingEmailGenerat
private Email createEmail(EntityTrackingEmailData emailData) private Email createEmail(EntityTrackingEmailData emailData)
{ {
String content = EmailContentGenerator.generate(emailData, beginning, ending); String content = EmailContentGenerator.fillTemplateWithData(template, emailData);
String recipient = emailData.getRecipient(); String recipient = emailData.getRecipient();
return new Email(subject, content, replyTo, from, recipient); return new Email(subject, content, replyTo, from, recipient);
} }
...@@ -136,16 +129,18 @@ public class EntityTrackingEmailGenerator implements IEntityTrackingEmailGenerat ...@@ -136,16 +129,18 @@ public class EntityTrackingEmailGenerator implements IEntityTrackingEmailGenerat
private static final String PERMLINK_LABEL = "Permlink"; private static final String PERMLINK_LABEL = "Permlink";
public static String generate(EntityTrackingEmailData emailData, String beginning, private static final String GENARATED_CONTENT_TARGET = "{generated-content}";
String ending)
public static String fillTemplateWithData(String template, EntityTrackingEmailData emailData)
{
return template.replace(GENARATED_CONTENT_TARGET, generateContent(emailData));
}
private static String generateContent(EntityTrackingEmailData emailData)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendln(sb, beginning);
appendNewline(sb);
appendSequencingSamplesData(sb, emailData.getSequencingSamplesData()); appendSequencingSamplesData(sb, emailData.getSequencingSamplesData());
appendDataSetsData(sb, emailData.getDataSets()); appendDataSetsData(sb, emailData.getDataSets());
appendNewline(sb);
appendln(sb, ending);
return sb.toString(); return sb.toString();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment