ds-caselaw-marklogic-api-client 37.0.1__py3-none-any.whl → 37.1.0__py3-none-any.whl
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.
- caselawclient/Client.py +18 -0
- caselawclient/factories.py +1 -1
- caselawclient/models/documents/__init__.py +12 -5
- caselawclient/xquery/get_missing_fclid.xqy +25 -0
- caselawclient/xquery_type_dicts.py +5 -0
- {ds_caselaw_marklogic_api_client-37.0.1.dist-info → ds_caselaw_marklogic_api_client-37.1.0.dist-info}/METADATA +1 -1
- {ds_caselaw_marklogic_api_client-37.0.1.dist-info → ds_caselaw_marklogic_api_client-37.1.0.dist-info}/RECORD +9 -8
- {ds_caselaw_marklogic_api_client-37.0.1.dist-info → ds_caselaw_marklogic_api_client-37.1.0.dist-info}/LICENSE.md +0 -0
- {ds_caselaw_marklogic_api_client-37.0.1.dist-info → ds_caselaw_marklogic_api_client-37.1.0.dist-info}/WHEEL +0 -0
caselawclient/Client.py
CHANGED
|
@@ -1198,6 +1198,24 @@ class MarklogicApiClient:
|
|
|
1198
1198
|
|
|
1199
1199
|
return results
|
|
1200
1200
|
|
|
1201
|
+
def get_missing_fclid(
|
|
1202
|
+
self,
|
|
1203
|
+
maximum_records: int = 50,
|
|
1204
|
+
) -> list[str]:
|
|
1205
|
+
"""Retrieve the URIs of published documents which do not have an identifier in the `fclid` schema."""
|
|
1206
|
+
vars: query_dicts.GetMissingFclidDict = {
|
|
1207
|
+
"maximum_records": maximum_records,
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
results: list[str] = get_multipart_strings_from_marklogic_response(
|
|
1211
|
+
self._send_to_eval(
|
|
1212
|
+
vars,
|
|
1213
|
+
"get_missing_fclid.xqy",
|
|
1214
|
+
)
|
|
1215
|
+
)
|
|
1216
|
+
|
|
1217
|
+
return results
|
|
1218
|
+
|
|
1201
1219
|
def resolve_from_identifier_slug(
|
|
1202
1220
|
self, identifier_slug: DocumentIdentifierSlug, published_only: bool = True
|
|
1203
1221
|
) -> IdentifierResolutions:
|
caselawclient/factories.py
CHANGED
|
@@ -151,7 +151,7 @@ class SearchResultFactory(SimpleFactory):
|
|
|
151
151
|
"name": "Judgment v Judgement",
|
|
152
152
|
"neutral_citation": "[2025] UKSC 123",
|
|
153
153
|
"court": "Court of Testing",
|
|
154
|
-
"date": datetime.datetime(2023, 2, 3)
|
|
154
|
+
"date": datetime.datetime(2023, 2, 3),
|
|
155
155
|
"transformation_date": datetime.datetime(2023, 2, 3, 12, 34).isoformat(),
|
|
156
156
|
"metadata": SearchResultMetadataFactory.build(),
|
|
157
157
|
"is_failure": False,
|
|
@@ -378,6 +378,16 @@ class Document:
|
|
|
378
378
|
"""
|
|
379
379
|
return self.api_client.validate_document(self.uri)
|
|
380
380
|
|
|
381
|
+
def assign_fclid_if_missing(self) -> Optional[FindCaseLawIdentifier]:
|
|
382
|
+
"""If the document does not have an FCLID already, mint a new one and save it."""
|
|
383
|
+
if len(self.identifiers.of_type(FindCaseLawIdentifier)) == 0:
|
|
384
|
+
document_fclid = FindCaseLawIdentifierSchema.mint(self.api_client)
|
|
385
|
+
self.identifiers.add(document_fclid)
|
|
386
|
+
self.save_identifiers()
|
|
387
|
+
return document_fclid
|
|
388
|
+
|
|
389
|
+
return None
|
|
390
|
+
|
|
381
391
|
def publish(self) -> None:
|
|
382
392
|
"""
|
|
383
393
|
:raises CannotPublishUnpublishableDocument: This document has not passed the checks in `is_publishable`, and as
|
|
@@ -386,11 +396,8 @@ class Document:
|
|
|
386
396
|
if not self.is_publishable:
|
|
387
397
|
raise CannotPublishUnpublishableDocument
|
|
388
398
|
|
|
389
|
-
##
|
|
390
|
-
|
|
391
|
-
document_fclid = FindCaseLawIdentifierSchema.mint(self.api_client)
|
|
392
|
-
self.identifiers.add(document_fclid)
|
|
393
|
-
self.save_identifiers()
|
|
399
|
+
## Make sure the document has an FCLID
|
|
400
|
+
self.assign_fclid_if_missing()
|
|
394
401
|
|
|
395
402
|
publish_documents(self.uri)
|
|
396
403
|
self.api_client.set_published(self.uri, True)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
xquery version "1.0-ml";
|
|
2
|
+
|
|
3
|
+
declare variable $maximum_records as xs:int? external := 1000;
|
|
4
|
+
|
|
5
|
+
for $doc in fn:subsequence(
|
|
6
|
+
cts:search(
|
|
7
|
+
fn:collection(),
|
|
8
|
+
cts:and-query(
|
|
9
|
+
(
|
|
10
|
+
cts:properties-fragment-query(
|
|
11
|
+
cts:element-value-query(xs:QName("published"), "true")
|
|
12
|
+
),
|
|
13
|
+
cts:not-query(
|
|
14
|
+
cts:properties-fragment-query(
|
|
15
|
+
cts:element-value-query(xs:QName("namespace"), "fclid")
|
|
16
|
+
)
|
|
17
|
+
)
|
|
18
|
+
)
|
|
19
|
+
)
|
|
20
|
+
),
|
|
21
|
+
1,
|
|
22
|
+
$maximum_records
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
return fn:base-uri($doc)
|
|
@@ -86,6 +86,11 @@ class GetLastModifiedDict(MarkLogicAPIDict):
|
|
|
86
86
|
uri: MarkLogicDocumentURIString
|
|
87
87
|
|
|
88
88
|
|
|
89
|
+
# get_missing_fclid.xqy
|
|
90
|
+
class GetMissingFclidDict(MarkLogicAPIDict):
|
|
91
|
+
maximum_records: Optional[int]
|
|
92
|
+
|
|
93
|
+
|
|
89
94
|
# get_pending_enrichment_for_version.xqy
|
|
90
95
|
class GetPendingEnrichmentForVersionDict(MarkLogicAPIDict):
|
|
91
96
|
maximum_records: Optional[int]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ds-caselaw-marklogic-api-client
|
|
3
|
-
Version: 37.0
|
|
3
|
+
Version: 37.1.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
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
caselawclient/Client.py,sha256=
|
|
1
|
+
caselawclient/Client.py,sha256=AGF7ud4x2hZFm6H--IUXa-n5woOWYmWz2yDzbPPCGdA,45193
|
|
2
2
|
caselawclient/__init__.py,sha256=DY-caubLDQWWingSdsBWgovDNXh8KcnkI6kwz08eIFk,612
|
|
3
3
|
caselawclient/client_helpers/__init__.py,sha256=eucyUXwUqI72TPw-C5zLcHlMu4GtFY507a6lQc03lQY,5053
|
|
4
4
|
caselawclient/client_helpers/search_helpers.py,sha256=R99HyRLeYHgsw2L3DOidEqlKLLvs6Tga5rKTuWQViig,1525
|
|
5
5
|
caselawclient/content_hash.py,sha256=0cPC4OoABq0SC2wYFX9-24DodNigeOqksDxgxQH_hUA,2221
|
|
6
6
|
caselawclient/errors.py,sha256=JC16fEGq_MRJX-_KFzfINCV2Cqx8o6OWOt3C16rQd84,3142
|
|
7
|
-
caselawclient/factories.py,sha256=
|
|
7
|
+
caselawclient/factories.py,sha256=tAZQ8RfWQwdZsqc6qScXyaXV6nk5lScB3Chx8fwRRro,6949
|
|
8
8
|
caselawclient/identifier_resolution.py,sha256=B5I1sD7o7YjzsXMECjbKjgiGLDda5bGhejsJ-lYpTIg,2429
|
|
9
9
|
caselawclient/models/__init__.py,sha256=kd23EUpvaC7aLHdgk8farqKAQEx3lf7RvNT2jEatvlg,68
|
|
10
|
-
caselawclient/models/documents/__init__.py,sha256=
|
|
10
|
+
caselawclient/models/documents/__init__.py,sha256=4o6-8Iy5ZA8KEaqOt8xkpbqc7vwOzm8IoHvI8897mPk,19460
|
|
11
11
|
caselawclient/models/documents/body.py,sha256=IVcuSbgA7SvCvii_VE8MZy_54enDZY8VPoESkUDgfKU,6114
|
|
12
12
|
caselawclient/models/documents/exceptions.py,sha256=Mz1P8uNqf5w6uLnRwJt6xK7efsVqtd5VA-WXUUH7QLk,285
|
|
13
13
|
caselawclient/models/documents/statuses.py,sha256=Cp4dTQmJOtsU41EJcxy5dV1841pGD2PNWH0VrkDEv4Q,579
|
|
@@ -50,6 +50,7 @@ caselawclient/xquery/get_judgment.xqy,sha256=34fMHSBNPcXY3u3QIX3Bul8DMuWyGGHrhuY
|
|
|
50
50
|
caselawclient/xquery/get_judgment_checkout_status.xqy,sha256=mdY9UXLyzQdB7byEERPqentlr0YDLbXRVqH0h4UuZTQ,193
|
|
51
51
|
caselawclient/xquery/get_judgment_version.xqy,sha256=wF9k9-CBrqo8VbxxyTrD-AGzR3-3jMm25tRVCjxPLrU,292
|
|
52
52
|
caselawclient/xquery/get_last_modified.xqy,sha256=8fCm_7o_kkytCEmEeSTLWzLP7iOjuPV01IfHDgf6HaQ,172
|
|
53
|
+
caselawclient/xquery/get_missing_fclid.xqy,sha256=FAZZMtqow0VAf1D9LjBydT9kcOxiEIQC7GQgs4o68sA,520
|
|
53
54
|
caselawclient/xquery/get_next_document_sequence_number.xqy,sha256=LkGoaS7jZfaKDuZLi0apP5qHP1rpcM1HbqX3RUwquKY,450
|
|
54
55
|
caselawclient/xquery/get_pending_enrichment_for_version.xqy,sha256=8J5Pi-jMXJd_BgtpK4g6C9uR99HP57JpFv5WkoPfNuo,2016
|
|
55
56
|
caselawclient/xquery/get_pending_parse_for_version.xqy,sha256=9cjVZtHeBBjm-a7RMsn1PVJt_Ug78YFlmp5CN8VJ1jQ,1197
|
|
@@ -81,8 +82,8 @@ caselawclient/xquery/validate_all_documents.xqy,sha256=z_0YEXmRcZ-FaJM0ouKiTjdI4
|
|
|
81
82
|
caselawclient/xquery/validate_document.xqy,sha256=PgaDcnqCRJPIVqfmWsNlXmCLNKd21qkJrvY1RtNP7eA,140
|
|
82
83
|
caselawclient/xquery/xslt.xqy,sha256=w57wNijH3dkwHkpKeAxqjlghVflQwo8cq6jS_sm-erM,199
|
|
83
84
|
caselawclient/xquery/xslt_transform.xqy,sha256=cccaFiGkCcvSfDv007UriZ3I4ak2nTLP1trRZdbOoS8,2462
|
|
84
|
-
caselawclient/xquery_type_dicts.py,sha256=
|
|
85
|
-
ds_caselaw_marklogic_api_client-37.0.
|
|
86
|
-
ds_caselaw_marklogic_api_client-37.0.
|
|
87
|
-
ds_caselaw_marklogic_api_client-37.0.
|
|
88
|
-
ds_caselaw_marklogic_api_client-37.0.
|
|
85
|
+
caselawclient/xquery_type_dicts.py,sha256=zuyDGTkcN6voOXCm3APXItZ-Ey6tZ2hdZummZWzjl50,6489
|
|
86
|
+
ds_caselaw_marklogic_api_client-37.1.0.dist-info/LICENSE.md,sha256=fGMzyyLuQW-IAXUeDSCrRdsYW536aEWThdbpCjo6ZKg,1108
|
|
87
|
+
ds_caselaw_marklogic_api_client-37.1.0.dist-info/METADATA,sha256=rwN7JhdRezJIDek5Vq-u2_C6sPf4zDQ4GXhVnezYzg8,4206
|
|
88
|
+
ds_caselaw_marklogic_api_client-37.1.0.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
|
89
|
+
ds_caselaw_marklogic_api_client-37.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|