package com.plannaplan.models; import java.util.Iterator; import java.util.List; import com.plannaplan.entities.Groups; /** * Instance to keep data to send in mail about accepted courses results */ public class EmailAcceptedData { private List accepted; private List removed; public EmailAcceptedData() { } /** * creates instance of class * * @param accepted list of groups that user joined to * @param removed lsit of groups that user failed to join */ public EmailAcceptedData(List accepted, List removed) { this.accepted = accepted; this.removed = removed; } /** * get list of removed assignments * * @return removed assingments */ public List getRemoved() { return removed; } /** * set list of removed assignments * * @param removed list of removed assignments */ public void setRemoved(List removed) { this.removed = removed; } /** * get list of accepted assignments * * @return accepted assingments */ public List getAccepted() { return accepted; } /** * set list of accepted assignments * * @param accepted list of accepted assignments */ public void setAccepted(List accepted) { this.accepted = accepted; } /** * it creates and return email message body * * @return string with emiale massage */ public String getEmailMessage() { String response = "Akceptacja Twoich przedmiotów właśnie dobiegła końca.\n\n"; if (this.accepted != null && this.accepted.size() > 0) { response += "Zatwierdzone grupy: \n"; Iterator iterator = accepted.iterator(); while (iterator.hasNext()) { final Groups gorup = iterator.next(); final String courseName = gorup.getCourseId() != null ? gorup.getCourseId().getName() : "Nieznana grupa"; response += (" - " + courseName + " - " + gorup.getType() + "\n"); } } if (this.removed != null && this.removed.size() > 0) { response += "Usunięte grupy: \n"; Iterator iterator = removed.iterator(); while (iterator.hasNext()) { final Groups gorup = iterator.next(); final String courseName = gorup.getCourseId() != null ? gorup.getCourseId().getName() : "Nieznana grupa"; response += (" - " + courseName + " - " + gorup.getType() + "\n"); } } return response; } }