Skip to content

Commit

Permalink
link entities
Browse files Browse the repository at this point in the history
  • Loading branch information
rruckley committed Oct 12, 2024
1 parent a4c49eb commit 3dc95e9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/tmf667/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use crate::{
};
use tmflib_derive::{HasId,HasName,HasLastUpdate,HasRelatedParty,HasDescription};
use crate::common::related_party::RelatedParty;
use crate::common::related_entity::RelatedEntity;
use crate::vec_insert;
use serde::{Deserialize,Serialize};

const CLASS_PATH : &str = "document";
Expand Down Expand Up @@ -56,7 +58,10 @@ pub struct Document {
#[serde(skip_serializing_if = "Option::is_none")]
creation_date: Option<DateTime>,
// Referenced objects
/// Parties
related_party: Option<Vec<RelatedParty>>,
/// Related Entities
related_entity : Option<Vec<RelatedEntity>>,
/// Attachement
attachment : AttachmentRefOrValue,
}
Expand Down Expand Up @@ -88,6 +93,17 @@ impl Document {
self.document_type = Some(r#type.into());
self
}

/// Link another TMF entity during creation
pub fn link<T : HasName>(mut self, entity : T) -> Document {
self.link_entity(entity);
self
}

/// Link another TMF entity into this document
pub fn link_entity<T : HasName>(&mut self, entity : T) {
vec_insert(&mut self.related_entity,RelatedEntity::from(entity));
}
}

impl From<AttachmentRefOrValue> for Document {
Expand Down

0 comments on commit 3dc95e9

Please sign in to comment.