22
1 Summary 1. StarUML - UML/MDA Plataform ............................................................................... 1 2. Creating Profiles in StarUML ..................................................................................... 2 3. Creating the GeoProfile............................................................................................. 5 4. Applying the GeoProfile .......................................................................................... 12 1. StarUML - UML/MDA Plataform StarUML (UML STAR, 2010) is an open source CASE tool and is under the GPL license (General Public License). It supports the modeling of systems using the UML2 diagrams and also to MDA, with definitions of transformations for some specific platforms. It also allowed the import/export of models using the XMI format. StarUML Desktop The specification of UML profiles in this tool is made differently from other tools reviewed. There is not a visual way to implement profiles. You must write the code of the profile in an XML document, save the file with the extension .PRF and put it in a directory of the installation tool.

StarUML Tutorial English

Embed Size (px)

Citation preview

1

Summary 1. StarUML - UML/MDA Plataform ............................................................................... 1

2. Creating Profiles in StarUML ..................................................................................... 2

3. Creating the GeoProfile ............................................................................................. 5

4. Applying the GeoProfile .......................................................................................... 12

1. StarUML - UML/MDA Plataform

StarUML (UML STAR, 2010) is an open source CASE tool and is under the GPL license

(General Public License). It supports the modeling of systems using the UML2 diagrams

and also to MDA, with definitions of transformations for some specific platforms. It

also allowed the import/export of models using the XMI format.

StarUML Desktop

The specification of UML profiles in this tool is made differently from other tools

reviewed. There is not a visual way to implement profiles. You must write the code of

the profile in an XML document, save the file with the extension .PRF and put it in a

directory of the installation tool.

2

The following will be shown step by step the creation process and an use example of

the GeoProfile for modeling geographic database. Remembering that this tutorial was

made using version 5.0 of the tool.

2. Creating Profiles in StarUML

In this tutorial we will focus only on the XML elements that will be useful in creating of Geoprofile. The basic structure of an XML document to create a profile for StarUML is shown below:

<?xml version=”1.0” encoding=”...” ?>

<PROFILE version="...">

<HEADER>

...

</HEADER>

<BODY>

...

</BODY>

</PROFILE>

Where the <HEADER> section defines the profile description and <BODY> is the

body of the profile itself, which will be defined stereotypes, classes, attributes and

data types of the profile.

The <HEADER> section can contain the following elements:

<HEADER>

<NAME>...</NAME>

<DISPLAYNAME>...</DISPLAYNAME>

<DESCRIPTION>...</DESCRIPTION>

<AUTOINCLUDE>...</AUTOINCLUDE>

</HEADER>

NAME: Contain the name of the profile. DISPLAYNAME: This is the caption used in the profile dialog and other user interfaces. DESCRIPTION: Contain the description of the profile. AUTOINCLUDE: Specifies whether to include the profile automatically when you create new project. The section <BODY> can contain the following elements: <BODY>

<STEREOTYPELIST>

...

3

</STEREOTYPELIST>

<TAGDEFINITIONSETLIST>

...

</TAGDEFINITIONSETLIST>

</BODY>

STEREOTYPELIST: List of stereotypes of the profile. For defining stereotypes see the section <STEREOTYPE>. TAGDEFINITIONSETLIST: Defines multiple tag definitions. For definition of tag see the section <TAGDEFINITIONSET>. DATATYPELIST: Define multiple data types. For defining data types, see the section <DATATYPE>. The section <STEREOTYPE> defines the information of the stereotype and the inheritance structure, may contain the following elements: <STEREOTYPE>

<NAME>...</NAME>

<DESCRIPTION>...</DESCRIPTION>

<BASECLASSES>

<BASECLASS>...</BASECLASS>

...

</BASECLASSES>

<PARENT>...</PARENT>

<RELATEDTAGDEFINITIONSET>...</RELATEDTAGDEFINITIONSET>

<ICON>...</ICON>

</STEREOTYPE>

NAME: Name of the stereotype. DESCRIPTION: Description of the stereotype. BASECLASSES: May contain names of multiple UML elements that can be applied to the stereotype. The name of the elements used here <BASECLASS> are the names of the UML elements (UMLClass, UMLAssociation, UMLClassifier, UMLAttribute, UMLPackage, UMLAbstractClass ...). Note: If the name of an abstract class as UMLClassifier is used, all elements inherited this will be applied. If the stereotype of top-level (parent element) is defined, this section will not be defined; any definition of this section is ignored and the value BASECLASSES stereotype is applied. PARENT: The stereotype might have relationship type inheritance. The PARENT element containing the name of the parent element of the stereotype. RELATEDTAGDEFINITIONSET: Contains the name of TagDefinitionSet related to the stereotype (name of stereotype attribute set).

4

ICON: A stereotype can also be indicated by an icon. This element contains the name of the icon file for the stereotype. The icon file must be located in the same directory as the document profile. The section<TAGDEFINITIONSET> defines a set of TaggedValues that may be related to a stereotype, this has the following structure: <TAGDEFINITIONSET>

<NAME>...</NAME>

<BASECLASSES>

<BASECLASS>...</BASECLASS>

...

</BASECLASSES>

<TAGDEFINITIONLIST>

...

</TAGDEFINITIONLIST>

</TAGDEFINITIONSET>

NAME: Name of TagDefinition. If the TagDefinition is interested in a particular stereotype, it is advised to use the name of the stereotype. BASECLASSES: Contains the names of the UML elements to be applied in TagDefinitionSet. TAGDEFINITIONLIST: Contains multiple definitions of tags included in the set. See the section <TAGDEFINITION>. The section <TAGDEFINITION> sets a TaggedValue section of a set of lists of tags. Has the the following structure: <TAGDEFINITION lock=”...”>

<NAME>...</NAME>

<TAGTYPE>...</TAGTYPE>

<DEFAULTDATAVALUE>...</DEFAULTDATAVALUE>

<LITERALS>

<LITERAL>...</LITERAL>

....

</LITERALS>

</TAGDEFINITION>

lock (TAGDEFINITION element): Sets whether the value of the tag may or may not be changed by the user. Can be "True" in the case of not being able to change, or "False" otherwise. NAME: Tag name. This must be unique within the set of tags to which this tag belongs (TagDefinitionSet). TAGTYPE: Sets the type of tag. This can be defined as being of the types: Integer, Boolean, Real, String, Enumeration, Reference or Collection. DEFAULTDATAVALUE: Default value of the tag.

5

LITERALS: Defines the literals <LITERAL> if the type of tag is Enumeration. Unfortunately, this tool does not support the definition of constraints on OCL language for profiles.

3. Creating the GeoProfile

The profile GeoProfile is shown in the figure below.

Stereotypes of GeoProfile

With this definition and the XML elements defined above, we can now create the GeoProfile to be used in the tool StarUML. Recalling that the file with the XML code must be saved with the .PRF extension code. GeoProfile XML code is shown below. <?xml version="1.0" encoding="UTF-8"?>

<PROFILE version="1.0">

<HEADER>

<NAME>GeoProfile</NAME>

<DISPLAYNAME>GeoProfile</DISPLAYNAME>

<DESCRIPTION>GeoDB conceptual modeling</DESCRIPTION>

</HEADER>

<BODY>

<STEREOTYPELIST>

<STEREOTYPE>

<NAME>GeoObject</NAME>

<DESCRIPTION>Object view.</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLAbstractClass</BASECLASS>

</BASECLASSES>

</STEREOTYPE>

6

<STEREOTYPE>

<NAME>Point</NAME>

<DESCRIPTION>Indicate a Point.</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLClass</BASECLASS>

</BASECLASSES>

<PARENT>GeoObject</PARENT>

<ICON>Point.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>Line</NAME>

<DESCRIPTION>Indicate a Line.</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLClass</BASECLASS>

</BASECLASSES>

<PARENT>GeoObject</PARENT>

<ICON>Line.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>Polygon</NAME>

<DESCRIPTION>Indicate a Polygon.</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLClass</BASECLASS>

</BASECLASSES>

<PARENT>GeoObject</PARENT>

<ICON>Polygon.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>ComplexSpatialObj</NAME>

<DESCRIPTION>Indicate a Complex Object.

</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLClass</BASECLASS>

</BASECLASSES>

<PARENT>GeoObject</PARENT>

<ICON>ComplexSpatialObj.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>GeoField</NAME>

<DESCRIPTION>Object view.</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLAbstractClass</BASECLASS>

</BASECLASSES>

</STEREOTYPE>

<STEREOTYPE>

<NAME>TIN</NAME>

<DESCRIPTION>Indicate a Triangular Irregular

Network.</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLClass</BASECLASS>

</BASECLASSES>

<PARENT>GeoField</PARENT>

<ICON>TIN.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>Isolines</NAME>

<DESCRIPTION>Indicate Isolines.</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLClass</BASECLASS>

</BASECLASSES>

7

<PARENT>GeoField</PARENT>

<ICON>Isolines.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>GridOfCells</NAME>

<DESCRIPTION>Indicate a Grid Of Cells.

</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLClass</BASECLASS>

</BASECLASSES>

<PARENT>GeoField</PARENT>

<ICON>GridOfCells.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>GridOfPoints</NAME>

<DESCRIPTION>Indicate a Grid Of Points.

</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLClass</BASECLASS>

</BASECLASSES>

<PARENT>GeoField</PARENT>

<ICON>GridOfPoints.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>IrregularPoints</NAME>

<DESCRIPTION>Indicate Irregular Points.

</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLClass</BASECLASS>

</BASECLASSES>

<PARENT>GeoField</PARENT>

<ICON>IrregularPoints.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>AdjPolygons</NAME>

<DESCRIPTION>Indicate Adjacent Polygons.

</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLClass</BASECLASS>

</BASECLASSES>

<PARENT>GeoField</PARENT>

<ICON>AdjPolygons.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>NetworkObj</NAME>

<DESCRIPTION>Object view.</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLAbstractClass</BASECLASS>

</BASECLASSES>

</STEREOTYPE>

<STEREOTYPE>

<NAME>Node</NAME>

<DESCRIPTION>Indicate a Node.</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLClass</BASECLASS>

</BASECLASSES>

<PARENT>NetworkObj</PARENT>

<ICON>Node.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

8

<NAME>Arc</NAME>

<DESCRIPTION>Object view.</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLAbstractClass</BASECLASS>

</BASECLASSES>

<PARENT>NetworkObj</PARENT>

</STEREOTYPE>

<STEREOTYPE>

<NAME>UnidirectionalArc</NAME>

<DESCRIPTION>Indicate an Unidirectional Arc.

</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLClass</BASECLASS>

</BASECLASSES>

<PARENT>Arc</PARENT>

<ICON>UnidirectionalArc.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>BidirectionalArc</NAME>

<DESCRIPTION>Indicate a Bidirectional Arc.

</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLClass</BASECLASS>

</BASECLASSES>

<PARENT>Arc</PARENT>

<ICON>BidirectionalArc.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>Network</NAME>

<DESCRIPTION>Indicate a network.</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLClass</BASECLASS>

</BASECLASSES>

<ICON>Network.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>TemporalObj</NAME>

<DESCRIPTION>Indicate a Temporal object.

</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLClass</BASECLASS>

</BASECLASSES>

<RELATEDTAGDEFINITIONSET>TemporalObj

</RELATEDTAGDEFINITIONSET>

<ICON>Temporal.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>Touch</NAME>

<DESCRIPTION>Indicate a Touch relationship.

</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLAssociation</BASECLASS>

</BASECLASSES>

<ICON>Touch.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>In</NAME>

<DESCRIPTION>Indicate an In relationship.

</DESCRIPTION>

<BASECLASSES>

9

<BASECLASS>UMLAssociation</BASECLASS>

</BASECLASSES>

<ICON>In.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>Cross</NAME>

<DESCRIPTION>Indicate a Cross relationship.

</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLAssociation</BASECLASS>

</BASECLASSES>

<ICON>Cross.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>Overlap</NAME>

<DESCRIPTION>Indicate a Overlap relationship.

</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLAssociation</BASECLASS>

</BASECLASSES>

<ICON>Overlap.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>Disjoint</NAME>

<DESCRIPTION>Indicate a Disjoint relationship.

</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLAssociation</BASECLASS>

</BASECLASSES>

<ICON>Disjoint.bmp</ICON>

</STEREOTYPE>

<STEREOTYPE>

<NAME>Temporal</NAME>

<DESCRIPTION>Indicate a Temporal relationship.

</DESCRIPTION>

<BASECLASSES>

<BASECLASS>UMLAssociation</BASECLASS>

</BASECLASSES>

<ICON>Temporal.bmp</ICON>

</STEREOTYPE>

</STEREOTYPELIST>

<TAGDEFINITIONSETLIST>

<TAGDEFINITIONSET>

<NAME>TemporalObj</NAME>

<BASECLASSES>

<BASECLASS>UMLAttribute</BASECLASS>

</BASECLASSES>

<TAGDEFINITIONLIST>

<TAGDEFINITION lock="False">

<NAME>temporalPrimitive</NAME>

<TAGTYPE>Enumeration</TAGTYPE>

<DEFAULTDATAVALUE>instant

</DEFAULTDATAVALUE>

<LITERALS>

<LITERAL>instant</LITERAL>

<LITERAL>interval</LITERAL>

</LITERALS>

</TAGDEFINITION>

<TAGDEFINITION lock="False">

<NAME>temporalType</NAME>

10

<TAGTYPE>Enumeration</TAGTYPE>

<DEFAULTDATAVALUE>valid_time

</DEFAULTDATAVALUE>

<LITERALS>

<LITERAL>valid_time</LITERAL>

<LITERAL>transaction_time

</LITERAL>

<LITERAL>bitemporal</LITERAL>

</LITERALS>

</TAGDEFINITION>

</TAGDEFINITIONLIST>

</TAGDEFINITIONSET>

</TAGDEFINITIONSETLIST>

</BODY>

</PROFILE>

Now, copy the XML code above to a text editor of your choice and save it with the .PRF extension so that it can be recognized by StarUML. To the profile to be automatically recognized, we must put it in a subdirectory of the tool: <install directory>\modules. The StarUML looks for and reads the profiles that are in the folder modules in your installation directory and registers automatically when the program starts. If the profile file is invalid or your extension is not .PRF, the program will skip the file. It is advisable to create a new folder inside the subdirectory modules containing the files from the profile, the .PRF file and icons.

Note that in the figure above the path to the desired directory is: C:\Arquivos de Programas\StarUML\modules or C:\Program Files\StarUML\modules in english. Which is the default installation directory of the operating system used.

11

Therefore, to our profile be recognized by the tool, simply create a new folder in this subdirectory, let's call it staruml-geoprofile.

Now, just copy the profile files (.PRF and icons) to this folder.

Now, simply begin the StarUML for the profile to be recognized automatically by the tool. Note that, after starting the program, on the lower tab Output, you will see the message "The Profile "GeoProfile" is loaded successfully" stating that the profile was loaded correctly. If the message does not appear is because there was some error occurred while creating the profile.

12

Also, note that now the option of adding profiles Model-> Profile-> Profile Manager, the GeoProfile is available to be added to your application.

4. Applying the GeoProfile

With the profile created and available for use in the tool, we can use it in our modeling

geographical classes. To use our profile, start creating a new template. When you start

the tool, choose Empty Project. If the window below does not appear at the beginning

of the application you can go to: File-> New Project.

13

To create an application using the GeoProfile we need to first add it to the template for this, go to Model -> Profiles and in the dialog that follows add the profile GeoProfile. Also make sure that the profile UML Standard Profile is also added.

Now, on the tab Model Explorer of upper right select the object "Untitled" with a click of the mouse right button and choose the option: Add-> Design Model to create a new blank drawing template.

14

To change the name of the template, select it and use the field Name of the tab Properties.

Now, let's create a new class diagram within this model, for this, select the template that you created earlier with the right mouse button and choose the option: Add Diagram-> Class Diagram. Give any name to the new diagram.

15

It is now possible to apply the GeoProfile stereotypes in UML elements of the diagram you created earlier. To test the GeoProfile, add an element Class on the diagram.

Having the class selected, in the tab Properties go into Stereotype. A window with the available stereotypes for an element of type Class will appear. For this application, only interested in GeoProfile stereotypes.

16

Note that, when you select a stereotype of GeoProfile, its icon will be shown on the field Icon Preview.

Select any stereotype and click OK to apply it to the class. Note that the name of the stereotype will be displayed between <<...>> at the top of the class.

17

StarUML only allows us to add one stereotype per element and allows you to show stereotypes in textual form "Textual", in form of icon "Iconic" or both "Decoration". To change the preview type, select the object and, in the top tab, select the type of view you want in the option Stereotype Display. Viewing the stereotype can also be changed by right-clicking on the object in the option Format option-> Stereotype Display.

As defined in GeoProfile, stereotypes can also be applied to relationships. Add a class

to model and an element Association between them.

18

To apply a stereotype to an element Association proceed the same way as described above for elements of type Class. Note that, now the only available stereotypes are those previously defined as being of type UMLAssociation in the profile.

StarUML only allows the viewing of stereotypes of type Association in textual form, even if they have been defined icons to stereotypes.

19

Remembering that StarUML only allows adding and viewing only one stereotype per element, and also that this tool does not support the definition of constraints on OCL language for profiles. Therefore, to verify the validity and consistency of the model is the responsibility of the designer. Another type of geographical object that can be found in our applications are the

temporal objects, defined in GeoProfile as TemporalObj. For this type of object are

defined two tagged values, temporalType and temporalPrimitive. To define their

values, first we should add a class with the stereotype TemporalObj.

The value of each tagged value for this object type can be defined on the field Tagged Values with a right click on the class.

20

The value of each tagged value of a class can be edited in the Tagged Value Editor that appears. In profile definition shown earlier, the value instant were chosen as default value for the field temporalPrimitive, and valid_time as default value for the field temporalType.

Other UML elements can also be added to the model as packages, attributes, operations, data types, etc. The properties of the elements added to the template can be changed in the Properties tab, which contains all the attributes of the selected element in the tab Model Explorer or in the drawing diagram.

21

With this, is already possible to create a UML model for spatial database modeling in

StarUML using the GeoProfile. An example of "School" by using this profile is shown

below.

Note that the classes Cidade (city), Escola (school) and Bairro (district) have

stereotypes such as <<Point>> and <<polygon>>, it shows how the class may be

represented in a geographic application. Bairro, for example, can be represented as a

22

point or a polygon, depending on the scale. The class Aluno (student), in turn, has not

stereotype, because it is a class without geographic representation will thus be created

as a common object class, without applying any stereotype.

Note also that were applied stereotypes to NARY relationships. The stereotype <<in>>

between Bairro and Cidade topologically shows that every Bairro element is within a

Cidade element, the same goes for the relationship between Escola and Bairro. There

is no topological relationship between Aluno and Escola, so we use only one common

relationship Association, without applying stereotypes.

StarUML also allows import and export models in XMI (XML Metadata Interchange)

format. In the option File -> Import/Export -> XMI the designer can export the current

template to the XMI format or import a model already created previously.

More information about this tool can be found at: http://staruml.sourceforge.net