Entity Report Filtering

By means of so called entity report filters it is possible to further narrow down the result of an entity report query. Such filters are applied after the execution of the report and can be contributed for either one specific entity report or as a general filter for all reports registered in the system. This offers the advantage of being able to reuse existing report query logic and simply adding general filtering steps for confining the result set.

Extension Point

Entity report filters can be contributed to com.heiler.ppm.entity.core.entityReports extension point, where the following information needs to be provided:

  • id: A unique extension identifier of the contributed entity report filter.

  • filter-cass: An implementation of interface EntityReportFilter, containing the filter's logic as well as the programmatic steps to enhance an entity report with additional parameters etc.

  • entity-report-identifier (optional): The identifier of the report to be filtered. If omitted, filter will be registered for all available entity reports.

Multiple filters registered for one report are NOT applied in a specific sequence and simply generate the intersection set of PIM objects adhering to the entity report result and corresponding filters.

Parameter Grouping in PIM Rich Client

For displaying entity report parameters within a special group in the PIM Rich Client's "edit query dialog", add a key/value pair to the corresponding parameter(s) like this:

parameter.setData( AbstractParameter.KEY_PARAMETER_GROUP, "Parameter group name" );

This is how the data quality status filter looks like for instance:

images/download/thumbnails/35914405/statusfilter.PNG

Example

One example for a convenient implementation example would be an assortment entity report filter, providing the means to filter each report result containing only PIM objects included in a given assortment.

AssortmentReportFilter
public class AssortmentReportFilter implements EntityReportFilter
{
public static final String PARAM_ASSORTMENT = "assortmentFilter"; //$NON-NLS-1$
private static final String VALUE_PARAM_GROUP = "AssortmentReportFilter.paramGroup"; //$NON-NLS-1$
 
@Override
public EntityItemList filter( IProgressMonitor progressMonitor, EntityItemList listTobeFiltered,
EntityReportQuery query ) throws CoreException, InterruptedException
{
EntityReportQuery.NamingTypes queryNamingType = EntityReportQuery.NamingTypes.NAME;
String queryName = query.getDisplayNaming( queryNamingType, null, true );
String taskName = Messages.getString( "StatusReportFilter.task" ); //$NON-NLS-1$
taskName = MessagesUtils.replace( taskName, false, queryName );
progressMonitor.beginTask( taskName, 1000 );
try
{
AssortmentProxy assortment = ( AssortmentProxy ) getParameterValue( PARAM_ASSORTMENT, query );
ReportResult assortmentReportResult = assortment.getAssortmentDetailModel()
.getItemReportResult();
ReportService reportingService = ReportingComponent.getReportService();
ReportResult toBeFilteredReportResult = listTobeFiltered.toReportResult( progressMonitor,
ReportPurposes.TEMPORARY );
ReportResult filteredReportResult = reportingService.intersectWithReport( assortmentReportResult,
toBeFilteredReportResult, false,
ReportPurposes.TEMPORARY );
Entity itemEntity = query.getReport()
.getItemEntity();
EntityItemList filteredItems = new ReportResultEntityItemList( itemEntity, filteredReportResult );
return filteredItems;
}
finally
{
progressMonitor.done();
}
}
 
@Override
public void adaptEntityReport( EntityReport entityReport )
{
AbstractEntityReport report = ( AbstractEntityReport ) entityReport;
String entityIdentifier = report.getItemEntity()
.getIdentifier();
Parameter assortmentParam = null;
switch ( entityIdentifier )
{
case "Article": //$NON-NLS-1$
assortmentParam = createAssortmentParameter( "Enum.AllArticleAssortments", "Article", //$NON-NLS-1$//$NON-NLS-2$
"com.heiler.ppm.article.assortment.core.permission.Read" ); //$NON-NLS-1$
break;
case "Product2G": //$NON-NLS-1$
assortmentParam = createAssortmentParameter( "Enum.Product2GAssortments", "Product2G", //$NON-NLS-1$ //$NON-NLS-2$
"com.heiler.ppm.product2g.assortment.core.permission.Read" ); //$NON-NLS-1$
break;
case "Variant": //$NON-NLS-1$
assortmentParam = createAssortmentParameter( "Enum.VariantAssortments", "Variant", //$NON-NLS-1$ //$NON-NLS-2$
"com.heiler.ppm.variant.assortment.core.permission.Read" ); //$NON-NLS-1$
break;
default:
return;
}
report.addParameter( assortmentParam );
}
 
@Override
public void clearEntityReport( EntityReport entityReport )
{
AbstractEntityReport report = ( AbstractEntityReport ) entityReport;
Entity itemEntity = report.getItemEntity();
String entityIdentifier = itemEntity.getIdentifier();
if ( entityIdentifier.equals( "Article" ) || entityIdentifier.equals( "Product2G" ) //$NON-NLS-1$ //$NON-NLS-2$
|| entityIdentifier.equals( "Variant" ) ) //$NON-NLS-1$
{
report.removeParameter( PARAM_ASSORTMENT );
}
}
 
@Override
public boolean isApplicable( EntityReportQuery query )
{
try
{
return getParameterValue( PARAM_ASSORTMENT, query ) != null;
}
catch ( CoreException shouldNotHappen )
{
String msg = "Unexpected error while obtaining parameter value for assortment report filter."; //$NON-NLS-1$
throw new IllegalStateException( msg, shouldNotHappen );
}
}
 
protected Object getParameterValue( String paramIdentifier, EntityReportQuery query ) throws CoreException
{
Object result = null;
Parameter parameter = query.getReport()
.getParameter( paramIdentifier );
if ( parameter != null )
{
result = query.getParamValue( parameter, false );
}
return result;
}
 
private Parameter createAssortmentParameter( String assortmentIdentifier, String entityIdentifier, String permission )
{
ParameterImpl parameter = new ParameterImpl( PARAM_ASSORTMENT );
parameter.setAlias( PARAM_ASSORTMENT );
parameter.setMandatory( false );
parameter.setVisible( true );
parameter.setOrder( 15000 );
parameter.setMessagesHelper( Messages.messagesHelper );
parameter.setNameOrResourceKey( "%AssortmentReportFilter.param.assortment.name" ); //$NON-NLS-1$
parameter.setDescriptionOrResourceKey( "%AssortmentReportFilter.param.assortment.description" ); //$NON-NLS-1$
parameter.setValueClassProvider( new FixClassProvider( AssortmentProxy.class ) );
parameter.setEnumIdentifier( assortmentIdentifier );
parameter.setEntityIdentifier( entityIdentifier );
parameter.setData( AbstractParameter.KEY_PARAMETER_GROUP, Messages.getString( VALUE_PARAM_GROUP ) );
parameter.setPermissions( new String[] { permission } );
return parameter;
}
}