pub struct DataModel {Show 13 fields
pub id: Uuid,
pub name: String,
pub description: Option<String>,
pub git_directory_path: String,
pub tables: Vec<Table>,
pub relationships: Vec<Relationship>,
pub domains: Vec<Domain>,
pub control_file_path: String,
pub diagram_file_path: Option<String>,
pub is_subfolder: bool,
pub parent_git_directory: Option<String>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
Data model representing a complete data model with tables and relationships
A DataModel is a container for a collection of tables and their relationships.
It represents a workspace or domain within a larger data modeling system.
§Example
use data_modelling_core::models::DataModel;
let model = DataModel::new(
"MyModel".to_string(),
"/path/to/git".to_string(),
"control.yaml".to_string(),
);Fields§
§id: UuidUnique identifier for the model (UUIDv5 based on name and path)
name: StringModel name
description: Option<String>Optional description of the model
git_directory_path: StringPath to the Git repository directory
tables: Vec<Table>Tables in this model
relationships: Vec<Relationship>Relationships between tables
domains: Vec<Domain>Business domains in this model
control_file_path: StringPath to the control file (relationships.yaml)
diagram_file_path: Option<String>Path to diagram file if applicable
is_subfolder: boolWhether this model is in a subfolder
parent_git_directory: Option<String>Parent Git directory if this is a subfolder
created_at: DateTime<Utc>Creation timestamp
updated_at: DateTime<Utc>Last update timestamp
Implementations§
Source§impl DataModel
impl DataModel
Sourcepub fn new(
name: String,
git_directory_path: String,
control_file_path: String,
) -> Self
pub fn new( name: String, git_directory_path: String, control_file_path: String, ) -> Self
Create a new data model with the given name and paths
§Arguments
name- The model namegit_directory_path- Path to the Git repository directorycontrol_file_path- Path to the control file (typically “relationships.yaml”)
§Returns
A new DataModel instance with a UUIDv5 ID (deterministic based on name and path)
and current timestamps.
§Example
use data_modelling_core::models::DataModel;
let model = DataModel::new(
"MyModel".to_string(),
"/workspace/models".to_string(),
"relationships.yaml".to_string(),
);Sourcepub fn get_table_by_id(&self, table_id: Uuid) -> Option<&Table>
pub fn get_table_by_id(&self, table_id: Uuid) -> Option<&Table>
Sourcepub fn get_table_by_id_mut(&mut self, table_id: Uuid) -> Option<&mut Table>
pub fn get_table_by_id_mut(&mut self, table_id: Uuid) -> Option<&mut Table>
Sourcepub fn get_table_by_name(&self, name: &str) -> Option<&Table>
pub fn get_table_by_name(&self, name: &str) -> Option<&Table>
Sourcepub fn get_table_by_unique_key(
&self,
database_type: Option<&str>,
name: &str,
catalog_name: Option<&str>,
schema_name: Option<&str>,
) -> Option<&Table>
pub fn get_table_by_unique_key( &self, database_type: Option<&str>, name: &str, catalog_name: Option<&str>, schema_name: Option<&str>, ) -> Option<&Table>
Get a table by its unique key (database_type, name, catalog, schema)
§Arguments
database_type- Optional database typename- Table namecatalog_name- Optional catalog nameschema_name- Optional schema name
§Returns
A reference to the table if found, None otherwise.
§Example
// Find table in specific schema
let table = model.get_table_by_unique_key(
Some("PostgreSQL"),
"users",
Some("mydb"),
Some("public"),
);Sourcepub fn get_relationships_for_table(&self, table_id: Uuid) -> Vec<&Relationship>
pub fn get_relationships_for_table(&self, table_id: Uuid) -> Vec<&Relationship>
Get all relationships involving a specific table
§Arguments
table_id- The UUID of the table
§Returns
A vector of references to relationships where the table is either the source or target.
§Example
// Get all relationships for a table
let relationships = model.get_relationships_for_table(table_id);Sourcepub fn filter_nodes_by_owner(&self, owner: &str) -> Vec<&Table>
pub fn filter_nodes_by_owner(&self, owner: &str) -> Vec<&Table>
Sourcepub fn filter_relationships_by_owner(&self, owner: &str) -> Vec<&Relationship>
pub fn filter_relationships_by_owner(&self, owner: &str) -> Vec<&Relationship>
Sourcepub fn filter_nodes_by_infrastructure_type(
&self,
infra_type: InfrastructureType,
) -> Vec<&Table>
pub fn filter_nodes_by_infrastructure_type( &self, infra_type: InfrastructureType, ) -> Vec<&Table>
Sourcepub fn filter_relationships_by_infrastructure_type(
&self,
infra_type: InfrastructureType,
) -> Vec<&Relationship>
pub fn filter_relationships_by_infrastructure_type( &self, infra_type: InfrastructureType, ) -> Vec<&Relationship>
Filter Data Flow relationships by infrastructure type
§Arguments
infra_type- The infrastructure type to filter by
§Returns
A vector of references to relationships matching the infrastructure type.
§Example
let kafka_relationships = model.filter_relationships_by_infrastructure_type(InfrastructureType::Kafka);Sourcepub fn add_domain(&mut self, domain: Domain)
pub fn add_domain(&mut self, domain: Domain)
Sourcepub fn get_domain_by_id(&self, domain_id: Uuid) -> Option<&Domain>
pub fn get_domain_by_id(&self, domain_id: Uuid) -> Option<&Domain>
Sourcepub fn get_domain_by_id_mut(&mut self, domain_id: Uuid) -> Option<&mut Domain>
pub fn get_domain_by_id_mut(&mut self, domain_id: Uuid) -> Option<&mut Domain>
Sourcepub fn get_domain_by_name(&self, name: &str) -> Option<&Domain>
pub fn get_domain_by_name(&self, name: &str) -> Option<&Domain>
Sourcepub fn add_system_to_domain(
&mut self,
domain_id: Uuid,
system: System,
) -> Result<(), String>
pub fn add_system_to_domain( &mut self, domain_id: Uuid, system: System, ) -> Result<(), String>
Add a system to a domain
§Arguments
domain_id- The UUID of the domainsystem- The system to add
§Returns
Ok(()) if the domain was found and the system was added, Err otherwise.
§Example
let system = System::new("kafka-cluster".to_string(), InfrastructureType::Kafka, domain_id);
model.add_system_to_domain(domain_id, system).unwrap();