how to get names from some metaclasses [message #528290] |
Mon, 19 April 2010 20:12  |
Eclipse User |
|
|
|
hi,guys.
i am using Acceleo to do a project about translating UML class diagram into first order logic formulas(prolog). One of the translation rules is for each metaclass named MC in the metamodel,we define a unary atomic predicate MC(x).And we can see the predicates for Class Diagram including: ValueSpecification(x),Class(x),Interface(x),Feature(x),...,e tc.
I can finish this job by using such templates:
[template public ValueSpecificationToPL(v:ValueSpecification)]
ValueSpecification([v.name.toUpperFirst()/]).
[/template]
[template public ClassToPL(c:Class)]
Class([c.name.toUpperFirst()/]).
[/template]
....
but i find that i can not get names from some metaclasses,including MultiplicityElement,Relationship,DirectedRelationship,Genera lization,ParameterDirectionKind,AggregationKind,VisibilityKi nd.
how can i get names from these metaclasses to finish the translation??
Thanks for help!
|
|
|
Re: how to get names from some metaclasses [message #528339 is a reply to message #528290] |
Tue, 20 April 2010 04:25   |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------040302080307070502090405
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi,
Under Eclispe you can easily import the UML plugin (File => import =>
plugins and fragments => select "org.eclipse.uml2.uml") and then take a
look at the metamodel to try and find what properties are used as "name"
for such or such metaclass.
However ... the clases you list here have no name attribute whatsoever.
"VisibilityKind" for one (and all "*Kind" classes) is an enumeration.
Why would you need a name for an enumeration type instead of using the
enumeration literal itself? The remainder (RelationShip, Generalization,
MultiplicityElement, ...) aren't named elements either ... could you be
a little more specific as to what you need?
Laurent Goubet
Obeo
lisadou wrote:
> hi,guys. i am using Acceleo to do a project about translating UML class
> diagram into first order logic formulas(prolog). One of the translation
> rules is for each metaclass named MC in the metamodel,we define a unary
> atomic predicate MC(x).And we can see the predicates for Class Diagram
> including: ValueSpecification(x),Class(x),Interface(x),Feature(x),...,e
> tc. I can finish this job by using such templates:
> [template public ValueSpecificationToPL(v:ValueSpecification)]
> ValueSpecification([v.name.toUpperFirst()/]). [/template]
> [template public ClassToPL(c:Class)] Class([c.name.toUpperFirst()/]).
> [/template]
> ...
> but i find that i can not get names from some metaclasses,including
> MultiplicityElement,Relationship,DirectedRelationship,Genera
> lization,ParameterDirectionKind,AggregationKind,VisibilityKi nd. how can
> i get names from these metaclasses to finish the translation??
> Thanks for help!
>
--------------040302080307070502090405
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------040302080307070502090405--
|
|
|
|
|
|
|
|
Re: how to get names from some metaclasses [message #528672 is a reply to message #528667] |
Wed, 21 April 2010 08:47  |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------030205040405080308040308
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
P.S: Note : if what you need is simply an iteration count, we define an
implicit variable named "i" for each Acceleo for loop. Thus you can do
something like :
[for (Sequence{'a', 'b', 'c'})]
[i/] = [self/]
[/for]
to generate the text :
1 = a
2 = b
3 = c
Laurent Goubet
Obeo
Laurent Goubet wrote:
> Lisadou,
>
> There was discussions quite a while ago about this very example you
> quote from the specification. I'll shamelessly quote myself :
>
> "Unfortunately, the specification as a fair number of 'examples' that
> simply cannot work as they're either contradicting other parts of the
> specification or they contradict the OCL specification."
>
> You can read this discussion here if you're interested :
> http://www.eclipse.org/forums/index.php?t=msg&th=19986&a mp;start=0 .
>
> The gist of it is : "int count = -1;" is a syntax error, and "count =
> count + 1" is both syntaxically incorrect and cannot work as expected.
> The OMG issue http://www.omg.org/issues/mtt-rtf.open.html#Issue14438
> descibes the problems in the specification pertaining to this particular
> example.
>
> Laurent Goubet
> Obeo
>
> lisadou wrote:
>> Thanks a lot for your detail explanation.
>> May be i didn't express myself clearly.Actually such codes can be
>> found in the OMG MOF Model to Test Transformation Language v1.0(Page 40):
>>
>> [template public class_header(c : Class) { int count = -1; } ]
>> [file (c.name +'.cpp', false)]
>> [trace(c.id() +'_header')]
>> // Bit vector #definies
>> [for(a : Attribute) | c.attribute) { count = count + 1; }]
>> #define [a.name/]_BIT [count/]
>> [/for]
>> ....
>>
>>
>> we can see that it uses variable "count" to help generate C++ code.
>> If i should use OCL expression "a : Integer = 1;" to replace { int
>> count = -1; }, how can i realize the function of { count = count + 1;
>> }? Please advice.
>
--------------030205040405080308040308
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------030205040405080308040308--
|
|
|
Powered by
FUDForum. Page generated in 0.27235 seconds