Tigerstripe Stereotypes Tutorial
< To: Tigerstripe_Tutorials
Stereotypes must be defined in the current profile before they can be used. This tutorial walks you through the definition of an Stereotypes named Persistence, its application to an Artifact, and how it can be used in a Plugin.
Creating your Persistence Stereotype
Complete the following procedure to create a sample Stereotype.
To create a Persistence Stereotype:
- Click the Stereotypes tab in your profile.
- Name your Stereotype
- For this example, name your Stereotype Persistence.
- Enter the version number for your Stereotype and enter a short description.
- Save your changes.
Defining the scope of your Persistence Stereotype.
Before you can use your Persistence stereotype in your project, you first need to define its scope. The scope defines the type of model element to which the stereotype can be applied. The scope can be defined as one of the follwoing elements:
- Any Method - This means that the stereotype can be applied to any Method in any artifact in the model.
- Any Attribute - This means that the stereotype can be applied to any Attribute in any artifact in the model.
- Any Label - This means that the stereotype can be applied to any Attribute in any artifact in the model.
- Any Argument - This means that the stereotype can be applied to any Argument of any Method in any artifact in the model.
In addition the stereotype can be applied to Artifacts of specific types.
IMPORTANT NOTE: The inclusion of an Artifact Type (eg Managed Entity) and another qualifier (eg Any Method) does not mean that an stereotype can only be applied to methods of Managed Entities. What it does mean is that the stereotype can be applied to any Method on any Artifact, AND it can also be applied to Managed Entity Artifacts (at the artifact level).
To define the scope for your Persistence stereotype:
- In the Stereotypes tab, select the Persistence stereotype and locate the Scope section.
- Select the scope you want to define with your stereotype or leave the option unselected if you want to exclude that option from your stereotype.
- For this example, select ManagedEntity Artifact.
- Save your profile.
Defining attributes for your Persistence stereotype.
After you define the scope of your Persistence stereotype, you may define one or more Stereotype attributes. Stereotype attributes are additional fields that appear on your stereotype when applied to a model element within a Tigerstripe Project - the Stereotype attributes can take a value that is chosen by the user. Note that stereotypes do not require Stereotype attributes - you can use stereotypes without any Stereotype attributes, simply by applying them to model elements and making their presence (rather than value) of significance.
You can include the following Stereotype attributes types:
- String - Allows you to create a text field in which the user must enter information.
- Option - Allows you to create a checkbox which the user may select true or false values.
- List - Allows you to create a list of options from which the user must select.
To define attributes:
- In the Stereotypes tab, select the Persistence stereotype and locate the Attributes section.
- Click Add. The Stereotype Attribute Edit' dialog box opens.
- Enter a name for your stereotype attribute.
- For this example, create an attribute named isPersistent.
- Enter a short description for your stereotype attribute and select Checkable Attribute.
- Note: In this example, isPersistent will be an attribute for which the user must enable or disable.
- Click OK to save your stereotype attribute definition.
- Save your profile.
To complete this example, create two more attributes:
- tableName - This attribute is a String Type Attribute with the default value of tableName.
- storageType - This attribute is a Selection List Attribute with the following selections:
- anEntry1 - Set this option as the default selection by clicking Set default.
When you are finished, your Stereotype Definitions in your project profile should include the following:
- Stereotype named Persistence.
- Scope of Managed Entity.
- Three stereotype attributes: isPersistent, tableName, storageType.
You must now Deploy the profile. For more information about deploying a profile, refer to the Tigerstripe_Profile_Tutorial.
Adding stereotypes to an entity.
Complete the following procedure to add the Persistence stereotype to an entity in your Tigerstripe Project.
To add a simple stereotype:
- In the Overview tab for your entity, locate the Stereotypes section. You may need to click on the title Stereotypes to open the list.
- Select Add. The Stereotype Selection dialog box displays.
- Select an stereotype from the list of stereotypes and click OK.
- In this example, select the Persistence stereotype.
To edit an stereotype:
- Double-click the stereotype in the Stereotypes section of your entity. Alternatively, select the stereotype and click Edit. The Stereotype Details dialog box opens.
- Enter the stereotype name in the tableName text box.
- Select isPersistent. In this example, this option is selected by default as defined in the Entity Stereotypes tutorial.
- Make a storage selection from the storageType list box. As defined earlier,anEntity1 is the default selection.
- Click OK to save your changes and return to the entity editor.
- Save your entity.