An intelligent contract automatic generation method for BPMN collaboration diagrams
By performing error detection of data flow and control flow on the BPMN collaboration graph, and converting it into a CSP# model for compilation, smart contracts are generated, and the problem that the existing technology cannot handle the BPMN collaboration graph and guarantee the quality of the model is solved, and the correct implementation of the smart contract is achieved.
Patent Information
- Application Number
- CN202210278384.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-21
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2042-03-21
AI Technical Summary
The prior art cannot effectively process the BPMN collaboration graph and cannot guarantee the quality of the graph model, resulting in the generated smart contracts that may not be implemented accurately.
By obtaining the BPMN collaborative graph model, data flow error detection and control flow error detection are performed, converted into a formal model based on CSP#, and formal model compilation is performed to generate smart contracts.
It solves the problem that the existing technology cannot act on BPMN collaborative graphs and cannot guarantee the quality of the graphical model, and ensures that the generated smart contracts meet the requirements and can be implemented correctly.
Smart Images

Figure CN114610319B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of smart contracts, and more specifically, to a method for automatically generating smart contracts for BPMN collaboration diagrams. Background Art
[0002] As a research focus in the field of business process management, collaborative business processes refer to business processes that cross the boundaries of a single organization and are shared by multiple participants, namely enterprises or organizations. It enables participants from different organizations in a distributed environment to achieve business goals through communication and interaction, and has emerged along with the development of e-commerce, virtual organizations, and extended enterprises.
[0003] BPMN, that is, Business Process Model and Notation, is a graphical modeling language for business processes proposed by the Object Management Group and is the current modeling standard. The latest version is v2.0.2. It can model business processes from different perspectives, such as individual business process diagrams, choreography diagrams, etc. Among them, the collaboration diagram is often used to model collaborative business processes.
[0004] Blockchain is a technology for processing decentralized and transactional data sharing on a distributed network. Since it is tamper-proof, the executed logging will not be disputed due to possible forgery by participants or third parties.
[0005] The collaborative business process based on blockchain converts the BPMN model into a smart contract that can be executed in a blockchain environment, which is used to coordinate and record the task execution and interaction information of participants. This enables it to provide a complete process audit trail of transactional data, which is very important for participants who do not have sufficient trust in each other.
[0006] Currently, existing research on smart contract generation mainly focuses on two different technical methods, namely directly converting the BPMN model into a smart contract, simply referred to as the direct generation method, and converting the BPMN model into a smart contract through an intermediate carrier form, simply referred to as the intermediate carrier generation method.
[0007] The direct generation method directly translates model elements into corresponding smart contract codes by analyzing the composition and structural characteristics of the graphical model. It has the characteristics of intuitiveness and simplicity. The intermediate carrier generation method first equivalently converts the graphical model into an intermediate carrier, which is usually in a formalized form with strict semantics. Then, the intermediate carrier is analyzed, and the formalized carrier is reduced through equivalent simulation and other methods. Finally, the simplified formal carrier is converted into a smart contract. Compared with the direct generation method, this type of method can reduce the execution cost of smart contracts.
[0008] The existing technical solutions have deficiencies in the following two aspects.
[0009] Firstly, in terms of the graphical model type. The current methods focus on traditional BPMN business process diagrams or BPMN choreography diagrams, without considering BPMN collaboration diagrams. In fact, in the current increasingly competitive business environment, multiple organizations / enterprises do not exist in isolation, but need to cooperate with each other to achieve common business goals, which has become one of the current mainstream trends. Collaboration diagrams play an important role in modeling such collaborative business process scenarios and are an indispensable model in the BPMN standard diagrams.
[0010] Secondly, in terms of the quality of the graphical model. The existing methods either focus on directly converting graphical model elements one-to-one into smart contracts or on simplifying smart contracts. They ignore the problem of unqualified graphical model quality, such as deadlocks in control flow and data flow errors in data flow. In practice, the quality of the graphical models designed by users is uneven, and it is difficult to ensure that the graphical models are 100% qualified. Without identification, unqualified graphical models will result in smart contracts that do not meet expectations. This will affect the correct implementation of blockchain-based collaborative business processes.
[0011] For example, the prior art discloses an optimized method for generating smart contract templates. This solution first converts the BPMN model diagram into a Petri net (a formal model). Then it analyzes the composition structure of the Petri net and simplifies the Petri net. Finally, it translates the simplified model into a smart contract. This solution has the following deficiencies:
[0012] Firstly, it does not support collaborative business processes and only considers the business processes within a single organization. This limits the application of this solution in the scenario of cross-organizational enterprise collaboration.
[0013] Secondly, it uses the Petri net, a formal modeling language, as an intermediate carrier. Although this formal language has strict semantics and corresponding analysis techniques, its support for communication and interaction in a distributed environment is insufficient. This also makes it unable to well meet the modeling requirements for communication and interaction in cross-organizational collaborative business processes.
[0014] Thirdly, it does not consider the situation when the model quality does not meet the requirements. That is, when there are problems in the BPMN model design, such as in control flow (deadlocks) and data flow (data flow errors), this solution cannot identify the problematic models in advance. In a practical environment, the quality of the graphical models designed by modelers cannot be ensured to be 100% qualified, which may result in the inaccurate implementation of smart contracts generated based on these graphical models.
[0015] Therefore, how to invent an intelligent contract automatic generation method for BPMN collaboration diagrams that can act on BPMN collaboration diagrams and ensure the quality of their graphical models is an urgent problem to be solved in this technical field. Summary of the Invention
[0016] In order to solve the problems that the existing technology cannot act on BPMN collaboration diagrams and cannot ensure the quality of their graphical models, the present invention provides an intelligent contract automatic generation method for BPMN collaboration diagrams, which considers the quality problem of graphical models, can identify unqualified models in advance, and provides a guarantee for generating intelligent contracts that meet the requirements.
[0017] In order to achieve the above object of the present invention, the following technical solutions are adopted:
[0018] An intelligent contract automatic generation method for BPMN collaboration diagrams includes the following specific steps:
[0019] S1. Obtain a BPMN collaboration diagram model;
[0020] S2. Perform data flow error detection on the BPMN collaboration diagram model. If it is determined that there is no error in the data flow, proceed to the next step; otherwise, modify the BPMN collaboration diagram model and repeat this step;
[0021] S3. Convert the BPMN collaboration diagram model that has passed the data flow error detection into a formal model based on CSP#;
[0022] S4. Perform control flow error detection on the formal model. If it is determined that there is no error in the control flow, proceed to the next step; otherwise, modify the BPMN collaboration diagram model and return to step S2;
[0023] S5. Compile the formal model that has passed the control flow error detection and obtain the logical dependency relationship of the elements in the formal model;
[0024] S6. Generate an intelligent contract according to the obtained logical dependency relationship of the model elements.
[0025] Preferably, the participants of the BPMN collaboration diagram model include several nodes, and the data model of each node is a 4-tuple: DM = (Input, Output, ContentSet, CorrelationSet), where Input is the input data of the node, Output is the output data of the node, and ContentSet is the content data of the message associated with the node.
[0026] Furthermore, when compiling the formal model, define the association relationships between the elements in the collaboration diagram model as 6 types: sequential Next, termination End, initial Init, parallel And, exclusive or Xor, enable Enable.
[0027] Furthermore, the data flow error detection is performed using three collaborative business process data flow error patterns, which respectively include:
[0028] Pattern 1: Through the formula: Determine whether there is an error of unable to send messages in the collaborative business process of the control flow of the BPMN collaboration diagram model, where n represents a node, BP represents a participant, Send(BP) represents the node used to send messages in the participant BP, Input(n) represents the input data of the node n, Output(n): represents the output data of the node n, ContentSet(n) represents the content data of the message associated with the node n, CorrelationSet(n): the correlation data of the message associated with the node n; if it is detected that there is an error of unable to send messages, it is determined that there is an error in the data flow;
[0029] Pattern 2: Through the formula: Determine whether there is an error of unable to receive messages in the collaborative business process of the control flow of the BPMN collaboration diagram model, where Receive(BP) represents the node used to send messages in the participant BP; if it is detected that there is an error of unable to receive messages, it is determined that there is an error in the data flow;
[0030] Pattern 3: Through the formula: Determine whether there is an error of unable to match the correct message in the collaborative business process of the control flow of the BPMN collaboration diagram model, where Rmsg(n) represents the message received by the node n, and CorrelationData(m) represents the correlation data of the specific message m; if it is detected that there is an error of unable to match the correct message, it is determined that there is an error in the data flow.
[0031] Furthermore, the conversion logic for converting the BPMN collaboration diagram model after data flow error detection into a formal model based on CSP#: Starting from the start node:
[0032] When encountering a send task node or a receive task node, map the send task node content and the receive task node content to CSP# message events and CSP# message channels;
[0033] When encountering an exclusive gateway, traverse all branches of the exclusive gateway, obtain the task elements on the branch until encountering the connection mode point corresponding to the exclusive gateway. If there are other gateways on the branch, recursively process, map the task elements to CSP# message events and CSP# message channels, and map the exclusive gateway to the CSP# general selection logical symbol;
[0034] When encountering a parallel gateway, traverse all branches of the parallel gateway, obtain the task elements on the branches until the connection mode point corresponding to the parallel gateway is encountered. If other gateways are included on the branches, process recursively. Map the task elements to CSP# message events and CSP# message channels, and map the parallel gateway to the CSP# parallel logical operator;
[0035] When encountering an event-based gateway, traverse all branches of the event-based gateway, obtain the task elements on the branches until the connection mode point corresponding to the event-based gateway is encountered. If other gateways are included on the branches, process recursively. Map the task elements to CSP# message events and CSP# message channels, and map the event-based gateway to the CSP# external selection logical operator;
[0036] When encountering an end node, end the transformation.
[0037] Furthermore, the control flow error detection is used to verify whether there are errors in the obtained formal model in terms of control flow, including whether there is deadlock; detecting whether there is deadlock is detected through the following formula:
[0038]
[0039] Among them, C represents the collaborative business process, deadlockfree means that there is no deadlock for the corresponding participants, and |ch| represents the number of remaining message events in the channel ch; if it is detected that there is deadlock, it is determined that there is an error in the control flow.
[0040] Furthermore, step S5 is specifically: traverse the formal model through the ternary tree method, parse out the logical dependency relationship of the formal model elements, and compile the formal model: the ternary tree is a logical tree composed of multiple nodes, and each node in the ternary tree includes a left node, a middle node, and a right node.
[0041] Furthermore, the specific method of traversing the formal model through the ternary tree method is:
[0042] A1. If the middle node of the node is a semicolon representing sequence, the left node is the initial node Init, and the right node is the next execution node Next of the left node. When the right node finishes execution, then the entire node will also finish End;
[0043] A2. If the middle node of the node is a parallel symbol, then both the left node and the right node are the initial nodes Init+And. When both the left node and the right node are all completed And, the node will also finish End;
[0044] A3. If the middle node of a node is an exclusive OR symbol, then the left node or the right node is the initial node Init+Xor, and when the left node or the right node finishes Xor, the node will also finish End;
[0045] A4. If the middle node of a node is an exclamation mark symbol, the node will perform the action of sending a message, triggering the enablement relationship Enable;
[0046] A5. If the middle node of a node is a question mark symbol, the node will perform the action of receiving a message, passively receiving the enablement relationship Enable.
[0047] Furthermore, the smart contract is generated based on a contract template, and the contract template includes the execution of a formal model and its corresponding call requests. The execution of the formal model has 4 execution states, including: Disabled, Waiting, Executing, Done.
[0048] Furthermore, the call requests include three core call requests, namely:
[0049] R1. Initial request: The initial request sets the process state to the Waiting state accessible by external requests by initializing the state of all initial processes from the Disabled state.
[0050] R2. Exit request: The exit request ends all affected participant processes according to the End relationship.
[0051] R3. External request: The external request triggers a state change by invoking the initial request and the exit request through an association relationship. At the same time, the external request also forwards the message to the receiver to enable the state of the receiving task.
[0052] The beneficial effects of the present invention are as follows:
[0053] The present invention solves the problems that the prior art cannot act on the BPMN collaboration diagram and cannot guarantee the quality of its graphical model by converting the BPMN collaboration diagram model detected for data flow errors into a formal model based on CSP#, respectively detecting the control flow errors and data errors of the formal model, and performing formal model compilation on the obtained formal model to generate a smart contract. Moreover, considering the quality problem of the graphical model, it can identify unqualified models in advance, providing a guarantee for generating smart contracts that meet the requirements. Description of the Drawings
[0054] Figure 1It is a schematic flow diagram of the intelligent contract automatic generation method for BPMN collaboration diagrams.
[0055] Figure 2 It is a schematic diagram of the modeling elements of the BPMN collaboration diagram model in the intelligent contract automatic generation method for BPMN collaboration diagrams.
[0056] Figure 3 It is a schematic diagram of the ternary tree in Embodiment 3.
[0057] Figure 4 It is a schematic diagram of the model relationship of the compiled CSP# model in Embodiment 3
[0058] Figure 5 It is a schematic diagram of the interaction relationship between the process state and the request in the intelligent contract generation Specific implementation manners
[0059] The present invention will be described in detail below in conjunction with the accompanying drawings and specific implementation manners.
[0060] Embodiment 1
[0061] As Figure 1 shown, an intelligent contract automatic generation method for BPMN collaboration diagrams includes the following specific steps:
[0062] S1. Obtain the BPMN collaboration diagram model;
[0063] S2. Perform data flow error detection on the BPMN collaboration diagram model. If it is determined that there is no error in the data flow, proceed to the next step; otherwise, modify the BPMN collaboration diagram model and repeat this step;
[0064] S3. Convert the BPMN collaboration diagram model that has passed the data flow error detection into a formal model based on CSP#;
[0065] S4. Perform control flow error detection on the formal model. If it is determined that there is no error in the control flow, proceed to the next step; otherwise, modify the BPMN collaboration diagram model and return to step S2;
[0066] S5. Compile the formal model that has passed the control flow error detection and obtain the logical dependency relationship of the elements in the formal model;
[0067] S6. Generate an intelligent contract according to the obtained logical dependency relationship of the model elements.
[0068] Embodiment 2
[0069] As Figure 1 shown, an intelligent contract automatic generation method for BPMN collaboration diagrams includes the following specific steps:
[0070] S1. Obtain the BPMN collaboration diagram model;
[0071] S2. Perform data flow error detection on the BPMN collaboration diagram model. If it is determined that there is no error in the data flow, proceed to the next step; otherwise, modify the BPMN collaboration diagram model and repeat this step;
[0072] S3. Convert the BPMN collaboration diagram model that has passed the data flow error detection into a formal model based on CSP#;
[0073] S4. Perform control flow error detection on the formal model. If it is determined that there is no error in the control flow, proceed to the next step; otherwise, modify the BPMN collaboration diagram model and return to step S2;
[0074] S5. Compile the formal model that has passed the control flow error detection and obtain the logical dependency relationship of the elements in the formal model;
[0075] S6. Generate a smart contract according to the obtained logical dependency relationship of the model elements.
[0076] In a specific embodiment, the participants in the BPMN collaboration diagram model include several nodes, and the data model of each node is a 4-tuple: DM = (Input, Output, ContentSet, CorrelationSet), where Input is the input data of the node, Output is the output data of the node, and ContentSet is the content data of the message associated with the node.
[0077] In a specific embodiment, when compiling the formal model, the association relationships between the elements in the collaboration diagram model are defined as 6 types: sequential Next, termination End, initial Init, parallel And, exclusive or Xor, and enable Enable.
[0078] In a specific embodiment, the data flow error detection is performed using 3 collaborative business process data flow error patterns, including:
[0079] Pattern 1: Through the formula: Determine whether there is an error in the collaborative business process of the control flow of the BPMN collaboration diagram model where n represents a node, BP represents a participant, Send(BP) represents the node in the participant BP used to send a message, Input(n) represents the input data of the node n, Output(n): represents the output data of the node n, ContentSet(n) represents the content data of the message associated with the node n, and CorrelationSet(n): represents the association data of the message associated with the node n; if it is detected that there is an error in sending a message, it is determined that there is an error in the data flow;
[0080] Mode 2: Through the formula: Determine whether there is an error of unable to receive messages in the collaborative business process of the control flow of the BPMN collaboration diagram model, where Receive(BP) represents the node used to send messages in the participant BP; if it is detected that there is an error of unable to receive messages, it is determined that there is an error in the data flow;
[0081] Mode 3: Through the formula: Determine whether there is an error of unable to match the correct message in the collaborative business process of the control flow of the BPMN collaboration diagram model, where Rmsg(n) represents the message received by node n, and CorrelationData(m) represents the correlation data of a specific message m; if it is detected that there is an error of unable to match the correct message, it is determined that there is an error in the data flow.
[0082] As Figure 2 shown, in a specific embodiment, the conversion logic for converting the BPMN collaboration diagram model after data flow error detection into a formal model based on CSP#: Starting from the start node:
[0083] When encountering a send task node or a receive task node, map the content of the send task node and the content of the receive task node to CSP# message events and CSP# message channels;
[0084] When encountering an exclusive gateway, traverse all branches of the exclusive gateway, obtain the task elements on the branches until encountering the connection mode point corresponding to the exclusive gateway. If other gateways are included on the branches, recursively process, map the task elements to CSP# message events and CSP# message channels, and map the exclusive gateway to the CSP# general selection logical symbol;
[0085] When encountering a parallel gateway, traverse all branches of the parallel gateway, obtain the task elements on the branches until encountering the connection mode point corresponding to the parallel gateway. If other gateways are included on the branches, recursively process, map the task elements to CSP# message events and CSP# message channels, and map the parallel gateway to the CSP# parallel logical symbol;
[0086] When encountering an event-based gateway, traverse all branches of the event-based gateway, obtain the task elements on the branches until encountering the connection mode point corresponding to the event-based gateway. If other gateways are included on the branches, recursively process, map the task elements to CSP# message events and CSP# message channels, and map the event-based gateway to the CSP# external selection logical symbol;
[0087] When encountering an end node, end the conversion.
[0088] In this embodiment, a brief description of the CSP# formal language grammar is as follows:
[0089] P ::= SKIP P is a process. SKIP represents a process that terminates successfully
[0090] | STOP represents a deadlock process
[0091] | a -> P means first execute a, and then run in the manner specified by process P. a can also be regarded as for communication purposes, that is, a ::= event | event.x | c!m | c?m, where event.x represents a composite event, c!m represents sending message m through channel c, and c?m represents receiving message m through channel c
[0092] | P;Q Both P and Q are processes, indicating that P and Q form a sequential composition. P is executed first, and then Q is executed
[0093] | P || Q represents a parallel process combination with barrier synchronization
[0094] | P |||| Q represents a parallel process combination without barrier synchronization
[0095] | P [] Q represents a general selection, either P or Q is executed
[0096] | P [*] Q represents an external selection, triggered by an external event to execute either P or Q
[0097] | p <> Q represents an internal selection, triggered by an internal event to execute either P or Q
[0098] |||| i:{0..n} @ P | ifb {P} else {Q} represents n parallel processes P, and i represents the serial number. ifb {P} else {Q} means that when b is true, process P is executed, otherwise process Q is executed. b is a boolean expression
[0099] In this embodiment, the mapping relationship between the core elements of the BPMN collaboration diagram and the CSP# model is as follows:
[0100]
[0101] In this embodiment, the formal model after the transformation of the Broker in the collaboration diagram is:
[0102] Broker() = cMB?SupplierOrder -> Skip;(cBS!TurnSupplierOrder -> Skip || cBC!TransportOrder -> Skip);
[0103] In this embodiment, the formal model first receives the message SupplierOrder through the channel cMB, and then performs parallel operations, sending the messages SupplierOrder and TransportOrder through the channels cBS and cBC respectively, which is equivalent to the BPMN collaboration diagram graphical model.
[0104] In a specific embodiment, the control flow error detection is used to verify whether there are errors in the obtained formal model in terms of control flow, which includes whether there is deadlock; a collaborative business process has no deadlock if and only if any participant process involved in the collaboration has no deadlock and there are no undelivered messages among the participants. This ensures that there is no deadlock in the process within each participant and there is no redundancy and congestion in all messages. Whether there is deadlock is detected by the following formula:
[0105]
[0106] where C represents the collaborative business process, deadlockfree represents that the corresponding participant has no deadlock, and |ch| represents the number of remaining message events in the channel ch; if it is detected that there is deadlock, it is determined that there is an error in the control flow.
[0107] In this embodiment, the detection result finds that there is a deadlock problem, which occurs in the exclusive gateway of Carrier and the event-based gateway of Supplier. The message collaboration and interaction between them trigger deadlock due to design errors. The counterexample leading to deadlock is as follows:
[0108] <init->cWM! ProductOrder -> cWM? ProductOrder -> cMB! SupplierOrder -> cMB? SupplierOrder -> cBC! TransportOrder -> cBC? TransportOrder -> cCS! DeliveryRequest -> cBS! TurnSupplierOrder -> cBS? TurnSupplierOrder -> cCS? DeliveryRequest -> cCS! Confirmation -> cCS? Confirmation -> cCS! DeclarationForm>.
[0109] Example 3
[0110] As Figure 1 shown, an intelligent contract automatic generation method for a BPMN collaboration diagram includes the following specific steps:
[0111] S1. Obtain the BPMN collaboration diagram model;
[0112] S2. Perform data flow error detection on the BPMN collaboration diagram model. If it is determined that there is no error in the data flow, proceed to the next step; otherwise, modify the BPMN collaboration diagram model and repeat this step;
[0113] S3. Convert the BPMN collaboration diagram model that has passed the data flow error detection into a formal model based on CSP#;
[0114] S4. Perform control flow error detection on the formal model. If it is determined that there is no error in the control flow, proceed to the next step; otherwise, modify the BPMN collaboration diagram model and return to step S2;
[0115] S5. Compile the formal model that has passed the control flow error detection and obtain the logical dependency relationship of the elements in the formal model;
[0116] S6. Generate an intelligent contract according to the obtained logical dependency relationship of the model elements.
[0117] In a specific embodiment, the participants in the BPMN collaboration diagram model include several nodes, and the data model of each node is a 4-tuple: DM = (Input, Output, ContentSet, CorrelationSet), where Input is the input data of the node, Output is the output data of the node, and ContentSet is the content data of the message associated with the node.
[0118] In a specific embodiment, when compiling the formal model, the association relationships between the elements in the collaboration diagram model are defined as six types: sequential Next, termination End, initial Init, parallel And, exclusive-or Xor, and enablement Enable.
[0119] In a specific embodiment, the data flow error detection is performed using three collaborative business process data flow error patterns, which respectively include:
[0120] Pattern 1: By the formula: Determine whether there is an error of unable to send messages in the collaborative business process of the control flow of the BPMN collaboration diagram model, where n represents a node, BP represents a participant, Send(BP) represents the node in the participant BP for sending messages, Input(n) represents the input data of the node n, Output(n) represents the output data of the node n, ContentSet(n) represents the content data of the message associated with the node n, and CorrelationSet(n) represents the correlation data of the message associated with the node n; if it is detected that there is an error of unable to send messages, it is determined that the data flow has an error;
[0121] Pattern 2: By the formula: Determine whether there is an error of unable to receive messages in the collaborative business process of the control flow of the BPMN collaboration diagram model, where Receive(BP) represents the node in the participant BP for sending messages; if it is detected that there is an error of unable to receive messages, it is determined that the data flow has an error;
[0122] Pattern 3: By the formula: Determine whether there is an error of unable to match the correct message in the collaborative business process of the control flow of the BPMN collaboration diagram model, where Rmsg(n) represents the message received by the node n, and CorrelationData(m) represents the correlation data of a specific message m; if it is detected that there is an error of unable to match the correct message, it is determined that the data flow has an error.
[0123] In a specific embodiment, the conversion logic for converting the BPMN collaboration diagram model after data flow error detection into a formal model based on CSP#: Starting from the start node:
[0124] When encountering a send task node or a receive task node, map the content of the send task node and the content of the receive task node to a CSP# message event and a CSP# message channel;
[0125] When encountering an exclusive gateway, traverse all branches of the exclusive gateway, obtain the task elements on the branches until the connection mode point corresponding to the exclusive gateway is encountered. If other gateways are included on the branches, recursively process, map the task elements to CSP# message events and CSP# message channels, and map the exclusive gateway to the CSP# general selection logical operator;
[0126] When encountering a parallel gateway, traverse all branches of the parallel gateway, obtain the task elements on the branches until the connection mode point corresponding to the parallel gateway is encountered. If other gateways are included on the branches, recursively process, map the task elements to CSP# message events and CSP# message channels, and map the parallel gateway to the CSP# parallel logical operator;
[0127] When encountering an event-based gateway, traverse all branches of the event-based gateway, obtain the task elements on the branches until the connection mode point corresponding to the event-based gateway is encountered. If other gateways are included on the branches, recursively process, map the task elements to CSP# message events and CSP# message channels, and map the event-based gateway to the CSP# external selection logical operator;
[0128] When encountering an end node, end the transformation. In a specific embodiment, step S3 is specifically: through the formula Detect whether there is a deadlock in each participant process in the collaborative business process of the BPMN collaboration diagram model after data flow error detection, where C represents the collaborative business process, deadlockfree represents that there is no deadlock in the corresponding participant, and |ch| represents the number of remaining message events in the channel ch (in the form of a queue); if it is detected that there is a deadlock, it is determined that there is an error in the control flow.
[0129] In a specific embodiment, step S5 is specifically: traverse the formal model through the ternary tree method, parse out the logical dependency relationship of the formal model elements, and compile the formal model: the ternary tree is a logical tree composed of multiple nodes, and each node in the ternary tree includes a left node, a middle node, and a right node, that is, (left_tree_node, middle_tree_node, right_tree_node), where left_tree_node is the left node, middle_tree_node is the middle node, and right_tree_node is the right node.
[0130] In a specific embodiment, the specific method of traversing the formal model through the ternary tree method is:
[0131] A1. If the middle node of a node is a semicolon ";" indicating sequence, then the left node is the initial node Init, and the right node is the next execution node Next of the left node. When the right node finishes execution, the entire node will also finish End;
[0132] A2. If the middle node of a node is a parallel symbol "||", then both the left node and the right node are the initial nodes Init + And. When both the left node and the right node are all completed And, the node will also finish End;
[0133] A3. If the middle node of a node is an exclusive OR symbol "[]", then either the left node or the right node is the initial node Init + Xor, and when either the left node or the right node is completed Xor, the node will also finish End;
[0134] A4. If the middle node of a node is an exclamation mark "!", the node will perform the action of sending a message, triggering the enablement relationship Enable;
[0135] A5. If the middle node of a node is a question mark "?", the node will perform the action of receiving a message, passively receiving the enablement relationship Enable.
[0136] As Figure 3 shown in a specific embodiment, the leaf nodes of a ternary tree corresponding to an example of a formal model, from left to right, are combined together to form the formal model corresponding to the collaboration diagram. That is:
[0137] Broker() = cMB? SupplierOrder -> Skip; (cBS! TurnSupplierOrder -> Skip || cBC! TransportOrder -> Skip);
[0138] As Figure 4 shown, by traversing, the following relationships between model elements are obtained:
[0139] Init(Broker) = [P1], which means that when the Broker formal model starts, P1 will be executed first. Next(P1) = [P2], which means that when P1 is completed, P2 can start, and there is a sequential relationship between them. End(P2) = [Broker], which means that when P2 is completed, it triggers the end of the Broker model. P2 has two initial processes because it contains a parallel operator, that is, Init(P2) = [P3, P4]. Only when both P3 and P4 are ended can P2 end: this situation involves three relationships: End(P3) = [P2], End(P4) = [P2], and And(P2) = [P3, P4]. In addition to observing the internal relationships in Broker, whether P1 (responsible for receiving messages, question mark?) can be executed also depends on the enabling relationship of external participants, that is, Enable(external participants) = [P1], because it requires the external participants to complete the message sending first. Correspondingly, both P3 and P4 are sending tasks (exclamation mark!), and they will trigger the enabling relationship with external participants.
[0140] As Figure 5 shown, in a specific embodiment, the smart contract is generated based on a contract template, and the contract template includes the execution of the formal model and its corresponding call requests. The execution of the formal model has 4 execution states, including: Disabled indicating that the process is in a silent state and not allowed to execute, Waiting indicating that the process is enabled and waiting to execute, Executing indicating that the process is executing, and Done indicating that the execution of the process has been completed and has exited the execution state.
[0141] In a specific embodiment, the call requests include three core call requests, which are respectively:
[0142] R1. Initial request: The initial request sets the state of all initial processes from the Disabled state to the Waiting state that can be accessed by external requests through the initial request.
[0143] R2. Exit request: The exit request ends all affected participant processes according to the End relationship.
[0144] R3. External request: The external request calls the initial request and the exit request through the association relationship to trigger a state change. At the same time, the external request also forwards the message to the receiver to enable the state of the receiving task.
[0145] In this embodiment, the algorithm of the initial request is as follows:
[0146]
[0147]
[0148] In this embodiment, the algorithm of the exit request is as follows:
[0149]
[0150]
[0151] In this embodiment, the algorithm of the external request is as follows:
[0152]
[0153]
[0154] The present invention converts the obtained BPMN collaboration diagram model into a formal model based on CSP# through 6 association relationships and a ternary tree traversal method, and respectively defines the control flow error and data error for detecting the formal model; compiles the obtained formal model to obtain the logical dependency relationship of the formal model elements; and then generates a smart contract according to the logical dependency relationship of the formal model elements through 4 execution states and 3 core call requests. Thus, the problems that the prior art cannot act on the BPMN collaboration diagram and cannot guarantee the quality of its graphical model are solved, and the quality problem of the graphical model is considered, and unqualified models can be identified in advance, providing a guarantee for generating smart contracts that meet the requirements.
[0155] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, rather than limiting the embodiments of the present invention. Any modifications, equivalent replacements, and improvements made within the spirit and principle of the present invention shall be included in the protection scope of the claims of the present invention.
Claims
1. An intelligent contract automatic generation method for BPMN collaboration diagrams, characterized in that: It includes the following specific steps: S1. Obtain the BPMN collaboration diagram model; S2. Perform data flow error detection on the BPMN collaboration diagram model. If it is determined that there is no error in the data flow, proceed to the next step; otherwise, modify the BPMN collaboration diagram model and repeat this step; S3. Convert the BPMN collaboration diagram model that has passed the data flow error detection into a formal model based on CSP#; the data flow error detection is performed using 3 collaborative business process data flow error patterns, including respectively: Mode 1: Through the formula: Determine whether there is an error in which a message cannot be sent in the collaborative business process of the control flow of the BPMN collaboration diagram model, where n represents a node, BP represents a participant, Send(BP) represents the node used to send messages in the participant BP, Input(n) represents the input data of the node n, Output(n): represents the output data of the node n, ContentSet(n) represents the content data of the message associated with the node n, and CorrelationSet(n): represents the correlation data of the message associated with the node n; if it is detected that there is an error in which a message cannot be sent, it is determined that there is an error in the data flow; Mode 2: Through the formula: Determine whether there is an error of unable to receive messages in the collaborative business process of the control flow of the BPMN collaboration diagram model, where Receive(BP) represents the node used to send messages in the participant BP; if it is detected that there is an error of unable to receive messages, it is determined that there is an error in the data flow; Mode 3: Through the formula: Determine whether there is an error in the collaborative business process of the control flow of the BPMN collaboration diagram model where the correct message cannot be matched. Here, Rmsg(n) represents the message received by node n, and CorrelationData(m) represents the correlation data of a specific message m; if it is detected that there is an error in which the correct message cannot be matched, it is determined that there is an error in the data flow. The conversion logic for converting the BPMN collaboration diagram model that has passed the data flow error detection into a formal model based on CSP#: Starting from the start node: When encountering a send task node or a receive task node, map the content of the send task node and the content of the receive task node to a CSP# message event and a CSP# message channel; When encountering an exclusive gateway, traverse all branches of the exclusive gateway, obtain the task elements on the branch until the connection mode point corresponding to the exclusive gateway is encountered. If other gateways are included on the branch, recursively process, map the task elements to a CSP# message event and a CSP# message channel, and map the exclusive gateway to a CSP# general selection logical operator; When encountering a parallel gateway, traverse all branches of the parallel gateway, obtain the task elements on the branch until the connection mode point corresponding to the parallel gateway is encountered. If other gateways are included on the branch, recursively process, map the task elements to a CSP# message event and a CSP# message channel, and map the parallel gateway to a CSP# parallel logical operator; When encountering an event-based gateway, traverse all branches of the event-based gateway, obtain the task elements on the branch until the connection mode point corresponding to the event-based gateway is encountered. If other gateways are included on the branch, recursively process, map the task elements to a CSP# message event and a CSP# message channel, and map the event-based gateway to a CSP# external selection logical operator; When encountering an end node, end the conversion; S4. Perform control flow error detection on the formal model. If it is determined that there is no error in the control flow, proceed to the next step; otherwise, modify the BPMN collaboration diagram model and return to step S2; S5. Compile the formal model that has passed the control flow error detection and obtain the logical dependency relationship of the elements in the formal model; S6. Generate a smart contract according to the obtained logical dependency relationship of the model elements.
2. The method for automatically generating an intelligent contract for a BPMN collaboration diagram according to claim 1, characterized in that: The participants in the BPMN collaboration diagram model include several nodes, and the data model of each node is a 4-tuple: DM = (Input, Output, ContentSet, CorrelationSet), where Input is the input data of the node, Output is the output data of the node, and ContentSet is the content data of the message associated with the node.
3. The method for automatically generating an intelligent contract for a BPMN collaboration diagram according to claim 1, characterized in that: When compiling the formal model, define the association relationships between the elements in the collaboration diagram model as 6 types: sequential Next, termination End, initial Init, parallel And, exclusive or Xor, enable Enable.
4. The intelligent contract automatic generation method for BPMN collaboration diagrams according to claim 1, characterized in that: The control flow error detection is used to verify whether there are errors in the obtained formal model in terms of control flow, including whether there is a deadlock; detecting whether there is a deadlock is detected by the following formula: Where C represents the collaborative business process, deadlockfree indicates that there is no deadlock for the corresponding participant, and |ch| represents the number of remaining message events in the channel ch; if it is detected that there is a deadlock, it is determined that there is an error in the control flow.
5. The method for automatically generating an intelligent contract for a BPMN collaboration diagram according to claim 3, characterized in that: Step S5 is specifically as follows: traverse the formal model through the ternary tree method, parse out the logical dependency relationship of the formal model elements, and compile the formal model: the ternary tree is a logical tree composed of multiple nodes, and each node in the ternary tree contains a left node, a middle node, and a right node.
6. The method for automatically generating an intelligent contract for a BPMN collaboration diagram according to claim 5, wherein: The specific method of traversing the formal model through the ternary tree method is as follows: A1. If the middle node of the node is a semicolon representing sequence, then the left node is the initial node Init, and the right node is the next execution node Next of the left node. When the right node finishes execution, then the entire node will also finish End; A2. If the middle node of the node is a parallel symbol, then both the left node and the right node are the initial nodes Init+And. When both the left node and the right node are all completed And, the node will also finish End; A3. If the middle node of the node is an exclusive or symbol, then either the left node or the right node is the initial node Init+Xor, and when either the left node or the right node is completed Xor, the node will also finish End; A4. If the middle node of the node is an exclamation mark symbol, the node will perform the action of sending a message, triggering the enabling relationship Enable; A5. If the middle node of the node is a question mark symbol, the node will perform the action of receiving a message, passively receiving the enabling relationship Enable.
7. The method for automatically generating an intelligent contract for a BPMN collaboration diagram according to claim 1, wherein: The smart contract is generated based on a contract template. The contract template includes the execution of the formal model and its corresponding call requests. The execution of the formal model has 4 execution states, including: Disabled, Waiting, Executing, and Done.
8. The method for automatically generating an intelligent contract for a BPMN collaboration diagram according to claim 7, wherein: The call requests include three core call requests, namely: R1. Initial request: The initial request initializes the state of all initial processes from the Disabled state to the Waiting state that can be accessed by external requests by the initial request; R2. Exit request: The exit request ends all affected participant processes according to the End relationship; R3. External request: The external request triggers a state change by calling the initial request and the exit request through an association relationship. At the same time, the external request also forwards the message to the receiver to enable the state of the receiving task.
Citation Information
Patent Citations
Method and system for mining concurrency of BPMN (Business Process Modeling Notation) compilation process
CN106920034A
Systems and Methods for Generating Trust Federation Data from BPMN Choreography
US20130145419A1