@@ -14,7 +14,7 @@ use crate::markup::{convert_from_jats, ConversionLimit, MarkupFormat};
1414use crate :: model:: {
1515 additional_resource:: { AdditionalResource , AdditionalResourceOrderBy } ,
1616 affiliation:: { Affiliation , AffiliationOrderBy } ,
17- award:: { Award , AwardOrderBy } ,
17+ award:: { Award , AwardOrderBy , AwardRole } ,
1818 biography:: { Biography , BiographyOrderBy } ,
1919 book_review:: { BookReview , BookReviewOrderBy } ,
2020 contact:: { Contact , ContactOrderBy , ContactType } ,
@@ -2224,6 +2224,11 @@ impl AdditionalResource {
22242224 self . url . as_ref ( )
22252225 }
22262226
2227+ #[ graphql( description = "Date associated with the additional resource" ) ]
2228+ pub fn date ( & self ) -> Option < NaiveDate > {
2229+ self . date
2230+ }
2231+
22272232 #[ graphql(
22282233 description = "Number representing this resource's position in an ordered list of resources within the work"
22292234 ) ]
@@ -2295,20 +2300,25 @@ impl Award {
22952300 self . category . as_ref ( )
22962301 }
22972302
2298- #[ graphql( description = "Additional note for this award" ) ]
2299- pub fn note (
2303+ #[ graphql( description = "Role of the work in this award" ) ]
2304+ pub fn role ( & self ) -> Option < AwardRole > {
2305+ self . role
2306+ }
2307+
2308+ #[ graphql( description = "Prize statement for this award" ) ]
2309+ pub fn prize_statement (
23002310 & self ,
23012311 #[ graphql(
23022312 default = MarkupFormat :: JatsXml ,
2303- description = "Markup format used for rendering note " ,
2313+ description = "Markup format used for rendering prize statement " ,
23042314 ) ]
23052315 markup_format : Option < MarkupFormat > ,
23062316 ) -> FieldResult < Option < String > > {
2307- self . note
2317+ self . prize_statement
23082318 . as_ref ( )
2309- . map ( |note | {
2319+ . map ( |prize_statement | {
23102320 convert_from_jats (
2311- note ,
2321+ prize_statement ,
23122322 markup_format. ok_or ( ThothError :: MissingMarkupFormat ) ?,
23132323 ConversionLimit :: Abstract ,
23142324 )
@@ -2365,6 +2375,18 @@ impl Endorsement {
23652375 self . author_role . as_ref ( )
23662376 }
23672377
2378+ #[ graphql(
2379+ description = "ORCID (Open Researcher and Contributor ID) of the endorsement author as full URL, using the HTTPS scheme and the orcid.org domain"
2380+ ) ]
2381+ pub fn author_orcid ( & self ) -> Option < & Orcid > {
2382+ self . author_orcid . as_ref ( )
2383+ }
2384+
2385+ #[ graphql( description = "Thoth ID of the endorsement author's institution" ) ]
2386+ pub fn author_institution_id ( & self ) -> Option < & Uuid > {
2387+ self . author_institution_id . as_ref ( )
2388+ }
2389+
23682390 #[ graphql( description = "URL associated with this endorsement" ) ]
23692391 pub fn url ( & self ) -> Option < & String > {
23702392 self . url . as_ref ( )
@@ -2413,6 +2435,15 @@ impl Endorsement {
24132435 pub fn work ( & self , context : & Context ) -> FieldResult < Work > {
24142436 Work :: from_id ( & context. db , & self . work_id ) . map_err ( Into :: into)
24152437 }
2438+
2439+ #[ graphql( description = "Get the endorsement author's institution" ) ]
2440+ pub fn author_institution ( & self , context : & Context ) -> FieldResult < Option < Institution > > {
2441+ self . author_institution_id
2442+ . as_ref ( )
2443+ . map ( |institution_id| Institution :: from_id ( & context. db , institution_id) )
2444+ . transpose ( )
2445+ . map_err ( Into :: into)
2446+ }
24162447}
24172448
24182449#[ juniper:: graphql_object(
@@ -2431,15 +2462,44 @@ impl BookReview {
24312462 }
24322463
24332464 #[ graphql( description = "Title of the review" ) ]
2434- pub fn title ( & self ) -> Option < & String > {
2435- self . title . as_ref ( )
2465+ pub fn title (
2466+ & self ,
2467+ #[ graphql(
2468+ default = MarkupFormat :: JatsXml ,
2469+ description = "Markup format used for rendering review title" ,
2470+ ) ]
2471+ markup_format : Option < MarkupFormat > ,
2472+ ) -> FieldResult < Option < String > > {
2473+ self . title
2474+ . as_ref ( )
2475+ . map ( |title| {
2476+ convert_from_jats (
2477+ title,
2478+ markup_format. ok_or ( ThothError :: MissingMarkupFormat ) ?,
2479+ ConversionLimit :: Title ,
2480+ )
2481+ } )
2482+ . transpose ( )
2483+ . map_err ( Into :: into)
24362484 }
24372485
24382486 #[ graphql( description = "Name of the review author" ) ]
24392487 pub fn author_name ( & self ) -> Option < & String > {
24402488 self . author_name . as_ref ( )
24412489 }
24422490
2491+ #[ graphql(
2492+ description = "ORCID (Open Researcher and Contributor ID) of the reviewer as full URL, using the HTTPS scheme and the orcid.org domain"
2493+ ) ]
2494+ pub fn reviewer_orcid ( & self ) -> Option < & Orcid > {
2495+ self . reviewer_orcid . as_ref ( )
2496+ }
2497+
2498+ #[ graphql( description = "Thoth ID of the reviewer's institution" ) ]
2499+ pub fn reviewer_institution_id ( & self ) -> Option < & Uuid > {
2500+ self . reviewer_institution_id . as_ref ( )
2501+ }
2502+
24432503 #[ graphql( description = "URL of the review publication" ) ]
24442504 pub fn url ( & self ) -> Option < & String > {
24452505 self . url . as_ref ( )
@@ -2477,6 +2537,11 @@ impl BookReview {
24772537 self . journal_issn . as_ref ( )
24782538 }
24792539
2540+ #[ graphql( description = "Page range of the review" ) ]
2541+ pub fn page_range ( & self ) -> Option < & String > {
2542+ self . page_range . as_ref ( )
2543+ }
2544+
24802545 #[ graphql( description = "Text of the review" ) ]
24812546 pub fn text (
24822547 & self ,
@@ -2520,6 +2585,15 @@ impl BookReview {
25202585 pub fn work ( & self , context : & Context ) -> FieldResult < Work > {
25212586 Work :: from_id ( & context. db , & self . work_id ) . map_err ( Into :: into)
25222587 }
2588+
2589+ #[ graphql( description = "Get the reviewer's institution" ) ]
2590+ pub fn reviewer_institution ( & self , context : & Context ) -> FieldResult < Option < Institution > > {
2591+ self . reviewer_institution_id
2592+ . as_ref ( )
2593+ . map ( |institution_id| Institution :: from_id ( & context. db , institution_id) )
2594+ . transpose ( )
2595+ . map_err ( Into :: into)
2596+ }
25232597}
25242598
25252599#[ juniper:: graphql_object(
0 commit comments