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

import java.util.List;

import javax.inject.Inject;

import de.ivu.elect.business.email.entity.Email;
import de.ivu.elect.jee.entity.EagerLoadingCollector;
import de.ivu.elect.jee.presentation.search.WildcardConverter;

public abstract class AbstractEmailSearch {

  @Inject
  protected transient EmailExtendedDAO dao;

  public AbstractEmailSearch() {
    super();
  }

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

  protected abstract List<Email> querySearchResult(EmailSearchParameters searchParameters);

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