Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Adding to DerivedEObjectEList gives UnsupportedOperationException, apparently new since EMF 2.3
Adding to DerivedEObjectEList gives UnsupportedOperationException, apparently new since EMF 2.3 [message #471146] Mon, 26 February 2007 10:09 Go to next message
JG is currently offline JG
Messages: 51
Registered: July 2009
Member
Hi,

I am using the UML2 DerivedEObjectEList to manually implement some of my
model's associations as being derived from others. So far I was quite
happy with the result. When I first tried this class, I made some test
code, adding something through either association end of both the
derived association as well as the basic association from which I derive.
Now all out of sudden I receive an UnsupportedOperationException when I
try to add something to the derived list.

I am using UML 2.1M4 with EMF 2.3.0M4.

The stack trace looks like this:


Exception in thread "main" java.lang.UnsupportedOperationException
at
org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:274)
at java.util.AbstractSequentialList.add(Unknown Source)
at
org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:656)
at
org.eclipse.uml2.common.util.DerivedEObjectEList.add(Derived EObjectEList.java:640)
at java.util.AbstractList.add(Unknown Source)
at
paladin.util.emf.EMFSQLHelper.attachUniqueConstraintToTable( EMFSQLHelper.java:126)

The last line is the method where I call add.

I am positive that I used add on derived lists before successfully, but
I think this was before I migrated to EMF 2.3 /UML 2.1 Could this be
the problem? Or anything else I am missing here?


Regards

JG
Re: Adding to DerivedEObjectEList gives UnsupportedOperationException, apparently new since EMF 2.3 [message #471148 is a reply to message #471146] Mon, 26 February 2007 14:42 Go to previous messageGo to next message
james bruck is currently offline james bruck
Messages: 1724
Registered: July 2009
Senior Member
Hi JG,

You cannot add items directly to derived lists. Derived lists obtain their
content based on other information ( i.e. .. content is derived from other
lists ).
If you want to populate your derived list, you need to add your items to the
lists that are being derived from.

Have a look at the draft versions of extending UML articles found here for
other details...
https://bugs.eclipse.org/bugs/show_bug.cgi?id=77413

Regards,

- James.

"JG" <jguni@gmx.de> wrote in message news:erubkg$2cn$6@utils.eclipse.org...
> Hi,
>
> I am using the UML2 DerivedEObjectEList to manually implement some of my
> model's associations as being derived from others. So far I was quite
> happy with the result. When I first tried this class, I made some test
> code, adding something through either association end of both the
> derived association as well as the basic association from which I derive.
> Now all out of sudden I receive an UnsupportedOperationException when I
> try to add something to the derived list.
>
> I am using UML 2.1M4 with EMF 2.3.0M4.
>
> The stack trace looks like this:
>
>
> Exception in thread "main" java.lang.UnsupportedOperationException
> at
>
org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(Der
ivedEObjectEList.java:274)
> at java.util.AbstractSequentialList.add(Unknown Source)
> at
>
org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectELi
st.java:656)
> at
>
org.eclipse.uml2.common.util.DerivedEObjectEList.add(Derived EObjectEList.jav
a:640)
> at java.util.AbstractList.add(Unknown Source)
> at
>
paladin.util.emf.EMFSQLHelper.attachUniqueConstraintToTable( EMFSQLHelper.jav
a:126)
>
> The last line is the method where I call add.
>
> I am positive that I used add on derived lists before successfully, but
> I think this was before I migrated to EMF 2.3 /UML 2.1 Could this be
> the problem? Or anything else I am missing here?
>
>
> Regards
>
> JG
>
>
Re: Adding to DerivedEObjectEList gives UnsupportedOperationException, apparently new since EMF 2.3 [message #471153 is a reply to message #471146] Mon, 26 February 2007 14:31 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn Hussey
Messages: 1618
Registered: July 2009
Senior Member
JG,

Modifications have never been permitted on a DerivedEObjectEList - they're
only permitted for instances if its subclass, DerivedSubsetEObjectEList. Are
you using DerivedSubsetEObjectEList? The UML API uses this modifiable
version of the list in a few places, and I'm not seeing any exceptions when
I add to those lists...

Kenn

"JG" <jguni@gmx.de> wrote in message news:erubkg$2cn$6@utils.eclipse.org...
> Hi,
>
> I am using the UML2 DerivedEObjectEList to manually implement some of my
> model's associations as being derived from others. So far I was quite
> happy with the result. When I first tried this class, I made some test
> code, adding something through either association end of both the
> derived association as well as the basic association from which I derive.
> Now all out of sudden I receive an UnsupportedOperationException when I
> try to add something to the derived list.
>
> I am using UML 2.1M4 with EMF 2.3.0M4.
>
> The stack trace looks like this:
>
>
> Exception in thread "main" java.lang.UnsupportedOperationException
> at
> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:274)
> at java.util.AbstractSequentialList.add(Unknown Source)
> at
> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:656)
> at
> org.eclipse.uml2.common.util.DerivedEObjectEList.add(Derived EObjectEList.java:640)
> at java.util.AbstractList.add(Unknown Source)
> at
> paladin.util.emf.EMFSQLHelper.attachUniqueConstraintToTable( EMFSQLHelper.java:126)
>
> The last line is the method where I call add.
>
> I am positive that I used add on derived lists before successfully, but
> I think this was before I migrated to EMF 2.3 /UML 2.1 Could this be
> the problem? Or anything else I am missing here?
>
>
> Regards
>
> JG
>
>
Re: Adding to DerivedEObjectEList gives UnsupportedOperationException, apparently new since EMF 2.3 [message #471166 is a reply to message #471153] Wed, 28 February 2007 06:44 Go to previous messageGo to next message
JG is currently offline JG
Messages: 51
Registered: July 2009
Member
Kenn,

Kenn Hussey wrote:
> JG,
>
> Modifications have never been permitted on a DerivedEObjectEList - they're
> only permitted for instances if its subclass, DerivedSubsetEObjectEList. Are
> you using DerivedSubsetEObjectEList? The UML API uses this modifiable
> version of the list in a few places, and I'm not seeing any exceptions when
> I add to those lists...

Thanks Kenn, that explains it. Apparently I had been using the
DerivedSubsetEObjectEList previously. I remember wondering once what the
difference between the two was and decided to go with the
DerivedEObjectEList. I forgot about that, and a month later I got that
exception.

A request: Perhaps the Javadoc of the add methods of DerivedEObjectEList
and UML2 javadocs in general (I have seen the Bugzilla James Bruck
pointed out) should be updated. Of all the classes I used directly in
UML2, there was almost no single Javadoc comment that explained the
purpose of the class (especially the differences between the zillions of
differnt EList implementations) and how it is to be used.
Regarding the DerivedEObjectEList : Maybe its add() should throw an
"UnsupportedOperationException", this would stop people wondering that
fell for this trap.

So let me sum up my understanding of the DerivedSubsetEList:
I specify an int[] with the feature IDs of the source features, which,
naturally, have to be (inherited) features of the class where the
derived reference is being implemented. All those values of these
features that are an instance of the dataClass given as parameter will
show up in the DerivedSubsetEList. Is this correct? Can I actually
specify more than one feature in the sourceFeatureIDs int[]? If I can,
why would I still need the DerivedUnionEList (since I could just set the
dataClass to object if I do not want to narrow the derived reference)?
If I can't why, does the signature of the DerivedSubsetEList suggest
that I can, by accepting an int[] instead of an int?
Maybe the Javadoc should provide an example of each List's use, in
conjunction with the respective UML concept that can be implemented with
its use.


And a question: I am using Rational Rose to build my model and generate
an EMF model from it. Currently I am implementing the derived
relationships using the UML2 DerivedLists by hand, and I am sure I
messed it up pretty good in more than one place (I am still not very
acustomed to the inner workings of every aspect of the generated
classes, like when there is a basicSetXY method and how I should
override it if I want to make the association derived).
Is there any way to actually specify the derivation in a modeling tool
and have it generated for me? Can I use Rose annotations in conjunction
with the "derived" flag? What about IBM Rational Software Modeler?

Regards

JG

>
> Kenn
>
> "JG" <jguni@gmx.de> wrote in message news:erubkg$2cn$6@utils.eclipse.org...
>> Hi,
>>
>> I am using the UML2 DerivedEObjectEList to manually implement some of my
>> model's associations as being derived from others. So far I was quite
>> happy with the result. When I first tried this class, I made some test
>> code, adding something through either association end of both the
>> derived association as well as the basic association from which I derive.
>> Now all out of sudden I receive an UnsupportedOperationException when I
>> try to add something to the derived list.
>>
>> I am using UML 2.1M4 with EMF 2.3.0M4.
>>
>> The stack trace looks like this:
>>
>>
>> Exception in thread "main" java.lang.UnsupportedOperationException
>> at
>> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:274)
>> at java.util.AbstractSequentialList.add(Unknown Source)
>> at
>> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:656)
>> at
>> org.eclipse.uml2.common.util.DerivedEObjectEList.add(Derived EObjectEList.java:640)
>> at java.util.AbstractList.add(Unknown Source)
>> at
>> paladin.util.emf.EMFSQLHelper.attachUniqueConstraintToTable( EMFSQLHelper.java:126)
>>
>> The last line is the method where I call add.
>>
>> I am positive that I used add on derived lists before successfully, but
>> I think this was before I migrated to EMF 2.3 /UML 2.1 Could this be
>> the problem? Or anything else I am missing here?
>>
>>
>> Regards
>>
>> JG
>>
>>
>
>
Re: Adding to DerivedEObjectEList gives UnsupportedOperationException, apparently new since EMF 2.3 [message #471174 is a reply to message #471166] Wed, 28 February 2007 14:52 Go to previous message
Kenn Hussey is currently offline Kenn Hussey
Messages: 1618
Registered: July 2009
Senior Member
JG,

Agreed, the documentation could be MUCH better; contributions are always
welcome. :)

Please consider adding a comment to
https://bugs.eclipse.org/bugs/show_bug.cgi?id=77413 to ensure that we make
Javadoc for the classes in org.eclipse.uml2.common a priority for this
release.

Yes, DerivedSubsetEObjectELists are only practical for use with one superset
feature; the API should have enforced this. Perhaps what we should do is add
another constructor that takes a single superset feature identifier and add
a guard to the existing constructor to throw an exception if more than one
identifier is specified - would you like to open a Bugzilla report for this?

Currently, the only kind of derivation that can be generated automatically
is for derived unions, because the algoritihm for which elements to include
is based directly on the model structure (i.e. include everything in the
subsets); with derived subsets, the algorithm is not always
straight-forward. We've considered adding support for generating code when
the subset is to be computed by type alone, but have yet to come up with a
good way to describe this in UML, and since only a few such subsets exist in
UML itself, it wasn't a high priority. If you'd like us to give this more
consideration, feel free to open an enhancement request and we'll see what
we can do.

Marking a feature as volatile (most, if not all, derived features are
volatile) should give you a hint as to which methods need to be implemented
by hand - the code generator will generate a stub method that throws an
exception unless you override and implement it...

Kenn

"JG" <jguni@gmx.de> wrote in message news:es38cf$rtv$1@utils.eclipse.org...
> Kenn,
>
> Kenn Hussey wrote:
>> JG,
>>
>> Modifications have never been permitted on a DerivedEObjectEList -
>> they're
>> only permitted for instances if its subclass, DerivedSubsetEObjectEList.
>> Are
>> you using DerivedSubsetEObjectEList? The UML API uses this modifiable
>> version of the list in a few places, and I'm not seeing any exceptions
>> when
>> I add to those lists...
>
> Thanks Kenn, that explains it. Apparently I had been using the
> DerivedSubsetEObjectEList previously. I remember wondering once what the
> difference between the two was and decided to go with the
> DerivedEObjectEList. I forgot about that, and a month later I got that
> exception.
>
> A request: Perhaps the Javadoc of the add methods of DerivedEObjectEList
> and UML2 javadocs in general (I have seen the Bugzilla James Bruck
> pointed out) should be updated. Of all the classes I used directly in
> UML2, there was almost no single Javadoc comment that explained the
> purpose of the class (especially the differences between the zillions of
> differnt EList implementations) and how it is to be used.
> Regarding the DerivedEObjectEList : Maybe its add() should throw an
> "UnsupportedOperationException", this would stop people wondering that
> fell for this trap.
>
> So let me sum up my understanding of the DerivedSubsetEList:
> I specify an int[] with the feature IDs of the source features, which,
> naturally, have to be (inherited) features of the class where the
> derived reference is being implemented. All those values of these
> features that are an instance of the dataClass given as parameter will
> show up in the DerivedSubsetEList. Is this correct? Can I actually
> specify more than one feature in the sourceFeatureIDs int[]? If I can,
> why would I still need the DerivedUnionEList (since I could just set the
> dataClass to object if I do not want to narrow the derived reference)?
> If I can't why, does the signature of the DerivedSubsetEList suggest
> that I can, by accepting an int[] instead of an int?
> Maybe the Javadoc should provide an example of each List's use, in
> conjunction with the respective UML concept that can be implemented with
> its use.
>
>
> And a question: I am using Rational Rose to build my model and generate
> an EMF model from it. Currently I am implementing the derived
> relationships using the UML2 DerivedLists by hand, and I am sure I
> messed it up pretty good in more than one place (I am still not very
> acustomed to the inner workings of every aspect of the generated
> classes, like when there is a basicSetXY method and how I should
> override it if I want to make the association derived).
> Is there any way to actually specify the derivation in a modeling tool
> and have it generated for me? Can I use Rose annotations in conjunction
> with the "derived" flag? What about IBM Rational Software Modeler?
>
> Regards
>
> JG
>
>>
>> Kenn
>>
>> "JG" <jguni@gmx.de> wrote in message
>> news:erubkg$2cn$6@utils.eclipse.org...
>>> Hi,
>>>
>>> I am using the UML2 DerivedEObjectEList to manually implement some of my
>>> model's associations as being derived from others. So far I was quite
>>> happy with the result. When I first tried this class, I made some test
>>> code, adding something through either association end of both the
>>> derived association as well as the basic association from which I
>>> derive.
>>> Now all out of sudden I receive an UnsupportedOperationException when I
>>> try to add something to the derived list.
>>>
>>> I am using UML 2.1M4 with EMF 2.3.0M4.
>>>
>>> The stack trace looks like this:
>>>
>>>
>>> Exception in thread "main" java.lang.UnsupportedOperationException
>>> at
>>> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:274)
>>> at java.util.AbstractSequentialList.add(Unknown Source)
>>> at
>>> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:656)
>>> at
>>> org.eclipse.uml2.common.util.DerivedEObjectEList.add(Derived EObjectEList.java:640)
>>> at java.util.AbstractList.add(Unknown Source)
>>> at
>>> paladin.util.emf.EMFSQLHelper.attachUniqueConstraintToTable( EMFSQLHelper.java:126)
>>>
>>> The last line is the method where I call add.
>>>
>>> I am positive that I used add on derived lists before successfully, but
>>> I think this was before I migrated to EMF 2.3 /UML 2.1 Could this be
>>> the problem? Or anything else I am missing here?
>>>
>>>
>>> Regards
>>>
>>> JG
>>>
>>>
>>
>>
Re: Adding to DerivedEObjectEList gives UnsupportedOperationException, apparently new since EMF 2.3 [message #590745 is a reply to message #471146] Mon, 26 February 2007 14:42 Go to previous message
james bruck is currently offline james bruck
Messages: 1724
Registered: July 2009
Senior Member
Hi JG,

You cannot add items directly to derived lists. Derived lists obtain their
content based on other information ( i.e. .. content is derived from other
lists ).
If you want to populate your derived list, you need to add your items to the
lists that are being derived from.

Have a look at the draft versions of extending UML articles found here for
other details...
https://bugs.eclipse.org/bugs/show_bug.cgi?id=77413

Regards,

- James.

"JG" <jguni@gmx.de> wrote in message news:erubkg$2cn$6@utils.eclipse.org...
> Hi,
>
> I am using the UML2 DerivedEObjectEList to manually implement some of my
> model's associations as being derived from others. So far I was quite
> happy with the result. When I first tried this class, I made some test
> code, adding something through either association end of both the
> derived association as well as the basic association from which I derive.
> Now all out of sudden I receive an UnsupportedOperationException when I
> try to add something to the derived list.
>
> I am using UML 2.1M4 with EMF 2.3.0M4.
>
> The stack trace looks like this:
>
>
> Exception in thread "main" java.lang.UnsupportedOperationException
> at
>
org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(Der
ivedEObjectEList.java:274)
> at java.util.AbstractSequentialList.add(Unknown Source)
> at
>
org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectELi
st.java:656)
> at
>
org.eclipse.uml2.common.util.DerivedEObjectEList.add(Derived EObjectEList.jav
a:640)
> at java.util.AbstractList.add(Unknown Source)
> at
>
paladin.util.emf.EMFSQLHelper.attachUniqueConstraintToTable( EMFSQLHelper.jav
a:126)
>
> The last line is the method where I call add.
>
> I am positive that I used add on derived lists before successfully, but
> I think this was before I migrated to EMF 2.3 /UML 2.1 Could this be
> the problem? Or anything else I am missing here?
>
>
> Regards
>
> JG
>
>
Re: Adding to DerivedEObjectEList gives UnsupportedOperationException, apparently new since EMF 2.3 [message #593839 is a reply to message #471146] Mon, 26 February 2007 14:31 Go to previous message
Kenn Hussey is currently offline Kenn Hussey
Messages: 1618
Registered: July 2009
Senior Member
JG,

Modifications have never been permitted on a DerivedEObjectEList - they're
only permitted for instances if its subclass, DerivedSubsetEObjectEList. Are
you using DerivedSubsetEObjectEList? The UML API uses this modifiable
version of the list in a few places, and I'm not seeing any exceptions when
I add to those lists...

Kenn

"JG" <jguni@gmx.de> wrote in message news:erubkg$2cn$6@utils.eclipse.org...
> Hi,
>
> I am using the UML2 DerivedEObjectEList to manually implement some of my
> model's associations as being derived from others. So far I was quite
> happy with the result. When I first tried this class, I made some test
> code, adding something through either association end of both the
> derived association as well as the basic association from which I derive.
> Now all out of sudden I receive an UnsupportedOperationException when I
> try to add something to the derived list.
>
> I am using UML 2.1M4 with EMF 2.3.0M4.
>
> The stack trace looks like this:
>
>
> Exception in thread "main" java.lang.UnsupportedOperationException
> at
> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:274)
> at java.util.AbstractSequentialList.add(Unknown Source)
> at
> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:656)
> at
> org.eclipse.uml2.common.util.DerivedEObjectEList.add(Derived EObjectEList.java:640)
> at java.util.AbstractList.add(Unknown Source)
> at
> paladin.util.emf.EMFSQLHelper.attachUniqueConstraintToTable( EMFSQLHelper.java:126)
>
> The last line is the method where I call add.
>
> I am positive that I used add on derived lists before successfully, but
> I think this was before I migrated to EMF 2.3 /UML 2.1 Could this be
> the problem? Or anything else I am missing here?
>
>
> Regards
>
> JG
>
>
Re: Adding to DerivedEObjectEList gives UnsupportedOperationException, apparently new since EMF 2.3 [message #593921 is a reply to message #471153] Wed, 28 February 2007 06:44 Go to previous message
JG is currently offline JG
Messages: 51
Registered: July 2009
Member
Kenn,

Kenn Hussey wrote:
> JG,
>
> Modifications have never been permitted on a DerivedEObjectEList - they're
> only permitted for instances if its subclass, DerivedSubsetEObjectEList. Are
> you using DerivedSubsetEObjectEList? The UML API uses this modifiable
> version of the list in a few places, and I'm not seeing any exceptions when
> I add to those lists...

Thanks Kenn, that explains it. Apparently I had been using the
DerivedSubsetEObjectEList previously. I remember wondering once what the
difference between the two was and decided to go with the
DerivedEObjectEList. I forgot about that, and a month later I got that
exception.

A request: Perhaps the Javadoc of the add methods of DerivedEObjectEList
and UML2 javadocs in general (I have seen the Bugzilla James Bruck
pointed out) should be updated. Of all the classes I used directly in
UML2, there was almost no single Javadoc comment that explained the
purpose of the class (especially the differences between the zillions of
differnt EList implementations) and how it is to be used.
Regarding the DerivedEObjectEList : Maybe its add() should throw an
"UnsupportedOperationException", this would stop people wondering that
fell for this trap.

So let me sum up my understanding of the DerivedSubsetEList:
I specify an int[] with the feature IDs of the source features, which,
naturally, have to be (inherited) features of the class where the
derived reference is being implemented. All those values of these
features that are an instance of the dataClass given as parameter will
show up in the DerivedSubsetEList. Is this correct? Can I actually
specify more than one feature in the sourceFeatureIDs int[]? If I can,
why would I still need the DerivedUnionEList (since I could just set the
dataClass to object if I do not want to narrow the derived reference)?
If I can't why, does the signature of the DerivedSubsetEList suggest
that I can, by accepting an int[] instead of an int?
Maybe the Javadoc should provide an example of each List's use, in
conjunction with the respective UML concept that can be implemented with
its use.


And a question: I am using Rational Rose to build my model and generate
an EMF model from it. Currently I am implementing the derived
relationships using the UML2 DerivedLists by hand, and I am sure I
messed it up pretty good in more than one place (I am still not very
acustomed to the inner workings of every aspect of the generated
classes, like when there is a basicSetXY method and how I should
override it if I want to make the association derived).
Is there any way to actually specify the derivation in a modeling tool
and have it generated for me? Can I use Rose annotations in conjunction
with the "derived" flag? What about IBM Rational Software Modeler?

Regards

JG

>
> Kenn
>
> "JG" <jguni@gmx.de> wrote in message news:erubkg$2cn$6@utils.eclipse.org...
>> Hi,
>>
>> I am using the UML2 DerivedEObjectEList to manually implement some of my
>> model's associations as being derived from others. So far I was quite
>> happy with the result. When I first tried this class, I made some test
>> code, adding something through either association end of both the
>> derived association as well as the basic association from which I derive.
>> Now all out of sudden I receive an UnsupportedOperationException when I
>> try to add something to the derived list.
>>
>> I am using UML 2.1M4 with EMF 2.3.0M4.
>>
>> The stack trace looks like this:
>>
>>
>> Exception in thread "main" java.lang.UnsupportedOperationException
>> at
>> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:274)
>> at java.util.AbstractSequentialList.add(Unknown Source)
>> at
>> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:656)
>> at
>> org.eclipse.uml2.common.util.DerivedEObjectEList.add(Derived EObjectEList.java:640)
>> at java.util.AbstractList.add(Unknown Source)
>> at
>> paladin.util.emf.EMFSQLHelper.attachUniqueConstraintToTable( EMFSQLHelper.java:126)
>>
>> The last line is the method where I call add.
>>
>> I am positive that I used add on derived lists before successfully, but
>> I think this was before I migrated to EMF 2.3 /UML 2.1 Could this be
>> the problem? Or anything else I am missing here?
>>
>>
>> Regards
>>
>> JG
>>
>>
>
>
Re: Adding to DerivedEObjectEList gives UnsupportedOperationException, apparently new since EMF 2.3 [message #593955 is a reply to message #471166] Wed, 28 February 2007 14:52 Go to previous message
Kenn Hussey is currently offline Kenn Hussey
Messages: 1618
Registered: July 2009
Senior Member
JG,

Agreed, the documentation could be MUCH better; contributions are always
welcome. :)

Please consider adding a comment to
https://bugs.eclipse.org/bugs/show_bug.cgi?id=77413 to ensure that we make
Javadoc for the classes in org.eclipse.uml2.common a priority for this
release.

Yes, DerivedSubsetEObjectELists are only practical for use with one superset
feature; the API should have enforced this. Perhaps what we should do is add
another constructor that takes a single superset feature identifier and add
a guard to the existing constructor to throw an exception if more than one
identifier is specified - would you like to open a Bugzilla report for this?

Currently, the only kind of derivation that can be generated automatically
is for derived unions, because the algoritihm for which elements to include
is based directly on the model structure (i.e. include everything in the
subsets); with derived subsets, the algorithm is not always
straight-forward. We've considered adding support for generating code when
the subset is to be computed by type alone, but have yet to come up with a
good way to describe this in UML, and since only a few such subsets exist in
UML itself, it wasn't a high priority. If you'd like us to give this more
consideration, feel free to open an enhancement request and we'll see what
we can do.

Marking a feature as volatile (most, if not all, derived features are
volatile) should give you a hint as to which methods need to be implemented
by hand - the code generator will generate a stub method that throws an
exception unless you override and implement it...

Kenn

"JG" <jguni@gmx.de> wrote in message news:es38cf$rtv$1@utils.eclipse.org...
> Kenn,
>
> Kenn Hussey wrote:
>> JG,
>>
>> Modifications have never been permitted on a DerivedEObjectEList -
>> they're
>> only permitted for instances if its subclass, DerivedSubsetEObjectEList.
>> Are
>> you using DerivedSubsetEObjectEList? The UML API uses this modifiable
>> version of the list in a few places, and I'm not seeing any exceptions
>> when
>> I add to those lists...
>
> Thanks Kenn, that explains it. Apparently I had been using the
> DerivedSubsetEObjectEList previously. I remember wondering once what the
> difference between the two was and decided to go with the
> DerivedEObjectEList. I forgot about that, and a month later I got that
> exception.
>
> A request: Perhaps the Javadoc of the add methods of DerivedEObjectEList
> and UML2 javadocs in general (I have seen the Bugzilla James Bruck
> pointed out) should be updated. Of all the classes I used directly in
> UML2, there was almost no single Javadoc comment that explained the
> purpose of the class (especially the differences between the zillions of
> differnt EList implementations) and how it is to be used.
> Regarding the DerivedEObjectEList : Maybe its add() should throw an
> "UnsupportedOperationException", this would stop people wondering that
> fell for this trap.
>
> So let me sum up my understanding of the DerivedSubsetEList:
> I specify an int[] with the feature IDs of the source features, which,
> naturally, have to be (inherited) features of the class where the
> derived reference is being implemented. All those values of these
> features that are an instance of the dataClass given as parameter will
> show up in the DerivedSubsetEList. Is this correct? Can I actually
> specify more than one feature in the sourceFeatureIDs int[]? If I can,
> why would I still need the DerivedUnionEList (since I could just set the
> dataClass to object if I do not want to narrow the derived reference)?
> If I can't why, does the signature of the DerivedSubsetEList suggest
> that I can, by accepting an int[] instead of an int?
> Maybe the Javadoc should provide an example of each List's use, in
> conjunction with the respective UML concept that can be implemented with
> its use.
>
>
> And a question: I am using Rational Rose to build my model and generate
> an EMF model from it. Currently I am implementing the derived
> relationships using the UML2 DerivedLists by hand, and I am sure I
> messed it up pretty good in more than one place (I am still not very
> acustomed to the inner workings of every aspect of the generated
> classes, like when there is a basicSetXY method and how I should
> override it if I want to make the association derived).
> Is there any way to actually specify the derivation in a modeling tool
> and have it generated for me? Can I use Rose annotations in conjunction
> with the "derived" flag? What about IBM Rational Software Modeler?
>
> Regards
>
> JG
>
>>
>> Kenn
>>
>> "JG" <jguni@gmx.de> wrote in message
>> news:erubkg$2cn$6@utils.eclipse.org...
>>> Hi,
>>>
>>> I am using the UML2 DerivedEObjectEList to manually implement some of my
>>> model's associations as being derived from others. So far I was quite
>>> happy with the result. When I first tried this class, I made some test
>>> code, adding something through either association end of both the
>>> derived association as well as the basic association from which I
>>> derive.
>>> Now all out of sudden I receive an UnsupportedOperationException when I
>>> try to add something to the derived list.
>>>
>>> I am using UML 2.1M4 with EMF 2.3.0M4.
>>>
>>> The stack trace looks like this:
>>>
>>>
>>> Exception in thread "main" java.lang.UnsupportedOperationException
>>> at
>>> org.eclipse.uml2.common.util.DerivedEObjectEList$DerivedList Iterator.add(DerivedEObjectEList.java:274)
>>> at java.util.AbstractSequentialList.add(Unknown Source)
>>> at
>>> org.eclipse.uml2.common.util.DerivedEObjectEList.addUnique(D erivedEObjectEList.java:656)
>>> at
>>> org.eclipse.uml2.common.util.DerivedEObjectEList.add(Derived EObjectEList.java:640)
>>> at java.util.AbstractList.add(Unknown Source)
>>> at
>>> paladin.util.emf.EMFSQLHelper.attachUniqueConstraintToTable( EMFSQLHelper.java:126)
>>>
>>> The last line is the method where I call add.
>>>
>>> I am positive that I used add on derived lists before successfully, but
>>> I think this was before I migrated to EMF 2.3 /UML 2.1 Could this be
>>> the problem? Or anything else I am missing here?
>>>
>>>
>>> Regards
>>>
>>> JG
>>>
>>>
>>
>>
Previous Topic:Navigability, ends owned by Association, how to relate ends and associated elements
Next Topic:Unable to read profile or model file programatically
Goto Forum:
  


Current Time: Sat Sep 20 10:15:03 GMT 2014

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

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