Applying Worklist Filter

This tutorial helps you to create and apply worklist filter from the Portal Configuration.

Using this example, you can:

Creating a Model

Download the Support Case model. You can download the example source code as well as the complete model from the following link as a ZIP file:

You need to add following to the downloaded model:

Creating a Filter Provider Java File

Create the java file named LocationFilter.java.

By creating the filter provider, you can control the viewing of worklist of a particular location or role. For more information, please refer to chapter Configuring Worklists in the Infinity Portal documentation.

Note you can specify the filter based on your requirement. The following is the sample code snippet to create the LocationFilter.java.

package com.filters;

import java.util.Iterator;
import java.util.List;

import org.eclipse.stardust.ui.web.viewscommon.beans.SessionContex;
import org.eclipse.stardust.ui.web.viewscommon.common.provider.AbstractFilterProvider;
import org.eclipse.stardust.engine.api.query.DataFilter;
import org.eclipse.stardust.engine.api.query.FilterAndTerm;
import org.eclipse.stardust.engine.api.query.FilterOrTerm;
import org.eclipse.stardust.engine.api.query.Query;
import org.eclipse.stardust.engine.api.runtime.Grant;
import org.eclipse.stardust.engine.api.runtime.User;


public class LocationFilter extends AbstractFilterProvider
{
   private static final long serialVersionUID = 1L;

   /* (non-Javadoc)
    * @see org.eclipse.stardust.ui.web.client.common.spi.IFilterProvider#applyFilter(org.eclipse.stardust.engine.api.query.Query)
    */
   public void applyFilter(Query query)
   {
      System.out.println("Applying Filter Provider - LocationFilter.applyFilter()");
      User user = SessionContext.findSessionContext().getUser();
      
      boolean puneCenter = false;
      boolean mumbaiCenter = false;

      List<Grant> grants = (List<Grant>) user.getAllGrants();
      Iterator<Grant> iterator = grants.iterator();
      while (iterator.hasNext())
      {
         Grant grant = iterator.next();

         if (grant.getId().equalsIgnoreCase("PuneCenter"))
         {
            puneCenter = true;
         }

         if (grant.getId().equalsIgnoreCase("MumbaiCenter"))
         {
            mumbaiCenter = true;
         }
      }

      System.out.println("puneCenter = " + puneCenter + ":: mumbaiCenter = " + mumbaiCenter);
      
      if (puneCenter && mumbaiCenter)
      {
         FilterOrTerm filter = query.getFilter().addOrTerm();
         filter.add(DataFilter.like("SupportCaseData", "Location", "%Pune%", false));
         filter.add(DataFilter.like("SupportCaseData", "Location", "%Mumbai%", false));
      }
      else if (puneCenter)
      {
         FilterAndTerm filter = query.getFilter().addAndTerm();
         filter.add(DataFilter.like("SupportCaseData", "Location", "%Pune%", false));
      }
      else if (mumbaiCenter)
      {
         FilterAndTerm filter = query.getFilter().addAndTerm();
         filter.add(DataFilter.like("SupportCaseData", "Location", "%Mumbai%", false));
      }
      else
      {
         System.out.println("NOT Applying any Filter");
      }
   }
}

Adding the Java File

Add the LocationFilter.java file in the src folder of the project in which you have added the Support Case moodel. Make sure that the LocationFilter.java file is under the package called com.filters

Working in Infinity Process Platform Portal and Applying the Filter

Perform the following steps:

  1. Deploy your model
  2. Login with user motu
  3. Create three users named Croft Lara, Doodle Duck and Cityman Frank
  4. Assign roles CallCenter, Engineer and PuneCenter to Croft Lara
  5. Assign roles CallCenter, Engineer and MumbaiCenter to Doodle Duck
  6. Assign roles CallCenter, Engineer, MumbaiCenter and PuneCenter to Cityman Frank
  7. Assign role CallCenter to motu
  8. Start five processes of Support Case Management Process and enter location as Pune, Mumbai and Delhi in each process.
  9. Specify the following filter in the Configuration View and click Save:
    puneCenter=com.filters.LocationFilter,mumbaiCenter=com.filters.LocationFilter 

    The following screenshot displays the filter provider details:

    Worklist - Filter Provider
    Figure: Worklist Configuration

  10. Login with user Croft Lara and open her worklist. Note that Croft Lara can see activities with location Pune.
  11. Login with user Doodle Duck and open his worklist. Note that Doodle Duck can see activities with location Mumbai.
  12. Login with user Cityman Frank and open his worklist. Note that Cityman Frank can see activities of both the locations that is Pune and Mumbai. Also, none of the three users can see activities with location Delhi. The user motu can view all activities.

In case both roles are assigned to one user and only puneCenter=com.filters.LocationFilter is applied then that user can see the activities of the location Pune.