/**
 * License Agreement.
 *
 *  JBoss RichFaces - Ajax4jsf Component Library
 *
 * Copyright (C) 2007  Exadel, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */
package org.richfaces.realworld.service;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.richfaces.realworld.domain.Image;

@Name("imageAction")
@Stateless
public class ImageAction implements IImageAction {

	@In(value="entityManager")
	EntityManager em;
	
	public void deleteImage(Image image){
		image.getAlbum().removeImage(image);
		em.flush();
	}

/*	public void editImage(Image image, boolean parentChanged) {
		if(parentChanged){
			Album albumPrevious = image.getAlbum();
			String login = albumPrevious.getOwner().getLogin();
			String albumName = image.getAlbumName();
			albumPrevious.removeImage(image);
			Album album = (Album)em.createNamedQuery(Constants.ALBUM_BY_ALBUM_NAME_AND_LOGIN_QUERY).setParameter(Constants.ALBUM_NAME_PARAMETER, albumName).setParameter(Constants.LOGIN_PARAMETER, login).getSingleResult();
			album.addImage(image);
		}
		image.getTags().clear();
		image.setTags(image.getMeta());
		em.flush();
	}*/

/*	public void addImage(Image image) {
		em.persist(image);
		image.getAlbum().addImage(image);
		image.getTags().clear();
		image.setTags(image.getMeta());
		em.flush();
	}*/
	
/*	public void deleteComment(Comment comment){
		comment.getImage().removeComment(comment);
		em.flush();
	}*/
	
/*	public void addComment(Comment comment){
		comment.getImage().addComment(comment);
		em.flush();
	}*/


/*	public void vote(Image image, Long value) {
		image.getRank().setHits(image.getRank().getHits() + 1);
		image.getRank().setTotal(value += image.getRank().getTotal());
		em.flush();
	}*/
}
