Coverage Report - org.jtheque.films.controllers.impl.AutoAddController
 
Classes in this File Line Coverage Branch Coverage Complexity
AutoAddController
0 %
0/23
0 %
0/4
1.333
 
 1  
 package org.jtheque.films.controllers.impl;
 2  
 
 3  
 /*
 4  
  * This file is part of JTheque.
 5  
  *
 6  
  * JTheque is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License.
 9  
  *
 10  
  * JTheque is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  
  * GNU General Public License for more details.
 14  
  *
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 
 19  
 import org.jtheque.core.managers.view.able.controller.AbstractController;
 20  
 import org.jtheque.films.controllers.able.IAutoAddController;
 21  
 import org.jtheque.films.controllers.able.IFilmController;
 22  
 import org.jtheque.films.persistence.od.able.Film;
 23  
 import org.jtheque.films.services.able.IFilmAutoService;
 24  
 import org.jtheque.films.services.able.IFilmsService;
 25  
 import org.jtheque.films.services.impl.utils.EditArguments;
 26  
 import org.jtheque.films.services.impl.utils.web.FilmResult;
 27  
 import org.jtheque.films.view.able.IAutoAddView;
 28  
 
 29  
 import javax.annotation.Resource;
 30  
 
 31  
 /**
 32  
  * An auto add controller implementation.
 33  
  *
 34  
  * @author Baptiste Wicht
 35  
  */
 36  0
 public final class AutoAddController extends AbstractController implements IAutoAddController {
 37  
     private boolean edit;
 38  
     private EditArguments args;
 39  
 
 40  
     @Resource
 41  
     private IFilmAutoService filmAutoService;
 42  
 
 43  
     @Resource
 44  
     private IFilmsService filmsService;
 45  
 
 46  
     @Resource
 47  
     private IAutoAddView autoAddView;
 48  
 
 49  
     @Resource
 50  
     private IFilmController filmController;
 51  
 
 52  
     @Override
 53  
     public IAutoAddView getView() {
 54  0
         return autoAddView;
 55  
     }
 56  
 
 57  
     @Override
 58  
     public void add() {
 59  0
         autoAddView.display();
 60  0
     }
 61  
 
 62  
     @Override
 63  
     public void edit() {
 64  0
         displayView();
 65  0
     }
 66  
 
 67  
     @Override
 68  
     public void setFields(EditArguments args) {
 69  0
         edit = true;
 70  0
         this.args = args;
 71  0
     }
 72  
 
 73  
     @Override
 74  
     public void auto(FilmResult selectedFilm) {
 75  0
         if (edit) {
 76  0
             Film film = filmController.getViewModel().getCurrentFilm();
 77  
 
 78  0
             filmAutoService.modifyFilm(selectedFilm, film, args);
 79  
 
 80  0
             filmController.view(film);
 81  0
             filmController.manualEdit();
 82  0
         } else {
 83  0
             Film film = filmAutoService.getFilm(selectedFilm);
 84  
 
 85  0
             filmsService.create(film);
 86  
 
 87  0
             filmController.view(film);
 88  
         }
 89  0
     }
 90  
 
 91  
     @Override
 92  
     public void displayView() {
 93  0
         super.displayView();
 94  
 
 95  0
         if (edit) {
 96  0
             autoAddView.sendMessage("title", filmController.getViewModel().getCurrentFilm().getTitle());
 97  
         }
 98  0
     }
 99  
 }