Instances Migration error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Instances Migration error

dario trussardi
Hi,

        i have a class with some version.

        I'm interested to migrate all instances at the last version.



From programming guide i create the method:


migrateInstancesDTR

| hist  all  |

hist := DTRdbDatiSocietari classHistory.

all := SystemRepository listInstances: hist.

1 to: hist size -1 do:[ :index | ( hist at: index )
                migrateInstances: ( all at: index)
                to: ( hist at:  hist size) ].

^true


When do it  from Gemtools workspace the system erase the error:

ClassHistory (Object) | _error:args:
ClassHistory (Object) | _errorExpectedClass:
ClassHistory (Object) | _validateClass:
[] in Repository | _listInstances:limit:toDirectory:
IdentitySet (IdentityBag) | do:
Repository | _listInstances:limit:toDirectory:
Repository | listInstances:limit:
Repository | listInstances:
DTRdbDatiSocietari class | migrateInstancesDTR
Executed Code
GsMethod | _executeInContext:
String | evaluateInContext:symbolList:
JadeServer | evaluate:inContext:
JadeServer | printIt:in:



Any considerations ?


Thanks,
                Dario
Reply | Threaded
Open this post in threaded view
|

Re: Instances Migration error

Dale
Dario,

It looks like the _listInstances:limit:toDirectory: is doing a class validation against the passed in Array of classes and is expecting an Array not a ClassHistory, even though ClassHistory is a kindOf: Array.

Create an Array explicity from 'DTRdbDatiSocietari classHistory' to get around this problem.

Was this example in the manual? If so this is possibly a documentation bug (could you give me the section/page number so I can check it out?).

Dale
----- "Dario Trussardi" <[hidden email]> wrote:

| Hi,
|
| i have a class with some version.
|
| I'm interested to migrate all instances at the last version.
|
|
|
| From programming guide i create the method:
|
|
| migrateInstancesDTR
|
| | hist  all  |
|
| hist := DTRdbDatiSocietari classHistory.
|
| all := SystemRepository listInstances: hist.
|
| 1 to: hist size -1 do:[ :index | ( hist at: index )
| migrateInstances: ( all at: index)
| to: ( hist at:  hist size) ].
|
| ^true
|
|
| When do it  from Gemtools workspace the system erase the error:
|
| ClassHistory (Object) | _error:args:
| ClassHistory (Object) | _errorExpectedClass:
| ClassHistory (Object) | _validateClass:
| [] in Repository | _listInstances:limit:toDirectory:
| IdentitySet (IdentityBag) | do:
| Repository | _listInstances:limit:toDirectory:
| Repository | listInstances:limit:
| Repository | listInstances:
| DTRdbDatiSocietari class | migrateInstancesDTR
| Executed Code
| GsMethod | _executeInContext:
| String | evaluateInContext:symbolList:
| JadeServer | evaluate:inContext:
| JadeServer | printIt:in:
|
|
|
| Any considerations ?
|
|
| Thanks,
| Dario
Reply | Threaded
Open this post in threaded view
|

Re: Instances Migration error

dario trussardi

Hi Dale,


Dario,

It looks like the _listInstances:limit:toDirectory: is doing a class validation against the passed in Array of classes and is expecting an Array not a ClassHistory, even though ClassHistory is a kindOf: Array.

Create an Array explicity from 'DTRdbDatiSocietari classHistory' to get around this problem.

I change my method to: 

migrateInstancesDTR

|  all  arrayClassHist  |

arrayClassHist := Array withAll: DTRdbDatiSocietari classHistory.

all := SystemRepository listInstances: arrayClassHist.

1 to: hist size -1 do:[ :index | ( hist at: index ) 
migrateInstances: ( all at: index)
to: ( hist at:  hist size) ].

^true

but i found the same error.


Was this example in the manual? If so this is possibly a documentation bug (could you give me the section/page number so I can check it out?).
 
I have one hold print manual of  Gemstone Programming Guide  ( Gemstone/s version 6.0) 

But i found the same example into Gemstone Programming Guide ( Gemstone/64 Version 2.2 )

at page 205  point  Example 8.5 

Example 8.5 uses migrateInstances:to: to migrate all instances of all versions of a class, except the latest version, to the latest version.
Example 8.5
| animalHist allAnimals | animalHist := Animal classHistory. 
allAnimals := SystemRepository listInstances: animalHist.
 "Returns an array of the same size as the class history.
Each element in the array is a set corresponding to one version of the class. Each set contains all the instances of that version of the class."
1 to: animalHist size-1 do: [:index | (animalHist at: index) migrateInstances:(allAnimals at: index) to: (animalHist at: animalHist size)].

I hope this enough.....

Ciao,
Dario


Dale
----- "Dario Trussardi" <[hidden email]> wrote:

| Hi,
|
| i have a class with some version.
|
| I'm interested to migrate all instances at the last version.
|
|
|
| From programming guide i create the method:
|
|
| migrateInstancesDTR
|
| | hist  all  |
|
| hist := DTRdbDatiSocietari classHistory.
|
| all := SystemRepository listInstances: hist.
|
| 1 to: hist size -1 do:[ :index | ( hist at: index )
| migrateInstances: ( all at: index)
| to: ( hist at:  hist size) ].
|
| ^true
|
|
| When do it  from Gemtools workspace the system erase the error:
|
| ClassHistory (Object) | _error:args:
| ClassHistory (Object) | _errorExpectedClass:
| ClassHistory (Object) | _validateClass:
| [] in Repository | _listInstances:limit:toDirectory:
| IdentitySet (IdentityBag) | do:
| Repository | _listInstances:limit:toDirectory:
| Repository | listInstances:limit:
| Repository | listInstances:
| DTRdbDatiSocietari class | migrateInstancesDTR
| Executed Code
| GsMethod | _executeInContext:
| String | evaluateInContext:symbolList:
| JadeServer | evaluate:inContext:
| JadeServer | printIt:in:
|
|
|
| Any considerations ?
|
|
| Thanks,
| Dario

Reply | Threaded
Open this post in threaded view
|

Re: Instances Migration error

James Foster
In reply to this post by dario trussardi
On Apr 17, 2010, at 3:46 AM, Dario Trussardi wrote:

> Hi,
> i have a class with some version.
> I'm interested to migrate all instances at the last version.
>
> From programming guide i create the method:
>
> migrateInstancesDTR
> | hist  all  |
> hist := DTRdbDatiSocietari classHistory.
> all := SystemRepository listInstances: hist.
> 1 to: hist size -1 do:[ :index | ( hist at: index )
> migrateInstances: ( all at: index)
> to: ( hist at:  hist size) ].
> ^true

This code looks correct (and matches the programming guide!). I've tried it in my system (with a different class that has multiple versions) and it works correctly.

> When do it  from Gemtools workspace the system erase the error:
> ..
> ClassHistory (Object) | _validateClass:
> [] in Repository | _listInstances:limit:toDirectory:
> ..

If you look at Repository>>#'_listInstances:limit:toDirectory:', there is only one sender of #'_validateClass:', and it is validating that each of the items passed in the first argument (the classHistory array) is a Behavior. It seems surprising, but this error suggests that something in the classHistory is not a Behavior. Could you try 'Print it' on the following? Do you get an array where all are true?

        DTRdbDatiSocietari classHistory asArray collect: [:each | each isKindOf: Behavior].

If so, I suggest that you execute the code in the above method by itself in a workspace. If that does not work, then we'll need to do more investigation. Have you used Topaz? It is not as 'user-friendly' but it allows better cut-and-paste to/from a text file or email.

James