Relationship Client/Supplier Problems

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Relationship Client/Supplier Problems

Postby m.faughn@prometheuscomputing.com » Tue Oct 10, 2017 9:31 am

I am working on a plugin that will programmatically instantiate classifiers, properties, associations, etc. When it comes to Associations, I have Properties that are owned by Classifiers and I am calling property.setAssociation(myAssociation) to initialize the memberEnds of the Associations. I am having a problems though. Here is a sampling of the error messages with some notes:

Code: Select all
2017-10-10 10:28:59,683 [AWT-EventQueue-0] WARN  MODEL - Not valid element: com.nomagic.uml2.ext.magicdraw.classes.mdkernel.impl.PropertyImpl@18022808 MyPackage::MyClass::my_property
      id - _17_0_2_4_5df01f7_1406214040753_666131_2321      reason - Relationship has no client. Relationship has no supplier.


This is a property that is one end of an association. I also get the same kind of warning for the property at the other end of the association.

Code: Select all
2017-10-10 10:28:59,684 [AWT-EventQueue-0] WARN  MODEL - Not valid element: com.nomagic.uml2.ext.magicdraw.classes.mdkernel.impl.AssociationImpl@39d53de7 MyPackage::
      id - _16_9_78e0236_1366068121348_380727_2316      reason - Relationship has no client. Relationship has no supplier.


An unnamed association.

I have 36 errors with AssociationImpl and 144 with PropertyImpl so there is an obvious 1:4 ratio of errors.

From page 66 of the OpenAPI user guide v18.0:

A model element is a relationship, if it implements one of the following interfaces: Relationship, ActivityEdge, Transition, ExceptionHandler, Connector."
...
Create a new relationship model element.
2. Set client and supplier ModelElements by using ModelHelper.setSupplierElement(), Model-
Helper.setClientElement() methods.
3. Add a new relationship into some parent by using ModelElementsManager.addElement().


This isn't quite enough for me to figure it out. I'll assume that the relationship parameter or said methods is the Association. What elements should be the client and supplier elements for second parameters of the methods, respectively?

If you are able to relate this to the OMG UML specification it would also help me to understand what is going on here. Most of the references to client and supplier relationships that I can find are within the context of Dependencies. I do not understand why/how they apply to Associations.

Thanks for any guidance!
m.faughn@prometheuscomputing.com
Forum Newbie
Forum Newbie
 
Posts: 17
Posts Rating:0
Joined: Fri May 30, 2014 9:30 am

Re: Relationship Client/Supplier Problems

Postby mindaugas.genutis » Wed Oct 11, 2017 12:55 am

Hello,

Association is created between two classifiers. Properties are association member ends. When initializing an association you should pass in classifiers, MagicDraw will initialize properties and member ends for you:

Code: Select all
ModelHelper.setClientElement(association, class1);
ModelHelper.setSupplierElement(association, class2);


Yours Sincerely,

-- Mindaugas Genutis
User avatar
mindaugas.genutis
Customer Support
Customer Support
 
Posts: 471
Posts Rating:28
Joined: Thu Feb 04, 2010 1:57 am
Location: Kaunas

Re: Relationship Client/Supplier Problems

Postby m.faughn@prometheuscomputing.com » Wed Oct 11, 2017 7:00 am

Thanks for the response. I am still a bit unclear though.

Which class should be the client and which the supplier? Also, how does this relate to the OMG UML specification (or does it not)?
m.faughn@prometheuscomputing.com
Forum Newbie
Forum Newbie
 
Posts: 17
Posts Rating:0
Joined: Fri May 30, 2014 9:30 am

Re: Relationship Client/Supplier Problems

Postby mindaugas.genutis » Thu Oct 12, 2017 5:41 am

Hello,

Association is a bi-directional relationship, it doesn't matter which one you specify as client and which as supplier.

-- Mindaugas
User avatar
mindaugas.genutis
Customer Support
Customer Support
 
Posts: 471
Posts Rating:28
Joined: Thu Feb 04, 2010 1:57 am
Location: Kaunas


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 1 guest