/*
* Template-File src/main/takatuka/templates/EntityAbstractSearch.vm
*/
package de.ivu.elect.business.wahl.boundary;

import java.util.List;

import javax.inject.Inject;

import de.ivu.elect.business.wahl.entity.Wahltermin;
import de.ivu.elect.jee.entity.EagerLoadingCollector;
import de.ivu.elect.jee.presentation.search.WildcardConverter;

public abstract class AbstractWahlterminSearch {

  @Inject
  protected transient WahlterminExtendedDAO dao;

  public AbstractWahlterminSearch() {
    super();
  }

  public List<Wahltermin> getSearchResult(WahlterminSearchParameters searchParameters, EagerLoadingCollector<Wahltermin> eagerLoadingCollector) {
    return eagerLoadingCollector.eagerLoad(querySearchResult(searchParameters));
  }

  protected abstract List<Wahltermin> querySearchResult(WahlterminSearchParameters searchParameters);

  protected String convertSearchPattern(String patternInput) {
    return new WildcardConverter().addAndConvertToJpqlLikeExpression(patternInput);
  }
}
