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

import static java.util.Collections.emptyList;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.ivu.elect.business.kandidatur.entity.Listenkandidatur;

public class ListenkandidaturSearch extends AbstractListenkandidaturSearch {

  private static final Logger LOG = LoggerFactory.getLogger(ListenkandidaturSearch.class);

  public ListenkandidaturSearch() {
    super();
  }

  @Override
  protected List<Listenkandidatur> querySearchResult(ListenkandidaturSearchParameters searchParameters) {
    if (searchParameters.getListe() == null) {
      LOG.error("Die Suchparameter enthalten keine Liste! [wahl = {}, liste = {}]", searchParameters.getSelectedWahl(), searchParameters.getListe());

      return emptyList();
    }

    // ELECT-8688 Sortierung nach relativer Position, um Unterschied zu sehen
    return dao.findByListeOrderByRelativePosition(searchParameters.getListe());
  }
}
