« Back to AAU Project

Delete Connectors autonomously

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Delete Connectors autonomously
Answer
6/23/15 5:59 PM
Would you please post an example, how to delete a specific connector (relation) of type "Is-A" after the eventĀ  "AfterEditAttributeValue".
The problem is how to use DELETE_CONNECTOR ConnectorID | FromToIDs!
Attachment

Attachments: Connector.png (2.8k)

RE: Delete Connectors autonomously
Answer
7/2/15 6:18 AM as a reply to Fadi Al Machot.
Dear Fadi,
Thank you for your question. For deleting connectors with the command DELETE_CONNECTOR you need the id of the connector (1) or the source-object-id and the target-object-id (2). Below you can find an example for the both scenarios.

1) Delete connectors with relation-id

 1ON_EVENT "AfterEditAttributeValue" {
 2SET id_ModelId: (modelid)
 3SET id_InstId: (instid)
 4SET id_AttrId: (attrid)
 5
 6CC "Core" GET_CLASS_ID classname:"A"
 7CC "Core" GET_ATTR_ID classid: (classid) attrname:"Table"
 8SET nTableAttrId: (attrid)
 9
10#Trigger Event if attribute "Table" is editted
11  IF (nTableAttrId=id_AttrId) {
12  CC "Core" GET_OBJ_NAME objid: (id_InstId)
13  SET sObjName: (objname)
14
15#Query the relation ids of the outgoing "RelatedTo"-relations from the current instance
16  CC "AQL" EVAL_AQL_EXPRESSION expr: ("{\"" + sObjName + "\"} -> <\"RelatedTo\">" ) modelid: (id_ModelId)
17  SET s_RelationIds: (objids)
18
19#Delete "RelatedTo"-relations which are outgoing from the current object
20    FOR i in: (s_RelationIds) {
21    CC "Core" DELETE_CONNECTOR modelid: (id_ModelId) objid: (VAL i)
22    }
23  }
24}


2) Delete Connectors with from-object-id and to-object-id

 1ON_EVENT "AfterEditAttributeValue" {
 2SET id_ModelId: (modelid)
 3SET id_InstId: (instid)
 4SET id_AttrId: (attrid)
 5
 6CC "Core" GET_CLASS_ID classname:"A"
 7CC "Core" GET_ATTR_ID classid: (classid) attrname:"Table"
 8SET nTableAttrId: (attrid)
 9
10#Trigger Event if attribute "Table" is editted
11 IF (nTableAttrId=id_AttrId) { 
12  CC "Core" GET_CLASS_ID relation classname:"RelatedTo"
13  SET nRelatedToClassId: (classid)
14  CC "Core" GET_OBJ_NAME objid: (id_InstId)
15  SET sObjName: (objname)
16
17#Query the target objects of the current instance
18  CC "AQL" EVAL_AQL_EXPRESSION expr: ("{\"" + sObjName + "\"} -> \"RelatedTo\"" ) modelid: (id_ModelId)
19  SET s_RelationIds: (objids)
20
21#Delete "RelatedTo"-relations which are outgoing from the current object
22    FOR i in: (s_RelationIds) {
23    CC "Core" DELETE_CONNECTOR modelid: (id_ModelId) fromobjid: (id_InstId) toobjid: (VAL i) classid: (nRelatedToClassId)}
24    }
25 }
26}