Coverage Report - org.jtheque.films.view.impl.actions.auto.imports.AcValidateAutoImportView
 
Classes in this File Line Coverage Branch Coverage Complexity
AcValidateAutoImportView
0 %
0/7
0 %
0/2
1.25
AcValidateAutoImportView$1
0 %
0/4
N/A
1.25
AcValidateAutoImportView$ImportFilmsRunnable
0 %
0/5
N/A
1.25
 
 1  
 package org.jtheque.films.view.impl.actions.auto.imports;
 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.Managers;
 20  
 import org.jtheque.core.managers.beans.IBeansManager;
 21  
 import org.jtheque.core.managers.view.able.IViewManager;
 22  
 import org.jtheque.core.managers.view.edt.SimpleTask;
 23  
 import org.jtheque.core.managers.view.impl.actions.JThequeAction;
 24  
 import org.jtheque.films.persistence.od.able.Film;
 25  
 import org.jtheque.films.services.able.IAutoImportService;
 26  
 import org.jtheque.films.services.able.IFilmsService;
 27  
 import org.jtheque.films.view.able.IAutoImportView;
 28  
 
 29  
 import javax.annotation.Resource;
 30  
 import java.awt.event.ActionEvent;
 31  
 import java.util.Collection;
 32  
 
 33  
 /**
 34  
  * Action to validate the auto import process.
 35  
  *
 36  
  * @author Baptiste Wicht
 37  
  */
 38  0
 public final class AcValidateAutoImportView extends JThequeAction {
 39  
     @Resource
 40  
     private IAutoImportService service;
 41  
 
 42  
     @Resource
 43  
     private IFilmsService filmsService;
 44  
 
 45  
     @Resource
 46  
     private IAutoImportView autoImportView;
 47  
 
 48  
     /**
 49  
      * Create a new AcValidateAutoImportView action.
 50  
      */
 51  
     public AcValidateAutoImportView() {
 52  0
         super("auto.import.view.actions.import");
 53  
         
 54  0
         Managers.getManager(IBeansManager.class).inject(this);
 55  0
     }
 56  
 
 57  
     @Override
 58  
     public void actionPerformed(ActionEvent arg0) {
 59  0
         if (autoImportView.validateContent(IAutoImportView.PHASE_2)) {
 60  0
             Managers.getManager(IViewManager.class).execute(new SimpleTask() {
 61  
                 @Override
 62  
                 public void run() {
 63  0
                     autoImportView.startWait();
 64  
 
 65  0
                     new Thread(new ImportFilmsRunnable()).start();
 66  0
                 }
 67  
             });
 68  
         }
 69  0
     }
 70  
 
 71  
     /**
 72  
      * A runnable for search titles.
 73  
      *
 74  
      * @author Baptiste Wicht
 75  
      */
 76  0
     private final class ImportFilmsRunnable implements Runnable {
 77  
         @Override
 78  
         public void run() {
 79  0
             Collection<Film> films = service.importFilms(autoImportView.getModel().getTitles(), autoImportView.isWebMode(), autoImportView.getSelectedSite());
 80  
 
 81  0
             filmsService.createAll(films);
 82  
 
 83  0
             autoImportView.stopWait();
 84  0
         }
 85  
     }
 86  
 }