ds-caselaw-marklogic-api-client 27.3.0__tar.gz → 28.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ds-caselaw-marklogic-api-client might be problematic. Click here for more details.
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/PKG-INFO +1 -1
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/pyproject.toml +1 -1
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/Client.py +40 -2
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/factories.py +2 -2
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/documents/__init__.py +28 -7
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/documents/exceptions.py +4 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/judgments.py +7 -6
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/press_summaries.py +7 -6
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/utilities/__init__.py +2 -2
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_components_for_document.xqy +1 -1
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_pending_enrichment_for_version.xqy +13 -7
- ds_caselaw_marklogic_api_client-28.0.0/src/caselawclient/xquery/get_recently_enriched.xqy +18 -0
- ds_caselaw_marklogic_api_client-28.0.0/src/caselawclient/xquery/get_recently_parsed.xqy +19 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/LICENSE.md +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/README.md +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/__init__.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/client_helpers/__init__.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/client_helpers/search_helpers.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/content_hash.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/errors.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/__init__.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/documents/body.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/documents/statuses.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/documents/transforms/html.xsl +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/documents/xml.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/neutral_citation_mixin.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/utilities/aws.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/utilities/dates.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/utilities/move.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/py.typed +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/responses/__init__.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/responses/search_response.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/responses/search_result.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/responses/xsl/search_match.xsl +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/search_parameters.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xml_helpers.py +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/break_judgment_checkout.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/checkin_judgment.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/checkout_judgment.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/copy_document.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/delete_judgment.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/document_collections.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/document_exists.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_combined_stats_table.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_highest_enrichment_version.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_highest_parser_version.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_judgment.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_judgment_checkout_status.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_judgment_version.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_last_modified.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_pending_parse_for_version.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_properties_for_search_results.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_property.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_version_annotation.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_version_created.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/insert_document.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/list_judgment_versions.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_boolean_property.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_metadata_citation.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_metadata_court.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_metadata_jurisdiction.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_metadata_name.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_metadata_this_uri.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_metadata_work_expression_date.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_property.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/update_document.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/update_locked_judgment.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/user_has_privilege.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/user_has_role.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/validate_all_documents.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/validate_document.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/xslt.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/xslt_transform.xqy +0 -0
- {ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery_type_dicts.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ds-caselaw-marklogic-api-client
|
|
3
|
-
Version:
|
|
3
|
+
Version: 28.0.0
|
|
4
4
|
Summary: An API client for interacting with the underlying data in Find Caselaw.
|
|
5
5
|
Home-page: https://github.com/nationalarchives/ds-caselaw-custom-api-client
|
|
6
6
|
Keywords: national archives,caselaw
|
{ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/pyproject.toml
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "ds-caselaw-marklogic-api-client"
|
|
3
|
-
version = "
|
|
3
|
+
version = "28.0.0"
|
|
4
4
|
description = "An API client for interacting with the underlying data in Find Caselaw."
|
|
5
5
|
authors = ["The National Archives"]
|
|
6
6
|
homepage = "https://github.com/nationalarchives/ds-caselaw-custom-api-client"
|
|
@@ -62,6 +62,8 @@ except importlib.metadata.PackageNotFoundError:
|
|
|
62
62
|
VERSION = "0"
|
|
63
63
|
DEFAULT_USER_AGENT = f"ds-caselaw-marklogic-api-client/{VERSION}"
|
|
64
64
|
|
|
65
|
+
DEBUG: bool = bool(os.getenv("DEBUG", default=False))
|
|
66
|
+
|
|
65
67
|
|
|
66
68
|
class NoResponse(Exception):
|
|
67
69
|
"""A requests HTTPError has no response. We expect this will never happen."""
|
|
@@ -207,12 +209,14 @@ class MarklogicApiClient:
|
|
|
207
209
|
Returns a list of PressSummary objects associated with a given Document URI
|
|
208
210
|
"""
|
|
209
211
|
vars: query_dicts.GetComponentsForDocumentDict = {
|
|
210
|
-
"parent_uri":
|
|
212
|
+
"parent_uri": uri,
|
|
211
213
|
"component": "pressSummary",
|
|
212
214
|
}
|
|
213
215
|
response = self._send_to_eval(vars, "get_components_for_document.xqy")
|
|
214
216
|
uris = get_multipart_strings_from_marklogic_response(response)
|
|
215
|
-
return [
|
|
217
|
+
return [
|
|
218
|
+
PressSummary(DocumentURIString(uri.strip("/").strip(".xml")), self) for uri in uris
|
|
219
|
+
] # TODO: Migrate this strip behaviour into proper manipulation of a MarkLogicURIString
|
|
216
220
|
|
|
217
221
|
def get_document_by_uri(
|
|
218
222
|
self,
|
|
@@ -728,6 +732,10 @@ class MarklogicApiClient:
|
|
|
728
732
|
"vars": vars,
|
|
729
733
|
}
|
|
730
734
|
path = "LATEST/eval"
|
|
735
|
+
|
|
736
|
+
if DEBUG:
|
|
737
|
+
print(f"Sending {vars} to {xquery_path}")
|
|
738
|
+
|
|
731
739
|
response = self.session.request(
|
|
732
740
|
"POST",
|
|
733
741
|
url=self._path_to_request_url(path),
|
|
@@ -1101,6 +1109,21 @@ class MarklogicApiClient:
|
|
|
1101
1109
|
|
|
1102
1110
|
return results
|
|
1103
1111
|
|
|
1112
|
+
def get_recently_enriched(
|
|
1113
|
+
self,
|
|
1114
|
+
) -> list[list[Any]]:
|
|
1115
|
+
"""Retrieve documents which are not yet enriched with a given version."""
|
|
1116
|
+
results: list[list[Any]] = json.loads(
|
|
1117
|
+
get_single_string_from_marklogic_response(
|
|
1118
|
+
self._send_to_eval(
|
|
1119
|
+
{},
|
|
1120
|
+
"get_recently_enriched.xqy",
|
|
1121
|
+
),
|
|
1122
|
+
),
|
|
1123
|
+
)
|
|
1124
|
+
|
|
1125
|
+
return results
|
|
1126
|
+
|
|
1104
1127
|
def get_highest_parser_version(self) -> tuple[int, int]:
|
|
1105
1128
|
"""This gets the highest parser version in the database, so if nothing has been parsed with the most recent version of the parser, this won't reflect that change."""
|
|
1106
1129
|
table = json.loads(
|
|
@@ -1135,3 +1158,18 @@ class MarklogicApiClient:
|
|
|
1135
1158
|
)
|
|
1136
1159
|
|
|
1137
1160
|
return results
|
|
1161
|
+
|
|
1162
|
+
def get_recently_parsed(
|
|
1163
|
+
self,
|
|
1164
|
+
) -> list[list[Any]]:
|
|
1165
|
+
"""Retrieve documents which are not yet enriched with a given version."""
|
|
1166
|
+
results: list[list[Any]] = json.loads(
|
|
1167
|
+
get_single_string_from_marklogic_response(
|
|
1168
|
+
self._send_to_eval(
|
|
1169
|
+
{},
|
|
1170
|
+
"get_recently_parsed.xqy",
|
|
1171
|
+
),
|
|
1172
|
+
),
|
|
1173
|
+
)
|
|
1174
|
+
|
|
1175
|
+
return results
|
|
@@ -5,7 +5,7 @@ from unittest.mock import Mock
|
|
|
5
5
|
from typing_extensions import TypeAlias
|
|
6
6
|
|
|
7
7
|
from caselawclient.Client import MarklogicApiClient
|
|
8
|
-
from caselawclient.models.documents import Document
|
|
8
|
+
from caselawclient.models.documents import Document, DocumentURIString
|
|
9
9
|
from caselawclient.models.documents.body import DocumentBody
|
|
10
10
|
from caselawclient.models.judgments import Judgment
|
|
11
11
|
from caselawclient.models.press_summaries import PressSummary
|
|
@@ -54,7 +54,7 @@ class DocumentFactory:
|
|
|
54
54
|
@classmethod
|
|
55
55
|
def build(
|
|
56
56
|
cls,
|
|
57
|
-
uri:
|
|
57
|
+
uri: DocumentURIString = DocumentURIString("test/2023/123"),
|
|
58
58
|
html: str = "<p>This is a judgment.</p>",
|
|
59
59
|
api_client: Optional[MarklogicApiClient] = None,
|
|
60
60
|
**kwargs: Any,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import datetime
|
|
2
2
|
import warnings
|
|
3
3
|
from functools import cached_property
|
|
4
|
-
from typing import TYPE_CHECKING, Any,
|
|
4
|
+
from typing import TYPE_CHECKING, Any, Optional
|
|
5
5
|
|
|
6
6
|
from ds_caselaw_utils import courts
|
|
7
7
|
from ds_caselaw_utils.courts import CourtNotFoundException
|
|
@@ -30,7 +30,7 @@ from caselawclient.models.utilities.aws import (
|
|
|
30
30
|
)
|
|
31
31
|
|
|
32
32
|
from .body import DocumentBody
|
|
33
|
-
from .exceptions import CannotPublishUnpublishableDocument, DocumentNotSafeForDeletion
|
|
33
|
+
from .exceptions import CannotPublishUnpublishableDocument, DocumentNotSafeForDeletion, InvalidDocumentURIException
|
|
34
34
|
from .statuses import DOCUMENT_STATUS_HOLD, DOCUMENT_STATUS_IN_PROGRESS, DOCUMENT_STATUS_NEW, DOCUMENT_STATUS_PUBLISHED
|
|
35
35
|
|
|
36
36
|
MINIMUM_ENRICHMENT_TIME = datetime.timedelta(minutes=20)
|
|
@@ -47,7 +47,26 @@ if TYPE_CHECKING:
|
|
|
47
47
|
from caselawclient.Client import MarklogicApiClient
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
DocumentURIString
|
|
50
|
+
class DocumentURIString(str):
|
|
51
|
+
"""
|
|
52
|
+
This class checks that the string is actually a valid Document URI on creation. It does _not_ manipulate the string.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
def __new__(cls, content: str) -> "DocumentURIString":
|
|
56
|
+
# Check that the URI doesn't begin or end with a slash
|
|
57
|
+
if content[0] == "/" or content[-1] == "/":
|
|
58
|
+
raise InvalidDocumentURIException(
|
|
59
|
+
f'"{content}" is not a valid document URI; URIs cannot begin or end with slashes.'
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# Check that the URI doesn't contain a full stop
|
|
63
|
+
if "." in content:
|
|
64
|
+
raise InvalidDocumentURIException(
|
|
65
|
+
f'"{content}" is not a valid document URI; URIs cannot contain full stops.'
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# If everything is good, return as usual
|
|
69
|
+
return str.__new__(cls, content)
|
|
51
70
|
|
|
52
71
|
|
|
53
72
|
class Document:
|
|
@@ -105,13 +124,15 @@ class Document:
|
|
|
105
124
|
Individual document classes should extend this list where necessary to validate document type-specific attributes.
|
|
106
125
|
"""
|
|
107
126
|
|
|
108
|
-
def __init__(self, uri:
|
|
127
|
+
def __init__(self, uri: DocumentURIString, api_client: "MarklogicApiClient", search_query: Optional[str] = None):
|
|
109
128
|
"""
|
|
110
|
-
:param uri:
|
|
129
|
+
:param uri: The URI of the document to retrieve from MarkLogic.
|
|
130
|
+
:param api_client: An instance of the API client object to handle communication with the MarkLogic server.
|
|
131
|
+
:param search_query: Optionally, a search string which should be highlighted if it appears in the document body.
|
|
111
132
|
|
|
112
133
|
:raises DocumentNotFoundError: The document does not exist within MarkLogic
|
|
113
134
|
"""
|
|
114
|
-
self.uri: DocumentURIString =
|
|
135
|
+
self.uri: DocumentURIString = uri
|
|
115
136
|
self.api_client: MarklogicApiClient = api_client
|
|
116
137
|
if not self.document_exists():
|
|
117
138
|
raise DocumentNotFoundError(f"Document {self.uri} does not exist")
|
|
@@ -123,7 +144,7 @@ class Document:
|
|
|
123
144
|
search_query=search_query,
|
|
124
145
|
),
|
|
125
146
|
)
|
|
126
|
-
""" `Document.body` represents the
|
|
147
|
+
""" `Document.body` represents the body of the document itself, without any information such as version tracking or properties. """
|
|
127
148
|
|
|
128
149
|
def __repr__(self) -> str:
|
|
129
150
|
name = self.body.name or "un-named"
|
|
@@ -10,7 +10,7 @@ from caselawclient.models.neutral_citation_mixin import NeutralCitationMixin
|
|
|
10
10
|
if TYPE_CHECKING:
|
|
11
11
|
from caselawclient.models.press_summaries import PressSummary
|
|
12
12
|
|
|
13
|
-
from .documents import Document
|
|
13
|
+
from .documents import Document, DocumentURIString
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class Judgment(NeutralCitationMixin, Document):
|
|
@@ -21,8 +21,8 @@ class Judgment(NeutralCitationMixin, Document):
|
|
|
21
21
|
document_noun = "judgment"
|
|
22
22
|
document_noun_plural = "judgments"
|
|
23
23
|
|
|
24
|
-
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
25
|
-
super().__init__(self.document_noun, *args, **kwargs)
|
|
24
|
+
def __init__(self, uri: DocumentURIString, *args: Any, **kwargs: Any) -> None:
|
|
25
|
+
super().__init__(self.document_noun, uri, *args, **kwargs)
|
|
26
26
|
|
|
27
27
|
@cached_property
|
|
28
28
|
def neutral_citation(self) -> NeutralCitationString:
|
|
@@ -46,8 +46,9 @@ class Judgment(NeutralCitationMixin, Document):
|
|
|
46
46
|
Attempt to fetch a linked press summary, and return it, if it exists
|
|
47
47
|
"""
|
|
48
48
|
try:
|
|
49
|
-
uri = self.uri + "/press-summary/1"
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
uri = DocumentURIString(self.uri + "/press-summary/1")
|
|
50
|
+
if not TYPE_CHECKING: # This isn't nice, but will be cleaned up when we refactor how related documents work
|
|
51
|
+
PressSummary = importlib.import_module("caselawclient.models.press_summaries").PressSummary
|
|
52
|
+
return PressSummary(uri, self.api_client)
|
|
52
53
|
except DocumentNotFoundError:
|
|
53
54
|
return None
|
|
@@ -9,7 +9,7 @@ from ds_caselaw_utils.types import NeutralCitationString
|
|
|
9
9
|
from caselawclient.errors import DocumentNotFoundError
|
|
10
10
|
from caselawclient.models.neutral_citation_mixin import NeutralCitationMixin
|
|
11
11
|
|
|
12
|
-
from .documents import Document
|
|
12
|
+
from .documents import Document, DocumentURIString
|
|
13
13
|
|
|
14
14
|
if TYPE_CHECKING:
|
|
15
15
|
from caselawclient.models.judgments import Judgment
|
|
@@ -23,8 +23,8 @@ class PressSummary(NeutralCitationMixin, Document):
|
|
|
23
23
|
document_noun = "press summary"
|
|
24
24
|
document_noun_plural = "press summaries"
|
|
25
25
|
|
|
26
|
-
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
27
|
-
super().__init__(self.document_noun, *args, **kwargs)
|
|
26
|
+
def __init__(self, uri: DocumentURIString, *args: Any, **kwargs: Any) -> None:
|
|
27
|
+
super().__init__(self.document_noun, uri, *args, **kwargs)
|
|
28
28
|
|
|
29
29
|
@cached_property
|
|
30
30
|
def neutral_citation(self) -> NeutralCitationString:
|
|
@@ -47,8 +47,9 @@ class PressSummary(NeutralCitationMixin, Document):
|
|
|
47
47
|
Attempt to fetch a linked judgement, and return it, if it exists
|
|
48
48
|
"""
|
|
49
49
|
try:
|
|
50
|
-
uri = self.uri.removesuffix("/press-summary/1")
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
uri = DocumentURIString(self.uri.removesuffix("/press-summary/1"))
|
|
51
|
+
if not TYPE_CHECKING: # This isn't nice, but will be cleaned up when we refactor how related documents work
|
|
52
|
+
Judgment = importlib.import_module("caselawclient.models.judgments").Judgment
|
|
53
|
+
return Judgment(uri, self.api_client)
|
|
53
54
|
except DocumentNotFoundError:
|
|
54
55
|
return None
|
|
@@ -12,14 +12,14 @@ uk_namespace = {"uk": "https://caselaw.nationalarchives.gov.uk/akn"}
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class VersionsDict(TypedDict):
|
|
15
|
-
uri: str
|
|
15
|
+
uri: str ## TODO: This should be either a MarkLogicDocumentURIString (raw from ML) or a DocumentURIString (and we parse it out). Just a str is too vague.
|
|
16
16
|
version: int
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def render_versions(decoded_versions: list[BodyPart]) -> list[VersionsDict]:
|
|
20
20
|
versions: list[VersionsDict] = [
|
|
21
21
|
{
|
|
22
|
-
"uri": part.text.rstrip(".xml"),
|
|
22
|
+
"uri": part.text.strip("/").rstrip(".xml"),
|
|
23
23
|
"version": extract_version(part.text),
|
|
24
24
|
}
|
|
25
25
|
for part in decoded_versions
|
|
@@ -14,7 +14,7 @@ let $docTypeQuery := cts:element-attribute-value-query(
|
|
|
14
14
|
)
|
|
15
15
|
let $refQuery := cts:element-query(
|
|
16
16
|
xs:QName("uk:summaryOf"),
|
|
17
|
-
concat("https://caselaw.nationalarchives.gov.uk/id", $parent_uri)
|
|
17
|
+
concat("https://caselaw.nationalarchives.gov.uk/id/", $parent_uri)
|
|
18
18
|
)
|
|
19
19
|
|
|
20
20
|
return xdmp:node-uri(cts:search(//akn:akomaNtoso, cts:and-query(($refQuery, $collectionQuery, $docTypeQuery))))
|
|
@@ -11,20 +11,26 @@ xdmp:to-json(xdmp:sql(
|
|
|
11
11
|
"SELECT process_data.uri, enrich_version_string, minutes_since_enrichment_request
|
|
12
12
|
FROM (
|
|
13
13
|
SELECT
|
|
14
|
+
propertysummary.published,
|
|
14
15
|
process_data.uri,
|
|
15
16
|
enrich_version_string, enrich_major_version, enrich_minor_version,
|
|
16
17
|
parser_major_version, parser_minor_version,
|
|
17
18
|
DATEDIFF('minute', last_sent_to_enrichment, CURRENT_TIMESTAMP) AS minutes_since_enrichment_request
|
|
18
19
|
FROM documents.process_data
|
|
19
20
|
JOIN documents.process_property_data ON process_data.uri = process_property_data.uri
|
|
21
|
+
JOIN documents.propertysummary ON process_data.uri = propertysummary.uri
|
|
20
22
|
)
|
|
21
|
-
WHERE
|
|
22
|
-
(
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
WHERE
|
|
24
|
+
(minutes_since_enrichment_request > 43200 OR minutes_since_enrichment_request IS NULL) AND
|
|
25
|
+
(propertysummary.published = 'true') AND
|
|
26
|
+
( enrich_version_string IS NULL
|
|
27
|
+
OR
|
|
28
|
+
(
|
|
29
|
+
(enrich_major_version <= @target_enrichment_major_version AND enrich_minor_version < @target_enrichment_minor_version)
|
|
30
|
+
AND
|
|
31
|
+
(parser_major_version = @target_parser_major_version AND parser_minor_version = @target_parser_minor_version)
|
|
32
|
+
)
|
|
33
|
+
)
|
|
28
34
|
ORDER BY enrich_major_version ASC NULLS FIRST, enrich_minor_version ASC
|
|
29
35
|
LIMIT @maximum_records",
|
|
30
36
|
"array",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
xquery version "1.0-ml";
|
|
2
|
+
|
|
3
|
+
declare namespace xdmp="http://marklogic.com/xdmp";
|
|
4
|
+
xdmp:to-json(xdmp:sql(
|
|
5
|
+
"SELECT *, process_data.uri, hours_since_enrichment_request, enrich_major_version, enrich_minor_version
|
|
6
|
+
FROM (
|
|
7
|
+
SELECT
|
|
8
|
+
process_data.uri, enrich_major_version, enrich_minor_version,
|
|
9
|
+
DATEDIFF('hour', last_sent_to_enrichment, CURRENT_TIMESTAMP) AS hours_since_enrichment_request
|
|
10
|
+
FROM documents.process_data
|
|
11
|
+
JOIN documents.process_property_data ON process_data.uri = process_property_data.uri
|
|
12
|
+
)
|
|
13
|
+
ORDER BY hours_since_enrichment_request ASC
|
|
14
|
+
LIMIT 1000",
|
|
15
|
+
"array",
|
|
16
|
+
map:new((
|
|
17
|
+
))
|
|
18
|
+
))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
xquery version "1.0-ml";
|
|
2
|
+
|
|
3
|
+
declare namespace xdmp="http://marklogic.com/xdmp";
|
|
4
|
+
xdmp:to-json(xdmp:sql(
|
|
5
|
+
"SELECT process_data.uri, hours_since_parse_request, parser_major_version, parser_minor_version
|
|
6
|
+
FROM (
|
|
7
|
+
SELECT
|
|
8
|
+
process_data.uri, parser_major_version, parser_minor_version,
|
|
9
|
+
DATEDIFF('hour', last_sent_to_parser, CURRENT_TIMESTAMP) AS hours_since_parse_request
|
|
10
|
+
FROM documents.process_data
|
|
11
|
+
JOIN documents.process_property_data ON process_data.uri = process_property_data.uri
|
|
12
|
+
)
|
|
13
|
+
ORDER BY hours_since_parse_request ASC
|
|
14
|
+
LIMIT 1000",
|
|
15
|
+
"array",
|
|
16
|
+
map:new((
|
|
17
|
+
))
|
|
18
|
+
))
|
|
19
|
+
|
{ds_caselaw_marklogic_api_client-27.3.0 → ds_caselaw_marklogic_api_client-28.0.0}/LICENSE.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|