PTC Arbortext Content Delivery Customization > Search Customization > Auto-Set Serial Number (SN) and Context in the SN Decoder UI
Auto-Set Serial Number (SN) and Context in the SN Decoder UI
Product instances (PI/SN) are stored as separate business objects in PTC Arbortext Content Delivery. These objects enable the serial number (SN) based filtering by default. You can set the SN and context using the SN Decoder UI. By default, when you type an SN in the SN/Model box, PTC Arbortext Content Delivery searches for the SN. If that SN is not found, PTC Arbortext Content Delivery opens the SN Decoder UI, sets the typed in SN as the serial number, and asks you to set a context. After you set the context and apply it, PTC Arbortext Content Delivery applies the SN based filtering for future navigation and search operations.
You can further customize this feature to automatically set the SN and context associated with a Vehicle Identification Number (VIN).
Customization
To customize, you must implement the ProductIdentifierFilterDelegate delegate. For details about the delegate, see the Java Delegates section in this topic.
Consider a use case where you have a comma-separated text file that contains information about VIN, SN, and the context, and you want to update the SN and context on the SN Decoder UI by reading this file. To update the SN and context on the SN Decoder UI, perform the following steps.
1. Create the VINProductIdentifierFilterDelegate.java file to implement the ProductIdentifierFilterDelegate class and implement all the methods.
* 
See the sample VINProductIdentifierFilterDelegate.java file provided in this topic.
This delegate has a dependency on the following two JAR files:
ServiceCommon.jar which you can find here: <HOME>\SW\Applications\Windchill.ear\codebase.war\WEB-INF\lib\ServiceCommon.jar
Core.jar which you can find here: <HOME>\SW\Applications\Windchill.ear\codebase.war\WEB-INF\lib\Core.jar
2. Create the following directory structure in the custom folder: com/ptc/sc/customs. You can find the custom folder here:<InS_SW>/SW/Applications/Windchill.ear/codebase.war/delivery
3. Add the VINProductIdentifierFilterDelegate.java file to the customs folder that you have created in the above step.
4. Run the following command to compile the VINProductIdentifierFilterDelegate.java file and create the VINProductIdentifierFilterDelegate Java class file:javac –g <InS_SW>/SW/Applications/Windchill.ear/codebase.war/delivery/custom/com/ptc/sc/customs/VINProductIdentifierFilterDelegate.java
5. Add the VINProductIdentifierFilterDelegate Java class file to <InS_SW>/SW/Applications/Windchill.ear/codebase.war/WEB-INF/classes/com/ptc/sc/customs. Create this directory structure if it does not exist.
6. To update the SN and context on the SN Decoder UI, you must customize the machineSearchController.js file.
* 
See the sample machineSearchController.js code provided in this topic.
7. Perform the following steps to register VINProductIdentifierFilterDelegate in PTC Arbortext Content Delivery:
a. Open the sc-service.properties.xconf file in the directory HOME>/SW/SW/Applications/Windchill.ear/codebase.war/com/ptc/sc/xconf
b. Add the following property code to the sc-service.properties.xconf file to register the ProductIdentifierFilterDelegate custom delegate in PTC Arbortext Content Delivery:
<Service context="default"
name="com.ptc.sc.services.utils.ProductIdentifierFilterDelegate">
<Option requestor="null" cardinality="duplicate"
serviceClass="
com.ptc.sc.customs.VINProductIdentifierFilterDelegate"/>
</Service>
8. Stop the coreServer, coreCMIserver, and JBoss services.
9. Run the xconfmanager -p utility to propagate the new property.
10. Start the coreServer, coreCMIserver, and JBoss services.
Java Delegates
Interface Name: ProductIdentifierFilterDelegate
This delegate takes the VIN or user specified text as input and creates a SCList comprising the serial number and context.
This interface includes two methods; the details for each are as follows:
Methods
Description
Parameters
Returns
Supported API
Extendable
determineProductIdentifierFilterCriteria(String productId)
Method to decode the product identifier and return valid filters such as serial number and model. Invokes the other API with contextId as null.
productid—the product identifier string.
SCList—list of SCItems that can be utilized to add custom objects or attributes.
true
true
determineProductIdentifierFilterCriteria(String productId, String contextId)
Method to decode the product identifier and return valid filters such as serial number and model.
productId—the product identifier string (typically SN).
contextId—the context Id (Model Number); can be null.
SCList—list of SCItems that can be utilized to add custom objects or attributes (SCItem must have the Context and SerialNumber attributes).
true
true
Samples for Customization
Following are the samples for customization.
The sample code for VINProductIdentifierFilterDelegate:
package com.ptc.sc.customs;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

import com.ptc.sc.conceptualmodel.SCItem;
import com.ptc.sc.conceptualmodel.SCList;
import com.ptc.sc.services.utils.ProductIdentifierFilterDelegate;

public class VINProductIdentifierFilterDelegate implements ProductIdentifierFilterDelegate {

static Map <String, ContextDN> vinDetails;

@Override
public SCList determineProductIdentifierFilterCriteria(String productId) throws Exception {
return determineProductIdentifierFilterCriteria(productId, null);
}

@Override
public SCList determineProductIdentifierFilterCriteria(String productId, String context) throws Exception {
SCList scList = new SCList();
if (productId == null)
return scList;
else {
if (!vinDetails.isEmpty() && vinDetails.get(productId) != null) {
ContextDN contextDN = vinDetails.get(productId);
SCItem item = new SCItem();
item.addAttribute("Context", contextDN.getContext());
item.addAttribute("SerialNumber", contextDN.getSn());
scList.addItem(item);
}
}
return scList;
}

/**
* read the external file & populate the VIN Details Map
*/
private static void populateVINDetails(String filePath) {
...
}
}

class ContextDN {
String context;
String sn;

}
The contents of contextSNMap.csv:
VIN
Context
SN
Bicycle_1_SN10
Bicycle_1
SN10
Bicycle_2_SN5
Bicycle_2
SN5
GolfCart_SN6
GolfCart
SN6
Changes to machineSearchController.js:
if(data.items[0].attributes.Context && data.items[0].attributes.Context)
{
$scope.serialNumberKeyword = data.items[0].attributes.Context;
$scope.invalidSerialKeyword = data.items[0].attributes.SerialNumber;
$scope.setSerialNumberRegistrationFlyoutActive(true);
$timeout(function () {
$scope.setSerialNumberRegistrationFlyoutActive(true);
$('#machineSearchInput').click();
});
return;
}
Was this helpful?