1. papyrus uml2 modeler - departamento de … · 3 by right-clicking the project in the tab...

26
1 Summary 1. Papyrus UML2 Modeler ........................................................................................................ 1 2. Creating the GeoProfile ......................................................................................................... 2 3. Applying OCL Constraints .................................................................................................... 10 4. Applying Icons to Stereotypes ............................................................................................. 14 5. Applying the GeoProfile ...................................................................................................... 16 1. Papyrus UML2 Modeler The CASE tool Papyrus UML2 Modeler(Papyrus UML, 2010) is an open source tool. It is based on the Eclipse framework and is licensed under the EPL (Eclipse Public License). Among other interesting features for modeling systems using the UML2 standard, the tool supports the creation of UML profiles, which is our goal. The profile is created by selecting for use stereotypes and metaclasses will be extended by these stereotypes. In the figure below you can see part of the stereotypes of the GeoProfile beings specified in the tool. Desktop of Papyrus UML2 Modeler

Upload: donhan

Post on 10-Sep-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

1

Summary 1. Papyrus UML2 Modeler ........................................................................................................ 1

2. Creating the GeoProfile ......................................................................................................... 2

3. Applying OCL Constraints .................................................................................................... 10

4. Applying Icons to Stereotypes ............................................................................................. 14

5. Applying the GeoProfile ...................................................................................................... 16

1. Papyrus UML2 Modeler

The CASE tool Papyrus UML2 Modeler(Papyrus UML, 2010) is an open source tool. It is

based on the Eclipse framework and is licensed under the EPL (Eclipse Public License).

Among other interesting features for modeling systems using the UML2 standard, the

tool supports the creation of UML profiles, which is our goal. The profile is created by

selecting for use stereotypes and metaclasses will be extended by these stereotypes.

In the figure below you can see part of the stereotypes of the GeoProfile beings

specified in the tool.

Desktop of Papyrus UML2 Modeler

2

2. Creating the GeoProfile

To create the profile in this tool, first we must create a new project.

Give the project the name "GeoProfile" and save to any directory. Now let's create the

profile itself. Right-click the new project and go to: New-> Create an empty profile.

Give your profile the name "GeoProfile" and in the window that appears, select the

project you created earlier.

See that in the tab Navigator should appear the previously created profile and the

toolbar Palette with the elements, as shown in the figure below.

3

By right-clicking the project in the tab Outline, we will have the option to Add an

element that enables us to add the elements contained in this tool, the elements

which we will use here are: Metaclass, Stereotype, Extension and Enumeration, some

of these and the other can be found in the palette on the right side: Generalization,

ImportMetaclass, Stereotype, Extension.

First, let's create the stereotypes of the GeoProfile, let's start with stereotypes for

network objects: NetworkObj, Arc, Node, UnidirectionalArc and BidirectionalArc. Add

the elements Stereotype, as shown in the figure below. Note that the stereotypes

NetworkObj and Arc are abstract. To place a stereotype as abstract simply select it in

the template and check the Abstract field on the tab General.

4

Then use the element Generalization, in order to let the profile as shown below.

Note: If you are inserting the elements for the tab Outline, the element will not appear

in the diagram, so that an element becomes visible, simply drag it from the Outline to

the diagrams.

The next step is to extend the UML metaclass Class using stereotypes created, add the

element ImportMetaclass; in the window that appears select the metaclass Class, add

to the project and give OK.

5

The metaclass Class will appear on the diagram; now let's extend the metaclass

created using a stereotype; just use the element Extension.

Now let's extend the metaclass Association, creating stereotypes that deals with the

topological relationships between the classes. There are six different types of

topological relationships in GeoProfile, let's create just one to exemplify.

First, create an element Stereotype and give it the name Temporal, as shown in the

figure below.

6

Now includes an element ImportMetaclass, but this time select the metaclass

Association.

Use now the element Extension to extend the metaclass Association with the

stereotype created.

7

A stereotype can have properties, which can be referred to as tag definitions. When a

stereotype is applied to an element of the model, the values of properties can be

referred to as tagged values.

The next step is to create the stereotype TemporalObject and their enumerations

(tagged values). The GeoProfile defines two kinds of enumeration, TemporalPrimitive

and TemporalType. Includes two elements to the schema type Enumeration, and

name them as TemporalPrimitive and TemporalType.

Add the EnumerationLiterals (instant and interval) in TemporalPrimitive and

(valid_time, transaction_time e bitemporal) in TemporalType, see the figure below.

8

Now, add to the schema the stereotype TemporalObj and includes two attributes

(Property) with kinds of previously created enumerations: TemporalPrimitive of type

temporalPrimitive and temporalType of type TemporalType.

To add the type of the attribute, just select it within the stereotype or in the tab

Outline, and in the tab General click the button + ahead of the field Type and select

the type on the window that appears, see the figure below.

9

Just now we extend the metaclass Class again for the stereotype created; includes an

element Extension of stereotype TemporalObj to the metaclass Class.

This is already possible to create the diagram of the profile to the stereotypes of

GeoProfile entirely according to its specification; include other Stereotypes,

Generalizations and Extensions that are missing to let the template as follows:

10

Schema of GeoProfile

Save the template. A dialog window will appear to decide if the profile should be

defined or not. The definition is required to use the profile.

Chose Yes and a window will appear to add version number and other information

about the profile, this information can be viewed using the UML2 tool box tree editor.

3. Applying OCL Constraints

The Papyrus supports OCL language for defining constraints, the same used to validate

the generated conceptual schema. This way, OCL constraints described in this section

always have as context a stereotype of GeoProfile, besides being invariant.

The constraints specified for GeoProfile basically avoiding the occurrence of three

types of errors: adding stereotypes incompatible within a single element; poor

11

construction of networks; and addition of topological relationships are impossible to

happen between two elements (e.g. relationship type Cross between two objects with

representation of geographic point). These three groups of constraints are analysed

below.

To declare constraints, we must first select the stereotype to which the constraint is

added, then in the Properties pane go to Constraints tab, then click the + button to

add a constraint. The right panel is where we add the OCL constraint.

The image below shows the insertion of a constraint on stereotype GeoField.

The next image shows the OCL constraint added and validated in the profile. Simply

enter the constraint and then click the Evaluate button, if the expression is correct

then the message "Successfully Parsed" will appear. Once evaluated, the restriction

must be saved, for this, just click on the Save button.

12

GeoProfile restrictions are described below, add them to profile created. The field

context refers to which stereotype the constraint is applied.

OCL constraints for verification of the existence of stereotypes incompatible in a same

schema class.

A context GeoField

self.base_Class.getAppliedStereotypes() -> select(s | s.name = 'Point' or s.name = 'Line' or s.name = 'Polygon' or s.name = 'ComplexSpatialObj') -> isEmpty()

B context Network

self.base_Class.getAppliedStereotypes() -> select(s | s.name = 'Point' or s.name = 'Line' or s.name = 'Polygon' or s.name = 'ComplexSpatialObj' or s.name = 'TIN' or s.name = 'Isolines' or s.name = 'GridOfCells' or s.name = 'AdjPolygons' or s.name = 'GridOfPoints' or s.name = 'IrregularPoints' or s.name = 'Node' or s.name = 'UnidirectionalArc' or s.name = 'BidirectionalArc') -> isEmpty()

C context NetworkObj

self.base_Class.getAppliedStereotypes() -> select(s | s.name = 'TIN' or s.name = 'Isolines' or s.name = 'GridOfCells' or s.name = 'AdjPolygons' or s.name = 'GridOfPoints' or s.name = 'IrregularPoints') -> isEmpty()

D context Node

self.base_Class.getAppliedStereotypes() -> select(s | s.name = 'UnidirectionalArc' or s.name = 'BidirectionalArc') -> isEmpty()

E context UnidirectionalArc

self.base_Class.getAppliedStereotypes() -> select(s | s.name = 'BidirectionalArc') -> isEmpty()

OCL constraints for verification of the existence of stereotypes incompatible in a same

schema Association.

F context Cross

self.base_Association.getAppliedStereotypes() -> select(s | s.name = 'Disjoint' or s.name = 'In' or s.name = 'Overlap' or s.name = 'Touch') -> isEmpty()

13

G context Disjoint

self.base_Association.getAppliedStereotypes() -> select(s | s.name = 'Cross' or s.name = 'In' or s.name = 'Overlap' or s.name = 'Touch') -> isEmpty()

H context In

self.base_Association.getAppliedStereotypes() -> select(s | s.name = 'Disjoint' or s.name = 'Cross' or s.name = 'Overlap' or s.name = 'Touch') -> isEmpty()

I context Overlap

self.base_Association.getAppliedStereotypes() -> select(s | s.name = 'Disjoint' or s.name = 'Cross' or s.name = 'In' or s.name = 'Touch') -> isEmpty()

J context Touch

self.base_Association.getAppliedStereotypes() -> select(s | s.name = 'Disjoint' or s.name = 'Cross' or s.name = 'In' or s.name = 'Overlap') -> isEmpty()

OCL constraints for validation of the networks defined in the schema.

K context Network

not self.base_Class.ownedAttribute.association.memberEnd.class.getAppliedStereotypes() -> select(s | s.name = 'Node') -> isEmpty()

L context Network

not self.base_Class.ownedAttribute.association.memberEnd.class .getAppliedStereotypes() -> select(s | s.name = 'UnidirectionalArc' or s.name = 'BidirectionalArc') -> isEmpty()

M context Arc

not self.base_Class.ownedAttribute.association.memberEnd.class .getAppliedStereotypes() -> select(s | s.name = 'Node') -> isEmpty()

N context Node

not self.base_Class.ownedAttribute.association.memberEnd.class .getAppliedStereotypes() -> select(s | s.name = 'UnidirectionalArc' or s.name = 'BidirectionalArc') -> isEmpty()

OCL constraints for validation of topological relationships of type In and Disjoint.

O context In

self.base_Association.memberEnd.class -> forAll (c | c.getAppliedStereotypes() -> select(s | s.name = 'Point' or s.name = 'Line' or s.name = 'Polygon') -> notEmpty())

P context Disjoint

self.base_Association.memberEnd.class -> forAll (c | c.getAppliedStereotypes() -> select(s | s.name = 'Point' or s.name = 'Line' or s.name = 'Polygon') -> notEmpty())

OCL constraints for validation of topological relationships of type Cross, Overlap and

Touch.

Q context Cross

let classes : OrderedSet(Class) = self.base_Association.memberEnd.class -> asOrderedSet() in ((classes -> at(1)).getAppliedStereotypes() -> select(s | s.name = 'Line') -> notEmpty() and (classes -> at(2)).getAppliedStereotypes() -> select(s | s.name = 'Line') -> notEmpty() ) or ((classes -> at(1)).getAppliedStereotypes() -> select(s | s.name = 'Line') -> notEmpty() and (classes -> at(2)).getAppliedStereotypes() -> select(s | s.name = 'Polygon') -> notEmpty() ) or ((classes -> at(1)).getAppliedStereotypes() -> select(s | s.name = 'Polygon') -> notEmpty() and (classes -> at(2)).getAppliedStereotypes() -> select(s | s.name = 'Line') -> notEmpty() )

R context Overlap

let classes : OrderedSet(Class) = self.base_Association.memberEnd.class -> asOrderedSet() in ((classes -> at(1)).getAppliedStereotypes() -> select(s | s.name = 'Line') -> notEmpty() and (classes -> at(2)).getAppliedStereotypes() ->

14

select(s | s.name = 'Line') -> notEmpty() ) or ((classes -> at(1)).getAppliedStereotypes() -> select(s | s.name = 'Polygon') -> notEmpty() and (classes -> at(2)).getAppliedStereotypes() -> select(s | s.name = 'Polygon') -> notEmpty() )

S context Touch

let classes : OrderedSet(Class) = self.base_Association.memberEnd.class -> asOrderedSet() in ((classes -> at(1)).getAppliedStereotypes() -> select(s | s.name = 'Polygon') -> notEmpty() and (classes -> at(2)).getAppliedStereotypes() -> select(s | s.name = 'Polygon') -> notEmpty() ) or ((classes -> at(1)).getAppliedStereotypes() -> select(s | s.name = 'Line') -> notEmpty() and (classes -> at(2)).getAppliedStereotypes() -> select(s | s.name = 'Line') -> notEmpty() ) or ((classes -> at(1)).getAppliedStereotypes() -> select(s | s.name = 'Line') -> notEmpty() and (classes -> at(2)).getAppliedStereotypes() -> select(s | s.name = 'Polygon') -> notEmpty() ) or ((classes -> at(1)).getAppliedStereotypes() -> select(s | s.name = 'Polygon') -> notEmpty() and (classes -> at(2)).getAppliedStereotypes() -> select(s | s.name = 'Line') -> notEmpty() ) or ((classes -> at(1)).getAppliedStereotypes() -> select(s | s.name = 'Point') -> notEmpty() and (classes -> at(2)).getAppliedStereotypes() -> select(s | s.name = 'Polygon') -> notEmpty() ) or ((classes -> at(1)).getAppliedStereotypes() -> select(s | s.name = 'Polygon') -> notEmpty() and (classes -> at(2)).getAppliedStereotypes() -> select(s | s.name = 'Point') -> notEmpty() ) or ((classes -> at(1)).getAppliedStereotypes() -> select(s | s.name = 'Point') -> notEmpty() and (classes -> at(2)).getAppliedStereotypes() -> select(s | s.name = 'Line') -> notEmpty() ) or ((classes -> at(1)).getAppliedStereotypes() -> select(s | s.name = 'Line') -> notEmpty() and (classes -> at(2)).getAppliedStereotypes() -> select(s | s.name = 'Point') -> notEmpty() )

Recalling that the OCL constraints of the GeoProfile validate only the conceptual

schema; is valid to say that a topological relationship modeled between classes that

have multiple representation is conceptually correct if the type of topological

relationship can exist for at least one geographical representation of the classes

concerned. In this case, the application has to restrict which geographical

representation of the class will be involved in the relationship.

4. Applying Icons to Stereotypes

Icons can be associated with stereotypes for a clearer representation of diagram

elements.

To associate an icon to a stereotype, right-click the stereotype to which to apply the

icon in the Outline window. On the menu, go to Add an element and add the element

Image in the stereotype.

15

Let's put an icon on the stereotype Point. See the Image element will appear within

the tab this stereotype. Now select the element Image added, and in the window

Properties on the tab General, choose the image properties, in the field Kind select

Icon, now on the button + Content select the icon you want to add to the stereotype.

16

See the icon added will appear in front of the field Content.

Now you can add the other icons of other stereotypes: Point, Line, Polygon,

ComplexSpatialObj, TemporalObj, TIN, Isolines, GridOfCells, GridOfPoints,

IrregularPoints, AdjPolygons, Node, UniderctionalArc, BidirectionalArc, Touch, In,

Cross, Overlap, Disjoint e Network.

5. Applying the GeoProfile

With the profile created, we can use it in our modeling geographical classes. To use the

profile, start by creating a new model: File-New-> Create an empty model.

17

Name the model and choose where it will be:

Select the model (or Package) on the Outline window, then on the Properties window

go to the tab Profile and click the button + Apply profile.

18

On the window that follows, select the profile you want to apply to the model, in this

case, GeoProfile.

Now, with the profile applied, you can apply the stereotypes of GeoProfile in UML

elements. To test the GeoProfile, create a class, have it selected and click the button

+ (Add a new element) in the field Applied Stereotypes in the tab Profile.

19

On the window that follows select the stereotype you want to apply. Let's select

stereotypes Point and Polygon. Then click OK.

Note: you can apply more of one stereotype to a same class, the OCL constraints

described above prevent incompatible stereotypes are applied in the same class.

20

As defined in the GeoProfile, stereotypes can also be applied to relationships. Add one

more class with any stereotype and an element Association between them.

21

Select the object Association added and add a stereotype to proceed in the same way

as shown for objects of type Class.

The visualization of stereotypes may be made in written form, via icons or both. To

change the appearance of stereotype select the class to which you want to modify, and

in the tab Appearance of the Properties window, select the type of view in the field

Stereotype Appearance. Switch to Icon and see the result.

22

There are occurrences of problems when viewing more than one stereotype by class. If

it is applied over a stereotype to a class, can only be viewed the icon of the first

stereotype applied. To work around this problem, you should opt for the visualization

of stereotypes in textual form or text and icon.

23

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 in the model with the stereotype TemporalObj.

The value of each tagged value for this object type can be defined in the tab Profile of

the Properties window. To do this, select the field that you want to change, a new field

Property values will appear with the default value for this tag. Papyrus considers the

first value declared as the default value.

24

To change this value, simply double-click on the value already exists, and a new

window will open to choice the new field value.

Other UML elements can also be added to the model as packages, attributes, operations, data types, etc. To add new elements to the model, you can use the Palette tab or right-click on the model in the Outline tab; on the menu choose Add an element and all elements can be added to the model will be shown.

This is enough to create a UML model for modeling spatial database by using the tool

Papyrus using the GeoProfile. An example "Escola" using this profile is shown below.

25

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

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 any stereotype.

The next step is to validate our model using OCL constraints defined in the GeoProfile.

To do this, open the file Escola.uml that appears in the Navigator window. On the

window that opens, click with the right mouse button on the model "<Model> Escola"

and go on (Validation-Validate > OCL constraints defined in Stereotypes).

26

A validation confirmation window will appear. If there is any inconsistency in the

model, an error message is shown.

More information about this tool can be found at:

http://www.papyrusuml.org/home/index.htm