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 11:00  |
Eclipse User |
|
|
|
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 05:17   |
Eclipse User |
|
|
|
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 05:18  |
Eclipse User |
|
|
|
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 05:17  |
Eclipse User |
|
|
|
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 05:18  |
Eclipse User |
|
|
|
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
|
|
|
Goto Forum:
Current Time: Thu May 08 13:02:20 EDT 2025
Powered by FUDForum. Page generated in 0.07027 seconds
|