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/mydashboard/modules/grusupply/web/MyDashboardComponentCompletedNotificationGRU.java 135
fr/paris/lutece/plugins/mydashboard/modules/grusupply/web/MyDashboardComponentInProgressNotificationGRU.java 136
            DemandResult demandResult = _notificationService.getListDemandByStatus( identity.getCustomerId( ), getListStatusCompleted( ) ,strCurrentPageIndex, String.valueOf( nDefaultItemsPerPage ), EnumNotificationType.MYDASHBOARD.toString( ), categoryCode );

            // PAGINATOR
            if( demandResult != null && CollectionUtils.isNotEmpty( demandResult.getListDemandDisplay( ) ) )
            {
                LocalizedDelegatePaginator<DemandDisplay> paginator = new LocalizedDelegatePaginator<>( demandResult.getListDemandDisplay( ), nDefaultItemsPerPage,
                        strUrl, PARAMETER_INDEX_PAGE, strCurrentPageIndex, demandResult.getNumberResult( ),
                        request.getLocale( ) );
    
                List<DemandDashboard> listDemandDashboards = getDemandDashboardList( identity.getCustomerId( ), paginator );                
                setModel( model, nDefaultItemsPerPage, paginator, listDemandDashboards );
            }

            HtmlTemplate htmTemplate = AppTemplateService.getTemplate( TEMPLATE_NOTIFICATION_LIST, request.getLocale( ), model );

            return htmTemplate.getHtml( );
        }

        return StringUtils.EMPTY;
    }

    @Override
    public String getComponentId( )
    {
        return DASHBOARD_COMPONENT_ID;
    }

    @Override
    public String getComponentDescription( Locale locale )
    {
        return I18nService.getLocalizedString( MESSAGE_COMPONENT_DESCRIPTION, locale );
    }
    
    /**
     * Get demand dashboard list
     * @param user
     * @param paginator
     * @return list of demand dashboard
     */
    private List<DemandDashboard> getDemandDashboardList( String strCustomerId, LocalizedDelegatePaginator<DemandDisplay> paginator )
    {
        List<DemandDashboard> listDemandDashboards = new ArrayList<>( );
        
        if ( CollectionUtils.isNotEmpty( paginator.getPageItems( ) ) )
        {
            for( DemandDisplay demand : paginator.getPageItems( ) )
            {
                NotificationResult notificationList = _notificationService.getListNotification( demand.getDemand( ).getId( ), demand.getDemand( ).getTypeId( ), strCustomerId, EnumNotificationType.MYDASHBOARD.name( ));

                DemandDashboard demandDashboard = new DemandDashboard( demand.getDemand( ).getUID( ) , false );
                demandDashboard.setStatus( demand.getStatus( ) );
                demandDashboard.setDemand( demand.getDemand( ) );                       
                
                if ( notificationList != null && notificationList.getNotifications( ) != null )
                {
                    demandDashboard.setListNotification( notificationList.getNotifications( ) );
                }
                listDemandDashboards.add( demandDashboard );
            }                
            listDemandDashboards = DemandDashboardHome.selectByDemandIds( listDemandDashboards );
        }
        return listDemandDashboards;
    }

    /**
     * Set model
     * @param model
     * @param nDefaultItemsPerPage
     * @param paginator
     * @param listDemandDashboards
     */
    private void setModel( Map<String, Object> model, int nDefaultItemsPerPage, LocalizedDelegatePaginator<DemandDisplay> paginator, List<DemandDashboard> listDemandDashboards )
    {
        model.put( MARK_DEMAND_TYPE_LIST, _notificationService.getListDemandType( ) );
        model.put( MARK_NB_ITEMS_PER_PAGE, nDefaultItemsPerPage );
        model.put( MARK_PAGINATOR, paginator );
        model.put( MARK_LIST_DEMAND, listDemandDashboards );
    }
    
    /**
     * Returns the list of status ids that are compelted.
     * @return list of status ids that are completed.
     */
    private String getListStatusCompleted( )
File Line
fr/paris/lutece/plugins/mydashboard/modules/grusupply/web/MyDashboardComponentCompletedNotificationGRU.java 104
fr/paris/lutece/plugins/mydashboard/modules/grusupply/web/MyDashboardComponentInProgressNotificationGRU.java 105
    @Inject
    @Named( NotificationGruService.BEAN_NAME )
    private NotificationGruService _notificationService;

    @Override
    public String getDashboardData( HttpServletRequest request )
    {
        LuteceUser user = SecurityService.getInstance( ).getRegisteredUser( request );
        String categoryCode = request.getParameter( PARAMETER_CATEGORY_CODE );

        String strUrl = AppPropertiesService.getProperty( PROPERTY_URL_MES_DEMARCHES ) + request.getParameter( PARAMETER_PANEL );
        
        if( StringUtils.isNotEmpty( categoryCode ))
        {
            strUrl = strUrl + "&cat=" + categoryCode;
        }
        
        if ( user != null )
        {
            Map<String, Object> model = new HashMap<>( );

            HttpSession session = request.getSession( true );

            String strCurrentPageIndex = session.getAttribute( CURRENT_PAGE_INDEX ) != null ? ( String ) session.getAttribute( CURRENT_PAGE_INDEX ) : null;

            strCurrentPageIndex = AbstractPaginator.getPageIndex( request, PARAMETER_INDEX_PAGE, strCurrentPageIndex );
            session.setAttribute( CURRENT_PAGE_INDEX, strCurrentPageIndex );

            int nDefaultItemsPerPage = AppPropertiesService.getPropertyInt( PROPERTY_NUMBER_OF_DEMAND_PER_PAGE, 10 );

            IdentityDto identity = IdentityStoreService.getIdentityByGuid( user.getName( ) );
            DemandResult demandResult = _notificationService.getListDemandByStatus( identity.getCustomerId( ), getListStatusCompleted( ) ,strCurrentPageIndex, String.valueOf( nDefaultItemsPerPage ), EnumNotificationType.MYDASHBOARD.toString( ), categoryCode );