Author Topic: Finding the source and target of a relationship  (Read 7268 times)

Clemo

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Finding the source and target of a relationship
« on: June 26, 2014, 06:18:28 pm »
Hi,

Think this may be a beginner question so apologies.

I have created a profile that has two constructs (A & B) that can be connected via a relationship R.  Relationship R can only go from A->B, B->A is not allowed.

I have created the relation using an association with direction:source->destination.

How do I now use the Java api to check that relationship R is going from A->B and not B->A

Thanks

Clemo

Jeremie0

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: Finding the source and target of a relationshi
« Reply #1 on: June 26, 2014, 06:27:15 pm »
i would say
that a connector is defined as a type (association for example), a clientID and a supplierID

if you know the elementID, just see if the element is the client or the supplier

in your example supplier would be A and client B

Clemo

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: Finding the source and target of a relationshi
« Reply #2 on: June 26, 2014, 06:37:25 pm »
Thanks for the quick response and so obvious!

Clemo

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: Finding the source and target of a relationshi
« Reply #3 on: June 26, 2014, 07:05:53 pm »
I really must be doing something wrong as I have done what has been suggested and irrespective of which way the relationship is directed I get the same output


elementId = 11
source = A(7), has destination = B(11)

I would have expected the source and destination to swap over when the direction of the relationship changes but it appears they did not!

Anybody any ideas because now I am really confused, do I need to do anything in the profile definition to ensure the source and destination are directional?

Clemo

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13303
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Finding the source and target of a relationshi
« Reply #4 on: June 26, 2014, 07:15:35 pm »
Some connectors such as a generalization can only be directional.
The Direction dropdown is disabled.
Maybe you can figure out what triggers this behavior and then apply that on your connector?

Geert

Clemo

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: Finding the source and target of a relationshi
« Reply #5 on: June 26, 2014, 07:22:53 pm »
Thanks for the information I am making an assumption that because the association has an arrow at one end of the association and that in the definition the direction states source->destination that the association is directional.

Is this a wrong assumption, as I am creating my own profile I do have the option of using another connector type although would prefer not too.

Regards

Paul

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Finding the source and target of a relationshi
« Reply #6 on: June 26, 2014, 07:43:14 pm »
Using the quick linker you are able t create either source->target as well as target->source connectors.

q.

Clemo

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: Finding the source and target of a relationshi
« Reply #7 on: June 26, 2014, 07:50:25 pm »
Thanks for the reply.

The relationship I am tying to use has been defined in my bespoke profile (stereotype of an association) as part of the toolbox for the diagram.

I am then selecting that relationship and attaching it to two of my constructs, the association seems to be showing as a directed association but I do not appear to be able to work out which is the source and which is the destination.

I am guessing its an issue with the way I am defining the relationship in my profile but cannot see what to do.

Thanks

Clemo

Clemo

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: Finding the source and target of a relationshi
« Reply #8 on: June 26, 2014, 11:47:22 pm »
Hi,

I have been looking at the quick linker as suggested (seems exactly what I want!) but I do not seem to be able to get it to work.  My line looks like this:

A=Class
B=A
C=Class
D=B
E
F
G
H=Association
I
J=directed
K=R(the relationship)
L
M=TRUE
N
O
P
Q=n-ary Association also tried BCM
R=0
S
T
U
V

Anybody spot what I am doing wrong?

Thanks

Clemo

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Finding the source and target of a relationshi
« Reply #9 on: June 27, 2014, 04:56:38 am »
It's really fiddly twiddly with the QL. You have to go through a couple of trial and error cycles. Try to use an existing matrix and make little changes to see how it reacts. Very tedious and unforgiving  :(

q.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: Finding the source and target of a relationshi
« Reply #10 on: June 27, 2014, 09:45:34 am »
Quote
Hi,

I have been looking at the quick linker as suggested (seems exactly what I want!) but I do not seem to be able to get it to work.  My line looks like this:

A=Class
B=A
C=Class
D=B
E
F
G
H=Association
I
J=directed
K=R(the relationship)
L
M=TRUE
N
O
P
Q=n-ary Association also tried BCM
R=0
S
T
U
V

Anybody spot what I am doing wrong?

Thanks

Clemo
If I understand you correctly, keep that row in your quicklinker definitions and add a second row from Class B to Class A with direction set to "from" instead of "directed". Then when you drag a quicklink from A to B it will create an Association from A to B, and when you drag a quicklink from B to A it will create an Association from A to B.
The Sparx Team
[email protected]

Clemo

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: Finding the source and target of a relationshi
« Reply #11 on: June 27, 2014, 05:05:06 pm »
Thanks guys, nearly there :)

Last issue is the link being created does not seem to be being set to my stereotype which I thought column K would do, is there some other column that I need to populate?

Fiddly I agree but now I have discovered it, looks incredibly useful.

Clemo

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: Finding the source and target of a relationshi
« Reply #12 on: June 27, 2014, 05:09:03 pm »
Quote
Thanks guys, nearly there :)

Last issue is the link being created does not seem to be being set to my stereotype which I thought column K would do, is there some other column that I need to populate?

Fiddly I agree but now I have discovered it, looks incredibly useful.

Clemo
Column I for the new link stereotype. Column K is the text that gets displayed on the menu.
The Sparx Team
[email protected]

Clemo

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: Finding the source and target of a relationshi
« Reply #13 on: June 27, 2014, 05:41:23 pm »
Thanks, I think much of the problem with the quick linker I have had is that it appears you have to restart EA to get the changes in your quick linker artifact to take place, its not just a question of rebuilding the profile.

Is that correct or is there a way around this?

Paul

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Finding the source and target of a relationshi
« Reply #14 on: June 27, 2014, 07:21:23 pm »
You can unload/load the MDG which (now) does the same job. But I found out that closing/reopening is usually faster than that.

q.