package de.ivu.elect.presentation.internet.action;

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

import de.ivu.elect.business.internet.boundary.CoreInternetWidgetBoundaryCreate;
import de.ivu.elect.business.internet.entity.InternetWidget;
import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.presentation.internet.InternetWidgetEditView;

@Named(InternetWidgetKopieAction.COMPONENT_NAME)
public class InternetWidgetKopieAction extends AbstractInternetWidgetAction {

  public static final String COMPONENT_NAME = "internetWidgetKopieAction";

  private static final long serialVersionUID = 1L;

  @Inject
  private transient CoreInternetWidgetBoundaryCreate internetWidgetCreate;

  @Override
  protected UseCasePermission getRequiredPermission() {
    return UseCasePermission.INTERNET_WIDGET_CREATE;
  }

  @Override
  protected String doIt(InternetWidget entity) {

    InternetWidget copy = internetWidgetCreate.copy(entity);
    messages.addInfoMessage("internet.widget.kopiert");
    conversationSelect.setEntity(copy);

    return InternetWidgetEditView.VIEW_ID;
  }

  @Override
  public String getLabelKey() {
    return "entity.edit.action.copy";
  }

  @Override
  public String getIcon() {
    return appIcons.getIconCopy();
  }
}
