sparxsystems

sparxsystems

Sparx Systems


99 Albert Street
Creswick,
Victoria
3363
Australia
P: +61 3 5345 1140
F: +61 3 5345 1104
 
Sparx Systems specializes in high performance and scalable visual modeling tools for the planning, design and construction of software intensive systems. A Contributing Member of the Object Management Group (OMG), Sparx Systems is committed to realizing the potential of model-driven development based on open standards. The company’s flagship product, Enterprise Architect, has received numerous accolades since its commercial release in August, 2000. Enterprise Architect is the design tool of choice for over 740,000 registered users worldwide.

Overview

When planning resource utilization for a large project, the task allocation details can be defined against each element in the project and assigned to a resource (a staff member).  This process can be completed in Enterprise Architect or MS Project.  This script provides support to exchange project details between Enterprise Architect and MS Project.  If resource utilization has already been defined external to the model, this script allows you to easily import the details into your Enterprise Architect Repository.

Import

The import script imports Tasks from MS Project and creates a tree of Elements within a Package. This element-tree reflects the MS Project task-tree structure being imported. You can then view the project management details using Enterprise Architect's Gantt chart view.

Export

The export script parses a tree of Packages and Elements and creates a hierarchical tree of Tasks in the MS Project.

Requirements

You need to have the following installed on your machine:

  • Enterprise Architect, version 9.2 or later
  • Microsoft Project

How to Use the Script

The attached repository contains two scripts called "Import from MS Project" and "Export to MS Project". These are implemented as "Package Scripts" that can be conveniently run using the Context Menu of Enterprise Architect's Project Browser.

Importing a file from MS Project:

  1. Open the attached repository in Enterprise Architect
  2. Select the Package named "Imports" in the Project Browser (or create and select your own Package for this purpose)
  3. Right-click on the Package
  4. Select Scripts | Import from MS Project from the context menu

You will be prompted to select the directory that contains the source MS Project File (*.mpp).

After the Project file is imported, you can:

  • Open the Package diagram
  • Check the diagram is set to Gantt View.

To view a diagram using the Gantt Chart View:

  1. Right-click on the Package diagram
  2. Select Gantt View from the context menu

Note: To make this the default setting for this diagram, set the option via the menu: Diagram | Properties | Digram | [x] Always open as Gantt.

Exporting a Package to MS Project:

  1. Open the attached repository in Enterprise Architect
  2. Select the Package named "Use Case Model" in the Project Browser
  3. Right-click on a Package
  4. Select Scripts | Export to MS Project from the context menu

You will be prompted to select the directory that contains the source MS Project File (*.mpp).

Wednesday, 11 January 2012 01:39

Model Simulation - A Simple Cafe Model

Model Simulation

The zip file below contains a State Machine and a Sequence Diagram that model the operation of a simple Cafe. The file has been used to create video demonstrations of Enterprise Architect simulation capability. Exploring this model may help you to get started using simulation in Enterprise Architect.

You may wish to view the video Creating a Sequence Diagram, which contains footage that illustrates how to simulate a sequence diagram using Enterprise Architect.


When updating a legacy data model, say as part of a transformation or modernization project, it can be beneficial to start redesigning from the logical or conceptual level. This also applies when the data model is used as the basis for other aspects of project development, such as generating a class model, or deriving user interface or form designs.

A common starting point is a physical data model perhaps derived from reverse engineering a database. With all it's platform-specific details, you'll want to automatically derive an abstract (platform independent) representation.

In this post we provide two MDA transformation templates for Enterprise Architect that can help you do this:

  • The Physical to Logical transform

This takes a Physical level model of any DBMS, and transforms it to the Logical level – eliminating Primary Keys, Foreign keys, Identifiers and simplifying the Field types to standard UML typing.

  • Logical to Conceptual transform

This simplifies the Logical diagram by removing the Attributes to give the simple Entities and their relationships.

 

Also attached is an update for the Logical to Physical DDL transform built into Enterprise Architect. The update:

  • Allows for modeled Enumerations to be generated to script for MySQL
  • Sets a Primary Key in the Join tables created by the transformation.

 

Set up

To use the scripts unpack the attached zip folder.

To load the transform scripts into a model, select from Enterprise Architect's main menu:

Project | Model Import Export | Import Reference Data

 

Using the Select File button, choose the XML file to import. Then under Select Datasets to Import, choose the template name. The templates provided in the attached zip are:

  • DDL to Logical (select “DDL to Logical_Transform_Template”)
  • Logical to Conceptual (select “Logical to Conceptual_Transform_Template”)
  • Updated DDL Transform ( select “DDL_Transform_Template”)

 

To check that the transforms have been loaded, select from the main menu: 

Settings | Transform Templates

Enterprise Architect's list of transformations should now include the additional templates “Logical to Conceptual” and “DDL to Logical”.

 

Usage

It is suggested that a new package is created to contain the target/transformed model before performing the transformation.

To run a transform:

  • Select in the Project Browser the Package with the existing Physical database model
  • Right-click and select Transform Current Package (Ctrl+Shift+H) from the context menu
  • In the Model Transformation window, select the newly imported ‘DDL to Logical’ Transform Script under Transformations
  • This will open a dialog to select a package in which to place the generated transform
  • Select the package you created for this purpose (as suggested above)
  • Click on the Do Transform button (this executes the transformation process)

Once the transformation completes, you can navigate to the generated package and view the automatically created class Diagram!

 

For help on using these templates see additional information in Enterprise Architect's User Guide under the topic Transform Elements.

Overview

Whether setting up a document library for a large organization or modeling a large system with a lot of detailed specification documents, it can be beneficial to organize these externally created documents in a model repository. We'll refer to this kind of model repository as a 'Document Library.'

This script creates Elements in a Package tree that reflects the directory tree structure being imported. It creates a Document Artifact element for each file and links it to the Element.Filename property. In cases where these files are of type .doc or .rtf - they are imported as Linked Documents and stored internally against the Document Artifact Element.

Using Enterprise Architect's traceability features, you can link imported source documents with any other form of documentation derived from them. You can also use Enterprise Architect to help you manage the workflow behind reviewing and publishing these documents. For example, from a source specification document, you might derive user guide documentation or product flyers. As these derived documents are linked to their source, you can define a process for managing how they are created, edited and approved prior to publication. You might use Enterprise Architect's Tagged Values, User (Role-based) Security, Workflow Scripting, Team Review, or Process Modeling features to do this.

 

Requirements

You need to have the following installed on your machine:

  • Enterprise Architect, version 8.0 or later
  • Microsoft Word

 

How to Use the Script

The attached repository contains a script called "Document Import". Because it is implemented as an Enterprise Architect "Package Script", you can conveniently run it from the Context Menu in Enterprise Architect’s Project Browser.

To run the script:

  1. Right-click on a Package in the Project Browser
  2. Select Scripts |  Import Documents  from the context menu

You will be prompted to select the directory that contains the source documents.

For .doc and .rtf files, the script attempts to open MS Word, convert the document to RTF format and load it into the Element's Linked Document. For other files, the script simply creates an Element and stores the original file path, which can be launched from Enterprise Architect.

After the documents are imported, you can:

  • Open a Word or RTF document using the Linked Document editor by pressing Ctrl+Alt+D
  • Open the original document in its external application:
    1. Right-click on an element in the Project Browser
    2. Select Scripts |  Open from the context menu

 

Shortcuts

If your source documents share just one or a couple of formats such as .doc and .pdf, you can use an alternative short-cut that will open the original documents via the application that is registered in Enterprise Architect as a Programming Language editor.

The current script sets each Document Artifact's Language and Filename properties. The Language property is set to “Delphi”. The Filename is set to the full file path of the original document. By setting these two properties, Enterprise Architect will treat the document as a source code file, and enable shortcuts to open the file in an external editor (in this case it could be set as MS Word or OpenOffice).

Enterprise Architect has a source code engineering option for each language that specifies which editor to open for files of that language type. In the attached model, the Delphi Code Language Editor option is set to what is a common file path for a Word installation. You can change this to match your machine settings and favorite word processor via:

Tools | Options | Source Code Engineering | Delphi

You can reset the Editor option to something like:

C:\Program Files (x86)\OpenOffice.org 3\program\swriter.exe

Or

C:\Program Files (x86)\Microsoft Office\OFFICE11\WinWord.exe

Having set this up you can then open the documents using the F10 key.

Note: You could alter the script to accommodate other commonly used document formats such as PDF by assigning these to another Language and altering the Editor path for that Language.

 

In order to copy a Tagged Value named "mytag" from the source model to the target model you can add the following to the Class template (Ctrl+Alt+H):

 

%if classTag:"mytag" != ""%
Tag
{
  name=%qt%mytag%qt%
  value=%qt%%classTag:"mytag"%%qt%
}
%endIf%

 

For more information on transformation templates see:

http://www.sparxsystems.com/enterprise_architect_user_guide/8.0/software_development/transformationtemplates.html

 

Wednesday, 03 November 2010 03:45

Workflow Script Template

This resource updates Enterprise Architect's built-in Workflow Script Template. It provides more detailed documentation and a clearer structure that will help those who are new to Workflow Scripting. It also includes a comprehensive set of available workflow functions to choose from. Therefore you can focus on defining your Workflow rules, rather than rewriting skeleton code to invoke built-in Workflow functions.

Once deployed, the template will be automatically applied to any scripts created in a Workflow Script group.

 

To deploy the template:

  1. Download and extract the Zip File.
  2. Copy the file entitled "WorkflowTemplate.vbs" into the Enterprise Architect config/Script Templates directory.

For example on a typical 32-bit Windows installation, this directory can be found at:

C:\Program Files\Sparx Systems\EA\Config\Script Templates.

 

More information about Workflow Scripting can be found in the Enterprise Architect User Guide.

This example add-in demonstrates how to define a custom compartment to show the Notes defined by an Element's classifier. For example, an Object Instance will show the notes of the Class that it instantiates.

 

The CS_AddinFramework example project can be used as the basis to implement this functionality. The code snippets attached to this article can be inserted into any working C# add-In.

 

Summary of Code

 

Two broadcast events need to be implemented to define a custom compartment - EA_QueryAvailableCompartments and EA_GetCompartmentData.

 

EA_QueryAvailableCompartments returns the names of the custom compartments to be made available. Multiple compartments can be defined using a comma separated string. Options could be implemented at this level to globally disable display of certain compartments. For a more detailed example, refer to the API documentation for this event.

 

EA_GetCompartmentData handles the compartments defined in EA_QueryAvailableCompartments and defines the data to be inserted in the compartment. This event is called for each element on the diagram and each custom compartment to be handled. If the compartment should not be displayed for the current element, return null.

 

Some basic input checking is included in this example to determine whether the custom compartment is displayed for a given element. The following checks are made:

  • The element has a Classifier ID
  • The referenced Classifier contains some notes
  • The element contains a Tagged Value named named “ShowClassifierNotes” with the value “True” (this helps users of the add-in to prevent breaking the layout of existing diagrams, by giving the user explicit control of the compartment visibility)

 

Example of the resulting compartment in Enterprise Architect:

classifier notes small

Wednesday, 17 February 2010 05:18

Visualization of Package Dependencies

When reverse engineering existing source code into Enterprise Architect, there is an option to import dependency relationships based on operation return types and parameter types.  These dependencies are only shown between individual classes.  Some users however, wish to view implicit dependencies at the Package level, which Enterprise Architect does not generate by default.

The purpose of these scripts is to generate implicit dependencies at the package level based on the contents of the packages, and to assist with drawing a diagram to show these cross-package dependencies.

 

Configuring the scripts

In this example, we will take advantage of the new ability to call scripts directly from the Project Browser, introduced in Enterprise Architect 8.0.

  1. Open the scripting window (View | Scripting)
  2. Create a new script group
  3. Name the group "Project Browser"
  4. Set the group type to "Project Browser"
  5. Create a new VBScript under this group and name it "Synchronize Package Dependencies"
  6. Open this new script in the built-in editor and paste in the contents of the file VBS_SynchPackageDependencies.txt
  7. Save
  8. Create another new VBScript under this same group and name it "Synchronize Package Dependency Diagram"
  9. Open this new script in the built-in editor and paste in the contents of the file VBS_SynchPackageDependencyDiagram.txt
  10. Save

 

Using the scripts

With the scripts successfully added to your model, select the root package in the Project Browser from where you wish to generate your cross-package dependencies. To see the messages output by this script, make sure to open the Output window (View | System Output).

  1. Create a new Diagram of type 'Package' and open it (this diagram is where the dependencies will be drawn)
  2. Right-click on the context package in the Project Browser and select "Scripts | Synchronize Package Dependencies".  The Output window will inform you when the process has been completed and report how many new package dependencies have been found.
  3. Right-click on your context package in the Project Browser again and select "Scripts | Synchronize Package Dependency Diagram"
  4. Several packages should now appear on your open diagram, but will all be piled on top of one another.  We can now use EA's automatic diagram layout tools to organize these packages into a sensible layout.
  5. Open the Diagram Layout window ("View | Layout Tools")
  6. Select "Digraph" layout and click the "Apply Layout" button

These scripts can be executed again at any later time to update any changes in your cross-package dependencies that may have occurred since the original execution.  Dependency relationships are added and removed between packages as necessary by running the “Synchronize Package Dependencies” script, and running the “Synchronize Package Dependency Diagram” script again can automatically add/remove packages from the currently open package diagram to show the items that are now relevant.  If any items are added or removed from the diagram, you may need to run the automatic diagram layout tools again.

 

Package-dependency

 

 

Thursday, 17 December 2009 03:32

Listing all Connectors in a Diagram

Introduction:

This script has been produced in response to requests from the Enterprise Architect community for a way to display all Connector information for a given diagram. The script displays this information in Enterprise Architect's Search window.

The script iterates over the 'Diagram Link' API collection for a given diagram to retrieve the details of each connector.

Installation Instructions:

  1. Open Enterprise Architect's Scripting window.
  2. You may create a New Group or place the script within an existing Group.
  3. Right click the Group and select the option "New JScript".
  4. Label the script "List Connectors".
  5. Copy the script below and paste it into the script "List Connectors".
  6. Save the script.
  7. Select the diagram of interest in the Project Browser. (If it is already open, ensure that changes are saved.)
  8. Select the script "List Connectors" and execute it by selecting the "Run script" button.
  9. All of the connectors for the selected diagram will appear within Search Window.

Please copy the script below:

/*
 * Script Name: ListDiagramConnectors
 *
 * Author: Michael Fraser (Sparx Systems)
 *
 * Purpose: Lists relationships between objects that appear on the diagram that is
 * currently selected in the project browser
 *
 * Date: 2009-12-17
 */

// ==========================================
//  GLOBAL DEFINITIONS
// ==========================================
var DIAGRAM_OT        = 8;

// The columns that will appear in the Model Search window
var SEARCH_SPECIFICATION = "<ReportViewData>" +
                            "<Fields>" +
                            "<Field name=\"CLASSGUID\" />" +
                            "<Field name=\"CLASSTYPE\" />" +
                            "<Field name=\"Client\" />" +
                            "<Field name=\"Supplier\" />" +
                            "<Field name=\"Direction\" />" +
                            "<Field name=\"Name\" />" +
                            "<Field name=\"Notes\" />" +
                            "<Field name=\"Client Aggregation\" />" +
                            "<Field name=\"Client Cardinality\" />" +
                            "<Field name=\"Client Role\" />" +
                            "<Field name=\"Supplier Aggregation\" />" +
                            "<Field name=\"Supplier Cardinality\" />" +
                            "<Field name=\"Supplier Role\" />" +
                            "</Fields>" +
                            "<Rows/>" +
                            "</ReportViewData>";

/*
 * Main function
 */
function ListDiagramConnectors()
{
    Repository.EnsureOutputVisible( "Script" );
    
    Session.Output( "JScript: List Diagram Relationships" );
    Session.Output( "=========================================" );
    
    // Get the type of element selected in the Project Browser
    var treeSelectedType = Repository.GetTreeSelectedItemType();
    
    // Handling Code
    switch ( treeSelectedType )
    {
        case DIAGRAM_OT:
        {
            // Code for when a diagram is selected
            var theDiagram as EA.Diagram;
            theDiagram = Repository.GetTreeSelectedObject();
            
            // Create a DOM object to represent the search tree
            var xmlDOM = new ActiveXObject( "MSXML2.DOMDocument.4.0" );
            xmlDOM.validateOnParse = false;
            xmlDOM.async = false;
            
            Session.Output( "Working on diagram '" + theDiagram.Name + "' (Type=" +
            theDiagram.Type + ", ID=" + theDiagram.DiagramID + ")" );
            
            // Load the search template
            if( xmlDOM.loadXML(SEARCH_SPECIFICATION) )
            {
                // Resolve the results node in the xml template
                var node = xmlDOM.selectSingleNode( "//ReportViewData//Rows" );
                
                // A connector has a one to many relationship with diagram (eg one connector
                // may appear on many diagrams). The DiagramLink object represents an instance
                // of a connector on a single diagram, and contains properties such as its
                // geometry, visibility etc.
                //
                // Get all diagramLinks for this diagram
                var diagramLinks as EA.Collection;
                diagramLinks = theDiagram.DiagramLinks;
                
                for ( var i = 0 ; i < diagramLinks.Count ; i++ )
                {
                    // Get the current diagram link
                    var currentLink as EA.DiagramLink;
                    currentLink = diagramLinks.GetAt( i );
                                        
                    // Load the corresponding connector object for the link
                    var correspondingConnector as EA.Connector;
                    correspondingConnector = Repository.GetConnectorByID( currentLink.ConnectorID );
                    
                    // Add the connector's details to the search data
                    AddRow( xmlDOM, node, correspondingConnector );    
                }
                
                // Fill the Model Search window with the results
                Repository.RunModelSearch( "", "", "", xmlDOM.xml );
                
            }
            else
            {
                Session.Prompt( "Failed to load search xml", 0 );
            }
            
            break;
        }
        default:
        {
            // Error message
            Session.Prompt( "This script does not support items of this type.", 0 );
        }
    }
    
    Session.Output( "Done!" );
}

/*
 * Adds an entry for the method object 'theRelationship' to the xml row node 'rowsNode'
 */
function AddRow( xmlDOM, rowsNode, theRelationship )
{
    // Cast theMethod for intellisense
    var relationship as EA.Connector;
    relationship = theRelationship;

    // Create a Row node
    var row = xmlDOM.createElement( "Row" );
    
    // Get client details for the connector
    var client as EA.Element;
    var clientEnd as EA.ConnectorEnd;
    client = Repository.GetElementByID( relationship.ClientID );
    clientEnd = relationship.ClientEnd;
    
    // Get supplier details for the connector
    var supplier as EA.Element;
    var supplierEnd as EA.ConnectorEnd;
    supplier = Repository.GetElementByID( relationship.SupplierID );
    supplierEnd = relationship.SupplierEnd;
        
    // Add the Model Search row data to our DOM
    AddField( xmlDOM, row, "CLASSGUID", relationship.ConnectorGUID );
    AddField( xmlDOM, row, "CLASSTYPE", "connector" );
    AddField( xmlDOM, row, "Client", client.Name );
    AddField( xmlDOM, row, "Client", supplier.Name );
    AddField( xmlDOM, row, "Direction", relationship.Direction );
    AddField( xmlDOM, row, "Name", relationship.Name );
    AddField( xmlDOM, row, "Notes", relationship.Notes );
    AddField( xmlDOM, row, "Client Aggregation", clientEnd.Aggregation );
    AddField( xmlDOM, row, "Client Cardinality", clientEnd.Cardinality );
    AddField( xmlDOM, row, "Client Role", clientEnd.Role );
    AddField( xmlDOM, row, "Supplier Aggregation", supplierEnd.Aggregation );
    AddField( xmlDOM, row, "Supplier Cardinality", supplierEnd.Cardinality );
    AddField( xmlDOM, row, "Supplier Role", supplierEnd.Role );
    
    
    // Append the newly created row node to the rows node
    rowsNode.appendChild( row );
}

/*
 * Adds an Element to our DOM called Field which makes up the Row data for the Model Search window.
 * <Field name "" value ""/>
 */
function AddField( xmlDOM, row, name, value )
{
    var fieldNode = xmlDOM.createElement( "Field" );
    
    // Create first attribute for the name
    var nameAttribute = xmlDOM.createAttribute( "name" );
    nameAttribute.value = name;
    fieldNode.attributes.setNamedItem( nameAttribute );
    
    // Create second attribute for the value
    var valueAttribute = xmlDOM.createAttribute( "value" );
    valueAttribute.value = value;
    fieldNode.attributes.setNamedItem( valueAttribute );
    
    // Append the fieldNode
    row.appendChild( fieldNode );
}

ListDiagramConnectors();

Monday, 26 October 2009 05:47

C# Add-in template

The following file is a C# Add-in Template for Enterprise Architect. Use it as a base project for any C# Add-in work.

Page 23 of 28