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

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;

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

import de.ivu.elect.business.internet.entity.InternetWidget;
import de.ivu.elect.business.internet.entity.InternetWidgetFileEntity;

@RequestScoped
@Named(InternetWidgetFileConversationSelect.COMPONENT_NAME)
public class InternetWidgetFileConversationSelect implements java.io.Serializable {

  public static final String COMPONENT_NAME = "internetWidgetFileConversationSelect";

  private static final long serialVersionUID = 1L;

  @Inject
  @ConversationGroup(InternetWidgetFileConversationStore.class)
  protected transient InternetWidgetFileConversationStore conversationStore;

  private transient InternetWidgetFileEntity cache;

  public boolean isSelected() {
    return conversationStore.isSelected();
  }

  public InternetWidgetFileEntity getEntity() {

    if (cache == null) {
      cache = conversationStore.getEntity();
    }
    return cache;
  }

  public void setEntity(InternetWidgetFileEntity entity, InternetWidget internetWidget) {
    cache = null;
    conversationStore.setEntityPK(entity, internetWidget);
  }

}