Servigistics InService Customization > Customizing Shopping Parameters > Writing a Custom Import or Export Delegate for Cart and CartItem
  
Writing a Custom Import or Export Delegate for Cart and CartItem
Servigistics InService provides capability to import and export cart and cartItem in Microsoft Excel format through the com.ptc.sc.services.plugins.excel.ExcelCartFormatConverterDelegate interface. However if you need any other format (for example, CSV ) then you can create a custom delegate Java class implementing the com.ptc.sc.services.plugins.CartFormatConverterDelegate interface.
This interface has the following methods to implement. com.ptc.sc.services.utils.ImportExportUtility has been created to handle basic functions of importing and exporting, it is recommended that customers use this utility when creating custom delegates. For more details on these see the JavaDoc for the above classes.
InputStream convertFromSCItem(SCItem cart)
Exports the cart and its content. The given SCItem represents the cart object and has “items” collection that represents the list of cart Items.
SCItem convertToSCItem(InputStream inputStream)
Imports the cart and its content. The given InputStream is the uploaded file.
String getExtension()
Returns the extension suffix that this delegate can handle. For example if writing CSV delegate then this method will return “.csv”.
String getMimeType()
Returns MIME Media Type corresponding to extension this delegate handles. For example for csv it would be: "text/csv".
String getLocalizedTitle()
Returns the localized title of the extension that this delegate handles. This is the title that will be shown in the UI when user clicks on the download action from Cart Details page:
void createSheetFromData(XSSFWorkbook workbook, String newSheetName, List<List<Object>> cartItemsDataTable)
Updates an Excel workbook with a table of data on a new sheet.
There is no customization needed in client code. The localized title of the extension that the custom delegate supports will show up in the File Type drop-down after registration.
Registering the Custom Delegate Class
Add the following entry for the custom export delegate to the site.xconf file located in the directory <INS_HOME>/InS_SW/SW/Applications/Windchill.ear::
<Service context="default" name="com.ptc.sc.services.plugins.
CartFormatConverterDelegate">
<Option serviceClass="<customExportDelegateClassName>" requestor="null"
selector="<file extension>"/>
</Service>
The selector value should be the file extension that this delegate supports. For example, if the delegate supports CSV then the value for selector should be “.csv”.