Author Topic: Relationships do not show on the diagram  (Read 3440 times)

Moe

  • EA User
  • **
  • Posts: 107
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
Relationships do not show on the diagram
« on: January 10, 2021, 12:54:11 pm »
Hello, EA Experts,

I imported this Python code
https://ibb.co/RQrJRLb

To get these classes on a diagram but without relationships shown
https://ibb.co/C9H2LHX

When I transformed the model to DDL, I still do not see relationships
https://ibb.co/mBv3zgt

I checked the diagram properties and I confirmed that "Show Relationships" is checked
https://ibb.co/M14VSnL

What should I do to show the relationships?

Thank you,
Mo

PhD Student - Systems Engineering

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 11852
  • Karma: +460/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Relationships do not show on the diagram
« Reply #1 on: January 10, 2021, 05:32:39 pm »
I guess EA didn't create any relationships when importing your code.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 12844
  • Karma: +367/-296
  • I'm no guru at all
    • View Profile
Re: Relationships do not show on the diagram
« Reply #2 on: January 10, 2021, 08:20:15 pm »
class without self? What Python code is that?

q.

Moe

  • EA User
  • **
  • Posts: 107
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
Re: Relationships do not show on the diagram
« Reply #3 on: January 11, 2021, 09:52:37 am »
Thank you, Geert and q. for your responses.

Is this a problem from EA's side or something missing in the code?

Is there a way to fix that?

Thank you,
Mo
PhD Student - Systems Engineering

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7736
  • Karma: +103/-18
    • View Profile
Re: Relationships do not show on the diagram
« Reply #4 on: January 11, 2021, 10:13:54 am »
The problem is that Python doesn't explicitly declare the type for the variables and EA can't infer it.
Eve

support@sparxsystems.com

qwerty

  • EA Guru
  • *****
  • Posts: 12844
  • Karma: +367/-296
  • I'm no guru at all
    • View Profile
Re: Relationships do not show on the diagram
« Reply #5 on: January 11, 2021, 10:16:42 am »
Well, your code isn't Python. A class needs self as first parameter. Always. Formally: this is not a sentence of the Python language. The compiler will not swallow it. And EA will probably not even croak but do "something".

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7736
  • Karma: +103/-18
    • View Profile
Re: Relationships do not show on the diagram
« Reply #6 on: January 11, 2021, 10:45:00 am »
Are you sure qwerty?

My (limited) Python understanding says that what is defined there are class definitions with static variables. As there are no methods at all there's no reason why there should be a self parameter. I assume that django requires a database structure to to be specified like this.
Eve

support@sparxsystems.com

Moe

  • EA User
  • **
  • Posts: 107
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
Re: Relationships do not show on the diagram
« Reply #7 on: January 11, 2021, 05:49:27 pm »
I have very little knowledge of Python. I just got this code from another team member and tried to import it to EA.

It was successfully imported (as a Python code) but with no relationships on the class diagram created by EA as I indicated earlier

When I told the developer that there are no relationships shown in EA, he exported this ERD from Django-extensions (and it shows relationships)

https://ibb.co/NSV9zYc

He also shared the below code of the ERD (as a .dott file) but I could not import this .dot file to EA

Code: [Select]
digraph model_graph {
  // Dotfile by Django-Extensions graph_models
  // Created: 2021-01-08 07:36
  // Cli Options: -a
  fontname = "Roboto"
  fontsize = 8
  splines  = true
  node [
    fontname = "Roboto"
    fontsize = 8
    shape = "plaintext"
  ]
  edge [
    fontname = "Roboto"
    fontsize = 8
  ]
  // Labels
  django_contrib_admin_models_LogEntry [label=<
    <TABLE BGCOLOR="white" BORDER="1" CELLBORDER="0" CELLSPACING="0">
    <TR><TD COLSPAN="2" CELLPADDING="5" ALIGN="CENTER" BGCOLOR="#1b563f">
    <FONT FACE="Roboto" COLOR="white" POINT-SIZE="10"><B>
    LogEntry
    </B></FONT></TD></TR>
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto"><B>id</B></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto"><B>AutoField</B></FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT COLOR="#7B7B7B" FACE="Roboto"><B>content_type</B></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT COLOR="#7B7B7B" FACE="Roboto"><B>ForeignKey (id)</B></FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto"><B>user</B></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto"><B>ForeignKey (id)</B></FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto">action_flag</FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto">PositiveSmallIntegerField</FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto">action_time</FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto">DateTimeField</FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT COLOR="#7B7B7B" FACE="Roboto">change_message</FONT>
    </TD><TD ALIGN="LEFT">
    <FONT COLOR="#7B7B7B" FACE="Roboto">TextField</FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT COLOR="#7B7B7B" FACE="Roboto">object_id</FONT>
    </TD><TD ALIGN="LEFT">
    <FONT COLOR="#7B7B7B" FACE="Roboto">TextField</FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto">object_repr</FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto">CharField</FONT>
    </TD></TR>
 
 
    </TABLE>
    >]
  django_contrib_auth_models_AbstractUser [label=<
    <TABLE BGCOLOR="white" BORDER="1" CELLBORDER="0" CELLSPACING="0">
    <TR><TD COLSPAN="2" CELLPADDING="5" ALIGN="CENTER" BGCOLOR="#1b563f">
    <FONT FACE="Roboto" COLOR="white" POINT-SIZE="10"><B>
    AbstractUser<BR/>&lt;<FONT FACE="Roboto"><I>AbstractBaseUser,PermissionsMixin</I></FONT>&gt;
    </B></FONT></TD></TR>
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto">date_joined</FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto">DateTimeField</FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT COLOR="#7B7B7B" FACE="Roboto">email</FONT>
    </TD><TD ALIGN="LEFT">
    <FONT COLOR="#7B7B7B" FACE="Roboto">EmailField</FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT COLOR="#7B7B7B" FACE="Roboto">first_name</FONT>
    </TD><TD ALIGN="LEFT">
    <FONT COLOR="#7B7B7B" FACE="Roboto">CharField</FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto">is_active</FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto">BooleanField</FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto">is_staff</FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto">BooleanField</FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto"><I>is_superuser</I></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto"><I>BooleanField</I></FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT COLOR="#7B7B7B" FACE="Roboto"><I>last_login</I></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT COLOR="#7B7B7B" FACE="Roboto"><I>DateTimeField</I></FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT COLOR="#7B7B7B" FACE="Roboto">last_name</FONT>
    </TD><TD ALIGN="LEFT">
    <FONT COLOR="#7B7B7B" FACE="Roboto">CharField</FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto"><I>password</I></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto"><I>CharField</I></FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto">username</FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto">CharField</FONT>
    </TD></TR>
 
 
    </TABLE>
    >]
  django_contrib_auth_models_Permission [label=<
    <TABLE BGCOLOR="white" BORDER="1" CELLBORDER="0" CELLSPACING="0">
    <TR><TD COLSPAN="2" CELLPADDING="5" ALIGN="CENTER" BGCOLOR="#1b563f">
    <FONT FACE="Roboto" COLOR="white" POINT-SIZE="10"><B>
    Permission
    </B></FONT></TD></TR>
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto"><B>id</B></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto"><B>AutoField</B></FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto"><B>content_type</B></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto"><B>ForeignKey (id)</B></FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto">codename</FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto">CharField</FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto">name</FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto">CharField</FONT>
    </TD></TR>
 
 
    </TABLE>
    >]
  django_contrib_auth_models_Group [label=<
    <TABLE BGCOLOR="white" BORDER="1" CELLBORDER="0" CELLSPACING="0">
    <TR><TD COLSPAN="2" CELLPADDING="5" ALIGN="CENTER" BGCOLOR="#1b563f">
    <FONT FACE="Roboto" COLOR="white" POINT-SIZE="10"><B>
    Group
    </B></FONT></TD></TR>
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto"><B>id</B></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto"><B>AutoField</B></FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto">name</FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto">CharField</FONT>
    </TD></TR>
 
 
    </TABLE>
    >]
  django_contrib_auth_models_User [label=<
    <TABLE BGCOLOR="white" BORDER="1" CELLBORDER="0" CELLSPACING="0">
    <TR><TD COLSPAN="2" CELLPADDING="5" ALIGN="CENTER" BGCOLOR="#1b563f">
    <FONT FACE="Roboto" COLOR="white" POINT-SIZE="10"><B>
    User<BR/>&lt;<FONT FACE="Roboto"><I>AbstractUser</I></FONT>&gt;
    </B></FONT></TD></TR>
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto"><B>id</B></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto"><B>AutoField</B></FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto"><I>date_joined</I></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto"><I>DateTimeField</I></FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT COLOR="#7B7B7B" FACE="Roboto"><I>email</I></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT COLOR="#7B7B7B" FACE="Roboto"><I>EmailField</I></FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT COLOR="#7B7B7B" FACE="Roboto"><I>first_name</I></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT COLOR="#7B7B7B" FACE="Roboto"><I>CharField</I></FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto"><I>is_active</I></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto"><I>BooleanField</I></FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto"><I>is_staff</I></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto"><I>BooleanField</I></FONT>
    </TD></TR>
 
 
 
    <TR><TD ALIGN="LEFT" BORDER="0">
    <FONT FACE="Roboto"><I>is_superuser</I></FONT>
    </TD><TD ALIGN="LEFT">
    <FONT FACE="Roboto"><I>BooleanField</I></FONT>
    </TD><...
« Last Edit: January 11, 2021, 05:51:44 pm by Mo »
PhD Student - Systems Engineering

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 11852
  • Karma: +460/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Relationships do not show on the diagram
« Reply #8 on: January 11, 2021, 05:57:04 pm »
What did you expect?  I didn't see any relations in the python code, just a whole bunch of html inside the code.

If EA parses code it will show the relations it can extract from the code. It will definitely not parse the HTML and do something with it.

Geert

Moe

  • EA User
  • **
  • Posts: 107
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
Re: Relationships do not show on the diagram
« Reply #9 on: January 11, 2021, 06:00:38 pm »
Thank you, Geert.

But do you know how did he manage to export an ERD (with relationships ) from Django-extensions? Also, the image he extracted from Django shows relationships.

When I noticed no relations in the Python code and asked the developed, he said "look for models.forignkey"

Any advice would be appreciated.

Thank you,
Mo
« Last Edit: January 11, 2021, 06:12:49 pm by Mo »
PhD Student - Systems Engineering

qwerty

  • EA Guru
  • *****
  • Posts: 12844
  • Karma: +367/-296
  • I'm no guru at all
    • View Profile
Re: Relationships do not show on the diagram
« Reply #10 on: January 11, 2021, 07:42:31 pm »
Are you sure qwerty?

My (limited) Python understanding says that what is defined there are class definitions with static variables. As there are no methods at all there's no reason why there should be a self parameter. I assume that django requires a database structure to to be specified like this.
Well, it was late. They use the Django framework. So this IS legal Python. However, I don't think Sparx is using a fullly fledged Python compiler and will not recognize that structure. Personally I would not blame EA for not being able...

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7736
  • Karma: +103/-18
    • View Profile
Re: Relationships do not show on the diagram
« Reply #11 on: January 12, 2021, 07:55:29 am »
When I noticed no relations in the Python code and asked the developed, he said "look for models.forignkey"
EA imports associations between classes when the explicitly declared type matches the name of another class.

It can not infer the type from the ways that it is used, including the initial value. Even if it could, it knows nothing about django in order to parse the model.ForeignKey invocation.
Eve

support@sparxsystems.com

Moe

  • EA User
  • **
  • Posts: 107
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
Re: Relationships do not show on the diagram
« Reply #12 on: January 12, 2021, 09:01:28 am »
Thank you, Eve, q. and Geert for your input. I really appreciate it.
PhD Student - Systems Engineering