Skip to content

Commit

Permalink
Merge pull request #286 from oarepo/add_rdm_mapping_fields
Browse files Browse the repository at this point in the history
additional rdm fields
  • Loading branch information
Alzpeta authored Jan 7, 2025
2 parents a21096b + 3622c7d commit a45ec28
Show file tree
Hide file tree
Showing 8 changed files with 926 additions and 501 deletions.
168 changes: 168 additions & 0 deletions oarepo_model_builder/builtin_models/invenio.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,174 @@
}
}
},
"is_published": {
"type": "boolean",
"marshmallow": {
"read": false,
"write": false
},
"sample": {
"skip": true
},
"facets": {
"searchable": true,
"facet": false
}
},
"deletion_status": {
"type": "keyword",
"marshmallow": {
"read": false,
"write": false
},
"sample": {
"skip": true
},
"facets": {
"searchable": true,
"facet": false
}
},
"version_id": {
"type": "integer",
"marshmallow": {
"read": false,
"write": false
},
"sample": {
"skip": true
},
"facets": {
"searchable": true,
"facet": false
}
},
"is_deleted": {
"type": "boolean",
"marshmallow": {
"read": false,
"write": false
},
"sample": {
"skip": true
},
"facets": {
"searchable": true,
"facet": false
}
},
"versions": {
"type": "object",
"marshmallow": {
"skip": true,
"read": false,
"write": false,
"generate": false,
"class": "FakeVersionsSchema"
},
"ui": {
"marshmallow": {
"read": false,
"write": false,
"generate": false,
"skip": true,
"class": "FakeVersionsUISchema"
}
},
"sample": {
"skip": true
},
"facets": {
"searchable": true,
"facet": false
},
"properties": {
"index": {
"type": "integer",
"marshmallow": {
"read": false,
"write": false
},
"sample": {
"skip": true
},
"facets": {
"searchable": true,
"facet": false
}
},
"is_latest": {
"type": "boolean",
"marshmallow": {
"read": false,
"write": false
},
"sample": {
"skip": true
},
"facets": {
"searchable": true,
"facet": false
}
},
"is_latest_draft": {
"type": "boolean",
"marshmallow": {
"read": false,
"write": false
},
"sample": {
"skip": true
},
"facets": {
"searchable": true,
"facet": false
}
},
"latest_id": {
"type": "keyword",
"marshmallow": {
"read": false,
"write": false
},
"sample": {
"skip": true
},
"facets": {
"searchable": true,
"facet": false
}
},
"latest_index": {
"type": "integer",
"marshmallow": {
"read": false,
"write": false
},
"sample": {
"skip": true
},
"facets": {
"searchable": true,
"facet": false
}
},
"next_draft_id": {
"type": "keyword",
"marshmallow": {
"read": false,
"write": false
},
"sample": {
"skip": true
},
"facets": {
"searchable": true,
"facet": false
}
}
}
},
"$schema": {
"type": "keyword",
"marshmallow": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def _build_class_name(
):
schema_class = marshmallow_config.get("class")
generate = marshmallow_config.get("generate", True)

if schema_class:
qualified_schema_class = qualified_name(marshmallow_module, schema_class)
if qualified_schema_class != schema_class:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-model-builder
version = 4.0.99
version = 4.0.100
description = A utility library that generates OARepo required data model files from a JSON specification file
authors = Miroslav Bauer <[email protected]>, Miroslav Simek <[email protected]>
readme = README.md
Expand Down
59 changes: 32 additions & 27 deletions tests/test_builder_from_entrypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Meta:
data = builder.filesystem.open(
os.path.join("test", "services", "records", "ui_schema.py")
).read()
print(data)

assert (
strip_whitespaces(
"""
Expand All @@ -84,32 +84,37 @@ class Meta:
os.path.join("test", "records", "mappings", "os-v2", "test", "test-1.0.0.json")
)
data = json.loads(data)
assert data == {
"mappings": {
"properties": {
"$schema": {"type": "keyword", "ignore_above": 1024},
"a": {"type": "keyword", "ignore_above": 1024},
"created": {
"type": "date",
"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",
},
"id": {"type": "keyword", "ignore_above": 1024},
"pid": {
"properties": {
"obj_type": {"ignore_above": 1024, "type": "keyword"},
"pid_type": {"ignore_above": 1024, "type": "keyword"},
"pk": {"type": "integer"},
"status": {"ignore_above": 1024, "type": "keyword"},
},
"type": "object",
},
"updated": {
"type": "date",
"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",
},
},
}
}
print(data)
assert data == {'mappings': {'properties': {'$schema': {'ignore_above': 1024,
'type': 'keyword'},
'a': {'ignore_above': 1024, 'type': 'keyword'},
'created': {'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',
'type': 'date'},
'deletion_status': {'ignore_above': 1024,
'type': 'keyword'},
'id': {'ignore_above': 1024, 'type': 'keyword'},
'is_deleted': {'type': 'boolean'},
'is_published': {'type': 'boolean'},
'pid': {'properties': {'obj_type': {'ignore_above': 1024,
'type': 'keyword'},
'pid_type': {'ignore_above': 1024,
'type': 'keyword'},
'pk': {'type': 'integer'},
'status': {'ignore_above': 1024,
'type': 'keyword'}},
'type': 'object'},
'updated': {'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',
'type': 'date'},
'version_id': {'type': 'integer'},
'versions': {'properties': {'index': {'type': 'integer'},
'is_latest': {'type': 'boolean'},
'is_latest_draft': {'type': 'boolean'},
'latest_id': {'ignore_above': 1024,
'type': 'keyword'},
'latest_index': {'type': 'integer'},
'next_draft_id': {'ignore_above': 1024,
'type': 'keyword'}},
'type': 'object'}}}}

data = builder.filesystem.read("setup.cfg")
assert "version = 1.0.0" in data
Expand Down
Loading

0 comments on commit a45ec28

Please sign in to comment.