oarepo-runtime 1.5.68__py3-none-any.whl → 1.5.70__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- oarepo_runtime/datastreams/writers/attachments_service.py +1 -1
- oarepo_runtime/services/entity/__init__.py +0 -0
- oarepo_runtime/services/entity/config.py +14 -0
- oarepo_runtime/services/entity/schema.py +9 -0
- oarepo_runtime/services/entity/service.py +48 -0
- oarepo_runtime/services/results.py +50 -0
- {oarepo_runtime-1.5.68.dist-info → oarepo_runtime-1.5.70.dist-info}/METADATA +1 -1
- {oarepo_runtime-1.5.68.dist-info → oarepo_runtime-1.5.70.dist-info}/RECORD +12 -8
- {oarepo_runtime-1.5.68.dist-info → oarepo_runtime-1.5.70.dist-info}/LICENSE +0 -0
- {oarepo_runtime-1.5.68.dist-info → oarepo_runtime-1.5.70.dist-info}/WHEEL +0 -0
- {oarepo_runtime-1.5.68.dist-info → oarepo_runtime-1.5.70.dist-info}/entry_points.txt +0 -0
- {oarepo_runtime-1.5.68.dist-info → oarepo_runtime-1.5.70.dist-info}/top_level.txt +0 -0
@@ -51,7 +51,7 @@ class AttachmentsServiceWriter(BaseWriter):
|
|
51
51
|
|
52
52
|
with BulkUnitOfWork() as uow:
|
53
53
|
for entry in batch.entries:
|
54
|
-
if not entry.ok or entry.deleted:
|
54
|
+
if not entry.ok or entry.deleted or not entry.entry["files"]["enabled"]:
|
55
55
|
continue
|
56
56
|
with record_invenio_exceptions(entry):
|
57
57
|
self._write_attachments(entry, uow)
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
from invenio_records_resources.services.base.config import ServiceConfig
|
2
|
+
|
3
|
+
from ..results import ArrayRecordItem, ArrayRecordList
|
4
|
+
from .schema import KeywordEntitySchema
|
5
|
+
|
6
|
+
|
7
|
+
class EntityServiceConfig(ServiceConfig):
|
8
|
+
links_item = {}
|
9
|
+
result_item_cls = ArrayRecordItem
|
10
|
+
result_list_cls = ArrayRecordList
|
11
|
+
|
12
|
+
|
13
|
+
class KeywordEntityServiceConfig(EntityServiceConfig):
|
14
|
+
schema = KeywordEntitySchema
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import abc
|
2
|
+
from typing import Iterable
|
3
|
+
|
4
|
+
from invenio_records_resources.services.base.links import LinksTemplate
|
5
|
+
from invenio_records_resources.services.base.service import Service
|
6
|
+
from invenio_records_resources.services.records.schema import ServiceSchemaWrapper
|
7
|
+
|
8
|
+
|
9
|
+
class EntityService(Service):
|
10
|
+
@property
|
11
|
+
def links_item_tpl(self):
|
12
|
+
"""Item links template."""
|
13
|
+
return LinksTemplate(
|
14
|
+
self.config.links_item,
|
15
|
+
)
|
16
|
+
|
17
|
+
@property
|
18
|
+
def schema(self):
|
19
|
+
"""Returns the data schema instance."""
|
20
|
+
return ServiceSchemaWrapper(self, schema=self.config.schema)
|
21
|
+
|
22
|
+
@abc.abstractmethod
|
23
|
+
def read(self, identity, id_, **kwargs):
|
24
|
+
raise NotImplementedError()
|
25
|
+
|
26
|
+
@abc.abstractmethod
|
27
|
+
def read_many(self, identity, ids: Iterable[str], fields=None, **kwargs):
|
28
|
+
raise NotImplementedError()
|
29
|
+
|
30
|
+
|
31
|
+
class KeywordEntityService(EntityService):
|
32
|
+
|
33
|
+
def read(self, identity, id_, **kwargs):
|
34
|
+
result = {"keyword": self.config.keyword, "id": id_}
|
35
|
+
return self.result_item(
|
36
|
+
self, identity, record=result, links_tpl=self.links_item_tpl
|
37
|
+
)
|
38
|
+
|
39
|
+
def read_many(self, identity, ids: Iterable[str], fields=None, **kwargs):
|
40
|
+
if not ids:
|
41
|
+
return []
|
42
|
+
results = [{"keyword": self.config.keyword, "id": id} for id in ids]
|
43
|
+
return self.result_list(
|
44
|
+
self,
|
45
|
+
identity,
|
46
|
+
results=results,
|
47
|
+
links_item_tpl=self.links_item_tpl,
|
48
|
+
)
|
@@ -88,3 +88,53 @@ class RecordList(BaseRecordList):
|
|
88
88
|
expand=self._expand,
|
89
89
|
)
|
90
90
|
yield projection
|
91
|
+
|
92
|
+
|
93
|
+
class ArrayRecordItem(RecordItem):
|
94
|
+
"""Single record result."""
|
95
|
+
|
96
|
+
@property
|
97
|
+
def id(self):
|
98
|
+
"""Get the record id."""
|
99
|
+
return self._record["id"]
|
100
|
+
|
101
|
+
|
102
|
+
class ArrayRecordList(RecordList):
|
103
|
+
# move to runtime
|
104
|
+
|
105
|
+
@property
|
106
|
+
def total(self):
|
107
|
+
"""Get total number of hits."""
|
108
|
+
return len(self._results)
|
109
|
+
|
110
|
+
@property
|
111
|
+
def aggregations(self):
|
112
|
+
"""Get the search result aggregations."""
|
113
|
+
return None
|
114
|
+
|
115
|
+
@property
|
116
|
+
def hits(self):
|
117
|
+
"""Iterator over the hits."""
|
118
|
+
for hit in self._results:
|
119
|
+
# Project the record
|
120
|
+
projection = self._schema.dump(
|
121
|
+
hit,
|
122
|
+
context=dict(
|
123
|
+
identity=self._identity,
|
124
|
+
record=hit,
|
125
|
+
),
|
126
|
+
)
|
127
|
+
if self._links_item_tpl:
|
128
|
+
projection["links"] = self._links_item_tpl.expand(self._identity, hit)
|
129
|
+
if self._nested_links_item:
|
130
|
+
for link in self._nested_links_item:
|
131
|
+
link.expand(self._identity, hit, projection)
|
132
|
+
|
133
|
+
for c in self.components:
|
134
|
+
c.update_data(
|
135
|
+
identity=self._identity,
|
136
|
+
record=hit,
|
137
|
+
projection=projection,
|
138
|
+
expand=self._expand,
|
139
|
+
)
|
140
|
+
yield projection
|
@@ -35,7 +35,7 @@ oarepo_runtime/datastreams/readers/service.py,sha256=izIMcrsUr4_qRZXHKQZs7Tyn1Op
|
|
35
35
|
oarepo_runtime/datastreams/readers/yaml.py,sha256=U4nyJQ8ocM_ohp-eUN1RjVoNzYV9z7xQ1XiQKG_B9Kk,408
|
36
36
|
oarepo_runtime/datastreams/writers/__init__.py,sha256=PWufWNrixFhXv5wSv3_pzmrimroqVB2DVgTxVtY5FCg,526
|
37
37
|
oarepo_runtime/datastreams/writers/attachments_file.py,sha256=kV_IPAWawJ9PX-IfoncmLQXpdTbzRMsJie8uKX1vNp0,3161
|
38
|
-
oarepo_runtime/datastreams/writers/attachments_service.py,sha256=
|
38
|
+
oarepo_runtime/datastreams/writers/attachments_service.py,sha256=g_tbjUA3YnTE5gP21zlG2kIxneZsn0q95EVjlxB8s1M,4152
|
39
39
|
oarepo_runtime/datastreams/writers/service.py,sha256=PvCxYASDxOqT6iyL6cjw0aH41LaC1vwob4W3vnE9XmA,3920
|
40
40
|
oarepo_runtime/datastreams/writers/utils.py,sha256=Lk_ZLNeXTLuFEn04lw1-6bJ7duG6kwA8X4wf9c_GiL4,1067
|
41
41
|
oarepo_runtime/datastreams/writers/validation_errors.py,sha256=wOCXdniR6so_4ExpdFYYgBRyENp7_6kVFZM2L-Hy3G8,661
|
@@ -73,13 +73,17 @@ oarepo_runtime/resources/localized_ui_json_serializer.py,sha256=3V9cJaG_e1PMXKVX
|
|
73
73
|
oarepo_runtime/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
74
74
|
oarepo_runtime/services/components.py,sha256=zaZroTqzV5fz8yVAtRFLbbkTT9iD_dx9jFYANm3JIfI,3285
|
75
75
|
oarepo_runtime/services/generators.py,sha256=j87HitHA_w2awsz0C5IAAJ0qjg9JMtvdO3dvh6FQyfg,250
|
76
|
-
oarepo_runtime/services/results.py,sha256=
|
76
|
+
oarepo_runtime/services/results.py,sha256=_Din6CxQH7E5TP0TVZjIXJb2vyJRL_o_97jkUQo-GOc,4062
|
77
77
|
oarepo_runtime/services/search.py,sha256=9xGTN5Yg6eTdptQ9qjO_umbacf9ooMuHYGXWYfla4-M,6227
|
78
78
|
oarepo_runtime/services/config/__init__.py,sha256=dtlD84pJ6xI77UF22IPrCOt7tHD3g5DAEDApUdjDVFE,406
|
79
79
|
oarepo_runtime/services/config/permissions_presets.py,sha256=zApeA-2DYAlD--SzVz3vq_OFjq48Ko0pe08e4o2vxr4,6114
|
80
80
|
oarepo_runtime/services/config/service.py,sha256=s-dVbGkLICpsce6jgu7b5kzYFz9opWjSQFDBgbIhKio,4002
|
81
81
|
oarepo_runtime/services/custom_fields/__init__.py,sha256=_gqMcA_I3rdEZcBtCuDjO4wdVCqFML5NzaccuPx5a3o,2565
|
82
82
|
oarepo_runtime/services/custom_fields/mappings.py,sha256=tg9CAdxGOkd_n6RB5Z2_wSwo_A0wqEey8RMcZ79AHo0,6906
|
83
|
+
oarepo_runtime/services/entity/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
84
|
+
oarepo_runtime/services/entity/config.py,sha256=1jfdPrxSbMuKj7eOUNKRWTCPbBPyRV6MrWE4Vgf9rX0,399
|
85
|
+
oarepo_runtime/services/entity/schema.py,sha256=8TBpUFRITaBO7qCMz36cly1Hj4I1nLa9PeSAfWSa2YM,157
|
86
|
+
oarepo_runtime/services/entity/service.py,sha256=Y8QJ4sWZpX89IKTyo90pJlRfEN-iWg9tFN_5_RGMiaQ,1475
|
83
87
|
oarepo_runtime/services/expansions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
84
88
|
oarepo_runtime/services/expansions/expandable_fields.py,sha256=7DWKFL6ml8J7zGI6wm9LO7Xd6R0LSylsuq4lyRumNHQ,745
|
85
89
|
oarepo_runtime/services/expansions/service.py,sha256=HaEy76XOhDf__sQ91hi-8iH1hthM9q07pRhOmyZyVrs,144
|
@@ -126,9 +130,9 @@ tests/marshmallow_to_json/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
126
130
|
tests/marshmallow_to_json/test_datacite_ui_schema.py,sha256=82iLj8nW45lZOUewpWbLX3mpSkpa9lxo-vK-Qtv_1bU,48552
|
127
131
|
tests/marshmallow_to_json/test_simple_schema.py,sha256=izZN9p0v6kovtSZ6AdxBYmK_c6ZOti2_z_wPT_zXIr0,1500
|
128
132
|
tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
129
|
-
oarepo_runtime-1.5.
|
130
|
-
oarepo_runtime-1.5.
|
131
|
-
oarepo_runtime-1.5.
|
132
|
-
oarepo_runtime-1.5.
|
133
|
-
oarepo_runtime-1.5.
|
134
|
-
oarepo_runtime-1.5.
|
133
|
+
oarepo_runtime-1.5.70.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
|
134
|
+
oarepo_runtime-1.5.70.dist-info/METADATA,sha256=cTigl40zh7RbRJmxmOuElSMoWYL8OaKTlTfqgVTjVtY,4720
|
135
|
+
oarepo_runtime-1.5.70.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
136
|
+
oarepo_runtime-1.5.70.dist-info/entry_points.txt,sha256=0cschM0RHc6UJ1uudhu4EP0hrVStPGpgMO-XEDGRtY4,430
|
137
|
+
oarepo_runtime-1.5.70.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
|
138
|
+
oarepo_runtime-1.5.70.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|