Book a Demo

Author Topic: Attach ActionPin with Operation in Script  (Read 7274 times)

Cisore

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Attach ActionPin with Operation in Script
« on: July 18, 2012, 12:23:57 am »
Hi,

I want to do a script that generates the same result that if I slip an operation in a activity's diagram !

(On Action with a ActionPin's element who it linking with the operation !)

Actually I arrived to generate the Action and the ActionPin element but I don't arrived to link the ActionPin with the Operation !

Someone can help me ?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Attach ActionPin with Operation in Script
« Reply #1 on: July 18, 2012, 03:56:01 am »
It appears that the Classifier_GUID of the action is that of the operation.

q.

Cisore

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Re: Attach ActionPin with Operation in Script
« Reply #2 on: July 18, 2012, 06:18:39 pm »
I'm sorry but I don't have attribute Classifier_GUID !

(I have ClassifierID, it's a int whereas ClassifierID of the operation are String, and it's read only !)

May be I don't have build the Action correctly :
Code: [Select]
EA.Element elm = (EA.Element)diag.Elements.AddNew(nomAct, "Action");
elm.Update();
diag.Elements.Refresh();

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Attach ActionPin with Operation in Script
« Reply #3 on: July 18, 2012, 07:27:11 pm »
Classifier_GUID is a column in t_object. It does not seem as there is any corresponding property in Element. So (I guess) you have to poke that in via a SQL.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Attach ActionPin with Operation in Script
« Reply #4 on: July 18, 2012, 08:30:15 pm »
The trick in these kind of cases is:
- Start with an empty model
- Create what you need manually
- Inspect the results in the database
- Try to replicate the same results using the API
- If that doesn't work (because some attribute isn't exposed) then you resort to Repository.Execute(SQLString)

Geert

Cisore

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Re: Attach ActionPin with Operation in Script
« Reply #5 on: July 18, 2012, 10:14:36 pm »
Quote
The trick in these kind of cases is:
- Start with an empty model
- Create what you need manually
[highlight]- Inspect the results in the database[/highlight]
- Try to replicate the same results using the API
- If that doesn't work (because some attribute isn't exposed) then you resort to Repository.Execute(SQLString)
How can I do that ?

Quote
Classifier_GUID is a column in t_object. It does not seem as there is any corresponding property in Element. So (I guess) you have to poke that in via a SQL.
(where can I find example of SQL request to change this table ? It's the first time, I hear spoken of this table !  :-[ :-[)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Attach ActionPin with Operation in Script
« Reply #6 on: July 18, 2012, 10:17:34 pm »
depends on what you are using as repository.
For .eap file use MS Access or your favorite generic sql client.

Geert

Cisore

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Re: Attach ActionPin with Operation in Script
« Reply #7 on: July 18, 2012, 10:25:42 pm »
What is the name of the base ? (the location, the password and the login name ?)
« Last Edit: July 18, 2012, 10:26:33 pm by Cisore »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Attach ActionPin with Operation in Script
« Reply #8 on: July 18, 2012, 10:45:31 pm »
Have a look in my Inside book. I guess the basics are explained rather clearly in it.

q.

Cisore

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Re: Attach ActionPin with Operation in Script
« Reply #9 on: July 18, 2012, 11:40:44 pm »
Ok I find the base (and the good table) but ...

Who can I run a SQL request in a script ?

(I have read yours book : ScriptingEA and InsideEA but I don't find the information !)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Attach ActionPin with Operation in Script
« Reply #10 on: July 18, 2012, 11:55:32 pm »
Quote
The trick in these kind of cases is:
- Start with an empty model
- Create what you need manually
- Inspect the results in the database
- Try to replicate the same results using the API
- If that doesn't work (because some attribute isn't exposed) [highlight]then you resort to Repository.Execute(SQLString)[/highlight]

Geert

I must say I'm getting tired of repeating myself ::)

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Attach ActionPin with Operation in Script
« Reply #11 on: July 19, 2012, 12:12:18 am »
Quote
(I have read yours book : ScriptingEA and InsideEA but I don't find the information !)
True. i haven't put that in my books yet. Repository.Execute is some unofficial stuff (though you find it listed in the Scripting book on pg. 44). However, I'm about to put in an example on how to use this method.

q.

Cisore

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Re: Attach ActionPin with Operation in Script
« Reply #12 on: July 19, 2012, 12:16:33 am »
Sorry ! and thanks

[size=8]We never tire of hearing you that's why they make you repeat[/size]
« Last Edit: July 19, 2012, 05:41:00 pm by Cisore »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Attach ActionPin with Operation in Script
« Reply #13 on: July 20, 2012, 02:22:00 am »
Cisore,
have you managed to get it to work? I just peeked around and found this very strange. An action created normally can not be transformed to one created from an operation. The Advanced menu for both is different, though they are all Actions. Obviously there are also two entries created in t_xref, but until now I was not able to create such an operation-action. Very, very strange.

q.

Cisore

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Re: Attach ActionPin with Operation in Script
« Reply #14 on: July 20, 2012, 05:44:39 pm »
Heu ... Yes I have a code how works :

diag = Activity Element
vue = EA.Diagram (attach to diag)

Code: [Select]
EA.Element elm = (EA.Element)diag.Elements.AddNew(nomAct, "Action");

elm.Update();
diag.Elements.Refresh();

EA.Element tar = (EA.Element)elm.Elements.AddNew("target", "ActionPin");
tar.Update();

Repository.Execute("UPDATE t_object SET Classifier_guid='"+methodExec.MethodGUID+"' WHERE Name='"+nomAct+"';");

Guid g1 = Guid.NewGuid();
String sqlRequest1 = "INSERT INTO t_xref VALUES ";
sqlRequest1 +=                                  "(\""+g1.ToString()+"\",";
sqlRequest1 +=                                  "\"CustomProperties\",";
sqlRequest1 +=                                  "\"element property\",";
sqlRequest1 +=                                  "\"Public\",";
sqlRequest1 +=                                  "NULL,";
sqlRequest1 +=                                  "NULL,";
sqlRequest1 +=                                  "NULL,";
sqlRequest1 +=                                  "NULL,";
sqlRequest1 +=                                  "0,";
sqlRequest1 +=                                  "\"@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU=CallOperation@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;\",";
sqlRequest1 +=                                  "\"" +elm.ElementGUID+ "\",";
sqlRequest1 +=                                  "\"<none>\",";
sqlRequest1 +=                                  "NULL)";

Repository.Execute(sqlRequest1);

Guid g2 = Guid.NewGuid();
String sqlRequest2 = "INSERT into t_xref VALUES";
sqlRequest2+=                                   "(\""+g2.ToString()+"\",";
sqlRequest2+=                                   "\"MOFProps\",";
sqlRequest2+=                                   "\"element property\",";
sqlRequest2+=                                   "\"Public\",";
sqlRequest2+=                                   "NULL,";
sqlRequest2+=                                   "NULL,";
sqlRequest2+=                                   "NULL,";
sqlRequest2+=                                   "\"target\",";
sqlRequest2+=                                   "0,";
sqlRequest2+=                                   "\""+tar.ElementGUID+"\",";
sqlRequest2+=                                   "\""+elm.ElementGUID+"\",";
sqlRequest2+=                                   "\"<none>\",";
sqlRequest2+=                                   "NULL)";
Repository.Execute(sqlRequest2);

EA.DiagramObject ob = (EA.DiagramObject)vue.DiagramObjects.AddNew(nomAct, "");
ob.ElementID = elm.ElementID;
ob.Update();                                    

I'm not sure to have understand your question.  :-/