# Business Process Configuration according to Data Dependency Specification
## 4 Conf-BP Framework: A Configurable System to Create Imperative BP
### Automatic Transformation from Declarative to Imperative Model
#### 4.3.2 Transformation of the COP results into a BP Imperative Model
```
1:proceduresequentialTreatment(_Problem p_):BPMN-Graph
2:\(sol\):BPMN-Graph to return
3:\(lprob\): list of Problems
4:\(lsol\): list of BPMN-Graphs
5:if(\(p.listActivities.size()==1\)) then
6:\(sol\gets p\)
7:else
8:\(lprob\leftarrow\) separate \(p\) by detecting sequential points
9:for each \(p\in lprob\)do
10:\(lsol.add(parallelTreatment(p))\)
11:endfor
12:endif
13:\(sol\leftarrow\) link sequentially \(lsol\)
14:return\(sol\)
15:endprocedure
16:procedureparallelTreatment(_Problem p_):BPMN-Graph
17:\(sol\):BPMN-Graph to return
18:\(lprob\): list of Problems
19:\(lsol\): list of BPMN-Graphs
20:if(\(p.listActivities.size()==1\)) then
21:\(sol\gets p\)
22:else
23:\(lprob\leftarrow\) separate \(p\) by detecting parallel groups
24:for each \(p\in lprob\)do
25:\(lsol.add(sequentialTreatment(p))\)
26:endfor
27:endif
28:\(sol\leftarrow\) link \(lsol\) by gateways
29:return\(sol\)
30:endprocedure
```  
**Algorithm 2** Create a BP model from COP result. Algorithm 2 details the procedures for the sequential and parallel treatments explained above. Algorithm 2 takes a _Problem_ and transforms it into a BPMN-Graph. Initially, the _Problem_ is treated sequentially with the algorithm \(sequentialTreatment\), which finds the sequential points following Definition 9. Each of the _subproblems_ found, has to be analyzed to identify the parallel subsets of activities with the algorithm \(parallelTreatment\) (following Definition 10). The parallel treatment of a _Problem_ consists of gathering the activities that are related into subsets and creating new problems from these subsets. The relationships among the activities are given by the tuples of Condition-Relation of the _Problem_. Each _subproblem_ is then solved recursively. To combine the parallel subsets, two gateway vertices are inserted as split and join gateway respectively. Each BPMN-sub-graph will be a branch related by means of the gateway. To combine two sequential BPMN-sub-graphs, only and edge needs to be included between the last node of the first solution and the first node of the second solution. The algorithm draws to a halt when reaching a base case, or when the problem contains only one activity. In both treatments, the solution of a base case is a graph with a unique vertex that represents this activity. Step 2: Defining The Gateways  
Once the graph is created, the correct gateways that diverge the sequence flows have to be selected. In the graph, the gateways are identified by means of studying the tuples of Condition-Relation obtained from the constraints, defined in the declarative specification. The different types of relations described by means of the tuples of Condition-Relation, and how they affect to the type of gateway are explained below:  
* **Parallel**: two activities are executed in a parallel way if there are no conditions that relate the \(t_{ini}\) of both activities (see Figure 9). * **Exclusive**: two activities are executed in an exclusive way if the constraints that relate the \(t_{ini}\) of the two activities and the domain of these constraints are complete and do not overlap. For example, as shown in Figure 10, if the execution of \(A_{2}\) and \(A_{3}\) depends on a value of the output data \(A_{1}.output\), but there are no overlaps (\(A_{2}\) is executed when \(A_{1}.output\) is less than 50 and \(A_{3}\) is executed when \(A_{1}.output\) is greater than or equal to 50), then there is an exclusive relationship between them. There is another possibility when only one condition is described, for example only exists the condition (\(A_{2}\) is executed when \(A_{1}.output\) is less than 50), in that case it means that there are two branches for the XOR gateway, but one of them with no activities. * **Inclusive**: two activities are executed in an inclusive way if there are conditions that relate the \(t_{ini}\) of both activities, and the domain of these conditions are complete and overlapped.