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

import de.ivu.elect.business.konfiguration.entity.CustomParameterKategorie;
import de.ivu.elect.business.konfiguration.entity.CustomParameterTemplate;
import de.ivu.elect.business.konfiguration.entity.ElectKonfigurationWerte;
import de.ivu.elect.business.konfiguration.entity.MandantKonfigurationWerte;
import de.ivu.elect.business.mandant.entity.Mandant;
import org.apache.deltaspike.core.api.scope.ConversationGroup;
import org.apache.deltaspike.core.api.scope.GroupedConversationScoped;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import static java.util.Arrays.asList;

@GroupedConversationScoped
@ConversationGroup(AbstractKonfigurationSearchParameters.class)
public class KonfigurationSearchParameters extends AbstractKonfigurationSearchParameters implements CustomParameterSearchParameters {

  private static final long serialVersionUID = 1L;

  private Mandant mandant;


  public Mandant getMandant() {
    return mandant;
  }

  public void setMandant(Mandant mandant) {
    this.mandant = mandant;
  }

  private CustomParameterKategorie kategorie;

  public KonfigurationSearchParameters() {
    super();
  }

  @Override
  public CustomParameterKategorie getKategorie() {
    return kategorie;
  }

  @Override
  public void setKategorie(CustomParameterKategorie kategorie) {
    this.kategorie = kategorie;
  }

  private boolean nurUngueltige;
  @Override
  public void setNurUngueltige(boolean nurUngueltige) {
    this.nurUngueltige = nurUngueltige;
  }

  @Override
  public boolean isNurUngueltige() {
    return nurUngueltige;
  }

  @Override
  public void reset() {
    super.reset();
    nurUngueltige = false;
  }

  @Override
  public Collection<CustomParameterTemplate> getSupportedTemplates() {
    Set<CustomParameterTemplate> result = new HashSet<>();

    // ELECT-8087
    result.addAll(asList(MandantKonfigurationWerte.values()));
    result.addAll(asList(ElectKonfigurationWerte.values()));

    return result;
  }

  public void searchUngueltigFuerMandant(Mandant mandant) {
    setMandant(mandant);
    setNurUngueltige(true);
  }
}
