« Back to CIDOC-CRM Project

Follow Up "Multiple Inheritance" : Constraints on drawing the connector

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Follow Up "Multiple Inheritance" : Constraints on drawing the connector
community class relation documentation
Answer
3/27/14 11:17 AM
When there is not a relation (an attribute in my case) that connects two classes and i am trying to do so, a window without attributes appears and then when the user clicks on "Cancel" there is a connection (a simple arrow) between the classes but without any actual meaning. Could I avoid it and prevent the connector to be drawn if it is not allowed?

RE: Follow Up "Multiple Inheritance" : Constraints on drawing the connector
Answer
6/24/13 10:16 AM as a reply to Anonymous.
The event "BeforeCreateRelationInstance" is triggered before a relation (connector) is created. You can an event handler for this event in the library attribute "Modi" and exit the creation process with the code "-1". Thus the process of creating the relation instance is aborted without displaying any error message.
An example of a possible implementation of the event handler can be seen below:

 1...
 2ON_EVENT "BeforeCreateRelationInstance"
 3{
 4#Event triggered before a relation instance (connector) is created
 5#componentid contains the ID of the affected component
 6#relationclassid the ID of the new relation's class
 7#frominstid the ID of the from-instance of the relation
 8#toinstid the ID of the to-instance of the new relation.
 9#The Event Handler returns one of these values: 0 - no abortion, -1 - abortion without error, -2 - abortion with error, >0 - abort with core error code.
10
11SET id_relationclassid: (relationclassid)
12SET id_frominstanceid: (frominstid)
13SET id_toinstanceid: (toinsid)
14SET id_componentid: (componentid)
15
16CC "Core" GET_CLASS_NAME classid: (relationclassid)
17 # --> RESULT ecode: intValue classname: strValue isrel: intValue
18SET str_classname: (classname)
19 IF (str_classname = "any2any")
20 {
21   #determine the interref name
22  CC "Core" GET_CLASS_ID objid: (id_frominstanceid)
23   #--> RESULT ecode: intValue classid: intValue isrel: intValue .
24  SET id_fromClassID: (classid)
25  CC "Core"  GET_CLASS_NAME classid: (id_fromClassID)
26   #--> RESULT ecode: intValue classname: strValue isrel: intValue .
27  SET str_fromClassName: (classname)
28  CC "Core"  GET_CLASS_ID objid: (id_toinstanceid)
29   #--> RESULT ecode: intValue classid: intValue isrel: intValue .
30  SET id_toClassID: (classid)
31  CC "Core"  GET_CLASS_NAME classid: (id_toClassID)
32   #--> RESULT ecode: intValue classname: strValue isrel: intValue .
33  SET str_toClassName: (classname)
34
35  IF (str_fromClassName = "A")
36  {
37   IF (str_toClassName = "B") 
38   {
39    EXIT -1
40   }
41   IF (str_toClassName = "A") 
42   {
43    EXIT -1
44   }
45   IF (str_toClassName = "E") 
46   {
47    EXIT -1
48   }
49   IF (str_toClassName = "Y") 
50   {
51    EXIT -1
52   }
53  }
54  ELSIF (str_fromClassName = "B")
55  {
56   IF (str_toClassName != "Y") 
57   {
58    EXIT -1
59   }
60  }
61  ELSIF (str_fromClassName = "E")
62  {
63   IF (str_toClassName = "A") 
64   {
65    EXIT -1
66   }
67   IF (str_toClassName = "B") 
68   {
69    EXIT -1
70   }
71  }
72 }
73}