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( )