[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

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(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