My Profile
Help
Hot Topics
Top Community Contributors
Displaying items by tag: dotnet
Using the Database Builder to import a DB Schema as enumerations classes
As part of an EA add'in implementation, I had to import all Enterprise Architect table and column names in enumeration classes.
Having access to a database that stores a Sparx Systems Enterprise Architect project (e.g. MySQL, SQL Server, or even an EAP file via ODBC), there was a number of ways to populate enumeration classes with literal values using a small application in C# or another programming language. As Enterprise Architect 12 includes the Database Builder, an integrated tool to work on DB schemas, I took the opportunity to use it. Compared with the result of a C# application, this feature would let me capture the enumeration classes in my EA modelling project in addition to generating C# enumeration classes in my add'in solution.
This article only covers a small portion of Sparx EA Database Builder features: it illustrates how I managed to import Enterprise Architect table names as literal values in the EADBTableType enumeration class, and their column names as literal values in separate enumeration classes e.g. t_diagramColumnType, t_objectColumnType...
Import all tables in Enterprise Architect
- Open the menu Tools > Database Builder
- Right click and select New Data Model:
- Select the DBMS used, e.g. MySQL and confirm Ok
- Right click on MySQL > Load
- Right click on Connections > Add new DB connection
- Open the new DB connection and select ODBC based datatype
- Select an existing ODBC DSN (or create one) to the DB that stores the Enterprise Architect project where the schema needs to be imported
- Right click on MySQL > Import DB Schema from ODBC
- Click on Import and select all tables:
- All tables, columns, primary keys, foreign keys, indexes, etc. have been imported.
- Go back to the Database builder and open the Tables tabs: all tables are displayed. Selecting one of the tables provides access to all columns' details.
Generate the enumeration classes
The Database Builder let me achieved what I needed. Having all tables and columns stored in a single package, I wrote a simple script to perform the following:
- create an enumeration class named EADBTableType
- for each table:
- create a literal value with the table name in EADBTableType e.g. t_object
- create an enumeration class named after the table based on the following format: <table name>ColumnType e.g. t_attributeColumnType
- for each column in the table:
- create a literal value with the column name in the current table's enumeration class (e.g. Classifier in t_attributeColumnType)
Having executed this script, the following enumeration classes have been generated:
Transform enumeration classes to dotNet C# classes
The MDA model transformation can be used to generate C# enumeration classes for the above enums:
- Right click on the package that contains all enums > Advanced > Transform Package
- Select C# as the target, select the package, and click on Do Transform
- Having all C# enumeration classes created, and making sure the namespace is correct (e.g. create packages myaddin.common.enums), the code can be generated: right click on package > Code Engineering > Generate Source Code.
- The generated code can be used in Visual Studio IDE:
EA User Group 2014: smart use cases, code generation tool, EA11 cloud services, RAS and OSLC
Last May I went to the European EA User Group in the UK (Maidenhead) where the Enterprise Architect community gathered. Prior to delivering my presentation on the alternatives to set up a shared Enterprise Architect project, I attended several presentations, including the following ones that are covered in this article:
- Pragmatic agile model driven development using smart use cases by Sander Hoogendoorn (Capgemini, NL)
- Enterprise Architect Version 11 Cloud Services, OSLC and RAS by Phil Chudley (Dunstan Thomas, UK)
Pragmatic agile model driven development using smart use cases
Sander Hoogendoorn shared the use of smart use cases, coupled with Enterprise Architect and a custom-made code generation tool, Tobago MDA.
Smart Use Cases
Sander and his team at Capgemini developed their own agile process, called SMART, which involves the use of smart use cases to capture and manage functional requirements, as explained hereafter. Note: the SMART agile process has been applied over the past 10 years; it is based on agile and iterative best practices.
Smart use cases match « sea » and « fish » granularity use cases according to the following levels defined by Alistair Cockburn in his book "Writing Effective Use Cases":
Where traditional use case modeling can lead to several pages of documentation, including triggers, pre/post conditions, actors, main/alternative scenarios, and so on, smart use cases maintain a visual deliverable via use case diagrams as each use case is detailed by several smaller use cases connected with “extends” and “includes” associations (smart use cases can be reused amongst use cases). On average, a “standard” use case is associated with 20 smart use cases.
Stereotypes have been created to choose the type of a smart use case from a list of identified patterns: select, search, manage, file import or export, validation service, etc. Smart use cases also serve estimation purposes. An estimation value has been defined on the smart use case stereotypes to provide a default value (from 1 to 10 points) according to the selected type (e.g. 2 points for a “select” smart use case). This enables accessing all the information from our models and diagrams as illustrated below:
Here is another example with UI smart use cases in yellow and a Service smart use case in red, alongside their respective estimation points.
Project Management Dashboard
In order to manage the project according to the smart use cases defined in Enterprise Architect, www.speedbird9.com website has been created by Sander and his team. This site makes it possible to import/export smart use cases with Enterprise Architect via XMI or CSV files for planning and progress management.
Here is an illustration where smart use cases have been imported from Enterprise Architect:
Tobago MDA code generation tool
Sander released with his team Tobago MDA, a code generation tool built for smart use cases defined in Enterprise Architect. This tool generates source code based on templates, making it possible to define the content required by any programming language (e.g. dotNet C#, Java, PHP…). Tobago MDA is shipped with pre-defined templates used by Capgemini for different types of projects including Java, .Net, PowerBuilder (Sybase – SAP), and BI. Tobago MDA has been used in dotNet projects to produce 100% of the code for average use cases.
The Tobago templates are easy to understand text files. Syntax mechanisms built for these templates include tags and methods e.g. to loop on a class attributes, test an empty value, etc. Tobago MDA can access the Enterprise Architect models using an XML file created via an XMI export, or by connecting directly to an Enterprise Architect project without having to open Enterprise Architect.
The presentation ended with a demonstration; Sander created in the Enterprise Architect project a “search” smart use case to add a new Search feature for an existing dotNet web application. Once the model was updated, Tobago was launched to generate new C# files. Then Visual Studio was used to re-build the application. Finally the app was run to show that a new search feature was available, with criteria matching the attributes entered in the smart use case.
Tobago MDA is available from the following site: www.smartusecase.com.
New Enterprise Architect 11 features: Cloud Services, RAS, OSLC
Phil Chudley from Dunstan Thomas gave us an efficient speech and demo based on his in-depth trial of new Enterprise Architect 11 features: Cloud Services, OSLC, and Reusable Asset Service.
Cloud Services
Cloud Services makes it possible for Enterprise Architect 11 users to access Enterprise Architect projects from anywhere via the http/https protocols. As a result an Enterprise Architect project can be either accessed from the LAN or from the Internet. Cloud services provide short response times to suit slow remote access.
Cloud Services are available to download for free from Sparx Systems website. It can be installed as a Windows Service or integrated with an existing IIS web server. Installation includes a management client software. Setting up a user access to a project is very easy; only the url and credentials are required (compared with a project hosted on a local database requiring an ODBC connector driver and the connection string to the DB).
Note: this service doesn’t work with EAP files i.e. a DBMS must be used.
Note: Sparx Cloud Services mustn’t be confused with hosting services in the Cloud, such as a MS Azure SQL Database available online, since they aim at providing access to locally hosted Enterprise Architect projects from the Internet.
Once installed, the management software can be used to expose to the outside world one or several Enterprise Architect projects, as per the provided configuration including: http or https protocol, authentication mode, read-only access enabled/disabled, and setting any limitation on the max number of concurrent users. This software also displays the currently opened projects via the Cloud Services.
http connection to Enterprise Architect models has enabled Sparx Systems to provide additional features: OSLC and RAS.
OSLC: Open Services for Lifecycle Collaboration
The Open Services for Lifecycle Collaboration (OSLC) is an open community that has defined a set of specifications to enable integration of software development, e.g. to let Application Life-cycle Management (ALM) and Product Life-cycle Management (PLM) software communicate and exchange information.
Enterprise Architect 11 currently supports OSLC to access and manage requirements only. Requirements can be accessed with an XML content through the use of urls from a browser. A client application can be implemented to access web services from Sparx Enterprise Architect in order to run queries or create new requirements.
Examples: Query -> http://server-name:port/repository-name/oslc/qc/?oslc.where=ss:type=“Functional”, Create -> http://server-name:port/repository-name/oslc/cf/
Note: it is currently possible to test OSLC queries from online SparxSystems Enterprise Architect projects, as illustrated below: http://sparxcloud.co.uk/Example/oslc/qc/
With the following url, results are limited to « Chuck Wilson » author: http://sparxcloud.co.uk/Example/oslc/qc/?oslc.where=dcterms:creator=%22Chuck%20Wilson%22
RAS: Sparx Systems Reusable Asset Service
Reusable Asset Service or RAS is intended to let various teams integrate in their respective Enterprise Architect projects distributed and reusable models/resources, stored in a central Enterprise Architect project, acting as a library or framework. Users may update the reusable assets and resources from Enterprise Architect providing they have a write access.
To use RAS, an Enterprise Architect project must be set up in a central database (e.g. MySQL, SQL Server…), with access via http using Sparx Cloud Services, where reusable models will be created and published. Users can access its content using the RAS feature from another Enterprise Architect project.
Provided a user has a write access, a package that for instance contain a class model for a Bookstore can be added to the shared and reusable project.
Once this is done, other teams of users can open the RAS model and import the published package to use it. Phil pointed out during his demo that management of dependencies between packages in RAS should be improved.
It seems to me that this feature could especially be useful and applied for a project Framework, or to let standards organizations publish and share their models for anyone to use in their Enterprise Architect project.
Conclusion
This year’s EA User Group has really been interesting thanks to the content delivered during the presentations. It has also been an opportunity to meet and exchange with other Enterprise Architect users and experts.
Official EA User Group website: www.eausergroup.com.