xxx12

Exercise 6-5: Add a Modeled Attribute
Objectives
● Model an attribute.
Scenario
The class previously created, CustomerOrder, needs an attribute to represent the name of the customer that placed the order. In this exercise, you will add a modeled attribute to a modeled customization, per customer requirements.
Detailed Description
The attribute cost needs to be added.
Step 1. Consider whether the previous custom tables should be dropped.
a. Modeled attributes are stored as columns in the database, so the existing CustomerOrder table would need to be dropped and then recreated with new SQL artifacts generated after the model edits are complete.
Step 2. Open the Class Specification window for com.customer.doc.CustomerOrder.
Step 3. Add the cost attribute.
a. Open the Attributes tab of the Class Specification window.
Result:
b. Clear the Show inherited check box. There should be no attributes in CustomerOrder.
c. Right-click and select Insert. An attribute will be created with a default name of name.
d. Double-click on the attribute and the Attribute Specification window will open.
Example:
e. In the Name: field, enter cost.
f. In the Type: field, enter java.lang.Float.
g. Under Export Control, select Public.
h. What does “public” mean? Try using the Rational Rose help to find out.
i. Select the Windchill tab. What is the value of ColumnName? What will be the name of this column in the database?
j. Save the unit.
Step 4. Using the current SQL, drop the CustomerOrder table.
a. Open a Windchill shell.
b. Navigate to WT_HOME/db/sql/com/customer/doc.
c. Execute the drop scripts. Drop indexes before tables.
Example:
Step 5. System generate.
Step 6. Recompile.
Step 7. Execute the new SQL.
Step 8. Restart Tomcat and the Method Server.
Step 9. Test.
Step 10. Challenge: add an attribute to represent the company placing the order.
a. What will the attribute be named?
b. What will be the attribute type?
c. Does the previous customization need to be dropped?
---
Enumerated Types
Enumerated types are special Windchill attributes that have a discrete set of valid values.
• Theoretically, attributes of this type could be modeled directly on the class, and then developers could write logic to control the possible values.
• Don’t use this approach; use the enumerated type pattern.
• The framework around enumerated type attributes includes control of the discrete set of valid values and localization of the values in text files. These are known as resource bundles.
• The attribute itself is implemented by creating a custom class that extends a standard Windchill class wt.fc.EnumeratedType.
• The custom attributes are known as “enumerated types” and have a UML relationship to the class they are contained in.
• From the UI, these attributes are visible and can be edited just like other attributes modeled directly on the class.
• Just like attributes directly modeled on a class, system generation will generate accessor methods.
Examples of the enumerated type design pattern can be found throughout the Windchill model.
• Open WTdesigner.mdl and search for EnumeratedType.
As with other design patterns, use the existing model as a pattern that can be copied and applied for the desired customization.
EnumeratedType Examples
• Part
– Source (Make, Buy)
– QuantityUnit (Each, As Needed, Liters, Kilograms, Meters)
– PartType (Component, Inseparable Assembly, Separable Assembly)
• Document
– DocumentType (Document, Requirements Document, Test Plan, etc.)
– DepartmentList (Accounting, Design, Manufacturing, etc.)
• Change Objects
– Category (Safety Issue, Cost Reduction, Other etc.)
– IssuePriority (High, Medium, Low, Emergency)
– Complexity (Simple, Complex)
• CAD Documents
– EPMAuthoringAppType (Pro/ENGINEER, AutoCAD, Catia, SolidWorks, Unigraphics, etc.)
– EPMDocSubType (NC Model, Process Plan, Skeleton, Sheet Metal, etc.)
Figure 6-17: 2 Examples of EnumeratedTypes in wt.doc Package
Editing Enumerated Type Values
After modeling the enumerated type, system generation will create a resource bundle to contain possible values.
• These resource bundles can be localized, as well.
Use WT_HOME/bin/enumCustomize to edit the values:

你可能感兴趣的:(sql,tomcat,C++,SQL Server,UML)