package com.peetz.tradingcards.view;

import com.peetz.tradingcards.dal.SportDao;
import com.peetz.tradingcards.service.SportService;
import java.io.Serializable;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author tpeetz
 */
@ManagedBean(name="TradingCardsView")
@RequestScoped
public class SportView implements Serializable {

	private static final long serialVersionUID = 1399103334723066025L;

	private static final Logger LOG = Logger.getLogger(SportView.class.getName());

    private String name;

    @EJB
    private SportService sportService;

    public SportView() {
        LOG.info("SportView created");
    }

    public Integer getSportNumber() {
        LOG.info("SportView#getSportNumber");
        return sportService.getAllSports().size();
    }
    
    public Integer getTeamNumber() {
        LOG.info("SportView#getTeamNumber");
        return sportService.getAllTeams().size();
    }

    public String getName() {
        LOG.info("SportView#getName");
        return name;
    }

    public void setName(String name) {
        this.name = name;
        sportService.addSport(name);
        LOG.info("SportView#setName");
    }
}
