caselawclient.models.press_summaries
1from __future__ import annotations 2 3import importlib 4from functools import cached_property 5from typing import TYPE_CHECKING, Any, Optional 6 7from ds_caselaw_utils.types import NeutralCitationString 8 9from caselawclient.errors import DocumentNotFoundError 10from caselawclient.identifier_resolution import IdentifierResolutions 11from caselawclient.models.neutral_citation_mixin import NeutralCitationMixin 12from caselawclient.types import DocumentURIString 13 14from .documents import Document 15 16if TYPE_CHECKING: 17 from caselawclient.models.judgments import Judgment 18 19 20class PressSummary(NeutralCitationMixin, Document): 21 """ 22 Represents a press summary document. 23 """ 24 25 document_noun = "press summary" 26 document_noun_plural = "press summaries" 27 type_collection_name = "press-summary" 28 _default_reparse_document_type = "pressSummary" 29 30 def __init__(self, uri: DocumentURIString, *args: Any, **kwargs: Any) -> None: 31 super().__init__(self.document_noun, uri, *args, **kwargs) 32 33 @cached_property 34 def neutral_citation(self) -> Optional[NeutralCitationString]: 35 value_in_xml = self.body.get_xpath_match_string( 36 "/akn:akomaNtoso/akn:doc/akn:preface/akn:p/akn:neutralCitation/text()", 37 { 38 "akn": "http://docs.oasis-open.org/legaldocml/ns/akn/3.0", 39 }, 40 ) 41 if value_in_xml: 42 return NeutralCitationString(value_in_xml) 43 return None 44 45 @cached_property 46 def linked_document(self) -> Optional[Judgment]: 47 """ 48 Attempt to fetch a linked judgement, and return it, if it exists 49 """ 50 try: 51 uri = DocumentURIString(self.uri.removesuffix("/press-summary/1")) 52 if not TYPE_CHECKING: # This isn't nice, but will be cleaned up when we refactor how related documents work 53 Judgment = importlib.import_module("caselawclient.models.judgments").Judgment 54 return Judgment(uri, self.api_client) 55 except DocumentNotFoundError: 56 return None 57 58 def linked_judgments(self, only_published: bool = True) -> "IdentifierResolutions": 59 return self.linked_document_resolutions(["ukncn"], only_published)
class
PressSummary(caselawclient.models.neutral_citation_mixin.NeutralCitationMixin, caselawclient.models.documents.Document):
21class PressSummary(NeutralCitationMixin, Document): 22 """ 23 Represents a press summary document. 24 """ 25 26 document_noun = "press summary" 27 document_noun_plural = "press summaries" 28 type_collection_name = "press-summary" 29 _default_reparse_document_type = "pressSummary" 30 31 def __init__(self, uri: DocumentURIString, *args: Any, **kwargs: Any) -> None: 32 super().__init__(self.document_noun, uri, *args, **kwargs) 33 34 @cached_property 35 def neutral_citation(self) -> Optional[NeutralCitationString]: 36 value_in_xml = self.body.get_xpath_match_string( 37 "/akn:akomaNtoso/akn:doc/akn:preface/akn:p/akn:neutralCitation/text()", 38 { 39 "akn": "http://docs.oasis-open.org/legaldocml/ns/akn/3.0", 40 }, 41 ) 42 if value_in_xml: 43 return NeutralCitationString(value_in_xml) 44 return None 45 46 @cached_property 47 def linked_document(self) -> Optional[Judgment]: 48 """ 49 Attempt to fetch a linked judgement, and return it, if it exists 50 """ 51 try: 52 uri = DocumentURIString(self.uri.removesuffix("/press-summary/1")) 53 if not TYPE_CHECKING: # This isn't nice, but will be cleaned up when we refactor how related documents work 54 Judgment = importlib.import_module("caselawclient.models.judgments").Judgment 55 return Judgment(uri, self.api_client) 56 except DocumentNotFoundError: 57 return None 58 59 def linked_judgments(self, only_published: bool = True) -> "IdentifierResolutions": 60 return self.linked_document_resolutions(["ukncn"], only_published)
Represents a press summary document.
PressSummary( uri: caselawclient.types.DocumentURIString, *args: Any, **kwargs: Any)
31 def __init__(self, uri: DocumentURIString, *args: Any, **kwargs: Any) -> None: 32 super().__init__(self.document_noun, uri, *args, **kwargs)
Parameters
- uri: The URI of the document to retrieve from MarkLogic.
- api_client: An instance of the API client object to handle communication with the MarkLogic server.
- search_query: Optionally, a search string which should be highlighted if it appears in the document body.
Raises
- DocumentNotFoundError: The document does not exist within MarkLogic
neutral_citation: Optional[ds_caselaw_utils.types.NeutralCitationString]
34 @cached_property 35 def neutral_citation(self) -> Optional[NeutralCitationString]: 36 value_in_xml = self.body.get_xpath_match_string( 37 "/akn:akomaNtoso/akn:doc/akn:preface/akn:p/akn:neutralCitation/text()", 38 { 39 "akn": "http://docs.oasis-open.org/legaldocml/ns/akn/3.0", 40 }, 41 ) 42 if value_in_xml: 43 return NeutralCitationString(value_in_xml) 44 return None
linked_document: Optional[caselawclient.models.judgments.Judgment]
46 @cached_property 47 def linked_document(self) -> Optional[Judgment]: 48 """ 49 Attempt to fetch a linked judgement, and return it, if it exists 50 """ 51 try: 52 uri = DocumentURIString(self.uri.removesuffix("/press-summary/1")) 53 if not TYPE_CHECKING: # This isn't nice, but will be cleaned up when we refactor how related documents work 54 Judgment = importlib.import_module("caselawclient.models.judgments").Judgment 55 return Judgment(uri, self.api_client) 56 except DocumentNotFoundError: 57 return None
Attempt to fetch a linked judgement, and return it, if it exists
def
linked_judgments( self, only_published: bool = True) -> caselawclient.identifier_resolution.IdentifierResolutions:
Inherited Members
- caselawclient.models.neutral_citation_mixin.NeutralCitationMixin
- attributes_to_validate
- has_ncn
- has_valid_ncn
- caselawclient.models.documents.Document
- uri
- api_client
- body
- document_exists
- docx_exists
- best_human_identifier
- public_uri
- slug
- is_published
- is_held
- is_locked
- checkout_message
- source_name
- source_email
- consignment_reference
- docx_url
- pdf_url
- assigned_to
- versions
- versions_as_documents
- version_number
- is_version
- is_failure
- is_parked
- has_name
- has_valid_court
- is_publishable
- first_published_datetime
- first_published_datetime_display
- has_ever_been_published
- validation_failure_messages
- annotation
- structured_annotation
- has_unique_content_hash
- has_only_clean_assets
- version_created_datetime
- status
- force_enrich
- enrich
- enriched_recently
- validates_against_schema
- assign_fclid_if_missing
- publish
- unpublish
- hold
- unhold
- safe_to_delete
- delete
- move
- force_reparse
- reparse
- can_reparse
- can_enrich
- validate_identifiers
- save_identifiers
- linked_document_resolutions
- linked_documents
- content_as_html
- xml_with_correct_frbr
- compare_to