Customization > Extensibility Through Profiles, Stereotypes, Tag Definitions and Scripts > Lightweight extensions of PTC profiles > Overview of lightweight extensions of PTC profiles > Worked example: Creating a derived tag definition for a lightweight extension
  
Worked example: Creating a derived tag definition for a lightweight extension
This worked example continues from Worked example: Creating a lightweight extension of a link type, in which we created a new link type named Partially Satisfy that was an extension of the Satisfy link type from the SysML Profile.
We have a Block named Block1 that is linked to Requirement1 using the SysML Satisfy link and linked to Requirement2 using our Partially Satisfy link.
When we look at the RequirementRelated tab of the Block1's Property Pages we can see that Requirement1 is linked to Block1 through the Satisfy link, but we cannot see that Requirement2 is linked through the Partially Satisfy link.
The RequirementRelated tab is created for the «RequirementRealted» stereotype and the Tag Definitions listed are derived Tag Definition that lists items that are linked through their associated link types.
To resolve this problem we will create a derived Tag Definition that will show Requirements that are linked through our Partially Satisfy link type.
In our MyExts profile Package we create a Package named Tag Definitions and in it we create a Tag Definition named partiallySatisfies. The name of the Tag Definition is not important.
We will set up our partiallySatisfies tag definition based on the satisfies tag definition in the SysML Profile. We locate the satisfies tag definition and set up the options on the Type tab of our partiallySatisfies tag definition's Property Pages to be the same as those of the satisfies tag definition.
On the satisfies tag definition's Property Pages, we click the Derivation Script tab and copy its script.
We paste the copied script to the Derivation Script tab of our partiallySatisfies tag definition's Property Pages. We now need to change the script for our Tag Definition.
The script contains a model object reference to the Satisfies stereotype (Satisfies in blue text). We delete this model object reference, and create a new model object reference to the owning item (our partiallySatisfies tag definition) by dragging the partiallySatisfies tag definition to the script.
The script uses the 'REQUIREMENTS Satisfies' role, which is the Satisfies role from the Requirements profile. We need to use the Partially Satisfies role that was created for our MyExts profile when the profile helper was reinitialized.
To find the name of the role, we right-click the «PartiallySatisfy» stereotype, point to Tools, point to Profile Extensions, and then click Wrapper Details. The Meta Model Viewer dialog is opened and we expand the Roles folder to see the available roles for the «PartiallySatisfy» stereotype.
We find the role we require, which is derived from our profile name and the role name we created through the «PartiallySatisfy» stereotype, that is, Partially Satisfies. We find the 'MYEXTS Partially Satisfies' role, copy the role name, and paste the role name into our Derivation Script to replace the 'REQUIREMENTS Satisfies' text.
We now apply our partiallySatisfies tag definition to the «RequirementRelated» stereotype: on the Items tab of the partiallySatisfies tag definition's Property Pages, we show associated Stereotypes, click the Link button, and select the «RequirementRelated» stereotype.
Finally, on the Usage tab of the partiallySatisfies tag definition's Property Pages, we click the Publish button to publish the Tag Definition.
We now return to Block1's Property Pages and can see the partiallySatisfies tag definition is showing that Block1 is linked to Requirement2 through the Partially Satisfies link type.
In this example we created a derived Tag Definition for showing items linked through a new link type. You may also want to create derived Tag Definitions for new items types as well. For example, If you create a new item type that is based on the SysML Flow Port item, the Block tab of a Block's Property Pages will show you Flow Ports it owns, but it will not show you items of the new type it owns. However, the Profile Helper creates a role from Blocks to the new item type, so you can use this role to create a derived Tag Definition for the Block stereotype.
Note that if after publishing the derived Tag Definition we make changes to it, to see those changes we must close and reopen Modeler.