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::{
67    DomainReference, EnvironmentConnection, SharedResource, SystemReference, TableVisibility,
68    TransformationLink, Workspace,
69};
70
71// Decision and Knowledge models
72pub use decision::{
73    AssetLink, AssetRelationship, ComplianceAssessment, Decision, DecisionCategory, DecisionDriver,
74    DecisionIndex, DecisionIndexEntry, DecisionOption, DecisionStatus, DriverPriority,
75};
76pub use knowledge::{
77    ArticleRelationship, KnowledgeArticle, KnowledgeIndex, KnowledgeIndexEntry, KnowledgeStatus,
78    KnowledgeType, RelatedArticle, ReviewFrequency, SkillLevel,
79};
80pub use sketch::{Sketch, SketchIndex, SketchIndexEntry, SketchStatus, SketchType};
81
82use serde::{Deserialize, Serialize};
83
84/// Model type for references
85#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
86#[serde(rename_all = "PascalCase")]
87pub enum ModelType {
88    /// BPMN model
89    Bpmn,
90    /// DMN model
91    Dmn,
92    /// OpenAPI specification
93    OpenApi,
94}
95
96/// Model reference for CADS assets
97///
98/// Represents a reference from a CADS asset to a BPMN, DMN, or OpenAPI model.
99#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
100pub struct ModelReference {
101    /// Type of model being referenced
102    pub model_type: ModelType,
103    /// Target domain ID (None for same domain)
104    #[serde(skip_serializing_if = "Option::is_none")]
105    pub domain_id: Option<uuid::Uuid>,
106    /// Name of the referenced model
107    pub model_name: String,
108    /// Optional description of the reference
109    #[serde(skip_serializing_if = "Option::is_none")]
110    pub description: Option<String>,
111}
112
113impl ModelReference {
114    /// Create a new model reference
115    pub fn new(model_type: ModelType, model_name: String) -> Self {
116        ModelReference {
117            model_type,
118            domain_id: None,
119            model_name,
120            description: None,
121        }
122    }
123
124    /// Create a cross-domain model reference
125    pub fn new_cross_domain(
126        model_type: ModelType,
127        domain_id: uuid::Uuid,
128        model_name: String,
129    ) -> Self {
130        ModelReference {
131            model_type,
132            domain_id: Some(domain_id),
133            model_name,
134            description: None,
135        }
136    }
137}