進階自訂 > Business Logic Customization > Options and Variants > Customizing Options and Variants > Windchill Option Set Delegate Framework Customizations > Extend Option Set Delegate > Option Set Assignment Delegate Framework
  
Option Set Assignment Delegate Framework
The option set Assignment Delegate framework provides methods from a set of classes. These classes can be extended and methods can be implemented for customization as required. This delegate returns the option set to be used. When option set is overridden with a specific version of option set delegate, it returns the overridden version of option set to the Windchill system.
Following are some of the important classes of this framework for customization.
RegisteredOptionSetLink
Out-of-the box association class that associates an OptionSet to an OptionSetAssignable object. With this by default option set gets assigned to an OptionSetAssignable object.
AbstractOptionSetFetcherDelegate
This is an abstract delegate class defined to provide customization capability to UI and processing. This class has following methods which can be implemented to customize logic:
getAssignedOptionSet : This is a abstract method that can be implemented to determine option set for specified object.
isAssignOptionSetAllowed : This is a method that specifies if the custom logic needs the capability of assigning option set to object in user interface. When this is allowed, the UI can be used to create RegisteredOptionSetLink association with an object.
RegisteredOptionSetFetcherDelegate
The default delegate used to determine the option set for an option set assignable object. This delegate implements getAssignedOptionSet defined by AbstractOptionSetFetcherDelegate. While determining option set, this delegate uses RegisteredOptionSetLink association to find assigned option set for an object. If no option set for an object is found and if the object is contained, the object will check if option set is available in its container hierarchy. It only considers container for an object that are instance of OptionSetAssignable.
Delegate Framework Classes
com.ptc.windchill.option.delegate.AbstractOptionSetFetcherDelegate
com.ptc.windchill.option.delegate.impl.RegisteredOptionSetFetcherDelegate
com.ptc.windchill.option.delegate.impl.NullOptionSetFetcherDelegate
Please refer to the Windchill Java Documentation for more information about method signature and expected input and output parameters.
Writing custom Delegate
A new delegate extending com.ptc.windchill.option.delegate.AbstractOptionSetFetcherDelegate and implement method getAssignedOptionSet can be used. This custom delegate can be registered in system for a specific type of object. With this it is possible to write custom logic for determining option set for out-of-the-box objects or for custom objects.
Extend default registered option set delegate
In order to customize the out-of-the-box logic of the OptionSetDelegate determining option set for an object in Windchill, com.ptc.windchill.option.delegate.impl. RegisteredOptionSetFetcherDelegate can be extended and the method getAssignedOptionSet overwritten for custom logic. Extending the class provides the advantage of using both the OOTB delegate and the custom business logic.
Procedure
Procedures for extending classes using the Windchill Information Modeler are defined in the Windchill Customization Guide (Windchill 自訂指南). 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 was installed. These files may be replaced by future software releases.
2. Compile the java source file into the Windchill codebase.
3. Create an XCONF file that contains the appropriate new value for the property to register the delegate in Windchill system.
4. Use the XCONF Manager to update Windchill services properties.
These Windchill properties are defined using the Windchill XCONF feature. See the section Specialized Administration for details about the XCONF files and how to create them.
Example
You have defined a new custom type of part with its own set of business rules. The requirement for this type or its structure is such that it determines the option set with some custom logic. This custom logic does not require any direct association with the part type. Instead it uses some information on a part to determine option set. It also requires that there is no option set determined. Then based on information on the part it expects to use out-of-the box behavior to determine the option set.
After defining a new custom type of part with its own set of business rules, there is a business requirement for this type, or its structure, to determine the option set with some custom logic. This custom logic, instead of having a direct association with the part type, uses some information on a part to determine option set. It also requires that there is no option set determined. Then based on information on the part it expects to use out-of-the box behavior to determine the option set.