cardialfly / DALNIM

[DEPRECATED] Some source code and scripts for DALNIM
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Support precedence task #6

Closed cardialfly closed 2 years ago

cardialfly commented 2 years ago

Store BPMN task precedence (e.g., sequence flow, gateways) in the conceptual model.

Conceptual model may need to be changed.

cardialfly commented 2 years ago

This task is paused due to the following problem.

Problem

The concept model diagram only contains "PrecedenceTask -> isCompoundBySetOfTask -> Task".

However, we also need the relation "Task -> isPrecededBySetOfTask -> PrecedenceTask" (see figure 3 in the CyberArgus paper) in order to appropriately represent the "precedence" (i.e., if task2 comes after task1, then task1 "precedes" task2).

If we only use 1 relation (i.e., isCompoundBySetOfTask) we can indeed connect PrecedenceTask and Task, but we lose information about which task came before and which task came after (so we cannot actually represent a "precedence").

Suggested solution

Add relation "Task -> isPrecededBySetOfTask -> PrecedenceTask" to the conceptual model.

cardialfly commented 2 years ago

This task is paused due to the following problem.

Problem

The concept model diagram only contains "PrecedenceTask -> isCompoundBySetOfTask -> Task".

However, we also need the relation "Task -> isPrecededBySetOfTask -> PrecedenceTask" (see figure 3 in the CyberArgus paper) in order to appropriately represent the "precedence" (i.e., if task2 comes after task1, then task1 "precedes" task2).

If we only use 1 relation (i.e., isCompoundBySetOfTask) we can indeed connect PrecedenceTask and Task, but we lose information about which task came before and which task came after (so we cannot actually represent a "precedence").

Suggested solution

Add relation "Task -> isPrecededBySetOfTask -> PrecedenceTask" to the conceptual model.

The above seems to be solved now in revision https://github.com/cardialfly/DALNIM/commit/06239e4182d8b3a3f22bb0e4abf35d45aeb44c36

cardialfly commented 2 years ago

Still working on sequenceFlow mapping. Current approach is to add a rule like the following:

## Task isPrecededBySetOfTask precedence tasks (sequence flow)
rule rule_task_isPrecededBySetOfTask_precedenceTask_sequenceFlow:
when {
    $precedenceTask isa PrecedenceTask;
    $task1 isa Task;
    $task2 isa Task;
    $sequenceFlow isa BPMN_sequenceFlow, has BPMNattrib_sourceRef $sourceRef, has BPMNattrib_targetRef $targetRef;
    $bpmntask1 isa BPMN_Entity, has BPMNattrib_id $taskID1;
    $bpmntask2 isa BPMN_Entity, has BPMNattrib_id $taskID2;
    $taskID1 = $sourceRef;
    $taskID2 = $targetRef;
    (bpmnEntity: $sequenceFlow, conceptualModel: $precedenceTask) isa BPMN_hasConceptualModelElement;
    (bpmnEntity: $bpmntask1, conceptualModel: $task1) isa BPMN_hasConceptualModelElement;
    (bpmnEntity: $bpmntask2, conceptualModel: $task2) isa BPMN_hasConceptualModelElement;
} then {
    (precedence_task: $precedenceTask, task: $task2) isa isPrecededBySetOfTask;
};

The above means: if a sequence flow is connecting two tasks, then connect "Task -> isPrecededBySetOfTask -> PrecedenceTask".

The following can be used to query;

## query isPrecededBySetOfTask
match
    $p isa PrecedenceTask;
    $t isa Task;
    $r  (precedence_task: $p, task: $t) isa isPrecededBySetOfTask; 
    $bpmntask isa BPMN_Entity;
    $seq isa BPMN_Entity;
    $rel1 (bpmnEntity: $bpmntask, conceptualModel: $t) isa BPMN_hasConceptualModelElement;
    $rel2  (bpmnEntity: $seq, conceptualModel: $p) isa BPMN_hasConceptualModelElement;

Note: we still need a rule to connect "PrecedenceTask -> isCompoundBySetOfTask -> Task".

cardialfly commented 2 years ago

The new rule for "PrecedenceTask -> isCompoundBySetOfTask -> Task" associated with a sequenceFlow should be:

define
## Precedence task isCompoundBySetOfTask tasks (sequence flow)
rule rule_precedenceTask_isCompoundBySetOfTask_task_sequenceFlow:
when {
     $precedenceTask isa PrecedenceTask;
     $task1 isa Task;
     $task2 isa Task;
     $sequenceFlow isa BPMN_sequenceFlow, has BPMNattrib_sourceRef $sourceRef, has BPMNattrib_targetRef $targetRef;
     $bpmntask1 isa BPMN_Entity, has BPMNattrib_id $taskID1;
     $bpmntask2 isa BPMN_Entity, has BPMNattrib_id $taskID2;
     $taskID1 = $sourceRef;
     $taskID2 = $targetRef;
     (bpmnEntity: $sequenceFlow, conceptualModel: $precedenceTask) isa BPMN_hasConceptualModelElement;
     (bpmnEntity: $bpmntask1, conceptualModel: $task1) isa BPMN_hasConceptualModelElement;
     (bpmnEntity: $bpmntask2, conceptualModel: $task2) isa BPMN_hasConceptualModelElement;
} then {
     (precedence_task: $precedenceTask, task: $task1) isa isCompoundBySetOfTask;
};

With this, a query to retrieve the precedence task associated with sequenceFlow would be:


## query isPrecededBySetOfTask and isCompoundBySetOfTask associated with sequenceFlow
match
 $p isa PrecedenceTask;
 $t1 isa Task;
 $t2 isa Task;
 $r1  (precedence_task: $p, task: $t2) isa isPrecededBySetOfTask; 
 $r2  (precedence_task: $p, task: $t1) isa isCompoundBySetOfTask; 
 $bpmntask1 isa BPMN_Entity;
 $bpmntask2 isa BPMN_Entity;
 $seq isa BPMN_Entity;
 $rel1 (bpmnEntity: $bpmntask1, conceptualModel: $t1) isa BPMN_hasConceptualModelElement;
 $rel2 (bpmnEntity: $bpmntask2, conceptualModel: $t2) isa BPMN_hasConceptualModelElement;
 $rel3  (bpmnEntity: $seq, conceptualModel: $p) isa BPMN_hasConceptualModelElement;
cardialfly commented 2 years ago

The above rules related to isPrecededBySetOfTask and isCompoundBySetOfTask are done.

I'm still working with those related to gateways, though.

cardialfly commented 2 years ago

Created a relation called BPMN_gatewayTransitiveChain to connect the transitive closure of gateway precedence.

This can be used to retrieve all tasks that precede another task with gateways in the middle.

Example of query:

match
$gateway1 isa BPMN_Gateway, has BPMNattrib_name $attrib1;
$gateway2 isa BPMN_Gateway, has BPMNattrib_name $attrib2;
$rel (previous: $gateway1, next: $gateway2) isa BPMN_gatewayTransitiveChain;

I still need to create rules that use the above relation to populate/map the ANDPrecedenceTaskList and ORPrecedenceTaskList.

cardialfly commented 2 years ago

Added TypeDB rules to support "Task isPrecededBySetOfTask ORPrecedenceTaskList" in commit https://github.com/cardialfly/DALNIM/commit/c26a0f9c8161b297aeb41d2e8cf40dd55fe42205.

Remaining TypeDB rules:

cardialfly commented 2 years ago

Closing this issue because I finished addressing all rules associated with PrecedenceTask.

See commits https://github.com/cardialfly/DALNIM/commit/c431de3e90b2c9ad1e85004ae46726053fc62c7a and https://github.com/cardialfly/DALNIM/commit/1b33e77a241b7012c8bac601c6259fe7356f1b9a.