EPrints Technical Mailing List Archive
See the EPrints wiki for instructions on how to join this mailing list and related information.
Message: #08614
< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First
Re: [EP-tech] custom JSON export
- To: "'David R Newman'" <drn@ecs.soton.ac.uk>, "eprints-tech@ecs.soton.ac.uk" <eprints-tech@ecs.soton.ac.uk>, "phil@buildvoc.co.uk" <phil@buildvoc.co.uk>, Tomasz Neugebauer <Tomasz.Neugebauer@concordia.ca>
- Subject: Re: [EP-tech] custom JSON export
- From: Tomasz Neugebauer <Tomasz.Neugebauer@concordia.ca>
- Date: Fri, 14 May 2021 13:36:31 +0000
CAUTION: This e-mail originated outside the University of Southampton.
It's not clear from your sample output if the "status": 200 is
supposed to be a listed as a field of each eprint? If so, then you would just need to add something like this:
If
not, you would have to add it somewhere in here:
Tomasz
From: eprints-tech-bounces@ecs.soton.ac.uk <eprints-tech-bounces@ecs.soton.ac.uk> on behalf of Tomasz Neugebauer via Eprints-tech <eprints-tech@ecs.soton.ac.uk>
Sent: Thursday, May 13, 2021 12:00 PM To: 'David R Newman' <drn@ecs.soton.ac.uk>; eprints-tech@ecs.soton.ac.uk <eprints-tech@ecs.soton.ac.uk>; phil@buildvoc.co.uk <phil@buildvoc.co.uk> Subject: Re: [EP-tech] custom JSON export
CAUTION: This e-mail originated outside the University of Southampton.
Hi Phil,
It's great to see your work on this moving forward!
I really appreciate David's solution to this, so if you can make that work, great!
My two cents on this: the challenge with the native EPrints JSON export is that it is very comprehensive, which is not convenient when you want to create something more custom. It is a remapping of "everything" into JSON from the XML export. If
your JSON export only needs a few fields formatted in a specific way, you might want to only include those fields rather than process "everything" in the
epdata-to-json
function. So rather filtering out what you want changed in the default JSON export, intentionally only include what you want included, just in the way you need.
That was the approach taken with this custom JSON export: https://github.com/eprintsug/json-ld/blob/master/archives/%5Bname%5D/cfg/plugins/EPrints/Plugin/Export/JSONLD.pm
Tomasz
From: eprints-tech-bounces@ecs.soton.ac.uk <eprints-tech-bounces@ecs.soton.ac.uk> on behalf of Phil Stacey via Eprints-tech <eprints-tech@ecs.soton.ac.uk>
Sent: Tuesday, May 11, 2021 1:21 PM To: 'David R Newman' <drn@ecs.soton.ac.uk>; eprints-tech@ecs.soton.ac.uk <eprints-tech@ecs.soton.ac.uk> Subject: Re: [EP-tech] custom JSON export
CAUTION: This e-mail originated outside the University of Southampton.
David many thanks for the detail tutorial. Looks good The releasetool needs to have “status” as part of the response ] }, "status": 200 }
Any ideas ? Really appreciate your help will be publishing the releasetool image soon which is connected to eprints, annif, and jena fuseki (for keywords) if anyone wants to use this tool for evaluating automatic subject indexing keywords..
Best Regards, Phil Stacey building regulations guidance for fire safety
From: David R Newman <drn@ecs.soton.ac.uk>
Hi Phil, So it sounds like you need to make just a small tweak to the existing JSON export plugin. What you want to do is copy the existing JSON export plugin to your archive: cp EPRINTS_PATH/perl_lib/EPrints/Plugin/Export/JSON.pm EPRINTS_PATH/archives/ARCHIVE_NAME/cfg/plugins/EPrints/Plugin/Export/ReleaseToolJSON.pm Then edit at the top of the file, replacing each occurence of Export::JSON with Export::ReleaseToolJSON and replacing Export::TextFile with Export::JSON. When you get down to the "new" sub remove all the $self->... lines except the one for "name" and update this to "Release Tool JSON". Then remove all the other subs (functions) except "sub _epdata_to_json". In there you will need to make a small change, removing: $subdata->{$field->get_name} = $value; and replacing with: my $field_name = $field->get_name; Once you have done this. Run "epadmin test" to check everything is OK and the reload the webserver (e.g. apachectl graceful). If you now go to an item and look under its available export formats you should now see one labelled "Release Tool JSON". This will be exactly the same export (as JSON) except wherever eprintid was used before id will be used instead. However, this will mean that where documents use to reference the eprint with "eprintid" they will now use "id", which may not be what you want. If so, you may need to amend the if statement to take the depth into account: $field_name = "id" if $field_name eq "eprintid" && $depth == 1; Regards David Newman On 11/05/2021 06:13, Phil Stacey via Eprints-tech wrote:
|
- Follow-Ups:
- Re: [EP-tech] custom JSON export
- From: Tomasz Neugebauer <Tomasz.Neugebauer@concordia.ca>
- Re: [EP-tech] custom JSON export
- References:
- [EP-tech] custom JSON export
- From: <phil@buildvoc.co.uk>
- Re: [EP-tech] custom JSON export
- From: <phil@buildvoc.co.uk>
- Re: [EP-tech] custom JSON export
- From: Tomasz Neugebauer <Tomasz.Neugebauer@concordia.ca>
- Re: [EP-tech] custom JSON export
- From: Tomasz Neugebauer <Tomasz.Neugebauer@concordia.ca>
- [EP-tech] custom JSON export
- Prev by Date: [EP-tech] Antwort: Red and Publish Table
- Next by Date: Re: [EP-tech] custom JSON export
- Previous by thread: [EP-tech] EPrints/CRIS
- Next by thread: [EP-tech] DOI handling in orcid_support_advance
- Index(es):