package de.ivu.elect.presentation.internet.exchange;

import javax.inject.Inject;
import javax.inject.Named;

import de.ivu.elect.business.exchange.control.AbstractExporter;
import de.ivu.elect.business.internet.boundary.InternetKonfigurationExporter;
import de.ivu.elect.business.internet.entity.InternetKonfigurationExchangeContext;
import de.ivu.elect.business.internet.entity.InternetKonfigurationExchangeObject;
import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.jee.presentation.dynamicform.FormBuilder;
import de.ivu.elect.jee.presentation.dynamicform.LambdaBooleanProperty;
import de.ivu.elect.presentation.View;
import de.ivu.elect.presentation.exchange.AbstractExportSearchView;
import de.ivu.elect.presentation.exchange.ExportDescription;
import de.ivu.elect.presentation.hilfe.OnlineHilfeId;

@Named(InternetKonfigurationExportView.COMPONENT_NAME)
@View(viewId = InternetKonfigurationExportView.VIEW_ID, useCase = UseCasePermission.INTERNET_KONFIGURATION_EXPORTIEREN)
@OnlineHilfeId(value = "753",mehrfachVergebenOk = true)
public class InternetKonfigurationExportView extends AbstractExportSearchView<InternetKonfigurationExchangeObject, InternetKonfigurationExchangeContext> {

  public static final String COMPONENT_NAME = "internetKonfigurationExportView";

  public static final String VIEW_ID = "/internet/internet-konfiguration-export.xhtml";

  private static final long serialVersionUID = 1L;

  @Inject
  private transient InternetKonfigurationExporter exporter;

  @Inject
  private transient InternetKonfigurationExportDescription exportDescription;

  private boolean nurAktiveExportieren = false;

  public InternetKonfigurationExportView() {
    super();
  }

  @Override
  protected AbstractExporter<InternetKonfigurationExchangeObject, InternetKonfigurationExchangeContext> getExporter() {
    return exporter;
  }

  @Override
  protected InternetKonfigurationExchangeContext getContext() {
    return new InternetKonfigurationExchangeContext(getSelectedWahl(), nurAktiveExportieren);
  }

  @Override
  public ExportDescription getExportDescription() {
    return exportDescription;
  }

  @Override
  protected void addProperties(FormBuilder formBuilder) {
    super.addProperties(formBuilder);
    formBuilder.addProperty(new LambdaBooleanProperty(getMessage("internet.konfiguration.export.nur.aktive.seiten"), false, this::setNurAktiveExportieren, this::isNurAktiveExportieren));
  }

  public boolean isNurAktiveExportieren() {
    return nurAktiveExportieren;
  }

  public void setNurAktiveExportieren(boolean nurAktiveExportieren) {
    this.nurAktiveExportieren = nurAktiveExportieren;
  }
}
