Personalización avanzada > Business Logic Customization > Customizing MPMLink > Customizing the Source Template for Generating Manufacturing Structures
Customizing the Source Template for Generating Manufacturing Structures
Objective
Customize the default logic to resolve the process plan or routing plan template in the Source list.
Solution
Use the out‑of‑the‑box delegate framework to generate downstream structures using a template, while providing the ability to extend and apply custom logic for populating the Source list in the Initialize Manufacturing Structures dialog box.
Prerequisite Knowledge
To perform this task, you must have an understanding of the following:
Java fundamentals (inheritance, collections)
Windchill delegates and xconfmanager utility
Solution Elements
RelatedSourceDelegate
Abstract class invoked by Windchill to fetch source templates for duplicate or Save As parts.
DefaultRelatedSourceDelegate
OOTB implementation to fetch source templates.
CustomRelatedSourceDelegate
Custom implementation tailored to resolve source templates based on project needs.
Procedure
To implement custom logic for fetching the template, follow these steps:
1. Create a new delegate class, such as CustomRelatedSourceDelegate, by extending DefaultRelatedSourceDelegate.
2. Register the delegate in the BaseServer-service.properties.xconf file.
3. Override the methods as required:
a. getSourceTemplates—Customize the logic for fetching routing plan templates.
b. getSourceProcessPlans—Customize the logic for fetching process plan templates.
4. Run xconfmanager -p to propagate the changes.
5. Restart the method server for the changes to take effect.
OOTB Implementation
Here is an OOTB implementation for fetching source routing plans:
Sample XCONF Snippet
The following is a sample XCONF configuration that registers your custom delegate:
<Service context="default" name="com.ptc.windchill.baseserver.delegate.RelatedSourceDelegate">
<Option cardinality="singleton"
requestor=”null”
serviceClass="com.ptc.windchill.baseserver.delegate.CustomRelatedSourceDelegate"
selector="default"/>
</Service>
Sample Implementation
The following example shows a custom implementation of a related source delegate that fetches the source process plans from a different helper (for example, a list of process plan OIDs from a part attribute).
public class CustomRelatedSourceDelegate extends DefaultRelatedSourceDelegate {
@Override
protected Set<String> getSourceProcessPlans(final WTPart selectedPart, NavigationCriteria nc, boolean flag) {
//Fetch the list of process plan oids and related mbom oid from attribute.
Map<String, String> partToProcessPlans = CustomHelper.getMBomToProcessPlanMap(selectedPart, nc);

Set<String> processPlans = new HashSet<>();
for(Entry<String, String> mapEntry : partToProcessPlans.entrySet()) {
String mBomOid = mapEntry.getKey();
String processPlanOid = mapEntry.getValue();

If (flag) {
processPlans.add(mBomOid + “|” + processPlanOid);
} else {
processPlans.add(processPlanOid);
}
}
return processPlans;
}
¿Fue esto útil?