Book a Demo

Author Topic: Change colour of connector label in sequence diag  (Read 7961 times)

njf

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Change colour of connector label in sequence diag
« on: May 28, 2015, 03:23:26 pm »
Hi,

At the company I work at, each iteration of a project the changes are highlighted in a sequence diagram by changing the colour of the connector that has changed, along with its label and the part within the notes text that has changed.

I wanted to write a little script that changed these all back to the default colour ready for the next iteration.

The script I have can convert both the notes text and the connector itself, but I cannot figure out how to change the colour of the label. From investigation, I think this is stored within the PDATA5 field within the t_connector table, and I'm trying to replace CLR=33023 to CLR=-1 within this field.

But when I try to executed the script, it doesn't seem to update the database record.

The code is:

[size=9]
                           String query = "Select PData5 from t_connector where Connector_ID="+Integer.toString(connId);
                           String result = r.SQLQuery(query);
                          
                           Document xmlDoc = convertStringToDocument(result);
                           Element eadata = (Element) xmlDoc.getElementsByTagName("PData5").item(0);
                           String pdata5 = eadata.getTextContent();
                          
                          
                          
                           if (pdata5.contains("CLR") && !pdata5.contains("CLR=-1") && !pdata5.contains("CLR=0")  )
                           {
                                
                                 pdata5 = pdata5.replaceAll("CLR=[0-9]*", "CLR=-1");
                                 String statement = "UPDATE t_connector SET PData5='"+pdata5+"' where Connector_ID="+Integer.toString(connId);
                                 //System.out.println(statement);
                                 r.Execute(statement);
                           }[/size]


Is there anything I have done wrong? The statement it produces looks correct to me. Or is there an alternative simpler way to set the colour?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Change colour of connector label in sequence d
« Reply #1 on: May 28, 2015, 07:47:30 pm »
Looks ok. You should print the SQL in statement to see whether it's reasonable.

q.
« Last Edit: May 28, 2015, 07:48:27 pm by qwerty »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Change colour of connector label in sequence d
« Reply #2 on: May 29, 2015, 09:06:20 am »
The only thing that jumps out at me is how big is PDATA5, and what DB is your back-end. I know some of the DBs have trouble with large literal strings in sql.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Change colour of connector label in sequence d
« Reply #3 on: May 29, 2015, 01:33:46 pm »
As qwerty is saying, I would print the sql statement and execute it in an separate sql client.
If there are any errors int he sql then you will see it there.
If no errors then you can inspect the result using the sql client as well.

Geert

njf

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Change colour of connector label in sequence d
« Reply #4 on: May 29, 2015, 04:42:02 pm »
Quote
As qwerty is saying, I would print the sql statement and execute it in an separate sql client.
If there are any errors int he sql then you will see it there.
If no errors then you can inspect the result using the sql client as well.

Geert

Thanks for the replies.

We're just using the EAP files with an SVN repository. I tried running in Access 2007 (it converted the db), but one of the lines it produced was (I changed code slightly to see if it was case sensitive from the code above):

[size=9]UPDATE T_CONNECTOR SET PDATA5='SX=0;SY=-40;EX=0;EY=0;$LLB=;LLT=;LMT=CX=269:CY=13:OX=2:OY=-1:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;LMB=;LRT=;LRB=;IRHS=;ILHS=;' where CONNECTOR_ID=60161
[/size]


And Access accepted and changed it.

Is there a way I can use an SQL directly with an EAP file?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Change colour of connector label in sequence d
« Reply #5 on: May 29, 2015, 04:52:21 pm »
Quote
Is there a way I can use an SQL directly with an EAP file?

Use any generic SQL client. I use the free AnySQL Maestro

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Change colour of connector label in sequence d
« Reply #6 on: May 30, 2015, 09:32:02 pm »
Although Repository.Execute is not an official interface you should send a bug report to Sparx. They will at least have a look why a SQL is not executed.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Change colour of connector label in sequence d
« Reply #7 on: June 01, 2015, 09:42:18 am »
Quote
Although Repository.Execute is not an official interface you should send a bug report to Sparx. They will at least have a look why a SQL is not executed.

q.
I believe the phrasing is that it's not supported.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Change colour of connector label in sequence d
« Reply #8 on: June 01, 2015, 06:22:18 pm »
I definitely did not mean it would be accepted as bug. But most programmers ambition is to have bug free code. So knowing about it could help both sides ;)

q.
« Last Edit: June 01, 2015, 06:24:58 pm by qwerty »