OCL for Versioned class
CapableObjects Forums
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



OCL for Versioned class Expand / Collapse
Author
Message
Posted 2010-03-29 03:06:08
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 2011-09-26 22:51:32
Posts: 34, Visits: 111
Hi,

I would really appreciate if someone could help with a what should be a fairly simple(?) piece of ocl, it's just I can't figure out the syntax correctly.

The Query is to be run on the PS service...

pseudo code:

Select Car where Car.Manufacturer.Name = "Mercedes" and Car.ManufactureDate = Mach2010

Note Manufacturer is a VERSIONED class (but not Car)

[which is why I'm not able to use the ideal way of doing this: self.Cars.AllInstances->Select(ManufactureDate=date) and suppy the Mercedes Manufacturer obect as an arg]


Maybe there's an even better way of doing this?

thanks
Andy
Post #5061
Posted 2010-04-01 12:07:00
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 2011-07-14 17:05:00
Posts: 290, Visits: 2 617
AndyG (2010-03-29)
Hi,

I would really appreciate if someone could help with a what should be a fairly simple(?) piece of ocl, it's just I can't figure out the syntax correctly.

The Query is to be run on the PS service...

pseudo code:

Select Car where Car.Manufacturer.Name = "Mercedes" and Car.ManufactureDate = Mach2010

Note Manufacturer is a VERSIONED class (but not Car)

[which is why I'm not able to use the ideal way of doing this: self.Cars.AllInstances->Select(ManufactureDate=date) and suppy the Mercedes Manufacturer obect as an arg]


Maybe there's an even better way of doing this?

thanks
Andy


You haven't told us what you want to achieve.


====
Pete
Post #5101
Posted 2010-04-05 23:11:09
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 2011-09-26 22:51:32
Posts: 34, Visits: 111
Hi Pete,

well, it's all about performance optimisation. I need to retrieve a relatively small result set of a class that will have ever an increasing persisted number of objects. At our longest established customer site there are currently 30,000 persisted objects of a class with an "association" to a Versioned class (of lesser count). This will of course grow over the coming years, 100k to 1M.... (There are also other classes in our business model that this applies to, but just picking the prime example here) A typical results set would be 1-300 objects, so really we need to optimise using the PS service. Especially now that we use a transient ecospace for each user initiated (and automated) task processed.

Andy
Post #5110
Posted 2010-04-06 01:51:38
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Yesterday @ 22:44:38
Posts: 144, Visits: 679
Hello Andy,
indeed your OCL should be the ideal way of doing it:

[which is why I'm not able to use the ideal way of doing this: self.Cars.AllInstances->Select(ManufactureDate=date) and suppy the Mercedes Manufacturer obect as an arg]

You get all cars loaded that are associated with your versioned manufacturer and select the date in memory. And: OCLPS does not work. What can you do?

 

In normal cases OCL an OCLPS give you all tools to create a fast application. Versioning is one case where I could imagine to fall back to SQL for fetching objects. We have implemented this method to get objects by SQL but we have not used it till now. It's a fallback solution if we get perfomance issues which could be the case for you.

Post #5111
Posted 2010-04-07 01:00:10
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 2011-09-26 22:51:32
Posts: 34, Visits: 111
Hi Peter,

thanks for digging out that code from 2006! The classes that are Versioned really need to stay that way, this feature of Eco is really a perfect solution for us. Except that the implementation seems still incomplete to me, and would be totally awesome with a bit more flexibility. For example another issue that we have is that a PS query only returns persisted objects, I would love to have the option to include "new" (un-saved) objects in the ecospace in the results set. So that I can add one or two objects to my ecospace without having to use ocl.AllInstances and load 10,000's of ID's. So maybe I'm going to have to get into using this workaround and start writing SQL again! Having this kind of flexibility is really good, but the code is not simple!


As specified the ReadSQL code was written for ECO III so now there's some differences to accommodate (we're using ECO IV). I've fixed up the easy things but am left with the build errors copied below. Can someone suggest how to convert this to ECO IV+ ?


Code: IEcoStructuralFeature sf = oClass.EcoClass.AllStructuralFeatures[i].EcoStructuralFeature;
Warning 'Eco.UmlRt.IStructuralFeature.EcoStructuralFeature' is obsolete: 'All properties moved to IStructuralFeature'


Code: myEcoSpaceType.ExtractFieldName((sc[0] as ColumnReference).AliasColumn)));
Error The best overloaded method match for 'myNameSpace.myEcoSpaceType.ExtractFieldName(string)' has some invalid arguments Argument '1': cannot convert from 'method group' to 'string'


Code: Result.Add( this.GetIObjectByObjectId( NewObjectId ) );
Error 'myNameSpace.myEcoSpaceType' does not contain a definition for 'GetIObjectByObjectId' and no extension method 'GetIObjectByObjectId' accepting a first argument of type 'myNameSpace.myEcoSpaceType' could be found (are you missing a using directive or an assembly reference?)
Post #5114
Posted 2010-04-07 22:53:48
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 2010-04-07 22:36:16
Posts: 32, Visits: 78
Hi Andy

Last I looked the oclPS service does _not_ work with versioned classes. The PS will retrieve all objects that fits the query, and not only the last "active" object as you would expect. You cannot use PS to retrieve the latest version, sorry. See bug reports -> mantis 480 and 845. Issue 480 have been reported for a long time (May 14, 2008), but nothing seem to happen.

To load both persisted and in-memory objects, do the following:
1) Use the PS service to retrieve all the needed objects from the persisted storage. This loads the selected objects into the cache.
2) Then use ocl -> "< aClass >.allLoadedObjects->select(< query >)".

Hope this helps

Per
Post #5119
Posted 2010-04-08 02:25:47
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 2011-09-26 22:51:32
Posts: 34, Visits: 111
Hi,

That's a nice way to merge loaded and persisted ojects, very useful, thanks!

Andy
Post #5120
« 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:46

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