Home

Code Engineering Using UML Models

image

Contents

1. SQL Server Non Clustered Primary Key Ga a 12 4 Select the SQL Server Non Clustered Primary Key checkbox 5 Click on the Save amp Close button O 1998 2010 Sparx Systems Pty Ltd 137 Foreign Key 3 7 Foreign Key What is a Foreign Key Two types of key are used to access tables Primary Keys 134 and Foreign Keys A Primary Key uniquely identifies a record in a table while a Foreign Key accesses data in some other related table via its Primary Key Foreign keys are represented in Enterprise Architect UML using stereotyped operations A Foreign Key is a collection of columns attributes that together have some operational meaning they enforce a relationship to a Primary Key in another table A Foreign Key is modeled as an operation stereotyped with the FK stereotype the operation parameters become the columns involved in the key Note It isn t necessary to define a Foreign Key in order to access another table through its Primary Key Foreign Keys are a feature of some database management systems providing extras such as referential integrity checking that prevents the deletion of a record if its Primary Key value exists in some other table s Foreign Key The same thing can be achieved programmatically To create a Foreign Key 137 click on the link You might also have to define a Name Template at for Foreign Keys 3 7 1 Create Foreign Key To create a Foreign Key
2. l Create Primary Foreign Key Constraints Generate Packages Oracle Sonsoles Generate Table Properties Oracle Generate Triggers A Generate Stored Procedures Sep ate F Generate Views Generate Sequences Create Drop SQL Use as SQL Terminator on the same line F use and around names Generate Table Owner Use Database Use Alias if Available Use NULL for nullable columns mew Generate 1 coss nep 3 Inthe Path field use the Browse button to select the filename of the script to create 4 To include comments in the DDL in the Comment Level field select the appropriate level For example Column for comments on columns or All for comments on all structures 5 Select the checkboxes for the appropriate inclusions For example to include a drop table command in the script select the Create Drop SQL checkbox Deselect the checkboxes for inclusions you do not require Code Engineering Using UML Models Generate DDL For a Table 150 Notes e Some checkboxes display only if the appropriate database is defined for the table For example IF EXISTS displays only if the database for the table is PostgreSQL e f generating Oracle sequences you must always select the Generate Triggers and Generate Sequences checkboxes this ensures that a pre insert trigger is generated to select the next sequence value to populate the column Also select the Auto Numbering 130 che
3. Code Engineering Using UML Models Modeling Conventions VB Net Conventions 84 Applies To Corresponds To Widening Operation with stereotype operator The Widening keyword Operation with stereotype property This property only defining write code Other Conventions Namespaces are generated for each package below a namespace root 17 The s Leaf property of a Class corresponds to the NotInheritable keyword The Abstract property of a Class corresponds to the Mustinherit keyword The Static property of an attribute or operation corresponds to the Shared keyword The Abstract property of an operation corresponds to the MustOverride keyword The value of in for the Kind property of a parameter corresponds to the ByVal keyword The value of inout or out for the Kind property of a parameter corresponds to the ByRef keyword See Also Import Source Code 5 Generate Source Code 124 VB Net Options 54 1 6 12 Verilog Conventions Enterprise Architect supports round trip engineering of Verilog where the following conventions are used Stereotypes CTC CCA CET CTI CE CTN CEIM COC CTN pow a Method A sequential process Tagged Values Applies To Corresponds To weg Attribute signal The signal kind such as register bus mode Attribute port The port mode in out inout Attribute part The generic port map of the component instantiated Method The sensitivity list of a sequent
4. 1998 2010 Sparx Systems Pty Ltd 95 XML Schema XSD Model XSD anonymousType Specifies whether the Class type is anonymous for attributes true false ECH See the W3C XML Schema recommendation oo CO XSDattribute UML Attribute AssociationEnd Construct Description By applying this stereotype to a UML Class attribute or AssociationEnd the corresponding UML entity is generated as an XSD attribute within the parent complexType and not as an XSD element Tagged form Overrides the schema s attributeFormDefault value Values qualified unqualified use prohibited optional required Constraints The attribute datatype should not see a Class specification otherwise it is ignored XSDany UML Class Attribute Consiruct Description If applied to a UML attribute an XSD anyAttribute element is generated If applied to a UML Class an XSD any element is generated Tagged namespace Values 8 See the W3C XML Schema recommendation processContents skip lax strict Constraints we XSDrestriction UML Generalization Construct See the W3C XML Schema recommendation Description Overrides the default use of XSD extension for inheritance and generates the child as a complexType with a restriction element instead Code Engineering Using UML Models XML Schema XSD Model XSD 96 Constraints Applies only to UML Class paren
5. ENTERPRISE ARCHITECT Code Engineering Using UML Models Enterprise Architect is an intuitive flexible and powerful UML analysis and design tool for building robust and maintainable software This booklet describes the code engineering facilities of Enterprise Architect Sf SYSTEMS Copyright 1998 2010 Sparx Systems Pty Ltd Enterprise Architect Code Engineering Using UML Models 1998 2010 Sparx Systems Pty Lid All rights reserved No parts of this work may be reproduced in any form or by any means graphic electronic or mechanical including photocopying recording taping or information storage and retrieval systems without the written permission of the publisher Products that are referred to in this document may be either trademarks and or registered trademarks of the respective owners The publisher and the author make no claim to these trademarks While every precaution has been taken in the preparation of this document the publisher and the author assume no responsibility for errors or omissions or for damages resulting from the use of information contained in this document or from the use of programs and source code that may accompany it In no event shall the publisher and the author be liable for any loss of profit or any other commercial damage caused or alleged to have been caused directly or indirectly by this document Printed May 2010 Special thanks to Publisher All the people who h
6. Foreword This user guide describes the code engineering facilities of Enterprise Architect Code Engineering Using UML Models 1 Code Engineering geng S t PHP fN O K Y d p Li en Uy HARE e e Code Engineering is a process that includes automated code generation reverse engineering of source code and synchronization between the source code and model Enterprise Architect also enables you to rapidly model generate or forward engineer and reverse engineer e XML Technologies 88 namely XML Schema XSD and Web Service Definition Language WSDL e Database schemal 120 keys triggers constraints RI and other relational database features for and from a range of database products Code Engineering is available in the Professional Corporate Business and Software Engineering System Engineering and Ultimate editions of Enterprise Architect Code Generation Enterprise Architect enables you to generate source code 127 from UML model elements creating a source code equivalent of the Class or Interface element for future elaboration and compilation In particular you can generate C C C Delphi Java PHP Python ActionScript Visual Basic and VB NET 427 source code The source code generated includes Class definitions variables and function stubs for each attribute and method in the UML Class You can use the Source Code Viewer to view any source code you are opening see the D
7. State s Transitions break default break private void processOrder_Dispatched CommandType command switch command case Do Do Behaviors setStatus Dispatched State s Transitions nextState StateType ProcessOrder_Delivered Code Engineering Using UML Models Code Generation From Behavioral Models SW Code Generation State Machine Diagrams break default break private void processOrder_New CommandType command switch command case Do Do Behaviors setStatus new State s Transitions nextState StateType ProcessOrder_Packed break default break private void StatesProc StateType currState CommandType command switch currState case ProcessOrder_Delivered processOrder_Delivered commana break case ProcessOrder_Packed processOrder_Packed command break case ProcessOrder_Closed processOrder_Closed command break case ProcessOrder_Dispatched processOrder_Dispatched command break case ProcessOrder_New processOrder_New commana break default break private void TransitionsProc TransitionType transition switch transition case ProcessOrder_Delivered_to_ProcessOrder_Closed setStatus closed break default break 22 1998 2010 Sparx Systems Pty Ltd 23 Code Generation From Behavioral Model
8. Attributes e currState StateType a variable to hold the current State s information e nextState StateType a variable to hold the next State s information set by each State s transitions accordingly e currTransition TransitionType a variable to hold the current transition information this is set if the transition has a valid effect associated with it e transcend Boolean a flag used to advise if a transition is involved in transcending between different State Machines or Submachine states e xx_history StateType a history variable for each State Machine Submachine State to hold information about the last State from which the transition took place Operations e StatesProc a States procedure containing a map between a State s enumeration and its operation it de references the current State s information to invoke the respective State s function e TransitionsProc a Transitions procedure containing a map between the Transition s enumeration and its effect it invokes the respective effect e lt lt State gt gt an operation for each of the States contained within the State Machine this renders a State s behaviors based on the input CommandType and also executes its transitions e initializeStateMachine a function that initializes all the framework related attributes e runStateMachine a function that iterates through each State and executes their behaviors and transitions accordingly Click here 20
9. 15 Generate Source Code Generate a Group of Classes Note If any of the elements selected are not Classes or interfaces the option to generate code is not available 1 2 3 Generate a Package In addition to generating source code from single Classes and groups of Classes you can also generate code from a package This feature provides options to recursively generate child packages and automatically generate directory structures based on the package hierarchy This enables you to generate a whole branch of your project model in one step Generate a Package To generate a package follow the steps below ils 2 In the Project Browser right click on the package to generate code for The context menu displays Select the Code Engineering Generate Source Code menu option The Generate Package Source Code dialog displays Root Package Class Model Synchronize Synchronize model and code z Generate F Auto Generate Files Root Directory Retain Existin E p r r lie o gt D I Select Objects to Generate F Include all Child Packages Object Type Target File Extend Class C Documents and Settings rchester My Doc Hello Class C Users chester Documents Hello h Interfacename Interface C Users rchester Documents Interfacename Interfacename Interface C Documents and Settings rchester My Doc LibCheck1 Class C Documents and Settings rchester My
10. lt xs sequence gt lt xs element name Contactinfo homePhone type xs string maxOccurs 1 gt lt xs element name Contactinfo email type xs string gt lt xs element name Contactinfo streetAddress type xs string gt lt xs choice gt lt xs element name Contactinfo mobilePhone type xs string gt lt xs element name Contactinfo officePhone type xs string gt lt xs choice gt lt xs sequence gt lt xs complexType gt lt xs simpleType name Gender gt lt xs restriction base xs string gt lt xs pattern value male female gt lt xs restriction gt lt xs simpleType gt lt xs element name Employee type Employee gt lt xs complexType name Employee gt lt xs complexContent gt O 1998 2010 Sparx Systems Pty Ltd 91 XML Schema XSD Model XSD lt xs extension base Person gt lt xs sequence gt lt xs element name status type Status gt lt xs element name jobTitle type xs string gt lt xs element name startDate type xs date gt lt xs element name department type xs string gt lt xs sequence gt lt xs extension gt lt xs complexContent gt lt xs complexType gt lt xs element name Person type Person gt lt xs complexType name Person gt lt xs sequence gt lt xs element name surName type xs string maxOccurs 1 gt lt xs element name firstName type xs string maxOccurs 1 gt lt xs element name birthDate type xs strin
11. C Specifications F Disable Language Options for the current model Default Extension cs Options for the current user Default Attribute Type int Generate Namespaces True Remove hard breaks from summary False Generate Finalizer True Generate Dispose True Default Source Directory Editor Collection class for 1 associations Collection Classes 1 4 6 5 C Options Configure options for C code generation using the C Specifications page of the Options dialog select the Tools Options Source Code Engineering C menu option The options you can specify include e The version of C to generate this controls the set of templates used and how properties are created e The default reference type used when a type is specified by reference e The default file extensions e Default Get Set prefixes e Default source directory e The path that Enterprise Architect uses to search for the implementation file The first path in the list is the default path when generating new implementation files and parsing existing files if you add further directories Enterprise Architect also searches these when parsing existing files For example you have a directory inc that contains all of your headers while the source code is mixed through directories src srca and erch You therefore set the Source Path option to src srca srcb This ensures that new implementation files are generated into src but when parsing existing files
12. It is used to generate source code from a UML Class ClassNotes ClassDeclaration ClassBody The above template simply refers to three other templates namely ClassNotes ClassDeclaration and ClassBody The enclosing percent signs indicate a macro Code Templates consist of various types of macros each resulting in a substitution in the generated output For a language such as C the result of processing the above template might be po This is an example class note generated using code templates author Sparx Systems K class ClassA public ClassB Execution of Code Templates A reference to a template such as the ClassNotes macro from our example above results in the execution of that template Each template is designed for use with a particular element For example the ClassNotes template is to be Code Engineering Using UML Models Code Template Framework Code Templates 62 used with UML Class elements The element that is currently being generated is said to be in scope If the element in scope is stereotyped Enterprise Architect looks for a template that has been defined for that stereotype If a match is found the specialized template is executed Otherwise the default implementation of the base template is used Templates are processed sequentially line by line replacing each macro with its underlying text value from the model 1 5 1 1 Base Templates The Code Template F
13. Language Options 56 Verilog 7 Disable Language Options for the current model Default Extension N E Options for the current user Default Attribute Type Default Source Directory Import File Extensions Editor v verilog Collection dass for 1 associations 1 4 6 13 VHDL Options Configure options for VHDL code generation using the VHDL page of the Options dialog select the Tools Options Source Code Engineering VHDL menu option The options you can specify include the Default file extension s Default source directory Editor for changing code Collection Classes 1998 2010 Sparx Systems Pty Ltd 57 Code Engineering Settings Language Options VHDL T Disable Language Options for the current model Default Extension vhdl Options for the current user Default Attribute Type Default Source Directory Import File Extensions vhdl vhd Editor Collection dass for 1 associations Collection Classes 1 4 6 14 Visual Basic Options Configure options for Visual Basic code generation using the VB Specifications page of the Options dialog select the Tools Options Source Code Engineering Visual Basic menu option The options you can specify include the e Default file extension when reading writing e Default Visual Basic version e MTS transaction mode for MTS objects e Multi use true or false e Persistable e Data binding e Global namespace e Expo
14. 126 124 127 147 147 Code Engineering Using UML Models Index 172 U UML Data Modeling Profile 120 Mappings To XSD 99 UML Profile XSD Stereotypes 91 UML Toolbox SystemC Group 81 Verilog Group 84 VHDL Group 85 Unique Constraint 147 Index 147 User Settings 39 sW VB Net Code Generation 54 Language Options 54 Modeling Conventions 83 Verilog Code Generation 55 Enterprise Architect Toolbox Pages 84 Language Options 55 Modeling Conventions 84 VHDL Code Generation 56 Enterprise Architect Toolbox Pages 85 Language Options 56 Modeling Conventions 85 View Create 145 Database 145 Element 145 ReportOn 145 Visibility Indicators Values 68 Visual Basic Code Generation 57 Import Reverse Engineering 6 Language Options 57 Modeling Conventions 87 Visual Basic Net Import Reverse Engineering 6 W W3C XML Technologies Introduction 88 Web Service Definition Language 106 Web Services WSDL 106 Generate WSDL 117 Import WSDL 119 Model WSDL 106 Model WSDL Binding 113 Model WSDL Document 110 Model WSDL Message 113 Model WSDL Message Part 116 Model WSDL Namepaces 108 Model WSDL Port Type 112 Model WSDL Port Type Operation 115 Model WSDL Service 111 What Is A Check Constraint 147 A Foreign Key 137 A Primary Key 134 A Stored Procedure 143 A Trigger Operation 147 An Index 147 WSDL Binding Diagram 113 Binding Element 113 Document Element 110 Import 117 119 Message
15. 1998 2010 Sparx Systems Pty Ltd 147 Index Trigger Check Constraint 3 10 Index Trigger Check Constraint What is an Index An index is a sorted look up for a table When it is known in advance that a table must be sorted in a specific order it is usually worth the small processing overhead to always maintain a sorted look up list rather than sort the table every time it is required In Enterprise Architect an index is modeled as a stereotyped operation On generating DDL the necessary instructions for generating indexes are written to the DDL output The unique characteristic applied to a single column ensures that no two data values in the column can be identical The unique stereotype applied to an index ensures that no two combinations of values across a set of columns can be identical What is a Trigger A trigger is an operation automatically executed as a result of the modification of data in the database and usually ensures consistent behavior of the database For example a trigger might be used to define validations that must be performed every time a value is modified or might perform deletions in a secondary table when a record in the primary table is deleted In Enterprise Architect a trigger is modeled as a stereotyped operation Currently Enterprise Architect does not generate DDL for triggers but nonetheless they aid in describing and specifying the table structure in detail What is a Check Constra
16. 4 Inthe Current Owner field click on the drop down arrow and select the current owner to change or select lt All gt to change the ownership of all tables in the package to the name you typed in the New Owner field 5 Select the Change Table Owner checkbox 6 If there are child packages that also require changing select the Process Child Packages checkbox 7 Click on the OK button The ownership changes for all Tables in the selected packages with the specified current owner For more information on setting the table owner see the Set Table Owner 126 topic To display the table owner in the current diagram see the Diagram Properties topic in UML Modeling with Enterprise Architect UML Modeling Tool Code Engineering Using UML Models DBMS Datatypes 158 3 15 DBMS Datatypes When setting up your data modeling profile you can customize the datatypes associated with a particular DBMS using the Database Datatypes screen This screen enables you to add and configure custom data types For some data types you must add the size and precision defaults and maximum values To access the Database Datatypes screen select the Settings Database Datatypes menu option You can also add a DBMS product and configure the inbuilt data types F Set as Default Max Precision 4 Scale Defined Datatypes for Databases Datatype BIGINT BIT BLOB BOOL CHAR Length DATE DATETIME DECIMAL Precision an
17. 457 for both NET 1 1 and NET 2 0 e C 461 standard plus NET managed C extensions e Delphi 474 e Javal51 gt including Java 1 5 Aspects and Generics e PHP Sr e Python s52 e Visual Basic 574 e Visual Basic NET 547 The Code Template Framework CITE ei enables you to customize the way Enterprise Architect generates source code and also enables generation of languages that are not specifically supported by Enterprise Architect Before generating code you should also familiarize yourself with the way Enterprise Architect handles local path names Local path names enable you to substitute tags for directory names for example SRC C Source When you have completed the design of your Classes you can generate source code Note In the Corporate Business and Software Engineering System Engineering and Ultimate editions of Enterprise Architect if security is enabled you must have Generate Source Code and DDL permission to generate source code See User Security in UML Models Use Live Code Generation On the Package Build Scripts dialog you have the option to update your source code instantly as you make changes to your model See the Setup for Execution Analysis topic in Visual Execution Analyzer in Enterprise Architect Tasks When you generate code you perform one or more of the following tasks 1998 2010 Sparx Systems Pty Ltd 13 Generate Source Code 1 2 1 e Gener
18. Name All attributes defined in that Tagged Record are absorbed as the Class s attributes e A procedure function in an Ada specification file is considered as the Class s member function if its first parameter satisfies the conditions specified in the options Ref Param Style Ignore Reference parameter name and Ref parameter name e The option Define Reference for Tagged Record if enabled creates a reference type for the Class the name of which is determined by the option Reference Type Name For example HelloWorld ads package HelloWorld is type HelloWorld is tagged record Att1 Natural Att3 Integer end record Public Functions function MyPublicFunction P HelloWorld return String procedure MyPublicFunction P1 in out HelloWorld AFlag Boolean private Private Functions function MyPrivateFunction P HelloWorld return String procedure MyPrivateFunction P1 in out HelloWorld AFlag Boolean 1998 2010 Sparx Systems Pty Ltd 71 Modeling Conventions Ada 2005 end HelloWorld class Testbench HelloWorld Attl Natural Att3 Integer MyPublicFunction HelloWorld String MyPublicFunction HelloWorld Boolean void My String HelloWorld Ref See Also e Import Source Code 5 e Generate Source Code 124 e Ada 2005 Options 434 1 6 3 C Conventions Note Separate conventions apply to Object Oriented programming in Cl 72 gt Enterprise Architect
19. Reverse Engineering 6 Language Options 51 Modeling Conventions 79 Modeling Conventions AspectJ Extensions K Keys Foreign Definition Primary Definition L Language Macros 39 Language Options ActionScript 163 147 19 26 12 80 120 120 43 1998 2010 Sparx Systems Pty Ltd 169 Index Language Options Ada 2005 43 C 44 C 45 C 46 Code Generation 42 Delphi 47 Java 51 MDG Technology 58 PHP 51 Python 52 SystemC 53 VB NET 54 Verilog 55 VHDL 56 Visual Basic 57 Local Directories 39 Path Dialog 39 Paths 38 Macro Language 39 Preprocessor 39 Managed C Modeling Conventions 76 Mapper Data Type Conversion Procedures 155 MDG Technology Code Generation 58 Language Options 58 Message WSDL Diagram 113 WSDL Element 113 Message Part WSDL Attribute 116 Method Delete If Not In Code In Reverse Synchronization 36 Implemented Interfaces 36 Include Bodies In Model When Reverse Engineering 36 Model Databases 120 WSDL 106 WSDL Binding 113 WSDL Document 110 WSDL Message 113 WSDL Message Part 116 WSDL Namepace 108 WSDL Port Type 112 WSDL Port Type Operation 115 WSDL Service 111 XSD 89 Model State Machine Active State Logic 23 Designate Driving Triggers 23 Establish Port Trigger Mapping 23 For Hardware Description Languages 23 Modeling Conventions 68 ActionScript 2 and3 69 Ada 2005 69 ANSIC 71 C 71 C 73 C Object Oriented Programmin
20. and provides the editor for modifying templates Templates List the base code templates The active template is highlighted The Modified field indicates whether you have changed the default template for the current language Stereotype Overrides List the stereotyped templates for the active base template The Modified field indicates whether you have modified a default stereotyped template Add New Custom Invoke a dialog for creating a custom stereotyped template Template Add New Stereotyped Invoke a dialog for adding a stereotyped template for the currently selected base Override template Code Engineering Using UML Models Code Template Framework The Code Template Editor 66 1 5 3 Get Default Template Update the editor display with the default version of the active template Save Overwrite the active templates with the contents of the editor Delete If you have overridden the active template the override is deleted and replaced by the corresponding default code template For information on creating and editing code templates using the Code Template Editor window see SDK for Enterprise Architect Note User modified and user defined Code Templates can be imported and exported as Reference Data see the Import and Export Reference Data topic in UML Model Management The templates defined for each language are indicated in the Export Reference Data dialog by the language name with the
21. the drop down lists have all the attributes and operations from the current Class you can also enter free text Set Stored to True or False Set the Implements information Set the Default value if one exists Code Engineering Using UML Models Code Engineering Settings Language Options 50 Property Details Name PublishedProperty Test3 Type Integer Read FTestField Write FTestField PublishedProperty Test3 Integer read FTestField write FTestField A Defined Properties New see Delete cose Property Details PublicProperty Test 1 Integer read m_Name write GetName default Joe PublishedProperty Test4 Extended read GetPublishedPropertyTest4 write SetPubli PublishedPropertyTest3 Integer read FTestField write FTestField PublicProperty Test2 String read GetPublicProperty Test2 write setPublicPropertyT Public Property Test 1 Integer read m_Name write GetName default Joe Notes e Public properties are displayed with a symbol prefix and published with a e When creating a property in the Create Property Implementation dialog accessed through the Attributes dialog you can set the scope to Published if the property type is Delphi see the example below Property Details Name FTestField Getter GetFTestField Setter SetF TestField Value Integer Stereotype wl 7 Published Get Scope fg j Y Write Sa ope Limitations e Only
22. to display an example of Java code generated from the State Machine diagram above 1 3 1 1 Java Code Generated From State Machine Diagram private enum StateType int ProcessOrder_Delivered ProcessOrder_Packed ProcessOrder_Closed ProcessOrder_Dispatched ProcessOrder_New ST_NOSTATE private enum TransitionType int ProcessOrder_Delivered_to_ProcessOrder_Closed TT_NOTRANSITION private enum CommandType Do Entry Exit 1998 2010 Sparx Systems Pty Ltd 21 Code Generation From Behavioral Models SW Code Generation State Machine Diagrams private StateType currState private StateType nextState private TransitionType currTransition private boolean transcend private StateType ProcessOrder_history private void processOrder_Delivered CommandType command switch command case Do Do Behaviors setStatus Delivered State s Transitions if status Delivered nextState StateType ProcessOrder_Closed currTransition TransitionType ProcessOrder_Delivered_to_ProcessOrder_Closed break default break private void processOrder_Packed CommandType command switch command case Do Do Behaviors setStatus Packed State s Transitions nextState StateType ProcessOrder_Dispatched break default break private void processOrder_Closed CommandType command switch command case Do Do Behaviors
23. type xs string minOccurs 1 maxOccurs 1 gt lt xs element name mobilePhone type xs string minOccurs 1 maxOccurs 1 gt lt xs element name officePhone type xs string minOccurs 1 maxOccurs 1 gt lt xs element name streetAddress type xs string minOccurs 1 maxOccurs 1 gt lt xs sequence gt contsctDetsils lt xs complexType gt lt xs element name Person type Person gt xs complexType name Person gt lt xs sequence gt Person lt xs element name birthDate type xs string minOccurs 1 maxOccurs 1 gt lt xs element name firstName type xs string minOccurs 1 maxOccurs 1 gt lt xs element name gender type xs string minOccurs 1 maxOccurs 1 gt lt xs element name surName type xs string minOccurs 1 maxOccurs 1 gt lt xs element name contactDetails type Contactinfo minOccurs 1 maxOccurs 1 gt lt xs sequence gt lt xs complexType gt You can change this default behaviour by deselecting the Generate global element for all global ComplexTypes checkbox on the Generate XML Schema op dialog Then the generated XSD no longer contains the global element as shown below Code Engineering Using UML Models XML Schema XSD Generate XSD 102 class GenXSDExample lt xs complexType name Contactinfo gt lt xs sequence gt lt xs element name email type xs string minOccurs 1 maxOccurs 1
24. 101 WSDL 117 XML Schema For Referenced Packages 100 XML Schema For Child Packages XSD 100 Generate Code From Activity Diagrams From Behavioral Models From Interaction Diagrams From Sequence Diagrams From State Machine Diagrams Generate Source Code Overview 12 Global Element Generate For Global ComplexTypes Generate In XSD 101 Import XSD 104 Global Elements Import 102 H Hardware Description Languages Model State Machine For 23 HDL Model State Machine For Implemented Interfaces Generate Disable Methods For Import ActionScript Reverse Engineering 6 Binary Module Reverse Engineering 9 C Reverse Engineering 6 C Reverse Engineering 6 C Reverse Engineering 6 Component Types 33 Database Schema from ODBC DDL Schema from ODBC 160 Delphi Reverse Engineering 6 Directory Structure Reverse Engineering 8 Global Elements 102 100 19 27 19 19 26 19 26 19 100 23 36 160 Visual Basic Reverse Engineering 6 Visual Basic Net Reverse Engineering 6 WSDL 119 XSD 102 Imported Class Elements Index Create in Data Modeling Unique 147 What Is An 147 Interaction Diagram Generate Code From Interface Source Code Generation Internal Editor 34 Introduction To Code Engineering 2 To Forward Engineering 2 To Reverse Engineering 2 To Round trip Engineering 2 To Synchronization 2 S Java AspectJ Extensions 6 Code Generated From State Machine Diagram 20 Code Generation 51 Import
25. Code Engineering option on each language page click on the Collection Classes button Collection dass for 1 associations Collection Classes The Collection Classes for Association Roles dialog displays Language 58 Static Default Collection Class Collection Class for Ordered Multiplicity Collection Class for QualifiedMultiplicity L oe Il Ga lm On this dialog you can define e The default Collection Class for 1 roles e The ordered Collection Class to use for 1 roles e The qualified Collection Class to use for 1 roles On the Detail tab of the Class Properties dialog accessible from the right click context menu of any Class click on the Collection Classes button Concurrency Sequential Guarded Active gt Synchronous The Collection Classes for Association Roles dialog again displays but here you define for when only this Class is used e The default Collection Class for 1 roles e The ordered Collection Class to use for 1 roles e The qualified Collection Class to use for 1 roles When Enterprise Architect generates code for a connector that has a multiplicity role gt 1 the Collection Class is calculated as follows 1 2 If the Qualifier is set use the qualified collection e for the Class if set e else use the code language qualified collection If the Order option is set use the ordered collection e for the Class if set Code Engineering Using UM
26. Enterprise Architect looks in all three source directories but never in the inc directory You must still ensure that the implementation file name matches the header file name and that the file extension matches the extension specified in the options If these conditions are not met Enterprise Architect cannot handle that code 1998 2010 Sparx Systems Pty Ltd 47 Code Engineering Settings Language Options C Specifications i Disable Language E Options for the current model D C Version ANSI y Default Reference Type Pointer Header Extension h d Source Extension cpp F Get Prefix Get Set Prefix Set E E Options for the current user Default Attribute Type int Generate Namespaces False Comment Style Plain Method Notes in Header False Method Notes in Implementation True 7 Collection dass for 1 associations 1 4 6 6 Delphi Options Configure options for Delphi code generation using the Delphi Specifications page of the Options dialog select the Tools Options Source Code Engineering Delphi menu option The options you can specify include the e Default file extension e Default source directory You can also set a default directory for opening and saving Delphi source code Code Engineering Using UML Models Code Engineering Settings Language Options 48 Disable Language A Options for the current model Default Extension pas E Options for the curr
27. Models State Machine Modeling For HDLs Establish Port Trigger Mapping After successfully modeling the different operating modes of the component and the triggers associated with them you must associate the triggers with the component s ports as shown in the following diagram class HDL A dependency relationship is used to represent association between ports and their triggers A Dependency relationship from the Port to the associated trigger should be used to signify their association See Also e State Diagram See the UML Dictionary e Transition e SW Code Generation State Machine Diagrams 19 Active State Logic The first two aspects above put in place the preliminaries required for efficient interpretation of the hardware components The actual State Machine logic is now modeled within the Active Submachine state stm StateMachine The Submachine state that is intended to contain the actual design Note The current code generation engine supports only one clock trigger for a component Code Engineering Using UML Models Code Generation From Behavioral Models Code Generation Interaction Diagrams 26 1 3 3 Code Generation Interaction Diagrams Note To be able to generate code from behavioral models all behavioral constructs should be contained within a Class For an Interaction Sequence diagram the behavioral code generation engine expects the
28. Options 51 Modeling Conventions 80 Port Type WSDL Diagram 112 WSDL Element 112 Port Type Operation WSDL 115 Preprocessor Macros 39 Primary Key Complex 134 Create 134 Description 134 Extended Properties 136 Name Template Define 134 Simple 134 SQL Server Non Clustered 136 Python Code Generation 52 Import Reverse Engineering 6 Language Options 52 Modeling Conventions 81 R Referenced XML Schema Import 102 Reset Options ForAClass 59 For All Classes 59 Source Code Language 59 Reverse Engineer Source Code 4 Reverse Engineering And MDG Integration 10 Directory Structure 8 Eclipse 10 Handling Classes Not Found During Import 10 Import ActionScript 6 Import Binary Module 9 ImportC 6 Import C 6 Import C 6 Import Delphi 6 Import Java 6 Import PHP 6 Import Python 6 O 1998 2010 Sparx Systems Pty Ltd 171 Index Reverse Engineering Import Source Code 5 10 Import Visual Basic 6 Import Visual Basic Net 6 Introduction 2 ODBC Data Sources 160 Source Code Import Directory Structure 8 Synchronize Model And Code 10 Visual Studio 10 Reverse Synchronization Delete Attribute If Not In Code 36 Delete Method If Not In Code 36 Delete Model Aggregations For Attributes Not In Code 36 Delete Model Associations For Attributes Not In Code 36 Include Method Bodies In Model 36 Round Trip Engineering Introduction 2 LS Schema Database Import From ODBC DDL Import From ODBC 160 Owner Tagged Va
29. PrivateFunctionTest string property get GetPublicPropertyTest2 string property set SetPublicPropertyTest2 string ProtectedFunction Test boolean Constructor TestCreate TObject function PublicFunctionTest Word function ProtectedFunctionTest Boolean PublicProcedureTest Double property set SetPublishedPropertyTest4 Extended property get GetPublishedPropertyTest4 Extended ProtectedProcedureTest WideString destructor TestDestroy void tags property PublicPropertyTest1 Integer read m_Name write GetName default Joe property PublicPropertyTest2 String read GetPublicPropertyTest2 write setPublicPropertyTest2 default 13 property PublishedPropertyTest3 Integer read FTestField write FTestField property PublishedPropertyTest4 Extended read GetP ublishedPropertyTest4 write setPublishedPropertyTest4 To manually activate the property editor 1 Ensure the Class you have selected has the code generation language set to Delphi 2 Right click on the Class and select the Delphi Properties context menu option to open the editor The Delphi Properties editor enables you to build properties in a simple and straightforward manner From here you can Change the name and scope only Public and Published are currently supported Change the property type the drop down list includes all defined Classes in the project Set the Read and Write information
30. Select the Tagged Values tab of the table Properties dialog The Tagged Values tab shows the tags for the table Ce 2 Click on the New Tag button The Tagged Value dialog displays Tag Ss In the Tag field type the tag name Owner In the Value field type a value for the Owner tag Note For a PostgreSQL database to define the owner name e In the Tag field type the tag name OWNER TO e In the Value field type Owner_Name Click on the OK button to confirm the operation Generated DDL includes the table owner in the SQL script 3 3 2 Set MySQL Options In MySQL to make use of foreign keys you must declare the table type as InnoDB To do this follow the steps below 1 Select the Tagged Values tab of the table Properties dialog The Tagged Values tab shows the tags for the table 2 Click on the New Tag button inten The Tagged Value dialog displays 1998 2010 Sparx Systems Pty Ltd 127 Set Table Properties Set MySQL Options 3 Inthe Tag field type the tag name Type In the Value field type InnoDB as the value for the Type tag 4 Click on the OK button to confirm the operation Generated DDL includes the table type in the SQL script 5 To allow for later versions of MySQL additional table options that can be added in the same manner include 3 3 3 Set Oracle Table Properties For Oracle you can set table properties using the table s Tagged Value
31. Show a tree with the results of parsing the open file requires that the file is parsed successfully Don t parse files larger than Specify an upper limit on file size for parsing Used to prevent performance decrease due to parsing very large files 1 4 1 3 Options Object Lifetimes This set of options enables you to configure e Constructor details when generating code e Whether to create a copy constructor e Destructor details These options are accessed via the Constructor page of the Options dialog select the Tools Options Source Code Engineering Object Lifetimes menu option Code Engineering Using UML Models Code Engineering Settings Source Code Engineering 36 PF Sequence A ee 33 Objects Links V Generate Constructor 22 Communication Colors E Constructor indine C only gt XML Specifications Default constructor visibility 8 3 Source Code Engineering Copy Constructor 4 Code Editors e A m Generate Copy Constructor y Attribute Operations L Copy Constructor indine C only E ActionScript Default copy constructor visibility ej c Destructor E G Y Generate Destructor M Delphi d E Destructor indine C only d 7 Virtual Destructor C only p Java gi PHP EE Pubic y Python Visual Basic VB Net Ada Sc SystemC W Verilog DN VHDL 1 4 1 4 Options Attribute Operations This set of options ena
32. Source Code Generate a Package 16 As code generation proceeds Enterprise Architect displays progress messages If a Class requires an output filename Enterprise Architect prompts you to enter one at the appropriate time assuming Auto Generate Files is not selected For example if the selected Classes include partial Classes a prompt displays to enter the filename for the second partial Class For additional information on the options on the Generate Package Source Code dialog see the following table Root Package Check the name of the package to be generated Select options that specify how existing files should be generated Auto Generate Files Specify whether Enterprise Architect should automatically generate file names and directories based on the package hierarchy Root Directory If Auto Generate Files is selected display the path under which the generated directory structures are created Retain Existing File Paths If Auto Generate Files is selected specify whether to use existing file paths associated with Classes If unselected Enterprise Architect generates Classes to automatically determined paths regardless of whether source files are already associated with Classes Include all Child Packages Include all Classes from all sub packages of the target package in the list This option facilitates recursive generation of a given package and its sub packages Select Objects to Generate List all Classes that
33. add It is recommended that you do not delete any of the default entries as it may cause an invalid WSDL document to be generated 4 Select one or more services that should be exposed by this document The list of available services is populated from the Services package fh 5 Click on the OK button 1998 2010 Sparx Systems Pty Ltd 111 Web Services WSDL Model WSDL You can edit the WSDL specific properties of the document later by double clicking the component in the diagram or the Project Browser Alternatively click on the UML button in the WSDL Document Properties dialog to invoke the standard Properties dialog for a package This button does not display on the initial WSDL Document Properties dialog for a new WSDL element 2 2 1 3 WSDL Service WSDL services are represented in Enterprise Architect by UML interfaces stereotyped as WSDLservice Services should be defined under the Services packages in the WSDL namespace structure To define new WSDLservice elements for your namespace follow the steps below 1 Open the Overview diagram defined for your WSDL namespace package and double click on the Services package element to open the Services diagram 2 Drag the Service element from the Toolbox onto the diagram The WSDL Service dialog displays SampleService nen osete Port Name Binding Location SamplePortHTTP SampleBindingHTTP http www examplel SamplePortSOAP SampleBindingSOAP
34. and Oracle s ODBC driver for Oracle Drivers provided by third party vendors are not supported this includes the Microsoft ODBC driver for Oracle e f setting up a ODBC connection for reverse engineering the default settings are sufficient e Additional data types are available from the Datamodeling Data Types section of the Resources page on the Sparx Systems website Import Database Tables and Stored Procedures To import database tables and stored procedures follow the steps below 1 Select any package in the Logical View 2 To import into e The package only right click on the package to display the context menu and select the Code Engineering Import DB Schema from ODBC menu option e Adiagram right click on the diagram in the selected package to open the context menu and select the Import DB schema from ODBC menu option Note Alternatively you can select the Project Database Engineering Import DB Schema from ODBC menu option The Import DB Schema from ODBC Source dialog displays 1998 2010 Sparx Systems Pty Ltd 161 Import Database Schema from ODBC Import DB schema from ODBC source Database Oracle ORA11 ORA11_ SCOTT Options Schema Owner scott Include System Objects F Indude User Packages Oracle Indude User Views 4 Indude Length Semantics Oracle Indude Triggers Default Constraints SQL Server V Indude User Stored Procedures I
35. anonymous tags from native C are not supported e The Pure property of an operation corresponds to the keyword abstract See Also e Import Source Code si e Generate Source Code 124 1 6 5 2 C CLI Conventions The following conventions are used for modeling C CLI extensions to C In order to set Enterprise Architect to generate managed C CLI you must modify the C version in the C Options 487 Stereotypes Operation Defines an event to provide access to the event handler for this Class property Operation Attribute This is a property possibly containing both read and write code Corresponds to the ref class or ref struct keyword value Class Corresponds to the value class or value struct keyword Tagged Values attribute_name Operation with The name of the variable behind this property or event stereotype property or event generic Operation Defines the generic parameters for this Operation genericConstraint Templated Class or Defines the constraints on the generic parameters for this s Interface Operation Operation with tag generic Attribute Corresponds to the initonly keyword literal Attribute Corresponds to the literal keyword managedType Class with stereotype Corresponds to either the class or struct keyword reference value or enumeration Interface Code Engineering Using UML Models Modeling Conventions C Conventions 78 Other Conventions e
36. as two separate Classes with the partial tag e The s Leaf property of a Class corresponds to the sealed keyword See Also e Import Source Code si e Generate Source Code 124 e C Options 457 1 6 5 C Conventions Enterprise Architect supports round trip engineering of C including the Managed C 76 and C CLI 7A extensions where the following conventions are used Stereotypes CIN Jovoaion TT CN CI CAT typedef A typedef statement where the parent is the original type name Tagged Values Applies To Corresponds To anonymous Class also containing the The name of this class being only defined by the typedef Tagged Value typedef statement attribute_name Operation with stereotype The name of the variable behind this property property get or property set Code Engineering Using UML Models Modeling Conventions C Conventions 76 bites ms Dramen values are header classDec or classBody ETC CT ETA inline Operation The inline keyword and inline generation of the method body mutable Attribute The mutable keyword throws Operation The exceptions that are thrown by this method typedef Class with stereotype This Class being defined in a typedef statement other than typedef typeSynonyms The typedef name and or fields of this type Other conventions e Namespaces are generated for each package below a namespace root 17 e By Reference attributes correspond to a
37. elements and the Properties dialog is solely concerned with the Function or Sequence definition For Stored Procedures always select this option Code Engineering Using UML Models Import Database Schema from ODBC 162 If you select to import User Functions and or User Sequences as Class operations then they are imported as operations methods and you view and edit them through the Operations Properties dialog of the parent Class 6 When synchronizing existing Classes select the appropriate checkbox in the Synchronization panel to determine whether the model comments default values or constraints are to be synchronized with the ODBC tables or as new objects Note It is only possible to import into a diagram if it is in the selected package If a diagram from another package is open a message displays to give the option to cancel the import or to continue importing into the package only The Import DB Schema from ODBC Source dialog includes checkbox options to import into the diagram and package or into the package only If no diagram is open the Package Only radio button defaults to selected and the options are disabled If the open diagram is in the selected package you can select either option 7 Click on the Import button to start the import 8 Select the tablesl16 and if appropriate stored procedures to import This completes the procedure See the Imported Class Elementen topic 3 16 1 Select a Dat
38. gt lt xs element name homePhone type xs string minOccurs 1 maxOccurs 1 gt lt xs element name mobilePhone type xs string minOccurs 1 maxOccurs 1 gt lt xs element name officePhone type xs string minOccurs 1 maxOccurs 1 gt lt xs element name streetAddress type xs string minOccurs 1 maxOccurs 1 gt lt hs sequence gt lt hs complexType gt XSDcomplexT ype Contactinfo contactDetails lt xs complexType name Person gt lt xs sequence gt lt xs element name birthDate type xs string minOccurs 1 maxOccurs 1 gt lt xs element name firstName type xs string minOccurs 1 maxOccurs 1 gt lt xs element name gender type xs string minOccurs 1 maxOccurs 1 gt lt xs element name surName type xs string minOccurs 1 maxOccurs 1 gt lt xs element name contactDetails type Contactinfo minOccurs 1 maxOccurs 1 gt lt xs sequence gt lt xs complexType gt XSDeomplexT ype Person 2 1 3 Import XSD The XML Schema Import facility is used to reverse engineer a W3C XML Schema XSD file as a UML Class model An XSD file is imported into Enterprise Architect as a UML package To import an XSD file follow the steps below 1 Inthe Project Browser right click on the package to contain the imported XSD package The context menu displays 2 Select the Code Engineering Import XML Schema menu option The Import XML Schema
39. http www examplel 3 Inthe Name field type the service name 4 Click on the New button to add Service Ports The WSDL Port dialog displays Code Engineering Using UML Models Web Services WSDL Model WSDL 112 Port Name Binding SampleBindingHTTP v www exampleLocation com Port1 5 Type in the Port Name and Location and select a Binding The list of Bindings is taken from those defined in the Bindings package 113 6 Click on the OK button to close the WSDL Port dialog For each Port defined in this way Enterprise Architect creates an Association relationship between the Service and corresponding Binding element 7 Click on the OK button to close the WSDL Service dialog You can edit the WSDL specific properties of the service later by double clicking the Service interface in the diagram or Project Browser Alternatively click on the UML button in the WSDL Service dialog to invoke the standard Properties dialog for an interface This button does not display on the initial WSDL Service dialog for a new Service element 2 2 1 4 WSDL Port Type WSDL Port Types are represented in Enterprise Architect by UML interfaces stereotyped as WSDLportType PortTypes should be defined under the PortTypes packages in the WSDL namespace structure To define new WSDLportType elements for your namespace follow the steps below 1 Open the Overview diagram defined for your WSDL namespac
40. methods and XSD constructs Code Engineering Using UML Models XML Schema XSD Model XSD 90 XSDcomplexType XSDcomplexType Person Contactinfo XS Delement XS Delement birthDste string email string 1 3 firstName string homePhone string gender string 1 streetAddress sting surName string XSDcomplexType EmployeeRecords tags modelGroup all tags memberNames mixed false mode Group all XSDcomplexType Employee XSDelement department string jobTitle string stariDate date mobiePhone sting officePhone string string XSDsimple Type Gender enumeration Status Attributes Full Time string Part Time string Casual string Contract string tags denvstion restriction pattem male female The following code shows the schema generated for the Employee Details package by default Notice how each UML Class corresponds to a complexType definition in the schema The Class attributes are generated as schema elements contained in a Sequence model group within the definition The Enumeration Class is the exception here it maps directly to an XSD enumeration contained within a simpleType definition lt xml version 1 0 gt lt xs schema xmins xs http www w3 0rg 2001 XMLSchema gt lt xs element name Contactlnfo type Contactlnfo gt lt xs complexType name Contactlnfo gt
41. not display on the initial WSDL Message Part dialog for a new message part attribute 2 2 2 Generate WSDL The Generate WSDL feature forward engineers a UML model to a Web Service Definition Language WSDL file The Generate WSDL feature acts on a package stereotyped with WSDLnamespace It is used to generate any or all of the WSDL stereotyped components owned by the target WSDLnamespace structure To generate one or more WSDL files from a WSDLnamespace follow the steps below 1 Inthe Project Browser right click on the target WSDLnamespace package to display the context menu 2 Select the Code Engineering Generate WSDL menu option The Generate WSDL dialog displays Code Engineering Using UML Models Web Services WSDL Generate WSDL 118 Select Components To Generate Component WSDL Prefix Target File OnlineBookstore wsdl C Documents and Settings bconstable Des For each WSDL component set the required output file using the Target File column Using the Encoding field set the required XML encoding Click on the Generate button to generate the WSDL files The progress of the WSDL generator is shown in the Progress edit box oa Pw Tip The Generate WSDL dialog can also be accessed from the active diagram by selecting the Project Generate WSDL menu option 1998 2010 Sparx Systems Pty Ltd 119 Web Services WSDL Import WSDL 2 2 3 Import WSDL The WSD
42. package are defined within one schema This stereotype can be used to specify schema wide settings Tagged anonymousRole Specifies if the role name is included in the element declaration Values true false for the UML attribute anonymousType Specifies whether the Class type is anonymous for attributes true false attributeFormDefault Determines whether attribute instances must be qualified qualified unqualified defaultNamespace The default namespace used in this schema This value is used to specify the default namespace attribute xm ns in the schema element elementDerivation Determines whether inheritances are generated using XSD true false extension or copy down inheritance elementFormDefault Determines whether element instances must be qualified qualified unqualified memberNames Determines whether elements generated from Class attributes qualified unqualified have their name qualified by the corresponding Class name modelGroup Specifies the default XSD model group used to generate all seguence choice complexType definitions schemaLocation The URI that identifies the location of the schema This value is used in the import and include elements 1998 2010 Sparx Systems Pty Ltd 93 XML Schema XSD Model XSD XSDcomplexType UML Construct Description complexType definitions are created for generic UML Classes This stereotypes helps tailor the
43. pass in another language 5 Click on the Advanced button The Object Options dialog displays Code Engineering Using UML Models Generate Source Code Generate a Single Class 14 8 E Source Code Engineering A Object Lifetimes ae SET iy Atribute Operations i ways synchronize with existing file recommended Co tT E ActionScript gt Replace overwrite existing source file ej c E E Default Language for Code Generation 3 C i Delphi Wrap long comment lines at 80 chars 1 no wrap amp Java Auto Layout Diagram on Import On New Diagram v gi PHP Python S Visual Basic Prompt when synchronizing reversing d Comments Remove hard breaks from comments on import d VB Net Auto generate role names when creating code d WW Generate Do not generate members where association Reverse direction is Unspecified Create dependencies for operation returns and parameter types Remove prefixes when generating Get Set properties separate entries with m_s m_n m_b m_ 7 Treat as suffixes T Capitalized Attribute Name for Properties Y Use Is for Boolean property Gett Code page for source Set any custom options for this Class alone then click on the Close button to return to the Generate Code dialog In the Import s Header s fields type any import statements includes or other header information Note that in the case of Visual Basic this in
44. pointer to the type specified e The Transient property of an attribute corresponds to the volatile keyword e The Abstract property of an attribute corresponds to the virtual keyword e The Const property of an operation corresponds to the const keyword specifying a constant return type e The s Query property of an operation corresponds to the const keyword specifying the method doesn t modify any fields e The Pure property of an operation corresponds to a pure virtual method using the 0 syntax e The Fixed property of a parameter corresponds to the const keyword See Also e Import Source Code si e Generate Source Code 124 e C Options 467 1 6 5 1 Managed C Conventions The following conventions are used for managed extensions to C prior to C CLI 77 gt In order to set Enterprise Architect to generate managed C you must modify the C version in the C Options 467 Stereotypes Stereotype Applies To Corresponds To property get The property keyword and a read property property set The __ property keyword and a write property 1998 2010 Sparx Systems Pty Ltd 77 Modeling Conventions C Conventions Stereotype Applies To Corresponds To Tagged Values Applies To Corresponds To managedType Class with stereotype reference The keyword used in declaration of this type value or enumeration Interface Expected values are class or struct Other Conventions e The typedef and
45. that your organization uses e ls being developed on a daily basis by your developers Enterprise Architect currently supports reverse engineering in the following programming languages e ActionScript e e Ada 2005 6 Systems Engineering and Ultimate editions e Cl7t e Cl e Clg e Delphi 7A e Javal7 e PHP at e Python ei e SystemC 81 Systems Engineering and Ultimate editions e Verilog 841 Systems Engineering and Ultimate editions 1998 2010 Sparx Systems Pty Ltd 5 Reverse Engineering e VHDL 85 Systems Engineering and Ultimate editions e Visual Basic 8 e Visual Basic NEI sg Enterprise Architect is also able to reverse engineer certain types of binary files Java Jor files and NET PE files See Import Binary Module ai for more information Notes e Reverse Engineering of other languages is currently available through the use of MDG Technologies from www sparxsystems com resources mdg_tech e Inthe Corporate Business and Software Engineering System Engineering and Ultimate editions of Enterprise Architect if security is enabled you must have Reverse Engineer From DDL And Source Code permission to reverse engineer source code and synchronize model elements against code See User Security in UML Models 1 1 1 Import Source Code To import source code reverse engineer follow the steps below 1 Inthe Project Browser select or add a diagram into which to import
46. the Classes 2 Right click on the diagram background to open the context menu and either e Select the language to import from the Import from source file s submenu or e Click on the Import Language drop down arrow in the Code Generation toolbar and select the Import Import xxx files menu option where xxx represents the language to import 3 From the file browser that appears select one or more source code files e to import wer My Organize yeas Rss a e Name _ Date modified Type Size WW Desktop A z A eclipse 3 3 Recent Places de Linux Procedures amp Computer _ Class java More _ ContactInfo java Folders v HelloWorld java Lo Roy a _ OrderStatus java d i arc _ ShoppingBasket java A eclipse 3 3 _ Transition java d i Linux Proced _ A Sam E A ServerConfigu A Sharon A Simon Simon Se File name e Java Source Files Java Ise 4 Click on the Open button to start the import process As the import proceeds Enterprise Architect provides progress information When all files are imported Enterprise Architect makes a second pass to resolve associations and inheritance relationships between the imported Classes Code Engineering Using UML Models Reverse Engineering Import Source Code 6 Current Action Reverse engineer classes importing Y Dev Roy HelloWorld java Adding Class HelloWorld Resolve relationships elationships for HelloWord
47. their UML representations This enables you to examine legacy code and the functionality of code libraries for reuse or to bring the UML model up to date with the code You can reverse engineer in the same languages as you perform code generation with Enterprise Architect Enterprise Architect is also able to reverse engineer binary files namely Java jar files and NET PE files Note Reverse Engineering of other languages including CORBA IDL is also currently available through the use of the MDG Technologies See www sparxsystems com resources mdg_tech O 1998 2010 Sparx Systems Pty Ltd Synchronization Synchronization 10 is when changes in the model are exported to the source code and changes to source code are imported into the model This enables you to keep your model and source up to date as the project develops Round Trip Engineering Round trip engineering is a combination of reverse and forward generation of code and includes synchronization between the source code and the model in all but the most trivial of code engineering projects In order to get the most out of round trip engineering in Enterprise Architect you should be familiar with the modeling conventions 687 used when generating and reverse engineering the languages you use Code Engineering Using UML Models Reverse Engineering 4 1 1 Reverse Engineering UML 30 PHP Ab C yan Cz e Reverse Engineering in Ent
48. 10 Sparx Systems Pty Ltd 139 Foreign Key Create Foreign Key column PK WarehouselD VARCHAR2 10 Location VARCHAR2 30 Capacity NUMBER 8 2 PK leva Data modeling isperformed using PK_Warehouse VARCHAR2 dereotyped classes Add a table tothe diagram by dragging from the Class Elementstool box PK_Warehouse 1 WarehouselD WarehouselD FK_Inventory_Warehouse column PK InventorylD VARCHAR2 10 Inventoryld InventorylD FK WarehouselD VARCHAR2 10 CurrentStock NUMBER 8 OnOrder NUMBER 8 EKS FK_Book_Inventory FK_Inventory_Warehouse VARCHAR2 PK PK_Inventory VARCHAR2 column PK ISBN VARCHAR2 15 FK InventorylD VARCHAR2 10 AuthorlD VARCHAR2 30 PublisherlD VARCHAR2 20 Cost NUMBER 8 Stock NUMBER 8 Associations between tables are based on the Primary to Foreign key relationship These examples how howto define this PK PK_Book VARCHAR2 FK FK_Book_Inventory VARCHAR2 Composite Foreign Key To create a composite Foreign Key select the appropriate columns and click on the Save button The Foreign Key columns are sorted according to datatype to match the datatypes of the targeted composite Primary Key If required you can change the order of the key columns by clicking on the and buttons Tip If you are defining a MySQL database and want to use Foreign Keys you must set the table type 1261 to enable thi
49. 10082 MAC Croatia a zing feve 1026 IBM EBCDIC Turkish Latin 5 j C Remove hard breaks from comm f SI 1047 IBM EBCDIC Latin 1 Open System Ga Auto generate role names when 4449 IBM EBCDIC U S Canada 37 Euro E C Do not generate members where 1141 IBM EBCDIC Germany 20273 Euro fft Delphi direction is Unspecified _ 1142 IBM EBCDIC Denmark Norway 20277 dr Java Create dependencies for operatio 1143 IBM EBCDIC Finland Sweden 20278 parameter types 1144 IBM EBCDIC italy 20280 Euro S gt PHP 1145 IBM EBCDIC Latin America Spain 202 Python Remove prefixes when generat 1146 IBM EBCDIC United Kingdom 20285 Visual Basic ias 1148 IBM EBCDIC Intemational 500 Euro VB Net MAMI 1149 IBM EBCDIC Icelandic 20871 Euro 1250 ANSI Central Europe A Ada E Capitalized Attribute Name f 1251 ANSI Cyrillic Sc SystemC 1252 ANSI Latin I M e eer E Code page for source editing 2 Inthe Code page for source editing field click on the drop down arrow and select the appropriate Unicode character set 3 Click on the Close button 1 4 2 Local Paths Sometimes a team of developers could be working on the same Enterprise Architect model Each developer might store their version of the source code in their local file system but not always at the same location as their fellow developers To handle this scenario Enterprise Architect enables you to define local paths fo
50. 14 1 6 9 Python Conventions Enterprise Architect supports the round trip engineering of Python where the following conventions are used Tagged values Applies To Corresponds To Class Operation The decorators applied to this element in the source Other Conventions e Model members with Private Scope correspond to code members with two leading underscores e Attributes are only generated when the Initial value is not empty e All types are reverse engineered as var See Also e Import Source Code si e Generate Source Code 124 e Python Options 524 1 6 10 System C Conventions Enterprise Architect supports round trip engineering of SystemC where the following conventions are used Stereotypes DEER DEER DEET ES zoue ees CET Code Engineering Using UML Models Modeling Conventions System C Conventions 82 Stereotype Applies To Corresponds To struct Inner Class A Struct or union Tagged Values eene Por ec a rat si sob econ mows wove on Fornaio mannan O O COI CI TEC Other Conventions e SystemC also inherits most of the stereotypes and Tagged Values of C 757 SystemC Toolbox Pages To access the SystemC pages of the Enterprise Architect UML Toolbox select the More tools HDL SystemC Constructs menu option Drag these icons onto a diagram to model a SystemC design CC CN SystemC Module Define a SystemC Module An sc_module stereotyped Class element Enume
51. 7 Delphi Properties 48 JAVA OPON S eener eet SSES A A tne 51 PHP pose eeler ege a A EE i ne ie 51 Python Ee EE 52 SystemC Tee EE 53 VB Net Options dis DA Verilog Options rage ice EE ethane o 55 VADE ee EE 56 Visual Basic le EE 57 MDG Technology Language Options ceceeseeseeeeeeseseeeeeeseeeeeeeeaeeeeecaeeeseseeeseeeeaeeeesaeeeaeseeeeeseaeeneeeaees 58 1998 2010 Sparx Systems Pty Ltd H Contents Reset Options ici TA eee erica ere icine a ai 59 Code Template Framework cccsccsseceseeeeeeseeeseneeenseeeeeeesseseeeeneeeesseaeseseaeenseeeeseaesaseaneeseeaeas 61 Code dae Soe EE EE 61 Base Termplates ccccessssssrssesessstesseesonescanenseesenscesentensesconeasanensousoncesesensesencerencasensnsesseccasoneesensensenss 62 The Code Template Eqiton gege EE ENEE EEN 64 Synchronize Code 66 synchronize Ee Ee EE 67 Add New Gechons 0 2 eeceeceeeeeeeseeeeeeeeseeeeeeaeeeaesaeesaeeeeeeaeeeaeeeeeeaeeeaeeeaesaeeeaeenaesaeeeaeseeesaeeeaeeneesaeeeaeeneeeneeeatee 67 Add New Features and Elements AAA 67 Modeling Conventions ccccncccnnccnnncccnnnerncc rra 68 ACtionScript Conventions ii suck see aeaa aE aa aia aaa aae aA pren EE aE HSEEE 69 A O 69 A TO 71 Object Oriented Programming IN C A 72 CH Conventions E 73 ee EE 75 Managed C Conventions cion dd 76 C CLI Conventions 77 Delphi CONVENTIONS 2 78 JAVA CONVENIO E 79 ee VEER 80 PHP CONVENTIONS ii
52. Activity Diagrams else No Outstanding orders return Code Engineering Using UML Models Code Engineering Settings 32 1 4 Code Engineering Settings You can set the default code options such as the editors for each of the programming languages available for Enterprise Architect and special options for how source code is generated See Also e General Options 324 e Local Paths 384 e Local Path Dialog 394 e Language Macros 39 e Setting Collection Classes 41 1 4 1 Source Code Engineering The following topics describe general options that apply to all languages when generating code from Enterprise Architect These options are all available under the Source Code Engineering section of the Options dialog select the Tools Options Source Code Engineering menu option e Source Code Options 32 e Options Code Editors a e Options Object Lifetimes 35 e Options Attribute Operations 367 e Synchronize Model and Codel 107 e Code Page for Source Editing 374 1 4 1 1 Source Code Options When you generate code for a particular language you can set certain options These include e Create a default constructor e Create a destructor e Generate copy constructor e Select default language e Generate methods for implemented interfaces e Set the unicode options for code generation These options are accessed the Source Code Engineering page of the Options dialog select
53. Code Engineering Settings Language Options 44 Options Source Code Engineering Ada menu option The options you can specify include e Use Class Name for Tagged Record to inform the reverse engineering process whether the name of the Tagged Record is the same as the package name e Alternate Tagged Record Name to advise the engine of the alternate Tagged Record name to locate e Define Reference for Tagged Record to specify whether the engine should create a reference type for the Tagged Record if one is not defined e Reference Type Name to supply the name of the reference type to be created default is Ref e Ref Parameter Style to specify the reference parameter of a Reference Access type e Ignore Reference Parameter Name to tell the engine to ignore the name of the reference parameter e Ref Parameter Name to indicate the name of the reference parameter to locate Ada __ Disable Language Jei at Attnbute ype Options for the current user D Generate Namespaces True Default Source Directory Import File Extensions ads Editor Use Class Name for Tagged Record True Altemate Tagged Record Name Typ Define Reference for Tagged Record False m Reference Type Name Ref Ref Parameter Style Access Ignore Reference parameter name False Ref Parameter Name this z Collection dass for 1 associations Collection Classes 1 4 6 3 C Options Configure options for C code generati
54. Default Database MySql DDL Name Templates Internal Source Editor 1 43 Source Code Engineering Use inbuilt editor if no external editor set E Show Line Numbers Object Lifetimes Show Structure Tree a Attribute Operations Don t parse files larger than Always Parse I ActionScript ej c cy Ce JE C MY Delphi 2 Click on the DDL Name Template button The DDL Name Template dialog displays showing the default name templates Foreign Key Name Template ENK foreigntablename Yprimarytablename Primary Key Name Template Unique Constraint Name Template 3 Edit or replace the name template in the Foreign Key Name Template field Note If you want to display the Foreign Key description as FK_foreigntablename_FKcolumnname_primarytablename_PKcolumnname then change the Foreign Key Name Template field to FK_ foreigntablename _ fkcolumnname _ primarytablename _ pkcolumnname 4 Click on the Save button 1998 2010 Sparx Systems Pty Ltd 143 Stored Procedures 3 8 Stored Procedures What is a Stored Procedure A stored procedure is a group of SQL statements that form a logical unit and perform a particular task Stored procedures are used to encapsulate a set of operations or queries to execute on a database server You can compile and execute stored procedures with different parameters and results and they can have any combination of input output and
55. Diagram 113 Message Element 113 Model 106 Namespace Element 108 Overview Diagram 108 Port Type Diagram 112 Port Type Element 112 Port Type Operation 115 Service Diagram 111 Service Element 111 UML Toolbox Pages 106 Web Services 106 WSDL Support Introduction 106 X XML Import Referenced Schema 102 Technologies Introduction 88 XML Schema 1998 2010 Sparx Systems Pty Ltd 173 Index XML Schema Generate In Garden Of Eden Style 101 UML Profile For XSD 91 XSD 89 XSD Abstract Models 98 Datatype Packages 97 Generate 100 Import 102 Import Global Element Behaviour 104 Model 89 XML Schema 89 XSDany 91 XSDattribute 91 XSDattributeGroup 91 XSDchoice 91 XSDcomplexType 91 XSDelement 91 XSDgroup 91 XSDrestriction 91 XSDschema 91 XSDsequence 91 XSDsimpleType 91 XSDtopLevelAttribute 91 XSDtopLevelElement 91 XSDunion 91 Code Engineering Using UML Models Code Engineering Using UML Models www sparxsystems com
56. Doc LibCheck2 Class C Documents and Settings rchester My Doc Sub Topic 1 Class C Users rchester Documents Sub Topic1 h A In the Synchronize field click on the drop down arrow and select the appropriate synchronize option e Synchronize model and code Classes with existing files are forward synchronized with that file Classes with no existing file are generated to the displayed target file e Overwrite code All selected target files are overwritten forward generated e Do not generate Only selected Classes that do not have an existing file are generated all other Classes are ignored Highlight the Classes to generate Leave unselected any to not generate If you want to display the information in a more readable layout you can resize the dialog and its columns To make Enterprise Architect automatically generate directories and filenames based on the package hierarchy select the Auto Generate Files checkbox This then enables the Root Directory field in which you select a root directory under which the source directories are to be generated By default the Auto Generate Files feature ignores any file paths that are already associated with a Class You can change this behavior by also selecting the Retain Existing File Paths checkbox To include all sub packages in the output select the Include Child Packages checkbox Click on the Generate button to start generating code Code Engineering Using UML Models Generate
57. Foreign Key Name Template 141 Delphi Code Generation 47 Import Reverse Engineering 6 Language Options 47 Limitations 48 Modeling Conventions 78 Properties 48 Designate Driving Triggers Model State Machine For HDL 23 Diagram Data Model Example 122 WSDL Binding 113 WSDL Message 113 WSDL Overview 108 WSDL Port Type 112 WSDL Service WSDL Types Dialog Database Operation Properties Directory Structure Import Reverse Engineering 8 Document WSDL Element DS Element Stored Procedure View 145 WSDL Binding WSDL Message WSDL Namespace WSDL Service 111 WSDL Document 110 WSDL Port Type 112 Enterprise Architect Editor 34 Enterprise Architect Toolbox SystemC Group 81 Verilog Group 84 VHDL Group 85 Establish Port Trigger Mappng Model State Machine For HDL 23 SFe 111 108 136 110 143 113 113 108 Foreign Key Composite 137 Constraint 137 Create 137 Description 137 Name Template Define 141 Representation In Diagram 137 Forward Engineering Introduction 2 Forward Synchronization Code Engineering Using UML Models Index 168 Forward Synchronization Handle Classes Not Found 10 Delete Code From Features In Model 36 Java Reverse Engineering 6 PHP Reverse Engineering 6 G e Python Reverse Engineering 6 Referenced XML Schema 102 Source Code Reverse Engineering 5 10 Garden Of Eden Style Generate 101 Global Element For Global ComplexTypes 100 Global Element In XSD
58. L Import facility is used to reverse engineer WSDL files into UML Class models Note Enterprise Architect cannot import a WSDL file that references WSDL constructs existing outside the target file For example Enterprise Architect can import a WSDL as shown in htto www w3 org TR wsdl html example1 but not a file as shown in http www w3 org TR wsdl html style Attempting to import the second WSDL file would result in the following error message Cannot Import Split Files To avoid this limitation combine the split WSDL files into a single file and then import it into Enterprise Architect To import a WSDL file follow the steps below 1 Inthe Project Browser right click on the package to contain the imported WSDL package The context menu displays 2 Select the Code Engineering Import WSDL menu option The Import WSDL dialog displays ES E cara OnlineBookstore ict oo a 3 Inthe Filename field select the input file 4 The Target Package field is automatically set to the name of the selected input file If required change this name 5 Click on the Import button to import the schema 6 The progress of the WSDL import is shown in the Progress status bar Code Engineering Using UML Models 120 3 Data Modeling p You perform database modeling and database design in Enterprise Architect using the UML Data Modeling Profile This profile provides easy to use and easy to und
59. L Models Code Engineering Settings Set Collection Classes 42 e else use the code language ordered collection 3 Else use the default collection e for the Class if set e else use the code language default collection Note You can include the marker TYPE in the collection name Enterprise Architect replaces this with the name of the Class being collected at source generation time for example Vector lt TYPE gt would become Vector lt foo gt Additionally on both the Source Role and Target Role tabs of the Association Property dialog accessible from the right click context menu of any Association there is a Member Type field If you set this the value you enter overrides all the above options The example below shows a defined PersonList when code is generated because this has a Multiplicity greater than 1 and the Member Type is defined the variable created is of type PersonList General Constraints Source Role Target Role Class6 Role m_PersonList Alias Role Notes A list of staff in order Owned 1 4 6 Language Options You can set up various options for how Enterprise Architect handles a particular language when generating code These options are accessible on the Options dialog select the Tools Options menu option Under the Source Code Engineering option select the required language The following topics outline the options available f
60. Oracle Packages sescsseessessseeeseesseessneesenssseesseeeesnesseeesneesanesseesaueesanedanenseeesaneeanes Primary EE SQL Server Non Clustered KeyS ccsscssecseeseesssesseesseeseeeseeseeeseeseneneeseneseeneesseesensseaseneseeseeesseeneerseaseneneeees 136 O eeina nene cea cc tea sacd ease E Ee 137 Create Foreign E 137 Define Foreign Key Name Template cccssseeceesseeeeessseeeeeseaeeeesseeeeesneeeeeessaeaeenseneesesseaesenseneseesseaeeessaas 141 A A encoetezaenscaasecateceetets EE GEES 143 Create Individual Class Procedure csscccseccsseseeseeeeeeeeeseeeseeeeseeeesnecesneeeseeeneeeseeneeeeeeeseeeseeeseeseeeeeeseee 143 MIS aia 145 Index Trigger Check Constraint csseccceeeeeseeeeseeeeeeeeeesneeeeseeeeseaeseseaeeeeeeeeseaeseseeeeeeeeeeas 147 Generate DDL Fora Table maiirita eaaa a aa aada a cen testee coed i Aana dae NERE 149 Generate DDL for a Package commons 151 Data Type Conversion Procedure csssecceeeceseseeeeeneeeneeeeesnaeeeseeeeseaeseseaesneeeeeseaesaseeeeeeenaess 155 Data Type Conversion for a Package cccsccsssecseeeeeeeeeeesneeenseeeeeeesaseeeeneeeeessesaneeeeeseeeeas 156 DBMS Datatype dee EES 158 Import Database Schema from ODBC s snsssnsssnsununsuunnunnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn annn nnnn nnne anneanne 160 Selecta Data SO CE aiii AA isis 162 Select CT 163 The Imported Class EC 163 Index 165 1998 2010 Sparx Systems Pty Ltd 1 Foreword
61. Properties Oracle E Generate Views Generate Functions E Create Drop SQL F Generate Sequences Use asSQLTerminator Jon the same line Use and around names Generate Table Owner Use Database 7 Use Alias if Available F Use NULL for nullable columns File Generation Single Fie ve Individual file for each table lindude al Chid Packages ShoppingBasket StockItem Transaction Note Alternatively you can select the Project Database Engineering Generate Package DDL menu option Select the checkbox against each inclusion required Deselect the checkboxes for inclusions you do not require 1998 2010 Sparx Systems Pty Ltd 153 Generate DDL for a Package Notes e Some checkboxes display only if the appropriate database is defined for the tables in the package For example IF EXISTS displays only if the database for the tables is PostgreSQL e f generating Oracle sequences you must always select the Generate Triggers and Generate Sequences checkboxes this ensures that a pre insert trigger is generated to select the next sequence value to populate the column Also select the Auto Numbering ab checkbox 130 in the column properties 4 To recursively generate DDL select the Include All Child Packages checkbox 5 Click on the Generate button to proceed Enterprise Architect prompts you for file names as the process executes Compare DDL For a Database When you h
62. Public and Published are supported e f you change the name of a property and forward engineer a new property is added but the old one must 1998 2010 Sparx Systems Pty Ltd 51 Code Engineering Settings Language Options be manually deleted from the source file 1 4 6 7 Java Options Configure options for Java code generation using the Java Specifications page of the Options dialog select the Tools Options Source Code Engineering Java menu option The options you can specify include the e Default file extension e Default Get prefix e Default Set prefix You can also set a default directory for opening and saving Java source code Java Specifications Disable Language E Options for the current model Default Extension java Get Prefix get Set Prefix set Default Collection Class Options for the current user Default Attribute Type int Default Source Directory Editor Collection dass for 1 associations Collection Classes 1 4 6 8 PHP Options Configure options for PHP code generation using the PHP Specifications page of the Options dialog select the Tools Options Source Code Engineering PHP menu option The options you can specify include the e Default source extension specify the extension to be used when creating files for PHP source e Default import extension a semi colon separated list of extensions to look at when doing a directory code import 84 for PHP e De
63. Sequence diagram and all its associated messages and interaction fragments to be encapsulated within an Interaction element see the UML Dictionary During code generation from Interaction Sequence diagrams see the UML Dictionary in a Class Enterprise Architect applies its system engineering graph optimizer to transform the Class constructs into programmatic paradigms Messages and Fragments are identified as one of the several action types based on their functionality and Enterprise Architect uses the EASL code generation templates to render their behavior accordingly For example e A Message that invokes an operation is identified as an Action Call and is rendered accordingly e Combined Fragments are identified by their types and conditions for instance an Alt fragment is identified as an Action If and a loop fragment is identified as an Action Loop For more information on the EASL code generation macros and templates Enterprise Architect uses to generate code from behavioral models see the EASL Code Generation Macros topic in the Code Template Framework in SDK section of SDK for Enterprise Architect aa bVslidUser ret placeOrder arg_iOrderNo iOrderNo return il The above diagram contains e A Combined Fragment alt which is identified as an Action If see the UML Dictionary e An Interaction Occurrence which is identified as an Action Call with all argument information associated with it see the UML Dict
64. The typedef and anonymous tags are not used e The property get property set stereotypes are not used e The Pure property of an operation corresponds to the keyword abstract See Also e Import Source Code 5 e Generate Source Code 124 1 6 6 Delphi Conventions Enterprise Architect supports round trip engineering of Delphi where the following conventions are used Stereotypes ersten CT TT ERR oros nta o CT CE CT CO CE CET sme CE CT Tagged Values Tag Applies To Corresponds To attribute_name Operation with stereotype The name of the variable behind this property property get or property set packed The packed oyword property Class A property See Delphi Properties 487 for more information reintroduce The reintroduce keyword Other Conventions e The Static property of an attribute or operation corresponds to the class keyword e The Fixed property of a parameter corresponds to the const keyword e The value of inout for the Kind property of a parameter corresponds to the Var keyword O 1998 2010 Sparx Systems Pty Ltd 79 Modeling Conventions Delphi Conventions e The value of out for the Kind property of a parameter corresponds to the Out keyword See Also e Import Source Code si e Generate Source Code 124 e Delphi Options 474 1 6 7 Java Conventions Enterprise Architect supports round trip engineering of Java including AspectJ 80 gt extensions where the following conv
65. There are no items to show in this view 1998 2010 Sparx Systems Pty Ltd 155 Data Type Conversion Procedure 3 13 Data Type Conversion Procedure Once a database schema has been set up on an Enterprise Architect diagram either by importing through ODBC or manually setting up the tables the DBMS can be changed to another type and the column datatypes are mapped accordingly To map the DBMS type of a table to another DBMS type follow the steps below 1 Double click on the table element in a diagram to open the table Properties dialog 2 The Database field shows the current DBMS for this table 3 To map the column datatypes to another DBMS select the target from the Database drop down and click on the Apply button 4 The datatypes are converted to match those of the new DBMS and these are reflected in any DDL generated from this table General Table Detail Requirements Constraints Links Scenarios Files Tagged Values Name Account Stereotype Author Code Engineering Using UML Models Data Type Conversion for a Package 156 3 14 Data Type Conversion for a Package The DBMS Package procedure or mapper enables you to convert a package of database tables from one DBMS type to another DBMS type as well as providing the ability to change the ownership of tables To map the DBMS types of a package to another DBMS type follow the
66. To jisGeneric Attribute port The port declaration in a generic interface typedef tnd nto ena ETT mode Jansen repone ou ou eurer ago are Method The sensitivity list of a synchronous process type Inner Class The type indication of a type declaration yp typedef typeNameSpace Attribute part The type namespace of the instantiated component VHDL Toolbox Pages To access the VHDL pages of the Enterprise Architect UML Toolbox select the More tools HDL VHDL Constructs menu option Drag these icons onto a diagram to model a VHDL design C CTN CN VHDL Architecture VHDL Features Entity Enumeration Define an architecture to be associated with a VHDL entity An architecture stereotyped Class element Define a VHDL entity to contain the Port definitions An entity stereotyped interface element Define an Enumerated Type An enumeration stereotyped enumeration element Define a VHDL record A struct stereotyped Class element Define a VHDL type or subtype A typedef stereotyped Class element Define a VHDL Port A port stereotyped attribute Define a VHDL component instantiation A part stereotyped attribute Define a VHDL signal A signal stereotyped attribute Define a VHDL process 1998 2010 Sparx Systems Pty Ltd 87 Modeling Conventions VHDL Conventions e Concurrent e An asynchronous stereotyped method e Sequential e A synchronous stereotyped m
67. a Source To import DDL from existing data sources you must have a suitable ODBC connection installed and configured see UML Model Management From the Import DB Schema from ODBC Source dialog you can select the ODBC data source using the standard windows ODBC set up dialog Click on the data source name and then click on the OK button Data Source Name Type Description dBASE Files User Excel Files User MS Access Database User mysal_help_file_diags System Regression User A Machine Data Source is specific to this machine and cannot be shared User data sources are specific to a user on this machine System data sources can be used by all users on this machine or by a system wide service ok II Ga II hee 1998 2010 Sparx Systems Pty Ltd 163 Import Database Schema from ODBC Select Tables 3 16 2 Select Tables When you have opened the ODBC data source Enterprise Architect acquires a list of tables and stored procedures suitable for importing This is presented in a list form for you to select from Available Objects TABLE t_attribute TABLE t_attributeconstraints TABLE t_attributetag TABLE t_authors TABLE t_cardinality TABLE t_category TABLE t_clients TABLE t_complexitytypes TABLE t_connector TABLE t_connectorconstraint TABLE t_connectortag TABLE t_connectortypes TABLE t_constants TABLE t_constrainttypes TABLE t_datatype
68. ages radio button to list only those packages that have the stereotype XSDschema The list box displays for each package the package name and the file path where the schema file is to be generated 7 If itis necessary to change the file path for a package double click on the entry in the list box and on the Select XML File dialog type or select the appropriate file path 8 Ensure that the checkbox is selected for each package required for generation 9 Click on the Generate button to generate the schema for each of the selected packages 10 The progress of the schema generator is shown in the Progress box 11 When schema generation is complete click on an entry in the list box and click on the View Schema button to review the generated schema Tip The Generate XML Schema dialog can also be accessed from the active diagram by selecting the Project XML Schema Generate XML Schema menu option 2 1 2 1 Generate Global Element Enterprise Architect by default generates XML Schema in the Garden of Eden style For every global XSDcomplexType stereotyped Class Enterprise Architect generates a global element For example the following model by default generates the XSD shown sass Genxsoexameie 7 lt xs element name Contactinfo type Contactinfo gt lt xs complexType name Contactinfo gt e lt xs element name email type xs string minOccurs 1 maxOccurs 1 gt 1 lt xs element name homePhone
69. agram If necessary deselect the checkbox 9 For the Import XSD Elements Attributes as field select the appropriate radio button to import elements and attributes in the XML Schema as e UML Association connectors or e UML Class attributes 10 Click on the Import button to import the schema 11 The progress of the schema import is shown in the Progress status bar Code Engineering Using UML Models XML Schema XSD Import XSD 104 Tip The Import XML Schema dialog can also be accessed for the active diagram by selecting the Project XML Schema Import XML Schema menu option Note Enterprise Architect uses the schemaLocation attribute in the Import and Include elements of an XML Schema to determine the dependencies between the files Ensure that this attribute is set to a valid file path and not a URL for the dependent XML Schema s to be imported correctly 2 1 3 1 Global Element and ComplexType Some XML Schemas have ComplexType elements with the same name as the referring global elements but with the suffix Type as shown below lt xs element name Address type AddressType gt lt xs complexType name AddressType gt lt xs sequence gt lt xs complexType gt On XSD import Enterprise Architect treats this global element and its bounding ComplexType as a single entity and creates a single XSDcomplexType stereotyped Class with the same name as the global element as shown below XSDcomple
70. ard Colors 0 13 Diagram i A Appearance DDL Editor L Behavior Default Database MySql PF Sequence E3 Objects DDL Name Templates 1 Links 2 Communication Colors Internal Source Editor gt XML Specifications 1 43 Source Code Engineering Use inbuilt editor if no external editor set E Show Line Numbers A Object Lifetimes Show Structure Tree Don t parse files larger than Always Parse 2 Click on the DDL Name Templates button The DDL Name Template dialog displays showing the default name templates Foreign Key Name Template FK_ foreigntablename primar ytablename Primary Key Name Template Unique Constraint Name Template 3 Edit or replace the template in the Primary Key Name Template field Note If you want to display the Primary Key description as PK_tablename_columnname then change the Primary Key Name Template field to PK_ tablename _ columnname 4 Click on the Save button Code Engineering Using UML Models Primary Key SQL Server Non Clustered Keys 136 3 6 1 SQL Server Non Clustered Keys To define a primary key as non clustered for a SQL Server table follow the steps below 1 Right click on the table in a diagram to open the context menu 2 Select the Operations menu option The Table Operations dialog displays 3 Highlight the Primary Key Operation and select Extended Properties The Database Operation Properties dialog displays
71. are available for generation under the target packages Only selected highlighted Classes are generated Classes are listed with their target source file CET ATT 1 2 4 Update Package Contents Enterprise Architect enables you to synchronize a directory tree Follow the steps below 1 In the Project Browser right click on the root package of the tree to synchronize The context menu displays 2 Select the Code Engineering Synchronize Package With Code menu option The Synchronize Package Contents dialog displays O 1998 2010 Sparx Systems Pty Ltd 17 Generate Source Code Update Package Contents 1 2 5 Generate or reverse engineer all classes in this package that have a source file specified Update Type a Forward engineer model gt source _ Reverse engineer source gt model Y Include child packages 3 Inthe Update Type panel select the radio button to Forward Engineer or Reverse Engineer the package Classes 4 To include child packages in the synchronization select the Include child packages in generation checkbox 5 Click on the OK button to start Enterprise Architect uses the directory names specified when the project source was first imported generated and updates either the model or the source code depending on the option chosen Namespaces Languages such as Java support package structures or namespaces Enterprise Architect lets you specify a package as a na
72. artDate type xs date gt lt xs element name department type xs string gt 1998 2010 Sparx Systems Pty Ltd 99 XML Schema XSD Model XSD lt xs sequence gt lt xs extension gt lt xs complexContent gt lt xs complexType gt lt xs element name EmployeeRecords type EmployeeRecords gt lt xs complexType name EmployeeRecords gt lt xs sequence gt lt xs element name Employee type Employee minOccurs 0 maxOccurs unbounded gt lt xs sequence gt lt xs complexType gt lt xs element name Contactinfo type ContactInfo gt lt xs complexType name ContactInfo gt lt xs sequence gt lt xs element name homePhone type xs string gt lt xs element name mobilePhone type xs string gt lt xs element name officePhone type xs string gt lt xs element name email type xs string gt lt xs element name streetAddress type xs string gt lt xs sequence gt lt xs complexType gt lt xs schema gt 2 1 1 3 1 Default UML to XSD Mappings The following table describes the default mapping of UML to XSD constructs This set of mappings is useful when defining simple schemas from abstract Class models The defaults are also assumed by the schema generator when generating unstereotyped elements in an abstract model The XML Schema pages of the Enterprise Architect UML Toolbox and UML Profile for XSD override these default mappings through the use of stereotypes and Tag
73. ata topic in UML Model Management 1 4 1 2 Options Code Editors You access the source code editor options via the DDL page of the Options dialog select the Tools Options Source Code Engineering Code Editors menu option They enable you to configure options for Enterprise Architect s internal editor as well as the default editor for DDL scripts You can configure external editors for code languages on each language options page 1998 2010 Sparx Systems Pty Ltd 35 Code Engineering Settings Source Code Engineering S General Ta Standard Colors GC 23 Diagram 8 CA Appesrance DDL Editor ams Behavior Default Database MySql e TA Sequence 33 Objects Links gt Communication Colors Internal Source Editor lt gt XML Specifications Source Code Engineering v Use inbuilt editor if no external editor set E 7 Show Line Numbers A Object Lifetimes d Show Structure Tree Ze Attribute Operations Don t parse files larger than Always Parse v al ActionScript ej c Ce Ce E C P Delphi gp Java ehp PHP D Python Visual Basic VB Net Oy Ada Sc SystemC W Verilog HN VHDL DDL DDL Name Templates am The options for the inbuilt editor are Use inbuilt editor if no Specify the editor for code in a language if no external editor is defined for external editor set that language Show Line Numbers Show line numbers in the editor Show Structure Tree
74. ate a Single Class 13 e Generate a Group of Classes 147 e Generate a Package 191 e Update Package Contents 167 Generate a Single Class To generate code for a single Class first ensure the design of the model element Class or Interface is complete Also ensure you have added Inheritance connectors to parents and associations to other Classes that are used Also add Inheritance connectors to Interfaces that your Class implements Enterprise Architect offers the option to generate function stubs for all interface methods that a Class implements Once the design is satisfactory follow the steps below Generate Code for a Single Class 1 Open the diagram containing the Class or Interface for which to generate code 2 Right click on the required Class or Interface to display the context menu and select the Generate Code menu option or press F11 The Generate Code dialog displays which enables you to control how and where your source code is generated Path Abenchmark Wava Example 1ClassLib java Advanced Target Details arget language men Java v ClassLib Save Close Import s Header s 3 On the Path field click on Browse and select a path name for your source code to be generated to 4 Inthe Target Language field click on the drop down arrow and select the language to generate this becomes the permanent option for that Class so change it back if you are only doing one
75. ath set in the C options 467 When it finds the implementation file it can use it to resolve parameter names and method notes as necessary When importing C source code Enterprise Architect ignores function pointer declarations To import them into your model you could create a typedef to define a function pointer type then declare function pointers using that type Function pointers declared in this way are imported as attributes of the function pointer type Enterprise Architect does not expand macros that have been used these must be added into the internal list of Language Macros 39 CH Appropriate type of source file Ce Delphi Appropriate type of source file pas Java Appropriate type of source file Java Enterprise Architect supports the AspectJ language extensions aspect ThingObserving observers Vector new Vector addObserver Thing Thing void remove Observer Thing ThingObserver void updsteObserver Thing ThingObserver void advice after Thing void pointcut changes Thing void Aspects are modeled using Classes with the stereotype aspect These aspects can then contain attributes and methods as for a normal Class If an intertype attribute or operation is required you can add a tag className with the value being the name of the Class it belongs to Pointcuts are defined as operations with the stereotype of pointcut These can occur in any Java Class Interfa
76. ave changes The example below shows how an index looks in a diagram in the Order element Code Engineering Using UML Models Index Trigger Check Constraint 148 column column addres Age Name varchar 50 Name varchar 50 PK companylD Integer PK customerlD Integer PK PK PK_Compsny integer PK_Customer integer companylD companylD aFK customerlD customeriD FK_Order_Company 0 SIS column Amount FK companylD Integer FK customeriD Integer Pk orderiD Integer PK PK_Order integer FK FK Order Compsnvilntegen FK_Order_Customer integer index DX_Order 1998 2010 Sparx Systems Pty Ltd 149 Generate DDL For a Table 3 11 Generate DDL For a Table Note In the Corporate Business and Software Engineering System Engineering and Ultimate editions of Enterprise Architect if security is enabled you must have Generate Source Code and DDL permission to generate DDL See User Security in UML Models To generate simple DDL scripts to create the tables in your model follow the steps below 1 Inthe diagram right click on the table for which to generate DDL The context menu displays 2 Select the Generate DDL option The Generate DDL dialog displays Path am Options Comment Level Use and as comment
77. ave contributed suggestions examples bug Sparx Systems reports and assistance in the development of Enterprise Architect M ina Edit The task of developing and maintaining this tool has been greatly anagingiEctor enhanced by their contribution Geoffrey Sparks Technical Editors Geoffrey Sparks Simon McNeilly Vimal Kumar Henk Dekker Contents l Table of Contents Foreword 1 Code Engineering 2 Reverse Engineering E 4 Import S rce COMO ii aean E EENS 5 Notes on Source Code IMport scescsssceseseeesseceeeseeseeeseesenennesenesseeneesseeseneseeseneneennessnesesseeseneseesneesseeseerseesene 6 Import a Directory Structure 8 Import Binary Module ccccssseesseeeseeessneeseneeeseeesseesseeeeseessaesssneeseneeseneeseeessnesenneeseaeeasnesseneessnesseneasseesaneess 9 MDG Integration and Code Engineering esssssesseseeeseeseesseeseessessenssenseneseeeeeeseeeseasseesenesenseeesseeeeeteneas 10 Classes Not Found During IMport ccesceesseseeseesseesseseeeneesseesenessessneseesseassesseneseeseneseesneeseeeseeeseesenenentenes 10 Synchronize Model and Code ssscssecsseseesseeseeseeesencnneeseeneeeseesenesnseneseneneeeseasensseesenenensneesseeseeeseesenenensenes 10 Generate Source e TEE 12 Generate a Single Class CSS 13 Generate a Group of Classes 14 Generate a Package EE 15 Update Package Contents EENS een 16 DEGE E 17 Code Generation From Behavioral M
78. ave generated the DDL you can compare it with the database To do this follow the steps below 1 On the Generate Package DDL dialog click on the Compare button The Compare With Database dialog displays Database Name mmm Schema Owner canei ven 2 Click on the button and locate the required database on the Select Data Source dialog 3 For an Oracle database if required you can also specify the Owner in the Schema Owner field 4 Click on the View button to perform the comparison The Comparison Database dialog displays with the results of the comparison Click on each table name to review information on that table Code Engineering Using UML Models Generate DDL for a Package 154 Suggest Action E CREATE TABLE OrderStatus dosed Integer NULL orderSt CREATE TABLE Order date DATE NOT NULL lineItemID In CREATE TABLE LineItem lineItemID Integer NOT NULL qu Account CREATE TABLE Account accountID Integer NOT NULL na DROP TABLE usystables usysqueries DROP TABLE usysqueries usysoldtables l DROP TABLE usysoldtables usys_system l DROP TABLE usys_system 4 T D Compare Current Item Columns ODBC Status Item Datatype Nullable Default Datatype Nullable Default i VARCHAR2 50 NULL Boolean NULL NVARCHAR2 NULL VARCHAR2 50 NULL we Integer NULL order Integer NULL name VARCHAR2 50 NULL PK accountID Integer NOT NULL
79. ble fields you can create connectors between specific attributes in the Class element and the column attributes in the Table element See the Connect to Element Feature topic see the Work With Connectors section of UML Modeling With Enterprise Architect UML Modeling Tool Database Keys Two types of key are used to access tables Primary Keys and Foreign Keys A Primary Key uniquely identifies a record in a table while a Foreign Key accesses data in some other related table via its Primary Key A Primary Key consists of one or more columns a simple Primary Key single column is defined as the attribute of a stereotyped operation A complex Primary Key several columns is defined as the stereotyped operation itself A Foreign Key is a collection of columns attributes that together have some operational meaning they enforce a relationship to a Primary Key in another table Foreign keys are represented in Enterprise Architect as operations with the stereotype FK the operation parameters become the columns involved in the key Supported Databases Enterprise Architect supports import of database schema from these databases e DB2 e Firebird InterBase e Informix e Ingres e MS Access 97 2000 2003 1998 2010 Sparx Systems Pty Ltd 121 e Access 2007 e MS SQL Server 2000 2005 2008 e MySQL e Oracle 9i 10g and 11g e PostgreSQL e Sybase Adaptive Server Anywhere Sybase ASA e Sybase Adaptive Server Ente
80. bles you to Configure the default name generated from imported attributes Generate methods for implemented interfaces Delete model attributes not included in the code during reverse synchronization Delete model methods not included in the code during reverse synchronization Delete code from features contained in the model during forward synchronization Delete model associations and aggregations that correspond to attributes not included in the code during reverse synchronization Define whether or not the bodies of methods are included and saved in the Enterprise Architect model when reverse engineering Create attributes in quick succession clearing the dialog when you click on Save so that you can enter another attribute name These options are accessed via the Attribute Specifications page of the Options dialog select the Tools Options Source Code Engineering Attribute Operations menu option 1998 2010 Sparx Systems Pty Ltd 37 Code Engineering Settings Source Code Engineering Attribute Specifications e Links np Default name for associated attrib m_ LinkClass 2 Communication Colors gt XML Specifications A V On reverse synch delete model attributes not in code 8 ME Source Code Engineering On reverse synch delete model associations not in code Laf Code Editors 2 Object Lifetimes Operation Specifications 4 a ActionS
81. c properties of the binding later by double clicking the binding Class in the diagram or Project Browser Alternatively on the WSDL Binding dialog click on the UMLbutton to invoke the standard Properties dialog for a Class This button does not display on the initial WSDL Binding dialog for a new Binding element 2 2 1 7 WSDL Port Type Operation WSDL portType operations are represented in Enterprise Architect by operations defined as part of a WSDLportType interface see the WSDL Port Type 112 topic To add portType operations to your WSDLportType interfaces follow the steps below 1 Open the Overview diagram defined for your WSDL namespace package and double click on the PortTypes package to open the PortTypes diagram 2 Drag the PortType Operation item onto a WSDLPortType stereotyped interface The WSDL PortType Operation dialog displays Code Engineering Using UML Models Web Services WSDL Model WSDL 116 6 Bridal td Request Response Request SampleInput Type in the Name for the operation Select the Operation Type Type in or select the Input Output and Fault details for the operation The Message drop down list is taken from the WSDLmessage elements defined under the Messages package Click on the OK button to close the WSDL PortType Operation dialog and create the operation You can edit the WSDL specific properties of the portType operation later by double clicki
82. ce or aspect The details of the pointcut are included in the behavior field of the method Advice is defined as an operation with the stereotype advice The pointcut this advice operates on is in the behavior field and acts as part of the method s unique signature After advice can also have one of the Tagged Values returning or throwing PHP Appropriate type of source file php php4 or inc Python Appropriate type of source file DN Visual Basic Appropriate type of source file cls Class file Visual Basic NET Appropriate type of source file vb Class file Code Engineering Using UML Models Reverse Engineering Import a Directory Structure 8 1 1 3 Import a Directory Structure You can import from all source files in a complete directory structure This process enables you to import or synchronize multiple files in a directory tree in one pass Enterprise Architect creates the necessary packages and diagrams during the import process To import a directory structure follow the steps below 1 Inthe Project Browser right click on the target package for the import 2 From the context menu select the Code Engineering Import Source Directory menu option The Import Source Directory dialog displays Root Directory C Java Example Source Type Java X File Extensions java Defined Component Extensions None lacs V Recursively Process Subdirectories O Create Package
83. chronize button of the Arguments dialog to synchronize arguments and parameters The following diagram demonstrates the use of a Call Behavior Action and a Call Operation Action interspersed with a conditional statement E arg_Password Password arg_UserName UserName E NS bValidUser arg_newVal ActivityFinal The generated Java code might appear as follows public void doMarkAccountClosed doValidateUser password name if bValiduser setClosed true System out printin Invalid user return Code Engineering Using UML Models Code Generation From Behavioral Models Code Generation Activity Diagrams 30 Loops Enterprise Architect s system engineering graph optimizer is also capable of analyzing and identifying loops An identified loop is internally rendered as an Action Loop which is translated by the EASL code generation macros to generate the required code The following diagram demonstrates how a loop can be modeled status OrderStstus closed Initialize StateMachine status OrderStstus closed Run StateMachine The generated Java code might appear as follows public void doCheckForOutstandingOrders if status closed initializeStateMachine while status closed runStateMachine 1998 2010 Sparx Systems Pty Ltd 31 Code Generation From Behavioral Models Code Generation
84. ckbox 130 in the column properties 6 To create the DDL click on the Generate button 7 To view the output click on the View button you must configure a DDL viewer in the Local Settings dialog first Note You can transport these DDL scripts between models using the Export Reference Data and Import Reference Data options on the Tools menu See the Reference Data topic in UML Model Management 1998 2010 Sparx Systems Pty Ltd 151 Generate DDL for a Package 3 12 Generate DDL for a Package Note In the Corporate Business and Software Engineering System Engineering and Ultimate editions of Enterprise Architect if security is enabled you must have Generate Source Code and DDL permission to generate DDL See User Security in UML Models In this procedure you can generate DDL for a package and also compare the DDL with the database Generate DDL To generate DDL for a package follow the steps below 1 Right click on the required package in the Project Browser The context menu displays 2 Select the Code Engineering Generate DDL menu option The Generate Package DDL dialog displays Code Engineering Using UML Models Generate DDL for a Package 152 3 Root Package DDL Options Comment eve ue Create Primary Foreign Key Constraints Generate Index Constraints E Generate Triggers E Generate Packages Orade E Generate Stored Procedures E Generate Table
85. cript Y Generate methods for implemented interfaces i CR 4 On reverse synch delete model methods not in code C Include method bodies in model when reverse engineering M Delphi Options p Java hp PHP Y After save re select edited item ee i v On forward synch prompt to delete code features not in model VB Net Ada Sc SystemC Nr Verilog DN VHDL 3 1 4 1 5 Code Page for Source Editing Enterprise Architect enables you to define the Unicode character set for code generation To set the Unicode character set follow the steps below 1 Select the Tools Options Source Code Engineering menu option The Source Code Engineering page of the Options dialog displays Code Engineering Using UML Models Code Engineering Settings Source Code Engineering 38 TUUUS MAC Korean gege A 110004 MAC Arabic te 9 Always synchronize with exis 10005 MAC Hebrew Ey ae gt Replace overwrite existing s 10006 MAC Greek a S 10007 MAC Cyrillic Communication Colors 10008 MAC Simplified Chinese GB 2312 lt gt XML Specifications Default Language for Code G 10010 e S Geessen i ine 03 TS Wrap long comment lines at 40021 MAC Thai cy Aut i 10029 MAC Latin II A Object Lifetimes o Layout Dr o 007 MAC Icelandic Qo Attribute Operations Output files use both CH ALE 10081 MAC Turkish GI ActionScript fs anes
86. ct s generic profile mechanism by downloading the UML Profile for XSD See the Using Profiles topic in Extending UML With Enterprise Architect for details on importing UML profiles into Enterprise Architect The XSD profile used by Enterprise Architect is an adaptation of the profile defined in Modeling XML Applications with UML David Carlson The XSD stereotypes provide an explicit mapping from XSD to UML constructs The Tagged Values further define aspects of the mapping such as whether the elements should be qualified Full information on the Tagged Values can be obtained from the W3C XML Schema recommendation The constraints define any conditions that must be satisfied for the stereotype to apply The following stereotypes are provided e XSDschemal og e XSDcomplexType 9 e XSDsimpleType es e XSDsequence ad e XSDchoicel 947 e XSDelement 9A e XSDattributel 95 co Code Engineering Using UML Models XML Schema XSD Model XSD 92 e XSDanyl 954 e XSDrestriction 95 e XSDgroup 9 e XSDtopLevelElement 9 e XSDtopLevelAttribute og e XSDunion 974 e XSDattributeGroup 97 gt The following tables list the features of the UML Profile for XSD Note Tagged Value names are shown in bold followed by the allowed values If a default value is used by Enterprise Architect s schema generator it is underlined XSDschema UML Package Construct Description All Classes in a
87. d 2 4 tendIf3 File No 5 generic list ClassParameter separator File Impl No 6 tif generic 3 Namespace No 7 generic lt generic gt a Namespace Impl No 8 endIf Namespace Body No 9 classTag annotations 3 Namespace Body Impl No 10 HER i Namespace Declaration No 11 CONVERT_SCOPE classScope Namespace Declaration No 12 tclassStereotype static static 3 Class o 13 tclassIsLeaf I final Class Impl No 14 Class Notes No 15 Sit elemType Interface nn Class Base No 16 SEI f Class Interface No 17 classStereotype annotation ng Class Body No 18 interface tclassName generic bases Class Body Impl No 19 tendTemplate Class Declaration No Class Declaration Impl No 21 classAbstract T 2 abstract 3 4 m r 22 classStereotype enumeration enum class St Ovenid 23 tclassNamet generic bases ereotype Overides Class Feature Modified aspect No Add New Custom Template H m gt Add New Stereotyped Override Get Default Template Save Delete Help 4 eeeStantPag Code Template Editor gt Select the programming language New Language Display the Programming Languages Datatypes dialog see the Reference Data topic in UML Model Management which enables you to include programming languages other than those supported for Enterprise Architect for which to create or edit code templates Template Display the contents of the active template
88. d Class that is a Class element with a stereotype of table applied to it A table icon is shown in the upper right corner of the image when it is shown on a Data Model diagram Create a Table To create a Table follow the steps below 1 Select a diagram 2 Select the More Tools Data Modeling menu option on the Enterprise Architect UML Toolbox 3 Click on the Table element in the list of elements then click on the diagram The Table element is displayed on the diagram column PK InventorylD VARCHAR2 10 FK WarehouselD VARCHAR2 10 CurrentStock NUMBER 8 OnOrder NUMBER S FK FK_Inventory_Warehouse VARCHAR2 PK PK_Inventory VARCHAR2 4 Ifthe Class Table n Properties dialog does not display double click on the Table to display it 5 Inthe Name field type a name for the Table and set any other properties 124 as required 6 Click on the OK button Code Engineering Using UML Models Set Table Properties 124 3 3 Set Table Properties p Once you have created your table you can set its properties Most table properties can be set from the Properties dialog as described below However some properties must be entered as Tagged Values as described for setting the value of the Table Owner 126 and for MySQL 1261 and Oracle 127 databases setting the table options Set the Database Type The most important property to set for a table after its name is the database ty
89. d Scale 10 0 24 DOUBLE Precision and Scale 10 2 53 DOUBLE PRE Precision and Scale 10 2 53 y Datatype Map Close Help You can also map database datatype sizes between products To do this follow the steps below 1 On the Database Datatypes dialog click on the Datatype Map button The Database Datatypes Mapping dialog displays 1998 2010 Sparx Systems Pty Ltd 159 DBMS Datatypes Defined Datatypes for Databases Product Datatype Size Unit In the From Product Name field click on the drop down arrow and select the DBMS product to map datatypes from The Defined Datatypes for Databases panel displays all the defined datatypes for the product and where appropriate their sizes and values Click on the datatype to map this must have a defined size unit and value The Datatype and Common type fields under the From Product Name field display this datatype In the To Product Name field click on the drop down arrow and select the DBMS product to map datatypes to The Datatype and Common Type fields under this field display the corresponding values to those in the fields for the from product In the Size panel click on the radio button for the appropriate size unit and type the default values in the corresponding data fields Click on the Save button to save the mapping To map further datatypes repeat this process from step 3 When you
90. d features supported by Enterprise Architect e WSDL Namespace t08 e WSDL Document 11h e WSDL Service 114 e WSDL Port Type h e WSDL Message 115 e WSDL Binding 11h e WSDL Port Type Operation 115 Code Engineering Using UML Models Web Services WSDL Model WSDL 108 e WSDL Message Partl116 2 2 1 1 WSDL Namespace The WSDL namespace in Enterprise Architect represents the top level container for the WSDL elements including WSDL documents Conceptually it maps to the targetNamespace in a WSDL definition element A given WSDL namespace can reuse its schema Types Messages Port Types Bindings and Service across multiple physical WSDL documents The figure below shows an example WSDL namespace OnlineBookstore PSM which has a red margin to the bottom right corner including a single WSDL document 3 OnlineBookstore PSM i OnlineBookstore TA OnlineBookstore o Y Types 2 Types Address Cart Cartitem Id Invoice Price Searchparams Stockitem E Stockitemlist Url Messages VS Messages CartAddltemRequest CartAddltemResponse CartCheckoutRequest CartCheckoutResponse CartCreateRequest CartCreateResponse StockltemDetailsRequest StockltemDetailsResponse StockltemPriceRequest p900 0 0 0 0 0 0 8 Wi Ej StockltemPriceResponse E StockltemSearchRequest StockltemSearchResponse E PortTypes TA PortTypes 9 OnlineBookstoreServices E Bindings TA Bindings E OnlineBookstoreSer
91. da 2005 Ada 2005 support is available in the System Engineering and Ultimate editions of Enterprise Architect Enterprise Architect supports round trip engineering of Ada 2005 where the following conventions are used Code Engineering Using UML Models Modeling Conventions Ada 2005 70 Stereotypes Stereotype Applies To Corresponds To adaPackage Class A package specification in Ada 2005 without a tagged record typedef Inner Class A type definition subtype definition access type definition renaming Tagged Values Applies To Corresponds To Discriminant Inner Class with stereotype typedef The type s discriminant Parameter Determination of whether the parameter is an access variable InstantiatedUnitTy Inner Class with stereotype typedef The instantiated unit s type Package pe Procedure Function PartType Inner Class with stereotype typedef The part type renames or new Inner Class with stereotype typedef If Value SubType set subtype If Value Access set access type Other Conventions e Appropriate type of source files Ada specification file ads e Ada 2005 ae defined as either lt lt adaPackage gt gt Class or Class based on the settings in the Ada options 437 e A package in the Ada specification file is imported as a Class if it contains a Tagged Record the name of which is governed by the options Use Class Name for Tagged Record and Alternate Tagged Record
92. definition The code editor provides intellisense for basic SQL keywords and functions see Using Enterprise Architect UML Modeling Too 4 Click on the OK button to save your definition The View definition and certain other parameters are held as Tagged Values The View definition is held in the viewdef memo Tagged Value as shown in the following example diagram You can select and view the viewdef Tagged Value in the Tagged Values window and include it in RTF reports by inserting the valueOf viewdef field in the Package Element or Element Tagged Values sections see Report Creation in UML Models Code Engineering Using UML Models Views 146 column PK categorylD int CategoryName nvarchar 15 Description ntext Picture image PK PK_Cstegories int index categorylD categorylD FK column PK productiD int ProductNsme nvarchar 40 FK supplierlD int FK categorylD int QuantityPerUnit nvarchar 20 UnitPrice money 0 UnitsinStock smallint 0 UnitsOnOrder smallint 0 ReorderLevel smallint 0 Discontinued bit 0 PK PK_Product int index CategoriesProducts int Categories D int ProductName nvarchar SupplierlD int SuppliersProducts int check CK_ReorderLevel CK_Products_UnitPrice CK_UnitsinStock CK_UnitsOnOrder FK FK_Product_Categories int FK_Product_Supplier int
93. dialog displays 1998 2010 Sparx Systems Pty Ltd 103 XML Schema XSD Import XSD Root Package ClassLibrary1 Directory Selected File s Import Options E Import global elements with Type postfix Import XSD Elements Attributes as V Import referenced XML Schema s 9 UML Associations Y Create Diagram for XML Schema s UML Attributes Progress 3 Inthe Directory field click on the Browse button The Select XML Schema s dialog displays 4 Click on the required input file To select several individual files press Ctrl as you click on each one To select a range of files press Shift and click on the first and last file in the range 5 Click on the Open button to return to the Import XML Schema dialog which now shows the selected files in the Selected File s field 6 The Import global elements with Type postfix 10 checkbox defaults to unselected to import a global element and the ComplexType to which it refers as a single ComplexType Class 7 The Import referenced XML Schema s checkbox defaults to selected to import any other Schema file referenced by the selected input XML Schema file or files Note If an XML Schema file being imported already exists in the model Enterprise Architect skips importing the file 8 The Create Diagram for XML Schema s checkbox defaults to selected to display the imported elements on the di
94. e string homePhone string gender string mobilePhone string surNsme string officePhone string streetAddress string enumeration Status Full Time Part Time Casual Contract department string jobT tle string statDate Date ststus Ststus The following schema fragment would be generated by Enterprise Architect given the above model lt xml version 1 0 gt lt xs schema xmins xs http www w3 org 2001 XMLSchema gt lt xs simpleType name Status gt lt xs restriction base xs string gt lt xs enumeration value Full Time gt lt xs enumeration value Part Time gt lt xs enumeration value Casual gt lt xs enumeration value Contract gt lt xs restriction gt lt xs simpleType gt lt xs element name Person type Person gt lt xs complexType name Person gt lt xs sequence gt lt xs element name firstName type xs string gt lt xs element name surName type xs string gt lt xs element name birthDate type xs string gt lt xs element name gender type xs string gt lt xs element name contactDetails type ContactInfo gt lt xs sequence gt lt xs complexType gt lt xs element name Employee type Employee gt lt xs complexType name Employee gt lt xs complexContent gt lt xs extension base Person gt lt xs sequence gt lt xs element name status type Status gt lt xs element name jobTitle type xs string gt lt xs element name st
95. e Source Code 12 1 2 Generate Source Code UML als z gt le C yan Cz P y A PHP Generating source code forward engineering takes the UML Class or Interface model elements and creates a source code equivalent for future elaboration and compilation By forward engineering code from the model the mundane work involved with having to key in Classes and attributes and methods is avoided and symmetry between model and code is ensured Code is generated from Class or Interface model elements so you must create the required Class and Interface elements to generate from Add attributes which become variables and operations which become methods Before you generate code you should ensure the default settings for code generation match your requirements The default generation settings are located in the Source Code Engineering page of the Options dialog select the Tools Options Source Code Engineering menu option Set up the defaults to match your required language and preferences Preferences that you can define include default constructors and destructors methods for interfaces and the Unicode options for created languages Languages such as Java support namespaces 1 and can be configured to specify a namespace root In addition to the default settings for generating code Enterprise Architect supports the following code languages with their own specific code generation options e ActionScript 434 e CA e Cit
96. e named XSDDatatypes To import the XSDDatatypes package into your model follow the steps below 1 Download the XSDDatatypes package using the following link XSDDatatypes Package The file XSDDataTypes xmlis an XMI file 2 Use Enterprise Architect s XMI import facility which is available via the Project Import Export Import Package from XMI menu option See the Import XMI topic in UML Model Management 3 When the XMI import is complete you have the UML package named XSDDatatypes in your model from which you can drag and drop the relevant types as required Code Engineering Using UML Models XML Schema XSD Model XSD 98 2 1 1 3 Abstract XSD models XML schemas can be modeled using simple abstract Class models This can be useful in enabling an architect to start work at a higher level of abstraction without concern for the implementation details of a schema Such an abstract model can be refined further using the XML Schema pages of the Enterprise Architect UML Toolbox see Using Enterprise Architect UML Modeling Tool or it can be generated directly by Enterprise Architect s schema generator 100 In this case a set of default mappings og is assumed by the schema generator to convert the abstract model to an XSD file The following is a simplified version of the Employee Details example model which does not use XSD specific stereotypes or Tagged Values birthDste string email string firstNam
97. e of the selected package in the Source Package field Source alee ClassLibrary2 Encoding 150 8859 1 XSD Style Referenced Package Options V Generate global element for all V Generate XSD for Referenced packages global Complex Types E Prompt when missing Filename Child Package Options V Generate XSD for Child packages Include all packages Include lt XSDschema gt packages Package Filename Y ClassLibrary2 Classlib Schema xsd 1998 2010 Sparx Systems Pty Ltd 101 XML Schema XSD Generate XSD 3 Inthe Encoding field set the required XML encoding 4 Inthe XSD Style panel the Generate global element for all global ComplexTypes checkbox is selected by default to generate schema in the Garden of Eden style 10h 5 Inthe Referenced Package Options panel select the e Generate XSD for Referenced packages checkbox to generate schema for packages that are referenced by any of the packages selected in the list box e Prompt when missing Filename checkbox to enable Enterprise Architect to prompt for a filename for a referenced package during schema generation if the filename is missing 6 Inthe Child Package Options panel select the e Generate XSD for Child Packages checkbox to generate schema for child packages of the selected package e Include all packages radio button to list all child packages under the parent package in the list box e Include lt XSDschema gt pack
98. e package and double click on the PortTypes package to open the PortTypes diagram 2 Drag the Port Type element from the Toolbox onto the diagram The WSDL PortType dialog displays Name amplePortT ypeHTTP Documentation B Z j A K V ee x x A 3 Type in the name for the portType 4 Click on the OK button to close the WSDL PortType dialog 5 Define operations for the portType by dragging the Port Type Operation 115 item from the WSDL page of the Enterprise Architect UML Toolbox onto the portType interface 1998 2010 Sparx Systems Pty Ltd 113 Web Services WSDL Model WSDL You can edit the WSDL specific properties of the portType later by double clicking the interface in the diagram or Project Browser Alternatively in the WSDL PortType dialog click on the UML button to invoke the standard Properties dialog for an interface This button does not display on the initial WSDL PortType dialog for a new PortType element 2 2 1 5 WSDL Message WSDL messages are represented in Enterprise Architect by UML Classes stereotyped as WSDLmessage Messages should be defined under the Messages package in the WSDL namespace structure To define new WSDLmessage elements for your namespace follow the steps below 1 Open the Overview diagram defined for your WSDL namespace package and double click on the Messages package to open the Messages diagram 2 Drag the Message element from the Toolbox on
99. ec is defined as a C macro as outlined above the imported Class and operation contain a Tagged Value called Dec Macro1 with value dec ispec Subsequent macros would be defined as Dec Macro2 DeclMacro3 and so on During forward engineering these Tagged Values are used to regenerate the macros in code int __ declspec Bar int p Define Complex Macros It is sometimes useful to define rules for complex macros that can span multiple lines Enterprise Architect ignores the entire code section defined by the rule Such macros can be defined in Enterprise Architect as in the following two examples Both types can be combined in one definition Block Macros BEGIN_INTERFACE_PART END_INTERFACE_PART where the symbol represents the body of the macro This enables skipping from one macro to another Note The spaces surrounding the symbol are required Function Macros RTTI_EMULATION O 1998 2010 Sparx Systems Pty Ltd 41 Code Engineering Settings Language Macros where Enterprise Architect skips over the token including everything inside the parentheses 1 4 5 Set Collection Classes Enterprise Architect enables you to define Collection Classes for generating code from Association connectors where the target role has a multiplicity setting greater than 1 There are two options for doing this ile On the Source Code Engineering section of the Options dialog select the Tools Options Source
100. ect UML Modeling Tool can be used to conveniently model WSDL documents WSDL documents are represented as components marked with the stereotype WSDL WSDL documents are contained in a package hierarchy representing the target WSDL namespace and its constituent XSD Types Messages PortTypes Bindings and Services The top level package is stereotyped as a WSDLnamespace The figure below shows a WSDL namespace package structure 1998 2010 Sparx Systems Pty Ltd 107 Web Services WSDL Model WSDL 3 OnlineBookstore PSM 5 C OnlineBookstore VS OnlineBookstore ce Types TA Types Address Cart Cartitem Id Invoice Price Searchparams Stockitem Stockitemlist Url Messages TA Messages CartAddltemRequest CartAddltemResponse CartCheckoutRequest CartCheckoutResponse CartCreateRequest CartCreateResponse StockltemDetailsRequest E StockltemDetailsResponse StockltemPriceRequest StockltemPriceResponse StockltemSearchRequest StockltemSearchResponse a J PortTypes TA PortTypes 9 OnlineBookstoreServices 4 Bindings TA Bindings E OnlineBookstoreServices E CJ Services VS Services 9 OnlineBookstore Ej OnlineBookstore p9 0 0 0 0 0 0 0 8 0 Wi H A m A WSDLnamespace package can contain one or more WSDL components Each WSDL component can be automatically generated to a WSDL file using Enterprise Architect s built in WSDL oeneraior 7 The following topics describe the various WSDL elements an
101. ection in the source code differs from the result generated by the corresponding template that section is replaced Consider for example the following C Class declaration asm class A public B Now assume you add an inheritance relationship from Class A to Class C the entire Class declaration would be replaced with something like asm class A public B public C 1 5 3 2 Add New Sections The following can be added as new sections to existing features in the source code e Class Notes e Attribute Notes e Operation Notes e Operation Notes Impl e Operation Body e Operation Body Impl Assume Class A from the previous example had no note when you originally generated the code Now assume that you specify a note in the model for Class A Enterprise Architect attempts to add the new note from the model during synchronization It does this by executing the Class Notes template To make room for the new section to be inserted you can specify how much white space to append to the section via synchronization macros These macros are described in SDK for Enterprise Architect 1 5 3 3 Add New Features and Elements The following features and elements can be added to the source code during synchronization e Attributes e Inner Classes e Operations These are added by executing the relevant templates for each new element or feature in the model Enterprise Architect attempts to preserve the appropriate indenting of new features i
102. elies on a native Windows program called ldasm exe which is a tool provided with the MS Net SDK The SDK can be downloaded from the Microsoft website A choice of import methods is available because some files are not compatible with reflection such as mscorlib dll and can only be opened using the disassembler However the reflection based importer is generally much faster You can also configure e Whether to Synchronize or Overwrite existing Classes when found if a model Class is found matching the one in the file Synchronize updates the model Class to include the details from the one in the file which preserves information not represented in the file such as the location of Classes in diagrams Overwrite deletes the model Class and generates a new one from the file which deletes and does not replace the additional information e Whether to create a diagram for each package e What is shown on diagrams created by the import Code Engineering Using UML Models Reverse Engineering MDG Integration and Code Engineering 10 1 1 5 MDG Integration and Code Engineering MDG Integration for Eclipse and MDG Integration for Visual Studio are standalone products that provide an enhanced code engineering functionality between Enterprise Architect and the development environments The MDG Integration programs provide a lightweight bridge between Enterprise Architect and the development environment offering enhanced code gen
103. ema XSD Model XSD li This Class can inherit from only one XSDsimpleType Class XSDunion UML Class Construct Description Creates an lt xs union gt construct which can act as a container for XSDsimpleType Class Tagged None Values Constraints An XSDunion Class can contain only XSDsimpleType as its child Class and can generalize from other XSDsimpleType Classes only All the Classes that this Class generalizes become the members of the attribute memberTypes This Class cannot have any attributes or associations XSDattributeGroup UML Class Construct Description Creates an lt XSDattributeGroup gt construct which can act as a container for a set of elements for stereotype XSDattribute Tagged None Values Constraints An XSDattributeGroup Class can contain only elements of stereotype XSDattribute and can be associated only with other XSDattributeGroup Classes Only XSDcomplexType Classes can associate with this Class This Class cannot be inherited 2 1 1 2 XSD Datatypes Package When modeling XSD constructs it is often useful to have the XSD primitive types represented as UML elements In this way user defined types for example can reference the datatype elements as part of inheritance or association relationships Sparx Systems provides the set of primitive XSD data types as a UML package in the form of an XMI file Each of the XSD primitive types is represented by a UML Class in a packag
104. enerating and importing code Enterprise Architect provides the option to synchronize the model and source code creating a model that represents the latest changes in the source code and vice versa You can use either the model as the source or the code as the source For example you generated some source code but made subsequent changes to the model When you generate code again Enterprise Architect adds any new attributes or methods to the existing source code leaving intact what already exists This means developers can work on the source code and then generate additional methods as required from the model without having their code overwritten or destroyed 1998 2010 Sparx Systems Pty Ltd 11 Reverse Engineering Synchronize Model and Code Note Code synchronization does not change method bodies Behavioral code generation 19 only works when generating the entire file Similarly you might have made changes to a source code file but the model has detailed notes and characteristics you do not want to lose By synchronizing from the source code into the model you import additional attributes and methods but do not change other model elements Using the two synchronization methods above it is simple to keep source code and model elements up to date and synchronized Note In the Corporate Business and Software Engineering System Engineering and Ultimate editions of Enterprise Architect if security is e
105. ent user Default Attribute Type Integer Default Source Directory Editor Colection dass fr 1 associations You should also set Delphi properties 48 within each Class element 1 4 6 6 1 Delphi Properties Enterprise Architect has comprehensive support for Delphi properties These are implemented as Tagged Values with a specialized property editor to help create and modify Class properties The Class image below illustrates the appearance of a Delphi Class that has had properties added to it These are stored as Tagged Values and by using the Feature Visibility element context menu option you can display the tags compartment that contains the properties Imported Delphi Classes with properties have this feature automatically made visible for your convenience Show Element Compartments Responsibilities Inherited Responsibilities Tags Inherited Tags Fully Qualified Tags Coanetrainte Note When you use the Create Property dialog from the Attribute screen Enterprise Architect generates a pair of Get and Set functions together with the required property definition as Tagged Values You can manually edit these Tagged Values if required 1998 2010 Sparx Systems Pty Ltd 49 Code Engineering Settings Language Options FTestField Integer m_Name String property get GetName String property set SetN ame String void PrivateProcedure Test Integer function
106. entions are used Stereotypes Stereotype Applies To Corresponds To Attributes within a Class stereotyped An enumerated option distinguished from enumeration other attributes that have no stereotype ame foson CTN Tagged Values Applies To Corresponds To Anything The annotations on the current code feature Attribute with stereotype enum The arguments that apply to this enumerated value attribute_name Operation with stereotype property get or The name of the variable behind this property set property Class or Interface The dynamic keyword parameterList A parameter list with the syntax The exceptions that are thrown by this e Joren angie tat ae row ie transient Attribute The transient keyword Other Conventions e Package statements are generated when the current package is not a namespace root 17 e The Const property of an attribute or operation corresponds to the final keyword e The Transient property of an attribute corresponds to the volatile keyword e The Fixed property of a parameter corresponds to the final keyword Code Engineering Using UML Models Modeling Conventions Java Conventions 80 See Also e Import Source Code 5 e Generate Source Code 124 e Java Options 514 1 6 7 1 AspectJ Conventions The following are the conventions used for supporting AspectJ extensions to Java Stereotypes Stereotype Applies To Corresponds To Tagged Values Applies To Corres
107. eration reverse engineering and synchronization between code and the UML model Merging changes can be achieved with minimal effort and navigation between model and source code is significantly enhanced A trial version of MDG Integration for Eclipse can be downloaded from www sparxsystems com products mdg int eclipse index html and MDG Integration for Visual Studio can be downloaded from www sparxsystems com products mdg int vs index html 1 1 6 Classes Not Found During Import When reverse synchronizing from your code there are times when some Classes might be deliberately removed from your source code Enterprise Architect s import source directory functionality keeps track of the Classes it expects to synchronize with and on the Import Directory Structure dialog provides options for how to handle the Classes that weren t found You can select the appropriate action so that at the end of the import Enterprise Architect either ignores the missing Classes automatically deletes them or prompts you to handle them If you select the Prompt For Action 8 radio button on the Import Directory Structure dialog to manually review missing Classes the following dialog displays Name Action SE Se CartID Delete e Delete CartAddItem Delete i By default all Classes are marked for deletion To keep one or more Classes select them and click on the Ignore button 1 1 7 Synchronize Model and Code In addition to g
108. ernatively right click on the namespace to display a context menu and select the Locate Package in Browser menu option li aan Locate Package in Browser Development Model Work WSDLPackage1 Model Locking Model System Model lmplementation Model PSM C Model 4 1 e You can also clear the selected namespace by selecting the Clear Namespace Attribute option 1998 2010 Sparx Systems Pty Ltd 19 Code Generation From Behavioral Models 1 3 Code Generation From Behavioral Models 1 3 1 ON C jas Cz GE PHP Notes e Software code generation from behavioral models is available in the Business and Software Engineering Systems Engineering and Ultimate editions of Enterprise Architect e Hardware code generation from State Machine models is available in the Systems Engineering and Ultimate editions of Enterprise Architect For C OO please ensure that on the C Specifications page of the Options dialog you have set the Object Oriented Support option to True To be able to generate code from behavioral models all behavioral constructs should be contained within a Class Enterprise Architect s system engineering capability facilitates code generation from each of the following UML behavioral diagrams e State Machine diagrams 19 SW amp HW e Interaction Sequence diagrams 26 SW e Activity diagrams 2A SW You can generate code in various software and hard
109. erprise Architect enables you to import existing source code from a variety of code languages into a UML model Existing source code structures are mapped into their UML representations for example a Java Class is mapped into a UML Class element with the variables being defined as attributes methods are modeled as operations and the interactions between the Java Classes being displayed in the UML model Class diagram with the appropriate connectors Reverse Engineering enables users to examine legacy code and examine the functionality of code libraries for reuse or to bring the UML model up to date with the code that has been developed as part of a process called synchronization Examining the code in a UML model enables user to identify the critical modules contained the code enabling a starting point for understanding of the business and system requirements of the pre existing system and to enable the developers to gain a better overall understanding of the source code To begin the process of importing existing code into Enterprise Architect an existing source of code must be imported into Enterprise Architect 55 which can be a single directory or a directory structure 8 Several options are available when performing the reverse engineering process The Source Code Engineering Options 3 topic contains several options that affect the reverse engineering process These include e f comments are reverse engineered into notes fields and how the
110. erstand extensions to the UML standard mapping the database concepts of tables and relationships onto the UML concepts of Classes and associations These extensions also enable you to model database keys triggers constraints RI and other relational database features Note The UML Data Modeling Profile is not currently a ratified standard however it has wide industry support and is a useful method for bridging the gap between the UML and conventional relational database modeling Typical data modeling tasks you might perform are listed at the end of this topic Tables and Columns The basic modeling structure of a relational database is the table which represents a set of records or rows with the same structure The basic organizational element of a relational database is the column Every individual item of data entered into a relational database is represented by a value in a column of a row in a table The UML Data Modeling Profile represents e Tables as stereotyped Classes that is Class elements with a stereotype of table e Columns as stereotyped attributes that is attributes with a stereotype of column Enterprise Architect can generate simple DDL scripts to create the tables in your model You can also perform Model Driven Architecture MDA Transformations to DDL Enterprise Architect provides a template specifically for DDL transformations see the MDA Transformations User Guide To help you map Class attributes to Ta
111. es 46 Import Reverse Engineering 6 Language Options 46 Modeling Conventions 75 Modeling Conventions CLI Extensions 77 Modeling Conventions Managed 76 Check Constraint Create 147 What Is A 147 Class Collection Set 41 Elements Imported 163 Partial 73 Partial Generate 15 Reset Options 59 Source Code Generation 12 CLI Extensions C Modeling Conventions 77 Code Delete From Features In Model In Fwd Synchronization 36 Generated From State Machine 20 Synchronize 66 Code Engineering And MDG Integration 10 Code Reverse Engineer 4 Eclipse 10 Generate Code For Single Class 13 Generate Group of Classes 14 Generate Package 15 Generate Package Source Code 15 Generate Source Code 12 Introduction 2 Namespaces 17 Package Contents Update 16 Referenced XML Schema 102 Reverse Engineer Source Code 4 Settings 32 Settings Attribute Operation Options 36 Settings Code Generation Constructor Destructor Options 35 Settings Code Page for Source Editing 37 Code Engineering Using UML Models Index 166 Code Engineering Settings General Code Options 32 Settings Import Component Types 33 Settings Source Code Options 32 Synchronization 4 Synchronize Model And Code 10 Synchronize Package Tree 16 UML Profile For XSD 91 Update Package Contents 16 Visual Studio 10 XML Schema 89 XML Schema XSD Default UML To XSD Mappings 99 XML Schema Abstract XSD Models 98 XML Schema Generate XSD 100 XML Schema Impo
112. ethod e Configuration e A configuration stereotyped method See Also e Import Source Code si e Generate Source Codel 124 e VHDL Language Options 567 1 6 14 Visual Basic Conventions Enterprise Architect supports the round trip engineering of Visual Basic 5 and 6 where the following conventions are used Visual Basic Net 837 is supported as a different language Stereotypes Stereotype Applies To Corresponds To global Attribute The Global keyword rr library sam CECI TT Tagged Values Applies To Corresponds To Alias Operation with stereotype import The alias for this imported operation attribute name Operation with stereotype property get The name of the variable behind this property property set or property let Operation with stereotype import The library this import comes from New Attribute The New keyword Other Conventions e The value of in for the Kind property of a parameter corresponds to the ByVal keyword e The value of inout or out for the Kind property of a parameter corresponds to the ByRef keyword See Also e Import Source Code 5 e Generate Source Code 124 e Visual Basic Options 577 Code Engineering Using UML Models 2 XML Technologies Enterprise Architect enables rapid modeling forward engineering and reverse engineering of two key W3C XML technologies e XML Schema XSD e Web Service Definition Language WSDL XSD and WSDL support is c
113. ey checkbox and click on the Save button A stereotyped operation is automatically created It is this operation that defines the Primary Key for the table To remove a Primary Key simply delete this operation Define a Complex Primary Key Often a Primary Key consists of more than one column For example a column LastName might not be unique within a table so a Primary Key is created from the LastName FirstName and DateOfBirth columns Perform the following steps to create a complex Primary Key Follow the steps above to create a Simple Primary Key It doesn t matter which column you choose Right click on the table in a diagram to open the context menu Select the Operations menu option Select the Primary Key operation its name begins with PK_ and then click on the Column tab To add a column to the Primary Key click on the New button select a column from the Column Name list box and then click on the Save button ONS 5 Click on the Hand buttons up and down arrow to change the order of columns in the Primary Key if necessary See also the SQL Server Non Clustered Primary Keys 136 topic Define a Primary Key Name Template To define the name template for a Primary Key follow the steps below 1 Select the Tools Options Source Code Engineering Code Editors menu option The DDL page of the Options dialog displays 1998 2010 Sparx Systems Pty Ltd 135 Primary Key Eh General Stand
114. fault PHP version the version of PHP to generate You can also set a default directory for opening and saving PHP source code Code Engineering Using UML Models Code Engineering Settings Language Options 52 7 Disable Language E Options for the current model Default Version 4 0 Default Extension php Get Prefix get Set Prefix set Options for the current user Default Source Directory Import File Extensions php php4 inc Editor Collection class for 1 associations Collection Classes 1 4 6 9 Python Options Configure options for Python code generation using the Python Specifications page of the Options dialog select the Tools Options Source Code Engineering Python menu option The options you can specify include the e Default file extension s e Default source directory You can also set the editor for Python code 1998 2010 Sparx Systems Pty Ltd 53 Code Engineering Settings Language Options Python Specifications Disable Language E Options for the current model Default Extension py E Options for the current user Default Source Directory Editor Collection dass for 1 associations Collection Classes 1 4 6 10 SystemC Options Configure options for SystemC code generation using the SystemC page of the Options dialog select the Tools Options Source Code Engineering SystemC menu option The options you can specify include the e Default file extensi
115. follow the steps below 1 Locate the required Tables in a diagram Both tables must have defined database types 1251 2 Select an Associate connector in the Class Relationships page of the Enterprise Architect UML Toolbox 3 Click on the Table to contain the Foreign Key source and draw the connector to the other Table target 4 Right click on the connector to display the context menu and select the Foreign Keys option The Foreign Key Constraint dialog displays Code Engineering Using UML Models Foreign Key Create Foreign Key 138 Name FK_Inventory_Warehouse Source Inventory Target Warehouse Key Column Type Key Column Type PK InventoryID VARCHAR2 PK WarehouseID VARCHAR2 WarehouseID VARCHAR2 Location VARCHAR2 CurrentStock NUMBER Capacity NUMBER OnOrder NUMBER Source Des v Target 1 v Referential Integrity Delete Cascade Delete Column Type Column Type d m Li 4 m J gt 5 The default foreign key name is set by the Foreign Key Name Template To change the name to something other than the default provided by the template select the Override Template checkbox and edit the foreign key name 6 Highlight the columns involved in the Foreign Key relationship 7 Click on the Save button to automatically generate the Foreign Key operations You have created the Foreign Key The example below shows how this looks in a diagram 1998 20
116. formation is ignored in the case of Java the two import text boxes are merged and in the case of C the first import text area is placed in the header file and the second in the body cpp file Click on the Generate button to create the source code When complete click on the View button to see what has been generated Note that you should set up your default viewer editor for each language type first see the Source Code Viewer topic in Using Enterprise Architect UML Modeling Tool You can also set up the default editor on the DDL page of the Options dialog Tools Options Source Code Engineering Code Editors 1 2 2 Generate a Group of Classes In addition to being able to generate code for an individual Class you can also select a group of Classes for batch code generation When you do this you accept all the default code generation options for each Class in the set To Generate Multiple Classes 1 2 3 Select a group of Classes and or interfaces in a diagram Right click on an element in the group to display the context menu Select the Code Generation Generate Selected elements menu option The Save As dialog displays on which you specify the file path and name for each code file Enter this information and click on the Save button The Batch Generation dialog displays showing the status of the process as it executes the process might be too fast to see this dialog O 1998 2010 Sparx Systems Pty Ltd
117. g maxOccurs 1 gt lt xs element name contactDetails type ContactInfo gt lt xs sequence gt lt xs attribute name gender use optional type Gender gt lt xs complexType gt lt xs element name EmployeeRecords type EmployeeRecords gt lt xs complexType name EmployeeRecords gt lt xs all gt lt xs element name Employee type Employee gt lt xs all gt lt xs complexType gt lt xs simpleType name Status gt lt xs restriction base xs string gt lt xs enumeration value Full Time gt lt xs enumeration value Part Time gt lt xs enumeration value Casual gt lt xs enumeration value Contract gt lt xs restriction gt lt xs simpleType gt lt xs schema gt The following topics provide further explanation e UML Profile for XSD ot e XSD Datatypes Packagel 977 e Abstract XSD Models og 2 1 1 1 UML Profile for XSD The UML Profile for XSD specifies a set of stereotypes Tagged Values and constraints that can be applied to the UML model in order to change particular aspects of the resulting schema For example you might have to convert certain UML Class attributes to XSD attributes or use a model group other than the default Sequence Enterprise Architect provides native support for the UML Profile for XSD via the XML schema pages of the Enterprise Architect UML Toolbox see Using Enterprise Architect UML Modeling Tool Alternatively you can use the profile via Enterprise Archite
118. g 72 C 75 C Managed 76 C CLI Extensions 77 Delphi 78 Java 79 Java AspectJ Extensions 80 Object Oriented Programming in C 72 PHP 80 Python 81 SystemC 81 VB Net 83 Verilog 84 VHDL 85 Visual Basic 87 MySQL Table Type Set 126 N Name Template Foreign Key 141 Primary Key 134 Namespace Clear 17 Dialog 17 Explanation 17 List 17 Locate In Project Browser 17 Root 17 Set 17 WSDL Element 108 New Code Sections Add To Existing Features 67 Code Engineering Using UML Models Index 170 0 Object Oriented Programming C Code Generation For UML Model 72 Limitations 72 ODBC Data Modeling 149 ODBC Data Source Select 162 ODBC Source Select Stored Procedures From 163 Select Tables From 163 Operation WSDL Port Type Operation 115 Options Reset For A Class 59 Options Dialog ActionScript 43 Ada 2005 43 Attribute Operation Specifications 36 C 44 C 45 C 46 Delphi 47 Java 51 MDG Technology 58 PHP 51 Python 52 SystemC 53 VB NET 54 Verilog 55 VHDL 56 Visual Basic 57 Oracle Package Create 133 Sequence 130 Sequence Options DDL For Packages 151 Sequence Options DDL For Table 149 Tables Set Properties 127 Tables Tagged Values 127 Temporary Table 127 P Package Body For Oracle 133 Create Oracle Packages 133 Specification For Oracle 133 Synchronize Contents 16 Update Contents 16 Partial Class Generate 15 PHP Code Generation 51 Import Reverse Engineering 6 Language
119. ged Values UML Construct Default XSD Production Rules Package A schema element is generated for the target package If the target package includes Classes from another package which has the Tagged Values targetNamespace and targetNamespacePrefix set these are included as attributes of the schema element In addition an import or include element is created for each referenced package An include element is used if the external package shares the same targetNamespace Tagged Value as the target package An import element is used where the targetNamespaces differ Class A root level element declaration and complexType definition are generated The element name and type are the same as the Class name An XSD sequence model group is generated to contain UML attributes generated as elements An element is declared for each Class attribute The element name is set to that of the UML attribute name This is prefixed with the Class name to make the element unique The minOccurs and maxOccurs attributes are set to reflect the attribute cardinality Note If left unspecified minOccurs and maxOccurs default to 1 If the attribute refers to another Class the element declaration is followed a complexType definition which contains a reference to the appropriate complexType Association An element is declared for each association owned by a Class The element name is set to that of the association role The minOccurs and maxOccurs reflect the ca
120. generation of a complexType definition Tagged memberNames Determines whether elements generated from the UML Class Values qualified unqualified attributes and associations have their name qualified by the corresponding Class name for this complexType definition Determines whether this element can contain mixed element true false and character content See the W3CXML Schema recommendation modelGroup Overrides the default XSD model for generating this all sequence choice complexType definition conswaims ne XSDsimpleType UML Class Construct Description An XSD simpleType is generated for Classes with this stereotype Tagged derivation Specifies the derivation of the simpleType See the W3C XML Values restriction list Schema recommendation minLength maxLength See the W3C XML Schema recommendation totalDigits fractionDigits whiteSpace Constraints This Class can only participate in an inheritance relation with another simpleType lt cannot have any attributes or own any associations they are ignored if present Code Engineering Using UML Models XML Schema XSD Model XSD 94 XSDsequence UML Class Construct Description The schema generator creates a sequence model group as the container for the attributes and associations owned by this Class The model group is in turn added to the model groups of this Class respective owners Note Tagged va
121. ges Public Protected and Private e Java Package e Delphi Published e C Internal Protected Internal e ActionScript Internal e VB NET Friend Protected Friend e PHP Package e Python Package e C Package e C Package 1998 2010 Sparx Systems Pty Ltd 69 Modeling Conventions ActionScript Conventions 1 6 1 ActionScript Conventions Enterprise Architect supports round trip engineering of ActionScript 2 and 3 where the following conventions are used Stereotypes Stereotype Applies To Corresponds To Tagged Values Tag Applies To Corresponds To attribute_name Operation with stereotype property The name of the variable behind this get or property set property Class or Interface The dynamic keyword e ActionScript 3 Operation The final keyword intrinsic ActionScript 2 Class The intrinsic keyword Attribute Operation C Common Conventions e Package qualifiers ActionScript 2 and Packages ActionScript 3 are generated when the current package is not a namespace root 17 e An unspecified type is modeled as var or an empty Type field ActionScript 3 Conventions e The s Leaf property of a Class corresponds to the sealed keyword e Ifa namespace tag is specified it overrides the Scope that is specified See Also e Import Source Code si e Generate Source Code 124 e ActionScript Options 434 1 6 2 A
122. ggers that drive them as shown in the following diagram Code Engineering Using UML Models Code Generation From Behavioral Models State Machine Modeling For HDLs 24 stm StateMachine A change trigger is deemed as an The trigger to drive the actual asynchronous trigger if the following two system clock is of type time conditions are satisfied and is asociated with the 1 There is a transition from the actual transition from the reset state to Submachine state which encapsulates the the active state actual logic triggered by it 2 and the target state of that transition has a self transition triggered by the same trigger The Submachine state that i intended to contain the actual design Asynchronous Triggers Asynchronous triggers should be modeled according to the following pattern 1 The trigger should be of type Change specification true false 2 The active state Submachine State should have a transition trigger by it 3 The target state of the triggered transition should have a self transition with the same trigger Clock A trigger of type time which triggers the transitions to the active state Submachine State is deemed as the Clock The specification of this trigger should be specific to the target language Clock Trigger Specifications Positive Edge Triggered Negative Edge Triggered pes pe pr O 1998 2010 Sparx Systems Pty Ltd 25 Code Generation From Behavioral
123. global change in the Options dialog in existing Classes You must modify the options for the existing Class Modify Options for Single Class To modify options for a single Class follow the steps below 1 Right click on the Class to change and select the Generate Code menu option from the context menu The Generate Code dialog displays 2 Click on the Advanced button The Object Options dialog displays 3 Click on the Attributes Operations button 4 Change the options and click on the Close button to apply changes Modify Options for All Classes To modify options for all Classes within a package follow the steps below 1 Right click on the package in the Project Browser The context menu displays 2 Select the Code Engineering Reset Options for this Package menu option The Manage Code Generation dialog displays Code Engineering Using UML Models Code Engineering Settings Language Options 60 3 Reset the required defaults for each existing Class 4 Click on the OK button to apply changes 1998 2010 Sparx Systems Pty Ltd 61 Code Template Framework 1 5 Code Template Framework UML Ly D The Code Template Framework CTF is used during forward engineering of UML models The CTF enables you to e Generate source code from UML models e Customize the way in which Enterprise Architect generates source code e Forward engineer languages not specificall
124. h the stereotype WSDLportType e Bindings Contains the WSDL Bindings modeled as UML Classes that realize the PortTypes e Services Contains the WSDL Services modeled as UML interfaces with associations to each exposed Binding 6 Use the Overview diagram to navigate between the subpackages by double clicking the relevant packages You can edit the sample WSDL elements created in the previous step or drag new items from the WSDL pages of the Toolbox onto the relevant diagrams TODO Add your WSDL Types Messages Portypes Binding and Services by dragging elements from the WSDL toolbox Double click the pscksges below to navigate between the relevant disgrams You can sutomstically generste WSDLs from this model Drag WSDL components from the toolbox onto this diagram snd specify which services should be exposed i Gi Samplelnput Q SampilePornTypeHTTP B SampleBindingHTTP wO Sample Service InputParameters Gi SampleOutput Q SamplePortTypeSOAP SampleBindingSOAP OutputPsrameters a Generste this WSDL by selecting WSDL the WSDLnsmespsce in the SampleW SDLFile Project View and using the menu option Project Web Services Generste WSDL You can edit the WSDL specific properties of the namespace later by double clicking the package in the Project Browser Alternatively on the WSDL Namespace Properties dialog click on the UML button to invoke the standard Properties dialog for a package This button does
125. have finished mapping datatypes click on the Close button and again on the Database Datatypes dialog Code Engineering Using UML Models Import Database Schema from ODBC 160 3 16 Import Database Schema from ODBC a e EE Analysis of legacy database systems is possible using Enterprise Architect s reverse engineering 4 capabilities By connecting to a live database via ODBC you can import the database schema into a standard UML model Subsequent imports enable you to maintain synchronization between the data model and the live database Enterprise Architect supports importing database tables from an ODBC data source Tables are imported as stereotyped Classes with suitable data definitions for the source DBMS Notes e Import of stored procedures and views is supported for DB2 SQL Server Firebird Interbase Informix Ingres Oracle 9i 10g and 11g MySQL PostgreSQL Sybase Adaptive Server Enterprise ASE and Sybase Adaptive Server Anywhere ASA e f you are importing database schema from an MS Access Jet 4 0 database please ensure that you have selected the Use Jet 4 0 checkbox on the General page of the Options dialog see Using Enterprise Architect UML Modeling Tool Otherwise the Jet 3 5 routines are loaded You must restart Enterprise Architect after selecting the checkbox e The ODBC connection should use the ODBC driver available from the DBMS vendor For example MySQL s ODBC driver for MySQL
126. i ie 80 Python Conventions 81 System C Conventions 81 VB Net CONVENTIONS a E E T cubecsacedecescboteddeatdadeerscaeeieeceacsensoeseanie EES 83 KO Ree TE 84 VIDE en EE 85 Visual Basic CONVENTIONS E 87 XML Technologies 88 XML Schema XSD ircen eane soars es Eege EES 89 Model E 89 UME Profile for ASD oa AAA AAA E E N 91 XSD Datatypes Package aere enor a eel r et eee ates 97 ert Muere EE 98 Default UML to XSD Mappinge wiii ened EEN dice deena flab anne 99 Generate AA A EEE N AEAEE EE EAE EE E 100 Generate Global Element oia 101 Import XSD eceeseeeeeseeeeeeeeee we 102 Global Element and Complex Tvpe EEN 104 Web Services WSDL gett EN See eet 106 Model WSDL0 iia 106 WSDL Namespace 108 NN eeh teres deve Eddie en de d eeedee che 110 WSDL Service nvidia RL Re Aas eee del nn ee hd eco ances 111 WSDL PO O SE Patna ceeten ats EAE ATE O A E EA 112 WSDL M sa e EE 113 SIBI ES Cu Tote WER 113 WSDL Port Type Operation bese ae lee ae as 115 WSDL Message Pat ccmitatas tot eros 116 Generate WSDL i a eneore raeson aeaaee e ee aa gaa Ai EEGENEN ee 117 Impor WSDL ai a io 119 Data Modeling 120 A Data Model Diagram ooncccocnnncccnnnnonnnnnnnnnnnnrnnnrrcnrr rre 122 Code Engineering Using UML Models Contents 11 Create a ET TEEN Set Table Properties EEN EEN eege Set Table e TE Set MySQL Options ceeseeeeeeeeees Set Oracle Table Properties Greate ColuM EE Create
127. ial process Attribute The range or type value of an attribute O 1998 2010 Sparx Systems Pty Ltd 85 Modeling Conventions Verilog Conventions Verilog Toolbox Pages To access the Verilog pages of the Enterprise Architect UML Toolbox select the More tools HDL Verilog Constructs menu option Drag these icons onto a diagram to model a Verilog design page Jee fuero Verilog Module Define a Verilog Module A module stereotyped Class element Enumeration Define an Enumerated Type An enumeration stereotyped Class element Verilog Features Define a Verilog Port A port stereotyped attribute Part Define a Verilog component instantiation A part stereotyped attribute P Attribute Define an attribute Procedure Define a Verilog process e Concurrent e An asynchronous stereotyped method e Sequential e A synchronous stereotyped method e initializer e An initializer stereotyped method See Also e Import Source Code si e Generate Source Code 124 e Verilog Language Options 55 1 6 13 VHDL Conventions Enterprise Architect supports round trip engineering of VHDL where the following conventions are used Stereotypes CCOO CECI CET ESO CCT CN EI CEC CT CE CCT TT Code Engineering Using UML Models Modeling Conventions VHDL Conventions 86 Stereotype Applies To Corresponds To typedef A type or subtype definition Tagged Values Applies To Corresponds
128. ing Import Binary Module 1 1 4 Import Binary Module Enterprise Architect enables you to reverse engineer certain types of binary modules To import a binary module right click on the target package in the Project Browser and select the Code Engineering Import Binary Module context menu option File s al Source Type No file s selected Generation O Synchronise existing classes Overwrite existing Classes Create Logical Diagram for Let E each package o DI O Do not import private members Please be aware that creating diagrams for each package may significantly increase the time required to import me Gone a Currently the permitted types are as follows e Java Archive jar e Net PE file exe dll native Windows DLL and EXE files are not supported only PE files containing NET assembly data e Intermediate Language file il Enterprise Architect creates the necessary packages and diagrams during the import process Selecting the Do not import private members checkbox excludes private members from libraries from being imported into the model When importing Net files you can import via reflection or via disassembly or let Enterprise Architect decide the best method this might result in both types being used The reflection based importer relies on a Net program and requires the Net runtime environment to be installed The disassembler based importer r
129. ing is performed using column stereotyped classes Add s table to the PK WarehouselD VARCHAR2 10 disgram by dragging from the Class Location VARCHAR2 30 Elements toolbox Capacity NUMBER 8 2 PK PK_Warehouse VARCHAR2 PK_Warehouse 1 WarehouselD WarehouselD column PK ISBN VARCHAR2 15 FK InventorylD VARCHAR2 10 column AuthoriD VARCHAR2 30 FK_Book_Invento aa PK InventorylD VARCHAR2 10 a a x PublisheriD VARCHAR2 20 FK WarehouselD VARCHAR2 10 PK_InventorylD Cost NUMBER 8 CurrentStock NUMBER S Stock NUMBER OnOrder NUMBER S Inventoryld InventorylD Dn 8 PK aFK PK_Book VARCHAR2 FK_Inventory_Warehouse VARCHAR2 Fk 8 PK FK_Book_Inventory VARCHAR2 PK_Inventory VARCHAR2 Associstions between tables sre based on the Primary to Foreign key relationship These examples show how to define this A Data Model diagram is represented in Enterprise Architect as a Class diagram and is created in exactly the same way as other diagrams see the Working With Diagrams topic in UML Modeling With Enterprise Architect UML Modeling Too 1998 2010 Sparx Systems Pty Ltd 123 Create a Table 3 2 Create a Table What is a Table The basic modeling structure of a relational database is the Table A Table represents a set of records or rows with the same structure The UML Data Modeling Profile represents a Table as a stereotype
130. inking with existing attributes resolve generalizations resolve realisations Cancel Import 1 1 2 Notes on Source Code Import Enterprise Architect enables you to import codel 57 into your project in the following programming languages e ActionScript e e cle e CR e C 64 e Delphi 74 e Javal 7 e PHP 74 e Python 74 e Visual Basic 74 e Visual Basic NETI 75 Enterprise Architect supports most constructs and keywords for each coding language If there is a particular feature you require support for that you feel is missing please contact Sparx Systems You must select the appropriate type of source file for the language as the source code to import ActionScript Appropriate type of source file as Cc Appropriate type of source file h header files and or c files When you select a header file Enterprise Architect automatically searches for the corresponding c implementation file to import based on the options for extension and search path specified in the C options Ai Enterprise Architect does not expand macros that have been used these must be added into the internal list of Language Macros 39 C Appropriate type of source file h header file O 1998 2010 Sparx Systems Pty Ltd 7 Reverse Engineering Notes on Source Code Import Enterprise Architect automatically searches for the cpp implementation file based on the extension and search p
131. input output parameters Enterprise Architect models stored procedures as individual Classes 14 Note Stored procedures are currently supported for DB2 SQL Server Firebird Interbase Informix Ingres Oracle 9i 10g and 11g MySQL PostgreSQL Sybase Adaptive Server Enterprise ASE and Sybase Adaptive Server Anywhere ASA 3 8 1 Create Individual Class Procedure To create a stored procedure as an individual Class follow the steps below 1 Open the required diagram 2 From the Data Modeling page of the Enterprise Architect UML Toolbox More tools Data Modeling drag the Procedure icon onto the diagram 3 Ifthe Properties dialog does not automatically display double click on the element Code Engineering Using UML Models Stored Procedures Create Individual Class Procedure 144 Database MySql y Procedure definition E Ges Ge 4 Inthe Database field click on the drop down arrow and select the target DBMS to model The field displays the default database if it has already been set 5 Inthe Procedure definition field type the entire procedure text 6 Click on the OK button procedure Employee Sales By Country To define a name for the stored procedure click on the element click on the name Class lt n gt and click again This highlights the text for editing Type in the required name For further details see the In Place Editing section i
132. int A Check Constraint enforces domain integrity by limiting the values that are accepted by a column Create an Index Ensure that the column s to be used in the index have already been defined 1301 in the table 1 Right click on the required table either in a diagram or in the Project Browser 2 Select the Operations context menu option The Operations dialog displays 3 Add an operation with a name such as DX_CustomerlD the IDX_ prefix is optional but it helps identify the operation 4 Inthe Stereotype field for the operation select index check and unique are also supported 5 Click on the Column tab 6 Select the required columns from the Columns drop down list in the required order then click on the Save button to save changes Create a Check Constraint or Trigger 1 Locate the required table in either a diagram or the Project Browser 2 Use the context menu to open the Operations dialog 3 Add an operation such as CHK_ColumnName or TRG_OnCustomerUpdate the CHK_ and TRG_ prefixes are optional but help identify the operation 4 Inthe Stereotype field for the constraint select check or trigger as appropriate and click on the Save button to save changes 5 Select the constraint operation then the Behavior tab 6 Enter the entire check constraint clause for example col1 lt 1000 or the entire trigger code including the CREATE_TRIGGER statement in the Initial Code field and click on the Save button to s
133. ionary and e A message Action Opaque The Java code generated from this diagram resembles the following public void newTransaction behavior is an Interaction if bValidUser Alt combined fragment placeOrder 101 Interaction Occurrence 1998 2010 Sparx Systems Pty Ltd 27 Code Generation From Behavioral Models Code Generation Interaction Diagrams else return 1 3 4 Code Generation Activity Diagrams Note To be able to generate code from behavioral models all behavioral constructs should be contained within a Class Code generation from an Activity diagram see the UML Dictionary in a Class requires a validation phase during which Enterprise Architect uses the system engineering graph optimizer to analyze the diagram and render it into various code generatable constructs Enterprise Architect also transforms the constructs into one of the various action types if appropriate similar to the Interaction diagram constructs Enterprise Architect then uses the EASL code generation macros to generate code from these constructs For more information on the EASL code generation macros and templates Enterprise Architect uses to generate code from behavioral models see the EASL Code Generation Macros topic in the Code Template Framework in SDK section of SDK for Enterprise Architect To provide a comprehensive analysis of these features several diagrams from the EAExample project are
134. is parameter extension attributeName Operation with stereotype The name of the variable behind this property or event property or event Operation with stereotype The Class that this method is being added to extension cont O Attribute The const keyword definition Operation with stereotype Whether this is the declaration of the method or the partial definition delegate The delegate keyword property om foan feon id ma COCOS TC et Je EE genericConstraint Templated Class or The constraints on the generic parameters of this type s Interface Operation with or operation tag generic Operation The name of the method this implements including the interface name ImplementsExplici The presence of the source interface name in this CTN CST CEST row CENT TT prame CET TEN en CET CTN aie foes i sito ver sees bere 1998 2010 Sparx Systems Pty Ltd 75 Modeling Conventions C Conventions Applies To Corresponds To SE with stereotype This property only defining write code Other Conventions e Namespaces are generated for each package below a namespace root 17 e The Const property of an attribute corresponds to the readonly keyword while the tag const corresponds to the const keyword e The value of inout for the Kind property of a parameter corresponds to the ref keyword e The value of out for the Kind property of a parameter corresponds to the out keyword e Partial Classes can be modeled
135. ld be removed in the variables corresponding get set functions Click on the Component Types button to configure what elements 33 you would like to be created for files of any extension found while importing a source code directory Note It is worthwhile to configure these settings as they serve as the defaults for all Classes in the model You can override these on a per Class basis using the custom settings from the Code Generation dialog 1 4 1 1 1 Import Component Types The Import Component Types dialog enables you to configure what elements you would like to be created for files of any extension found while importing a source code directory To access the Import Component Types dialog select the Tools Options Source Code Engineering menu option to display the Source Code Engineering page of the Options dialog and click on the Component Types button Code Engineering Using UML Models Code Engineering Settings Source Code Engineering 34 Specify for this model the files by extension type their UML equivalent and an optional stereotype for importing additional items when reverse solution For each extension you can specify e The element type to be created e The stereotype to apply to these objects Note You can transport these import component types between models using the Export Reference Data and Import Reference Data options on the Tools menu See the Reference D
136. lue 126 Set Owner 126 Scope Values 68 Select ODBC Data Source Sequence Oracle DDL Options 149 Oracle DDL Options For Packages 151 Sequence Diagram Generate Code From Service WSDL Diagram 111 WSDL Element 111 Service Oriented Architecture 88 Set Collection Classes 41 Single User 39 SOA 88 SOAP Binding 113 Sorted Lookup Table Create In Data Modeling Source Code Add New Features And Elements 67 Import Reverse Engineering 5 Internal Editor Options 34 Reset Language 59 160 162 19 26 147 Reverse Engineer 4 Synchronize 4 Source Code Generation Class 12 Interface 12 Overview 12 SQL Server Non Clustered Primary Key State Machine Model For Hardware Description Languages 23 State Machine Diagram Code Generated From 20 Generate Code From 19 Stereotype XSD In UML Profile 91 Stored Procedure As Individual Class Definition 143 Element 143 Select From ODBC Data Source Supported Databases 143 Synchronization Introduction 2 Of Source Code And Model 4 Synchronize 136 143 163 Code 66 Existing Code Sections 67 SystemC Code Generation 53 Enterprise Architect Toolbox Pages 81 Language Options 53 Modeling Conventions 81 T Table DDL Script For 120 Owner Tagged Value Set Owner 126 Set Properties Tagged Value For Oracle Table Properties For Schema Owner 126 For Table Owner 126 Template Editor Code Templates 64 Trigger Operation What Is A Trigger Operation Create 147 What Is A
137. lues specified by owners of this Class persist through to the child elements of this model group Thus if memberNames are unqualified for a complexType so are the children of this model group when added to that complexType Tagged None Values Constraints This Class must be the destination of unidirectional associations If it is not this Class and its connectors are ignored possibly invalidating other model group Classes Inheritance relations are ignored for this Class XSDchoice UML Class Construct Description Creates an XSD choice element See XSDsequence for more details Tagged None Values XSDelement UML Attribute AssociationEnd Construct Description By applying this stereotype to a UML Class attribute or AssociationEnd the corresponding UML entity is generated as an element within the parent complexType and not as an XSD attribute Tagged form Overrides the schema s elementFormDefault value Values qualified unqualified Causes the elements to be ordered within a sequence model group of the containing complexType Duplicated and invalid position Tagged Values are ignored and result in undefined ordering of the UML attributes Missing position values cause the defined positions to be allocated as specified with the remaining elements filling the missing positions in an undefined order e Specifies H the role name is included in the element declaration false for the UML attribute
138. me Text 50 Container Text 50 Organisation Text 50 Notes Memo Phone1 Text 50 Derved Text 1 Phone2 Text 50 ID Long Mobile Text 50 Pos Long Fax Text 50 GenOption Memo Emal Text 50 Length Long Roles Text 255 Precision Long Notes Text 255 Scale Long Const Long O 1998 2010 Sparx Systems Pty Ltd 165 Index Index A Abstract XSD Models 98 ActionScript Code Generation Language Options 43 Import Reverse Engineering 6 Modeling Conventions 69 Options 43 Versions Supported 43 Active State Logic Model State Machine For HDL 23 Activity Diagram Generate Code From 19 27 Ada 2005 Code Generation Language Options 43 Modeling Conventions 69 Options 43 Add New Code Sections To Existing Features ANSIC 44 Modeling Conventions 71 Association Connector Set Collection Class 41 Attribute Create Fast Option 36 Delete If Not In Code In Reverse Synchronization 36 Imported Default Name Generated From Message Part WSDL 116 Stereotyped For Columns 130 B Behavioral Models Generate Code From 19 Binary Module Import Reverse Engineering 9 Binding WSDL Diagram 113 WSDL Element 113 C C Code Generation Language Options 44 Import Reverse Engineering 6 Modeling Conventions 71 72 Object Oriented Programmiing 72 Options 44 C Code Generation Language Options 45 Import Reverse Engineering 6 Modeling Conventions 73 Options 45 C Code Generation 46 Implementation Fil
139. mespace root which denotes where the namespace structure starts all subordinate packages below this point are generated as namespaces to code To define a package as a namespace root right click on the package in the Project Browser and select the Code Engineering Set as Namespace Root context menu option The package icon in the Project Browser changes to include a colored corner Au When you have set the namespace root the menu option changes to Clear Namespace Root click on this option to take the namespace root status off the package Also see the context menu described below Once you have set a namespace root Java code generated beneath this root automatically adds a package declaration at the head of the generated file indicating the current package location To view a list of namespaces select the Settings Namespaces menu option The Namespaces dialog displays Defined Namespaces Namespace Development Model DFD Fulfill Orders Development Model Use Case Model Development Model Use Case Model ClassLibrary1 Development Model Use Case View Sequence Diagram Development Model Work WSDLPackage1 Model Locking Model System Model Implementation Model PSM C Model gt mW m 4 Code Engineering Using UML Models Generate Source Code Namespaces 18 If you double click on a namespace in the list the package is highlighted in the Project Browser Alt
140. mper parsing of the underlying C language To help remedy this you can include any number of macro definitions which are ignored during the parsing phase of the reverse engineering It is still preferable if you have the facility to preprocess the code using the appropriate compiler first this way complex macro definitions and defines are expanded out and can be readily parsed If you don t have this facility then this option provides a convenient substitute Code Engineering Using UML Models Code Engineering Settings Language Macros 40 Note You can transport these language macro or preprocessor macro definitions between models using the Export Reference Data and Import Reference Data options on the Tools menu The macros are exported as a Macro List See the Reference Data topic in UML Model Management Define a Macro 1 Select the Settings Preprocessor Macros menu option The Language Macros dialog displays Defined Macros Delete _AFX_NO_DEBUG_CRT A AFX_NO_OCC_SUPPORT AFX_OLD_EXCEPTIONS AFX_PACKING AFXDLL DEBUG MSC VER UNICODE AFX_CDECL AFX_COMDAT KE 2 Click on the Add New button 3 Enter details for your macro 4 Click on the OK button Macros Embedded Within Declarations Macros are sometimes used within the declaration of Classes and operations as in the following examples class __declspec Foo If declsp
141. mpl Operation Notes Impl Used by the Operation template to generate documentation for an operation The base templates form a hierarchy which varies slightly across different programming languages A typical template hierarchy relevant to a language like C or Java which do not have header files is shown in the example diagram below In this diagram the templates are modeled as Classes in reality they are just plain text This hierarchy would be slightly more complicated for languages like C and Delphi which have separate implementation templates Each of the base templates must be specialized to be of use in code engineering In particular each template is specialized for the supported languages or products For example there is a ClassBody template defined for C another for C another for Java and so on By specializing the templates you can tailor the code generated for the corresponding UML entity Once the base templates are specialized for a given language they can be further specialized based on e A Class s stereotype e A feature s stereotype where the feature can be an operation or attribute This type of specialization enables for example a C operation that is stereotyped as property to have a different Operation Body template from an ordinary operation The Operation Body template can then be specialized further based on the Class stereotype Code Engineering Using UML Models Code Template Frame
142. mport as individual dasses Import as dass operations Y Indude User Functions _ Import as individual dasses 9 Import as class operations 4 Indude User Sequences gt Import as individual dasses 9 Import as class operations Synchronization 9 Synchronize existing classes Y Synchronize Table Column Comments Y Synchronize Column Default Values een C Import as New objects Import To 9 Diagram Package O Package Only 3 Inthe Database field click on the Browse button and select a suitable ODBC data source 1627 from the ODBC dialog ODBC must be installed and configured on your machine for this to work correctly When you have selected the data source the Database field shows the DBMS the database server ID and the database name separated by full stops that is dbms dbserver database 4 If importing from Oracle to restrict the import to a specific owner type the owner name in the Schema Owner field By default Enterprise Architect inserts the Oracle user name in this field For imports from other types of database leave this field blank 5 Inthe Filter panel select the appropriate checkboxes for additional items to include in the import Select the appropriate checkboxes to import system tables and views user views triggers and or Oracle packages If you select to import User Functions and or User Sequences as individual Classes then they are imported as separate
143. n UML Modeling With Enterprise Architect UML Modeling Tool O 1998 2010 Sparx Systems Pty Ltd 145 Views 3 9 Views Note Views are currently supported for DB2 SQL Server Firebird Interbase Informix Ingres Oracle 9i 10g and 11g MySQL PostgreSQL Sybase Adaptive Server Enterprise ASE and Sybase Adaptive Server Anywhere ASA Create a View To create a database View follow the steps below 1 On the Data Modeling page of the Enterprise Architect UML Toolbox More tools Data Modeling drag the View icon onto your Data Modeling diagram 2 Ifthe View Properties dialog does not immediately display double click on the element Database Dependencies View definition 3 From the Database drop down list select the target DBMS to model The default database displays if it has already been set 4 Click on the OK button To define a name for the View click on the element click on the name Class lt n gt and click again This highlights the text for editing Type in the required name For further details see the In Place Editing section in UML Modeling With Enterprise Architect UML Modeling Tool Define View Properties 1 Create a Dependency connector from the View to the table or tables on which the View depends 2 Double click on the View to display the Properties dialog The tables are now listed in the Dependencies field 3 Inthe View definition field type the full view
144. n are optional Primary Key select the checkbox if the column represents the primary key 134 for this table Not Null select the checkbox if empty values are forbidden for this column Unique select the checkbox if it is forbidden for any two values of this column to be identical Initial type a value that can be used as a default value for this column if required Access click on the drop down arrow and select a scope of Private Protected or Public the field defaults to Public Alias type an alternative name for the field for display purposes if any Notes type any other information necessary to document the column you can format the text using the Rich Text Notes toolbar at the top of the field Notes e The unique characteristic applied to a single column ensures that no two data values in the column can be identical The unique stereotype applied to an Index ai ensures that no two combinations of values across a set of columns can be identical e Some datatypes such as the Oracle NUMBER type require a precision and scale These fields are displayed where required and should be filled in as appropriate For example for Oracle create NUMBER by setting Precision 0 and Scale 0 create NUMBER 8 by setting Precision 8 and Scale 0 create NUMBER 8 2 by setting Precision 8 and Scale 2 e Oracle VARCHAR2 15 CHAR and VARCHAR2 50 BYTE datatypes can be created by adding the tag LengthType with the value CHAR o
145. n the Class name and function operation name The function in C code must also have a reference parameter to the Class object You can modify the Reference as Operation Parameter Reference Parameter Style and Reference Parameter Name options on the C Specifications page to support this reference parameter Limitations of Object Oriented Programming in C 1 No scope mapping for an attribute an attribute in a UML Class is mapped to a structure variable in C code and its scope private protected or public is ignored 2 Currently an inner Class is ignored if a UML Class is the inner Class of another UML Class it is ignored when generating C code 3 Initial value is ignored the initial value of an attribute in a UML Class is ignored in generated C code See Also e Import Source Code 5 e Generate Source Code 124 e C Options 445 1 6 4 C Conventions Enterprise Architect supports the round trip engineering of C where the following conventions are used Stereotypes Stereotype Applies To Corresponds To om foen ome Operation A Class extension method represented in code by a this parameter in the signature Code Engineering Using UML Models Modeling Conventions C Conventions 74 Stereotype Applies To Corresponds To property A property possibly containing both read and write code Tagged Values Applies To Corresponds To argumentName Operation with stereotype The name given to the th
146. n the Local Paths dialog select the Settings Local Paths option Path C Java Source A ID Java Apply Path Expand Path Type Java si Relative Paths New Delete Type ID Path Java Java C Java Source Version Control SVN_Use Y Dev Howard 4Review _EAFutureBuilds C0905 Version Control SVN_config C VC Workspaces Subversion Roys Testing 4 mt 8 5 Cose Hep The Local Paths dialog enables you to define e Path the local directory in the file system for example d java source e ID the shared ID that is substituted for the Local Path for example JAVA_SRC e Type the language type for example Java And also to e Apply Path Select a path and click on this button to update any existing paths in the model with full path names to the shared relative path name so d java source main java might become JAVA_SRC main java e Expand Path The opposite of Apply Path This enables you to remove a relative path and substitute the full path name Using the two options you can update and change existing paths Note You can also set up a hyperlink see the UML Dictionary on a diagram to access the Local Paths dialog to switch update or expand your current Local Path 1 4 4 Language Macros When reverse engineering a language such as C you might find preprocessor directives scattered throughout the code This can make code management easier but can ha
147. n the code by finding the indents specified in list macros of the Class For languages that make use of namespaces the synchNamespaceBodyIndent macro is available Classes defined within a non global namespace are indented according to the value set for this macro during synchronization This value is ignored for Classes defined within a package setup as a root namespace or if the Generate Namespace option is set to False in the appropriate language page C C or VB Net on the Options dialog Tools Options Source Code Engineering lt language gt Code Engineering Using UML Models Modeling Conventions 68 1 6 Modeling Conventions Wns In order to get the most out of the round trip engineering in Enterprise Architect you must be familiar with the modeling conventions used when generating and reverse engineering the languages you use This topic describes the stereotypes Tagged Values and other conventions used in code engineering in Enterprise Architect for the following supported languages e ActionScript e e Ada 2005 69 for Systems Engineering and Ultimate editions of Enterprise Architect e cl e CHIT e Clg e Delphi 784 e Javal e PHP at e Python e System Ce e VB Net si e Verilog 8 e VHDL eg e Visual Basic ei Note Enterprise Architect incorporates a number of visibility indicators or scope values for its supported languages These include for e All langua
148. n to generate namespaces or not e Shown if the technology supports namespaces e Saved once for all projects Default Source Directory e The default directory to save generated source files e Always shown e Saved once for all projects Editor e The editor that is loaded to edit the source files Always shown Saved once for all projects 1998 2010 Sparx Systems Pty Ltd 59 Code Engineering Settings Language Options e AttType e Default type for attributes e Always shown e Saved once for all projects These options are set in the technology inside the lt CodeOptions gt tag of a code module as follows lt CodeOption name DefaultExtension gt rb lt CodeOption gt E Objects IDL g Links i 22 Communication Colors Disable Language dy XML Specifications E Options for the current model J Source Code Engineering Default Extension 2 io Options for the current user E Default Attribute Type Ze EE Generate Namespaces False ae ae Default Source Directory cq CH Import File Extensions G Editor ft Delphi p Java gp PHP 2 Python Visual Basic S VB Net Ada Sc SystemC Nr Verilog DN VHDL Collection dass for 1 associations EI a Close 1 4 6 16 Reset Options Enterprise Architect stores some of the options for a Class when it is first created Some are global for example LinkClass is stored when you first create the Class so it won t automatically pick up the
149. nabled you must have Generate Source Code and DDL permission to synchronize source code with model elements See User Security in UML Models Synchronize Classes on Forward Generation When there are features present in the code but not in the model you can use the following buttons during forward synchronization Note These buttons are only available when the On forward synch prompt to delete code features not in model checkbox is selected in the Options Attributes and Operations 367 dialog e Delete when you click on this button the selected code features are removed from the code e Reassign when you click on this button the code elements are reassigned to elements in the model this is only possible when an appropriate model element is present that is not already defined in the code e Ignore when you click on this button the code elements not present in the model are ignored completely e Reset to Default when you click on this button the settings for synchronizing during forward generation are set to Ignore meaning that the elements present in the code but not in the model are ignored completely Code features not in model Feature ClassLibX ClassLibX StatesProc State Type CommandType TransitionsProc Transition Type initialize State Machine runStateMachine transcend cur Transition next State currState Code Engineering Using UML Models Generat
150. ng the operation in the diagram or Project Browser Alternatively on the WSDL PortType Operation dialog click on the UML button to invoke the standard Properties dialog for an operation This button does not display on the initial WSDL PortType Operation dialog for a new PortType Operation 2 2 1 8 WSDL Message Part WSDL message parts are represented in Enterprise Architect by UML attributes defined as part of a WSDLmessage Class see the WSDL Message mi topic To add message parts to your WSDLmessage Classes follow the steps below ie Open the Overview diagram defined for your WSDL namespace package and double click on the 1998 2010 Sparx Systems Pty Ltd 117 Web Services WSDL Model WSDL Messages package to open the Messages diagram 2 Drag the Message Part element onto a WSDLmessage stereotyped Class The WSDL Message Part dialog displays Name elementi Type string a o Jl cancel Il me 3 Type in a Name and Type for the message part The type should be selected from the drop down list of primitive XSD types or from the types defined under the Types package 4 Click on the OK button You can edit the WSDL specific properties of the message part later by double clicking the attribute in the diagram or Project Browser Alternatively on the WSDL Message Part dialog click on the UML button to invoke the standard Properties dialog for an attribute This button does
151. ngineering Using UML Models Web Services WSDL Model WSDL 114 ampleBindingSOAP SamplePortT ypeSOAF soap http schemas xmlsoap org soap http Type in a Name for the Binding Select the PortType for the Binding the drop down list of PortTypes is taken from those defined in the PortTypes package Select the Protocol for the Binding either http or soap For SOAP Bindings enter the Transport URL and select the Style For http Bindings select the Verb Click on the OK button to close the WSDL Binding dialog and create the binding A realization connector is created between the binding and the corresponding Port Type interface To specify the Binding operations select and double click on an Operation in the Binding element The WSDL Binding Operation Details dialog displays 1998 2010 Sparx Systems Pty Ltd 115 Web Services WSDL Model WSDL Operation Name SetSampleSOAP Action Style document y Location Documentation B I UA Kal A 9 Type in or select the Binding Operation details 10 Click on the Parameters button The WSDL Binding Operation Parameters dialog displays For each input output and fault click on the Details button and enter the details 11 Click on the OK button on each of the WSDL Binding Parameter Details WSDL Binding Operation Parameters and WSDL Binding Operation Details dialogs to close them You can edit the WSDL specifi
152. not display on the initial WSDL Namespace Properties dialog for a new Namespace element Code Engineering Using UML Models Web Services WSDL Model WSDL 110 2 2 1 2 WSDL Document WSDL documents are represented in Enterprise Architect by UML components stereotyped as WSDL These components are modeled as direct child elements of the top level WSDL namespace package You can create multiple WSDL documents for a single namespace thus enabling the services for that namespace to be reused and exposed as required across multiple WSDLs To define new WSDL document components for your namespace follow the steps below 1 Open the Overview diagram defined for your WSDL namespace package and drag the WSDL element from the Toolbox onto the diagram The WSDL Document Properties dialog displays Name SampleWSDLFile File Name C Temp MyWSDLFile wsdl Documentation B P http www exampleURI com WSDLPackage 1 http schemas xmlsoap org wsdl http schemas xmlsoap org wsdl soap http schemas xmlsoap org wsdl http htn Jhananar w2 arn IMA NMI Gebees e New Delete Service Name SampleService m o Jl cms J me 2 Type in the Name and File Name for the document 3 The XMLNS panel lists the default XML namespaces used by the document If required click on the New button to add further namespaces Note You can also delete any namespace entries that you
153. ockable Windows section of Using Enterprise Architect UML Modeling Too Note You view source code for an element by selecting it and pressing either Ctrl E or F12 If the element does not have a generation file that is code has not been or cannot be generated such as for a Use Case Enterprise Architect checks whether the element has a link to either an operation or an attribute of another element If such a link exists and that other element has source code the code for that element displays You can also generate code from three UML behavioral modeling 1 paradigms e State Machine diagrams e Interaction diagrams e Activity diagrams The Code Template Framework CTF 6 enables you to customize the way Enterprise Architect generates source code It also enables you to generate languages that Enterprise Architect does not specifically support by helping you define the appropriate code generation templates for that language this is discussed in SDK for Enterprise Architect You can integrate the facilities of Enterprise Architect with other development environments The MDG Integration for Eclipse and MDG Integration for Visual Studio 10 are standalone products that provide an enhanced code engineering functionality between Enterprise Architect and the development environments Reverse Engineering Reverse Engineeringl 4 is the import of existing source code into model elements mapping the source code structures onto
154. odels cseccseseeceseeeeneeeeseeesesneeenseeeesseeseseeeeeeenenas 19 SW Code Generation State Machine Diagrams sscscssceesseeeeeeseeeseeeseeeseeseneeeesenenensneeseeeseenseeseneseneenes 19 Java Code Generated From State Machine Diagoram conc c arc nnncnnncnrcnnnnn 20 State Machine Modeling For HDLS ssscesssecseeseeesensseesseeseeeseesenesenssneseeeseeesessneseesenesensneesseeseesseesenesentents 23 Code Generation Interaction Diagrams cecsessnsessneseeesessenesenseeseesseessesseneeeeseneseesneeseeeseeeseesenenensenes 26 Code Generation Activity Diagrams 0onnnnnonnininnnncne erre 27 Code Engineering Settings Source Code Enotneertng gue EES SEENEN Eeer eier Opt EC Import Component TYPOS ode arses isesend aae ENEE gc 33 Options Gode Editors Edge AL ada 34 Options Object Lifetimes inie onan be ve Hd ieee ae 35 Options Attribute Operations 36 Code Page for Source EGiting e228 ace e ed dE cds 37 LOCal Paths siieccicssisdssreausstarsgecvesonsectacsctersdoncoten cused uoussanddvasesveteusudbancsbeuaceesoeceucavedsereuseauececeuanesvey eabsseusevvansduaceis 38 Local Paths Dialog EE 39 Language MACLOS iiieoo nonten aena anmannan Aaaa er 39 Set Collection Classes Al Language el EE 42 ActionScript Options 43 Ada 2005 Options EE 43 GiOptiOnS cesaron Ib arar 44 Gi OPTIONS sat A AAA AA E E R IA 45 CHF OPHONS tic Arta 46 Delphi Options iia aa iia tana ica aes eet ee Ae ee a 4
155. ody of a namespace Namespace Declaration Used by the Namespace template to generate the namespace declaration 1998 2010 Sparx Systems Pty Ltd 63 Code Template Framework Code Templates A top level template for generating operations from a UML Class s operations Operation Body Used by the Operation template to generate the body of a UML operation Operation Declaration Used by the Operation template to generate the operation declaration Operation Notes Used by the Operation template to generate documentation for an operation Used by the Operation Declaration template to generate parameters The second table lists templates used for generating code for languages that have separate interface and implementation sections Class Impl A top level template for generating the implementation of a Class Class Body Impl Used by the Class Impl template to generate the implementation of Class members File Impl A top level template for generating the implementation file File Notes Impl Used by the File Imp template to generate notes in the source file Import Section Impl Used by the File Imp template to generate external dependencies Operation Impl A top level template for generating operations from a UML Class s operations Operation Body Impl Used by the Operation template to generate the body of a UML operation Operation Declaration Used by the Operation template to generate the operation declaration I
156. olumns 130 Create Table 123 Data Model Diagram 122 Data Type Conversion Procedures 155 DBMS Conversion Procedure Package 156 DBMS Data Types 158 DDL Generate 149 Foreign Keys 137 Generate DDL 149 Generate DDL For A Package 151 Index 147 Introduction 120 Primary Key Extended Properties 136 Primary Key Create 134 Profile UML 120 Set MySQL Table Type 126 Set Oracle Table Properties 127 Set Schema Owner 126 Set Table Owner 126 1998 2010 Sparx Systems Pty Ltd 167 Index Data Modeling Set Table Properties Sorted Lookup Table Stored Procedure Trigger Operation Typical Tasks 120 Unique Constraint Data Source Select Data Type Conversion Procedures DBMS 158 Database Compare Package DDL With Default 34 Design 120 Keys 120 Modeling 120 Schema Import Of Supported Types 120 View ReportOn 145 Database Operation Properties Dialog 136 Database Table Select From ODBC Data Source DBMS Conversion Procedures 155 Data Type Conversion Procedures DBMS Conversion Mapper 156 Procedure 156 Table Conversion Between DBMS Types DDL Compare With Database Data Modeling 149 Default Script Editor 34 Generate For Package 151 Generate For Table 149 Import Schema From ODBC Schema Import From ODBC 124 147 143 147 147 162 155 151 120 163 155 156 151 160 160 Scripts And Generated Tables 120 Default Database 34 DDL Script Editor 34 UML To XSD Mappings 99 Define
157. on s e Default source directory e Editor for changing code Code Engineering Using UML Models Code Engineering Settings Language Options 54 SystemC Disable Language E Options for the current model Default Extension E Options for the current user Default Attribute Type Default Source Directory Import File Extensions Editor Collection dass for 1 associations 1 4 6 11 VB Net Options Configure options for VB Net code generation using the VB Net Specifications page of the Options dialog select the Tools Options Source Code Engineering VB Net menu option The options you can specify include the Default file extension Default source directory 1998 2010 Sparx Systems Pty Ltd 55 Code Engineering Settings Language Options VB Net Specifications T Disable Language E Options for the current model Default Extension vb E Options for the current user Default Attribute Type Variant Generate Namespaces True Default Source Directory Editor Collection class for 1 associations 1 4 6 12 Verilog Options Configure options for Verilog code generation using the Verilog page of the Options dialog select the Tools Options Source Code Engineering Verilog menu option The options you can specify include the e Default file extension s e Default source directory e Editor for changing code Code Engineering Using UML Models Code Engineering Settings
158. on using the C Specifications page of the Options dialog select the Tools Options Source Code Engineering C menu option The options you can specify include e Support for Object Oriented coding e Default file extensions header and source e Default source directory e Editor for C code e Path that Enterprise Architect uses to search for the implementation file the first path in the list is the default path when generating 1998 2010 Sparx Systems Pty Ltd 45 Code Engineering Settings Language Options C Specifications Disable Language E Options for the current model Header Extension Source Extension Object Oriented Support Namespace Delimiter Reference as Operation Parameter Reference Parameter Style Reference Parameter Name Default Constructor Name Default Destructor Name Options for the current user Default Attribute Type Import Hdefine Constants False True Pointer delete False m Collection dass for 1 associations 1 4 6 4 C Options File extension Get prefix Set prefix Directory for opening and saving C source code Configure options for C code generation using the C Specifications page of the Options dialog select the Tools Options Source Code Engineering C menu option The options you can specify include the default Code Engineering Using UML Models Code Engineering Settings Language Options 46
159. onal database is the column Every individual item of data entered into a relational database is represented as a value in a column of a row in a table Columns are represented in the UML Data Modeling Profile as a stereotyped attribute that is an attribute with the Column stereotype Create Columns Note For MySQL before creating columns first add ENUM and SET datatypes Select the Settings Database Datatypes menu option and on the Database Datatypes dialog in the Product Name field select MySQL Add the datatypes ENUM and SET To create columns follow the steps below 1 Right click on the Table in a diagram to open the context menu and select the Attributes menu option 2 The lt Tablename gt Columns dialog displays Columns PK Name Type m_delivery INTEGER No PK Order Dino Address BIGINT Basket BIGINT Delivery Address BIGINT 3 Inthe Name field type the column name 4 Inthe Data Type field click on the drop down arrow and select the data type and click on the Save button O 1998 2010 Sparx Systems Pty Ltd 131 Create Columns Tip If the drop down list of datatypes is empty this means that you have not selected a target database for the table Close the Columns dialog and re open the Table Properties dialog to set a database type before continuing To prevent this recurring set the default database type 34 The following fields for each colum
160. or each language e ActionScript 437 e Ada 2005 43 in the System Engineering and Ultimate editions of Enterprise Architect e ANSI C 44 e CHI 4 e C44 465 1998 2010 Sparx Systems Pty Ltd 43 Code Engineering Settings Language Options e Delphi 477 e Delphi Properties 8 e Javal st e PHP ai e Python s52 e SystemC 534 e VB Net 54 e Verilog 58 e VHDL sg e Visual Basic 574 e MDG Technology Languages sg e Reset Options sg 1 4 6 1 ActionScript Options Configure options for ActionScript code generation using the ActionScript Specifications page of the Options dialog select the Tools Options Source Code Engineering ActionScript menu option The options you can specify include the e Default ActionScript version to generate AS2 0 or AS3 0 e Default file extensions header and source e Default source directory e Editor for ActionScript code ActionScript Specifications Disable Language E Options for the current model Default Version 2 0 Default Extension as Options for the current user Default Source Directory Editor Collection dass for 1 associations 1 4 6 2 Ada 2005 Options Note Ada 2005 support is available in the System Engineering and Ultimate editions of Enterprise Architect Configure options for Ada 2005 code generation using the Ada page of the Options dialog select the Tools Code Engineering Using UML Models
161. pe This defines the list of datatypes that are available for defining columns and also declares which dialect of DDL is generated Enterprise Architect supports the following databases e DB2 e Informix e Ingres e InterBase e MS Access 97 2000 2003 e Access 2007 e MySQL e Oracle 9i 10g and 11g e PostgreSQL e SQL Server 2000 2005 and 2008 e SQLServer7 e Sybase Adaptive Server Anywhere Sybase ASA e Sybase Adaptive Server Enterprise Sybase ASE To set the database type follow the steps below 1 Double click on the table element in a diagram to open the Properties dialog 2 Select the General tab 1998 2010 Sparx Systems Pty Ltd 125 Set Table Properties Name Stereotype table Author an Administrator L oe Jee wo uti 3 Inthe Database field click on the drop down arrow and select the database type 4 Click on the Apply button to save changes By clicking on the Table Detail tab on this dialog you can access the Columns dialog 134 or Operations dialog 47 or you can Generate DDL 14 for this table Code Engineering Using UML Models Set Table Properties 126 General Table Detail Require Constraints Links Scenario Files Tagged Values DB Version MySql 10 2 10 Table Space USERS 3 3 1 Set Table Owner To define the owner of a table follow the steps below 1
162. per Directory Options 0 Create Package per Namespace gt Create Package per File Synchronization O Synchronize existing classes C Overwrite existing classes Remove Classes not found in code o Never delete Prompt for action D Always delete U 3 Select the options you require You can configure The source directory The source type The file extensions to look at Whether to recurse sub directories Whether to create a diagram for each package Whether to import additional files as described in the Import Component Types dialog Whether to exclude private members from libraries being imported from the model Whether to create a package for every directory namespace or file this might be restricted depending on the source type selected Whether to Synchronize or Overwrite existing Classes when found if a model Class is found matching the one in code Synchronize updates the model Class to include the details from the one in code which preserves information not represented in code such as the location of Classes in diagrams Overwrite deletes the model Class and generates a new one from code which deletes and does not replace the additional information How to handle Classes not found during the import Prompt for action enables you to review Classes individually 107 What is shown on diagrams created by the import 4 Click on the OK button to start 1998 2010 Sparx Systems Pty Ltd 9 Reverse Engineer
163. ponds To Attribute or operation within a Class The Classes this AspectJ intertype member belongs to stereotyped aspect Other Conventions e The specifications of a pointcut are included in the Behavior field of the method See Also e Import Source Code si e Generate Source Code 124 1 6 8 PHP Conventions Enterprise Architect supports the round trip engineering of PHP 4 and 5 where the following conventions are used Stereotypes Stereotype Applies To Corresponds To Tagged Values Tag Applies To Corresponds To attribute_name Operation with stereotype property The name of the variable behind this get or property set property final o Operations in PHP 5 The final keyword Common Conventions e An unspecified type is modeled as var 1998 2010 Sparx Systems Pty Ltd 81 Modeling Conventions PHP Conventions e Methods returning a reference are generated by setting the Return Type to var e Reference parameters are generated from parameters with the parameter Kind set to inout or out PHP 5 Conventions e The final Class modifier corresponds to the s Leaf property e The abstract Class modifier corresponds to the Abstract property e Parameter type hinting is supported by setting the Type of a parameter e The value of inout or out for the Kind property of a parameter corresponds to a reference parameter See Also e Import Source Code si e Generate Source Code 124 e PHP Options 5
164. r BYTE e For MySQL ENUM and SET datatypes in the Initial field type the values as a comma separated list in the format one two three or if one value is the default in the format one two reel default three 5 Click on the Column Properties button The Database Columns Properties dialog displays Basket BIGINT Column Properties AutoNum False StartNum 1 Increment 1 Zerofill False Unsigned False ok come If you require a sequence such as an Oracle sequence select the AutoNum property set the value to True and if necessary define the start number and increment Click on the OK button to return to the lt Tablename gt Columns dialog Code Engineering Using UML Models Create Columns 132 6 Click on the Save button and on either the New button to define another column or the Close button to exit from the dialog Change the Column Order To change the column order follow the steps below 1 On the Columns dialog highlight a column name in the Columns panel 2 Click on the EN button to move the column up one position RB button to move the column down one position 1998 2010 Sparx Systems Pty Ltd 133 Create Oracle Packages 3 5 Create Oracle Packages To create an Oracle package follow the steps below 1 Open the project in the Project Browser and create an Enterprise Architect package and if required a Cla
165. r each Enterprise Architect user using the Local Paths 397 dialog select the Settings Local Paths menu option As well as generating code and reverse engineering you can use local paths in version control developing XML schemas and generating RTF and HTML reports Local paths take a bit of setting up but if you want to work collaboratively on source and model concurrently the effort is well worth while For example developer A stores their java files in a C Java Source directory while developer B stores theirs in D Source Meanwhile both developers want to generate and reverse engineer into the same Enterprise Architect model located on a shared or replicated network drive Developer A might define a local path of JAVA_SOURCE C Java Source All Classes generated and stored in the Enterprise Architect project are stored as JAVA_SOURCE i lt xxx java gt Developer B now defines a local path as JAVA_SOURCE D Source Now Enterprise Architect stores all java files in these directories as WJAVA_SOURCE lt filename gt On each developer s machine the filename is expanded to the correct local version 1998 2010 Sparx Systems Pty Ltd 39 Code Engineering Settings Local Paths Dialog 1 4 3 Local Paths Dialog The Local Paths dialog enables you to set up local paths for a single user on a particular machine For a description of what Local Paths are used for see the Local Paths 387 topic To ope
166. ramework consists of a number of base templates Each base template transforms particular aspects of the UML to corresponding parts of object oriented languages The following table lists and briefly describes the base templates used in the CTF Used by the Class template to generate a base Class name in the inheritance list of a derived Class where the base Class doesn t exist in the model of a derived Class where the interface doesn t exist in the model this corresponds to the header file Linked Attribute A top level template for generating attributes derived from UML Associations Linked Attribute Notes Used by the Linked Attribute template to generate the attribute notes Linked Attribute Used by the Linked Attribute template to generate the attribute declaration Declaration Linked Class Base Used by the Class template to generate a base Class name in the inheritance list of a derived Class for a Class element in the model that is a parent of the current Class Linked Class Interface Used by the Class template to generate an Interface name in the inheritance list of a derived Class for an Interface element in the model that is a parent of the current Class Namespace A top level template for generating namespaces from UML packages Although not all languages have namespaces this template can be used to generate an equivalent construct such as packages in Java Namespace Body Used by the Namespace template to generate the b
167. ration Define an Enumerated Type An enumeration stereotyped Enumeration element Struct Define a Structure A struct stereotyped Class element SystemC Features Define a SystemC Port An sc_port stereotyped attribute Signal Define a SystemC Signal An sc_signal stereotyped attribute Constructor Define a SystemC Constructor An sc_ctor stereotyped method See Also e Import Source Code si e Generate Source Code 124 e SystemC Language Options 537 O 1998 2010 Sparx Systems Pty Ltd 83 Modeling Conventions VB Net Conventions 1 6 11 VB Net Conventions Enterprise Architect supports round trip engineering of Visual Basic Net where the following conventions are used Earlier versions of Visual Basic 87 are supported as a different language Stereotypes wen CET CEET CON CT TT CET CN CTN property Operation A property possibly containing both read and write code Tagged Values Applies To Corresponds To Alias Operation with stereotype import The alias for this imported operation attribute_name Operation with stereotype property The name of the variable behind this property Charset Operation with stereotype import The character set clause for this import One of the values Ansi Unicode or Auto delegate The Delegate Keyword Operation with stereotype property The datatype that this property is represented as CC CI IN DEELER en CE IT E EEC ECT stares COCOS ETT
168. rdinality of the association Note If the direction of the association is unspecified the owner is assumed to be the source Generalization For single inheritances an extension element is generated with the base attribute set Inheritance to the base Classname The UML attributes of the child Class are then appended to an all model group within the extension element Code Engineering Using UML Models XML Schema XSD Model XSD 100 UML Construct Default XSD Production Rules enumeration st A simpleType element is declared for the enumeration Class with the name attribute set to the Classname A restriction element is generated with base set to string Each of the Class attributes is appended to the restriction element as XSD enumeration elements with value set to the UML attribute name Any type specification for the UML attributes is ignored by the schema generator 2 1 2 Generate XSD The Generate XML Schema feature forward engineers a UML Class model to a W3C XML Schema XSD file An XML schema corresponds to a UML package in Enterprise Architect therefore XML schema generation is a package level operation To generate an XML schema from a package follow the steps below 1 Inthe Project Browser right click on the package to be converted to XSD The context menu displays 2 Select the Code Engineering Generate XML Schema menu option The Generate XML Schema dialog displays showing the nam
169. ritical for the development of a complete Service Oriented Architecture SOA and the coupling of UML 2 1 and XML provides the natural mechanism for specifying constructing and deploying XML based SOA artifacts within an organization The following topics explain how to work with these technologies using Enterprise Architect e XML Schema XSD 89 e Web Services WSDL 108 O 1998 2010 Sparx Systems Pty Ltd 89 XML Schema XSD 2 1 XML Schema XSD XSD Enterprise Architect supports Forward and Reverse engineering of W3C XML schemas XSD The following topics explain how to use Enterprise Architect to model generate and import XML schemas e Model XSD s e Import XSD 102 e Generate XSD 1007 2 1 1 Model XSD XML schemas are modeled using UML Class diagrams The XML Schema pages of the Enterprise Architect UML Toolbox see Using Enterprise Architect UML Modeling Tool provide in built support for the UML profile for XSD This enables an abstract UML Class model to be automatically generated as a W3C XML Schema XSD file The following Class diagram models simple schema for an example Employee Details system intended to store a company s employee contact information The Classes shown form the EmployeeDetails package The UML attributes of the Classes map directly to XML elements or attributes Note that the Classes have no methods since there is no meaningful correspondence between Class
170. rprise Sybase ASE Notes e You can download SQL Server 2005 data types and SQL Server 2008 data types from the Resources page of the Sparx Systems web site e Firebird 1 5 database tables can be modeled and generated as InterBase tables Firebird tables can be imported but are treated as InterBase tables Typical Tasks Typical tasks you can perform when modeling or designing databases include e Create a Data Model Diagram 1221 e Create a Table 125 e Set Properties of a Table 124 e Create Columns 1301 e Create Oracle Packages 133 e Create Primary Keys 134 e Create Foreign Keys 13A e Create Stored Procedures 1431 e Create Views 145 e Create Indexes Check Constraints and Triggers 14 e Generate DDL for a Table 145 e Generate DDL for a Package ai and compare with the database e Convert Datatypes for a Table 155 e Convert Datatypes for a Package 156 e Customize Datatypes for a DBMS 158 e Import a Database Schema from an ODBC Data Source 160 Code Engineering Using UML Models A Data Model Diagram 122 3 1 A Data Model Diagram An example of a Data Model diagram is provided below showing three tables that are linked on primary to foreign key pairs with associated multiplicity Note the use of stereotyped operations for Primary PK and Foreign FK keys Operations could also be added for e Triggers 147 e Constraints 147 check unique e Indexes 147 Dsts model
171. rt XSD 102 XML Schema Model XSD 89 XSD 89 XSD Datatype Packages 97 Code Generation ActionScript Language Options 43 Ada 2005 Language Options 43 C Language Options 44 C Language Options 45 C Language Options 46 Delphi Language Options 47 From Activity Diagrams 19 27 From Behavioral Models 19 From Interaction Diagrams 19 26 From Sequence Diagrams 19 26 From State Machine Diagrams 19 Java Language Options 51 Language Options 42 MDG Technology Language Options 58 PHP Language Options 51 Python Language Options 52 SystemC Language Options 53 VB NET Language Options 54 Verilog Language Options 55 VHDL Language Options 56 Visual Basic Language Options 57 Code Sections Synchronize 67 Code Template Base Templates 62 Editor 64 Framework Overview 61 Overview 61 Collaborative Development 38 Collection Classes Set 41 Column Create In Data Modeling 130 Definition 130 In UML Data Modeling Profile 130 Order Change 130 Properties 130 Sequence Entries 130 Stereotyped Attribute 130 Unique 130 Compare DDL With Database 151 Composite Foreign Key 137 Create Check Constraint 147 Columns In Data Modeling 130 Foreign Key 137 Index Data Modeling 147 Primary Key 134 Primary Key Name Template 134 Sorted Lookup Table 147 Table in Data Modeling 123 Trigger Operation 147 Unique Constraint 147 View 145 CTF Overview 61 D Data Modeling Check Constraint 147 Compare DDL With Database 151 Create C
172. s Code Engineering Using UML Models Foreign Key Create Foreign Key 140 Name FK_Table2_Table1 Source Table2 Target Tablei Column t2_date t2_id PK unique t2_pk t2_name Source Referential Integrity Delete Cascade Update Cascade tiid int ti_name varchar ti_data_created datetime 4 Im This creates the composite Foreign Key The example below shows how this looks in a diagram 1998 2010 Sparx Systems Pty Ltd 141 Foreign Key Create Foreign Key column PK t1_id int PK t1_name varchar 50 PK ti_dsts_ crested datetime PK PK_Table1 int varchar datetime PK_Tablet 1 Composite key columns are A lil 5 A AAA A eee ae sorted so the foreign key 12_name ti_nsme FK datatypes match the primary t2_dste ti1_dsts_crested key datatypes FK_Table2_Table1 lo column FK t2_date dstetime FK t2_id int PK 12 pk int FK t2_name varchar 50 FK FK_Table2_Table1 int varchar datetime PK PK_Table2 int 3 7 2 Define Foreign Key Name Template To define the name template for a Foreign Key follow the steps below 1 Select the Tools Options Source Code Engineering Code Editors menu option The DDL page of the Options dialog displays Code Engineering Using UML Models Foreign Key Define Foreign Key Name Template 142 DDL DDL Editor
173. s SW Code Generation State Machine Diagrams private void initalizeStateMachine currState StateType ProcessOrder_New nextState StateType ST_NOSTATE currTransition TransitionType TT_NOTRANSITION private void runStateMachine while true if currState StateType ST_NOSTATE currTransition TransitionType TT_NOTRANSITION StatesProc currState CommandType Do then check if there is any valid transition assigned after the do behavior if nextState StateType ST_NOSTATE if currTransition TransitionType TT_NOTRANSITION break break TransitionsProc currTransition if currState nextState StatesProc currState CommandType Exit StatesProc nextState CommandType Entry currState nextState 1 3 2 State Machine Modeling For HDLs Note To be able to generate code from behavioral models all behavioral constructs should be contained within a Class For efficient code generation from State Machine models into Hardware Description Languages HDL such as VHDL Verilog and Systems C apply the design practices outlined in this topic In an HDL State Machine model the following are expected e Designate Driving Triggers e Establish Port Trigger Mapping e Active State Logic Designate Driving Triggers The top level State Machine diagram should be used to model the different modes of a hardware component and the associated tri
174. s Follow the steps below 1 Select the Tagged Values tab of the table Properties dialog The Tagged Values tab shows the tags for the table 2 Click on the New Tag button 3 Define the table properties as shown in the examples below The Tagged Value dialog displays Tag INITIAL Value 65536 a Tag PCTFREE Value 10 A 4 Click on the OK button to save the Tagged Value All available properties for an Oracle table are listed below Code Engineering Using UML Models Set Table Properties Set Oracle Table Properties 128 Note The same properties can be added to indexes and constraints 147 Highlight the index or constraint and add the properties as Tagged Values The properties defined for a given table are listed on the Tagged Values tab as illustrated by the following typical Tagged Value list O 1998 2010 Sparx Systems Pty Ltd 129 Set Table Properties Set Oracle Table Properties COMPRESSION DBVERSION INITIAL INITRANS LOGGING MAXEXTENTS MAXTRANS MINEXTENTS MONITORING OWNER PARALLEL PCTFREE PCTINCREASE PCTUSED TABLESPACE DEFAULT NOCACHE DISABLED 10 2 10 65536 1 LOGGING 2147483645 255 1 MONITORING PL SOL NOPARALLEL 10 Code Engineering Using UML Models Create Columns 130 3 4 Create Columns What is a Column The basic organizational element of a relati
175. s TABLE t_diagram TABLE t_diagramlinks TABLE t_diagramobjects TABLE t_diagramtypes TABLE t_document TABLE t_ecf TABLE t_efforttypes TABLE t_files TABLE t_genopt TARIE ninecans Highlight the tables and stored procedures to import and clear those you do not require Selection shortcuts e To select all tables and procedures click on the Select All button e To clear all tables and procedures click on the Select None button e Hold down Ctrl while clicking on tables and procedures to select multiple objects e Hold down Shift and click on tables and procedures to select a range When you have selected the tables and procedures click on the OK button 3 16 3 The Imported Class Elements When you import DDL table definitions they are converted to stereotyped Classes according the UML Data Modeling Profile The image below shows some example tables imported into the model using an ODBC data connection Code Engineering Using UML Models Import Database Schema from ODBC The Imported Class Elements 164 t_attributeconstraints column column Object_ID Long Object_ID Long Constraint Text 50 Name Text 255 AttName Text 50 Scope Text 50 Type Text 50 Stereotype Text 50 Notes Memo Containment Text 50 ID Long IsStatic Long Defsult Text 255 IsCollection Long IsOrdered Long t clients AlowDuplicates Long LowerBound Text 50 column UpperBound Text 50 Na
176. sed e Data source behavior e Creatable Code Engineering Using UML Models Code Engineering Settings Language Options 58 Collection dass for 1 associations VB Specifications Disable Language Options for the current model D Default Version 6 0 Default Extension cls Multiuse True Persistable False Data Binding Behavior False Data Source Behavior False Global Namespace False Creatable True Exposed False MTS Transaction Mode 0 NotAnMTSObject Options for the current user Default Attribute Type Variant e Collection Classes 1 4 6 15 MDG Technology Language Options If you have loaded an MDG Technology that specifies a code module into your Sparx Systems gt EA gt MDG Technologies folder see the MDG Technologies in SDK section of SDK For Enterprise Architect the language is included in the Source Code Engineering list on the Options dialog The language is only listed on the Options dialog if an MDG Technology file actually uses it in your model The options for each language are based on what is defined in the technology code module but are limited to the following Default Extension e Default extension for generated source files e Shown if the option is in the technology e Saved per project Import File Extensions e Default folder to import source files from e Shown if there is a grammar set in the technology e Saved once for all projects Generate Namespaces e Optio
177. shown as examples Conditional Statements To model a conditional statement you use Decision Merge nodes Alternatively you can imply Decisions Merges internally The graph optimizer expects an associated Merge node for each Decision node to facilitate efficient tracking of various branches and analysis of the code constructs within them The following diagram is interpreted as a nested IF statement Code Engineering Using UML Models Code Generation From Behavioral Models Code Generation Activity Diagrams 28 loadAccountDetails Account boolean bRet UserName name Password password Valid Password InvalidUser bRet false Invalid Password bRet false Set User Status ActivityFinal The Java code that might be generated from this diagram is as follows public boolean doValidateUser String Password String UserName loadAccountDetails boolean bRet if Username name if Password password bRet true bValidUser true bRet false else 1998 2010 Sparx Systems Pty Ltd 29 Code Generation From Behavioral Models Code Generation Activity Diagrams return bRet bRet false Invocation Actions Call Operation Action Call Behavior Action Call Actions are handled more efficiently Each action has arguments relating to the parameters of the associated behavior use the Syn
178. ss diagram Add a Class element to either the package or the diagram Open the Properties dialog for the element and in the Stereotype field type the value Package For the package specification create an Operation with the name Specification and with no return type Open the Properties dialog for the Specification Operation and on the Behavior tab type the entire package specification into the Initial Code field For the package body create an Operation with the name Body and with no return type Open the Properties dialog for the Body Operation and on the Behavior tab type the entire package body into the Initial Code field aor oN N o For information on the objects mentioned above see the Work With Elements section of UML Modeling With Enterprise Architect UML Modeling Tool Code Engineering Using UML Models Primary Key 134 3 6 Primary Key What is a Primary Key Keys are used to access tables and come in two varieties Primary Keys and Foreign Keys A Primary Key uniquely identifies a record in a table while a Foreign Key 137 accesses data in some other related table via its Primary Key Define a Simple Primary Key If a Primary Key consists of a single column it is very easy to define 1 Right click on the table in a diagram to display the context menu Select the Attributes menu option 2 Inthe Attributes dialog select the column that makes up the Primary Key 3 Select the Primary K
179. st set the Object Oriented Support option to True on the C Specifications 441 page of the Options dialog Stereotype ares ows CET EE typedef Class A typedef statement where the parent is the original type name fo Attribute A keyword union in variable definition 1998 2010 Sparx Systems Pty Ltd 73 Modeling Conventions C Conventions Tagged Values Applies To Corresponds To anonymous Class with stereotype of The name of this Class being defined only by the enumeration struct or union typedef statement bodyLocation Operation The location the method body is generated to Expected values are header classDec or classBody define Attribute define statement typedef Class with stereotype of This Class being defined in a typedef statement enumeration struct or union Object Oriented C Code Generation for UML Model The basic idea of implementing a UML Class in C code is to group the data variable UML attributes into a structure type This structure is defined in a h file so that it can be shared by other classes and by the client that referred to it An operation in a UML Class is implemented in C code as a function The name of the function must be a fully qualified name that consists of the operation name as well as the Class name to indicate that the operation is for that Class A delimiter specified in the Namespace Delimiter option on the C Specifications 441 page is used to joi
180. steps below 1 Right click on the package in the Project Browser to display the context menu 2 Select the Code Engineering Reset DBMS Options menu option The Manage DBMS Options dialog displays 7 Convert DBMS Type o Curent DBMS MSAccess Wi New DBMS Oracle Wi Change Table Owner Current Owner x New Owner Process Child Packages 3 Inthe Current DBMS field click on the drop down arrow and select the current DBMS In the New DBMS field click on the drop down arrow and select the target DBMS 4 Select the Convert DBMS Type checkbox 5 If there are child packages that also require changing select the Process Child Packages checkbox 6 Click on the OK button All tables in the selected packages are mapped to the new DBMS To change the owner of the table or all of the tables in a package follow the steps below 1 Right click on the package in the Project Browser to display the context menu 2 Select the Code Engineering Reset DBMS Options menu option The Manage DBMS Options dialog displays 1998 2010 Sparx Systems Pty Ltd 157 Data Type Conversion for a Package E Convert DBMS Type Current DBMS Oracle New DBMS x Y Change Table Owner Current Owner lt All gt y New Owner Andrew Loyd E Process Child Packages 3 Inthe New Owner field type the name for the new table owner
181. suffix _Code_Templates lf no templates exist for a language there is no entry for the language in the dialog Synchronize Code Enterprise Architect uses code templates during the forward synchronization of the following programming languages e ActionScript e C e C e CH e Delphi e Java e PHP e Python o VB e VB Net Only a subset of the code templates are used during synchronization This subset corresponds to the distinct sections that Enterprise Architect recognizes in the source code The following table lists the code templates and their corresponding code sections which can be synchronized Operation Notes Impl As for Operation Notes AS tor Operation Notes Operation Declaration Operation Declaration Impl Three types of change can occur in the source when it is synchronized with the UML model 1998 2010 Sparx Systems Pty Ltd 67 Code Template Framework Synchronize Code e Synchronize Existing Sections 67 for example changing the return type in an operation declaration e Add New Sections to Existing Features 6 for example adding notes to a Class declaration where there were previously none e Add New Features and Elements 6 for example adding a new operation to a Class Each of these changes must be handled differently by Enterprise Architect their effect on the CTF is described in the linked topics above 1 5 3 1 Synchronize Existing Sections When an existing s
182. supports round trip engineering of C where the following conventions are used Stereotype EC oe typedef Inner Class A typedef statement where the parent is the original type name Po Attribute A keyword union in variable definition Tagged Values Class also containing the The name of this class being defined only by Code Engineering Using UML Models Modeling Conventions C Conventions 72 Po Tagged Value typedef the typedef statement bodyLocation Operation The location the method body is generated to Expected values are header classDec or classBody typedef Class with stereotype other This Class being defined in a typedef than typedef statement C Code Generation for UML Model CN CO CIN A pair of C files h c File name is the same as Class name Operation public amp Function declaration in h file protected and definition in c file Operation private Function definition in c file MA only Attribute public amp protected Variable definition in h file VA Attribute private Variable definition in c file Inner Class without N A This inner Class would be ignored stereotype See Also e Import Source Code si e Generate Source Code 1 e C Options Ai 1 6 3 1 Object Oriented Programming In C The following conventions are used for Object Oriented programming in C To configure Enterprise Architect to support Object Oriented programming using C you mu
183. t child relations XSDgroup UML Class Construct Description An XSDgroup is generated for Classes with this stereotype Tagged dee Overrides the default XSD model for generating this group Values sequence choice all definition Constraints A group Class can only associate itself to other group Classes A group Class can be associated by another group Class or a complexType Class The association should be via an Association connector A group Class cannot be inherited aggregated XSDtopLevelElement UML Class Construct Description Creates an lt xs element gt construct which acts as a container for XSDcomplexType and XSDsimpleType Class Tagged Values See the W3C XML Schema recommendation Constraints An XSDtopLevelElement Class can contain either an XSDsimpleType or an XSDcomplexType as its child Class When such a Class is present as its child all its inheritance is ignored This Class cannot be inherited XSDtopLevelAttribute UML Class Construct Description Creates an lt xs attributr gt construct which acts as a container for XSDsimpleType Class Tagged use Values optional required prohibited See the W3C XML Schema recommendation Constraints An XSDtopLevelAttribute Class can contain only an XSDsimpleType Class as its child Class When such a Class is present as its child all its inheritance is ignored O 1998 2010 Sparx Systems Pty Ltd 97 XML Sch
184. the Tools Options Source Code Engineering menu option 1998 2010 Sparx Systems Pty Ltd 33 Code Engineering Settings Source Code Engineering aa 3 ii DIA PO component Types Links D Replace overwrite existing source file Communication Colors R 4 XML Specifications Default Language for Code Generation C e E JEET Wrap long comment lines at 80 chars 1 no wrap Ee mg Auto Layout Diagram on Import On New Diagram v Sa Attribute Operations Output files use both CR amp LF d KI ActionScript Prompt when synchronizing reversing Comments ej c Remove hard breaks from comments on import Y Ca CH Auto generate role names when creating code Y d Generate c C Do not generate members where association Y Reverse Delphi J direction is Unspecified pas i Create dependencies for operation retums and gt PHP parameter types Python Remove prefixes when generating Get Set properties separate entries w viet Basic m sm nm bm Treat as suffixes Ada E Capitalized Attribute Name for Properties Use Is for Boolean property Get Sc SystemC y Code page f ing M i VHDL page for source editing Most of the settings are self explanatory The Remove prefixes when generating Get Set properties field enables you to specify prefixes used in your variable naming conventions if those prefixes shou
185. to the diagram The WSDL Message dialog displays Name sells ss Doamentation AAA UML L o Jl cae Il me 3 Type in the Name for the message 4 Click on the OK button to close the WSDL Message dialog 5 You can define parts for the message by dragging the Message Part 1161 element from the WSDL Elements page of the Enterprise Architect UML Toolbox onto the Message element You can edit the WSDL specific properties of the message later by double clicking the Message element in the diagram or Project Browser Alternatively on the WSDL Message dialog click on the UML button to invoke the standard Properties dialog for a Class This button does not display on the initial WSDL Message dialog for a new Message element 2 2 1 6 WSDL Binding WSDL bindings are represented in Enterprise Architect by UML Classes stereotyped as WSDLbinding Bindings should be defined under the Bindings package in the WSDL namespace structure Each WSDLbinding Class implements the operations specified by a particular WSDLportType interface Therefore WSDLportTypes should be defined beforel112 creating WSDLbindings To define new WSDLbinding elements for your namespace follow the steps below 1 Open the Overview diagram defined for your WSDL namespace package and double click on the Bindings package to open the Bindings diagram 2 Drag the Binding element from the Toolbox onto the diagram The WSDL Binding dialog displays Code E
186. vices a Y Services ta Services 9 OnlineBookstore H SJ OnlineBookstore Rae Co as a ca aaa c aa c aa c Go C a c Dad C Baa E a DI 1998 2010 Sparx Systems Pty Ltd 109 Web Services WSDL Model WSDL To create a new WSDL namespace in your model follow the steps below 1 Open or create the appropriate diagram 2 Select the More Tools WSDL menu option from the Enterprise Architect UML Toolbox 3 Drag the Namespace element from the Toolbox onto the diagram The WSDL Namespace Properties dialog displays WSDL Package Name E Target Namespace http www exampleURI com WSDLPackage 1 o _ cane me 4 Type in a WSDL Package Name and Target Namespace name You can edit these values later 5 Click on the OK button to create a package stereotyped as WSDLnamespace This contains the following sub packages and an Overview diagram to navigate between the sub packages e Types Contains the XSD types used by the WSDL Message elements this package is modeled as an XML Schemal 89 and you drag XSDelement 941 XSDsimpleType 9 and XSDcomplexType 9 elements onto the Types diagram from the XML Schema page of the Enterprise Architect UML Toolbox see Using Enterprise Architect UML Modeling Tool e Messages Contains the WSDL Messages modeled as UML Classes marked with the stereotype WSDLmessage e PortTypes Contains the WSDL Port Types modeled as UML interfaces marked wit
187. ware 230 languages including C OO C C Java VB Net VHDL Verilog and SystemC To experiment with code generation from these diagrams use the EAExample project provided with your Enterprise Architect installer SW Code Generation State Machine Diagrams do updateStatus setStatus OrderStatus New do updateStatus setStatus OrderStatus packed do updateStatus setStatus OrderStatus dispatched status OrderStatus delivered setStatus OrderStatus closed do updateStatus Code Engineering Using UML Models Code Generation From Behavioral Models SW Code Generation State Machine Diagrams 20 Note To be able to generate code from behavioral models all behavioral constructs should be contained within a Class A State Machine see the UML Dictionary in a Class internally generates the following constructs in software languages to enable effective execution of the States behaviors do entry and exit and also to code the appropriate transition s effect when necessary Enumerations e StateType comprises an enumeration for each of the States contained within the State Machine e TransitionType comprises an enumeration for each transition that has a valid effect associated with it for example ProcessOrder_Delivered_to_ProcessOrder_Closed e CommandType comprises an enumeration for each of the behavior types that a State can contain Do Entry Exit
188. work Code Templates 64 CodeTemplate File lt A 0 CodeTemplate CodeTemplate o a 2 y Ji Y i Ba 1 1 1 CodeTemplste CodeTemplate CodeTemplate ClassDeclaration 1 F i 7 E d gt Q ms E CodeTemplate CodeTemplate CodeTemplate Attribute i i Operation 1 1 1 1 1 1 1 1 CodeTemplate CodeTemplate CodeTemplate OperationNotes OperationDeclarati 7 SS E 1 1 CodeTemplate CodeTemplate CodeTemplate T 1 Di 2 F i A Note The above Class Model shows the hierarchy of Code Generation templates for a language such as C or Java The Aggregation connectors denote references between templates 1 5 2 The Code Template Editor The Code Template Editor provides the facilities of the Common Code Editor including intellisense for the various macros For more information on intellisense and the Common Code Editor see the Code Editors topic in Using Enterprise Architect UML Modeling Tool To access the Code Template Editor window select the Settings Code Generation Templates menu option 1998 2010 Sparx Systems Pty Ltd 65 Code Template Framework The Code Template Editor Language Template Java Z 1 fbases 3ClassInheritsi 2 tif bases lates New Language A 3 bases bases Name Modifie
189. xType Address You can change this default behaviour by selecting the Import global elements with Type posifix checkbox When you select this option Enterprise Architect treats the global element and the ComplexType it is referring to as two separate entities So for the above example Enterprise Architect creates an XSDtopLevelElement stereotyped Class for the global element and an XSDcomplexType stereotyped Class for the ComplexType and connects them as follows XSDcomplexType AddressType XSDtopLevelElement Address O 1998 2010 Sparx Systems Pty Ltd 105 XML Schema XSD Import XSD Note Enterprise Architect treats the following as two separate entities irrespective of whether the Import global elements with Type postfix checkbox is selected or unselected lt xs element name HomeAddress type AddressType gt lt xs complexType name AddressType gt lt xs sequence gt lt xs complexType gt Code Engineering Using UML Models Web Services WSDL 106 2 2 Web Services WSDL WSDL Enterprise Architect supports Forward and Reverse Engineering of the W3C Web Service Definition Language WSDL The following topics explain how to use Enterprise Architect to model generate and import WSDL files e Model WSDL 108 e Import WSDL 119 e Generate WSDL 117 2 2 1 Model WSDL The WSDL pages of the Enterprise Architect UML Toolbox see Using Enterprise Archit
190. y are formatted if they are e How property methods are recognized e f dependencies should be created for operation return and parameter types It is important to note that when a legacy system is not well designed simply importing the source into Enterprise Architect does not create an easily understandable UML model When working with a legacy system that is poorly designed it is useful to break down the code into manageable components by examining the code elements individually This can be achieved by importing a specific Class of interest into a diagram and then inserting the related elements see UML Modeling with Enterprise Architect UML Modeling Tool at one level to determine immediate relationship to other Classes From this point it is possible to create Use Cases that identify the interaction between the legacy Classes enabling an overview of the legacy system s operation Copyright ownership is an important issue to take into account when undertaking the process of reverse engineering In some cases software might have specific limitations that prohibit the process of reverse engineering It is important that a user address the issue of copyright before beginning the process of reverse engineering code Situations that typically lend themselves to reverse engineering source code include source code that e You have already developed e ls part of a third party library that you have obtained permission to use e ls part of a framework
191. y supported by Enterprise Architect The CTF consists of e Default Code Templates e which are built into Enterprise Architect for forward engineering supported languages e A Code Template Editor 6 for creating and maintaining user defined Code Templates also see SDK for Enterprise Architect e Code templates to synchronize code eg 1 5 1 Code Templates Code templates enable you to customize code generation of existing languages For example e Modify the file headers created when generating new files e Change the style of the generated code such as indenting or brace position to match the required coding standards e Handle particular stereotypes to generate things like specialized method bodies and extra methods They also enable you to add code generation of entirely new languages that Enterprise Architect would otherwise not be able to handle In this situation it is most useful to combine code templates with an MDG technology file that includes the datatypes and options for default file extensions See the Create MDG Technologies topic in SDK for Enterprise Architect Enterprise Architect s base code templates 627 specify the transformation from UML elements to the various parts of a given programming language The templates are written as plain text with a syntax that shares some aspects of both mark up languages and scripting languages A simple example of a template used by Enterprise Architect is the Class template

Download Pdf Manuals

image

Related Search

Related Contents

Message from the Postgraduate House Student Housing Dear  iStarUSA WN158  BL600 Development Kit  PDF - 576kB - TLC Direct  Portátil y Autónomo MICROSCOPIO DIGITAL LCD  

Copyright © All rights reserved.
Failed to retrieve file