The addition of the types, properties, and methods modules in Teamcenter introduces a great deal of flexibility in the area of data model customization. You can now create new types, modify the behavior of existing types, add their own properties, and completely customize the ask, set, and initialize behavior of these properties using methods.
Common Teamcenter Object Model Customization Scenarios
A combination of reference-based, relation-based, and runtime properties can accommodate nearly all type customization requirements. For implementation examples, refer to IMAN_ROOT/sample/properties/smp_props.c (UNIX or Linux), IMAN_ROOT\sample\properties\smp_props.c (Windows) and ./smp_prop_customization.c.
The following sections discuss the following approaches and techniques used to customize the Teamcenter object model:
• Tools and techniques
• Creating a new type versus adding a subclass
• Adding a persistent property to an existing type
• Adding runtime/derived properties to an existing type
• Adding a compound property to an existing type
• Adding a relation between two types
• Customizing the behavior (overall and property) of a type Tools and Techniques
If you want to customize the Teamcenter object model, you must be familiar with the following applications, utilities, and ITK programming techniques:
• Adding classes
You can add new POM classes with the Schema Browser (in other words, sb or schema_browser utilities) or the install utility. For more information, see the Utilities Reference manual.
• Adding types
You can add new types using the install_types utility or the IMANTYPE ITK functions. For more information about the install_types utility, see the Utilities Reference manual. For more information about the IMANTYPE ITK functions, see the Integration Toolkit Function Reference manual.
• Adding properties
You can add new properties to a type by declaring the function prototype
Core Functions
Creating a New Type Versus Adding a Subclass
Teamcenter only allows one level of subtypes to be added to each POM class. In other words, you cannot create a subtype of an existing subtype in the same POM class. Therefore, if you need additional subtypes, they must be added to a new POM class or subclass. There is no limitation to the number and levels of subclasses that can be added to a POM class.
The best way to specialize an existing Teamcenter object is to add a new type rather than creating a new subclass. This is because subtypes inherit all the properties and behavior of the super-type (in other words, primary type).
Also, adding a new subclass by extending the POM schema is a permanent change. A type can be removed at a later date when it is no longer needed.
When creating a type for the Item class, corresponding types must be created for the ItemRevision, ItemMaster, and ItemRevisionMaster classes. The IMAN_BIN/install_types utility automatically creates these parallel types when a new type is added to any one of the four classes. However, if one of the four parallel types is deleted, the other three are not automatically deleted.
Teamcenter does not allow subclasses of the Item or ItemRevision POM classes. If you try to add a subclass to them, you may see unpredictable behavior and lose data. Therefore, use types to specialize these classes.
When creating a subclass of the Folder class, use the Schema Browser to create the new subclass. Because there is no user interface for creating instances of Folder subclasses, you must write some user interface extensions to instantiate any new Folder subclasses.
Although the Dataset POM class can be subclassed, it is not advisable. Instead, use a dataset type to specialize this class. Additionally, it is possible to extend a dataset type by adding a form as a named reference. For more information about creating and managing dataset types and named references, see Type Help.
Although the Form POM class can be subclassed, it is not advisable. Instead, use a form type to specialize this class. For additional information about creating and managing form types, see Type Help.
Chapter 6 Core Functions
Adding a New Relation Type
Teamcenter supplies a standard set of relation types including Specification, Manifestation, and Requirement. You can define new relation types. For example, to create a new Model relation:
1. Define a new relation type using one of the following:
• GRM_create_relation_type function
• install_types utility For example:
$IMAN_BIN/install_types -f=add -c=ImanRelation/
-t=CUSTOM_model
2. Define two text strings for this new relation type. One string is singular and is used to display the relation type name in the user interface (for example, in the Workspace Relation column). The other string is plural and is used when displaying pseudo-folders.
3. Define the relation type text strings by adding new entries to iman_text.uil according to the following format:
gk_relation-name_att gk_relation-name_pf
For example:
gk_CUSTOM_model_att : exported "Model";
gk_CUSTOM_model_pf : exported "Models";
4. Compile the iman_text.uil file and copy the resulting the iman_text.uid file to IMAN_APP_UID_DIR or IMAN_USER_UID_DIR as appropriate.
5. Define a display name for the property that is mapped onto this relation by adding the following to the user_property_names.uih file:
CUSTOM_model : exported "Model";
6. Compile the property_names.uil file and copy the resulting property_names.uid file to IMAN_APP_UID_DIR or IMAN_USER_UID_DIR as appropriate.
7. To make this new relation type accessible from the Item Display Options dialog window, add a relation-name_relation_primary preference entry to the site preference stored in the database, listing each type of item and item revision you want to be able to show the relation under. For example:
CUSTOM_model_relation_primary=
Item
ItemRevision Document
Core Functions
Adding a Persistent Property
You can add a persistent property to an existing type by adding the corresponding attribute to an existing class or to a new subclass. The following shows various ways to add a new persistent property, property2, to the database.
Adding an Attribute to an Existing Class
Adding an attribute to an existing class is rarely used because it is not possible to add attributes to instantiated classes. Additionally, the Schema Browser does not allow attributes to be added to saved classes even if they have not been instantiated.
However, if you are creating a new class, and have not created an instance of that class in the database, this technique can be valuable. Figure 6-5 shows an example of adding an attribute to an existing class.
Figure 6-5. Adding an Attribute to an Existing Class
The Schema Browser limitation can be overcome by using the install utility with the –add_attr argument.
Once the attribute is added to the class, a new property is automatically generated for the primary type. This property is created with default behavior (in other words, the property is read-only and is not displayed in the workspace).
To add the attribute2 attribute to the existing ExampleA class (as shown in figure 6-5), follow these steps:
1. Add attribute2 to the ExampleA class using the Schema Browser or install utility.
Steps 2 and 3 are required only if you are customizing the default property behavior.
2. Register a property init module function for the ExampleA type.
3. Insert code into the property init module function to customize the behavior of property2.
Chapter 6 Core Functions
Adding an Attribute to a New Subclass
Because of the limitations that exist for adding attributes to existing Teamcenter classes, another technique for adding a persistent property to a type is to create a new subclass with the desired attributes. These attributes can then be mapped to a new type. Figure 6-6 shows an example of adding an attribute to a new subclass.
Figure 6-6. Adding an Attribute to a New Subclass
The new subclass and attribute can be added using the Schema Browser. A primary type is automatically be created with the same name as the class if the install_types utility is run without any parameters, and if the underlying class is a workspace object. To create a type for a non-workspace object or to create a type with a different name than the subclass, run the install_types utility with the –f=add argument.
To add the attribute2 attribute to the new SubExampleA subclass, follow these steps:
1. Add the new SubExampleA subclass to the ExampleA class with the Schema Browser or install utility.
2. Add the new SubExampleA primary type with the install_types utility or the IMANTYPE ITK functions.
3. The SubExampleA type inherits all of the properties of the ExampleA primary type and automatically has a property that corresponds (in other words, has the same name as) to attribute2.
Steps 4 and 5 are only required if you are customizing the default property behavior.
4. Register a property init module function for the SubExampleA type.
5. Insert code into the property init module function to customize the behavior of property2.
Core Functions
Adding a Property From a Relation
Adding a relation between two classes (in other words, between a primary class and a secondary class) is a technique that allows all the attributes of both classes to be displayed as properties associated with the primary class. There are two approaches that can be used for adding a relation between two classes:
• Teamcenter preference settings
• ITK
The advantage of using Teamcenter preference settings is that the relation can be part of a Workspace Find by Class query.
Figure 6-7 shows how property2 can be added to the ExampleA type from the ExampleB class using the RelationAB relation.
Figure 6-7. Adding a Property From a Relation
Adding a Property From a Relation Using Teamcenter Preference Settings
A generic preference (relation_type_relation_primary) automatically creates a relation property on specified types by manually modifying the preference stored in the database. For more information about adding relations using the Teamcenter preference setting, see the Configuration Guide.
To add a new property (property2) from a relation (RelationAB) using Teamcenter preference settings, follow these steps:
1. Create a new GRM type using the GRM_create_relation_type function or the install_types utility.
2. Create a new relation_type_relation_primary preference entry in the appropriate preference file stored in the database.
Steps 3 and 4 are only required if you are customizing the default property behavior.
3. Register a property init module function for the ExampleA type.
4. Insert code into the property init module function to customize the behavior of property2.
Chapter 6 Core Functions
Adding a Property From a Relation Using ITK
To add a new property (property2) from a relation (RelationAB) using ITK, follow these steps:
1. Create a new GRM type using the GRM_create_relation_type function or the install_types utility.
2. Register a property init module function for the ExampleA type.
3. Insert code into the property init module function to add the property2 relation property.
Step 4 is only required if you are customizing the default property behavior.
4. Insert code into the property init module function to customize the behavior of property2.
Adding a Runtime (Derived) Property
Adding a runtime property is similar to adding a persistent property except that Teamcenter controls the behavior of the property at runtime before displaying it to the user. Essentially, the displayed value of the property is derived each time the property is displayed.
Runtime properties can use many kinds of information (for example, property values from other types, attributes of other classes, and system date and time) to derive the displayed value. Figure 6-8 shows a runtime property (property2) derived from two pieces of information: attribute2 and system date.
Figure 6-8. Adding a Runtime Property
To derive property2 from attribute2 and the system date, follow these steps:
1. Register a property init module function for the ExampleA type.
2. Insert code into the property init module function to add runtime property2.
3. Insert code into the property init module function to customize the behavior of property2. This must include registering a method against the PROP_ask_value_type_msg function. This function contains the code for deriving the value of this runtime property.
When you add a runtime property, the locking, unlocking, refreshing
Core Functions
Adding a Compound Property
You can add a compound property by defining a compound property rule through the Compound Property rule module of the Business Modeler application. For further details about creating a compound property rule, see Business Modeler Help.
UGS recommends that you use the Compound Property rules functionality when you want a property to be displayed from an object (display object) as if it were the object’s own property, though it is actually defined and resides on another object (the source object), where the display and the source objects are connected through one or more reference/relation properties.
Customizing the Behavior of a Type
There are two basic approaches that can be used to customize behavior of a type:
• Customize overall behavior (for example, create, save, delete)
• Customize property behavior (for example, askValue, setValue)
Customize the Overall Behavior
The overall behavior of a type (for example, create, save, and delete) is defined by a set of messages that are passed to the type at runtime. These messages are implemented using methods. New methods can be defined for a type (base action) or existing methods can be customized and extended by adding a precondition, preaction, or postaction.
Customize the Property Behavior
It is also possible to change the ask, set, and initialize behavior of both existing and newly created properties. This is accomplished with the following ITK messages:
• PROP_UIF_ask_value_msg
• PROP_UIF_set_value_msg
• PROP_init_value_msg
• PROP_ask_value_type_msg
• PROP_ask_value_types_msg
• PROP_ask_value_type_at_msg
• PROP_set_value_type_msg
• PROP_set_value_types_msg
• PROP_set_value_type_at_msg
• PROP_is_modifiable_msg
Chapter 6 Core Functions
Where type is one the following data types:
• Date (date)
• Double-precision floating point decimal (double)
• Integer (int)
• Logical (logical)
• Unique identifier (tag)
For examples of how to implement customizations using these messages in conjunction with the METHOD_register_prop_method method, see the IMAN_ROOT/sample/smp_prop_customization.c file.
Customizing the Master Suffix
If you want to customize the master suffix (for example, change it from Master to _Master), follow these steps:
1. Go to the IMAN_ROOT/lang/textserver/language directory and open the iman_text.xml file in a text editor.
2. Search for <key id="gk_master_suffix">.
3. Change the key entry to your custom master suffix (for example, change it from Master to _Master).
4. Save the file and close the text editor.
5. Log into the rich client as an administrator.
6. Open the Type application.
7. Expand theForm Type and click the Item Master type.
8. InNew subtype name, enter the new Form type name that reflects the new suffix. It must be in the form Itemnew-suffix (for example, Item_Master).
9. Click Create.
10. Click theItemRevision Master type.
11. Repeat steps 8–9 for ItemRevision Master. It must be in the form ItemRevisionnew-suffix (for example, ItemRevision_Master).
12. Log off the rich client.
Core Functions