ds-caselaw-marklogic-api-client 19.1.0__tar.gz → 21.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-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/PKG-INFO +1 -1
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/pyproject.toml +2 -1
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/Client.py +72 -2
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/models/documents.py +30 -8
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/models/neutral_citation_mixin.py +15 -14
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/models/utilities/aws.py +11 -10
- ds_caselaw_marklogic_api_client-21.0.0/src/caselawclient/xquery/get_highest_enrichment_version.xqy +9 -0
- ds_caselaw_marklogic_api_client-21.0.0/src/caselawclient/xquery/get_highest_parser_version.xqy +9 -0
- ds_caselaw_marklogic_api_client-21.0.0/src/caselawclient/xquery/get_pending_enrichment_for_version.xqy +35 -0
- ds_caselaw_marklogic_api_client-21.0.0/src/caselawclient/xquery/get_pending_parse_for_version.xqy +28 -0
- ds_caselaw_marklogic_api_client-21.0.0/src/caselawclient/xquery/set_metadata_jurisdiction.xqy +37 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery_type_dicts.py +16 -1
- ds_caselaw_marklogic_api_client-19.1.0/src/caselawclient/xquery/get_pending_enrichment_for_version.xqy +0 -18
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/LICENSE.md +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/README.md +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/__init__.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/client_helpers/__init__.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/client_helpers/search_helpers.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/content_hash.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/errors.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/models/__init__.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/models/judgments.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/models/press_summaries.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/models/utilities/__init__.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/models/utilities/move.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/py.typed +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/responses/__init__.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/responses/search_response.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/responses/search_result.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/responses/xsl/search_match.xsl +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/search_parameters.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xml_helpers.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xml_tools.py +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/break_judgment_checkout.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/checkin_judgment.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/checkout_judgment.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/copy_document.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/delete_judgment.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/document_collections.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/document_exists.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/get_combined_stats_table.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/get_judgment.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/get_judgment_checkout_status.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/get_judgment_version.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/get_last_modified.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/get_properties_for_search_results.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/get_property.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/get_version_annotation.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/get_version_created.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/insert_document.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/list_judgment_versions.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/set_boolean_property.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/set_metadata_citation.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/set_metadata_court.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/set_metadata_name.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/set_metadata_this_uri.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/set_metadata_work_expression_date.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/set_property.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/update_document.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/update_locked_judgment.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/user_has_privilege.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/user_has_role.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/validate_all_documents.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/xslt.xqy +0 -0
- {ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.0.0}/src/caselawclient/xquery/xslt_transform.xqy +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ds-caselaw-marklogic-api-client
|
|
3
|
-
Version:
|
|
3
|
+
Version: 21.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-19.1.0 → ds_caselaw_marklogic_api_client-21.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 = "21.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"
|
|
@@ -32,6 +32,7 @@ coverage = "^7.2.3"
|
|
|
32
32
|
pytest = "^7.3.2"
|
|
33
33
|
responses = "^0.24.0"
|
|
34
34
|
python-dotenv = "^1.0.0"
|
|
35
|
+
time-machine = "^2.13.0"
|
|
35
36
|
|
|
36
37
|
[tool.poetry.group.docs]
|
|
37
38
|
optional = true
|
|
@@ -446,6 +446,24 @@ class MarklogicApiClient:
|
|
|
446
446
|
|
|
447
447
|
return self._send_to_eval(vars, "set_metadata_court.xqy")
|
|
448
448
|
|
|
449
|
+
def set_document_jurisdiction(
|
|
450
|
+
self, document_uri: DocumentURIString, content: str
|
|
451
|
+
) -> requests.Response:
|
|
452
|
+
uri = self._format_uri_for_marklogic(document_uri)
|
|
453
|
+
vars: query_dicts.SetMetadataJurisdictionDict = {"uri": uri, "content": content}
|
|
454
|
+
return self._send_to_eval(vars, "set_metadata_jurisdiction.xqy")
|
|
455
|
+
|
|
456
|
+
def set_document_court_and_jurisdiction(
|
|
457
|
+
self, document_uri: DocumentURIString, content: str
|
|
458
|
+
) -> requests.Response:
|
|
459
|
+
if "/" in content:
|
|
460
|
+
court, jurisdiction = re.split("\\s*/\\s*", content)
|
|
461
|
+
self.set_document_court(document_uri, court)
|
|
462
|
+
return self.set_document_jurisdiction(document_uri, jurisdiction)
|
|
463
|
+
else:
|
|
464
|
+
self.set_document_court(document_uri, content)
|
|
465
|
+
return self.set_document_jurisdiction(document_uri, "")
|
|
466
|
+
|
|
449
467
|
def set_judgment_this_uri(
|
|
450
468
|
self, judgment_uri: DocumentURIString
|
|
451
469
|
) -> requests.Response:
|
|
@@ -952,12 +970,32 @@ class MarklogicApiClient:
|
|
|
952
970
|
|
|
953
971
|
return results
|
|
954
972
|
|
|
973
|
+
def get_highest_enrichment_version(self) -> tuple[int, int]:
|
|
974
|
+
"""This gets the highest enrichment version in the database,
|
|
975
|
+
so if nothing has been enriched with the most recent version of enrichment,
|
|
976
|
+
this won't reflect that change."""
|
|
977
|
+
table = json.loads(
|
|
978
|
+
get_single_string_from_marklogic_response(
|
|
979
|
+
self._send_to_eval(
|
|
980
|
+
{},
|
|
981
|
+
"get_highest_enrichment_version.xqy",
|
|
982
|
+
)
|
|
983
|
+
)
|
|
984
|
+
)
|
|
985
|
+
|
|
986
|
+
return (int(table[1][1]), int(table[1][2]))
|
|
987
|
+
|
|
955
988
|
def get_pending_enrichment_for_version(
|
|
956
|
-
self,
|
|
989
|
+
self,
|
|
990
|
+
target_enrichment_version: tuple[int, int],
|
|
991
|
+
target_parser_version: tuple[int, int],
|
|
957
992
|
) -> list[list[Any]]:
|
|
958
993
|
"""Retrieve documents which are not yet enriched with a given version."""
|
|
959
994
|
vars: query_dicts.GetPendingEnrichmentForVersionDict = {
|
|
960
|
-
"
|
|
995
|
+
"target_enrichment_major_version": target_enrichment_version[0],
|
|
996
|
+
"target_enrichment_minor_version": target_enrichment_version[1],
|
|
997
|
+
"target_parser_major_version": target_parser_version[0],
|
|
998
|
+
"target_parser_minor_version": target_parser_version[1],
|
|
961
999
|
}
|
|
962
1000
|
results: list[list[Any]] = json.loads(
|
|
963
1001
|
get_single_string_from_marklogic_response(
|
|
@@ -969,3 +1007,35 @@ class MarklogicApiClient:
|
|
|
969
1007
|
)
|
|
970
1008
|
|
|
971
1009
|
return results
|
|
1010
|
+
|
|
1011
|
+
def get_highest_parser_version(self) -> tuple[int, int]:
|
|
1012
|
+
"""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."""
|
|
1013
|
+
table = json.loads(
|
|
1014
|
+
get_single_string_from_marklogic_response(
|
|
1015
|
+
self._send_to_eval(
|
|
1016
|
+
{},
|
|
1017
|
+
"get_highest_parser_version.xqy",
|
|
1018
|
+
)
|
|
1019
|
+
)
|
|
1020
|
+
)
|
|
1021
|
+
|
|
1022
|
+
return (int(table[1][1]), int(table[1][2]))
|
|
1023
|
+
|
|
1024
|
+
def get_pending_parse_for_version(
|
|
1025
|
+
self, target_version: tuple[int, int]
|
|
1026
|
+
) -> list[list[Any]]:
|
|
1027
|
+
"""Retrieve documents which are not yet parsed with a given version."""
|
|
1028
|
+
vars: query_dicts.GetPendingParseForVersionDict = {
|
|
1029
|
+
"target_major_version": target_version[0],
|
|
1030
|
+
"target_minor_version": target_version[1],
|
|
1031
|
+
}
|
|
1032
|
+
results: list[list[Any]] = json.loads(
|
|
1033
|
+
get_single_string_from_marklogic_response(
|
|
1034
|
+
self._send_to_eval(
|
|
1035
|
+
vars,
|
|
1036
|
+
"get_pending_parse_for_version.xqy",
|
|
1037
|
+
)
|
|
1038
|
+
)
|
|
1039
|
+
)
|
|
1040
|
+
|
|
1041
|
+
return results
|
|
@@ -154,6 +154,10 @@ class Document:
|
|
|
154
154
|
)
|
|
155
155
|
)
|
|
156
156
|
|
|
157
|
+
def __repr__(self) -> str:
|
|
158
|
+
name = self.name or "un-named"
|
|
159
|
+
return f"<{self.document_noun} {self.uri}: {name}>"
|
|
160
|
+
|
|
157
161
|
def document_exists(self) -> bool:
|
|
158
162
|
"""Helper method to verify the existence of a document within MarkLogic.
|
|
159
163
|
|
|
@@ -194,6 +198,20 @@ class Document:
|
|
|
194
198
|
},
|
|
195
199
|
)
|
|
196
200
|
|
|
201
|
+
@cached_property
|
|
202
|
+
def jurisdiction(self) -> str:
|
|
203
|
+
return self.xml.get_xpath_match_string(
|
|
204
|
+
"/akn:akomaNtoso/akn:*/akn:meta/akn:proprietary/uk:jurisdiction/text()",
|
|
205
|
+
{
|
|
206
|
+
"uk": "https://caselaw.nationalarchives.gov.uk/akn",
|
|
207
|
+
"akn": "http://docs.oasis-open.org/legaldocml/ns/akn/3.0",
|
|
208
|
+
},
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
@property
|
|
212
|
+
def court_and_jurisdiction(self) -> str:
|
|
213
|
+
return "/".join((self.court, self.jurisdiction))
|
|
214
|
+
|
|
197
215
|
@cached_property
|
|
198
216
|
def document_date_as_string(self) -> str:
|
|
199
217
|
return self.xml.get_xpath_match_string(
|
|
@@ -460,9 +478,9 @@ class Document:
|
|
|
460
478
|
"""
|
|
461
479
|
Request enrichment of the document
|
|
462
480
|
"""
|
|
463
|
-
|
|
481
|
+
now = datetime.datetime.now(datetime.timezone.utc)
|
|
464
482
|
self.api_client.set_property(
|
|
465
|
-
self.uri, "last_sent_to_enrichment",
|
|
483
|
+
self.uri, "last_sent_to_enrichment", now.isoformat()
|
|
466
484
|
)
|
|
467
485
|
|
|
468
486
|
announce_document_event(
|
|
@@ -532,6 +550,9 @@ class Document:
|
|
|
532
550
|
def reparse(self) -> None:
|
|
533
551
|
"Send an SNS notification that triggers reparsing, also sending all editor-modifiable metadata and URI"
|
|
534
552
|
|
|
553
|
+
now = datetime.datetime.now(datetime.timezone.utc)
|
|
554
|
+
self.api_client.set_property(self.uri, "last_sent_to_parser", now.isoformat())
|
|
555
|
+
|
|
535
556
|
parser_type_noun = {"judgment": "judgment", "press summary": "pressSummary"}[
|
|
536
557
|
self.document_noun
|
|
537
558
|
]
|
|
@@ -546,13 +567,14 @@ class Document:
|
|
|
546
567
|
# values are "" from the API, we should pass None instead in this case.
|
|
547
568
|
|
|
548
569
|
parser_instructions: ParserInstructionsDict = {
|
|
549
|
-
"name": self.name or None,
|
|
550
|
-
"cite": self.best_human_identifier or None,
|
|
551
|
-
"court": self.court or None,
|
|
552
|
-
"date": checked_date,
|
|
553
|
-
"uri": self.uri,
|
|
554
570
|
"documentType": parser_type_noun,
|
|
555
|
-
"
|
|
571
|
+
"metadata": {
|
|
572
|
+
"name": self.name or None,
|
|
573
|
+
"cite": self.best_human_identifier or None,
|
|
574
|
+
"court": self.court or None,
|
|
575
|
+
"date": checked_date,
|
|
576
|
+
"uri": self.uri,
|
|
577
|
+
},
|
|
556
578
|
}
|
|
557
579
|
|
|
558
580
|
request_parse(
|
|
@@ -19,20 +19,21 @@ class NeutralCitationMixin:
|
|
|
19
19
|
"""
|
|
20
20
|
|
|
21
21
|
def __init__(self, document_noun: str, *args: Any, **kwargs: Any) -> None:
|
|
22
|
-
self.attributes_to_validate: list[
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
self.attributes_to_validate: list[tuple[str, bool, str]] = (
|
|
23
|
+
self.attributes_to_validate
|
|
24
|
+
+ [
|
|
25
|
+
(
|
|
26
|
+
"has_ncn",
|
|
27
|
+
True,
|
|
28
|
+
f"This {document_noun} has no neutral citation number",
|
|
29
|
+
),
|
|
30
|
+
(
|
|
31
|
+
"has_valid_ncn",
|
|
32
|
+
True,
|
|
33
|
+
f"The neutral citation number of this {document_noun} is not valid",
|
|
34
|
+
),
|
|
35
|
+
]
|
|
36
|
+
)
|
|
36
37
|
|
|
37
38
|
super(NeutralCitationMixin, self).__init__(*args, **kwargs)
|
|
38
39
|
|
|
@@ -16,24 +16,25 @@ from typing_extensions import NotRequired
|
|
|
16
16
|
env = environ.Env()
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
class ParserInstructionsMetadataDict(TypedDict):
|
|
20
|
+
name: Optional[str]
|
|
21
|
+
cite: Optional[str]
|
|
22
|
+
court: Optional[str]
|
|
23
|
+
date: Optional[str]
|
|
24
|
+
uri: Optional[str]
|
|
25
|
+
|
|
26
|
+
|
|
19
27
|
class ParserInstructionsDict(TypedDict):
|
|
20
|
-
name: NotRequired[Optional[str]]
|
|
21
|
-
cite: NotRequired[Optional[str]]
|
|
22
|
-
court: NotRequired[Optional[str]]
|
|
23
|
-
date: NotRequired[Optional[str]]
|
|
24
|
-
uri: NotRequired[Optional[str]]
|
|
25
28
|
documentType: NotRequired[Optional[str]]
|
|
26
|
-
|
|
29
|
+
metadata: NotRequired[ParserInstructionsMetadataDict]
|
|
27
30
|
|
|
28
31
|
|
|
29
32
|
@overload
|
|
30
|
-
def create_aws_client(service: Literal["s3"]) -> S3Client:
|
|
31
|
-
...
|
|
33
|
+
def create_aws_client(service: Literal["s3"]) -> S3Client: ...
|
|
32
34
|
|
|
33
35
|
|
|
34
36
|
@overload
|
|
35
|
-
def create_aws_client(service: Literal["sns"]) -> SNSClient:
|
|
36
|
-
...
|
|
37
|
+
def create_aws_client(service: Literal["sns"]) -> SNSClient: ...
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
def create_aws_client(service: Union[Literal["s3"], Literal["sns"]]) -> Any:
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
xquery version "1.0-ml";
|
|
2
|
+
|
|
3
|
+
declare variable $target_enrichment_major_version as xs:int external;
|
|
4
|
+
declare variable $target_enrichment_minor_version as xs:int external;
|
|
5
|
+
declare variable $target_parser_major_version as xs:int external;
|
|
6
|
+
declare variable $target_parser_minor_version as xs:int external;
|
|
7
|
+
|
|
8
|
+
xdmp:to-json(xdmp:sql(
|
|
9
|
+
"SELECT process_data.uri, enrich_version_string, minutes_since_enrichment_request
|
|
10
|
+
FROM (
|
|
11
|
+
SELECT
|
|
12
|
+
process_data.uri,
|
|
13
|
+
enrich_version_string, enrich_major_version, enrich_minor_version,
|
|
14
|
+
parser_major_version, parser_minor_version,
|
|
15
|
+
DATEDIFF('minute', last_sent_to_enrichment, CURRENT_TIMESTAMP) AS minutes_since_enrichment_request
|
|
16
|
+
FROM documents.process_data
|
|
17
|
+
JOIN documents.process_property_data ON process_data.uri = process_property_data.uri
|
|
18
|
+
)
|
|
19
|
+
WHERE (
|
|
20
|
+
(enrich_version_string IS NULL) OR
|
|
21
|
+
(enrich_major_version <= @target_enrichment_major_version AND enrich_minor_version < @target_enrichment_minor_version)
|
|
22
|
+
) AND (
|
|
23
|
+
(parser_major_version = @target_parser_major_version AND parser_minor_version = @target_parser_minor_version)
|
|
24
|
+
)
|
|
25
|
+
AND (minutes_since_enrichment_request > 43200 OR minutes_since_enrichment_request IS NULL)
|
|
26
|
+
ORDER BY enrich_major_version ASC NULLS FIRST, enrich_minor_version ASC",
|
|
27
|
+
"array",
|
|
28
|
+
map:new((
|
|
29
|
+
map:entry("target_enrichment_major_version", $target_enrichment_major_version),
|
|
30
|
+
map:entry("target_enrichment_minor_version", $target_enrichment_minor_version),
|
|
31
|
+
map:entry("target_parser_major_version", $target_parser_major_version),
|
|
32
|
+
map:entry("target_parser_minor_version", $target_parser_minor_version)
|
|
33
|
+
))
|
|
34
|
+
))
|
|
35
|
+
|
ds_caselaw_marklogic_api_client-21.0.0/src/caselawclient/xquery/get_pending_parse_for_version.xqy
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
xquery version "1.0-ml";
|
|
2
|
+
|
|
3
|
+
declare variable $target_major_version as xs:int external;
|
|
4
|
+
declare variable $target_minor_version as xs:int external;
|
|
5
|
+
|
|
6
|
+
xdmp:to-json(xdmp:sql(
|
|
7
|
+
"SELECT process_data.uri, parser_version_string, minutes_since_parse_request
|
|
8
|
+
FROM (
|
|
9
|
+
SELECT
|
|
10
|
+
process_data.uri,
|
|
11
|
+
parser_version_string, parser_major_version, parser_minor_version,
|
|
12
|
+
DATEDIFF('minute', last_sent_to_parser, CURRENT_TIMESTAMP) AS minutes_since_parse_request
|
|
13
|
+
FROM documents.process_data
|
|
14
|
+
JOIN documents.process_property_data ON process_data.uri = process_property_data.uri
|
|
15
|
+
)
|
|
16
|
+
WHERE (
|
|
17
|
+
(parser_version_string IS NULL) OR
|
|
18
|
+
(parser_major_version <= @target_major_version AND parser_minor_version < @target_minor_version)
|
|
19
|
+
)
|
|
20
|
+
AND (minutes_since_parse_request > 43200 OR minutes_since_parse_request IS NULL)
|
|
21
|
+
ORDER BY parser_major_version ASC NULLS FIRST, parser_minor_version ASC",
|
|
22
|
+
"array",
|
|
23
|
+
map:new((
|
|
24
|
+
map:entry("target_major_version", $target_major_version),
|
|
25
|
+
map:entry("target_minor_version", $target_minor_version)
|
|
26
|
+
))
|
|
27
|
+
))
|
|
28
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
xquery version "1.0-ml";
|
|
2
|
+
|
|
3
|
+
declare namespace akn = "http://docs.oasis-open.org/legaldocml/ns/akn/3.0";
|
|
4
|
+
declare namespace uk = "https://caselaw.nationalarchives.gov.uk/akn";
|
|
5
|
+
|
|
6
|
+
declare variable $uri as xs:string external;
|
|
7
|
+
declare variable $content as xs:string external;
|
|
8
|
+
declare variable $proprietary-node := document($uri)/akn:akomaNtoso/akn:*/akn:meta/akn:proprietary;
|
|
9
|
+
declare variable $jurisdiction-node := $proprietary-node/uk:jurisdiction;
|
|
10
|
+
|
|
11
|
+
declare function local:delete($uri)
|
|
12
|
+
{
|
|
13
|
+
xdmp:node-delete($jurisdiction-node)
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare function local:edit($uri, $content)
|
|
17
|
+
{
|
|
18
|
+
xdmp:node-replace(
|
|
19
|
+
$jurisdiction-node,
|
|
20
|
+
<uk:jurisdiction>{$content}</uk:jurisdiction>
|
|
21
|
+
)
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
declare function local:add($uri, $content)
|
|
25
|
+
{
|
|
26
|
+
xdmp:node-insert-child(
|
|
27
|
+
$proprietary-node,
|
|
28
|
+
<uk:jurisdiction>{$content}</uk:jurisdiction>
|
|
29
|
+
)
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
if (fn:boolean(
|
|
33
|
+
cts:search(doc($uri),
|
|
34
|
+
cts:element-query(xs:QName('uk:jurisdiction'),cts:and-query(()))))) then
|
|
35
|
+
if ($content = "") then local:delete($uri) else local:edit($uri, $content)
|
|
36
|
+
else
|
|
37
|
+
local:add($uri, $content)
|
|
@@ -80,7 +80,16 @@ class GetLastModifiedDict(MarkLogicAPIDict):
|
|
|
80
80
|
|
|
81
81
|
# get_pending_enrichment_for_version.xqy
|
|
82
82
|
class GetPendingEnrichmentForVersionDict(MarkLogicAPIDict):
|
|
83
|
-
|
|
83
|
+
target_enrichment_major_version: int
|
|
84
|
+
target_enrichment_minor_version: int
|
|
85
|
+
target_parser_major_version: int
|
|
86
|
+
target_parser_minor_version: int
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# get_pending_parse_for_version.xqy
|
|
90
|
+
class GetPendingParseForVersionDict(MarkLogicAPIDict):
|
|
91
|
+
target_major_version: int
|
|
92
|
+
target_minor_version: int
|
|
84
93
|
|
|
85
94
|
|
|
86
95
|
# get_properties_for_search_results.xqy
|
|
@@ -135,6 +144,12 @@ class SetMetadataCourtDict(MarkLogicAPIDict):
|
|
|
135
144
|
uri: MarkLogicDocumentURIString
|
|
136
145
|
|
|
137
146
|
|
|
147
|
+
# set_metadata_jurisdiction.xqy
|
|
148
|
+
class SetMetadataJurisdictionDict(MarkLogicAPIDict):
|
|
149
|
+
content: str
|
|
150
|
+
uri: MarkLogicDocumentURIString
|
|
151
|
+
|
|
152
|
+
|
|
138
153
|
# set_metadata_name.xqy
|
|
139
154
|
class SetMetadataNameDict(MarkLogicAPIDict):
|
|
140
155
|
content: str
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
xquery version "1.0-ml";
|
|
2
|
-
|
|
3
|
-
declare variable $target_version as xs:int external;
|
|
4
|
-
|
|
5
|
-
xdmp:to-json(xdmp:sql(
|
|
6
|
-
"SELECT process_data.uri, enrich_version_string, minutes_since_enrichment_request
|
|
7
|
-
FROM (
|
|
8
|
-
SELECT process_data.uri, enrich_version_string, enrich_major_version, DATEDIFF('minute', last_sent_to_enrichment, CURRENT_TIMESTAMP) AS minutes_since_enrichment_request
|
|
9
|
-
FROM documents.process_data
|
|
10
|
-
JOIN documents.process_property_data ON process_data.uri = process_property_data.uri
|
|
11
|
-
)
|
|
12
|
-
WHERE ((enrich_version_string IS NULL) OR (enrich_major_version < @target_version))
|
|
13
|
-
AND (minutes_since_enrichment_request > 43200 OR minutes_since_enrichment_request IS NULL)
|
|
14
|
-
ORDER BY enrich_major_version ASC NULLS FIRST",
|
|
15
|
-
"array",
|
|
16
|
-
map:new(map:entry("target_version", $target_version))
|
|
17
|
-
))
|
|
18
|
-
|
{ds_caselaw_marklogic_api_client-19.1.0 → ds_caselaw_marklogic_api_client-21.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
|