Procedure
Suppose that you want to add information related to department data along with the equivalence status in the report. You can create a delegate and extend EquivalenceReportDelegate to do so.
If you want to export the report for object types other than WTPart, extend MPMLReportDelegate and provide the implementation.
1. Run the enumCustomize utility and open the MPMLinkReportTypeRB.rbInfo file located at $WT_HOME/codebase/com/ptc/windchill/mpml/client/reports.
2. Create a type for the new report, such as PFDINFO.
3. Create a new delegate, such as CustomReportDelegate.
4. Add information about the delegate in the mpmlink.service.properties.xconf file located at WT_HOME/codebase/com/ptc/windchill/mpml/xconfs.
Add the entry under the given service:
<Service context="default" name="com.ptc.windchill.mpml.reports.MPMLReportDelegate">
<Option cardinality="singleton" requestor="wt.part.WTPart" selector="PFDINFO" serviceClass="com.ptc.windchill.mpml.reports.CustomReportDelegate"/>
The selector value should match the type given in the MPMLinkReportTypeRB.rbInfo file. If you want to generate a report for a different object type, the requestor entry should contain the internal name of that type.
5. Override the following methods in CustomReportDelegate:
protected List<String> getHeaders() throws WTException;
Provides logic to return headers that you require in the report. You can add columns by overriding getRowToWrite.
protected abstract RowData getRoot(Persistable seed, ReportParams params) throws WTException;
Extend this method to add data in rowData for root node.
protected abstract List<RowData> getChildren(List<RowData> parents, ReportParams params) throws WTException;
Method to get data for child nodes. This method is called recursively to collect data for the whole structure. You can extend this method to add data in rowData for child nodes.
protected abstract List<String> getRowToWrite(RowData rowData, ReportParams params) throws WTException;
Provides logic to return a list of values that you want to export into the report. You can add values for your custom columns here. However, you need to maintain the order of the values as per the columns in the report.
protected abstract void validateAndPopulateParams(ReportParams params) throws WTException;
Validates whether the given root is supported by the delegate. You can add your validation here.
The following methods are optional. If you do not override these methods, the out-of-the-box implementation is used.
protected boolean isValidForReport(NavigationUnit navUnit);
Skips specific navigation units from being added to the report as per your criteria. By default, the method returns true. Provide your implementation here.
protected String getFilePrefix();
Returns the prefix for the report file. MPMLinkReport is the default prefix. You can add your implementation here.
protected ExportListWriter getExporter() throws ExportException;
Returns the exporter for the type of report you want. You can add your implementation here. For example, for a CSV report, use ExportFileType.CSV.toString().
protected List<TypeIdentifier> getReportForTypes() throws WTException;
Returns a list of object types for which you want to fetch the report.
After performing the above steps, the CustomReportDelegate class appears as shown:
도움이 되셨나요?