diff --git a/inspirehep/dojson/hep/fields/bd90x99x.py b/inspirehep/dojson/hep/fields/bd90x99x.py index f6fffcbeef..d9ec9b2345 100644 --- a/inspirehep/dojson/hep/fields/bd90x99x.py +++ b/inspirehep/dojson/hep/fields/bd90x99x.py @@ -58,7 +58,7 @@ def get_value(value): mapping = [ ('o', rb.set_number), ('m', rb.add_misc), - ('x', rb.add_raw_reference), + ('x', partial(rb.add_raw_reference, source='dojson')), ('1', rb.set_texkey), ('u', rb.add_url), ('r', rb.add_report_number), @@ -74,6 +74,7 @@ def get_value(value): ('h', rb.add_author), ('e', partial(rb.add_author, role='ed.')) ] + for field, method in mapping: for element in force_force_list(value.get(field)): if element: diff --git a/inspirehep/modules/records/jsonschemas/records/elements/reference.json b/inspirehep/modules/records/jsonschemas/records/elements/reference.json index c57f19bc0c..de77208f41 100644 --- a/inspirehep/modules/records/jsonschemas/records/elements/reference.json +++ b/inspirehep/modules/records/jsonschemas/records/elements/reference.json @@ -1,5 +1,5 @@ { - "description": "An article or thesis or book or...", + "description": "record-like Schema for a Publication's reference", "title": "Reference", "$schema": "http://json-schema.org/schema#", "type": "object", @@ -20,9 +20,13 @@ "value": { "type": "string" }, - "serialization": { + "source": { "type": "string", - "description": "E.g. refextract, text, JATS, Elsevier, BibTeX..." + "description": "E.g. refextract, JATS, Elsevier" + }, + "format": { + "type": "string", + "description": "E.g. text, json, xml, bibtex" } } } diff --git a/inspirehep/modules/references/processors.py b/inspirehep/modules/references/processors.py index ae23bffdaf..de73e14132 100644 --- a/inspirehep/modules/references/processors.py +++ b/inspirehep/modules/references/processors.py @@ -92,11 +92,13 @@ def add_misc(self, misc): self._ensure_field('misc', []) self.obj['misc'].append(misc) - def add_raw_reference(self, raw_reference, serialization='text'): + def add_raw_reference(self, raw_reference, source='reference_builder', + ref_format='text'): self._ensure_field('raw_reference', []) self.obj['raw_reference'].append({ 'value': raw_reference, - 'serialization': serialization}) + 'source': source, + 'format': ref_format}) def set_year(self, year): try: diff --git a/tests/unit/references/test_processors.py b/tests/unit/references/test_processors.py index 16f6fd6f00..e4f1835978 100644 --- a/tests/unit/references/test_processors.py +++ b/tests/unit/references/test_processors.py @@ -28,7 +28,7 @@ def test_reference_builder_no_uids(): rb.set_number('1') rb.set_texkey('book') rb.add_title('Awesome Paper') - rb.add_raw_reference('[1] Awesome Paper') + rb.add_raw_reference('[1] Awesome Paper', 'arXiv') rb.add_misc('misc 0') rb.add_misc('misc 1') rb.add_author('Cox, Brian') @@ -53,8 +53,10 @@ def test_reference_builder_no_uids(): 'texkey': 'book', 'titles': [{'title': 'Awesome Paper'}], 'raw_reference': [ - {'value': '[1] Awesome Paper', 'serialization': 'text'}, - {'value': 'BAD PUBNOTE', 'serialization': 'text'} + {'value': '[1] Awesome Paper', 'format': 'text', + 'source': 'arXiv'}, + {'value': 'BAD PUBNOTE', 'format': 'text', + 'source': 'reference_builder'} ], 'misc': ['misc 0', 'misc 1'], 'authors': [{'full_name': 'Cox, Brian'},