-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 from rruckley/TMF634-179
TMF634 Additional schema
- Loading branch information
Showing
4 changed files
with
185 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
//! Resource Catalog Module | ||
use serde::{Deserialize,Serialize}; | ||
|
||
const CLASS_PATH : &str = "catalog"; | ||
|
||
use super::MOD_PATH; | ||
|
||
use crate::{ | ||
LIB_PATH, | ||
HasId, | ||
HasName, | ||
HasValidity, | ||
HasLastUpdate, | ||
HasDescription, | ||
Uri, | ||
DateTime, | ||
TimePeriod, | ||
}; | ||
|
||
use tmflib_derive::{ | ||
HasId, | ||
HasName, | ||
HasLastUpdate, | ||
HasDescription, | ||
HasValidity, | ||
}; | ||
|
||
/// Resource Catalog structure | ||
#[derive(Clone,Default,Debug,Deserialize,HasId,HasName,HasLastUpdate,HasDescription,HasValidity,Serialize)] | ||
pub struct Catalog { | ||
/// Cataloge Type | ||
pub catalog_type : Option<String>, | ||
/// Cataloge Description | ||
pub description: Option<String>, | ||
/// HTTP Reference | ||
pub href: Option<Uri>, | ||
/// Unique Identier | ||
pub id: Option<String>, | ||
/// Last Update | ||
pub last_update: Option<DateTime>, | ||
/// Lifecycle status | ||
pub lifecycle_status: Option<String>, | ||
/// Name | ||
pub name: Option<String>, | ||
/// Validity | ||
pub valid_for: Option<TimePeriod>, | ||
/// Version | ||
pub version: Option<String>, | ||
} | ||
|
||
impl Catalog { | ||
/// Create a new catalog | ||
pub fn new(name : impl Into<String>) -> Catalog { | ||
Catalog { | ||
name : Some(name.into()), | ||
..Catalog::create() | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::Catalog; | ||
use crate::HasDescription; | ||
|
||
const CATALOG_NAME : &str = "CatalogueName"; | ||
const CATALOG_DESC : &str = "CatalogueDescription"; | ||
|
||
#[test] | ||
fn test_catalog_description() { | ||
let catalog = Catalog::new(CATALOG_NAME) | ||
.description(CATALOG_DESC); | ||
|
||
assert_eq!(catalog.description.is_some(),true); | ||
assert_eq!(catalog.get_description().as_str(),CATALOG_DESC); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
//! Resource Category Module | ||
/// Resource Catagory Structure | ||
pub struct ResourceCategory {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
//! Resource Specification Module | ||
use serde::{Deserialize,Serialize}; | ||
use crate::{ | ||
DateTime, | ||
HasDescription, | ||
HasId, | ||
HasLastUpdate, | ||
HasName, | ||
HasValidity, | ||
TimePeriod, | ||
Uri, | ||
LIB_PATH | ||
}; | ||
|
||
use tmflib_derive::{ | ||
HasId, | ||
HasName, | ||
HasDescription, | ||
HasLastUpdate, | ||
HasValidity | ||
}; | ||
|
||
use crate::common::attachment::AttachmentRefOrValue; | ||
use crate::common::external_identifier::ExternalIdentifier; | ||
|
||
use super::MOD_PATH; | ||
|
||
const CLASS_PATH: &str = "resourceSpecification"; | ||
|
||
/// Resource Specification | ||
#[derive(Clone,Default,Debug,Deserialize,HasId,HasName,HasDescription,HasLastUpdate,HasValidity,Serialize)] | ||
pub struct ResourceSpecification { | ||
/// Resource Specification Category | ||
pub category: Option<String>, | ||
/// Description | ||
pub description: Option<String>, | ||
/// Uri for this specification | ||
pub href: Option<Uri>, | ||
/// Unique Id of this specification | ||
pub id: Option<String>, | ||
/// Is this part of a bundle? | ||
pub is_bundle : bool, | ||
/// When was this recort last updated | ||
pub last_update: Option<DateTime>, | ||
/// Current lifecycle status | ||
pub lifecycle_status : Option<String>, | ||
/// Name of the specification | ||
pub name : Option<String>, | ||
/// Validity for this specification | ||
pub valid_for: Option<TimePeriod>, | ||
// Referenced types | ||
/// Attachments | ||
pub attachment : Vec<AttachmentRefOrValue>, | ||
/// External identifiers | ||
pub external_identifier : Vec<ExternalIdentifier>, | ||
/// Features | ||
pub feature : Vec<FeatureSpecification>, | ||
} | ||
|
||
impl ResourceSpecification { | ||
/// Create a new specification with the given name | ||
pub fn new(name : impl Into<String>) -> ResourceSpecification { | ||
ResourceSpecification { | ||
name : Some(name.into()), | ||
lifecycle_status : Some(String::from("New")), | ||
..ResourceSpecification::create_with_time() | ||
} | ||
} | ||
} | ||
|
||
/// Feature Specification for Resource | ||
#[derive(Clone,Default,Debug,Deserialize,Serialize)] | ||
pub struct FeatureSpecification { | ||
/// Specificaiton Relationships | ||
pub feature_spec_relationship : Vec<FeatureSpecificationRelationship> | ||
} | ||
|
||
/// Specification Relationship Type | ||
#[derive(Clone,Default,Debug,Deserialize,Serialize)] | ||
pub struct FeatureSpecificationRelationship {} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::*; | ||
|
||
const SPEC_NAME : &str = "SpecificationName"; | ||
|
||
#[test] | ||
fn test_resourcespecification_new() { | ||
let spec = ResourceSpecification::new(SPEC_NAME); | ||
|
||
assert_eq!(spec.name.is_some(),true); | ||
assert_eq!(spec.get_name().as_str(),SPEC_NAME); | ||
} | ||
} |