[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EP-tech] custom JSON export



CAUTION: This e-mail originated outside the University of Southampton.
Sorry, that got sent before it finished... here is what I meant:

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 (untested code):

$subdata->{status} = "200";

At the end of  _epdata_to_json function, for example, after
$subdata->{uri} = $epdata->uri;

If the status is supposed to be returned for the list, at the level of an eprint, you would have to add it somewhere in the output_list function,  making sure that the JSON structure remains intact.

Tomasz



________________________________
From: eprints-tech-bounces at ecs.soton.ac.uk <eprints-tech-bounces at ecs.soton.ac.uk> on behalf of Tomasz Neugebauer via Eprints-tech <eprints-tech at ecs.soton.ac.uk>
Sent: Thursday, May 13, 2021 12:00 PM
To: 'David R Newman' <drn at ecs.soton.ac.uk>; eprints-tech at ecs.soton.ac.uk <eprints-tech at ecs.soton.ac.uk>; phil at buildvoc.co.uk <phil at 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://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fjson-ld%2Fblob%2Fmaster%2Farchives%2F%255Bname%255D%2Fcfg%2Fplugins%2FEPrints%2FPlugin%2FExport%2FJSONLD.pm&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866032933%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=lIsHdy9JiYADqPjMtTrYsHgHLSYuvx3rxeue1UuvnEo%3D&amp;reserved=0<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fjson-ld%2Fblob%2Fmaster%2Farchives%2F%255Bname%255D%2Fcfg%2Fplugins%2FEPrints%2FPlugin%2FExport%2FJSONLD.pm&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866032933%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=lIsHdy9JiYADqPjMtTrYsHgHLSYuvx3rxeue1UuvnEo%3D&amp;reserved=0>

Tomasz



________________________________
From: eprints-tech-bounces at ecs.soton.ac.uk <eprints-tech-bounces at ecs.soton.ac.uk> on behalf of Phil Stacey via Eprints-tech <eprints-tech at ecs.soton.ac.uk>
Sent: Tuesday, May 11, 2021 1:21 PM
To: 'David R Newman' <drn at ecs.soton.ac.uk>; eprints-tech at ecs.soton.ac.uk <eprints-tech at 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<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Feprints.buildvoc.co.uk%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866032933%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=lbnOjxitgl0lTMkxPtiJCZt2q65aJb63XgRcuiW4w%2FE%3D&amp;reserved=0>





From: David R Newman <drn at ecs.soton.ac.uk>
Sent: 11 May 2021 08:13
To: eprints-tech at ecs.soton.ac.uk; phil at buildvoc.co.uk
Subject: Re: [EP-tech] custom JSON export



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;
                        $field_name = "id" if $field_name eq "eprintid";
                        $subdata->{$field_name} = $value;

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:

CAUTION: This e-mail originated outside the University of Southampton.

Good morning, working with an app to carry out reviews of automatic subject indexing created by ZBW called releasetool. https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fzbw%2Freleasetool&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866032933%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=M%2BteW66H1VCieZXeDYSN5PMF8uw1M2tA1BIqVPG6FWk%3D&amp;reserved=0<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fzbw%2Freleasetool&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866032933%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=M%2BteW66H1VCieZXeDYSN5PMF8uw1M2tA1BIqVPG6FWk%3D&amp;reserved=0>

For this tool to connect to a catalogue requires a certain format of JSON, for example ?id? instead of ?eprintid?

Buildvoc is running eprints version 3.4.1, can anyone advise how to update the configuration to export as shown below. (any help would be much appreciated)

{

                "record": {

                                "description": [

                                                "Much of the guidance in this document is given in terms of performance classifications in relation   to British or European Standards. In such cases, it will be necessary to demonstrate that a system   or product can meet the relevant performance classification. This will be achieved if the system or   product complies with one of the following.  a. They should be in accordance with a specification or design that has been shown by a specific   test to be capable of meeting that performance classification.  b. They should have been designed by using relevant design standards in order to meet that   performance classification.  c. They should have been assessed by applying relevant test evidence, in lieu of carrying out a   specific test, as being capable of meeting that performance classification.  NOTE: Some products are subject to Classification Without Further Testing (CWFT). For the purposes   of this approved document, such products can be considered to have been shown to be  able of meeting a performance specification as per paragraph B1a."

                                ],

                                "edition": [

                                                "2019"

                                ],

                                "id": "884",

                                "identifier_number": [

                                                "hdl:10419/56344 [Handle]"

                                ],

                                "identifier_url": [

                                                "https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.gov.uk%2Fgovernment%2Fpublications%2Ffire-safety-approved-document-b&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866032933%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=LVaSIC2uOSW8Lja7okPSGl1y5LaciAbHEL6Dt2rFSbI%3D&amp;reserved=0";<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.gov.uk%2Fgovernment%2Fpublications%2Ffire-safety-approved-document-b&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866032933%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=LVaSIC2uOSW8Lja7okPSGl1y5LaciAbHEL6Dt2rFSbI%3D&amp;reserved=0>

                                ],

                                "series": [

                                                "Approved Document B: Fire Safety - Volume 1: Dwellings"

                                ],

                                "subject": [

                                                "Appendix B: Performance of materials, products and structures",

                                                "Building standards"

                                ],

                                "title": "Para:B1 Introduction",

                                "type": "Book Section",

                                "type_genre": [

                                                "Working Paper"

                                ]

                },

                "status": 200

}

Best Regards,

Phil Stacey

building regulations guidance for fire safety<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Feprints.buildvoc.co.uk%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866032933%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=lbnOjxitgl0lTMkxPtiJCZt2q65aJb63XgRcuiW4w%2FE%3D&amp;reserved=0>





*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech

*** Archive: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866042896%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=0Az8PPRqW%2B8i3OlHky%2BkRzSf54sfcr5GdSMmfvvEg8Q%3D&amp;reserved=0<https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866042896%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=0Az8PPRqW%2B8i3OlHky%2BkRzSf54sfcr5GdSMmfvvEg8Q%3D&amp;reserved=0>

*** EPrints community wiki: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866042896%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=9L2fZgsJL8OziOK25nTUcalXuiykRBp9zpIhr%2FHU%2Bc0%3D&amp;reserved=0<https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866042896%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=9L2fZgsJL8OziOK25nTUcalXuiykRBp9zpIhr%2FHU%2Bc0%3D&amp;reserved=0>



[https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fipmcdn.avast.com%2Fimages%2Ficons%2Ficon-envelope-tick-green-avg-v1.png&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866042896%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=uONc4YkF%2BRZer%2FmAUohcu%2FtklLJ62oEJKqEhhEPoSOE%3D&amp;reserved=0]<https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.avg.com%2Femail-signature%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Demailclient&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866042896%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=5dA6dA0Ad4fPRq4CGoxCNASa4JnKee3pHOszvU6xZGE%3D&amp;reserved=0>

Virus-free. https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.avg.com%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866042896%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=s7meHjWD3BngOTPsa0CpPp%2FmREd%2F3FrowGQDqkFqNBA%3D&amp;reserved=0<https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.avg.com%2Femail-signature%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Demailclient&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C27de798b49144b000dd408d916de3398%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637565965866042896%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=5dA6dA0Ad4fPRq4CGoxCNASa4JnKee3pHOszvU6xZGE%3D&amp;reserved=0>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20210514/cb404f38/attachment-0001.html