Fork me on GitHub

CPD Results

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

Duplications

File Line
fr/paris/lutece/plugins/transparency/web/AppointmentPublicXPage.java 118
fr/paris/lutece/plugins/transparency/web/AppointmentXPage.java 172
        if ( request.getParameter( Paginator.PARAMETER_PAGE_INDEX ) != null && _appointmentIdsList != null ) 
        {
            // paginate list
            _strCurrentPageIndex = request.getParameter( Paginator.PARAMETER_PAGE_INDEX );
            paginator = new Paginator<Integer>( _appointmentIdsList, _nItemsPerPage, getViewFullUrl( VIEW_MANAGE_APPOINTMENTS ),
                Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex );
            
            _filter.setListIds( paginator.getPageItems( ) );
            
            // get full appointments corresponding to the Ids
            appointmentList = AppointmentHome.getFullAppointmentsList( _filter );
        }
        else if ( request.getParameter( PARAMETER_SORTED_ATTRIBUTE_NAME ) != null && _appointmentIdsList != null )
        {
            // sort list
            if ( request.getParameter( PARAMETER_SORTED_ATTRIBUTE_NAME ).equals( PARAMETER_START_DATE ) )
            {
                if ( request.getParameter( PARAMETER_ASC ) != null && request.getParameter( PARAMETER_ASC ).equals( "true" ) )
                {
                    _filter.setOrderBy( PARAMETER_START_DATE + " ASC " );
                }
                else
                {
                    _filter.setOrderBy( PARAMETER_START_DATE + " DESC " );
                }
            }
            
            // reinitialize
            _strCurrentPageIndex = "1" ;
            _filter.setListIds( null ) ;
            
            // search all Ids whith the same filter
            _appointmentIdsList = AppointmentHome.getAppointmentIdsList( _filter );
            
            paginator = new Paginator<Integer>( _appointmentIdsList, _nItemsPerPage, getViewFullUrl( VIEW_MANAGE_APPOINTMENTS ) ,
                Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex );
            
            _filter.setListIds(  paginator.getPageItems( ) );
            
            // get full appointments corresponding to the Ids
            appointmentList = AppointmentHome.getFullAppointmentsList( _filter );
        }
        else
        {
            // new search 
            String strSearchPeriod = request.getParameter( PARAMETER_SEARCH_PERIOD );
            String strSearchElectedOfficial = request.getParameter( PARAMETER_SEARCH_ELECTED_OFFICIAL );
            String strSearchLobby = request.getParameter( PARAMETER_SEARCH_LOBBY );
            String strSearchTitle = request.getParameter( PARAMETER_SEARCH_TITLE );

            
            if ( strSearchPeriod != null ) _filter.setNumberOfDays( StringUtil.getIntValue( strSearchPeriod, CONSTANT_DEFAULT_SEARCH_PERIOD ) );
            _filter.setLobbyName( strSearchLobby );
            _filter.setElectedOfficialName( strSearchElectedOfficial );
            _filter.setTitle( strSearchTitle );
File Line
fr/paris/lutece/plugins/transparency/business/AppointmentDAO.java 197
fr/paris/lutece/plugins/transparency/business/AppointmentDAO.java 256
        StringBuilder sql = buildSQL( filter, false );

        DAOUtil daoUtil = new DAOUtil( sql.toString( ), plugin );
        int i = 1;

        if ( filter != null && 
                (filter.getListIds( ) ==null || filter.getListIds( ).size( ) == 0 ) ) 
        {
                if ( filter.getNumberOfDays( ) > 0 )
                    daoUtil.setInt( i++, filter.getNumberOfDays( ) );
                if ( !StringUtils.isBlank( filter.getElectedOfficialName( ) ) )
                    daoUtil.setString( i++, "%" + filter.getElectedOfficialName( ) + "%" );
                if ( !StringUtils.isBlank( filter.getLobbyName( ) ) )
                    daoUtil.setString( i++, "%" + filter.getLobbyName( ) + "%" );
                if ( !StringUtils.isBlank( filter.getUserId( ) ) )
                    daoUtil.setString( i++, filter.getUserId( ) );
                if ( filter.getIdAppointment( ) > 0 )
                    daoUtil.setInt( i++, filter.getIdAppointment( ) );
                if ( !StringUtils.isBlank( filter.getTitle( ) ) )
                    daoUtil.setString( i++, "%" + filter.getTitle( ) + "%" );
        }
        

        // execute
        daoUtil.executeQuery( );

        while ( daoUtil.next( ) )
        {
File Line
fr/paris/lutece/plugins/transparency/web/AbstractManageAppointementsJspBean.java 56
fr/paris/lutece/plugins/transparency/web/AbstractManageLobbiesJspBean.java 56
    private static final String PROPERTY_DEFAULT_LIST_ITEM_PER_PAGE = "transparency.listItems.itemsPerPage";

    // Parameters
    private static final String PARAMETER_PAGE_INDEX = "page_index";

    // Markers
    private static final String MARK_PAGINATOR = "paginator";
    private static final String MARK_NB_ITEMS_PER_PAGE = "nb_items_per_page";

    // Variables
    private int _nDefaultItemsPerPage;
    private String _strCurrentPageIndex;
    private int _nItemsPerPage;

    /**
     * Return a model that contains the list and paginator infos
     * 
     * @param request
     *            The HTTP request
     * @param strBookmark
     *            The bookmark
     * @param list
     *            The list of item
     * @param strManageJsp
     *            The JSP
     * @return The model
     */
    protected Map<String, Object> getPaginatedListModel( HttpServletRequest request, String strBookmark, List list, String strManageJsp )
    {
        _strCurrentPageIndex = Paginator.getPageIndex( request, Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex );
        _nDefaultItemsPerPage = AppPropertiesService.getPropertyInt( PROPERTY_DEFAULT_LIST_ITEM_PER_PAGE, 50 );
        _nItemsPerPage = Paginator.getItemsPerPage( request, Paginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPage, _nDefaultItemsPerPage );

        UrlItem url = new UrlItem( strManageJsp );
        String strUrl = url.getUrl( );

        // PAGINATOR
        LocalizedPaginator paginator = new LocalizedPaginator( list, _nItemsPerPage, strUrl, PARAMETER_PAGE_INDEX, _strCurrentPageIndex, getLocale( ) );

        Map<String, Object> model = getModel( );

        model.put( MARK_NB_ITEMS_PER_PAGE, String.valueOf( _nItemsPerPage ) );
        model.put( MARK_PAGINATOR, paginator );
        model.put( strBookmark, paginator.getPageItems( ) );

        return model;
    }
}
File Line
fr/paris/lutece/plugins/transparency/web/AppointmentJspBean.java 324
fr/paris/lutece/plugins/transparency/web/AppointmentXPage.java 515
        if ( idLobby > 0 && lobby != null && lobby.getName( ).equals( strSelectLobby ) )
        {
            LobbyAppointmentHome.removeByAppointmentId( _appointment.getId( ) );
            LobbyAppointmentHome.create( new LobbyAppointment( lobby.getId( ), _appointment.getId( ) ) );
            _appointment.getLobbyList( ).add( lobby );
        }
        else
            if ( !StringUtils.isBlank( strSelectLobby ) )
            {
                Lobby newLobby = new Lobby( );
                newLobby.setName( strSelectLobby );
                newLobby.setVersionDate( new Date( ( new java.util.Date( ) ).getTime( ) ) );
                newLobby = LobbyHome.create( newLobby );

                LobbyAppointmentHome.removeByAppointmentId( _appointment.getId( ) );
                LobbyAppointmentHome.create( new LobbyAppointment( newLobby.getId( ), _appointment.getId( ) ) );
                _appointment.getLobbyList( ).add( newLobby );

            }

        addInfo( INFO_APPOINTMENT_UPDATED, getLocale( ) );
File Line
fr/paris/lutece/plugins/transparency/business/LobbyDAO.java 199
fr/paris/lutece/plugins/transparency/business/LobbyDAO.java 231
            daoUtil.setString( 1, strLikeText );

        daoUtil.executeQuery( );

        while ( daoUtil.next( ) )
        {
            Lobby lobby = new Lobby( );
            int nIndex = 1;

            lobby.setId( daoUtil.getInt( nIndex++ ) );
            lobby.setName( daoUtil.getString( nIndex++ ) );
            lobby.setNationalId( daoUtil.getString( nIndex++ ) );
            lobby.setNationalIdType( daoUtil.getString( nIndex++ ) );
            lobby.setUrl( daoUtil.getString( nIndex++ ) );
            lobby.setJsonData( daoUtil.getString( nIndex++ ) );
            lobby.setVersionDate( daoUtil.getDate( nIndex++ ) );

            lobbyList.add( lobby );
        }

        daoUtil.free( );
        return lobbyList;
    }

    /**
     * {@inheritDoc }
     */
    @Override
    public List<Lobby> selectLobbiesListByAppointment( int idAppointment, Plugin plugin )
File Line
fr/paris/lutece/plugins/transparency/web/AppointmentJspBean.java 208
fr/paris/lutece/plugins/transparency/web/AppointmentXPage.java 360
        if ( idLobby > 0 && lobby != null )
        {
            LobbyAppointmentHome.create( new LobbyAppointment( lobby.getId( ), _appointment.getId( ) ) );
            _appointment.getLobbyList( ).add( lobby );
        }
        else
            if ( !StringUtils.isBlank( strSelectLobby ) )
            {
                Lobby newLobby = new Lobby( );
                newLobby.setName( strSelectLobby );
                newLobby.setVersionDate( new Date( ( new java.util.Date( ) ).getTime( ) ) );
                newLobby = LobbyHome.create( newLobby );

                LobbyAppointmentHome.create( new LobbyAppointment( newLobby.getId( ), _appointment.getId( ) ) );
                _appointment.getLobbyList( ).add( newLobby );

            }

        addInfo( INFO_APPOINTMENT_CREATED, getLocale( ) );
File Line
fr/paris/lutece/plugins/transparency/business/LobbyDAO.java 100
fr/paris/lutece/plugins/transparency/business/LobbyDAO.java 129
        daoUtil.setInt( 1, nKey );
        daoUtil.executeQuery( );
        Lobby lobby = null;

        if ( daoUtil.next( ) )
        {
            lobby = new Lobby( );
            int nIndex = 1;

            lobby.setId( daoUtil.getInt( nIndex++ ) );
            lobby.setName( daoUtil.getString( nIndex++ ) );
            lobby.setNationalId( daoUtil.getString( nIndex++ ) );
            lobby.setNationalIdType( daoUtil.getString( nIndex++ ) );
            lobby.setUrl( daoUtil.getString( nIndex++ ) );
            lobby.setJsonData( daoUtil.getString( nIndex++ ) );
            lobby.setVersionDate( daoUtil.getDate( nIndex++ ) );
        }

        daoUtil.free( );
        return lobby;
    }

    /**
     * {@inheritDoc }
     */
    @Override
    public Lobby loadByNationalId( String strNationalId, Plugin plugin )
File Line
fr/paris/lutece/plugins/transparency/business/AppointmentDAO.java 126
fr/paris/lutece/plugins/transparency/business/AppointmentDAO.java 225
            appointment = new Appointment( );
            int nIndex = 1;

            appointment.setId( daoUtil.getInt( nIndex++ ) );
            appointment.setTitle( daoUtil.getString( nIndex++ ) );
            appointment.setDescription( daoUtil.getString( nIndex++ ) );
            appointment.setStartDate( daoUtil.getDate( nIndex++ ) );
            appointment.setEndDate( daoUtil.getDate( nIndex++ ) );
            appointment.setTypeId( daoUtil.getInt( nIndex++ ) );
            appointment.setTypeLabel( daoUtil.getString( nIndex++ ) );
            appointment.setUrl( daoUtil.getString( nIndex++ ) );
            appointment.setContacts( daoUtil.getString( nIndex++ ) );
File Line
fr/paris/lutece/plugins/transparency/web/AppointmentPublicXPage.java 197
fr/paris/lutece/plugins/transparency/web/AppointmentXPage.java 252
        model.put( MARK_LOBBY_REFERENCE_START_URL, AppPropertiesService.getProperty( PROPERTY_LOBBY_REFERENCE_START_URL_KEY ) );

        return getXPage( TEMPLATE_MANAGE_APPOINTMENTS, request.getLocale( ), model );
    }

    /**
     * Returns the form to update info about a appointment
     *
     * @param request
     *            The Http request
     * @return The HTML form to update info
     */
    @View( VIEW_DETAIL_APPOINTMENT )
    public XPage getDetailAppointment( HttpServletRequest request )
    {
        int nId = Integer.parseInt( request.getParameter( PARAMETER_ID_APPOINTMENT ) );

        if ( _appointment == null || ( _appointment.getId( ) != nId ) )
        {
            _appointment = AppointmentHome.findByPrimaryKey( nId );
        }

        _appointment.setElectedOfficialList( ElectedOfficialHome.getElectedOfficialsListByAppointment( _appointment.getId( ) ) );
        _appointment.setLobbyList( LobbyHome.getLobbiesListByAppointment( _appointment.getId( ) ) );

        Map<String, Object> model = getModel( );
        model.put( MARK_APPOINTMENT, _appointment );
File Line
fr/paris/lutece/plugins/transparency/business/AppointmentDAO.java 92
fr/paris/lutece/plugins/transparency/business/AppointmentDAO.java 166
            daoUtil.setString( nIndex++, appointment.getTitle( ) );
            daoUtil.setString( nIndex++, appointment.getDescription( ) );
            daoUtil.setDate( nIndex++, appointment.getStartDate( ) );
            daoUtil.setDate( nIndex++, appointment.getEndDate( ) );
            daoUtil.setInt( nIndex++, appointment.getTypeId( ) );
            daoUtil.setString( nIndex++, appointment.getTypeLabel( ) );
            daoUtil.setString( nIndex++, appointment.getUrl( ) );
            daoUtil.setString( nIndex++, appointment.getContacts( ) );

            daoUtil.executeUpdate( );