package online.mrsys.movierecommender.action.admin;

import com.opensymphony.xwork2.ActionContext;

import online.mrsys.movierecommender.action.base.BaseAction;
import online.mrsys.movierecommender.action.base.WebConstant;
import online.mrsys.movierecommender.domain.Movie;

public class DeleteMovieAction extends BaseAction {
    
    private static final long serialVersionUID = -863968185438174742L;
    
    private Integer id;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Override
    public String execute() throws Exception {
        ActionContext actionContext = ActionContext.getContext();
        Movie movie = movieManager.getMovieById(getId());
        if (movie == null) {
            actionContext.getSession().put(WebConstant.INTERCEPT_2, "Movie does not exist");
            return ERROR;
        }
        movieManager.deleteMovie(getId());
        actionContext.getSession().put(WebConstant.INTERCEPT_2, "Success");
        return SUCCESS;
    }
    
}

@@ -46,16 +46,40 @@
 admin;%0A%0A
+import java.util.List;%0A%0A
 import c
@@ -290,16 +290,68 @@
 n.Movie;
+%0Aimport online.mrsys.movierecommender.domain.Rating;
 %0A%0Apublic
@@ -961,24 +961,199 @@
 ;%0A        %7D%0A
+        List%3CRating%3E ratings = movieManager.getRatingsByMovie(movie);%0A        for (Rating rating : ratings) %7B%0A            movieManager.deleteRating(rating.getId());%0A        %7D%0A
         movi

fix the bug when delete movie