[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.mdt.uml2] Re: Problems with DerivedUnion during deserialization

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(XMLHandler.java:2648)


at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardReferences(XMLHandler.java:1135)

at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHandler.java:1214)

at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.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(XMLResourceImpl.java:180)


at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1445)

at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1241)

at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:255)

at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:270)

at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(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(MultiPageEditorPart.java:310)


    at ....


Caused by: java.lang.UnsupportedOperationException
at org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedListIterator.add(DerivedEObjectEList.java:278)


at java.util.AbstractSequentialList.add(Unknown Source)
at org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(DerivedEObjectEList.java:636)


at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1192)

at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.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