Modify BOM Difference APIs
Windchill ESI uses the features of Windchill APIs to determine what changes have been made to product structures. Additionally, it uses Windchill Difference APIs to determine what changes have been made to document associations to parts. If you want to modify the way changes are identified, you can extend the default Difference APIs.
Product Structure Differences
Windchill ESI relies upon the product structure difference logic to determine the changes to the product structure since the part was last published. This difference information identifies what information must be published in order to synchronize the data with your target enterprise systems.
The differences are returned as java enumeration objects pointing to wt.part.PartUsageInfo objects. The PartUsageInfo class is a non-persistent class that represents the inclusion of a part by another part. In addition to the included part, the object provides access to the substitutes and reference designators specified for the included part.
Procedure
To customize, extend the default implementation and override specific methods.
Procedures for extending classes using the Windchill Information Modeler are defined in the Basic Customization. For simple extensions of the default interface implementation use this process:
1. Define the java source file using the editor or Integrated Development Environment (IDE) of your choice.
* 
Do not modify or replace any classes that were provided when Windchill ESI was installed. These files may be replaced by future software releases.
2. Compile the java source file into the Windchill codebase.
3. Change the appropriate property to point to the new implementation.
(For more details, see "Customizing service.properties" in the Windchill Customization Guide (Windchill 自訂指南).)
Example
The following example illustrates how to extend the wt.part.PartUsageInfo class and modify the default behavior for comparison. The example compares line numbers in addition to the default comparisons.
The source code is located at <Windchill>/codebase/com/ptc/windchill/esi/examples/Example4MyPartUsageInfo.java.
These are the contents of the sample file:
package com.ptc.windchill.esi.examples; import wt.part.LineNumber;
import wt.part.PartUsageInfo; import wt.part.WTPartUsageLink; import wt.util.WTException;

public class Example4MyPartUsageInfo extends PartUsageInfo
{
protected boolean isDifferent(PartUsageInfo info)
{
boolean result = super.isDifferent(info);

if (result == false)
{
Example4MyPartUsageInfo other = (Example4MyPartUsageInfo)info; WTPartUsageLink thisLink = this.getPartUsageLink(); WTPartUsageLink otherLink = other.getPartUsageLink(); LineNumber thisLine = thisLink.getLineNumber();
LineNumber otherLine = otherLink.getLineNumber();

if (thisLine == null)
{
if (otherLine != null)
{
// different line number result = true;
}
}
else
{
if (otherLine == null || thisLine.equals(otherLine) == false)
{
// different line number result = true;
}
}
}
return result;
}
}
Consider the following:
The package statement ensures that the output of the java compiler is written to the correct directory.
The java import statements are required by the class’ inheritance and implementation specifics.
You can compile the example by doing the following:
Launch the Windchill shell, from within the <Windchill> directory that was defined when you installed Windchill PDMLink with this command:
bin/windchill shell
Use the java compiler to compile the class.
javac -d ./codebase ./codebase/com/ptc/windchill/esi/examples/*.java
To activate the new implementation, modify wt.properties to specify a property file that specifies the service implementation for wt.part.PartUsageInfo.
wt.services.applicationcontext.WTServiceProviderFromProperties.customPropertyFiles
Append the name of a property file that contains the specification for the new implementation, using a comma to separate the file names. There is an example property file (<Windchill>/codebase/com/ptc/windchill/esi/examples/Example4.properties) that contains the specification for the example implementation.
wt.services/svc/default/wt.part.PartUsageInfo/null/java.lang.Object/0=com.ptc.windc hill.esi.examples.Example4MyPartUsageInfo/duplicate
Document Attachment Differences
Windchill ESI relies upon the Document Attachment Difference logic to determine the changes to document associations since a RevisionControlled object (such as a WTPart) was last published. This difference information identifies what information must be sent in order to synchronize the data with your ERP systems.
The differences are returned as enumerations of com.ptc.windchill.esi.esidoc.PartDocInfo objects. The PartDocInfo class is a transient class that represents the attachment of a document to a RevisionControlled object.
There are several different associations that represent documentation for a RevisionControlled object. The following document associations are applicable to a WTPart object:
wt.doc.WTDocument associated with wt.part.WTPart via a "Described By" association
wt.doc.WTDocumentMaster associated with wt.part.WTPart via a "References" association
wt.epm.EPMDocument associated with wt.part.WTPart via a "Build History" association
wt.epm.EPMDocument association with wt.part.WTPart via a "Described By" association
wt.doc.WTDocument associated with wt.esi.ERPMaterial (that represents the given WTPart object) via a “Described By” association
wt.doc.WTDocumentMaster associated with wt.esi.ERPMaterial (that represents the given WTPart object) via a “References” association
wt.epm.EPMDocument association with the wt.esi.ERPMaterial (that represents the given WTPart object) via a “Described By” association
wt.doc.WTDocument associated with com.ptc.windchill.enterprise.data.EnterpriseData (that represents the given WTPart object or com.ptc.windchill.enterprise.data.EnterpriseData ) via a “Described By” association
wt.doc.WTDocumentMaster associated com.ptc.windchill.enterprise.data.EnterpriseData (that represents the given WTPart object or com.ptc.windchill.enterprise.data.EnterpriseData) via a “References” association
wt.epm.EPMDocument association with the com.ptc.windchill.enterprise.data.EnterpriseData (that represents the given WTPart object or com.ptc.windchill.enterprise.data.EnterpriseData) via a “Described By” association
Procedure
Procedures for extending classes using the Windchill Information Modeler are defined in the Basic Customization. For simple extensions of the default interface implementation, use this process:
1. Define the java source file using the editor or Integrated Development Environment (IDE) of your choice.
* 
Caution: Do not modify or replace any classes that were provided when Windchill ESI was installed. These files may be replaced by future software releases.
2. Compile the java source file into the Windchill codebase.
3. Change the appropriate property to point to the new implementation.
(For more details, see "Customizing service.properties" in the Windchill Customization Guide (Windchill 自訂指南).)
Example
The following example illustrates how to extend the com.ptc.windchill.esi.esidoc.PartDocInfo class and modify the default behavior for generating document URLs. Instead of generating a URL to the document properties page, this example generates a URL to the document content.
The source code is located at <Windchill>/codebase/com/ptc/windchill/esi/examples/Example5MyPartDocInfo.java.
These are the contents of the sample file:
package com.ptc.windchill.esi.examples;

import com.ptc.windchill.esi.esidoc.PartDocInfo; import java.util.HashMap;
import wt.doc.Document;

import wt.fc.ObjectIdentifier; import wt.fc.Persistable; import wt.fc.PersistenceHelper;

import wt.httpgw.GatewayServletHelper; import wt.httpgw.URLFactory;

import wt.util.WTException;

public class Example5MyPartDocInfo extends PartDocInfo
{
public String getDocumentURL()
{
String url = null;

try
{
// Generate a URL to download the document content.

URLFactory urlFactory = new URLFactory(); HashMap map = new HashMap();

map.put("action", "DownloadContent"); map.put("oid", getDocumentOID());

url = GatewayServletHelper.buildAuthenticatedHREF(
urlFactory, "wt.enterprise.URLProcessor", "URLTemplateAction", map);
}
catch (WTException e)
{
// Use the default logic which generates a URL to display
// the document properties.

url = super.getDocumentURL();
}


return url;

}

private String getDocumentOID() throws WTException
{
Persistable p = (Persistable)getDocument();
ObjectIdentifier oid = PersistenceHelper.getObjectIdentifier(p);

return oid.getStringValue();
}
}
Consider the following:
The package statement ensures the output of the java compiler is written to the correct directory.
The java import statements are required by the class’ inheritance and implementation specifics.
You can compile the example by doing the following:
Launch the Windchill shell, from within the <Windchill> directory that was defined when you installed Windchill with this command:
bin/windchill shell
Use the java compiler to compile the class.
javac -d ./codebase ./codebase/com/ptc/windchill/esi/examples/*.java
To activate the new implementation, modify wt.properties to specify a property file that specifies the service implementation for com.ptc.windchill.esi.esidoc.PartDocInfo.
wt.services.applicationcontext.WTServiceProviderFromProperties. customPropertyFiles
Append the name of a property file that contains the specification for the new implementation, using a comma to separate the file names. There is an example property file (<Windchill>/codebase/com/ptc/windchill/esi/examples/Example5.properties) that contains the specification for the example implementation.
wt.services/svc/default/com.ptc.windchill.esi.esidoc.PartDocInfo/null/java.lang.Object/0=com.ptc.windchill.esi.examples. Example5MyPartDocInfo/duplicate
這是否有幫助?