Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [Epsilon] Compare an enumeration value with a string in EVL
[Epsilon] Compare an enumeration value with a string in EVL [message #8533] Mon, 12 January 2009 16:00 Go to next message
Hector Iturria is currently offline Hector IturriaFriend
Messages: 60
Registered: July 2009
Member
Hi!

I am still using EVL to validate UML (I say "still" becuase it has
passed a long time since my last question) and I have found something
wrong (or that I don't know how to do it).

The thing is that I tried to compare an enumeration value with a string,
because it was the first that came to my head, but didn't work. But I
never surrender, so I copied the check line and pasted it in the message
instrucction to watch what was returning my code, and to my surprise it
was indeed returning what I expected. However, the test failed. You'll
see what I mean with an example:

The constraint:

constraint isShared{

check: self.packagedElement.select(a: Association | a.name=
'Association1').first().ownedEnd.select(p: Property | p.name =
'dst').first().aggregation = 'shared'

message: 'The Associoation must have the field Aggregation = shared
and is ' + self.packagedElement.select(a: Association | a.name=
'Association1').first().ownedEnd.select(p: Property | p.name =
'dst').first().aggregation

}

returns: 'The Associoation must have the field Aggregation = shared and
is shared


After confirming that there were no troubles with blank spaces next to
check were data types. And managed to compare them converting the
enumeration value into a string, through appending an string:

constraint isShared{

check: self.packagedElement.select(a: Association | a.name=
'Association1').first().ownedEnd.select(p: Property | p.name =
'dst').first().aggregation+'' = 'shared'

message: 'The Associoation must have the field Aggregation = shared
and is ' + self.packagedElement.select(a: Association | a.name=
'Association1').first().ownedEnd.select(p: Property | p.name =
'dst').first().aggregation

}

This workaround works fine, but I don't know if it is the best way to do
it. I tought you may want to know this.

Best regards,
Héctor Iturria
Re: [Epsilon] Compare an enumeration value with a string in EVL [message #8565 is a reply to message #8533] Tue, 13 January 2009 10:17 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Hector,

The value of the .aggregation property is not a string; it is an
instance of class org.eclipse.uml2.uml.AggregationKind (you can see this
by doing a .aggregation.getClass().println()). To obtain the actual
string you should call .aggregation.literal . I've seen this before and
I think that it has to do with dynamic vs. generated EMF, but I have to
investigate more.

Cheers,
Dimitris

Héctor Iturria wrote:
> Hi!
>
> I am still using EVL to validate UML (I say "still" becuase it has
> passed a long time since my last question) and I have found something
> wrong (or that I don't know how to do it).
>
> The thing is that I tried to compare an enumeration value with a string,
> because it was the first that came to my head, but didn't work. But I
> never surrender, so I copied the check line and pasted it in the message
> instrucction to watch what was returning my code, and to my surprise it
> was indeed returning what I expected. However, the test failed. You'll
> see what I mean with an example:
>
> The constraint:
>
> constraint isShared{
>
> check: self.packagedElement.select(a: Association | a.name=
> 'Association1').first().ownedEnd.select(p: Property | p.name =
> 'dst').first().aggregation = 'shared'
>
> message: 'The Associoation must have the field Aggregation =
> shared and is ' + self.packagedElement.select(a: Association |
> a.name= 'Association1').first().ownedEnd.select(p: Property | p.name =
> 'dst').first().aggregation
>
> }
>
> returns: 'The Associoation must have the field Aggregation = shared and
> is shared
>
>
> After confirming that there were no troubles with blank spaces next to
> check were data types. And managed to compare them converting the
> enumeration value into a string, through appending an string:
>
> constraint isShared{
>
> check: self.packagedElement.select(a: Association | a.name=
> 'Association1').first().ownedEnd.select(p: Property | p.name =
> 'dst').first().aggregation+'' = 'shared'
>
> message: 'The Associoation must have the field Aggregation =
> shared and is ' + self.packagedElement.select(a: Association |
> a.name= 'Association1').first().ownedEnd.select(p: Property | p.name =
> 'dst').first().aggregation
>
> }
>
> This workaround works fine, but I don't know if it is the best way to do
> it. I tought you may want to know this.
>
> Best regards,
> Héctor Iturria
Re: Compare an enumeration value with a string in EVL [message #8582 is a reply to message #8565] Tue, 13 January 2009 10:18 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Forgot to mention that there is no reason to prefix messages with
[Epsilon] any more as this is a dedicated newsgroup.

Cheers,
Dimitris

Dimitrios Kolovos wrote:
> Hi Hector,
>
> The value of the .aggregation property is not a string; it is an
> instance of class org.eclipse.uml2.uml.AggregationKind (you can see this
> by doing a .aggregation.getClass().println()). To obtain the actual
> string you should call .aggregation.literal . I've seen this before and
> I think that it has to do with dynamic vs. generated EMF, but I have to
> investigate more.
>
> Cheers,
> Dimitris
>
> Héctor Iturria wrote:
>> Hi!
>>
>> I am still using EVL to validate UML (I say "still" becuase it has
>> passed a long time since my last question) and I have found something
>> wrong (or that I don't know how to do it).
>>
>> The thing is that I tried to compare an enumeration value with a
>> string, because it was the first that came to my head, but didn't
>> work. But I never surrender, so I copied the check line and pasted it
>> in the message instrucction to watch what was returning my code, and
>> to my surprise it was indeed returning what I expected. However, the
>> test failed. You'll see what I mean with an example:
>>
>> The constraint:
>>
>> constraint isShared{
>> check: self.packagedElement.select(a: Association |
>> a.name= 'Association1').first().ownedEnd.select(p: Property | p.name =
>> 'dst').first().aggregation = 'shared'
>> message: 'The Associoation must have the field
>> Aggregation = shared and is ' + self.packagedElement.select(a:
>> Association | a.name= 'Association1').first().ownedEnd.select(p:
>> Property | p.name = 'dst').first().aggregation
>> }
>>
>> returns: 'The Associoation must have the field Aggregation = shared
>> and is shared
>>
>>
>> After confirming that there were no troubles with blank spaces next to
>> check were data types. And managed to compare them converting the
>> enumeration value into a string, through appending an string:
>>
>> constraint isShared{
>> check: self.packagedElement.select(a: Association |
>> a.name= 'Association1').first().ownedEnd.select(p: Property | p.name =
>> 'dst').first().aggregation+'' = 'shared'
>> message: 'The Associoation must have the field
>> Aggregation = shared and is ' + self.packagedElement.select(a:
>> Association | a.name= 'Association1').first().ownedEnd.select(p:
>> Property | p.name = 'dst').first().aggregation
>> }
>>
>> This workaround works fine, but I don't know if it is the best way to
>> do it. I tought you may want to know this.
>>
>> Best regards,
>> Héctor Iturria
Re: [Epsilon] Compare an enumeration value with a string in EVL [message #563831 is a reply to message #8533] Tue, 13 January 2009 10:17 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Hector,

The value of the .aggregation property is not a string; it is an
instance of class org.eclipse.uml2.uml.AggregationKind (you can see this
by doing a .aggregation.getClass().println()). To obtain the actual
string you should call .aggregation.literal . I've seen this before and
I think that it has to do with dynamic vs. generated EMF, but I have to
investigate more.

Cheers,
Dimitris

Héctor Iturria wrote:
> Hi!
>
> I am still using EVL to validate UML (I say "still" becuase it has
> passed a long time since my last question) and I have found something
> wrong (or that I don't know how to do it).
>
> The thing is that I tried to compare an enumeration value with a string,
> because it was the first that came to my head, but didn't work. But I
> never surrender, so I copied the check line and pasted it in the message
> instrucction to watch what was returning my code, and to my surprise it
> was indeed returning what I expected. However, the test failed. You'll
> see what I mean with an example:
>
> The constraint:
>
> constraint isShared{
>
> check: self.packagedElement.select(a: Association | a.name=
> 'Association1').first().ownedEnd.select(p: Property | p.name =
> 'dst').first().aggregation = 'shared'
>
> message: 'The Associoation must have the field Aggregation =
> shared and is ' + self.packagedElement.select(a: Association |
> a.name= 'Association1').first().ownedEnd.select(p: Property | p.name =
> 'dst').first().aggregation
>
> }
>
> returns: 'The Associoation must have the field Aggregation = shared and
> is shared
>
>
> After confirming that there were no troubles with blank spaces next to
> check were data types. And managed to compare them converting the
> enumeration value into a string, through appending an string:
>
> constraint isShared{
>
> check: self.packagedElement.select(a: Association | a.name=
> 'Association1').first().ownedEnd.select(p: Property | p.name =
> 'dst').first().aggregation+'' = 'shared'
>
> message: 'The Associoation must have the field Aggregation =
> shared and is ' + self.packagedElement.select(a: Association |
> a.name= 'Association1').first().ownedEnd.select(p: Property | p.name =
> 'dst').first().aggregation
>
> }
>
> This workaround works fine, but I don't know if it is the best way to do
> it. I tought you may want to know this.
>
> Best regards,
> Héctor Iturria
Re: Compare an enumeration value with a string in EVL [message #563855 is a reply to message #8565] Tue, 13 January 2009 10:18 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Forgot to mention that there is no reason to prefix messages with
[Epsilon] any more as this is a dedicated newsgroup.

Cheers,
Dimitris

Dimitrios Kolovos wrote:
> Hi Hector,
>
> The value of the .aggregation property is not a string; it is an
> instance of class org.eclipse.uml2.uml.AggregationKind (you can see this
> by doing a .aggregation.getClass().println()). To obtain the actual
> string you should call .aggregation.literal . I've seen this before and
> I think that it has to do with dynamic vs. generated EMF, but I have to
> investigate more.
>
> Cheers,
> Dimitris
>
> Héctor Iturria wrote:
>> Hi!
>>
>> I am still using EVL to validate UML (I say "still" becuase it has
>> passed a long time since my last question) and I have found something
>> wrong (or that I don't know how to do it).
>>
>> The thing is that I tried to compare an enumeration value with a
>> string, because it was the first that came to my head, but didn't
>> work. But I never surrender, so I copied the check line and pasted it
>> in the message instrucction to watch what was returning my code, and
>> to my surprise it was indeed returning what I expected. However, the
>> test failed. You'll see what I mean with an example:
>>
>> The constraint:
>>
>> constraint isShared{
>> check: self.packagedElement.select(a: Association |
>> a.name= 'Association1').first().ownedEnd.select(p: Property | p.name =
>> 'dst').first().aggregation = 'shared'
>> message: 'The Associoation must have the field
>> Aggregation = shared and is ' + self.packagedElement.select(a:
>> Association | a.name= 'Association1').first().ownedEnd.select(p:
>> Property | p.name = 'dst').first().aggregation
>> }
>>
>> returns: 'The Associoation must have the field Aggregation = shared
>> and is shared
>>
>>
>> After confirming that there were no troubles with blank spaces next to
>> check were data types. And managed to compare them converting the
>> enumeration value into a string, through appending an string:
>>
>> constraint isShared{
>> check: self.packagedElement.select(a: Association |
>> a.name= 'Association1').first().ownedEnd.select(p: Property | p.name =
>> 'dst').first().aggregation+'' = 'shared'
>> message: 'The Associoation must have the field
>> Aggregation = shared and is ' + self.packagedElement.select(a:
>> Association | a.name= 'Association1').first().ownedEnd.select(p:
>> Property | p.name = 'dst').first().aggregation
>> }
>>
>> This workaround works fine, but I don't know if it is the best way to
>> do it. I tought you may want to know this.
>>
>> Best regards,
>> Héctor Iturria
Previous Topic:[Epsilon] Compare an enumeration value with a string in EVL
Next Topic:Small query on using Native
Goto Forum:
  


Current Time: Thu Apr 25 00:53:18 GMT 2024

Powered by FUDForum. Page generated in 0.03065 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top