
package de.ivu.elect.presentation.email;

import javax.inject.Inject;
import javax.inject.Named;

import org.apache.deltaspike.core.api.scope.ViewAccessScoped;

import de.ivu.elect.business.email.entity.EmailLayout;
import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.jee.entity.EagerLoadingCollector;
import de.ivu.elect.jee.presentation.dynamicform.FormBuilder;
import de.ivu.elect.jee.presentation.search.AbstractSearchParameters;
import de.ivu.elect.presentation.View;
import de.ivu.elect.presentation.email.table.EmailLayoutColumnBuilder;
import de.ivu.elect.presentation.hilfe.OnlineHilfeId;
import de.ivu.elect.presentation.security.AbstractGebietSecurityFilter;

@OnlineHilfeId(value = "740", mehrfachVergebenOk = true)
@ViewAccessScoped
@Named(AbstractEmailLayoutSearchView.COMPONENT_NAME)
@View(viewId = AbstractEmailLayoutSearchView.VIEW_ID, useCase = UseCasePermission.EMAIL_LAYOUT_SEARCH)
public class EmailLayoutSearchView extends AbstractEmailLayoutSearchView {

  private static final long serialVersionUID = 1L;

  @Inject
  private EmailLayoutColumnBuilder emailLayoutColumnBuilder;

  public EmailLayoutSearchView() {
    super();
  }

  @Override
  protected AbstractGebietSecurityFilter<EmailLayout> getGebietSecurityFilter() {
    return KEIN_GEBIET_SECURITY_FILTER;
  }

  @Override
  public void presetSearchParameters() {
    // Do nothing...
  }

  @Override
  public void addProperties(FormBuilder formBuilder) {
    String wildcardTooltip = getMessage(AbstractSearchParameters.WILDCARD_TOOLTIP_MSG_KEY);

    formBuilder.addProperty(getSearchParameters().getBezeichnungProperty()).withTooltip(wildcardTooltip).withRequired(false);
  }

  @Override // ELECTKOM-1649
  public EagerLoadingCollector<EmailLayout> getEagerLoadingCollector() {
    EagerLoadingCollector<EmailLayout> eagerLoadingCollector = EagerLoadingCollector.create();
    emailLayoutColumnBuilder.collectEagerLoadings(eagerLoadingCollector);

    return eagerLoadingCollector;
  }
}
