
package de.ivu.elect.presentation.personenregister;

import javax.annotation.Nullable;
import javax.inject.Inject;

import de.ivu.elect.business.person.entity.EntityMitPersonendaten;
import de.ivu.elect.business.wahl.boundary.WahlSessionSelector;
import de.ivu.elect.business.wahl.boundary.WahlterminSessionSelect;
import de.ivu.elect.business.wahl.entity.Wahl;
import de.ivu.elect.business.wahl.entity.Wahltermin;
import de.ivu.elect.jee.presentation.redirect.Redirect;
import de.ivu.elect.jee.presentation.security.StartViewResolver;
import de.ivu.elect.jee.presentation.view.AbstractView;
import de.ivu.elect.presentation.ViewFormBuilder;

public abstract class AbstractEntityMitPersonendatenSelectionViewCreateViewHelper<E extends EntityMitPersonendaten> extends AbstractView {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient StartViewResolver startViewResolver;

  @Inject
  private transient WahlterminSessionSelect wahlterminSessionSelect;

  @Inject
  private transient WahlSessionSelector wahlSessionSelector;

  public AbstractEntityMitPersonendatenSelectionViewCreateViewHelper() {
    super();
  }

  @Nullable
  public abstract String checkPreCondition();

  protected String getStartViewId() {
    return startViewResolver.getStartViewId();
  }

  public abstract String getParentViewId();

  public abstract String getViewId();

  public boolean isWahlterminSelected() {
    return wahlterminSessionSelect.isSelected();
  }

  public Wahltermin getSelectedWahltermin() {
    return wahlterminSessionSelect.getEntity();
  }

  public boolean isWahlSelected() {
    return wahlSessionSelector.isSelected();
  }

  public Wahl getSelectedWahl() {
    return wahlSessionSelector.getEntity();
  }

  @Redirect
  public String cancel() {
    return goBack(getParentViewId());
  }

  protected abstract ViewFormBuilder getViewFormBuilder();
}
