oarepo-runtime 1.5.40__py3-none-any.whl → 1.5.41__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- oarepo_runtime/records/systemfields/owner.py +6 -0
- oarepo_runtime/services/custom_fields/mappings.py +84 -5
- {oarepo_runtime-1.5.40.dist-info → oarepo_runtime-1.5.41.dist-info}/METADATA +1 -1
- {oarepo_runtime-1.5.40.dist-info → oarepo_runtime-1.5.41.dist-info}/RECORD +8 -8
- {oarepo_runtime-1.5.40.dist-info → oarepo_runtime-1.5.41.dist-info}/WHEEL +1 -1
- {oarepo_runtime-1.5.40.dist-info → oarepo_runtime-1.5.41.dist-info}/LICENSE +0 -0
- {oarepo_runtime-1.5.40.dist-info → oarepo_runtime-1.5.41.dist-info}/entry_points.txt +0 -0
- {oarepo_runtime-1.5.40.dist-info → oarepo_runtime-1.5.41.dist-info}/top_level.txt +0 -0
@@ -19,7 +19,7 @@ from oarepo_runtime.records.systemfields.mapping import MappingSystemFieldMixin
|
|
19
19
|
class Mapping(InvenioMapping):
|
20
20
|
@classmethod
|
21
21
|
def properties_for_fields(
|
22
|
-
|
22
|
+
cls, given_fields_names, available_fields, field_name="custom_fields"
|
23
23
|
):
|
24
24
|
"""Prepare search mapping properties for each field."""
|
25
25
|
|
@@ -34,7 +34,7 @@ class Mapping(InvenioMapping):
|
|
34
34
|
|
35
35
|
@classmethod
|
36
36
|
def settings_for_fields(
|
37
|
-
|
37
|
+
cls, given_fields_names, available_fields, field_name="custom_fields"
|
38
38
|
):
|
39
39
|
"""Prepare mapping settings for each field."""
|
40
40
|
|
@@ -72,10 +72,11 @@ def prepare_cf_indices():
|
|
72
72
|
if record_class:
|
73
73
|
prepare_cf_index(record_class, config)
|
74
74
|
parent_class = getattr(record_class, "parent_record_cls", None)
|
75
|
-
|
75
|
+
prepare_parent_mapping(parent_class, config)
|
76
|
+
prepare_cf_index(parent_class, config, path=["parent", "properties"])
|
76
77
|
|
77
78
|
|
78
|
-
def prepare_cf_index(record_class, config):
|
79
|
+
def prepare_cf_index(record_class, config, path=[]):
|
79
80
|
if not record_class:
|
80
81
|
return
|
81
82
|
|
@@ -85,6 +86,11 @@ def prepare_cf_index(record_class, config):
|
|
85
86
|
settings = fld.mapping_settings
|
86
87
|
dynamic_templates = fld.dynamic_templates
|
87
88
|
|
89
|
+
for pth in reversed(path):
|
90
|
+
mapping = {
|
91
|
+
pth: mapping
|
92
|
+
}
|
93
|
+
|
88
94
|
# upload mapping
|
89
95
|
try:
|
90
96
|
record_index = dsl.Index(
|
@@ -109,6 +115,79 @@ def prepare_cf_index(record_class, config):
|
|
109
115
|
click.secho(e.info["error"]["reason"], fg="red")
|
110
116
|
|
111
117
|
|
118
|
+
def prepare_parent_mapping(parent_class, config):
|
119
|
+
if not parent_class:
|
120
|
+
return
|
121
|
+
parent_mapping = {
|
122
|
+
"parent": {
|
123
|
+
"type": "object",
|
124
|
+
"properties": {
|
125
|
+
"created": {
|
126
|
+
"type": "date",
|
127
|
+
"format": "strict_date_time||strict_date_time_no_millis||basic_date_time||basic_date_time_no_millis||basic_date||strict_date||strict_date_hour_minute_second||strict_date_hour_minute_second_fraction"
|
128
|
+
},
|
129
|
+
"id": {
|
130
|
+
"type": "keyword",
|
131
|
+
"ignore_above": 1024
|
132
|
+
},
|
133
|
+
"pid": {
|
134
|
+
"properties": {
|
135
|
+
"obj_type": {
|
136
|
+
"type": "keyword",
|
137
|
+
"ignore_above": 1024
|
138
|
+
},
|
139
|
+
"pid_type": {
|
140
|
+
"type": "keyword",
|
141
|
+
"ignore_above": 1024
|
142
|
+
},
|
143
|
+
"pk": {
|
144
|
+
"type": "long"
|
145
|
+
},
|
146
|
+
"status": {
|
147
|
+
"type": "keyword",
|
148
|
+
"ignore_above": 1024
|
149
|
+
}
|
150
|
+
}
|
151
|
+
},
|
152
|
+
"updated": {
|
153
|
+
"type": "date",
|
154
|
+
"format": "strict_date_time||strict_date_time_no_millis||basic_date_time||basic_date_time_no_millis||basic_date||strict_date||strict_date_hour_minute_second||strict_date_hour_minute_second_fraction"
|
155
|
+
},
|
156
|
+
"uuid": {
|
157
|
+
"type": "keyword",
|
158
|
+
"ignore_above": 1024
|
159
|
+
},
|
160
|
+
"version_id": {
|
161
|
+
"type": "long"
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
# upload mapping
|
168
|
+
try:
|
169
|
+
record_index = dsl.Index(
|
170
|
+
build_alias_name(
|
171
|
+
config.record_cls.index._name,
|
172
|
+
),
|
173
|
+
using=current_search_client,
|
174
|
+
)
|
175
|
+
update_index(record_index, {}, parent_mapping)
|
176
|
+
|
177
|
+
if hasattr(config, "draft_cls"):
|
178
|
+
draft_index = dsl.Index(
|
179
|
+
build_alias_name(
|
180
|
+
config.draft_cls.index._name,
|
181
|
+
),
|
182
|
+
using=current_search_client,
|
183
|
+
)
|
184
|
+
update_index(draft_index, {}, parent_mapping)
|
185
|
+
|
186
|
+
except search.RequestError as e:
|
187
|
+
click.secho("An error occurred while creating parent mapping.", fg="red")
|
188
|
+
click.secho(e.info["error"]["reason"], fg="red")
|
189
|
+
|
190
|
+
|
112
191
|
def update_index(record_index, settings, mapping, dynamic_templates=None):
|
113
192
|
if settings:
|
114
193
|
record_index.close()
|
@@ -125,6 +204,6 @@ def update_index(record_index, settings, mapping, dynamic_templates=None):
|
|
125
204
|
|
126
205
|
def get_mapping_fields(record_class) -> Iterable[MappingSystemFieldMixin]:
|
127
206
|
for cfg_name, cfg_value in inspect.getmembers(
|
128
|
-
|
207
|
+
record_class, lambda x: isinstance(x, MappingSystemFieldMixin)
|
129
208
|
):
|
130
209
|
yield cfg_value
|
@@ -60,7 +60,7 @@ oarepo_runtime/records/systemfields/featured_file.py,sha256=MbSaYR130_o5S9gEObln
|
|
60
60
|
oarepo_runtime/records/systemfields/has_draftcheck.py,sha256=4JkMEefPLpqtPtlTgK3UT0KzTRgyw5_Qtkss2qcz5xk,1643
|
61
61
|
oarepo_runtime/records/systemfields/icu.py,sha256=tAwplzy9y7C9Dm7HqcGZsDu2AKqVGXhCbKLsFlgVWg8,5921
|
62
62
|
oarepo_runtime/records/systemfields/mapping.py,sha256=tXOK_jkdY1pOUO7_VfChfDNB8UTi21GUXaidpugTnO8,1017
|
63
|
-
oarepo_runtime/records/systemfields/owner.py,sha256=
|
63
|
+
oarepo_runtime/records/systemfields/owner.py,sha256=U7CD71Ve9midaH72pV4A4_I7AdywqZW0BSRHAK10_qA,3944
|
64
64
|
oarepo_runtime/records/systemfields/record_status.py,sha256=U3kem4-JkNsT17e0iAl3HIAZ2MvO5lY_0U757aZvTKE,935
|
65
65
|
oarepo_runtime/records/systemfields/selectors.py,sha256=VlbV3FKP2h3PLU7H4-YsI4qrb0UO_SrhJ2dcsTBGoqI,900
|
66
66
|
oarepo_runtime/records/systemfields/synthetic.py,sha256=GC7g6BZSQqVV7bFk3x6Y1E4dFgvX7VwHuIFXEDpmuSs,4238
|
@@ -76,7 +76,7 @@ oarepo_runtime/services/config/__init__.py,sha256=SCqww5sV8qh3gmev6TE8EyJbD58juI
|
|
76
76
|
oarepo_runtime/services/config/permissions_presets.py,sha256=zApeA-2DYAlD--SzVz3vq_OFjq48Ko0pe08e4o2vxr4,6114
|
77
77
|
oarepo_runtime/services/config/service.py,sha256=2aq5jobPH22T1QqlJDommvAxJwo9aQGiqK5q-k-l9CA,4668
|
78
78
|
oarepo_runtime/services/custom_fields/__init__.py,sha256=xJ7XEyMJHPfIgX5JKpgpwh7SYc9Zee2dC5oC8cm99Qc,2282
|
79
|
-
oarepo_runtime/services/custom_fields/mappings.py,sha256=
|
79
|
+
oarepo_runtime/services/custom_fields/mappings.py,sha256=d2uWqk-x4nfoxMx7Uw_PGWKba_Wlf_ukpRB5ruU-RPU,7397
|
80
80
|
oarepo_runtime/services/expansions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
81
81
|
oarepo_runtime/services/expansions/expandable_fields.py,sha256=7DWKFL6ml8J7zGI6wm9LO7Xd6R0LSylsuq4lyRumNHQ,745
|
82
82
|
oarepo_runtime/services/expansions/service.py,sha256=HaEy76XOhDf__sQ91hi-8iH1hthM9q07pRhOmyZyVrs,144
|
@@ -116,9 +116,9 @@ oarepo_runtime/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
|
|
116
116
|
oarepo_runtime/utils/functools.py,sha256=gKS9YZtlIYcDvdNA9cmYO00yjiXBYV1jg8VpcRUyQyg,1324
|
117
117
|
oarepo_runtime/utils/path.py,sha256=V1NVyk3m12_YLbj7QHYvUpE1wScO78bYsX1LOLeXDkI,3108
|
118
118
|
tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
119
|
-
oarepo_runtime-1.5.
|
120
|
-
oarepo_runtime-1.5.
|
121
|
-
oarepo_runtime-1.5.
|
122
|
-
oarepo_runtime-1.5.
|
123
|
-
oarepo_runtime-1.5.
|
124
|
-
oarepo_runtime-1.5.
|
119
|
+
oarepo_runtime-1.5.41.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
|
120
|
+
oarepo_runtime-1.5.41.dist-info/METADATA,sha256=Kx5C6qgpAbZSJ0XztooVip_UQC9mTSJtPgrOciV_DsM,4680
|
121
|
+
oarepo_runtime-1.5.41.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
|
122
|
+
oarepo_runtime-1.5.41.dist-info/entry_points.txt,sha256=QrlXAKuPDVBinaSh_v3yO9_Nb9ZNmJCJ0VFcCW-z0Jg,327
|
123
|
+
oarepo_runtime-1.5.41.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
|
124
|
+
oarepo_runtime-1.5.41.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|