« Back to AAU Project

Editor-Notebook Interaction

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Editor-Notebook Interaction
community relation documentation adoscript trigger attribute type
Answer
3/27/14 11:07 AM
I have a question please,
-In ADOxx, If we draw a relation (connection) between 2  elements (classes), a field of a type “INTERREF ” should be set to the other element(class) value.
- For example:
If we draw:
Car(class) ----Connection(has)----- Engine(class).
Then, in notebook of the class “car”, the field “connected_to”  of type “INTERREF ”  should be set to the value “Engine”, and the same for the class “engine”, its “connected_to” field should be set to the value “car”.
Any body can help?

RE: Editor-Notebook Interaction
on_event add_interref get_attr_id get_class_name get_class_id
Answer
12/16/13 2:41 PM as a reply to Fadi.
Dear Fadi,

for that purpose you would have to implement an event handler for the event "CreateRelationInstance" in the library attribute External Coupling of the Dynamic Library.
In the event handler, you have to read the information about the relation name and the names of the from and to objects, respectively, and, if all these names are "compatible", you create a new pointer (INTERREF) using the command call ADD_INTERREF. Please observe the implementation below:
 1ON_EVENT "CreateRelationInstance"
 2{
 3#Event triggered when a relation instance (connector) is created
 4#componentid contains the ID of the affected component
 5#relationinstanceid the ID of the affected relation
 6#relationclassid the ID of the new relation's class
 7#frominstanceid the ID of the from-instance of the relation
 8#toinstanceid the ID of the to-instance of the new relation.
 9
10SET id_relationinstanceid: (relationinstanceid)
11SET id_relationclassid: (relationclassid)
12SET id_frominstanceid: (frominstanceid)
13SET id_toinstanceid: (toinstanceid)
14SET id_componentid: (componentid)
15CC "Core" GET_CLASS_NAME classid: (id_relationclassid)
16 # --> RESULT ecode: intValue classname: strValue isrel: intValue
17SET str_classname: (classname)
18IF (str_classname = "has")
19{
20 # read class names of the two object connected with the newly created connector
21 CC "Core" GET_CLASS_ID objid: (id_frominstanceid)
22  #--> RESULT ecode: intValue classid: intValue isrel: intValue .
23 SET id_fromClassID: (classid)
24 CC "Core"  GET_CLASS_NAME classid: (id_fromClassID)
25  #--> RESULT ecode: intValue classname: strValue isrel: intValue .
26 SET str_fromClassName: (classname)
27 CC "Core"  GET_CLASS_ID objid: (id_toinstanceid)
28  #--> RESULT ecode: intValue classid: intValue isrel: intValue .
29 SET id_toClassID: (classid)
30 CC "Core"  GET_CLASS_NAME classid: (id_toClassID)
31  #--> RESULT ecode: intValue classname: strValue isrel: intValue .
32 SET str_toClassName: (classname)
33
34 IF ((str_fromClassName = "vehicle") AND (str_toClassName = "part")) 
35 {
36  #create interref
37  CC "Core" GET_ATTR_ID classid: (id_fromClassID) attrname: ("connected_to")
38  # --> RESULT ecode: intValue attrid: id .
39  SET id_interrefID: (attrid)
40  CC "Core" ADD_INTERREF objid: (id_frominstanceid) attrid: (id_interrefID) tobjid: (id_toinstanceid)
41  #--> RESULT ecode: intValue 
42 }
43}
44}
45#=============================================

The names used in the example are fictive names, of course, and you have to adapt them to your own modelling language.

RE: Editor-Notebook Interaction
Answer
12/16/13 2:48 PM as a reply to Sabin Popescu.
An aspect to add to Sabin's example above relates to the "endpoint" definition for both the relation class and the respective INTERREF attribute. Both value domains need to be aligned so that the INTERREF can acutally be created. Also consider multiple incoming and outgoing relation instances of different types.

RE: Editor-Notebook Interaction
Answer
12/16/13 3:12 PM as a reply to Wilfrid Utz.
Thanks emoticon, I will try it