Mar 11, 2024 6:37:53 PM seb leridon avatar

wiki : Technical documentation > Progress bar manager

Progress bar management

Introduction

This service allows you to manage achievement pourcentage, number of successful actions, number of failures, and a final report

Usage

Use the ProgressManagerService instance to :

  • register the process and get a feedtoken,
private final ProgressManagerService progressManagerService = ProgressManagerService.getInstance( );

 @View( value = VIEW_BATCH_ITEMS )
 public String getManageBatchItems( final HttpServletRequest request )
 {
 	List<Item> mylist = getAList( ... );

 	feedToken = progressManagerService.registerFeed( FEED_NAME, 0 ); // the feed total can initialized here or later

 	doMyProcess( mylist, feedToken) 

 	Map<String, Object> model = getModel( );
 	model.put( MARK_FEED_TOKEN, _feedToken );
 	return getPage( PROPERTY_PAGE_TITLE_..., TEMPLATE_..., model );
 }
  • pass the feedtoken to the process and update the number of successful actions (incrementSuccess() method), number of failures, and add reports.
private final ProgressManagerService progressManagerService = ProgressManagerService.getInstance( );

  public int doMyProcess( List<Item> mylist, String feedToken) 
  {
	  progressManagerService.initFeed( feedToken, mylist.size( ) );
	  progressManagerService.addReport( feedToken, "start processing list..." );

	  for (Item item : mylist)
	  {
	  	doSomething( item );
		progressManagerService.incrementSuccess( feedToken, 1 );
	  }

	  ...
  }

Use @progress macro in the template, and pass the feedtoken as argument. This macro will make the JS calls to update the status.

<@progress token='${feed_token}' showReport=false intervalTime=1000 />

Don't forget to empty the feeds in the service.

Rest api

REST web service methods available :

  • /rest/progressmanager/api/v1/progressfeed/[token of the feed] : achievement pourcentage
  • /rest/progressmanager/api/v1/progressfeed/[token of the feed]/success : success nb
  • /rest/progressmanager/api/v1/progressfeed/[token of the feed]/failure : failure nb
  • /rest/progressmanager/api/v1/progressfeed/[token of the feed]/report : report