file [UPDATE, FIXED]UnsupportedOpertationException

6 years 3 months ago - 6 years 3 months ago #4183 by deankramer99
Dear forum,
I have a module which was originally developed for 3.3. I have since migrated to 3.5 with the relevant changes to get it to compile and import, however there are now broken parts of my module.

For a start (and for this discussion) is my associations. In my models I have 3 different type of elements (ContextSource, ContextRule, and ContextState). All three extend Class type in terms of a model. The diagram extends StaticDiagram.

When we want to association (draw a line) between the different elements, I use a UMLAssociation, which is created in a DefaultLinkTool class (attached to the palette). This should link the different elements together. While everything seemed to be working before, I now seem to be finding the following exception being thrown:
ERROR o.m.api.impl     - 'Every: 
For: '{d3bd900a-20ce-4962-aa11-95a3a10744c7} Association: Can only add newly added objects.
java.lang.UnsupportedOperationException: 'Every: 
For: '{d3bd900a-20ce-4962-aa11-95a3a10744c7} Association: Can only add newly added objects.
	at org.modelio.vcore.session.impl.CoreSession$ScratchRepository.attach(

Without putting the whole code (which has a few things that I do not think are relevant or helpful in people being able to understand my code),

I firstly get the source and destination elements with:
Classifier c_source = (Classifier) source.getElement();
Classifier c_destination = (Classifier) destination.getElement();

I then create the association and give it a stereotype and name the different parts:
Association association = model.createAssociation();

String name = "";
String endMulMin = "";

if (assocType == 1) {
    name = "Every: \nFor: ";

and next I setup the Association ends:
AssociationEnd endSource = model.createAssociationEnd();

AssociationEnd endTarget = model.createAssociationEnd();

Now I find that when I try to add both AssociationEnds, the exception throws (specifically it seems to throw when "endTarget" is added):

Can someone help?

Sorry, have found the cause the issue. Seems the issue was that the source and destination of the second AssociationEnd had not been set.
I am still interested to know why this worked in Modelio 3.3, as the code is the same.

Please Log in or Create an account to join the conversation.

6 years 3 months ago #4191 by pan
Hi deankramer99,

Maybe it was an issue on Modelio 3.3 to have the possibility to do it because it could lead to an inconsistent model.


Please Log in or Create an account to join the conversation.

Moderators: tmachmaab
Time to create page: 0.076 seconds
^ Back to Top