package de.ivu.elect.business.email.boundary;

import de.ivu.elect.business.email.control.EmailVorlageExchangeContext;
import de.ivu.elect.business.email.control.EmailVorlageExportExchange;
import de.ivu.elect.business.email.entity.EmailVorlage;
import de.ivu.elect.business.exchange.control.AbstractExporter;
import de.ivu.elect.business.exchange.control.ExportExchange;
import de.ivu.elect.business.exchange.entity.DateiExportArt;

import javax.ejb.Stateless;
import javax.inject.Inject;
import java.util.List;

@Stateless
public class EmailVorlageExporter extends AbstractExporter<List<EmailVorlage>, EmailVorlageExchangeContext> {

  @Inject
  private transient EmailVorlageExportExchange emailVorlageExportExchange;

  @Inject
  private transient EmailVorlageDAO emailVorlageDao;

  public EmailVorlageExporter() {
    super();
  }

  @Override
  protected ExportExchange<List<EmailVorlage>, EmailVorlageExchangeContext> getExchange() {
    return emailVorlageExportExchange;
  }

  @Override
  protected List<EmailVorlage> getExportObject(EmailVorlageExchangeContext context) {
    return emailVorlageDao.findByWahlterminOrderByBezeichnung(context.getWahltermin());
  }

  @Override
  protected DateiExportArt getDateiExportArt() {
    return DateiExportArt.EMAIL_VORLAGE_EXPORT;
  }
}
