Skip to main content

ebi_objects/constants/
ebi_object.rs

1use crate::{
2    BusinessProcessModelAndNotation, EventLogPython, EventLogTraceAttributes,
3    PortableDocumentFormat, PortableNetworkGraphics, StochasticNondeterministicFiniteAutomaton,
4    constants::ebi_object_type::EbiObjectType,
5    ebi_objects::{
6        deterministic_finite_automaton::DeterministicFiniteAutomaton,
7        directly_follows_graph::DirectlyFollowsGraph, directly_follows_model::DirectlyFollowsModel,
8        event_log::EventLog, event_log_csv::EventLogCsv, event_log_ocel::EventLogOcel,
9        event_log_xes::EventLogXes, executions::Executions, finite_language::FiniteLanguage,
10        finite_stochastic_language::FiniteStochasticLanguage,
11        finite_stochastic_partially_ordered_language::FiniteStochasticPartiallyOrderedLanguage,
12        labelled_petri_net::LabelledPetriNet, language_of_alignments::LanguageOfAlignments,
13        process_tree::ProcessTree, scalable_vector_graphics::ScalableVectorGraphics,
14        stochastic_deterministic_finite_automaton::StochasticDeterministicFiniteAutomaton,
15        stochastic_directly_follows_model::StochasticDirectlyFollowsModel,
16        stochastic_labelled_petri_net::StochasticLabelledPetriNet,
17        stochastic_language_of_alignments::StochasticLanguageOfAlignments,
18        stochastic_process_tree::StochasticProcessTree,
19    },
20    traits::infoable::Infoable,
21};
22use anyhow::Result;
23#[cfg(any(test, feature = "testactivities"))]
24use ebi_activity_key::TestActivityKey;
25use ebi_bpmn::StochasticBusinessProcessModelAndNotation;
26use std::fmt::Display;
27
28#[derive(Clone)]
29pub enum EbiObject {
30    BusinessProcessModelAndNotation(BusinessProcessModelAndNotation),
31    StochasticBusinessProcessModelAndNotation(StochasticBusinessProcessModelAndNotation),
32    LabelledPetriNet(LabelledPetriNet),
33    StochasticLabelledPetriNet(StochasticLabelledPetriNet),
34    StochasticDeterministicFiniteAutomaton(StochasticDeterministicFiniteAutomaton),
35    StochasticNondeterministicFiniteAutomaton(StochasticNondeterministicFiniteAutomaton),
36    EventLog(EventLog),
37    EventLogCsv(EventLogCsv),
38    EventLogPython(EventLogPython),
39    EventLogTraceAttributes(EventLogTraceAttributes),
40    EventLogXes(EventLogXes),
41    EventLogOcel(EventLogOcel),
42    FiniteLanguage(FiniteLanguage),
43    FiniteStochasticLanguage(FiniteStochasticLanguage),
44    FiniteStochasticPartiallyOrderedLanguage(FiniteStochasticPartiallyOrderedLanguage),
45    DirectlyFollowsModel(DirectlyFollowsModel),
46    StochasticDirectlyFollowsModel(StochasticDirectlyFollowsModel),
47    LanguageOfAlignments(LanguageOfAlignments),
48    StochasticLanguageOfAlignments(StochasticLanguageOfAlignments),
49    DeterministicFiniteAutomaton(DeterministicFiniteAutomaton),
50    ProcessTree(ProcessTree),
51    StochasticProcessTree(StochasticProcessTree),
52    Executions(Executions),
53    DirectlyFollowsGraph(DirectlyFollowsGraph),
54    ScalableVectorGraphics(ScalableVectorGraphics),
55    PortableNetworkGraphics(PortableNetworkGraphics),
56    PortableDocumentFormat(PortableDocumentFormat),
57}
58
59impl EbiObject {
60    pub fn get_type(&self) -> EbiObjectType {
61        match self {
62            EbiObject::BusinessProcessModelAndNotation(_) => {
63                EbiObjectType::BusinessProcessModelAndNotation
64            }
65            EbiObject::StochasticBusinessProcessModelAndNotation(_) => {
66                EbiObjectType::StochasticBusinessProcessModelAndNotation
67            }
68            EbiObject::LabelledPetriNet(_) => EbiObjectType::LabelledPetriNet,
69            EbiObject::StochasticLabelledPetriNet(_) => EbiObjectType::StochasticLabelledPetriNet,
70            EbiObject::StochasticDeterministicFiniteAutomaton(_) => {
71                EbiObjectType::StochasticDeterministicFiniteAutomaton
72            }
73            EbiObject::StochasticNondeterministicFiniteAutomaton(_) => {
74                EbiObjectType::StochasticNondeterministicFiniteAutomaton
75            }
76            EbiObject::EventLog(_) => EbiObjectType::EventLog,
77            EbiObject::EventLogCsv(_) => EbiObjectType::EventLogCsv,
78            EbiObject::EventLogOcel(_) => EbiObjectType::EventLogOcel,
79            EbiObject::EventLogPython(_) => EbiObjectType::EventLogPython,
80            EbiObject::EventLogTraceAttributes(_) => EbiObjectType::EventLogTraceAttributes,
81            EbiObject::EventLogXes(_) => EbiObjectType::EventLogXes,
82            EbiObject::FiniteLanguage(_) => EbiObjectType::FiniteLanguage,
83            EbiObject::FiniteStochasticLanguage(_) => EbiObjectType::FiniteStochasticLanguage,
84            EbiObject::FiniteStochasticPartiallyOrderedLanguage(_) => {
85                EbiObjectType::FiniteStochasticPartiallyOrderedLanguage
86            }
87            EbiObject::DirectlyFollowsModel(_) => EbiObjectType::DirectlyFollowsModel,
88            EbiObject::StochasticDirectlyFollowsModel(_) => {
89                EbiObjectType::StochasticDirectlyFollowsModel
90            }
91            EbiObject::LanguageOfAlignments(_) => EbiObjectType::LanguageOfAlignments,
92            EbiObject::StochasticLanguageOfAlignments(_) => {
93                EbiObjectType::StochasticLanguageOfAlignments
94            }
95            EbiObject::DeterministicFiniteAutomaton(_) => {
96                EbiObjectType::DeterministicFiniteAutomaton
97            }
98            EbiObject::ProcessTree(_) => EbiObjectType::ProcessTree,
99            EbiObject::StochasticProcessTree(_) => EbiObjectType::StochasticProcessTree,
100            EbiObject::Executions(_) => EbiObjectType::Executions,
101            EbiObject::DirectlyFollowsGraph(_) => EbiObjectType::DirectlyFollowsGraph,
102            EbiObject::ScalableVectorGraphics(_) => EbiObjectType::ScalableVectorGraphics,
103            EbiObject::PortableDocumentFormat(_) => EbiObjectType::PortableDocumentFormat,
104            EbiObject::PortableNetworkGraphics(_) => EbiObjectType::PortableNetworkGraphics,
105        }
106    }
107}
108
109impl Display for EbiObject {
110    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
111        match self {
112            EbiObject::BusinessProcessModelAndNotation(o) => write!(f, "{}", o),
113            EbiObject::StochasticBusinessProcessModelAndNotation(o) => write!(f, "{}", o),
114            EbiObject::LabelledPetriNet(o) => write!(f, "{}", o),
115            EbiObject::StochasticLabelledPetriNet(o) => write!(f, "{}", o),
116            EbiObject::StochasticDeterministicFiniteAutomaton(o) => write!(f, "{}", o),
117            EbiObject::StochasticNondeterministicFiniteAutomaton(o) => write!(f, "{}", o),
118            EbiObject::EventLog(o) => write!(f, "{}", o),
119            EbiObject::EventLogCsv(o) => write!(f, "{}", o),
120            EbiObject::EventLogOcel(o) => write!(f, "{}", o),
121            EbiObject::EventLogPython(o) => write!(f, "{}", o),
122            EbiObject::EventLogTraceAttributes(o) => write!(f, "{}", o),
123            EbiObject::EventLogXes(o) => write!(f, "{}", o),
124            EbiObject::FiniteLanguage(o) => write!(f, "{}", o),
125            EbiObject::FiniteStochasticLanguage(o) => write!(f, "{}", o),
126            EbiObject::FiniteStochasticPartiallyOrderedLanguage(o) => write!(f, "{}", o),
127            EbiObject::DirectlyFollowsModel(o) => write!(f, "{}", o),
128            EbiObject::StochasticDirectlyFollowsModel(o) => write!(f, "{}", o),
129            EbiObject::LanguageOfAlignments(o) => write!(f, "{}", o),
130            EbiObject::StochasticLanguageOfAlignments(o) => write!(f, "{}", o),
131            EbiObject::DeterministicFiniteAutomaton(o) => write!(f, "{}", o),
132            EbiObject::ProcessTree(o) => write!(f, "{}", o),
133            EbiObject::StochasticProcessTree(o) => write!(f, "{}", o),
134            EbiObject::Executions(o) => write!(f, "{}", o),
135            EbiObject::DirectlyFollowsGraph(o) => write!(f, "{}", o),
136            EbiObject::ScalableVectorGraphics(o) => write!(f, "{}", o),
137            EbiObject::PortableDocumentFormat(o) => write!(f, "{}", o),
138            EbiObject::PortableNetworkGraphics(o) => write!(f, "{}", o),
139        }
140    }
141}
142
143impl Infoable for EbiObject {
144    fn info(&self, f: &mut impl std::io::Write) -> Result<()> {
145        match self {
146            EbiObject::BusinessProcessModelAndNotation(o) => o.info(f),
147            EbiObject::StochasticBusinessProcessModelAndNotation(o) => o.info(f),
148            EbiObject::LabelledPetriNet(o) => o.info(f),
149            EbiObject::StochasticLabelledPetriNet(o) => o.info(f),
150            EbiObject::StochasticDeterministicFiniteAutomaton(o) => o.info(f),
151            EbiObject::StochasticNondeterministicFiniteAutomaton(o) => o.info(f),
152            EbiObject::EventLog(o) => o.info(f),
153            EbiObject::EventLogCsv(o) => o.info(f),
154            EbiObject::EventLogOcel(o) => o.info(f),
155            EbiObject::EventLogPython(o) => o.info(f),
156            EbiObject::EventLogTraceAttributes(o) => o.info(f),
157            EbiObject::EventLogXes(o) => o.info(f),
158            EbiObject::FiniteLanguage(o) => o.info(f),
159            EbiObject::FiniteStochasticLanguage(o) => o.info(f),
160            EbiObject::FiniteStochasticPartiallyOrderedLanguage(o) => o.info(f),
161            EbiObject::DirectlyFollowsModel(o) => o.info(f),
162            EbiObject::StochasticDirectlyFollowsModel(o) => o.info(f),
163            EbiObject::LanguageOfAlignments(o) => o.info(f),
164            EbiObject::StochasticLanguageOfAlignments(o) => o.info(f),
165            EbiObject::DeterministicFiniteAutomaton(o) => o.info(f),
166            EbiObject::ProcessTree(o) => o.info(f),
167            EbiObject::StochasticProcessTree(o) => o.info(f),
168            EbiObject::Executions(o) => o.info(f),
169            EbiObject::DirectlyFollowsGraph(o) => o.info(f),
170            EbiObject::ScalableVectorGraphics(o) => o.info(f),
171            EbiObject::PortableDocumentFormat(o) => o.info(f),
172            EbiObject::PortableNetworkGraphics(o) => o.info(f),
173        }
174    }
175}
176
177#[cfg(any(test, feature = "testactivities"))]
178impl TestActivityKey for EbiObject {
179    fn test_activity_key(&self) {
180        match self {
181            EbiObject::BusinessProcessModelAndNotation(o) => o.test_activity_key(),
182            EbiObject::StochasticBusinessProcessModelAndNotation(o) => o.test_activity_key(),
183            EbiObject::LabelledPetriNet(o) => o.test_activity_key(),
184            EbiObject::StochasticLabelledPetriNet(o) => o.test_activity_key(),
185            EbiObject::StochasticDeterministicFiniteAutomaton(o) => o.test_activity_key(),
186            EbiObject::StochasticNondeterministicFiniteAutomaton(o) => o.test_activity_key(),
187            EbiObject::EventLog(o) => o.test_activity_key(),
188            EbiObject::EventLogCsv(o) => o.test_activity_key(),
189            EbiObject::EventLogOcel(o) => o.test_activity_key(),
190            EbiObject::EventLogPython(o) => o.test_activity_key(),
191            EbiObject::EventLogTraceAttributes(o) => o.test_activity_key(),
192            EbiObject::EventLogXes(o) => o.test_activity_key(),
193            EbiObject::FiniteLanguage(o) => o.test_activity_key(),
194            EbiObject::FiniteStochasticLanguage(o) => o.test_activity_key(),
195            EbiObject::FiniteStochasticPartiallyOrderedLanguage(o) => o.test_activity_key(),
196            EbiObject::DirectlyFollowsModel(o) => o.test_activity_key(),
197            EbiObject::StochasticDirectlyFollowsModel(o) => o.test_activity_key(),
198            EbiObject::LanguageOfAlignments(o) => o.test_activity_key(),
199            EbiObject::StochasticLanguageOfAlignments(o) => o.test_activity_key(),
200            EbiObject::DeterministicFiniteAutomaton(o) => o.test_activity_key(),
201            EbiObject::ProcessTree(o) => o.test_activity_key(),
202            EbiObject::StochasticProcessTree(o) => o.test_activity_key(),
203            EbiObject::Executions(o) => o.test_activity_key(),
204            EbiObject::DirectlyFollowsGraph(o) => o.test_activity_key(),
205            EbiObject::ScalableVectorGraphics(o) => o.test_activity_key(),
206            EbiObject::PortableNetworkGraphics(o) => o.test_activity_key(),
207            EbiObject::PortableDocumentFormat(o) => o.test_activity_key(),
208        }
209    }
210}