package de.ivu.elect.presentation.wahl.exchange;

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

import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.business.wahl.boundary.WasWahlImporter;
import de.ivu.elect.presentation.View;
import de.ivu.elect.presentation.replikation.ReplikationPresentationStatus;

@Named(AbstractWahlImportSearchView.COMPONENT_NAME)
@View(viewId = AbstractWahlImportSearchView.VIEW_ID, useCase = UseCasePermission.WAHL_IMPORTIEREN)
public class WasWahlImportSearchView extends AbstractWahlImportSearchView {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient WasWahlImporter importer;

  @Inject
  private transient ReplikationPresentationStatus replikationPresentationStatus;

  @Override
  protected WasWahlImporter getImporter() {
    return importer;
  }

  // DUMMY muss bleiben, wegen Weld-Bug
  public void setImporter(WasWahlImporter importer) {
    this.importer = importer;
  }

  @Override
  public boolean isUploadPossible() {
    return super.isUploadPossible() && !isSlave();
  }

  // WASDE-1153
  private boolean isSlave() {
    return replikationPresentationStatus.isSlave();
  }
}
