BPMN-OS
BPMN for optimization and simulation
Loading...
Searching...
No Matches
DataProvider.cpp
Go to the documentation of this file.
1#include "DataProvider.h"
3
4using namespace BPMNOS::Model;
5
6DataProvider::DataProvider(const std::string& modelFile, const std::vector<std::string>& folders)
7 : model(std::make_unique<Model>(modelFile, folders))
8{
9 // determine all global attributes
10 attributes[nullptr] = {};
11 for ( auto& attribute : model->attributes ) {
12 attributes[nullptr].emplace(attribute->id,attribute.get());
13 }
14
15 // determine all attributes of all processes
16 for ( auto& process : model->processes ) {
17 // get all nodes in process with attribute definition
18 std::vector< BPMN::Node* > nodes = process->find_all(
19 [](BPMN::Node* node) {
20 if ( node->extensionElements ) {
21 if ( node->extensionElements->represents<BPMNOS::Model::ExtensionElements>() ) {
22 return true;
23 }
24 }
25 return false;
26 }
27 );
28
29 attributes[process.get()] = {};
30 // add all attributes of process
31 for ( auto& node : nodes ) {
32 auto extensionElements = node->extensionElements->as<BPMNOS::Model::ExtensionElements>();
33 // add all status attributes
34 for ( auto& attribute : extensionElements->attributes ) {
35 attributes[process.get()].emplace(attribute->id,attribute.get());
36 }
37 // add all data attributes
38 for ( auto& attribute : extensionElements->data ) {
39 attributes[process.get()].emplace(attribute->id,attribute.get());
40 }
41
42 // add all guiding attributes
43 if ( extensionElements->entryGuidance.has_value() ) {
44 for ( auto& attribute : extensionElements->entryGuidance.value()->attributes ) {
45 attributes[process.get()].emplace(attribute->id,attribute.get());
46 }
47 }
48 if ( extensionElements->exitGuidance.has_value() ) {
49 for ( auto& attribute : extensionElements->exitGuidance.value()->attributes ) {
50 attributes[process.get()].emplace(attribute->id,attribute.get());
51 }
52 }
53 if ( extensionElements->choiceGuidance.has_value() ) {
54 for ( auto& attribute : extensionElements->choiceGuidance.value()->attributes ) {
55 attributes[process.get()].emplace(attribute->id,attribute.get());
56 }
57 }
58 if ( extensionElements->messageDeliveryGuidance.has_value() ) {
59 for ( auto& attribute : extensionElements->messageDeliveryGuidance.value()->attributes ) {
60 attributes[process.get()].emplace(attribute->id,attribute.get());
61 }
62 }
63 }
64 }
65
66}
67
69
71 return *model;
72}
DataInput attributes
Map holding all attributes in the model with keys being the process (or nullptr for global attributes...
DataProvider(const std::string &modelFile, const std::vector< std::string > &folders)
Constructor for DataProvider.
const Model & getModel() const
std::unique_ptr< Model > model
Pointer to the BPMN model.
Class holding extension elements representing execution data for nodes.
Represents a BPMN model with all its processes.
Definition Model.h:21
STL namespace.