OCL with enum (TopicType = TopicType::Content)
CapableObjects Forums
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



OCL with enum (TopicType =... Expand / Collapse
Author
Message
Posted 2009-02-02 06:09:21


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 2010-08-11 16:02:44
Posts: 338, Visits: 890
Hi,

There's an enum:
public enum TopicType {
Content = 0,
BlogPost = 1 // etc
}

And there's an object Topic with property TopicType: TopicType (property name is equal to enum name).

When I try to execute OCL like: Topic.allinstances->select(TopicType = TopicType::Content)
it fails with error:
Borland.Eco.Internal.EBoldOCLError: 42:Unable to deduce type of expression
Operation: =
Arg 1: , Arg 2: TestApp.TopicType
Using deduce method: the two parameters must belong to the same domain (type, object, value)
at Borland.Eco.Internal.TBoldOclSemanticsVisitor.DeduceBoldType(TBoldOclOperation N)
at Borland.Eco.Internal.TBoldOclSemanticsVisitor.VisitTBoldOclOperation(TBoldOclOperation N)
at Borland.Eco.Internal.TBoldOclOperation.AcceptVisitor(TBoldOclVisitor V)


When I try to execute OCL like: Topic.allinstances->select(TopicType = #Content)
it fails with error:
Borland.Eco.Internal.EBoldOCLError: 42:Unable to deduce type of expression
Operation: =
Arg 1: , Arg 2:
Using deduce method: the two parameters must belong to the same domain (type, object, value)
at Borland.Eco.Internal.TBoldOclSemanticsVisitor.DeduceBoldType(TBoldOclOperation N)
at Borland.Eco.Internal.TBoldOclSemanticsVisitor.VisitTBoldOclOperation(TBoldOclOperation N)
at Borland.Eco.Internal.TBoldOclOperation.AcceptVisitor(TBoldOclVisitor V)


Isn't there a way to have enum and property with the same name?
It's Eco3, not sure how it behaves in Eco4-5.

Regards,
Dmitriy.


My Blog: http://dnagir.blogspot.com
Post #2083
Posted 2009-02-02 06:20:40


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 2010-08-11 16:02:44
Posts: 338, Visits: 890
While ECO cannot resolve the property and type we can use workaround by explicitly using object:
Topic.allinstances->select(t | t.TopicType = TopicType::Content)


My Blog: http://dnagir.blogspot.com
Post #2086
Posted 2009-02-03 12:12:39
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 2012-01-26 14:59:09
Posts: 242, Visits: 828
I guess if you put it like this:

Topic.allinstances->select(t | topicType = TopicType::Content)

If you have name conflict between types and properties in OCL, you can resove it with context sensitivity: the first small letter for property, the first capital letter: for type. I'm not sure though if this rule of thumb will be used in ECO >4 versions too.

BTW it's not specific for enumerations, but for all types.

/Efim

Post #2110
Posted 2009-02-03 23:08:22


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 2010-08-11 16:02:44
Posts: 338, Visits: 890
he first small letter for property, the first capital letter: for type

Interesting. I've tried and this and it seems this little trick works: Topic.allinstances->select(topicType = TopicType::Content)

Thanks for the tip.


My Blog: http://dnagir.blogspot.com
Post #2123
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: HansKarlsen, Jonas Hogstrom, PeterMorris

Permissions Expand / Collapse

All times are GMT +1:00, Time now is 9:31

Powered By InstantForum.NET v4.1.4 © 2012
Execution: 0,172. 6 queries. Compression Disabled.