Thursday, 9 June 2011

UML Profiles in Visual Studio 2010

UML Profiles are supported in Visual Studio 2010 (VS2010). Here I examine how they work and whether our CBDI-SAE UML Profile for SOA (SAE Profile) can be used in VS2010


Creating a UML Profile in VS2010

See MSDN for instructions on how to define a profile to extend UML in VS2010 and then add the profile to a model.

Here’s a simple profile I created in VS2010 covering two stereotypes from the SAE Profile - “Automation Unit” and “AU Dependency”. (an Automation Unit is the collection of software artifacts that provide a Service)

Unlike Sparx Systems’ Enterprise Architect (EA) that we have used to develop the SAE Profile, the Stereotypes don’t appear in the toolbox so they cannot be added directly to the diagram. Instead you add a Class or Dependency to the diagram, and then chose a Stereotype for it. The figure below shows the Stereotypes for Dependency, and the properties and values that can be set.

Use of UML Profile in VS2010
And here is the schema,




<?xml version="1.0" encoding="utf-8"?>
<profile dslVersion="1.0.0.0"
   name="SAEProfile" displayName="SAE Profile"
   xmlns="http://schemas.microsoft.com/UML2.1.2/ProfileDefinition">
      <stereotypes>
            <stereotype name="AUDependency" displayName="AU Dependency">
                <metaclasses>
                      <metaclassMoniker name="/SAEProfile/Microsoft.VisualStudio.Uml.Classes.IDependency" />
                </metaclasses>
                <properties>
                      <property name="AUDsource" displayName="AUD source" default="">
                            <propertyType>
                                <enumerationTypeMoniker name="/SAEProfile/AUDsource"/>
                            </propertyType>
                      </property>
                      <property name="AUDtype" displayName="AUD type" default="">
                            <propertyType>
                                <enumerationTypeMoniker name="/SAEProfile/AUDtype"/>
                            </propertyType>
                      </property>
                </properties>
            </stereotype>
            <stereotype name="AutomationUnit" displayName="Automation Unit">
                <metaclasses>
                      <metaclassMoniker name="/SAEProfile/Microsoft.VisualStudio.Uml.Classes.IClass" />
                </metaclasses>
                <properties>
                      <property name="AUhasEmbeddedDataStore" displayName="AUhasEmbeddedDataStore" default="">
                            <propertyType>
                                <externalType name="/SAEProfile/System.Boolean" />
                            </propertyType>
                      </property>
                      <property name="AUisDistributedPart" displayName="AUisDistributedPart" default="">
                            <propertyType>
                                <externalType name="/SAEProfile/System.Boolean" />
                            </propertyType>
                      </property>
                      <property name="AUname" displayName="AUnam" default="">
                            <propertyType>
                                <externalType name="/SAEProfile/System.String" />
                            </propertyType>
                      </property>
                      <property name="AUrequirement" displayName="AUrequirement" default="">
                            <propertyType>
                                <externalType name="/SAEProfile/System.String" />
                            </propertyType>
                      </property>
                      <property name="AUtype" displayName="AUtype" default="">
                            <propertyType>
                                <enumerationTypeMoniker name="/SAEProfile/AUtype" />
                            </propertyType>
                      </property>
                </properties>
            </stereotype>
      </stereotypes>
      <metaclasses>
            <metaclass name="Microsoft.VisualStudio.Uml.Classes.IDependency" />
            <metaclass name="Microsoft.VisualStudio.Uml.Classes.IClass" />
      </metaclasses>
      <propertyTypes>
            <externalType name="System.String" />
            <externalType name="System.Boolean" />
            <enumerationType name="AUtype">
            <enumerationLiterals>
                <enumerationLiteral name="component" displayName="component"/>
                <enumerationLiteral name="quasiComponent" displayName="quasiComponent"/>
                <enumerationLiteral name="wrapper" displayName="wrapper"/>
                <enumerationLiteral name="script" displayName="script"/>
                <enumerationLiteral name="BPEL" displayName="BPEL"/>
            </enumerationLiterals>
            </enumerationType>
            <enumerationType name="AUDsource">
            <enumerationLiterals>
                <enumerationLiteral name="fromServiceSpec" displayName="fromServiceSpec"/>
                <enumerationLiteral name="designChoice" displayName="designChoice"/>
                <enumerationLiteral name="fromAUSpec" displayName="fromAUSpec"/>
            </enumerationLiterals>
            </enumerationType>
            <enumerationType name="AUDtype">
                <enumerationLiterals>
                      <enumerationLiteral name="requiredType" displayName="requiredType"/>
                      <enumerationLiteral name="requiredIntegrity" displayName="requiredIntegrity"/>
                      <enumerationLiteral name="create" displayName="create"/>
                      <enumerationLiteral name="implementationOnly" displayName="implementationOnly"/>
                      <enumerationLiteral name="exclusiveService" displayName="exclusiveService"/>
                      <enumerationLiteral name="exclusiveDeployment" displayName="exclusiveDeployment"/>
                      <enumerationLiteral name="exclusiveInstance" displayName="exclusiveInstance"/>
                      <enumerationLiteral name="nonServiceDependency" displayName="nonServiceDependency"/>
                </enumerationLiterals>
            </enumerationType>
      </propertyTypes>
</profile>




Importing the SAE Profile

In VS2010 you can either create the UML Profile as a Visual Studio Extension as I did above or import an existing UML Profile in an XMI format. As the SAE Profile is available XMI format I tried importing it but unfortunately came up against some limitations.

The first major one is that we use generalization heavily in the SAE Profile. However, this is not supported in VS2010 and consequently generates the following warning,


Message              :               The following element was not imported: SAE Profile::Automation Unit Specification::Generalization. This element has the following type: Generalization. Line 30, position 4.

As a consequence this means many of the key elements of the SAE Profile are not imported.  In the SAE Profile Automation Unit for example is a type of Participant (which is used for mapping to SoaML).

Next it seems that a bug in the import means that enumerations are not imported. Enumerations are used to define the permitted values for properties. We have thousands of enumerations in our profile...

Hopefully Microsoft will improve this in subsequent releases. I am grateful to Steve Cook at Microsoft for helping me to try and import the SAE Profile.

In turn we are also migrating the UML model of the SAE Profile from EA over to No Magic’s Magic Draw. We need to do this in order to get support for XMI 2.2, whereas EA only supports 2.1. XMI 2.2 is required by IBM Rational tools, which has been popular in the past amongst our SAE Profile users, but the requirement for XMI 2.2 means that it cannot currently be imported.  We will look to see if Magic Draw can also export a format that imports better to VS2010. With thousands of elements in the SAE Profile, trying to convert it to VS2010’s own proprietary profile format would take a fair bit of effort.

No comments:

Post a Comment