UML2 profiles

33 views
Skip to first unread message

Jim Steel

unread,
Aug 3, 2011, 8:30:03 PM8/3/11
to tef...@googlegroups.com

Has anyone got experience writing tefkat transformations that generate UML2 models using profiles?

Jim.

michael lawley

unread,
Aug 4, 2011, 7:20:32 AM8/4/11
to tef...@googlegroups.com
ugh - back in the day I attempted to write some transformations that
created UML2 classes with stereotypes, but the only mechanism to do
this that was offered by the UML in EMF implementation required
calling methods (i.e., with side effects) *AND* you had to call them
in a specific order. That is, you could not just create all the
required UML2 metamodel instances and link them up via their
attributes. Needless to say, this became a head very quickly given
Tefkat's declarative nature and penchant for reordering terms during
evaluation.

I don't know if things have changed since then.

michael

Jim Steel

unread,
Aug 4, 2011, 7:36:53 AM8/4/11
to tef...@googlegroups.com
I was looking at the models that seem to be generated and it seems to work like this.

The definition of the profile, stored in x.profile.uml or some such file, includes
+ profile x
   + stereotype y
   + eAnnotations
      + ePackage x
         + eClass y

And then the use of the profile, in some file a.uml, has
+ uml:package a
   + uml:class b
   + x:y base_class=b

Which actually looks like it'd be fairly to do in tefkat, if I can only get my transformation to point a NAMESPACE statement inside the eAnnotations of the profile file. So far I'm struggling to do that, either because of the vagaries of xpath or because tefkat is pulling up short as soon as it opens the resource and finds something non-ecore.

(I say "I" was doing this, in fact it's primarily Eban, who may join the conversation at some point :)

Jim.





--
You received this message because you are subscribed to the Google Groups "Tefkat" group.
To post to this group, send an email to tef...@googlegroups.com.
To unsubscribe from this group, send email to tefkat+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/tefkat?hl=en-GB.


Eban Escott

unread,
Sep 17, 2011, 8:45:22 PM9/17/11
to Tefkat
Hi Michael and Jim,

I have trimmed down the various files so we can look at the relevant
parts. I think the 4 relevant files you need to see are:

test.profile.uml
test.uml
stereotype2stereotype.qvt
output.uml

I will paste the file below. Apologies for the dump as I could not
work out how to surround them with code tags.

Thanks for your help
Eban

//////////////////////
The UML Porfile:
//////////////////////
<?xml version="1.0" encoding="UTF-8"?>
<uml:Profile xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/
XMI/2.1" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML"
xmi:id="_vuQBkIepEd6G9vv1xOexfw" name="test"
metaclassReference="_hoX2kIeqEd6G9vv1xOexfw">
<eAnnotations xmi:id="_pts-8IeqEd6G9vv1xOexfw" source="http://
www.eclipse.org/uml2/2.0.0/UML">
<contents xmi:type="ecore:EPackage"
xmi:id="_9sDJ8OGDEeCcnryUetHFvw" name="test" nsURI="http:///schemas/
test/_9sAtsOGDEeCcnryUetHFvw/0" nsPrefix="test">
<eClassifiers xmi:type="ecore:EClass"
xmi:id="_9sDJ8eGDEeCcnryUetHFvw" name="domain">
<eAnnotations xmi:id="_9sDJ8uGDEeCcnryUetHFvw" source="http://
www.eclipse.org/uml2/2.0.0/UML" references="_bR-8QIeqEd6G9vv1xOexfw"/>
<eStructuralFeatures xmi:type="ecore:EReference"
xmi:id="_9sDJ8-GDEeCcnryUetHFvw" name="base_Class" ordered="false"
lowerBound="1">
<eType xmi:type="ecore:EClass" href="http://www.eclipse.org/
uml2/3.0.0/UML#//Class"/>
</eStructuralFeatures>
</eClassifiers>
</contents>
</eAnnotations>
<elementImport xmi:id="_hoX2kIeqEd6G9vv1xOexfw">
<importedElement xmi:type="uml:Class" href="pathmap://
UML_METAMODELS/UML.metamodel.uml#Class"/>
</elementImport>
<packagedElement xmi:type="uml:Stereotype"
xmi:id="_bR-8QIeqEd6G9vv1xOexfw" name="domain">
<ownedAttribute xmi:id="_lcH1AoeqEd6G9vv1xOexfw" name="base_Class"
association="_lcH1AIeqEd6G9vv1xOexfw">
<type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/
UML.metamodel.uml#Class"/>
</ownedAttribute>
</packagedElement>
<packagedElement xmi:type="uml:Extension"
xmi:id="_lcH1AIeqEd6G9vv1xOexfw" name="Class_domain"
memberEnd="_lcH1AYeqEd6G9vv1xOexfw _lcH1AoeqEd6G9vv1xOexfw">
<ownedEnd xmi:type="uml:ExtensionEnd"
xmi:id="_lcH1AYeqEd6G9vv1xOexfw" name="extension_domain"
type="_bR-8QIeqEd6G9vv1xOexfw" aggregation="composite"
association="_lcH1AIeqEd6G9vv1xOexfw"/>
</packagedElement>
</uml:Profile>

//////////////////////
The UML model:
//////////////////////
<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/
2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:test="http:///schemas/test/_9sAtsOGDEeCcnryUetHFvw/0"
xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML"
xsi:schemaLocation="http:///schemas/test/_9sAtsOGDEeCcnryUetHFvw/
0 ../../Profile/model/test.profile.uml#_9sDJ8OGDEeCcnryUetHFvw">
<uml:Package xmi:id="_bl5HgOGEEeCcnryUetHFvw"
name="au.edu.uq.itee.output">
<packagedElement xmi:type="uml:Class"
xmi:id="_bl68sOGEEeCcnryUetHFvw" name="Horse"/>
<profileApplication xmi:id="_uIFQUOGEEeCcnryUetHFvw">
<eAnnotations xmi:id="_uIF3YOGEEeCcnryUetHFvw" source="http://
www.eclipse.org/uml2/2.0.0/UML">
<references xmi:type="ecore:EPackage" href="../../Profile/
model/test.profile.uml#_9sDJ8OGDEeCcnryUetHFvw"/>
</eAnnotations>
<appliedProfile href="../../Profile/model/
test.profile.uml#_vuQBkIepEd6G9vv1xOexfw"/>
</profileApplication>
</uml:Package>
<test:domain xmi:id="_xukO0OGEEeCcnryUetHFvw"
base_Class="_bl68sOGEEeCcnryUetHFvw"/>
</xmi:XMI>

//////////////////////
The QVT file:
//////////////////////
TRANSFORMATION stereotype2stereotype : domain -> test

NAMESPACE http://www.eclipse.org/emf/2002/Ecore
NAMESPACE http://www.eclipse.org/uml2/3.0.0/UML
NAMESPACE platform:/resource/Profile/model/test.profile.uml

//Tracability for package to package
CLASS Package2PackageTrace {
Package srcPkg;
Package tgtPkg;
};

//Tracability for type to type
CLASS Type2TypeTrace {
EObject srcEObject;
EObject tgtEObject;
};

//Make a new package
RULE Package2Package
FORALL Package p
MAKE Package p2 {
name: p.name;
profileApplication: p.profileApplication;
}
LINKING Package2PackageTrace WITH srcPkg=p, tgtPkg=p2
;

//Make a new domain stereotyped class in the target package
RULE Class2Domain
FORALL Class c, Package p, _ d
WHERE d.base_Class = c
AND p.packagedElement = c
AND Package2PackageTrace LINKS srcPkg=p, tgtPkg=p2
//TODO apply the stereotype
MAKE Class c2 {
name: c.name;
}
SET p2.packagedElement = c2
LINKING Type2TypeTrace WITH srcEObject=c, tgtEObject=c2
;

//////////////////////
The output UML model:
//////////////////////
<?xml version="1.0" encoding="UTF-8"?>
<uml:Package xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/
XMI/2.1" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML"
xmi:id="_UpwmYOGFEeCcnryUetHFvw" name="au.edu.uq.itee.output">
<packagedElement xmi:type="uml:Class"
xmi:id="_UpxNcOGFEeCcnryUetHFvw" name="Horse"/>
<profileApplication xmi:id="_uIFQUOGEEeCcnryUetHFvw"
appliedProfile="../../Profile/model/
test.profile.uml#_vuQBkIepEd6G9vv1xOexfw">
<eAnnotations xmi:id="_uIF3YOGEEeCcnryUetHFvw" source="http://
www.eclipse.org/uml2/2.0.0/UML" references="ecore:EPackage ../../
Profile/model/test.profile.uml#_9sDJ8OGDEeCcnryUetHFvw"/>
</profileApplication>
</uml:Package>

Jim Steel

unread,
Oct 27, 2011, 2:37:17 AM10/27/11
to tef...@googlegroups.com
As an update, Eban and I got this partly working this morning, but there are still issues.

Firstly, NAMESPACE imports rely on the resources having an EPackage as a direct child of the resource. This is fairly easily fixed, in both the engine and the parser, by asking the import resolution to iterate over allContents rather than just contents (expensive perhaps, for big models). 

Unfortunately, after doing this, we seem to be getting AnyType objects rather than dynamic instances, which stuffs up the resolution of properties. I put in a hack for this for now, to crack open the AnyTypes, but I'm pretty sure its the wrong way to go about it.



michael lawley

unread,
Oct 27, 2011, 9:50:26 PM10/27/11
to tef...@googlegroups.com
There may be some EMF Utility methods to better handle this now?

I know when the code was originally written there were a whole bunch
of things I had to do manually wrt getting stuff out of resources fort
which there are now utility methods (which probably would work better
in a CDO environment for example).

Alternatively, can an EPackage be anywhere in a Resource, or are there
only certain well-know containment patterns (so we could traverse them
from the root rather than allContents)?

michael

Jim Steel

unread,
Nov 10, 2011, 8:57:51 PM11/10/11
to tef...@googlegroups.com
Seems we have it working. The NAMESPACE resolution is probably a little slow. The EPackage isn't absolutely anywhere - specifically, its within the EAnnotations of a Stereotype, which I guess is within a Profile, but that can be at various depths because of package nesting and so on, I think.

As a side note, the editor for defining and applying profiles in UML2 is pretty mad. For example, if you change a one of your stereotypes, there's this weird dance you have to do to convince it to generate the EPackage/EClass inside the EAnnotation (which doesn't get rid of the old ones, incidentally, it just adds new ones in there), then play awful games to make sure old models use the new stereotype rather than the old one.
Reply all
Reply to author
Forward
0 new messages