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