« Back to University of Vienna - OMILAB

Restrict connection between classes dependent on attribute

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Hello.

I extended the BPMN 2.0 library with a new attribute "SOD_Select" in the class "Task". The attribute is of type enumeration and has three options. I also made a new relation class "Constraint Verbindung" which can connect a "Task" with another "Task", but it should have the requirement that it can only connect two tasks which selected the same "SOD_Select" option. To achieve this I made a new "BeforeCreateRelationInstance"  event in the external coupling, with the following code. 

 1
 2ON_EVENT "BeforeCreateRelationInstance" {
 3SET id_relationclassid: (relationclassid)
 4SET id_frominstanceid: (frominstid)
 5SET id_toinstanceid: (toinstid)
 6SET id_componentid: (componentid)
 7
 8CC "Core" GET_CLASS_NAME classid: (relationclassid)
 9
10SET str_classname: (classname)
11IF (str_classname = "Constraint Verbindung") {
12
13  CC "Core" GET_CLASS_ID objid: (id_frominstanceid)
14 SET id_fromClassID: (classid)
15 CC "Core" GET_CLASS_NAME classid: (id_fromClassID)
16 SET str_fromClassName: (classname)
17
18CC "Core" GET_CLASS_ID objid: (id_toinstanceid) 
19SET id_toClassID: (classid)
20 CC "Core" GET_CLASS_NAME classid: (id_toClassID) 
21SET str_toClassName: (classname)
22
23
24CC "Core" debug GET_ATTR_ID classid:(id_fromClassID) attrname: "SOD_Select"
25SET from_AttID: (attrid)
26
27CC "Core" debug GET_ATTR_ID classid:(id_toClassID) attrname: "SOD_Select"
28SET to_AttID: (attrid)
29
30
31CC "Core" debug GET_ATTR_VAL objid:(from_AttID)
32SET from_attribute: (val)
33
34CC "Core" debug GET_ATTR_VAL objid:(to_AttID)
35 SET to_attribute: (val)
36
37IF (from_attribute <> to_attribute) {
38 
39  CC "AdoScript" ERRORBOX "Beide Tasks mussen SOD oder BOD sein!"
40  EXIT -1
41
42 }
43}
44}


After debugging I realized that I don't get the attribute(SOD_Select) value which is selected in the "Task". How would it be possible to achieve the desired output? Thank you very much!

RE: Restrict connection between classes dependent on attribute
Answer
3/2/16 7:37 AM as a reply to Anonymous.
If you want to receive attribute values with AdoScript you can use the command GET_ATTR_VAL in the messageport Core. The syntax of this command is as follows:

1CC "Core" GET_ATTR_VAL objid:id AttrSpec
2# As inputs you would need the objectid and the attribute specification. The parameters below (in square brackets) are optional.
3[ as-string ] [ core-value ] [ format:strValue ] [ sep:strValue ]
4# There are two options to declare the attribute 1) attribute id or 2) attribute name:
5AttrSpec : attrid:id | attrname:strValue .
6#-->RESULT ecode:intValue val:anyValue

In your case this would be then

 1CC "Core" GET_ATTR_ID classid: (id_fromClassID) attrname: "SOD_Select"
 2SET from_AttID: (attrid)
 3
 4CC "Core" GET_ATTR_ID classid: (id_toClassID) attrname: "SOD_Select"
 5SET to_AttID: (attrid)
 6
 7CC "Core" GET_ATTR_VAL objid: (id_frominstanceid) attrid: (from_AttID)
 8SET from_attribute: (val)
 9
10CC "Core" GET_ATTR_VAL objid: (id_toinstanceid) attrid: (to_AttID)
11SET to_attribute: (val)