Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Object access results in DynamicEObjectImpl (EClass: Invalid_Class)
[QVTO] Object access results in DynamicEObjectImpl (EClass: Invalid_Class) [message #489655] Mon, 05 October 2009 13:37 Go to next message
Patrick Konemann is currently offline Patrick KonemannFriend
Messages: 116
Registered: July 2009
Senior Member
Hi newsgroup,

I realized a strange behavior which I don't understand, maybe you guys can help me.
My transformation takes a model (instance of EMF Compare's emfdiff) as input but apparently some elements are not treated correctly:

mapping EmfDiff::DiffModel::toOtherDiffModel() : EmfDiff::DiffModel {
init {
var diffElements := self.ownedElements.allInstances(DiffElement).oclAsType(DiffE lement)
-- ->reject(oclIsTypeOf(UpdateReference)) ->reject(oclIsTypeOf(UpdateAttribute))
-- The line above removes the exception!
}
result.ownedElements := diffElements->map toOtherChange()->asOrderedSet();
}

mapping DiffElement::toOtherChange() : DiffElement {
init {
log(self.oclAsType(EObject).eClass().name + ' -> ' + self.repr());
if self.oclIsInvalid() or self.oclIsUndefined() or self.oclAsType(EObject).eClass().name.=('Invalid_Class') then
log('unreachable!')
endif;
result := object DiffGroup {}; -- here seems to be the QvtRuntimeException

-- some logging output to keep track of the transformed elements
log('> ' + self.metaClassName() + ' -> ' + result.metaClassName(), self)
}
}

The log output is the following:

[...]
ReferenceOrderChange -> The order of the values of reference eStructuralFeatures have been changed
> ReferenceOrderChange -> DiffGroup, data: The order of the values of reference eStructuralFeatures have been changed
DiffGroup -> 2 change(s) in EObject EObject
> DiffGroup -> DiffGroup, data: 2 change(s) in EObject EObject
UpdateAttribute -> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@bc5681 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@d35eb7 (name: Invalid_Class) (instanceClassName: null) (abstract: false, interface: false))
org.eclipse.m2m.internal.qvt.oml.evaluator.QvtRuntimeExcepti on: The feature 'null' is not a valid feature
at emfdiff2indepdiff::DiffElement::toOtherChange(ref_test.qvto: 29)
at emfdiff2indepdiff::DiffModel::toOtherDiffModel(ref_test.qvto : <Unknown>)
at emfdiff2indepdiff::main(ref_test.qvto:<Unknown>)


Which means, if I understood it correctly, that several model elements are processed correctly (ReferenceOrderChange, DiffGroup), others are not (UpdateAttribute).
At least the objects seems to be correct ("self.oclAsType(EObject).eClass().name" evaluates to "UpdateAttribute"), but for some reason it is not treated correctly but as a DynamicEObject which, I think I read in some other newsgroup posting, should represent OclVoid in this case.
Then, for some reason, a QvtRuntimeException occurs!

Any idea what went wrong here?
(my system: Eclipse 3.5, EMF 2.5.0, QVTo 2.0.1)


I put the transformation and the test model in a zip:
http://imm.dtu.dk/~pk/temp/qvto-dynamiceobject.zip
(Import -> Existing projects into workspace -> Run... -> QVTo -> ref_test)


Any help is appreciated!

Cheers
Patrick
Re: [QVTO] Object access results in DynamicEObjectImpl (EClass: Invalid_Class) [message #489828 is a reply to message #489655] Tue, 06 October 2009 07:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dvorak.radek.gmail.com

Hi Patrick,

The problem is in the Java generated 'diff' metamodel, more
precisely in the method
org.eclipse.emf.compare.diff.metamodel.impl.UpdateAttributeI mpl.toString().

In such cases it's always good to check the 'Error Log View',
where you can find:
java.lang.IllegalArgumentException: The feature 'null' is not a valid
feature
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenGet(BasicEO bjectImpl.java:1064)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1017)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1005)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1000)
at
org.eclipse.emf.compare.diff.metamodel.impl.UpdateAttributeI mpl.toString(UpdateAttributeImpl.java:61)
at java.lang.String.valueOf(String.java:2826)
at
org.eclipse.m2m.internal.qvt.oml.stdlib.OclAnyOperations$1.i nvoke(OclAnyOperations.java:60)
at
org.eclipse.m2m.internal.qvt.oml.ast.env.QvtOperationalEvalu ationEnv.callOperation(QvtOperationalEvaluationEnv.java:155)

What QVTO should do better is to return Invalid from Object::repr()
operation and
log an exception thrown, as this StdLib operation delegates to a
traditionally
user overridden operation.

Regards,
/Radek


On Mon, 05 Oct 2009 15:37:33 +0200, Patrick Könemann <pk@imm.dtu.dk> wrote:

> Hi newsgroup,
>
> I realized a strange behavior which I don't understand, maybe you guys
> can help me.
> My transformation takes a model (instance of EMF Compare's emfdiff) as
> input but apparently some elements are not treated correctly:
>
> mapping EmfDiff::DiffModel::toOtherDiffModel() : EmfDiff::DiffModel {
> init {
> var diffElements :=
> self.ownedElements.allInstances(DiffElement).oclAsType(DiffE lement)
> -- ->reject(oclIsTypeOf(UpdateReference))
> ->reject(oclIsTypeOf(UpdateAttribute))
> -- The line above removes the exception!
> }
> result.ownedElements := diffElements->map
> toOtherChange()->asOrderedSet();
> }
>
> mapping DiffElement::toOtherChange() : DiffElement {
> init {
> log(self.oclAsType(EObject).eClass().name + ' -> ' + self.repr());
> if self.oclIsInvalid() or self.oclIsUndefined() or
> self.oclAsType(EObject).eClass().name.=('Invalid_Class') then
> log('unreachable!')
> endif;
> result := object DiffGroup {}; -- here seems to be the
> QvtRuntimeException
>
> -- some logging output to keep track of the transformed elements
> log('> ' + self.metaClassName() + ' -> ' + result.metaClassName(),
> self)
> }
> }
>
> The log output is the following:
>
> [...]
> ReferenceOrderChange -> The order of the values of reference
> eStructuralFeatures have been changed
> > ReferenceOrderChange -> DiffGroup, data: The order of the values of
> reference eStructuralFeatures have been changed
> DiffGroup -> 2 change(s) in EObject EObject
> > DiffGroup -> DiffGroup, data: 2 change(s) in EObject EObject
> UpdateAttribute -> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@bc5681
> (eClass: org.eclipse.emf.ecore.impl.EClassImpl@d35eb7 (name:
> Invalid_Class) (instanceClassName: null) (abstract: false, interface:
> false))
> org.eclipse.m2m.internal.qvt.oml.evaluator.QvtRuntimeExcepti on: The
> feature 'null' is not a valid feature
> at emfdiff2indepdiff::DiffElement::toOtherChange(ref_test.qvto: 29)
> at
> emfdiff2indepdiff::DiffModel::toOtherDiffModel(ref_test.qvto : <Unknown>)
> at emfdiff2indepdiff::main(ref_test.qvto:<Unknown>)
>
>
> Which means, if I understood it correctly, that several model elements
> are processed correctly (ReferenceOrderChange, DiffGroup), others are
> not (UpdateAttribute).
> At least the objects seems to be correct
> ("self.oclAsType(EObject).eClass().name" evaluates to
> "UpdateAttribute"), but for some reason it is not treated correctly but
> as a DynamicEObject which, I think I read in some other newsgroup
> posting, should represent OclVoid in this case.
> Then, for some reason, a QvtRuntimeException occurs!
>
> Any idea what went wrong here?
> (my system: Eclipse 3.5, EMF 2.5.0, QVTo 2.0.1)
>
>
> I put the transformation and the test model in a zip:
> http://imm.dtu.dk/~pk/temp/qvto-dynamiceobject.zip
> (Import -> Existing projects into workspace -> Run... -> QVTo ->
> ref_test)
>
>
> Any help is appreciated!
>
> Cheers
> Patrick
Re: [QVTO] Object access results in DynamicEObjectImpl (EClass: Invalid_Class) [message #489861 is a reply to message #489828] Tue, 06 October 2009 09:52 Go to previous messageGo to next message
Patrick Konemann is currently offline Patrick KonemannFriend
Messages: 116
Registered: July 2009
Senior Member
Hi Radek,

this is very interesting, thank you for pointing that out!

The transformation actually works if I remove all "EObject::repr()" and "EObject::metaClassName()" calls.
However.. That means that I cannot write this useful information into the log anymore.

I see two solutions:
1. Fixing the IllegalArgumentException in the model java code (but for some strange reason I cannot reproduce the exception outsite the transformation..)
2. Catching this error in the transformation - is that possible? I read something about try-catch in the Eclipsecon 2008 slides, p. 32.


Thanks again!
Patrick


On 06-10-2009 09:36, radek dvorak wrote:
> Hi Patrick,
>
> The problem is in the Java generated 'diff' metamodel, more
> precisely in the method
> org.eclipse.emf.compare.diff.metamodel.impl.UpdateAttributeI mpl.toString().
>
> In such cases it's always good to check the 'Error Log View',
> where you can find:
> java.lang.IllegalArgumentException: The feature 'null' is not a valid
> feature
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenGet(BasicEO bjectImpl.java:1064)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1017)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1005)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1000)
>
> at
> org.eclipse.emf.compare.diff.metamodel.impl.UpdateAttributeI mpl.toString(UpdateAttributeImpl.java:61)
>
> at java.lang.String.valueOf(String.java:2826)
> at
> org.eclipse.m2m.internal.qvt.oml.stdlib.OclAnyOperations$1.i nvoke(OclAnyOperations.java:60)
>
> at
> org.eclipse.m2m.internal.qvt.oml.ast.env.QvtOperationalEvalu ationEnv.callOperation(QvtOperationalEvaluationEnv.java:155)
>
>
> What QVTO should do better is to return Invalid from Object::repr()
> operation and
> log an exception thrown, as this StdLib operation delegates to a
> traditionally
> user overridden operation.
>
> Regards,
> /Radek
>
>
> On Mon, 05 Oct 2009 15:37:33 +0200, Patrick Könemann <pk@imm.dtu.dk> wrote:
>
>> Hi newsgroup,
>>
>> I realized a strange behavior which I don't understand, maybe you guys
>> can help me.
>> My transformation takes a model (instance of EMF Compare's emfdiff) as
>> input but apparently some elements are not treated correctly:
>>
>> mapping EmfDiff::DiffModel::toOtherDiffModel() : EmfDiff::DiffModel {
>> init {
>> var diffElements :=
>> self.ownedElements.allInstances(DiffElement).oclAsType(DiffE lement)
>> -- ->reject(oclIsTypeOf(UpdateReference))
>> ->reject(oclIsTypeOf(UpdateAttribute))
>> -- The line above removes the exception!
>> }
>> result.ownedElements := diffElements->map
>> toOtherChange()->asOrderedSet();
>> }
>>
>> mapping DiffElement::toOtherChange() : DiffElement {
>> init {
>> log(self.oclAsType(EObject).eClass().name + ' -> ' + self.repr());
>> if self.oclIsInvalid() or self.oclIsUndefined() or
>> self.oclAsType(EObject).eClass().name.=('Invalid_Class') then
>> log('unreachable!')
>> endif;
>> result := object DiffGroup {}; -- here seems to be the
>> QvtRuntimeException
>>
>> -- some logging output to keep track of the transformed elements
>> log('> ' + self.metaClassName() + ' -> ' + result.metaClassName(), self)
>> }
>> }
>>
>> The log output is the following:
>>
>> [...]
>> ReferenceOrderChange -> The order of the values of reference
>> eStructuralFeatures have been changed
>> > ReferenceOrderChange -> DiffGroup, data: The order of the values of
>> reference eStructuralFeatures have been changed
>> DiffGroup -> 2 change(s) in EObject EObject
>> > DiffGroup -> DiffGroup, data: 2 change(s) in EObject EObject
>> UpdateAttribute ->
>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@bc5681 (eClass:
>> org.eclipse.emf.ecore.impl.EClassImpl@d35eb7 (name: Invalid_Class)
>> (instanceClassName: null) (abstract: false, interface: false))
>> org.eclipse.m2m.internal.qvt.oml.evaluator.QvtRuntimeExcepti on: The
>> feature 'null' is not a valid feature
>> at emfdiff2indepdiff::DiffElement::toOtherChange(ref_test.qvto: 29)
>> at
>> emfdiff2indepdiff::DiffModel::toOtherDiffModel(ref_test.qvto : <Unknown>)
>> at emfdiff2indepdiff::main(ref_test.qvto:<Unknown>)
>>
>>
>> Which means, if I understood it correctly, that several model elements
>> are processed correctly (ReferenceOrderChange, DiffGroup), others are
>> not (UpdateAttribute).
>> At least the objects seems to be correct
>> ("self.oclAsType(EObject).eClass().name" evaluates to
>> "UpdateAttribute"), but for some reason it is not treated correctly
>> but as a DynamicEObject which, I think I read in some other newsgroup
>> posting, should represent OclVoid in this case.
>> Then, for some reason, a QvtRuntimeException occurs!
>>
>> Any idea what went wrong here?
>> (my system: Eclipse 3.5, EMF 2.5.0, QVTo 2.0.1)
>>
>>
>> I put the transformation and the test model in a zip:
>> http://imm.dtu.dk/~pk/temp/qvto-dynamiceobject.zip
>> (Import -> Existing projects into workspace -> Run... -> QVTo ->
>> ref_test)
>>
>>
>> Any help is appreciated!
>>
>> Cheers
>> Patrick
Re: [QVTO] Object access results in DynamicEObjectImpl (EClass: Invalid_Class) [message #489870 is a reply to message #489861] Tue, 06 October 2009 10:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dvorak.radek.gmail.com

Hi Patrick,

1. Whatever better handling of such situations by QVTO does not solve the
problem.
Object::toString() throwing a runtime exception is just bad.
Use debugger, set a breakpoint to
org.eclipse.emf.compare.diff.metamodel.impl.UpdateAttributeI mpl.toString()
and launch another eclipse instance to execute your transf, you will
see the
the details.

2. No try-catch at the moment. It would not help either, as you have
no QVT typed exception to catch here.


What QVTO can do is to return Invalid and log the exception caught, hoping
someone
will notice that. This would be more fault tolerant and can be delivered
in a maintenance build,
which you can install. It will come later, potentially with other fixes as
Galileo SR2.
Raise bugzilla, if you want to to get it ;)

You can write a useful info to the log but with a useful Java code ;).
Try using your custom toString operation and redirect for AttributeChange
instances
to something safe.

helper DiffElement::myRepr() : String {
return self.repr();
}

helper AttributeChange::myRepr() : String {
return "my safe details";
}



Also, use
emfdiff.objects()[DiffModel]
instead of
// allInstances() is non-std and legacy addition to Stdlib
emfdiff.rootObjects().allInstances(DiffModel).oclAsType(Diff Model)

Avoid
self.oclAsType(EObject).eClass().name.=('Invalid_Class')
better check using OclAny::oclIsInvalid()

I can see your models produce validation problems, also a good thing to
check.

Regards,
/Radek



On Tue, 06 Oct 2009 11:52:37 +0200, Patrick Könemann <pk@imm.dtu.dk> wrote:

> Hi Radek,
>
> this is very interesting, thank you for pointing that out!
>
> The transformation actually works if I remove all "EObject::repr()" and
> "EObject::metaClassName()" calls.
> However.. That means that I cannot write this useful information into
> the log anymore.
>
> I see two solutions:
> 1. Fixing the IllegalArgumentException in the model java code (but for
> some strange reason I cannot reproduce the exception outsite the
> transformation..)
> 2. Catching this error in the transformation - is that possible? I read
> something about try-catch in the Eclipsecon 2008 slides, p. 32.
>
>
> Thanks again!
> Patrick
>
>
> On 06-10-2009 09:36, radek dvorak wrote:
>> Hi Patrick,
>>
>> The problem is in the Java generated 'diff' metamodel, more
>> precisely in the method
>> org.eclipse.emf.compare.diff.metamodel.impl.UpdateAttributeI mpl.toString().
>>
>> In such cases it's always good to check the 'Error Log View',
>> where you can find:
>> java.lang.IllegalArgumentException: The feature 'null' is not a valid
>> feature
>> at
>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenGet(BasicEO bjectImpl.java:1064)
>>
>> at
>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1017)
>>
>> at
>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1005)
>>
>> at
>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1000)
>>
>> at
>> org.eclipse.emf.compare.diff.metamodel.impl.UpdateAttributeI mpl.toString(UpdateAttributeImpl.java:61)
>>
>> at java.lang.String.valueOf(String.java:2826)
>> at
>> org.eclipse.m2m.internal.qvt.oml.stdlib.OclAnyOperations$1.i nvoke(OclAnyOperations.java:60)
>>
>> at
>> org.eclipse.m2m.internal.qvt.oml.ast.env.QvtOperationalEvalu ationEnv.callOperation(QvtOperationalEvaluationEnv.java:155)
>>
>>
>> What QVTO should do better is to return Invalid from Object::repr()
>> operation and
>> log an exception thrown, as this StdLib operation delegates to a
>> traditionally
>> user overridden operation.
>>
>> Regards,
>> /Radek
>>
>>
>> On Mon, 05 Oct 2009 15:37:33 +0200, Patrick Könemann <pk@imm.dtu.dk>
>> wrote:
>>
>>> Hi newsgroup,
>>>
>>> I realized a strange behavior which I don't understand, maybe you guys
>>> can help me.
>>> My transformation takes a model (instance of EMF Compare's emfdiff) as
>>> input but apparently some elements are not treated correctly:
>>>
>>> mapping EmfDiff::DiffModel::toOtherDiffModel() : EmfDiff::DiffModel {
>>> init {
>>> var diffElements :=
>>> self.ownedElements.allInstances(DiffElement).oclAsType(DiffE lement)
>>> -- ->reject(oclIsTypeOf(UpdateReference))
>>> ->reject(oclIsTypeOf(UpdateAttribute))
>>> -- The line above removes the exception!
>>> }
>>> result.ownedElements := diffElements->map
>>> toOtherChange()->asOrderedSet();
>>> }
>>>
>>> mapping DiffElement::toOtherChange() : DiffElement {
>>> init {
>>> log(self.oclAsType(EObject).eClass().name + ' -> ' + self.repr());
>>> if self.oclIsInvalid() or self.oclIsUndefined() or
>>> self.oclAsType(EObject).eClass().name.=('Invalid_Class') then
>>> log('unreachable!')
>>> endif;
>>> result := object DiffGroup {}; -- here seems to be the
>>> QvtRuntimeException
>>>
>>> -- some logging output to keep track of the transformed elements
>>> log('> ' + self.metaClassName() + ' -> ' + result.metaClassName(),
>>> self)
>>> }
>>> }
>>>
>>> The log output is the following:
>>>
>>> [...]
>>> ReferenceOrderChange -> The order of the values of reference
>>> eStructuralFeatures have been changed
>>> > ReferenceOrderChange -> DiffGroup, data: The order of the values of
>>> reference eStructuralFeatures have been changed
>>> DiffGroup -> 2 change(s) in EObject EObject
>>> > DiffGroup -> DiffGroup, data: 2 change(s) in EObject EObject
>>> UpdateAttribute ->
>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@bc5681 (eClass:
>>> org.eclipse.emf.ecore.impl.EClassImpl@d35eb7 (name: Invalid_Class)
>>> (instanceClassName: null) (abstract: false, interface: false))
>>> org.eclipse.m2m.internal.qvt.oml.evaluator.QvtRuntimeExcepti on: The
>>> feature 'null' is not a valid feature
>>> at emfdiff2indepdiff::DiffElement::toOtherChange(ref_test.qvto: 29)
>>> at
>>> emfdiff2indepdiff::DiffModel::toOtherDiffModel(ref_test.qvto : <Unknown>)
>>> at emfdiff2indepdiff::main(ref_test.qvto:<Unknown>)
>>>
>>>
>>> Which means, if I understood it correctly, that several model elements
>>> are processed correctly (ReferenceOrderChange, DiffGroup), others are
>>> not (UpdateAttribute).
>>> At least the objects seems to be correct
>>> ("self.oclAsType(EObject).eClass().name" evaluates to
>>> "UpdateAttribute"), but for some reason it is not treated correctly
>>> but as a DynamicEObject which, I think I read in some other newsgroup
>>> posting, should represent OclVoid in this case.
>>> Then, for some reason, a QvtRuntimeException occurs!
>>>
>>> Any idea what went wrong here?
>>> (my system: Eclipse 3.5, EMF 2.5.0, QVTo 2.0.1)
>>>
>>>
>>> I put the transformation and the test model in a zip:
>>> http://imm.dtu.dk/~pk/temp/qvto-dynamiceobject.zip
>>> (Import -> Existing projects into workspace -> Run... -> QVTo ->
>>> ref_test)
>>>
>>>
>>> Any help is appreciated!
>>>
>>> Cheers
>>> Patrick
>
Re: [QVTO] Object access results in DynamicEObjectImpl (EClass: Invalid_Class) [message #489888 is a reply to message #489870] Tue, 06 October 2009 12:33 Go to previous messageGo to next message
Patrick Konemann is currently offline Patrick KonemannFriend
Messages: 116
Registered: July 2009
Senior Member
Hi Radek,

Please see comments inline.

Best regards
Patrick

On 06-10-2009 12:53, radek dvorak wrote:
> Hi Patrick,
>
> 1. Whatever better handling of such situations by QVTO does not solve the problem.
> Object::toString() throwing a runtime exception is just bad.
> Use debugger, set a breakpoint to
> org.eclipse.emf.compare.diff.metamodel.impl.UpdateAttributeI mpl.toString()
> and launch another eclipse instance to execute your transf, you will see the
> the details.

That works, thanks!

>
> 2. No try-catch at the moment. It would not help either, as you have
> no QVT typed exception to catch here.
>
>
> What QVTO can do is to return Invalid and log the exception caught, hoping someone
> will notice that. This would be more fault tolerant and can be delivered in a maintenance build,
> which you can install. It will come later, potentially with other fixes as Galileo SR2.
> Raise bugzilla, if you want to to get it ;)

I guess it's not that urgent..

>
> You can write a useful info to the log but with a useful Java code ;).
> Try using your custom toString operation and redirect for AttributeChange instances
> to something safe.
>
> helper DiffElement::myRepr() : String {
> return self.repr();
> }
>
> helper AttributeChange::myRepr() : String {
> return "my safe details";
> }
>

That is helpful! Thanks a lot!

>
>
> Also, use
> emfdiff.objects()[DiffModel]
> instead of
> // allInstances() is non-std and legacy addition to Stdlib
> emfdiff.rootObjects().allInstances(DiffModel).oclAsType(Diff Model)

The point is that "DiffModels" might not be direct children of the emfdiff object:
emfdiff
+ diffResourceSet
+ diffModel1
+ diffModel2

As far as I see it, "emfdiff.objects()[DiffModel]" only returns direct children of the specified type?

>
> Avoid
> self.oclAsType(EObject).eClass().name.=('Invalid_Class')
> better check using OclAny::oclIsInvalid()

Sure, that was just for debugging.. ;-)

>
> I can see your models produce validation problems, also a good thing to
> check.

My fault.. I renamed the project which made some EMF references invalid.
Fixing that didn't change anything in the result though.

>
> Regards,
> /Radek
>
>
>
> On Tue, 06 Oct 2009 11:52:37 +0200, Patrick Könemann <pk@imm.dtu.dk> wrote:
>
>> Hi Radek,
>>
>> this is very interesting, thank you for pointing that out!
>>
>> The transformation actually works if I remove all "EObject::repr()"
>> and "EObject::metaClassName()" calls.
>> However.. That means that I cannot write this useful information into
>> the log anymore.
>>
>> I see two solutions:
>> 1. Fixing the IllegalArgumentException in the model java code (but for
>> some strange reason I cannot reproduce the exception outsite the
>> transformation..)
>> 2. Catching this error in the transformation - is that possible? I
>> read something about try-catch in the Eclipsecon 2008 slides, p. 32.
>>
>>
>> Thanks again!
>> Patrick
>>
>>
>> On 06-10-2009 09:36, radek dvorak wrote:
>>> Hi Patrick,
>>>
>>> The problem is in the Java generated 'diff' metamodel, more
>>> precisely in the method
>>> org.eclipse.emf.compare.diff.metamodel.impl.UpdateAttributeI mpl.toString().
>>>
>>>
>>> In such cases it's always good to check the 'Error Log View',
>>> where you can find:
>>> java.lang.IllegalArgumentException: The feature 'null' is not a valid
>>> feature
>>> at
>>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenGet(BasicEO bjectImpl.java:1064)
>>>
>>>
>>> at
>>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1017)
>>>
>>>
>>> at
>>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1005)
>>>
>>>
>>> at
>>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1000)
>>>
>>>
>>> at
>>> org.eclipse.emf.compare.diff.metamodel.impl.UpdateAttributeI mpl.toString(UpdateAttributeImpl.java:61)
>>>
>>>
>>> at java.lang.String.valueOf(String.java:2826)
>>> at
>>> org.eclipse.m2m.internal.qvt.oml.stdlib.OclAnyOperations$1.i nvoke(OclAnyOperations.java:60)
>>>
>>>
>>> at
>>> org.eclipse.m2m.internal.qvt.oml.ast.env.QvtOperationalEvalu ationEnv.callOperation(QvtOperationalEvaluationEnv.java:155)
>>>
>>>
>>>
>>> What QVTO should do better is to return Invalid from Object::repr()
>>> operation and
>>> log an exception thrown, as this StdLib operation delegates to a
>>> traditionally
>>> user overridden operation.
>>>
>>> Regards,
>>> /Radek
>>>
>>>
>>> On Mon, 05 Oct 2009 15:37:33 +0200, Patrick Könemann <pk@imm.dtu.dk>
>>> wrote:
>>>
>>>> Hi newsgroup,
>>>>
>>>> I realized a strange behavior which I don't understand, maybe you guys
>>>> can help me.
>>>> My transformation takes a model (instance of EMF Compare's emfdiff) as
>>>> input but apparently some elements are not treated correctly:
>>>>
>>>> mapping EmfDiff::DiffModel::toOtherDiffModel() : EmfDiff::DiffModel {
>>>> init {
>>>> var diffElements :=
>>>> self.ownedElements.allInstances(DiffElement).oclAsType(DiffE lement)
>>>> -- ->reject(oclIsTypeOf(UpdateReference))
>>>> ->reject(oclIsTypeOf(UpdateAttribute))
>>>> -- The line above removes the exception!
>>>> }
>>>> result.ownedElements := diffElements->map
>>>> toOtherChange()->asOrderedSet();
>>>> }
>>>>
>>>> mapping DiffElement::toOtherChange() : DiffElement {
>>>> init {
>>>> log(self.oclAsType(EObject).eClass().name + ' -> ' + self.repr());
>>>> if self.oclIsInvalid() or self.oclIsUndefined() or
>>>> self.oclAsType(EObject).eClass().name.=('Invalid_Class') then
>>>> log('unreachable!')
>>>> endif;
>>>> result := object DiffGroup {}; -- here seems to be the
>>>> QvtRuntimeException
>>>>
>>>> -- some logging output to keep track of the transformed elements
>>>> log('> ' + self.metaClassName() + ' -> ' + result.metaClassName(),
>>>> self)
>>>> }
>>>> }
>>>>
>>>> The log output is the following:
>>>>
>>>> [...]
>>>> ReferenceOrderChange -> The order of the values of reference
>>>> eStructuralFeatures have been changed
>>>> > ReferenceOrderChange -> DiffGroup, data: The order of the values of
>>>> reference eStructuralFeatures have been changed
>>>> DiffGroup -> 2 change(s) in EObject EObject
>>>> > DiffGroup -> DiffGroup, data: 2 change(s) in EObject EObject
>>>> UpdateAttribute ->
>>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@bc5681 (eClass:
>>>> org.eclipse.emf.ecore.impl.EClassImpl@d35eb7 (name: Invalid_Class)
>>>> (instanceClassName: null) (abstract: false, interface: false))
>>>> org.eclipse.m2m.internal.qvt.oml.evaluator.QvtRuntimeExcepti on: The
>>>> feature 'null' is not a valid feature
>>>> at emfdiff2indepdiff::DiffElement::toOtherChange(ref_test.qvto: 29)
>>>> at
>>>> emfdiff2indepdiff::DiffModel::toOtherDiffModel(ref_test.qvto : <Unknown>)
>>>> at emfdiff2indepdiff::main(ref_test.qvto:<Unknown>)
>>>>
>>>>
>>>> Which means, if I understood it correctly, that several model elements
>>>> are processed correctly (ReferenceOrderChange, DiffGroup), others are
>>>> not (UpdateAttribute).
>>>> At least the objects seems to be correct
>>>> ("self.oclAsType(EObject).eClass().name" evaluates to
>>>> "UpdateAttribute"), but for some reason it is not treated correctly
>>>> but as a DynamicEObject which, I think I read in some other newsgroup
>>>> posting, should represent OclVoid in this case.
>>>> Then, for some reason, a QvtRuntimeException occurs!
>>>>
>>>> Any idea what went wrong here?
>>>> (my system: Eclipse 3.5, EMF 2.5.0, QVTo 2.0.1)
>>>>
>>>>
>>>> I put the transformation and the test model in a zip:
>>>> http://imm.dtu.dk/~pk/temp/qvto-dynamiceobject.zip
>>>> (Import -> Existing projects into workspace -> Run... -> QVTo ->
>>>> ref_test)
>>>>
>>>>
>>>> Any help is appreciated!
>>>>
>>>> Cheers
>>>> Patrick
>>
Re: [QVTO] Object access results in DynamicEObjectImpl (EClass: Invalid_Class) [message #489900 is a reply to message #489888] Tue, 06 October 2009 12:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dvorak.radek.gmail.com

>
> The point is that "DiffModels" might not be direct children of the
> emfdiff object:
> emfdiff
> + diffResourceSet
> + diffModel1
> + diffModel2
>
> As far as I see it, "emfdiff.objects()[DiffModel]" only returns direct
> children of the specified type?

'emfdiff' is your input model, objects() will return all instances of that
type
in the whole model.

8.3.5.1 objects
Model::objects() : Set(Element)
Returns the list of the objects in the model extent.

When thinking about querying children of an object,
see Element::subobjects() : Set(Element), Element::allSubobjects() :
Set(Element), etc.


>
>>
>> Avoid
>> self.oclAsType(EObject).eClass().name.=('Invalid_Class')
>> better check using OclAny::oclIsInvalid()
>
> Sure, that was just for debugging.. ;-)
>
>>
>> I can see your models produce validation problems, also a good thing to
>> check.
>
> My fault.. I renamed the project which made some EMF references invalid.
> Fixing that didn't change anything in the result though.
>
>>
>> Regards,
>> /Radek
>>
>>
>>
>> On Tue, 06 Oct 2009 11:52:37 +0200, Patrick Könemann <pk@imm.dtu.dk>
>> wrote:
>>
>>> Hi Radek,
>>>
>>> this is very interesting, thank you for pointing that out!
>>>
>>> The transformation actually works if I remove all "EObject::repr()"
>>> and "EObject::metaClassName()" calls.
>>> However.. That means that I cannot write this useful information into
>>> the log anymore.
>>>
>>> I see two solutions:
>>> 1. Fixing the IllegalArgumentException in the model java code (but for
>>> some strange reason I cannot reproduce the exception outsite the
>>> transformation..)
>>> 2. Catching this error in the transformation - is that possible? I
>>> read something about try-catch in the Eclipsecon 2008 slides, p. 32.
>>>
>>>
>>> Thanks again!
>>> Patrick
>>>
>>>
>>> On 06-10-2009 09:36, radek dvorak wrote:
>>>> Hi Patrick,
>>>>
>>>> The problem is in the Java generated 'diff' metamodel, more
>>>> precisely in the method
>>>> org.eclipse.emf.compare.diff.metamodel.impl.UpdateAttributeI mpl.toString().
>>>>
>>>>
>>>> In such cases it's always good to check the 'Error Log View',
>>>> where you can find:
>>>> java.lang.IllegalArgumentException: The feature 'null' is not a valid
>>>> feature
>>>> at
>>>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenGet(BasicEO bjectImpl.java:1064)
>>>>
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1017)
>>>>
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1005)
>>>>
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1000)
>>>>
>>>>
>>>> at
>>>> org.eclipse.emf.compare.diff.metamodel.impl.UpdateAttributeI mpl.toString(UpdateAttributeImpl.java:61)
>>>>
>>>>
>>>> at java.lang.String.valueOf(String.java:2826)
>>>> at
>>>> org.eclipse.m2m.internal.qvt.oml.stdlib.OclAnyOperations$1.i nvoke(OclAnyOperations.java:60)
>>>>
>>>>
>>>> at
>>>> org.eclipse.m2m.internal.qvt.oml.ast.env.QvtOperationalEvalu ationEnv.callOperation(QvtOperationalEvaluationEnv.java:155)
>>>>
>>>>
>>>>
>>>> What QVTO should do better is to return Invalid from Object::repr()
>>>> operation and
>>>> log an exception thrown, as this StdLib operation delegates to a
>>>> traditionally
>>>> user overridden operation.
>>>>
>>>> Regards,
>>>> /Radek
>>>>
>>>>
>>>> On Mon, 05 Oct 2009 15:37:33 +0200, Patrick Könemann <pk@imm.dtu.dk>
>>>> wrote:
>>>>
>>>>> Hi newsgroup,
>>>>>
>>>>> I realized a strange behavior which I don't understand, maybe you
>>>>> guys
>>>>> can help me.
>>>>> My transformation takes a model (instance of EMF Compare's emfdiff)
>>>>> as
>>>>> input but apparently some elements are not treated correctly:
>>>>>
>>>>> mapping EmfDiff::DiffModel::toOtherDiffModel() : EmfDiff::DiffModel {
>>>>> init {
>>>>> var diffElements :=
>>>>> self.ownedElements.allInstances(DiffElement).oclAsType(DiffE lement)
>>>>> -- ->reject(oclIsTypeOf(UpdateReference))
>>>>> ->reject(oclIsTypeOf(UpdateAttribute))
>>>>> -- The line above removes the exception!
>>>>> }
>>>>> result.ownedElements := diffElements->map
>>>>> toOtherChange()->asOrderedSet();
>>>>> }
>>>>>
>>>>> mapping DiffElement::toOtherChange() : DiffElement {
>>>>> init {
>>>>> log(self.oclAsType(EObject).eClass().name + ' -> ' + self.repr());
>>>>> if self.oclIsInvalid() or self.oclIsUndefined() or
>>>>> self.oclAsType(EObject).eClass().name.=('Invalid_Class') then
>>>>> log('unreachable!')
>>>>> endif;
>>>>> result := object DiffGroup {}; -- here seems to be the
>>>>> QvtRuntimeException
>>>>>
>>>>> -- some logging output to keep track of the transformed elements
>>>>> log('> ' + self.metaClassName() + ' -> ' + result.metaClassName(),
>>>>> self)
>>>>> }
>>>>> }
>>>>>
>>>>> The log output is the following:
>>>>>
>>>>> [...]
>>>>> ReferenceOrderChange -> The order of the values of reference
>>>>> eStructuralFeatures have been changed
>>>>> > ReferenceOrderChange -> DiffGroup, data: The order of the values of
>>>>> reference eStructuralFeatures have been changed
>>>>> DiffGroup -> 2 change(s) in EObject EObject
>>>>> > DiffGroup -> DiffGroup, data: 2 change(s) in EObject EObject
>>>>> UpdateAttribute ->
>>>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@bc5681 (eClass:
>>>>> org.eclipse.emf.ecore.impl.EClassImpl@d35eb7 (name: Invalid_Class)
>>>>> (instanceClassName: null) (abstract: false, interface: false))
>>>>> org.eclipse.m2m.internal.qvt.oml.evaluator.QvtRuntimeExcepti on: The
>>>>> feature 'null' is not a valid feature
>>>>> at emfdiff2indepdiff::DiffElement::toOtherChange(ref_test.qvto: 29)
>>>>> at
>>>>> emfdiff2indepdiff::DiffModel::toOtherDiffModel(ref_test.qvto : <Unknown>)
>>>>> at emfdiff2indepdiff::main(ref_test.qvto:<Unknown>)
>>>>>
>>>>>
>>>>> Which means, if I understood it correctly, that several model
>>>>> elements
>>>>> are processed correctly (ReferenceOrderChange, DiffGroup), others are
>>>>> not (UpdateAttribute).
>>>>> At least the objects seems to be correct
>>>>> ("self.oclAsType(EObject).eClass().name" evaluates to
>>>>> "UpdateAttribute"), but for some reason it is not treated correctly
>>>>> but as a DynamicEObject which, I think I read in some other newsgroup
>>>>> posting, should represent OclVoid in this case.
>>>>> Then, for some reason, a QvtRuntimeException occurs!
>>>>>
>>>>> Any idea what went wrong here?
>>>>> (my system: Eclipse 3.5, EMF 2.5.0, QVTo 2.0.1)
>>>>>
>>>>>
>>>>> I put the transformation and the test model in a zip:
>>>>> http://imm.dtu.dk/~pk/temp/qvto-dynamiceobject.zip
>>>>> (Import -> Existing projects into workspace -> Run... -> QVTo ->
>>>>> ref_test)
>>>>>
>>>>>
>>>>> Any help is appreciated!
>>>>>
>>>>> Cheers
>>>>> Patrick
>>>
>
Re: [QVTO] Object access results in DynamicEObjectImpl (EClass: Invalid_Class) [message #489915 is a reply to message #489900] Tue, 06 October 2009 13:31 Go to previous message
Patrick Konemann is currently offline Patrick KonemannFriend
Messages: 116
Registered: July 2009
Senior Member
> 8.3.5.1 objects
> Model::objects() : Set(Element)
> Returns the list of the objects in the model extent.
>
> When thinking about querying children of an object,
> see Element::subobjects() : Set(Element), Element::allSubobjects() :
> Set(Element), etc.
>

Great! :-)
The problem was that I tried to use objects() also on model elements (not only the model itself)..
But allSubobjects() is exactly what I needed!

Actually I found even other interesting methods in the ocl spec :-)

Thanks again!
Patrick
Previous Topic:[ATL] EMFModelLoader
Next Topic:[ATL & Xtext] Processing Xtext resources in ATL transformations
Goto Forum:
  


Current Time: Thu Sep 26 03:54:00 GMT 2024

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

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

Back to the top