Export - Data provider
What are export data providers? How do they work? Which standard data providers are available? How can I customize data providers?
Override a standard provider
It is possible to override a specific standard provider since PIM 7.0.05. With this way you can modify the standard providers to your own behavior without any direct modifications to the code. Therefore there is a new optional overridesStandard attribute in the com.heiler.ppm.texttemplate.core.dataProviders extension point. By default this is false.
To override a specific standard data provider you have to set the overridesStandard flag of your export data provider contribution to true. Additionally your contributed class have to use the same type identifier as the the standard data provider to override.
In case you'll have several contributed dataProviders with same type identifier and the overrides standard flag is the same (both false or true) then you'll get an error in the log and the first loaded data provider will be initialized.
This function can be used to add a new sub-datatype to a specific provider for example. For this you have to override the standard contribution and your class have to extend the standard provider class. Now you can simply override the getSubDataTypes() method and add your sub-datatype there.
ReportListModelQuery and data providers
In PIM 7.0.05.09, PIM 7.1 and later versions, the usage of queries in data providers has been limited. Most likely, queries as data provider members will be removed completely with PIM 8.
How should you use queries in data providers?
Don't set this.query in finish_init() methods. Use the new setQuery( this.reportResult ) method after this.reportResult has been retrieved, see line 12.
@Override
public
void
finish_init()
throws
CoreException
{
if
( !
this
.initComplete )
{
this
.productReportResult = getAssortmentReportResult(
this
.productAssortmentProxy,
this
.updateAssortment );
// get article report by products
this
.reportResult =
new
Product2ArticleRefUtils().getChildItems(
this
.productReportResult,
getRevisionToken(
null
) );
// use this method to let the super implementation set an appropriate query
setQuery(
this
.reportResult );
this
.initComplete =
true
;
}
}
If you need a special query to get a listModel, you can set this.query temporarily (line 10), but don't forget to set the original query at the end of your function (line 24).
protected
ListModel queryDataQualityStatus( DataType dataType, Pair[] fields, ExecutionContext executionContext )
throws
CoreException
{
// ...
ReportResult allRefStatus = getAllRefStatus();
ListModel result =
null
;
// ... prepare query
ReportListModelQueryBaseImpl originalQuery =
this
.query;
AnyListByReportResult tmpQuery =
new
AnyListByReportResult( statusEntity.getEntityType()
.getIdentifier(), allRefStatus );
this
.query = tmpQuery;
// ...
// ... get the list model
// queryDataInternal uses this.query to load the list model
ListModel listModel = queryDataInternal(...);
// ...
// restore original query
this
.query = originalQuery;
result = listModel;
// ...
return
result;
}
There will be more information soon:
What is an export data provider?
Can I customize data providers?
Which rules apply?
How can I customize data providers?
When do I need a new data provider?