Skip to main content

data_modelling_core/models/
mod.rs

1//! Models module for the SDK
2//!
3//! Defines core data structures used by the SDK for import/export operations.
4//! These models are simplified versions focused on the SDK's needs.
5
6#[cfg(feature = "bpmn")]
7pub mod bpmn;
8pub mod cads;
9pub mod column;
10pub mod cross_domain;
11pub mod data_model;
12pub mod decision;
13#[cfg(feature = "dmn")]
14pub mod dmn;
15pub mod domain;
16pub mod domain_config;
17pub mod enums;
18pub mod knowledge;
19pub mod odcs;
20pub mod odps;
21#[cfg(feature = "openapi")]
22pub mod openapi;
23pub mod relationship;
24pub mod sketch;
25pub mod table;
26pub mod tag;
27pub mod workspace;
28
29#[cfg(feature = "bpmn")]
30pub use bpmn::{BPMNModel, BPMNModelFormat};
31pub use cads::{
32    CADSAsset, CADSBPMNFormat, CADSBPMNModel, CADSCompliance, CADSComplianceControl,
33    CADSComplianceFramework, CADSComplianceStatus, CADSDMNFormat, CADSDMNModel, CADSDescription,
34    CADSExternalLink, CADSImpactArea, CADSKind, CADSMitigationStatus, CADSOpenAPIFormat,
35    CADSOpenAPISpec, CADSPricing, CADSPricingModel, CADSRisk, CADSRiskAssessment,
36    CADSRiskClassification, CADSRiskMitigation, CADSRuntime, CADSRuntimeContainer,
37    CADSRuntimeResources, CADSSLA, CADSSLAProperty, CADSStatus, CADSTeamMember,
38    CADSValidationProfile, CADSValidationProfileAppliesTo,
39};
40pub use column::{
41    AuthoritativeDefinition, Column, ForeignKey, LogicalTypeOptions, PropertyRelationship,
42};
43pub use cross_domain::{CrossDomainConfig, CrossDomainRelationshipRef, CrossDomainTableRef};
44pub use data_model::DataModel;
45#[cfg(feature = "dmn")]
46pub use dmn::{DMNModel, DMNModelFormat};
47pub use domain::{
48    CADSNode, CrowsfeetCardinality, Domain, NodeConnection, ODCSNode, SharedNodeReference, System,
49    SystemConnection,
50};
51pub use domain_config::{DomainConfig, DomainOwner, ViewPosition};
52pub use enums::*;
53pub use odps::{
54    ODPSApiVersion, ODPSAuthoritativeDefinition, ODPSCustomProperty, ODPSDataProduct,
55    ODPSDescription, ODPSInputContract, ODPSInputPort, ODPSManagementPort, ODPSOutputPort,
56    ODPSSBOM, ODPSStatus, ODPSSupport, ODPSTeam, ODPSTeamMember,
57};
58#[cfg(feature = "openapi")]
59pub use openapi::{OpenAPIFormat, OpenAPIModel};
60pub use relationship::{
61    ConnectionHandle, ConnectionPoint, ETLJobMetadata, ForeignKeyDetails, Relationship,
62    VisualMetadata,
63};
64pub use table::{ContactDetails, Position, SlaProperty, Table};
65pub use tag::Tag;
66pub use workspace::{DomainReference, Workspace};
67
68// Decision and Knowledge models
69pub use decision::{
70    AssetLink, AssetRelationship, ComplianceAssessment, Decision, DecisionCategory, DecisionDriver,
71    DecisionIndex, DecisionIndexEntry, DecisionOption, DecisionStatus, DriverPriority,
72};
73pub use knowledge::{
74    ArticleRelationship, KnowledgeArticle, KnowledgeIndex, KnowledgeIndexEntry, KnowledgeStatus,
75    KnowledgeType, RelatedArticle, ReviewFrequency, SkillLevel,
76};
77pub use sketch::{Sketch, SketchIndex, SketchIndexEntry, SketchStatus, SketchType};
78
79use serde::{Deserialize, Serialize};
80
81/// Model type for references
82#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
83#[serde(rename_all = "PascalCase")]
84pub enum ModelType {
85    /// BPMN model
86    Bpmn,
87    /// DMN model
88    Dmn,
89    /// OpenAPI specification
90    OpenApi,
91}
92
93/// Model reference for CADS assets
94///
95/// Represents a reference from a CADS asset to a BPMN, DMN, or OpenAPI model.
96#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
97pub struct ModelReference {
98    /// Type of model being referenced
99    pub model_type: ModelType,
100    /// Target domain ID (None for same domain)
101    #[serde(skip_serializing_if = "Option::is_none")]
102    pub domain_id: Option<uuid::Uuid>,
103    /// Name of the referenced model
104    pub model_name: String,
105    /// Optional description of the reference
106    #[serde(skip_serializing_if = "Option::is_none")]
107    pub description: Option<String>,
108}
109
110impl ModelReference {
111    /// Create a new model reference
112    pub fn new(model_type: ModelType, model_name: String) -> Self {
113        ModelReference {
114            model_type,
115            domain_id: None,
116            model_name,
117            description: None,
118        }
119    }
120
121    /// Create a cross-domain model reference
122    pub fn new_cross_domain(
123        model_type: ModelType,
124        domain_id: uuid::Uuid,
125        model_name: String,
126    ) -> Self {
127        ModelReference {
128            model_type,
129            domain_id: Some(domain_id),
130            model_name,
131            description: None,
132        }
133    }
134}