package fr.inria.spirals.repairnator.notifier;

import fr.inria.spirals.repairnator.Utils;
import fr.inria.spirals.repairnator.notifier.engines.NotifierEngine;

import java.util.Date;
import java.util.List;

/**
 * Created by urli on 09/05/2017.
 */
public class EndProcessNotifier {
    private List<NotifierEngine> engines;
    private Date launchDate;
    private String processName;

    public EndProcessNotifier(List<NotifierEngine> engines, String processName) {
        this.launchDate = new Date();
        this.processName = processName;
        this.engines = engines;
    }

    public void notifyEnd() {
        String subject = "Process "+processName+" on "+Utils.getHostname()+" finished";
        String message = "The following process: "+processName+" launched on "+ Utils.getHostname()+" the "+this.launchDate.toString()+" has just finished the "+new Date().toString()+".";

        for (NotifierEngine engine : this.engines) {
            engine.notify(subject, message);
        }
    }
}

@@ -698,16 +698,51 @@
 ished%22;%0A
+        Date endDate = new Date();%0A
         
@@ -784,16 +784,17 @@
 cess: %22+
+ 
 processN
@@ -796,16 +796,17 @@
 cessName
+ 
 +%22 launc
@@ -839,16 +839,17 @@
 e()+
+ 
 %22 the %22+
 this
@@ -844,16 +844,17 @@
 %22 the %22+
+ 
 this.lau
@@ -878,16 +878,11 @@
 )+%22 
-has just
+and
  fin
@@ -891,24 +891,17 @@
 hed 
-the %22+new 
+%22+end
 Date
-()
 .toS
@@ -910,17 +910,110 @@
 ing()+%22.
-%22
+ %22%0A                + %22It ran for a total time of %22+Utils.getDuration(this.launchDate, endDate)
 ;%0A%0A     

Improve mail notification for end of process (#678)