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