Servigistics InService Customization > Customizing System Integrations > Writing a Custom import/export Delegate for cart and cartItem
  
Writing a Custom import/export Delegate for cart and cartItem
InService provides capability to import and export cart and cartItem in Microsoft Excel format through the com.ptc.sc.services.plugins.excel.ExcelCartFormatConverterDelegate. However if you need any other format (ex. 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)
Implement this method to export 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)
Implement this method to import the cart and its content. The given InputStream is the uploaded file.
String getExtension()
This method should return the extension suffix that this delegate can handle. For example if writing CSV delegate then this method will return “.csv”.
String getMimeType()
Return MIME Media Type corresponding to extension this delegate handles. For example for csv it would be: "text/csv".
String getLocalizedTitle()
Return 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:
There is no customization needed in client code. The localized title of the extension that the custom delegate supports will show up in File Type drop-down after registration.
Registering the Custom Delegate Class
Add the following entry into the <WT_HOME>/site.xconf file specifying the custom export delegate:
<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 it supports CSV then the value for selector should be “.csv”.