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

import java.util.Collections;
import java.util.List;

import de.ivu.elect.business.internet.entity.InternetWidget;
import de.ivu.elect.business.internet.entity.QInternetWidget;
import de.ivu.elect.jee.entity.QueryDsl;

public class InternetWidgetSearch extends AbstractInternetWidgetSearch {

  public InternetWidgetSearch() {
    super();
  }

  @Override
  protected List<InternetWidget> querySearchResult(InternetWidgetSearchParameters searchParameters) {
    if (searchParameters.getInternetSeite() == null) {
      return Collections.emptyList();
    }

    QInternetWidget qInternetWidget = QInternetWidget.internetWidget;

    QueryDsl queryDsl = dao.getQueryDsl();
    queryDsl.from(qInternetWidget);

    queryDsl.eq(qInternetWidget.internetSeite, searchParameters.getInternetSeite());

    queryDsl.orderBy(qInternetWidget.zeile.asc(), qInternetWidget.position.asc());

    return searchParameters.applyLimit(queryDsl).list(qInternetWidget);
  }
}
