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