CPD Results

The following document contains the results of PMD's CPD 4.2.2.

Duplications

File Line
org\jtheque\films\view\impl\panels\search\JPanelActorSearch.java 50
org\jtheque\films\view\impl\panels\search\JPanelRealizerSearch.java 51
    @Resource
    private ICountriesService countriesService;

    /**
     * Build the panel.
     */
    @PostConstruct
    private void build() {
        PanelBuilder builder = new PanelBuilder(this);

        boxNote = builder.add(new JCheckBox(), builder.gbcSet(0, 0));

        builder.addI18nLabel(Person.NOTE, builder.gbcSet(1, 0));

        modelNotes = new NotesComboBoxModel();

        builder.addComboBox(modelNotes, builder.gbcSet(2, 0));

        boxCountry = builder.add(new JCheckBox(), builder.gbcSet(0, 1));

        builder.addI18nLabel(Person.COUNTRY, builder.gbcSet(1, 1));

        modelCountries = new DataContainerCachedComboBoxModel<Country>(countriesService);

        builder.addComboBox(modelCountries, builder.gbcSet(2, 1));
    }

    @Override
    public Searcher<org.jtheque.primary.od.able.Person> getSearcher() {
        Searcher<org.jtheque.primary.od.able.Person> search = new DataSearcher<org.jtheque.primary.od.able.Person>();

        if (boxCountry.isSelected()) {
            search.addFilter(new CountryFilter<org.jtheque.primary.od.able.Person>(modelCountries.getSelectedData()));
        }

        if (boxNote.isSelected()) {
            search.addFilter(new NoteFilter<org.jtheque.primary.od.able.Person>(modelNotes.getSelectedNote()));
        }

        return search;
    }

    @Override
    public String getTitle() {
        return Managers.getManager(ILanguageManager.class).getMessage("search.realizer.title");

File Line
org\jtheque\films\view\impl\panels\principals\ActorView.java 193
org\jtheque\films\view\impl\panels\principals\RealizerView.java 184
            builder.addI18nLabel(Constants.Properties.Person.NAME, builder.gbcSet(0, 2));

            fieldName = builder.add(new JTextField(FIELD_COLUMNS), builder.gbcSet(1, 2, GridBagUtils.NONE, 0, 1));
            ConstraintManager.configure(fieldName, Constants.Properties.Person.NAME);
            fieldName.setEnabled(false);
        }

        /**
         * Add the field for country.
         *
         * @param builder The builder.
         */
        private void addCountryField(PanelBuilder builder) {
            builder.addI18nLabel(Constants.Properties.Person.COUNTRY, builder.gbcSet(0, 3));

            modelCountries = new DataContainerCachedComboBoxModel<Country>(Managers.getManager(IBeansManager.class).<DataContainer<Country>>getBean("countriesService"));

            comboCountries = builder.addComboBox(modelCountries, builder.gbcSet(1, 3));
            comboCountries.setEnabled(false);

            newCountryAction.setEnabled(false);

            builder.addButton(newCountryAction, builder.gbcSet(2, 3, GridBagUtils.NONE, 0, 1));
        }

        /**
         * Add the field for note.
         *
         * @param builder The builder.
         */
        private void addNoteField(PanelBuilder builder) {
            builder.addI18nLabel(Constants.Properties.Person.NOTE, builder.gbcSet(0, 4));

            modelNote = new NotesComboBoxModel();

            comboNote = builder.addComboBox(modelNote, builder.gbcSet(1, 4, GridBagUtils.NONE, GridBagUtils.ABOVE_BASELINE_LEADING, 0, 0, 1.0, 1.0));
            comboNote.setEnabled(false);
            comboNote.setRenderer(new NoteComboRenderer());
        }

        /**
         * Build the internal panel sort.
         *
         * @param parent The builder of the frame.
         */
        private static void buildPanelTri(PanelBuilder parent) {
            JXTitledPanel panelTri = new JThequeTitledPanel("realizer.view.panel.sort.title");

File Line
org\jtheque\films\services\impl\utils\file\exports\XLSExporter.java 80
org\jtheque\films\utils\ReportUtils.java 55
    public static JasperPrint configureForm001(JasperReport jasperReport, Collection<org.jtheque.films.persistence.od.able.Film> films) throws JRException {
        Map<String, String> parameters = new HashMap<String, String>(9);
        parameters.put(Form001_Parameters.TITLE, Managers.getManager(ILanguageManager.class).getMessage(Form001.TITLE));
        parameters.put(Form001_Parameters.KIND, Managers.getManager(ILanguageManager.class).getMessage(Film.KIND));
        parameters.put(Form001_Parameters.FILM, Managers.getManager(ILanguageManager.class).getMessage(Film.TITLE));
        parameters.put(Form001_Parameters.TYPE, Managers.getManager(ILanguageManager.class).getMessage(Film.TYPE));
        parameters.put(Form001_Parameters.REALIZER, Managers.getManager(ILanguageManager.class).getMessage(Film.REALIZER));
        parameters.put(Form001_Parameters.YEAR, Managers.getManager(ILanguageManager.class).getMessage(Film.YEAR));
        parameters.put(Form001_Parameters.DURATION, Managers.getManager(ILanguageManager.class).getMessage(Film.DURATION));
        parameters.put(Form001_Parameters.LANGUAGE, Managers.getManager(ILanguageManager.class).getMessage(Film.LANGUAGE));
        parameters.put(Form001_Parameters.ACTORS, Managers.getManager(ILanguageManager.class).getMessage(Film.ACTORS));

        return JasperFillManager.fillReport(jasperReport, parameters, new FilmsDatasource(films));

File Line
org\jtheque\films\controllers\impl\state\film\AutoAddFilmState.java 88
org\jtheque\films\controllers\impl\state\film\ModifyFilmState.java 85
        return controller.getViewState();
    }

    @Override
    public ControllerState create() {
        //Do nothing

        return null;
    }

    @Override
    public ControllerState manualEdit() {
        //Do nothing

        return null;
    }

    @Override
    public ControllerState delete() {
        //Do nothing

        return null;
    }

    @Override
    public ControllerState autoEdit(Data data) {
        Film film = (Film) data;

        if (Managers.getManager(IViewManager.class).askI18nUserForConfirmation(
                "film.dialogs.confirmSave", "film.dialogs.confirmSave.title")) {
            controller.save();
        } else {
            getViewModel().getCurrentFilm().restoreMemento();
        }

        getViewModel().setCurrentFilm(film);

        return controller.getAutoAddState();
    }

    @Override
    public ControllerState view(Data data) {
        Film film = (Film) data;

        if (Managers.getManager(IViewManager.class).askI18nUserForConfirmation(
                "film.dialogs.confirmSave", "film.dialogs.confirmSave.title")) {
            controller.save();
        } else {
            getViewModel().getCurrentFilm().restoreMemento();
        }

        getViewModel().setCurrentFilm(film);

        return controller.getViewState();
    }
}

File Line
org\jtheque\films\controllers\impl\state\actor\AutoAddActorState.java 91
org\jtheque\films\controllers\impl\state\actor\ModifyActorState.java 82
        return controller.getViewState();
    }

    @Override
    public ControllerState create() {
        //Do nothing

        return null;
    }

    @Override
    public ControllerState manualEdit() {
        //Do nothing

        return null;
    }

    @Override
    public ControllerState delete() {
        //Do nothing

        return null;
    }

    @Override
    public ControllerState autoEdit(Data data) {
        Person actor = (Person) data;

        assert actor.getType().equals(IActorService.PERSON_TYPE) : "The person must of type Actor";

        if (Managers.getManager(IViewManager.class).askI18nUserForConfirmation(
                "actor.dialogs.confirmSave", "actor.dialogs.confirmSave.title")) {
            controller.save();
        } else {
            getViewModel().getCurrentActor().restoreMemento();
        }

        getViewModel().setCurrentActor(actor);

        return controller.getAutoAddState();
    }

    @Override
    public ControllerState view(Data data) {
        Person actor = (Person) data;

        assert actor.getType().equals(IActorService.PERSON_TYPE) : "The person must of type Actor";

        if (Managers.getManager(IViewManager.class).askUserForConfirmation(

File Line
org\jtheque\films\persistence\dao\impl\DaoFilms.java 380
org\jtheque\films\persistence\dao\impl\DaoFilms.java 406
            Object[] parameters = {
                    film.getTitle(),
                    film.getNote().getValue().intValue(),
                    film.getComment(),
                    film.getDuration(),
                    film.getFilePath(),
                    film.getImage(),
                    film.getResume(),
                    film.getTheCollection().getId(),
                    film.getTheLanguage() == null ? null : film.getTheLanguage().getId(),
                    film.getTheLending() == null ? null : film.getTheLending().getId(),
                    film.getTheRealizer() == null ? null : film.getTheRealizer().getId(),
                    film.getTheSaga() == null ? null : film.getTheSaga().getId(),
                    film.getTheType() == null ? null : film.getTheType().getId(),

File Line
org\jtheque\films\view\impl\panels\principals\ActorView.java 302
org\jtheque\films\view\impl\panels\principals\RealizerView.java 293
            comboNote.setSelectedItem(current.getNote());
        }

        @Override
        protected void validate(Collection<JThequeError> errors) {
            ConstraintManager.validate(Constants.Properties.Person.NAME, fieldName.getText(), errors);
            ConstraintManager.validate(Constants.Properties.Person.FIRST_NAME, fieldFirstName.getText(), errors);
            ConstraintManager.validate(Constants.Properties.Person.COUNTRY, modelCountries.getSelectedData(), errors);
        }

        @Override
        public void setEnabled(boolean enabled) {
            fieldFirstName.setEnabled(enabled);
            fieldName.setEnabled(enabled);
            comboCountries.setEnabled(enabled);
            comboNote.setEnabled(enabled);
            newCountryAction.setEnabled(enabled);
        }
    }

}

File Line
org\jtheque\films\services\impl\utils\web\GenericWebGetter.java 187
org\jtheque\films\services\impl\utils\web\GenericWebGetter.java 227
                while (scanner.hasNextLine() && getAnalyzer().isNotComplete()) {
                    String line = scanner.nextLine().trim();

                    getAnalyzer().analyzeLine(line);
                }
            } catch (MalformedURLException e) {
                Managers.getManager(ILoggingManager.class).getLogger(getClass()).error(e);
            } catch (IOException e) {
                Managers.getManager(ILoggingManager.class).getLogger(getClass()).error(e);
            } finally {
                if (scanner != null) {
                    scanner.close();
                }
            }
        }

File Line
org\jtheque\films\services\impl\utils\file\restore\DBV3BackupReader.java 84
org\jtheque\films\services\impl\utils\file\restore\DBV4BackupReader.java 94
    public DBV4BackupReader() {
        super();

        Managers.getManager(IBeansManager.class).inject(this);
    }

    @Override
    public void readBackup(Object object) {
        Connection connection = (Connection) object;

        try {
            Collection<Film> films = importFilms(connection);
            Collection<Person> actors = importActors(connection);
            Collection<Person> realizers = importRealizers(connection);
            Collection<Kind> kinds = importKinds(connection);
            Collection<Type> types = importTypes(connection);
            Collection<Language> languages = importLanguages(connection);
            Collection<Country> countries = importCountries(connection);

File Line
org\jtheque\films\services\impl\utils\file\restore\DBV3BackupReader.java 252
org\jtheque\films\services\impl\utils\file\restore\DBV4BackupReader.java 266
                realizer.getTemporaryContext().setCountry(result.getInt("country"));
                realizer.setNote(notesService.getDefaultNote());

                realizers.add(realizer);
            }
        } catch (SQLException e) {
            throw new DatabaseException(e);
        } finally {
            DatabaseUtils.close(result);
            DatabaseUtils.close(statement);
        }

        return realizers;
    }

    /**
     * Import the kinds.
     *
     * @param connection The connection.
     * @return The imported kinds.
     * @throws DatabaseException Thrown when an error occurs during the database data getting process.
     */
    private Collection<Kind> importKinds(Connection connection) throws DatabaseException {
        Collection<Kind> kinds = new ArrayList<Kind>(10);

        Statement statement = null;
        ResultSet result = null;
        try {
            statement = connection.createStatement();
            result = statement.executeQuery("SELECT * FROM t_kinds");