Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Problems with DerivedUnion during deserialization
Problems with DerivedUnion during deserialization [message #479235] Mon, 10 August 2009 11:39 Go to next message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
Hey all,

i'm using the UML2 genmodel to generate a uml-like metamodel with
subsets and unions etc. I've rebuild the Element -> ownedComment
relationship of the UML 2.2 Superstructure (Figure 7.3). Instead of
Comment, i've sed the term Annotation. The model looks like

Element {abstract}
+/owner 0..1 {union, read-only}
+/ownedElement * {union, read-only}

TestingModel extends Element
+ annotation * {subsets ownedElement}

Annotation extends Element


When i define a simple model like the model mentioned in the following
XMI snippet

<?xml version="1.0" encoding="UTF-8"?>
<union:TestingModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:union="http:///union.ecore" ownedElement="//@annotation.0">
<annotation/>
</union:TestingModel>

i ran allways in an exception during deserialization. I've tried both
the editor and the programmatically deserialization. Both fail with the
following exception trace. It seems, that somewhere the
DerivedEObjectEList.add() method will be called.

org.eclipse.emf.ecore.xmi.IllegalValueException: Value
'union.impl.AnnotationImpl@352d87' is not legal.
(platform:/resource/f/My.union, -1, -1)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2648)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1135)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1214)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .endDocument(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1445)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1241)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
at union.presentation.UnionEditor.createModel(UnionEditor.java: 950)
at union.presentation.UnionEditor.createPages(UnionEditor.java: 1007)
at
org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:310)
at ....


Caused by: java.lang.UnsupportedOperationException
at
org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:278)
at java.util.AbstractSequentialList.add(Unknown Source)
at
org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:636)
at
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1192)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2643)
... 58 more


For serialization and deserialization i'm using an XMIBResource(Factory)
created by the genmodel automatically. Please let me know, what is going
wrong in this really simple example.

Thanks in advance
Timothy
Re: Problems with DerivedUnion during deserialization [message #479321 is a reply to message #479235] Mon, 10 August 2009 17:02 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Timothy,

I wouldn't have expected to see an 'ownedElement' element in the
serialization, since derived unions are, by definition read-only (hence
the reason why the addition is failing upon deserialization). Did you
make that feature transient in the metamodel?

Kenn

Timothy Marc wrote:
> Hey all,
>
> i'm using the UML2 genmodel to generate a uml-like metamodel with
> subsets and unions etc. I've rebuild the Element -> ownedComment
> relationship of the UML 2.2 Superstructure (Figure 7.3). Instead of
> Comment, i've sed the term Annotation. The model looks like
>
> Element {abstract}
> +/owner 0..1 {union, read-only}
> +/ownedElement * {union, read-only}
>
> TestingModel extends Element
> + annotation * {subsets ownedElement}
>
> Annotation extends Element
>
>
> When i define a simple model like the model mentioned in the following
> XMI snippet
>
> <?xml version="1.0" encoding="UTF-8"?>
> <union:TestingModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:union="http:///union.ecore" ownedElement="//@annotation.0">
> <annotation/>
> </union:TestingModel>
>
> i ran allways in an exception during deserialization. I've tried both
> the editor and the programmatically deserialization. Both fail with the
> following exception trace. It seems, that somewhere the
> DerivedEObjectEList.add() method will be called.
>
> org.eclipse.emf.ecore.xmi.IllegalValueException: Value
> 'union.impl.AnnotationImpl@352d87' is not legal.
> (platform:/resource/f/My.union, -1, -1)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2648)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1135)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1214)
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .endDocument(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown Source)
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
> Source)
> at javax.xml.parsers.SAXParser.parse(Unknown Source)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1445)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1241)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>
> at union.presentation.UnionEditor.createModel(UnionEditor.java: 950)
> at union.presentation.UnionEditor.createPages(UnionEditor.java: 1007)
> at
> org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:310)
>
> at ....
>
>
> Caused by: java.lang.UnsupportedOperationException
> at
> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:278)
>
> at java.util.AbstractSequentialList.add(Unknown Source)
> at
> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:636)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1192)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2643)
>
> ... 58 more
>
>
> For serialization and deserialization i'm using an XMIBResource(Factory)
> created by the genmodel automatically. Please let me know, what is going
> wrong in this really simple example.
>
> Thanks in advance
> Timothy
Re: Problems with DerivedUnion during deserialization [message #479390 is a reply to message #479321] Mon, 10 August 2009 20:39 Go to previous messageGo to next message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
Kenn,

god damn, i was aware of all other derived attributes or subset, but not
for the unions... is there any rationale, why derived associations or
attributes are not generally set to transient=true? Because of that they
are already set to volatile=true i allways forget to set them manually
to transient. But, it works now. Thanks!

Another point: The generated editor behaves weird for the following
snippet. I defined the following (trying to approximate the ownedRule
semtanics of the superstructure):

#####
Element {abstract}
+/ownedElement * {union, read-only, containment}
+/ownedRule 0..* {subsets ownedElement, containment}

NamedElemet extends Element

BehavioralFeature extends NamedElement

Operation extends BehavioralFeature
+precondition 0..* {subsets ownedRule, containment}
+postcondition 0..* {subsets ownedRule, containment} #####

If i add an 'ownedRule' to the operation, everything is fine. But any
adding of either pre- or postcondition has the effect, that 2 instances
of the same constraint is displayed. Well, the XMI looks okay, IMHO:

<packagedElement xsi:type="testing:Class" xmi:id="_cUg_8IXsEd6Lu8REkryexw">
<ownedOperation xmi:id="_fkrwMIXsEd6Lu8REkryexw"
postcondition="_gJMLcIXsEd6Lu8REkryexw">
<ownedRule xmi:id="_gJMLcIXsEd6Lu8REkryexw"/>
</ownedOperation>
</packagedElement>

The postcondition belongs both to the ownedRule containment reference,
and to the postcondition reference of its context operation. In the
editor, the constraint is shown twice instead of just being a single
element. If i add a constraint via the ownedRule reference, only a
single element is displayed.

The java code for Operation::postcondition is:

public EList<Constraint> getPostconditions() {
if (postconditions == null) {
postconditions = new
SubsetSupersetEObjectResolvingEList<Constraint>(Constraint.class, this,
TestingPackage.OPERATION__POSTCONDITION, POSTCONDITION_ESUPERSETS, null);
}
return postconditions;
}

and for Element::ownedRule it is

public EList<Constraint> getOwnedRules() {
if (ownedRules == null) {
ownedRules = new
EObjectContainmentWithInverseEList<Constraint>(Constraint.class, this,
TestingPackage.MODEL_ELEMENT__OWNED_RULE,
TestingPackage.CONSTRAINT__CONTEXT);
}
return ownedRules;
}

Again some perfect ideas?

Thanks in advance
Timothy

Kenn Hussey schrieb:
> Timothy,
>
> I wouldn't have expected to see an 'ownedElement' element in the
> serialization, since derived unions are, by definition read-only (hence
> the reason why the addition is failing upon deserialization). Did you
> make that feature transient in the metamodel?
>
> Kenn
>
> Timothy Marc wrote:
>> Hey all,
>>
>> i'm using the UML2 genmodel to generate a uml-like metamodel with
>> subsets and unions etc. I've rebuild the Element -> ownedComment
>> relationship of the UML 2.2 Superstructure (Figure 7.3). Instead of
>> Comment, i've sed the term Annotation. The model looks like
>>
>> Element {abstract}
>> +/owner 0..1 {union, read-only}
>> +/ownedElement * {union, read-only}
>>
>> TestingModel extends Element
>> + annotation * {subsets ownedElement}
>>
>> Annotation extends Element
>>
>>
>> When i define a simple model like the model mentioned in the following
>> XMI snippet
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <union:TestingModel xmi:version="2.0"
>> xmlns:xmi="http://www.omg.org/XMI" xmlns:union="http:///union.ecore"
>> ownedElement="//@annotation.0">
>> <annotation/>
>> </union:TestingModel>
>>
>> i ran allways in an exception during deserialization. I've tried both
>> the editor and the programmatically deserialization. Both fail with
>> the following exception trace. It seems, that somewhere the
>> DerivedEObjectEList.add() method will be called.
>>
>> org.eclipse.emf.ecore.xmi.IllegalValueException: Value
>> 'union.impl.AnnotationImpl@352d87' is not legal.
>> (platform:/resource/f/My.union, -1, -1)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2648)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1135)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1214)
>>
>> at
>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .endDocument(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
>> Source)
>> at javax.xml.parsers.SAXParser.parse(Unknown Source)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1445)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1241)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>>
>> at union.presentation.UnionEditor.createModel(UnionEditor.java: 950)
>> at union.presentation.UnionEditor.createPages(UnionEditor.java: 1007)
>> at
>> org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:310)
>>
>> at ....
>>
>>
>> Caused by: java.lang.UnsupportedOperationException
>> at
>> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:278)
>>
>> at java.util.AbstractSequentialList.add(Unknown Source)
>> at
>> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:636)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1192)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2643)
>>
>> ... 58 more
>>
>>
>> For serialization and deserialization i'm using an
>> XMIBResource(Factory) created by the genmodel automatically. Please
>> let me know, what is going wrong in this really simple example.
>>
>> Thanks in advance
>> Timothy
Re: Problems with DerivedUnion during deserialization [message #479524 is a reply to message #479390] Tue, 11 August 2009 12:46 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Timothy,

Yeah, we used to automatically make derived properties transient (a long
time ago) but we changed it because in some cases it may be desirable to
serialize derived properties (e.g. if a value is more compact than the
values it is derived from).

Regarding the duplicate display issue, I'd suggest looking at how the
item providers are defined for your features. I suspect that providers
for two different features are displaying the value in question. In this
case you probably don't want the values for pre- and post-conditions to
appear in the content tree (since they will be coerced to
non-containment) but rather in the Properties view.

Kenn


Timothy Marc wrote:
> Kenn,
>
> god damn, i was aware of all other derived attributes or subset, but not
> for the unions... is there any rationale, why derived associations or
> attributes are not generally set to transient=true? Because of that they
> are already set to volatile=true i allways forget to set them manually
> to transient. But, it works now. Thanks!
>
> Another point: The generated editor behaves weird for the following
> snippet. I defined the following (trying to approximate the ownedRule
> semtanics of the superstructure):
>
> #####
> Element {abstract}
> +/ownedElement * {union, read-only, containment}
> +/ownedRule 0..* {subsets ownedElement, containment}
>
> NamedElemet extends Element
>
> BehavioralFeature extends NamedElement
>
> Operation extends BehavioralFeature
> +precondition 0..* {subsets ownedRule, containment}
> +postcondition 0..* {subsets ownedRule, containment} #####
>
> If i add an 'ownedRule' to the operation, everything is fine. But any
> adding of either pre- or postcondition has the effect, that 2 instances
> of the same constraint is displayed. Well, the XMI looks okay, IMHO:
>
> <packagedElement xsi:type="testing:Class" xmi:id="_cUg_8IXsEd6Lu8REkryexw">
> <ownedOperation xmi:id="_fkrwMIXsEd6Lu8REkryexw"
> postcondition="_gJMLcIXsEd6Lu8REkryexw">
> <ownedRule xmi:id="_gJMLcIXsEd6Lu8REkryexw"/>
> </ownedOperation>
> </packagedElement>
>
> The postcondition belongs both to the ownedRule containment reference,
> and to the postcondition reference of its context operation. In the
> editor, the constraint is shown twice instead of just being a single
> element. If i add a constraint via the ownedRule reference, only a
> single element is displayed.
>
> The java code for Operation::postcondition is:
>
> public EList<Constraint> getPostconditions() {
> if (postconditions == null) {
> postconditions = new
> SubsetSupersetEObjectResolvingEList<Constraint>(Constraint.class, this,
> TestingPackage.OPERATION__POSTCONDITION, POSTCONDITION_ESUPERSETS, null);
> }
> return postconditions;
> }
>
> and for Element::ownedRule it is
>
> public EList<Constraint> getOwnedRules() {
> if (ownedRules == null) {
> ownedRules = new
> EObjectContainmentWithInverseEList<Constraint>(Constraint.class, this,
> TestingPackage.MODEL_ELEMENT__OWNED_RULE,
> TestingPackage.CONSTRAINT__CONTEXT);
> }
> return ownedRules;
> }
>
> Again some perfect ideas?
>
> Thanks in advance
> Timothy
>
> Kenn Hussey schrieb:
>> Timothy,
>>
>> I wouldn't have expected to see an 'ownedElement' element in the
>> serialization, since derived unions are, by definition read-only
>> (hence the reason why the addition is failing upon deserialization).
>> Did you make that feature transient in the metamodel?
>>
>> Kenn
>>
>> Timothy Marc wrote:
>>> Hey all,
>>>
>>> i'm using the UML2 genmodel to generate a uml-like metamodel with
>>> subsets and unions etc. I've rebuild the Element -> ownedComment
>>> relationship of the UML 2.2 Superstructure (Figure 7.3). Instead of
>>> Comment, i've sed the term Annotation. The model looks like
>>>
>>> Element {abstract}
>>> +/owner 0..1 {union, read-only}
>>> +/ownedElement * {union, read-only}
>>>
>>> TestingModel extends Element
>>> + annotation * {subsets ownedElement}
>>>
>>> Annotation extends Element
>>>
>>>
>>> When i define a simple model like the model mentioned in the
>>> following XMI snippet
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <union:TestingModel xmi:version="2.0"
>>> xmlns:xmi="http://www.omg.org/XMI" xmlns:union="http:///union.ecore"
>>> ownedElement="//@annotation.0">
>>> <annotation/>
>>> </union:TestingModel>
>>>
>>> i ran allways in an exception during deserialization. I've tried both
>>> the editor and the programmatically deserialization. Both fail with
>>> the following exception trace. It seems, that somewhere the
>>> DerivedEObjectEList.add() method will be called.
>>>
>>> org.eclipse.emf.ecore.xmi.IllegalValueException: Value
>>> 'union.impl.AnnotationImpl@352d87' is not legal.
>>> (platform:/resource/f/My.union, -1, -1)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2648)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1135)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1214)
>>>
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .endDocument(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
>>> Source)
>>> at javax.xml.parsers.SAXParser.parse(Unknown Source)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1445)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1241)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>>>
>>> at union.presentation.UnionEditor.createModel(UnionEditor.java: 950)
>>> at union.presentation.UnionEditor.createPages(UnionEditor.java: 1007)
>>> at
>>> org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:310)
>>>
>>> at ....
>>>
>>>
>>> Caused by: java.lang.UnsupportedOperationException
>>> at
>>> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:278)
>>>
>>> at java.util.AbstractSequentialList.add(Unknown Source)
>>> at
>>> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:636)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1192)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2643)
>>>
>>> ... 58 more
>>>
>>>
>>> For serialization and deserialization i'm using an
>>> XMIBResource(Factory) created by the genmodel automatically. Please
>>> let me know, what is going wrong in this really simple example.
>>>
>>> Thanks in advance
>>> Timothy
Re: Problems with DerivedUnion during deserialization [message #479751 is a reply to message #479524] Wed, 12 August 2009 11:15 Go to previous messageGo to next message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
Kenn,

hmm... i've compared the item providers of UML2 and my model
(OperationItemProvider). They look exactly like the same, so i really
don't know where to apply the leverage in order to erase this misbehavior...

All this providing stuff is still a closed book to me.

Timothy

Kenn Hussey schrieb:
> Timothy,
>
> Yeah, we used to automatically make derived properties transient (a long
> time ago) but we changed it because in some cases it may be desirable to
> serialize derived properties (e.g. if a value is more compact than the
> values it is derived from).
>
> Regarding the duplicate display issue, I'd suggest looking at how the
> item providers are defined for your features. I suspect that providers
> for two different features are displaying the value in question. In this
> case you probably don't want the values for pre- and post-conditions to
> appear in the content tree (since they will be coerced to
> non-containment) but rather in the Properties view.
>
> Kenn
>
>
> Timothy Marc wrote:
>> Kenn,
>>
>> god damn, i was aware of all other derived attributes or subset, but
>> not for the unions... is there any rationale, why derived associations
>> or attributes are not generally set to transient=true? Because of that
>> they are already set to volatile=true i allways forget to set them
>> manually to transient. But, it works now. Thanks!
>>
>> Another point: The generated editor behaves weird for the following
>> snippet. I defined the following (trying to approximate the ownedRule
>> semtanics of the superstructure):
>>
>> #####
>> Element {abstract}
>> +/ownedElement * {union, read-only, containment}
>> +/ownedRule 0..* {subsets ownedElement, containment}
>>
>> NamedElemet extends Element
>>
>> BehavioralFeature extends NamedElement
>>
>> Operation extends BehavioralFeature
>> +precondition 0..* {subsets ownedRule, containment}
>> +postcondition 0..* {subsets ownedRule, containment} #####
>>
>> If i add an 'ownedRule' to the operation, everything is fine. But any
>> adding of either pre- or postcondition has the effect, that 2
>> instances of the same constraint is displayed. Well, the XMI looks
>> okay, IMHO:
>>
>> <packagedElement xsi:type="testing:Class"
>> xmi:id="_cUg_8IXsEd6Lu8REkryexw">
>> <ownedOperation xmi:id="_fkrwMIXsEd6Lu8REkryexw"
>> postcondition="_gJMLcIXsEd6Lu8REkryexw">
>> <ownedRule xmi:id="_gJMLcIXsEd6Lu8REkryexw"/>
>> </ownedOperation>
>> </packagedElement>
>>
>> The postcondition belongs both to the ownedRule containment reference,
>> and to the postcondition reference of its context operation. In the
>> editor, the constraint is shown twice instead of just being a single
>> element. If i add a constraint via the ownedRule reference, only a
>> single element is displayed.
>>
>> The java code for Operation::postcondition is:
>>
>> public EList<Constraint> getPostconditions() {
>> if (postconditions == null) {
>> postconditions = new
>> SubsetSupersetEObjectResolvingEList<Constraint>(Constraint.class,
>> this, TestingPackage.OPERATION__POSTCONDITION,
>> POSTCONDITION_ESUPERSETS, null);
>> }
>> return postconditions;
>> }
>>
>> and for Element::ownedRule it is
>>
>> public EList<Constraint> getOwnedRules() {
>> if (ownedRules == null) {
>> ownedRules = new
>> EObjectContainmentWithInverseEList<Constraint>(Constraint.class, this,
>> TestingPackage.MODEL_ELEMENT__OWNED_RULE,
>> TestingPackage.CONSTRAINT__CONTEXT);
>> }
>> return ownedRules;
>> }
>>
>> Again some perfect ideas?
>>
>> Thanks in advance
>> Timothy
>>
>> Kenn Hussey schrieb:
>>> Timothy,
>>>
>>> I wouldn't have expected to see an 'ownedElement' element in the
>>> serialization, since derived unions are, by definition read-only
>>> (hence the reason why the addition is failing upon deserialization).
>>> Did you make that feature transient in the metamodel?
>>>
>>> Kenn
>>>
>>> Timothy Marc wrote:
>>>> Hey all,
>>>>
>>>> i'm using the UML2 genmodel to generate a uml-like metamodel with
>>>> subsets and unions etc. I've rebuild the Element -> ownedComment
>>>> relationship of the UML 2.2 Superstructure (Figure 7.3). Instead of
>>>> Comment, i've sed the term Annotation. The model looks like
>>>>
>>>> Element {abstract}
>>>> +/owner 0..1 {union, read-only}
>>>> +/ownedElement * {union, read-only}
>>>>
>>>> TestingModel extends Element
>>>> + annotation * {subsets ownedElement}
>>>>
>>>> Annotation extends Element
>>>>
>>>>
>>>> When i define a simple model like the model mentioned in the
>>>> following XMI snippet
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <union:TestingModel xmi:version="2.0"
>>>> xmlns:xmi="http://www.omg.org/XMI" xmlns:union="http:///union.ecore"
>>>> ownedElement="//@annotation.0">
>>>> <annotation/>
>>>> </union:TestingModel>
>>>>
>>>> i ran allways in an exception during deserialization. I've tried
>>>> both the editor and the programmatically deserialization. Both fail
>>>> with the following exception trace. It seems, that somewhere the
>>>> DerivedEObjectEList.add() method will be called.
>>>>
>>>> org.eclipse.emf.ecore.xmi.IllegalValueException: Value
>>>> 'union.impl.AnnotationImpl@352d87' is not legal.
>>>> (platform:/resource/f/My.union, -1, -1)
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2648)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1135)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1214)
>>>>
>>>> at
>>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .endDocument(Unknown
>>>> Source)
>>>> at
>>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
>>>> Source)
>>>> at
>>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>>> Source)
>>>> at
>>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>>> Source)
>>>> at
>>>> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
>>>> Source)
>>>> at
>>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
>>>> Source)
>>>> at
>>>> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
>>>> Source)
>>>> at javax.xml.parsers.SAXParser.parse(Unknown Source)
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1445)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1241)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>>>>
>>>> at union.presentation.UnionEditor.createModel(UnionEditor.java: 950)
>>>> at
>>>> union.presentation.UnionEditor.createPages(UnionEditor.java: 1007)
>>>> at
>>>> org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:310)
>>>>
>>>> at ....
>>>>
>>>>
>>>> Caused by: java.lang.UnsupportedOperationException
>>>> at
>>>> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:278)
>>>>
>>>> at java.util.AbstractSequentialList.add(Unknown Source)
>>>> at
>>>> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:636)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1192)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2643)
>>>>
>>>> ... 58 more
>>>>
>>>>
>>>> For serialization and deserialization i'm using an
>>>> XMIBResource(Factory) created by the genmodel automatically. Please
>>>> let me know, what is going wrong in this really simple example.
>>>>
>>>> Thanks in advance
>>>> Timothy
Re: Problems with DerivedUnion during deserialization [message #480610 is a reply to message #479751] Mon, 17 August 2009 20:53 Go to previous messageGo to next message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
Kenn,

it's me again concerning the duplicate entry problem. As mentioned, the
XMI is correct and when i load the model prgramatically, all stuff is
correct implemented... so one question: is the default generated editor
from emf capable to handle multiple subset containment references?

To me it seems, as there are problems with subsets, when two (or more)
references from one source element point to a target element. In case of
Operation->Constraint, there are 2 references (namely preconditios and
postconditions) where the asso ends are from the same type. It seems as
if the editor can not distinguish between a preconditon or
postcondition... the XMI is:

<?xml version="1.0" encoding="UTF-8"?>
<testing:TestingModel xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:testing="http://www.fokus.fraunhofer.de/testing/testing.ecore"
xmi:id="_vbeNAItuEd6Wtdf04WDKwQ">
<packagedElement xsi:type="testing:Class"
xmi:id="_T2weUYtvEd6uo5hY0fhr5A">
<ownedOperation xmi:id="_Uv00UItvEd6uo5hY0fhr5A"
postcondition="_VXUSIItvEd6uo5hY0fhr5A">
<ownedRule xsi:type="testing:Constraint"
xmi:id="_VXUSIItvEd6uo5hY0fhr5A"/> //inserted as precondition!!!!!
</ownedOperation>
</packagedElement>
</testing:TestingModel>

/Timothy

Timothy Marc schrieb:
> Kenn,
>
> hmm... i've compared the item providers of UML2 and my model
> (OperationItemProvider). They look exactly like the same, so i really
> don't know where to apply the leverage in order to erase this
> misbehavior...
>
> All this providing stuff is still a closed book to me.
>
> Timothy
>
> Kenn Hussey schrieb:
>> Timothy,
>>
>> Yeah, we used to automatically make derived properties transient (a
>> long time ago) but we changed it because in some cases it may be
>> desirable to serialize derived properties (e.g. if a value is more
>> compact than the values it is derived from).
>>
>> Regarding the duplicate display issue, I'd suggest looking at how the
>> item providers are defined for your features. I suspect that providers
>> for two different features are displaying the value in question. In
>> this case you probably don't want the values for pre- and
>> post-conditions to appear in the content tree (since they will be
>> coerced to non-containment) but rather in the Properties view.
>>
>> Kenn
>>
>>
>> Timothy Marc wrote:
>>> Kenn,
>>>
>>> god damn, i was aware of all other derived attributes or subset, but
>>> not for the unions... is there any rationale, why derived
>>> associations or attributes are not generally set to transient=true?
>>> Because of that they are already set to volatile=true i allways
>>> forget to set them manually to transient. But, it works now. Thanks!
>>>
>>> Another point: The generated editor behaves weird for the following
>>> snippet. I defined the following (trying to approximate the ownedRule
>>> semtanics of the superstructure):
>>>
>>> #####
>>> Element {abstract}
>>> +/ownedElement * {union, read-only, containment}
>>> +/ownedRule 0..* {subsets ownedElement, containment}
>>>
>>> NamedElemet extends Element
>>>
>>> BehavioralFeature extends NamedElement
>>>
>>> Operation extends BehavioralFeature
>>> +precondition 0..* {subsets ownedRule, containment}
>>> +postcondition 0..* {subsets ownedRule, containment} #####
>>>
>>> If i add an 'ownedRule' to the operation, everything is fine. But any
>>> adding of either pre- or postcondition has the effect, that 2
>>> instances of the same constraint is displayed. Well, the XMI looks
>>> okay, IMHO:
>>>
>>> <packagedElement xsi:type="testing:Class"
>>> xmi:id="_cUg_8IXsEd6Lu8REkryexw">
>>> <ownedOperation xmi:id="_fkrwMIXsEd6Lu8REkryexw"
>>> postcondition="_gJMLcIXsEd6Lu8REkryexw">
>>> <ownedRule xmi:id="_gJMLcIXsEd6Lu8REkryexw"/>
>>> </ownedOperation>
>>> </packagedElement>
>>>
>>> The postcondition belongs both to the ownedRule containment
>>> reference, and to the postcondition reference of its context
>>> operation. In the editor, the constraint is shown twice instead of
>>> just being a single element. If i add a constraint via the ownedRule
>>> reference, only a single element is displayed.
>>>
>>> The java code for Operation::postcondition is:
>>>
>>> public EList<Constraint> getPostconditions() {
>>> if (postconditions == null) {
>>> postconditions = new
>>> SubsetSupersetEObjectResolvingEList<Constraint>(Constraint.class,
>>> this, TestingPackage.OPERATION__POSTCONDITION,
>>> POSTCONDITION_ESUPERSETS, null);
>>> }
>>> return postconditions;
>>> }
>>>
>>> and for Element::ownedRule it is
>>>
>>> public EList<Constraint> getOwnedRules() {
>>> if (ownedRules == null) {
>>> ownedRules = new
>>> EObjectContainmentWithInverseEList<Constraint>(Constraint.class,
>>> this, TestingPackage.MODEL_ELEMENT__OWNED_RULE,
>>> TestingPackage.CONSTRAINT__CONTEXT);
>>> }
>>> return ownedRules;
>>> }
>>>
>>> Again some perfect ideas?
>>>
>>> Thanks in advance
>>> Timothy
>>>
>>> Kenn Hussey schrieb:
>>>> Timothy,
>>>>
>>>> I wouldn't have expected to see an 'ownedElement' element in the
>>>> serialization, since derived unions are, by definition read-only
>>>> (hence the reason why the addition is failing upon deserialization).
>>>> Did you make that feature transient in the metamodel?
>>>>
>>>> Kenn
>>>>
>>>> Timothy Marc wrote:
>>>>> Hey all,
>>>>>
>>>>> i'm using the UML2 genmodel to generate a uml-like metamodel with
>>>>> subsets and unions etc. I've rebuild the Element -> ownedComment
>>>>> relationship of the UML 2.2 Superstructure (Figure 7.3). Instead of
>>>>> Comment, i've sed the term Annotation. The model looks like
>>>>>
>>>>> Element {abstract}
>>>>> +/owner 0..1 {union, read-only}
>>>>> +/ownedElement * {union, read-only}
>>>>>
>>>>> TestingModel extends Element
>>>>> + annotation * {subsets ownedElement}
>>>>>
>>>>> Annotation extends Element
>>>>>
>>>>>
>>>>> When i define a simple model like the model mentioned in the
>>>>> following XMI snippet
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>> <union:TestingModel xmi:version="2.0"
>>>>> xmlns:xmi="http://www.omg.org/XMI"
>>>>> xmlns:union="http:///union.ecore" ownedElement="//@annotation.0">
>>>>> <annotation/>
>>>>> </union:TestingModel>
>>>>>
>>>>> i ran allways in an exception during deserialization. I've tried
>>>>> both the editor and the programmatically deserialization. Both fail
>>>>> with the following exception trace. It seems, that somewhere the
>>>>> DerivedEObjectEList.add() method will be called.
>>>>>
>>>>> org.eclipse.emf.ecore.xmi.IllegalValueException: Value
>>>>> 'union.impl.AnnotationImpl@352d87' is not legal.
>>>>> (platform:/resource/f/My.union, -1, -1)
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2648)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1135)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1214)
>>>>>
>>>>> at
>>>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .endDocument(Unknown
>>>>> Source)
>>>>> at
>>>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
>>>>> Source)
>>>>> at
>>>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>>>> Source)
>>>>> at
>>>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>>>> Source)
>>>>> at
>>>>> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
>>>>> Source)
>>>>> at
>>>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
>>>>> Source)
>>>>> at
>>>>> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
>>>>> Source)
>>>>> at javax.xml.parsers.SAXParser.parse(Unknown Source)
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1445)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1241)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>>>>>
>>>>> at
>>>>> union.presentation.UnionEditor.createModel(UnionEditor.java: 950)
>>>>> at
>>>>> union.presentation.UnionEditor.createPages(UnionEditor.java: 1007)
>>>>> at
>>>>> org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:310)
>>>>>
>>>>> at ....
>>>>>
>>>>>
>>>>> Caused by: java.lang.UnsupportedOperationException
>>>>> at
>>>>> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:278)
>>>>>
>>>>> at java.util.AbstractSequentialList.add(Unknown Source)
>>>>> at
>>>>> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:636)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1192)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2643)
>>>>>
>>>>> ... 58 more
>>>>>
>>>>>
>>>>> For serialization and deserialization i'm using an
>>>>> XMIBResource(Factory) created by the genmodel automatically. Please
>>>>> let me know, what is going wrong in this really simple example.
>>>>>
>>>>> Thanks in advance
>>>>> Timothy
Re: Problems with DerivedUnion during deserialization [message #485163 is a reply to message #480610] Thu, 10 September 2009 16:41 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Timothy,

Something must not be right about the way the precondition feature is
defined. Both it and the postcondition features should be
non-containment subsets of the ownedRule containment feature (which, in
UML2, is inherited from NamedElement).

Regarding the item provider implementation, I would expect only the
ownedRule feature to be referenced by the getChildrenFeatures(...)
method. Is that the case?

If you're still having trouble, perhaps you could send me your Ecore and
generator models and I'll take a closer look.

Kenn

Timothy Marc wrote:
> Kenn,
>
> it's me again concerning the duplicate entry problem. As mentioned, the
> XMI is correct and when i load the model prgramatically, all stuff is
> correct implemented... so one question: is the default generated editor
> from emf capable to handle multiple subset containment references?
>
> To me it seems, as there are problems with subsets, when two (or more)
> references from one source element point to a target element. In case of
> Operation->Constraint, there are 2 references (namely preconditios and
> postconditions) where the asso ends are from the same type. It seems as
> if the editor can not distinguish between a preconditon or
> postcondition... the XMI is:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <testing:TestingModel xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:testing="http://www.fokus.fraunhofer.de/testing/testing.ecore"
> xmi:id="_vbeNAItuEd6Wtdf04WDKwQ">
> <packagedElement xsi:type="testing:Class"
> xmi:id="_T2weUYtvEd6uo5hY0fhr5A">
> <ownedOperation xmi:id="_Uv00UItvEd6uo5hY0fhr5A"
> postcondition="_VXUSIItvEd6uo5hY0fhr5A">
> <ownedRule xsi:type="testing:Constraint"
> xmi:id="_VXUSIItvEd6uo5hY0fhr5A"/> //inserted as precondition!!!!!
> </ownedOperation>
> </packagedElement>
> </testing:TestingModel>
>
> /Timothy
>
> Timothy Marc schrieb:
>> Kenn,
>>
>> hmm... i've compared the item providers of UML2 and my model
>> (OperationItemProvider). They look exactly like the same, so i really
>> don't know where to apply the leverage in order to erase this
>> misbehavior...
>>
>> All this providing stuff is still a closed book to me.
>>
>> Timothy
>>
>> Kenn Hussey schrieb:
>>> Timothy,
>>>
>>> Yeah, we used to automatically make derived properties transient (a
>>> long time ago) but we changed it because in some cases it may be
>>> desirable to serialize derived properties (e.g. if a value is more
>>> compact than the values it is derived from).
>>>
>>> Regarding the duplicate display issue, I'd suggest looking at how the
>>> item providers are defined for your features. I suspect that
>>> providers for two different features are displaying the value in
>>> question. In this case you probably don't want the values for pre-
>>> and post-conditions to appear in the content tree (since they will be
>>> coerced to non-containment) but rather in the Properties view.
>>>
>>> Kenn
>>>
>>>
>>> Timothy Marc wrote:
>>>> Kenn,
>>>>
>>>> god damn, i was aware of all other derived attributes or subset, but
>>>> not for the unions... is there any rationale, why derived
>>>> associations or attributes are not generally set to transient=true?
>>>> Because of that they are already set to volatile=true i allways
>>>> forget to set them manually to transient. But, it works now. Thanks!
>>>>
>>>> Another point: The generated editor behaves weird for the following
>>>> snippet. I defined the following (trying to approximate the
>>>> ownedRule semtanics of the superstructure):
>>>>
>>>> #####
>>>> Element {abstract}
>>>> +/ownedElement * {union, read-only, containment}
>>>> +/ownedRule 0..* {subsets ownedElement, containment}
>>>>
>>>> NamedElemet extends Element
>>>>
>>>> BehavioralFeature extends NamedElement
>>>>
>>>> Operation extends BehavioralFeature
>>>> +precondition 0..* {subsets ownedRule, containment}
>>>> +postcondition 0..* {subsets ownedRule, containment} #####
>>>>
>>>> If i add an 'ownedRule' to the operation, everything is fine. But
>>>> any adding of either pre- or postcondition has the effect, that 2
>>>> instances of the same constraint is displayed. Well, the XMI looks
>>>> okay, IMHO:
>>>>
>>>> <packagedElement xsi:type="testing:Class"
>>>> xmi:id="_cUg_8IXsEd6Lu8REkryexw">
>>>> <ownedOperation xmi:id="_fkrwMIXsEd6Lu8REkryexw"
>>>> postcondition="_gJMLcIXsEd6Lu8REkryexw">
>>>> <ownedRule xmi:id="_gJMLcIXsEd6Lu8REkryexw"/>
>>>> </ownedOperation>
>>>> </packagedElement>
>>>>
>>>> The postcondition belongs both to the ownedRule containment
>>>> reference, and to the postcondition reference of its context
>>>> operation. In the editor, the constraint is shown twice instead of
>>>> just being a single element. If i add a constraint via the ownedRule
>>>> reference, only a single element is displayed.
>>>>
>>>> The java code for Operation::postcondition is:
>>>>
>>>> public EList<Constraint> getPostconditions() {
>>>> if (postconditions == null) {
>>>> postconditions = new
>>>> SubsetSupersetEObjectResolvingEList<Constraint>(Constraint.class,
>>>> this, TestingPackage.OPERATION__POSTCONDITION,
>>>> POSTCONDITION_ESUPERSETS, null);
>>>> }
>>>> return postconditions;
>>>> }
>>>>
>>>> and for Element::ownedRule it is
>>>>
>>>> public EList<Constraint> getOwnedRules() {
>>>> if (ownedRules == null) {
>>>> ownedRules = new
>>>> EObjectContainmentWithInverseEList<Constraint>(Constraint.class,
>>>> this, TestingPackage.MODEL_ELEMENT__OWNED_RULE,
>>>> TestingPackage.CONSTRAINT__CONTEXT);
>>>> }
>>>> return ownedRules;
>>>> }
>>>>
>>>> Again some perfect ideas?
>>>>
>>>> Thanks in advance
>>>> Timothy
>>>>
>>>> Kenn Hussey schrieb:
>>>>> Timothy,
>>>>>
>>>>> I wouldn't have expected to see an 'ownedElement' element in the
>>>>> serialization, since derived unions are, by definition read-only
>>>>> (hence the reason why the addition is failing upon
>>>>> deserialization). Did you make that feature transient in the
>>>>> metamodel?
>>>>>
>>>>> Kenn
>>>>>
>>>>> Timothy Marc wrote:
>>>>>> Hey all,
>>>>>>
>>>>>> i'm using the UML2 genmodel to generate a uml-like metamodel with
>>>>>> subsets and unions etc. I've rebuild the Element -> ownedComment
>>>>>> relationship of the UML 2.2 Superstructure (Figure 7.3). Instead
>>>>>> of Comment, i've sed the term Annotation. The model looks like
>>>>>>
>>>>>> Element {abstract}
>>>>>> +/owner 0..1 {union, read-only}
>>>>>> +/ownedElement * {union, read-only}
>>>>>>
>>>>>> TestingModel extends Element
>>>>>> + annotation * {subsets ownedElement}
>>>>>>
>>>>>> Annotation extends Element
>>>>>>
>>>>>>
>>>>>> When i define a simple model like the model mentioned in the
>>>>>> following XMI snippet
>>>>>>
>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>> <union:TestingModel xmi:version="2.0"
>>>>>> xmlns:xmi="http://www.omg.org/XMI"
>>>>>> xmlns:union="http:///union.ecore" ownedElement="//@annotation.0">
>>>>>> <annotation/>
>>>>>> </union:TestingModel>
>>>>>>
>>>>>> i ran allways in an exception during deserialization. I've tried
>>>>>> both the editor and the programmatically deserialization. Both
>>>>>> fail with the following exception trace. It seems, that somewhere
>>>>>> the DerivedEObjectEList.add() method will be called.
>>>>>>
>>>>>> org.eclipse.emf.ecore.xmi.IllegalValueException: Value
>>>>>> 'union.impl.AnnotationImpl@352d87' is not legal.
>>>>>> (platform:/resource/f/My.union, -1, -1)
>>>>>> at
>>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2648)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1135)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1214)
>>>>>>
>>>>>> at
>>>>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .endDocument(Unknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
>>>>>> Source)
>>>>>> at javax.xml.parsers.SAXParser.parse(Unknown Source)
>>>>>> at
>>>>>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
>>>>>> at
>>>>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1445)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1241)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>>>>>>
>>>>>> at
>>>>>> union.presentation.UnionEditor.createModel(UnionEditor.java: 950)
>>>>>> at
>>>>>> union.presentation.UnionEditor.createPages(UnionEditor.java: 1007)
>>>>>> at
>>>>>> org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:310)
>>>>>>
>>>>>> at ....
>>>>>>
>>>>>>
>>>>>> Caused by: java.lang.UnsupportedOperationException
>>>>>> at
>>>>>> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:278)
>>>>>>
>>>>>> at java.util.AbstractSequentialList.add(Unknown Source)
>>>>>> at
>>>>>> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:636)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1192)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2643)
>>>>>>
>>>>>> ... 58 more
>>>>>>
>>>>>>
>>>>>> For serialization and deserialization i'm using an
>>>>>> XMIBResource(Factory) created by the genmodel automatically.
>>>>>> Please let me know, what is going wrong in this really simple
>>>>>> example.
>>>>>>
>>>>>> Thanks in advance
>>>>>> Timothy
Re: Problems with DerivedUnion during deserialization [message #627860 is a reply to message #479235] Mon, 10 August 2009 17:02 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Timothy,

I wouldn't have expected to see an 'ownedElement' element in the
serialization, since derived unions are, by definition read-only (hence
the reason why the addition is failing upon deserialization). Did you
make that feature transient in the metamodel?

Kenn

Timothy Marc wrote:
> Hey all,
>
> i'm using the UML2 genmodel to generate a uml-like metamodel with
> subsets and unions etc. I've rebuild the Element -> ownedComment
> relationship of the UML 2.2 Superstructure (Figure 7.3). Instead of
> Comment, i've sed the term Annotation. The model looks like
>
> Element {abstract}
> +/owner 0..1 {union, read-only}
> +/ownedElement * {union, read-only}
>
> TestingModel extends Element
> + annotation * {subsets ownedElement}
>
> Annotation extends Element
>
>
> When i define a simple model like the model mentioned in the following
> XMI snippet
>
> <?xml version="1.0" encoding="UTF-8"?>
> <union:TestingModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:union="http:///union.ecore" ownedElement="//@annotation.0">
> <annotation/>
> </union:TestingModel>
>
> i ran allways in an exception during deserialization. I've tried both
> the editor and the programmatically deserialization. Both fail with the
> following exception trace. It seems, that somewhere the
> DerivedEObjectEList.add() method will be called.
>
> org.eclipse.emf.ecore.xmi.IllegalValueException: Value
> 'union.impl.AnnotationImpl@352d87' is not legal.
> (platform:/resource/f/My.union, -1, -1)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2648)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1135)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1214)
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .endDocument(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown Source)
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
> Source)
> at javax.xml.parsers.SAXParser.parse(Unknown Source)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1445)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1241)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>
> at union.presentation.UnionEditor.createModel(UnionEditor.java: 950)
> at union.presentation.UnionEditor.createPages(UnionEditor.java: 1007)
> at
> org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:310)
>
> at ....
>
>
> Caused by: java.lang.UnsupportedOperationException
> at
> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:278)
>
> at java.util.AbstractSequentialList.add(Unknown Source)
> at
> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:636)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1192)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2643)
>
> ... 58 more
>
>
> For serialization and deserialization i'm using an XMIBResource(Factory)
> created by the genmodel automatically. Please let me know, what is going
> wrong in this really simple example.
>
> Thanks in advance
> Timothy
Re: Problems with DerivedUnion during deserialization [message #627864 is a reply to message #479321] Mon, 10 August 2009 20:39 Go to previous message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
Kenn,

god damn, i was aware of all other derived attributes or subset, but not
for the unions... is there any rationale, why derived associations or
attributes are not generally set to transient=true? Because of that they
are already set to volatile=true i allways forget to set them manually
to transient. But, it works now. Thanks!

Another point: The generated editor behaves weird for the following
snippet. I defined the following (trying to approximate the ownedRule
semtanics of the superstructure):

#####
Element {abstract}
+/ownedElement * {union, read-only, containment}
+/ownedRule 0..* {subsets ownedElement, containment}

NamedElemet extends Element

BehavioralFeature extends NamedElement

Operation extends BehavioralFeature
+precondition 0..* {subsets ownedRule, containment}
+postcondition 0..* {subsets ownedRule, containment} #####

If i add an 'ownedRule' to the operation, everything is fine. But any
adding of either pre- or postcondition has the effect, that 2 instances
of the same constraint is displayed. Well, the XMI looks okay, IMHO:

<packagedElement xsi:type="testing:Class" xmi:id="_cUg_8IXsEd6Lu8REkryexw">
<ownedOperation xmi:id="_fkrwMIXsEd6Lu8REkryexw"
postcondition="_gJMLcIXsEd6Lu8REkryexw">
<ownedRule xmi:id="_gJMLcIXsEd6Lu8REkryexw"/>
</ownedOperation>
</packagedElement>

The postcondition belongs both to the ownedRule containment reference,
and to the postcondition reference of its context operation. In the
editor, the constraint is shown twice instead of just being a single
element. If i add a constraint via the ownedRule reference, only a
single element is displayed.

The java code for Operation::postcondition is:

public EList<Constraint> getPostconditions() {
if (postconditions == null) {
postconditions = new
SubsetSupersetEObjectResolvingEList<Constraint>(Constraint.class, this,
TestingPackage.OPERATION__POSTCONDITION, POSTCONDITION_ESUPERSETS, null);
}
return postconditions;
}

and for Element::ownedRule it is

public EList<Constraint> getOwnedRules() {
if (ownedRules == null) {
ownedRules = new
EObjectContainmentWithInverseEList<Constraint>(Constraint.class, this,
TestingPackage.MODEL_ELEMENT__OWNED_RULE,
TestingPackage.CONSTRAINT__CONTEXT);
}
return ownedRules;
}

Again some perfect ideas?

Thanks in advance
Timothy

Kenn Hussey schrieb:
> Timothy,
>
> I wouldn't have expected to see an 'ownedElement' element in the
> serialization, since derived unions are, by definition read-only (hence
> the reason why the addition is failing upon deserialization). Did you
> make that feature transient in the metamodel?
>
> Kenn
>
> Timothy Marc wrote:
>> Hey all,
>>
>> i'm using the UML2 genmodel to generate a uml-like metamodel with
>> subsets and unions etc. I've rebuild the Element -> ownedComment
>> relationship of the UML 2.2 Superstructure (Figure 7.3). Instead of
>> Comment, i've sed the term Annotation. The model looks like
>>
>> Element {abstract}
>> +/owner 0..1 {union, read-only}
>> +/ownedElement * {union, read-only}
>>
>> TestingModel extends Element
>> + annotation * {subsets ownedElement}
>>
>> Annotation extends Element
>>
>>
>> When i define a simple model like the model mentioned in the following
>> XMI snippet
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <union:TestingModel xmi:version="2.0"
>> xmlns:xmi="http://www.omg.org/XMI" xmlns:union="http:///union.ecore"
>> ownedElement="//@annotation.0">
>> <annotation/>
>> </union:TestingModel>
>>
>> i ran allways in an exception during deserialization. I've tried both
>> the editor and the programmatically deserialization. Both fail with
>> the following exception trace. It seems, that somewhere the
>> DerivedEObjectEList.add() method will be called.
>>
>> org.eclipse.emf.ecore.xmi.IllegalValueException: Value
>> 'union.impl.AnnotationImpl@352d87' is not legal.
>> (platform:/resource/f/My.union, -1, -1)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2648)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1135)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1214)
>>
>> at
>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .endDocument(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
>> Source)
>> at javax.xml.parsers.SAXParser.parse(Unknown Source)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1445)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1241)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>>
>> at union.presentation.UnionEditor.createModel(UnionEditor.java: 950)
>> at union.presentation.UnionEditor.createPages(UnionEditor.java: 1007)
>> at
>> org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:310)
>>
>> at ....
>>
>>
>> Caused by: java.lang.UnsupportedOperationException
>> at
>> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:278)
>>
>> at java.util.AbstractSequentialList.add(Unknown Source)
>> at
>> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:636)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1192)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2643)
>>
>> ... 58 more
>>
>>
>> For serialization and deserialization i'm using an
>> XMIBResource(Factory) created by the genmodel automatically. Please
>> let me know, what is going wrong in this really simple example.
>>
>> Thanks in advance
>> Timothy
Re: Problems with DerivedUnion during deserialization [message #627867 is a reply to message #479390] Tue, 11 August 2009 12:46 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Timothy,

Yeah, we used to automatically make derived properties transient (a long
time ago) but we changed it because in some cases it may be desirable to
serialize derived properties (e.g. if a value is more compact than the
values it is derived from).

Regarding the duplicate display issue, I'd suggest looking at how the
item providers are defined for your features. I suspect that providers
for two different features are displaying the value in question. In this
case you probably don't want the values for pre- and post-conditions to
appear in the content tree (since they will be coerced to
non-containment) but rather in the Properties view.

Kenn


Timothy Marc wrote:
> Kenn,
>
> god damn, i was aware of all other derived attributes or subset, but not
> for the unions... is there any rationale, why derived associations or
> attributes are not generally set to transient=true? Because of that they
> are already set to volatile=true i allways forget to set them manually
> to transient. But, it works now. Thanks!
>
> Another point: The generated editor behaves weird for the following
> snippet. I defined the following (trying to approximate the ownedRule
> semtanics of the superstructure):
>
> #####
> Element {abstract}
> +/ownedElement * {union, read-only, containment}
> +/ownedRule 0..* {subsets ownedElement, containment}
>
> NamedElemet extends Element
>
> BehavioralFeature extends NamedElement
>
> Operation extends BehavioralFeature
> +precondition 0..* {subsets ownedRule, containment}
> +postcondition 0..* {subsets ownedRule, containment} #####
>
> If i add an 'ownedRule' to the operation, everything is fine. But any
> adding of either pre- or postcondition has the effect, that 2 instances
> of the same constraint is displayed. Well, the XMI looks okay, IMHO:
>
> <packagedElement xsi:type="testing:Class" xmi:id="_cUg_8IXsEd6Lu8REkryexw">
> <ownedOperation xmi:id="_fkrwMIXsEd6Lu8REkryexw"
> postcondition="_gJMLcIXsEd6Lu8REkryexw">
> <ownedRule xmi:id="_gJMLcIXsEd6Lu8REkryexw"/>
> </ownedOperation>
> </packagedElement>
>
> The postcondition belongs both to the ownedRule containment reference,
> and to the postcondition reference of its context operation. In the
> editor, the constraint is shown twice instead of just being a single
> element. If i add a constraint via the ownedRule reference, only a
> single element is displayed.
>
> The java code for Operation::postcondition is:
>
> public EList<Constraint> getPostconditions() {
> if (postconditions == null) {
> postconditions = new
> SubsetSupersetEObjectResolvingEList<Constraint>(Constraint.class, this,
> TestingPackage.OPERATION__POSTCONDITION, POSTCONDITION_ESUPERSETS, null);
> }
> return postconditions;
> }
>
> and for Element::ownedRule it is
>
> public EList<Constraint> getOwnedRules() {
> if (ownedRules == null) {
> ownedRules = new
> EObjectContainmentWithInverseEList<Constraint>(Constraint.class, this,
> TestingPackage.MODEL_ELEMENT__OWNED_RULE,
> TestingPackage.CONSTRAINT__CONTEXT);
> }
> return ownedRules;
> }
>
> Again some perfect ideas?
>
> Thanks in advance
> Timothy
>
> Kenn Hussey schrieb:
>> Timothy,
>>
>> I wouldn't have expected to see an 'ownedElement' element in the
>> serialization, since derived unions are, by definition read-only
>> (hence the reason why the addition is failing upon deserialization).
>> Did you make that feature transient in the metamodel?
>>
>> Kenn
>>
>> Timothy Marc wrote:
>>> Hey all,
>>>
>>> i'm using the UML2 genmodel to generate a uml-like metamodel with
>>> subsets and unions etc. I've rebuild the Element -> ownedComment
>>> relationship of the UML 2.2 Superstructure (Figure 7.3). Instead of
>>> Comment, i've sed the term Annotation. The model looks like
>>>
>>> Element {abstract}
>>> +/owner 0..1 {union, read-only}
>>> +/ownedElement * {union, read-only}
>>>
>>> TestingModel extends Element
>>> + annotation * {subsets ownedElement}
>>>
>>> Annotation extends Element
>>>
>>>
>>> When i define a simple model like the model mentioned in the
>>> following XMI snippet
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <union:TestingModel xmi:version="2.0"
>>> xmlns:xmi="http://www.omg.org/XMI" xmlns:union="http:///union.ecore"
>>> ownedElement="//@annotation.0">
>>> <annotation/>
>>> </union:TestingModel>
>>>
>>> i ran allways in an exception during deserialization. I've tried both
>>> the editor and the programmatically deserialization. Both fail with
>>> the following exception trace. It seems, that somewhere the
>>> DerivedEObjectEList.add() method will be called.
>>>
>>> org.eclipse.emf.ecore.xmi.IllegalValueException: Value
>>> 'union.impl.AnnotationImpl@352d87' is not legal.
>>> (platform:/resource/f/My.union, -1, -1)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2648)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1135)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1214)
>>>
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .endDocument(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
>>> Source)
>>> at javax.xml.parsers.SAXParser.parse(Unknown Source)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1445)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1241)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>>>
>>> at union.presentation.UnionEditor.createModel(UnionEditor.java: 950)
>>> at union.presentation.UnionEditor.createPages(UnionEditor.java: 1007)
>>> at
>>> org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:310)
>>>
>>> at ....
>>>
>>>
>>> Caused by: java.lang.UnsupportedOperationException
>>> at
>>> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:278)
>>>
>>> at java.util.AbstractSequentialList.add(Unknown Source)
>>> at
>>> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:636)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1192)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2643)
>>>
>>> ... 58 more
>>>
>>>
>>> For serialization and deserialization i'm using an
>>> XMIBResource(Factory) created by the genmodel automatically. Please
>>> let me know, what is going wrong in this really simple example.
>>>
>>> Thanks in advance
>>> Timothy
Re: Problems with DerivedUnion during deserialization [message #627875 is a reply to message #479524] Wed, 12 August 2009 11:15 Go to previous message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
Kenn,

hmm... i've compared the item providers of UML2 and my model
(OperationItemProvider). They look exactly like the same, so i really
don't know where to apply the leverage in order to erase this misbehavior...

All this providing stuff is still a closed book to me.

Timothy

Kenn Hussey schrieb:
> Timothy,
>
> Yeah, we used to automatically make derived properties transient (a long
> time ago) but we changed it because in some cases it may be desirable to
> serialize derived properties (e.g. if a value is more compact than the
> values it is derived from).
>
> Regarding the duplicate display issue, I'd suggest looking at how the
> item providers are defined for your features. I suspect that providers
> for two different features are displaying the value in question. In this
> case you probably don't want the values for pre- and post-conditions to
> appear in the content tree (since they will be coerced to
> non-containment) but rather in the Properties view.
>
> Kenn
>
>
> Timothy Marc wrote:
>> Kenn,
>>
>> god damn, i was aware of all other derived attributes or subset, but
>> not for the unions... is there any rationale, why derived associations
>> or attributes are not generally set to transient=true? Because of that
>> they are already set to volatile=true i allways forget to set them
>> manually to transient. But, it works now. Thanks!
>>
>> Another point: The generated editor behaves weird for the following
>> snippet. I defined the following (trying to approximate the ownedRule
>> semtanics of the superstructure):
>>
>> #####
>> Element {abstract}
>> +/ownedElement * {union, read-only, containment}
>> +/ownedRule 0..* {subsets ownedElement, containment}
>>
>> NamedElemet extends Element
>>
>> BehavioralFeature extends NamedElement
>>
>> Operation extends BehavioralFeature
>> +precondition 0..* {subsets ownedRule, containment}
>> +postcondition 0..* {subsets ownedRule, containment} #####
>>
>> If i add an 'ownedRule' to the operation, everything is fine. But any
>> adding of either pre- or postcondition has the effect, that 2
>> instances of the same constraint is displayed. Well, the XMI looks
>> okay, IMHO:
>>
>> <packagedElement xsi:type="testing:Class"
>> xmi:id="_cUg_8IXsEd6Lu8REkryexw">
>> <ownedOperation xmi:id="_fkrwMIXsEd6Lu8REkryexw"
>> postcondition="_gJMLcIXsEd6Lu8REkryexw">
>> <ownedRule xmi:id="_gJMLcIXsEd6Lu8REkryexw"/>
>> </ownedOperation>
>> </packagedElement>
>>
>> The postcondition belongs both to the ownedRule containment reference,
>> and to the postcondition reference of its context operation. In the
>> editor, the constraint is shown twice instead of just being a single
>> element. If i add a constraint via the ownedRule reference, only a
>> single element is displayed.
>>
>> The java code for Operation::postcondition is:
>>
>> public EList<Constraint> getPostconditions() {
>> if (postconditions == null) {
>> postconditions = new
>> SubsetSupersetEObjectResolvingEList<Constraint>(Constraint.class,
>> this, TestingPackage.OPERATION__POSTCONDITION,
>> POSTCONDITION_ESUPERSETS, null);
>> }
>> return postconditions;
>> }
>>
>> and for Element::ownedRule it is
>>
>> public EList<Constraint> getOwnedRules() {
>> if (ownedRules == null) {
>> ownedRules = new
>> EObjectContainmentWithInverseEList<Constraint>(Constraint.class, this,
>> TestingPackage.MODEL_ELEMENT__OWNED_RULE,
>> TestingPackage.CONSTRAINT__CONTEXT);
>> }
>> return ownedRules;
>> }
>>
>> Again some perfect ideas?
>>
>> Thanks in advance
>> Timothy
>>
>> Kenn Hussey schrieb:
>>> Timothy,
>>>
>>> I wouldn't have expected to see an 'ownedElement' element in the
>>> serialization, since derived unions are, by definition read-only
>>> (hence the reason why the addition is failing upon deserialization).
>>> Did you make that feature transient in the metamodel?
>>>
>>> Kenn
>>>
>>> Timothy Marc wrote:
>>>> Hey all,
>>>>
>>>> i'm using the UML2 genmodel to generate a uml-like metamodel with
>>>> subsets and unions etc. I've rebuild the Element -> ownedComment
>>>> relationship of the UML 2.2 Superstructure (Figure 7.3). Instead of
>>>> Comment, i've sed the term Annotation. The model looks like
>>>>
>>>> Element {abstract}
>>>> +/owner 0..1 {union, read-only}
>>>> +/ownedElement * {union, read-only}
>>>>
>>>> TestingModel extends Element
>>>> + annotation * {subsets ownedElement}
>>>>
>>>> Annotation extends Element
>>>>
>>>>
>>>> When i define a simple model like the model mentioned in the
>>>> following XMI snippet
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <union:TestingModel xmi:version="2.0"
>>>> xmlns:xmi="http://www.omg.org/XMI" xmlns:union="http:///union.ecore"
>>>> ownedElement="//@annotation.0">
>>>> <annotation/>
>>>> </union:TestingModel>
>>>>
>>>> i ran allways in an exception during deserialization. I've tried
>>>> both the editor and the programmatically deserialization. Both fail
>>>> with the following exception trace. It seems, that somewhere the
>>>> DerivedEObjectEList.add() method will be called.
>>>>
>>>> org.eclipse.emf.ecore.xmi.IllegalValueException: Value
>>>> 'union.impl.AnnotationImpl@352d87' is not legal.
>>>> (platform:/resource/f/My.union, -1, -1)
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2648)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1135)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1214)
>>>>
>>>> at
>>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .endDocument(Unknown
>>>> Source)
>>>> at
>>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
>>>> Source)
>>>> at
>>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>>> Source)
>>>> at
>>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>>> Source)
>>>> at
>>>> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
>>>> Source)
>>>> at
>>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
>>>> Source)
>>>> at
>>>> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
>>>> Source)
>>>> at javax.xml.parsers.SAXParser.parse(Unknown Source)
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1445)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1241)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>>>>
>>>> at union.presentation.UnionEditor.createModel(UnionEditor.java: 950)
>>>> at
>>>> union.presentation.UnionEditor.createPages(UnionEditor.java: 1007)
>>>> at
>>>> org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:310)
>>>>
>>>> at ....
>>>>
>>>>
>>>> Caused by: java.lang.UnsupportedOperationException
>>>> at
>>>> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:278)
>>>>
>>>> at java.util.AbstractSequentialList.add(Unknown Source)
>>>> at
>>>> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:636)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1192)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2643)
>>>>
>>>> ... 58 more
>>>>
>>>>
>>>> For serialization and deserialization i'm using an
>>>> XMIBResource(Factory) created by the genmodel automatically. Please
>>>> let me know, what is going wrong in this really simple example.
>>>>
>>>> Thanks in advance
>>>> Timothy
Re: Problems with DerivedUnion during deserialization [message #627879 is a reply to message #479751] Mon, 17 August 2009 20:53 Go to previous message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
Kenn,

it's me again concerning the duplicate entry problem. As mentioned, the
XMI is correct and when i load the model prgramatically, all stuff is
correct implemented... so one question: is the default generated editor
from emf capable to handle multiple subset containment references?

To me it seems, as there are problems with subsets, when two (or more)
references from one source element point to a target element. In case of
Operation->Constraint, there are 2 references (namely preconditios and
postconditions) where the asso ends are from the same type. It seems as
if the editor can not distinguish between a preconditon or
postcondition... the XMI is:

<?xml version="1.0" encoding="UTF-8"?>
<testing:TestingModel xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:testing="http://www.fokus.fraunhofer.de/testing/testing.ecore"
xmi:id="_vbeNAItuEd6Wtdf04WDKwQ">
<packagedElement xsi:type="testing:Class"
xmi:id="_T2weUYtvEd6uo5hY0fhr5A">
<ownedOperation xmi:id="_Uv00UItvEd6uo5hY0fhr5A"
postcondition="_VXUSIItvEd6uo5hY0fhr5A">
<ownedRule xsi:type="testing:Constraint"
xmi:id="_VXUSIItvEd6uo5hY0fhr5A"/> //inserted as precondition!!!!!
</ownedOperation>
</packagedElement>
</testing:TestingModel>

/Timothy

Timothy Marc schrieb:
> Kenn,
>
> hmm... i've compared the item providers of UML2 and my model
> (OperationItemProvider). They look exactly like the same, so i really
> don't know where to apply the leverage in order to erase this
> misbehavior...
>
> All this providing stuff is still a closed book to me.
>
> Timothy
>
> Kenn Hussey schrieb:
>> Timothy,
>>
>> Yeah, we used to automatically make derived properties transient (a
>> long time ago) but we changed it because in some cases it may be
>> desirable to serialize derived properties (e.g. if a value is more
>> compact than the values it is derived from).
>>
>> Regarding the duplicate display issue, I'd suggest looking at how the
>> item providers are defined for your features. I suspect that providers
>> for two different features are displaying the value in question. In
>> this case you probably don't want the values for pre- and
>> post-conditions to appear in the content tree (since they will be
>> coerced to non-containment) but rather in the Properties view.
>>
>> Kenn
>>
>>
>> Timothy Marc wrote:
>>> Kenn,
>>>
>>> god damn, i was aware of all other derived attributes or subset, but
>>> not for the unions... is there any rationale, why derived
>>> associations or attributes are not generally set to transient=true?
>>> Because of that they are already set to volatile=true i allways
>>> forget to set them manually to transient. But, it works now. Thanks!
>>>
>>> Another point: The generated editor behaves weird for the following
>>> snippet. I defined the following (trying to approximate the ownedRule
>>> semtanics of the superstructure):
>>>
>>> #####
>>> Element {abstract}
>>> +/ownedElement * {union, read-only, containment}
>>> +/ownedRule 0..* {subsets ownedElement, containment}
>>>
>>> NamedElemet extends Element
>>>
>>> BehavioralFeature extends NamedElement
>>>
>>> Operation extends BehavioralFeature
>>> +precondition 0..* {subsets ownedRule, containment}
>>> +postcondition 0..* {subsets ownedRule, containment} #####
>>>
>>> If i add an 'ownedRule' to the operation, everything is fine. But any
>>> adding of either pre- or postcondition has the effect, that 2
>>> instances of the same constraint is displayed. Well, the XMI looks
>>> okay, IMHO:
>>>
>>> <packagedElement xsi:type="testing:Class"
>>> xmi:id="_cUg_8IXsEd6Lu8REkryexw">
>>> <ownedOperation xmi:id="_fkrwMIXsEd6Lu8REkryexw"
>>> postcondition="_gJMLcIXsEd6Lu8REkryexw">
>>> <ownedRule xmi:id="_gJMLcIXsEd6Lu8REkryexw"/>
>>> </ownedOperation>
>>> </packagedElement>
>>>
>>> The postcondition belongs both to the ownedRule containment
>>> reference, and to the postcondition reference of its context
>>> operation. In the editor, the constraint is shown twice instead of
>>> just being a single element. If i add a constraint via the ownedRule
>>> reference, only a single element is displayed.
>>>
>>> The java code for Operation::postcondition is:
>>>
>>> public EList<Constraint> getPostconditions() {
>>> if (postconditions == null) {
>>> postconditions = new
>>> SubsetSupersetEObjectResolvingEList<Constraint>(Constraint.class,
>>> this, TestingPackage.OPERATION__POSTCONDITION,
>>> POSTCONDITION_ESUPERSETS, null);
>>> }
>>> return postconditions;
>>> }
>>>
>>> and for Element::ownedRule it is
>>>
>>> public EList<Constraint> getOwnedRules() {
>>> if (ownedRules == null) {
>>> ownedRules = new
>>> EObjectContainmentWithInverseEList<Constraint>(Constraint.class,
>>> this, TestingPackage.MODEL_ELEMENT__OWNED_RULE,
>>> TestingPackage.CONSTRAINT__CONTEXT);
>>> }
>>> return ownedRules;
>>> }
>>>
>>> Again some perfect ideas?
>>>
>>> Thanks in advance
>>> Timothy
>>>
>>> Kenn Hussey schrieb:
>>>> Timothy,
>>>>
>>>> I wouldn't have expected to see an 'ownedElement' element in the
>>>> serialization, since derived unions are, by definition read-only
>>>> (hence the reason why the addition is failing upon deserialization).
>>>> Did you make that feature transient in the metamodel?
>>>>
>>>> Kenn
>>>>
>>>> Timothy Marc wrote:
>>>>> Hey all,
>>>>>
>>>>> i'm using the UML2 genmodel to generate a uml-like metamodel with
>>>>> subsets and unions etc. I've rebuild the Element -> ownedComment
>>>>> relationship of the UML 2.2 Superstructure (Figure 7.3). Instead of
>>>>> Comment, i've sed the term Annotation. The model looks like
>>>>>
>>>>> Element {abstract}
>>>>> +/owner 0..1 {union, read-only}
>>>>> +/ownedElement * {union, read-only}
>>>>>
>>>>> TestingModel extends Element
>>>>> + annotation * {subsets ownedElement}
>>>>>
>>>>> Annotation extends Element
>>>>>
>>>>>
>>>>> When i define a simple model like the model mentioned in the
>>>>> following XMI snippet
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>> <union:TestingModel xmi:version="2.0"
>>>>> xmlns:xmi="http://www.omg.org/XMI"
>>>>> xmlns:union="http:///union.ecore" ownedElement="//@annotation.0">
>>>>> <annotation/>
>>>>> </union:TestingModel>
>>>>>
>>>>> i ran allways in an exception during deserialization. I've tried
>>>>> both the editor and the programmatically deserialization. Both fail
>>>>> with the following exception trace. It seems, that somewhere the
>>>>> DerivedEObjectEList.add() method will be called.
>>>>>
>>>>> org.eclipse.emf.ecore.xmi.IllegalValueException: Value
>>>>> 'union.impl.AnnotationImpl@352d87' is not legal.
>>>>> (platform:/resource/f/My.union, -1, -1)
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2648)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1135)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1214)
>>>>>
>>>>> at
>>>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .endDocument(Unknown
>>>>> Source)
>>>>> at
>>>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
>>>>> Source)
>>>>> at
>>>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>>>> Source)
>>>>> at
>>>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>>>> Source)
>>>>> at
>>>>> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
>>>>> Source)
>>>>> at
>>>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
>>>>> Source)
>>>>> at
>>>>> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
>>>>> Source)
>>>>> at javax.xml.parsers.SAXParser.parse(Unknown Source)
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1445)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1241)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>>>>>
>>>>> at
>>>>> union.presentation.UnionEditor.createModel(UnionEditor.java: 950)
>>>>> at
>>>>> union.presentation.UnionEditor.createPages(UnionEditor.java: 1007)
>>>>> at
>>>>> org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:310)
>>>>>
>>>>> at ....
>>>>>
>>>>>
>>>>> Caused by: java.lang.UnsupportedOperationException
>>>>> at
>>>>> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:278)
>>>>>
>>>>> at java.util.AbstractSequentialList.add(Unknown Source)
>>>>> at
>>>>> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:636)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1192)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2643)
>>>>>
>>>>> ... 58 more
>>>>>
>>>>>
>>>>> For serialization and deserialization i'm using an
>>>>> XMIBResource(Factory) created by the genmodel automatically. Please
>>>>> let me know, what is going wrong in this really simple example.
>>>>>
>>>>> Thanks in advance
>>>>> Timothy
Re: Problems with DerivedUnion during deserialization [message #627933 is a reply to message #480610] Thu, 10 September 2009 16:41 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Timothy,

Something must not be right about the way the precondition feature is
defined. Both it and the postcondition features should be
non-containment subsets of the ownedRule containment feature (which, in
UML2, is inherited from NamedElement).

Regarding the item provider implementation, I would expect only the
ownedRule feature to be referenced by the getChildrenFeatures(...)
method. Is that the case?

If you're still having trouble, perhaps you could send me your Ecore and
generator models and I'll take a closer look.

Kenn

Timothy Marc wrote:
> Kenn,
>
> it's me again concerning the duplicate entry problem. As mentioned, the
> XMI is correct and when i load the model prgramatically, all stuff is
> correct implemented... so one question: is the default generated editor
> from emf capable to handle multiple subset containment references?
>
> To me it seems, as there are problems with subsets, when two (or more)
> references from one source element point to a target element. In case of
> Operation->Constraint, there are 2 references (namely preconditios and
> postconditions) where the asso ends are from the same type. It seems as
> if the editor can not distinguish between a preconditon or
> postcondition... the XMI is:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <testing:TestingModel xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:testing="http://www.fokus.fraunhofer.de/testing/testing.ecore"
> xmi:id="_vbeNAItuEd6Wtdf04WDKwQ">
> <packagedElement xsi:type="testing:Class"
> xmi:id="_T2weUYtvEd6uo5hY0fhr5A">
> <ownedOperation xmi:id="_Uv00UItvEd6uo5hY0fhr5A"
> postcondition="_VXUSIItvEd6uo5hY0fhr5A">
> <ownedRule xsi:type="testing:Constraint"
> xmi:id="_VXUSIItvEd6uo5hY0fhr5A"/> //inserted as precondition!!!!!
> </ownedOperation>
> </packagedElement>
> </testing:TestingModel>
>
> /Timothy
>
> Timothy Marc schrieb:
>> Kenn,
>>
>> hmm... i've compared the item providers of UML2 and my model
>> (OperationItemProvider). They look exactly like the same, so i really
>> don't know where to apply the leverage in order to erase this
>> misbehavior...
>>
>> All this providing stuff is still a closed book to me.
>>
>> Timothy
>>
>> Kenn Hussey schrieb:
>>> Timothy,
>>>
>>> Yeah, we used to automatically make derived properties transient (a
>>> long time ago) but we changed it because in some cases it may be
>>> desirable to serialize derived properties (e.g. if a value is more
>>> compact than the values it is derived from).
>>>
>>> Regarding the duplicate display issue, I'd suggest looking at how the
>>> item providers are defined for your features. I suspect that
>>> providers for two different features are displaying the value in
>>> question. In this case you probably don't want the values for pre-
>>> and post-conditions to appear in the content tree (since they will be
>>> coerced to non-containment) but rather in the Properties view.
>>>
>>> Kenn
>>>
>>>
>>> Timothy Marc wrote:
>>>> Kenn,
>>>>
>>>> god damn, i was aware of all other derived attributes or subset, but
>>>> not for the unions... is there any rationale, why derived
>>>> associations or attributes are not generally set to transient=true?
>>>> Because of that they are already set to volatile=true i allways
>>>> forget to set them manually to transient. But, it works now. Thanks!
>>>>
>>>> Another point: The generated editor behaves weird for the following
>>>> snippet. I defined the following (trying to approximate the
>>>> ownedRule semtanics of the superstructure):
>>>>
>>>> #####
>>>> Element {abstract}
>>>> +/ownedElement * {union, read-only, containment}
>>>> +/ownedRule 0..* {subsets ownedElement, containment}
>>>>
>>>> NamedElemet extends Element
>>>>
>>>> BehavioralFeature extends NamedElement
>>>>
>>>> Operation extends BehavioralFeature
>>>> +precondition 0..* {subsets ownedRule, containment}
>>>> +postcondition 0..* {subsets ownedRule, containment} #####
>>>>
>>>> If i add an 'ownedRule' to the operation, everything is fine. But
>>>> any adding of either pre- or postcondition has the effect, that 2
>>>> instances of the same constraint is displayed. Well, the XMI looks
>>>> okay, IMHO:
>>>>
>>>> <packagedElement xsi:type="testing:Class"
>>>> xmi:id="_cUg_8IXsEd6Lu8REkryexw">
>>>> <ownedOperation xmi:id="_fkrwMIXsEd6Lu8REkryexw"
>>>> postcondition="_gJMLcIXsEd6Lu8REkryexw">
>>>> <ownedRule xmi:id="_gJMLcIXsEd6Lu8REkryexw"/>
>>>> </ownedOperation>
>>>> </packagedElement>
>>>>
>>>> The postcondition belongs both to the ownedRule containment
>>>> reference, and to the postcondition reference of its context
>>>> operation. In the editor, the constraint is shown twice instead of
>>>> just being a single element. If i add a constraint via the ownedRule
>>>> reference, only a single element is displayed.
>>>>
>>>> The java code for Operation::postcondition is:
>>>>
>>>> public EList<Constraint> getPostconditions() {
>>>> if (postconditions == null) {
>>>> postconditions = new
>>>> SubsetSupersetEObjectResolvingEList<Constraint>(Constraint.class,
>>>> this, TestingPackage.OPERATION__POSTCONDITION,
>>>> POSTCONDITION_ESUPERSETS, null);
>>>> }
>>>> return postconditions;
>>>> }
>>>>
>>>> and for Element::ownedRule it is
>>>>
>>>> public EList<Constraint> getOwnedRules() {
>>>> if (ownedRules == null) {
>>>> ownedRules = new
>>>> EObjectContainmentWithInverseEList<Constraint>(Constraint.class,
>>>> this, TestingPackage.MODEL_ELEMENT__OWNED_RULE,
>>>> TestingPackage.CONSTRAINT__CONTEXT);
>>>> }
>>>> return ownedRules;
>>>> }
>>>>
>>>> Again some perfect ideas?
>>>>
>>>> Thanks in advance
>>>> Timothy
>>>>
>>>> Kenn Hussey schrieb:
>>>>> Timothy,
>>>>>
>>>>> I wouldn't have expected to see an 'ownedElement' element in the
>>>>> serialization, since derived unions are, by definition read-only
>>>>> (hence the reason why the addition is failing upon
>>>>> deserialization). Did you make that feature transient in the
>>>>> metamodel?
>>>>>
>>>>> Kenn
>>>>>
>>>>> Timothy Marc wrote:
>>>>>> Hey all,
>>>>>>
>>>>>> i'm using the UML2 genmodel to generate a uml-like metamodel with
>>>>>> subsets and unions etc. I've rebuild the Element -> ownedComment
>>>>>> relationship of the UML 2.2 Superstructure (Figure 7.3). Instead
>>>>>> of Comment, i've sed the term Annotation. The model looks like
>>>>>>
>>>>>> Element {abstract}
>>>>>> +/owner 0..1 {union, read-only}
>>>>>> +/ownedElement * {union, read-only}
>>>>>>
>>>>>> TestingModel extends Element
>>>>>> + annotation * {subsets ownedElement}
>>>>>>
>>>>>> Annotation extends Element
>>>>>>
>>>>>>
>>>>>> When i define a simple model like the model mentioned in the
>>>>>> following XMI snippet
>>>>>>
>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>> <union:TestingModel xmi:version="2.0"
>>>>>> xmlns:xmi="http://www.omg.org/XMI"
>>>>>> xmlns:union="http:///union.ecore" ownedElement="//@annotation.0">
>>>>>> <annotation/>
>>>>>> </union:TestingModel>
>>>>>>
>>>>>> i ran allways in an exception during deserialization. I've tried
>>>>>> both the editor and the programmatically deserialization. Both
>>>>>> fail with the following exception trace. It seems, that somewhere
>>>>>> the DerivedEObjectEList.add() method will be called.
>>>>>>
>>>>>> org.eclipse.emf.ecore.xmi.IllegalValueException: Value
>>>>>> 'union.impl.AnnotationImpl@352d87' is not legal.
>>>>>> (platform:/resource/f/My.union, -1, -1)
>>>>>> at
>>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2648)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1135)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1214)
>>>>>>
>>>>>> at
>>>>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .endDocument(Unknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
>>>>>> Source)
>>>>>> at
>>>>>> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
>>>>>> Source)
>>>>>> at javax.xml.parsers.SAXParser.parse(Unknown Source)
>>>>>> at
>>>>>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
>>>>>> at
>>>>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1445)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1241)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>>>>>>
>>>>>> at
>>>>>> union.presentation.UnionEditor.createModel(UnionEditor.java: 950)
>>>>>> at
>>>>>> union.presentation.UnionEditor.createPages(UnionEditor.java: 1007)
>>>>>> at
>>>>>> org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:310)
>>>>>>
>>>>>> at ....
>>>>>>
>>>>>>
>>>>>> Caused by: java.lang.UnsupportedOperationException
>>>>>> at
>>>>>> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:278)
>>>>>>
>>>>>> at java.util.AbstractSequentialList.add(Unknown Source)
>>>>>> at
>>>>>> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:636)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1192)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2643)
>>>>>>
>>>>>> ... 58 more
>>>>>>
>>>>>>
>>>>>> For serialization and deserialization i'm using an
>>>>>> XMIBResource(Factory) created by the genmodel automatically.
>>>>>> Please let me know, what is going wrong in this really simple
>>>>>> example.
>>>>>>
>>>>>> Thanks in advance
>>>>>> Timothy
Previous Topic:How to load MagicDraw .uml file?
Next Topic:UML2Ecore convertion
Goto Forum:
  


Current Time: Thu Apr 25 06:05:41 GMT 2024

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

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

Back to the top