package com.peetz.medien.service;

import java.util.Collection;

import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;

import com.peetz.medien.entity.AudioCDEntity;
import com.peetz.medien.entity.BoxSetEntity;
import com.peetz.medien.entity.FilmEntity;
import java.util.ArrayList;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

@Stateless(name="MedienService")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class MedienServiceImpl implements MedienService {

    @PersistenceContext(unitName = "kontor")
    private EntityManager em;

    @SuppressWarnings("unchecked")
	@Override
    public Collection<AudioCDEntity> getAllCDs() {
        Query query = em.createNamedQuery("AudioCD.findAll");
        ArrayList<AudioCDEntity> cdList = new ArrayList<AudioCDEntity>(query.getResultList());
        return cdList;
    }

    @Override
    public AudioCDEntity addCD(String title) {
		// TODO Auto-generated method stub
		return null;
    }

    @SuppressWarnings("unchecked")
	@Override
    public Collection<FilmEntity> getAllDVDs() {
        Query query = em.createNamedQuery("Film.findAll");
        ArrayList<FilmEntity> filmList = new ArrayList<FilmEntity>(query.getResultList());
        return filmList;
    }

    @Override
    public FilmEntity addDVD(String title) {
		// TODO Auto-generated method stub
		return null;
    }

    @Override
    public Collection<BoxSetEntity> getAllBoxSets() {
    		// TODO Auto-generated method stub
		return null;
    }

    @Override
    public BoxSetEntity addBoxSet(String title) {
		// TODO Auto-generated method stub
		return null;
    }
	
    @Override
    public BoxSetEntity assignBoxSet(BoxSetEntity boxSet, FilmEntity film) {
		// TODO Auto-generated method stub
		return null;
    }

    @Override
    public void saveCD(AudioCDEntity audioCD) {
		// TODO Auto-generated method stub
		
    }
}
