Fork me on GitHub

CPD Results

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

Duplications

File Line
fr/paris/lutece/plugins/myportal/business/ColumnStyleDAO.java 64
fr/paris/lutece/plugins/myportal/business/WidgetStyleDAO.java 64
    public int newPrimaryKey( Plugin plugin )
    {
        DAOUtil daoUtil = new DAOUtil( SQL_QUERY_NEW_PK, plugin );
        daoUtil.executeQuery( );

        int nKey;

        if ( !daoUtil.next( ) )
        {
            // if the table is empty
            nKey = 1;
        }

        nKey = daoUtil.getInt( 1 ) + 1;
        daoUtil.free( );

        return nKey;
    }

    /**
     * Insert a new record in the table.
     * 
     * @param style
     *            instance of the Style object to insert
     * @param plugin
     *            The plugin
     */
    public void insert( Style style, Plugin plugin )
    {
        DAOUtil daoUtil = new DAOUtil( SQL_QUERY_INSERT, plugin );

        style.setId( newPrimaryKey( plugin ) );

        daoUtil.setInt( 1, style.getId( ) );
        daoUtil.setString( 2, style.getName( ) );
        daoUtil.setString( 3, style.getCssClass( ) );

        daoUtil.executeUpdate( );
        daoUtil.free( );
    }

    /**
     * Load the data of the style from the table
     * 
     * @param nId
     *            The identifier of the style
     * @param plugin
     *            The plugin
     * @return the instance of the Style
     */
    public Style load( int nId, Plugin plugin )
    {
        DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT, plugin );
        daoUtil.setInt( 1, nId );
        daoUtil.executeQuery( );

        Style style = null;

        if ( daoUtil.next( ) )
        {
            style = new Style( );

            style.setId( daoUtil.getInt( 1 ) );
            style.setName( daoUtil.getString( 2 ) );
            style.setCssClass( daoUtil.getString( 3 ) );
        }

        daoUtil.free( );

        return style;
    }

    /**
     * Delete a record from the table
     * 
     * @param nStyleId
     *            The identifier of the style
     * @param plugin
     *            The plugin
     */
    public void delete( int nStyleId, Plugin plugin )
    {
        DAOUtil daoUtil = new DAOUtil( SQL_QUERY_DELETE, plugin );
        daoUtil.setInt( 1, nStyleId );
        daoUtil.executeUpdate( );
        daoUtil.free( );
    }

    /**
     * Update the record in the table
     * 
     * @param style
     *            The reference of the style
     * @param plugin
     *            The plugin
     */
    public void store( Style style, Plugin plugin )
    {
        DAOUtil daoUtil = new DAOUtil( SQL_QUERY_UPDATE, plugin );

        daoUtil.setInt( 1, style.getId( ) );
        daoUtil.setString( 2, style.getName( ) );
        daoUtil.setString( 3, style.getCssClass( ) );
        daoUtil.setInt( 4, style.getId( ) );

        daoUtil.executeUpdate( );
        daoUtil.free( );
    }

    /**
     * Load the data of all the styles and returns them as a List
     * 
     * @param plugin
     *            The plugin
     * @return The List which contains the data of all the styles
     */
    public List<Style> selectStylesList( Plugin plugin )
    {
        List<Style> styleList = new ArrayList<Style>( );
        DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECTALL, plugin );
        daoUtil.executeQuery( );

        while ( daoUtil.next( ) )
        {
            Style style = new Style( );

            style.setId( daoUtil.getInt( 1 ) );
            style.setName( daoUtil.getString( 2 ) );
            style.setCssClass( daoUtil.getString( 3 ) );

            styleList.add( style );
        }

        daoUtil.free( );

        return styleList;
    }
}
File Line
fr/paris/lutece/plugins/myportal/business/WidgetDAO.java 237
fr/paris/lutece/plugins/myportal/business/WidgetDAO.java 276
        DAOUtil daoUtil = new DAOUtil( strSQL, plugin );
        daoUtil.executeQuery( );

        while ( daoUtil.next( ) )
        {
            int nIndex = 1;
            Widget widget = new Widget( );

            widget.setIdWidget( daoUtil.getInt( nIndex++ ) );
            widget.setName( daoUtil.getString( nIndex++ ) );
            widget.setDescription( daoUtil.getString( nIndex++ ) );
            widget.setIdCategory( daoUtil.getInt( nIndex++ ) );
            widget.setWidgetType( daoUtil.getString( nIndex++ ) );
            widget.setIdIcon( daoUtil.getInt( nIndex++ ) );
            widget.setConfigData( new String( daoUtil.getBytes( nIndex++ ) ) );
            widget.setStatus( daoUtil.getInt( nIndex++ ) );
            widget.setCategory( daoUtil.getString( nIndex++ ) );
            widget.setIdStyle( daoUtil.getInt( nIndex++ ) );
            widget.setStyle( daoUtil.getString( nIndex++ ) );
            widget.setCssClass( daoUtil.getString( nIndex++ ) );
            widget.setIsEssential( daoUtil.getBoolean( nIndex++ ) );
            widget.setIsNew( daoUtil.getBoolean( nIndex++ ) );
            widgetsList.add( widget );
        }

        daoUtil.free( );

        return widgetsList;
    }

    /**
     * {@inheritDoc}
     */
    public List<Widget> getPublicMandatoryWidgets( Plugin plugin )
File Line
fr/paris/lutece/plugins/myportal/business/WidgetDAO.java 156
fr/paris/lutece/plugins/myportal/business/WidgetDAO.java 243
fr/paris/lutece/plugins/myportal/business/WidgetDAO.java 282
            widget = new Widget( );

            widget.setIdWidget( daoUtil.getInt( nIndex++ ) );
            widget.setName( daoUtil.getString( nIndex++ ) );
            widget.setDescription( daoUtil.getString( nIndex++ ) );
            widget.setIdCategory( daoUtil.getInt( nIndex++ ) );
            widget.setWidgetType( daoUtil.getString( nIndex++ ) );
            widget.setIdIcon( daoUtil.getInt( nIndex++ ) );
            widget.setConfigData( new String( daoUtil.getBytes( nIndex++ ) ) );
            widget.setStatus( daoUtil.getInt( nIndex++ ) );
            widget.setCategory( daoUtil.getString( nIndex++ ) );
            widget.setIdStyle( daoUtil.getInt( nIndex++ ) );
            widget.setStyle( daoUtil.getString( nIndex++ ) );
            widget.setCssClass( daoUtil.getString( nIndex++ ) );
            widget.setIsEssential( daoUtil.getBoolean( nIndex++ ) );
            widget.setIsNew( daoUtil.getBoolean( nIndex++ ) );
File Line
fr/paris/lutece/plugins/myportal/web/MyPortalApp.java 488
fr/paris/lutece/plugins/myportal/web/MyPortalApp.java 531
fr/paris/lutece/plugins/myportal/web/MyPortalApp.java 583
        UrlItem urlForJs = new UrlItem( JSP_URL_BROWSE_ESSENTIAL_WIDGETS );
        urlForJs.addParameter( PARAMETER_TAB_INDEX, strTabIndex );

        // Paginator
        String strCurrentPageIndex = Paginator.getPageIndex( request, Paginator.PARAMETER_PAGE_INDEX, "1" );
        int nDefaultItemsPerPage = AppPropertiesService.getPropertyInt( PROPERTY_DEFAULT_LIST_WIDGET_PER_PAGE_IN_FO, 50 );
        LocalizedPaginator paginator = new LocalizedPaginator( listWidgets, nDefaultItemsPerPage, url.getUrl( ), Paginator.PARAMETER_PAGE_INDEX,
                strCurrentPageIndex, request.getLocale( ) );

        Map<String, Object> model = new HashMap<String, Object>( );
        model.put( MARK_BASE_URL, strBaseUrl );
        model.put( MARK_WIDGETS_LIST, paginator.getPageItems( ) );
        model.put( MARK_NB_ITEMS_PER_PAGE, Integer.toString( nDefaultItemsPerPage ) );
        model.put( MARK_PAGINATOR, paginator );
        model.put( MARK_LIST_TAB, listTabs );
        model.put( MARK_PAGINATOR_URL_FOR_JS, urlForJs.getUrl( ) );
        model.put( MARK_TAB_INDEX, strTabIndex );
        model.put( MARK_USER_WIDGET_IDS, _widgetService.getUserWidgetIds( getUser( request ) ) );

        HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_BROWSE_ESSENTIAL_WIDGETS, request.getLocale( ), model );
File Line
fr/paris/lutece/plugins/myportal/business/ColumnStyleHome.java 59
fr/paris/lutece/plugins/myportal/business/WidgetStyleHome.java 59
    private ColumnStyleHome( )
    {
    }

    /**
     * Generates a new primary key
     * 
     * @return The new primary key
     */
    public static int newPrimaryKey( )
    {
        return _dao.newPrimaryKey( _plugin );
    }

    /**
     * Create an instance of the style class
     * 
     * @param style
     *            The instance of the Style which contains the informations to store
     * @return The instance of style which has been created with its primary key.
     */
    public static Style create( Style style )
    {
        _dao.insert( style, _plugin );

        return style;
    }

    /**
     * Update of the style which is specified in parameter
     * 
     * @param style
     *            The instance of the Style which contains the data to store
     * @return The instance of the style which has been updated
     */
    public static Style update( Style style )
    {
        _dao.store( style, _plugin );

        return style;
    }

    /**
     * Remove the style whose identifier is specified in parameter
     * 
     * @param nStyleId
     *            The style Id
     */
    public static void remove( int nStyleId )
    {
        _dao.delete( nStyleId, _plugin );
    }

    // /////////////////////////////////////////////////////////////////////////
    // Finders

    /**
     * Returns an instance of a style whose identifier is specified in parameter
     * 
     * @param nKey
     *            The style primary key
     * @return an instance of Style
     */
    public static Style findByPrimaryKey( int nKey )
    {
        return _dao.load( nKey, _plugin );
    }

    /**
     * Load the data of all the style objects and returns them in form of a list
     * 
     * @return the list which contains the data of all the style objects
     */
    public static List<Style> getStylesList( )
    {
        return _dao.selectStylesList( _plugin );
    }

    /**
     * Load the data of all the style objects and returns them in form of a list
     * 
     * @return the list which contains the data of all the style objects
     */
    public static ReferenceList getStyles( )
    {
        ReferenceList list = new ReferenceList( );

        for ( Style style : _dao.selectStylesList( _plugin ) )
        {
            list.addItem( style.getId( ), style.getName( ) );
        }

        return list;
    }
}
File Line
fr/paris/lutece/plugins/myportal/web/WidgetJspBean.java 199
fr/paris/lutece/plugins/myportal/web/WidgetJspBean.java 358
        String strWidgetName = request.getParameter( PARAMETER_WIDGET_NAME );
        String strWidgetDescription = request.getParameter( PARAMETER_WIDGET_DESCRIPTION );
        String strWidgetType = request.getParameter( PARAMETER_WIDGET_TYPE );
        String strIdCategory = request.getParameter( PARAMETER_ID_CATEGORY );
        String strIdIcon = request.getParameter( PARAMETER_ID_ICON );
        String strIdStyle = request.getParameter( PARAMETER_ID_STYLE );
        String strWidgetStatus = request.getParameter( PARAMETER_WIDGET_STATUS );

        if ( StringUtils.isNotBlank( strWidgetName ) && StringUtils.isNotBlank( strWidgetDescription ) && StringUtils.isNotBlank( strIdCategory )
                && StringUtils.isNumeric( strIdCategory ) && StringUtils.isNotBlank( strIdIcon ) && StringUtils.isNumeric( strIdIcon )
                && StringUtils.isNotBlank( strIdStyle ) && StringUtils.isNumeric( strIdStyle ) && StringUtils.isNotBlank( strWidgetStatus )
                && StringUtils.isNumeric( strWidgetStatus ) && StringUtils.isNotBlank( strWidgetType ) )
File Line
fr/paris/lutece/plugins/myportal/business/WidgetDAO.java 121
fr/paris/lutece/plugins/myportal/business/WidgetDAO.java 209
        daoUtil.setString( nIndex++, widget.getName( ) );
        daoUtil.setString( nIndex++, widget.getDescription( ) );
        daoUtil.setInt( nIndex++, widget.getIdCategory( ) );
        daoUtil.setString( nIndex++, widget.getWidgetType( ) );
        daoUtil.setInt( nIndex++, widget.getIdIcon( ) );
        daoUtil.setBytes( nIndex++, widget.getConfigData( ).getBytes( ) );
        daoUtil.setInt( nIndex++, widget.getIdStyle( ) );
        daoUtil.setInt( nIndex++, widget.getStatus( ) );
        daoUtil.setBoolean( nIndex++, widget.getIsEssential( ) );
        daoUtil.setBoolean( nIndex++, widget.getIsNew( ) );

        daoUtil.executeUpdate( );
File Line
fr/paris/lutece/plugins/myportal/business/DefaultPageBuilderDAO.java 186
fr/paris/lutece/plugins/myportal/business/DefaultPageBuilderDAO.java 265
        DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_ALL, plugin );

        daoUtil.executeQuery( );

        List<WidgetComponent> listWidgetComponents = new ArrayList<WidgetComponent>( );

        while ( daoUtil.next( ) )
        {
            int nIndex = 1;
            WidgetComponent widgetComponent = new WidgetComponent( );
            widgetComponent.setIdWidgetComponent( daoUtil.getInt( nIndex++ ) );
            widgetComponent.setIdWidget( daoUtil.getInt( nIndex++ ) );
            widgetComponent.setOrder( daoUtil.getInt( nIndex++ ) );
            widgetComponent.setColumn( daoUtil.getInt( nIndex++ ) );
            widgetComponent.setWidgetName( daoUtil.getString( nIndex++ ) );
            widgetComponent.setStyleName( daoUtil.getString( nIndex++ ) );
            listWidgetComponents.add( widgetComponent );
        }

        daoUtil.free( );

        return listWidgetComponents;
    }

    /**
     * {@inheritDoc}
     */
    public int selectMaxOrder( Plugin plugin )
File Line
fr/paris/lutece/plugins/myportal/business/icon/IconDAO.java 211
fr/paris/lutece/plugins/myportal/business/icon/IconDAO.java 246
        DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_ICON, plugin );
        daoUtil.executeQuery( );

        int nPos;

        while ( daoUtil.next( ) )
        {
            nPos = 0;
            icon = new Icon( );
            icon.setId( daoUtil.getInt( ++nPos ) );
            icon.setName( daoUtil.getString( ++nPos ) );
            icon.setMimeType( daoUtil.getString( ++nPos ) );
            icon.setWidth( daoUtil.getInt( ++nPos ) );
            icon.setHeight( daoUtil.getInt( ++nPos ) );
            icon.setDispolayFO( daoUtil.getBoolean( ++nPos ) );

            listIcon.add( icon );
        }

        daoUtil.free( );

        return listIcon;
    }
File Line
fr/paris/lutece/plugins/myportal/web/MyPortalApp.java 354
fr/paris/lutece/plugins/myportal/web/MyPortalApp.java 495
fr/paris/lutece/plugins/myportal/web/MyPortalApp.java 538
fr/paris/lutece/plugins/myportal/web/MyPortalApp.java 590
        String strBaseUrl = AppPathService.getBaseUrl( request );

        Map<String, Object> model = new HashMap<String, Object>( );
        model.put( MARK_BASE_URL, strBaseUrl );
        model.put( MARK_WIDGETS_LIST, paginator.getPageItems( ) );
        model.put( MARK_NB_ITEMS_PER_PAGE, Integer.toString( nDefaultItemsPerPage ) );
        model.put( MARK_PAGINATOR, paginator );
        model.put( MARK_LIST_TAB, listTabs );
        model.put( MARK_PAGINATOR_URL_FOR_JS, urlForJs.getUrl( ) );
        model.put( MARK_TAB_INDEX, strTabIndex );
        model.put( MARK_USER_WIDGET_IDS, _widgetService.getUserWidgetIds( getUser( request ) ) );

        HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_BROWSE_CATEGORIES_WIDGETS, request.getLocale( ), model );
File Line
fr/paris/lutece/plugins/myportal/web/WidgetJspBean.java 175
fr/paris/lutece/plugins/myportal/web/WidgetJspBean.java 321
        Map<String, Object> model = new HashMap<String, Object>( );
        model.put( MARK_CATEGORIES_LIST, _categoryService.getCategories( ) );
        model.put( MARK_ICONS_LIST, IconHome.getListIcons( getPlugin( ) ) );
        model.put( MARK_WIDGET_TYPES_LIST, WidgetHandlerService.instance( ).getHandlers( ) );
        model.put( MARK_STYLES_LIST, StyleService.getInstance( ).getWidgetStyles( ) );
        model.put( MARK_STATUS_DRAFT, WidgetStatusEnum.DRAFT.getId( ) );
        model.put( MARK_STATUS_MANDATORY, WidgetStatusEnum.MANDATORY.getId( ) );
        model.put( MARK_STATUS_PUBLIC, WidgetStatusEnum.PUBLIC.getId( ) );

        HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_CREATE_WIDGET, getLocale( ), model );
File Line
fr/paris/lutece/plugins/myportal/business/WidgetDAO.java 237
fr/paris/lutece/plugins/myportal/business/WidgetDAO.java 276
fr/paris/lutece/plugins/myportal/business/WidgetDAO.java 316
        DAOUtil daoUtil = new DAOUtil( strSQL, plugin );
        daoUtil.executeQuery( );

        while ( daoUtil.next( ) )
        {
            int nIndex = 1;
            Widget widget = new Widget( );

            widget.setIdWidget( daoUtil.getInt( nIndex++ ) );
            widget.setName( daoUtil.getString( nIndex++ ) );
            widget.setDescription( daoUtil.getString( nIndex++ ) );
            widget.setIdCategory( daoUtil.getInt( nIndex++ ) );
            widget.setWidgetType( daoUtil.getString( nIndex++ ) );
            widget.setIdIcon( daoUtil.getInt( nIndex++ ) );
            widget.setConfigData( new String( daoUtil.getBytes( nIndex++ ) ) );
File Line
fr/paris/lutece/plugins/myportal/business/WidgetDAO.java 251
fr/paris/lutece/plugins/myportal/business/WidgetDAO.java 290
fr/paris/lutece/plugins/myportal/business/WidgetDAO.java 330
            widget.setConfigData( new String( daoUtil.getBytes( nIndex++ ) ) );
            widget.setStatus( daoUtil.getInt( nIndex++ ) );
            widget.setCategory( daoUtil.getString( nIndex++ ) );
            widget.setIdStyle( daoUtil.getInt( nIndex++ ) );
            widget.setStyle( daoUtil.getString( nIndex++ ) );
            widget.setCssClass( daoUtil.getString( nIndex++ ) );
            widget.setIsEssential( daoUtil.getBoolean( nIndex++ ) );
            widget.setIsNew( daoUtil.getBoolean( nIndex++ ) );
            widgetsList.add( widget );
        }

        daoUtil.free( );

        return widgetsList;
    }