UKGovLD / registry-core

Linked data registry - core application and example UI
https://github.com/UKGovLD/registry-core/wiki
Apache License 2.0
23 stars 9 forks source link

Batch upload - contents only #40

Closed dr-shorthair closed 9 years ago

dr-shorthair commented 9 years ago

Batch upload is currently supported for container+contents. Would be good to allow for contents-only.

(I just had an initial upload fail because of an error in the source file, but not before the register had already been created. Now I want to load just the contents, but can't do that in a batch. Grrr.)

6a6d74 commented 9 years ago

The problem with upload failing part-way through a multi-stage process (registry created, content pending) is why we wanted the 'real-delete' function (see issue #17).

Also, I was pretty sure that you can upload multiple items in a single pass ... see one of my old test files below. This is not a 'batch' upload - just treat this as a normal upload and the Registry should be able to process all the entries.

(I don't have a test instance to hand right now to check this ...)

numbers-two-to-five.ttl:

@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dct:     <http://purl.org/dc/terms/> .
@prefix skos:    <http://www.w3.org/2004/02/skos/core#> .
@prefix reg:     <http://purl.org/linked-data/registry#> .

<two>
      a       skos:Concept ;
      rdfs:label "two"@en ;
      dct:description "Equivalent to the sum of one and one; one less than three; 2."@en ;
      .
<three>
      a       skos:Concept ;
      rdfs:label "three"@en ;
      dct:description "Equivalent to the sum of one and two; one more than two; 3."@en ;
      .
<four>
      a       skos:Concept ;
      rdfs:label "four"@en ;
      dct:description "Equivalent to the product of two and two; one more than three, or six less than ten; 4."@en ;
      .
<five>
      a       skos:Concept ;
      rdfs:label "five"@en ;
      dct:description "Equivalent to the sum of two and three; one more than four, or half of ten; 5."@en ;
      .
6a6d74 commented 9 years ago

You can also see one of the registry-core test files indicating a multiple entity & register item upload here:

https://raw.githubusercontent.com/UKGovLD/registry-core/master/test/test-multi-item-validate.ttl

dr-shorthair commented 9 years ago

Tried loading content below as a simple upload through the UI, but got the following error:

image

cofog.ttl

@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix dc:    <http://purl.org/dc/elements/1.1/> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix reg:   <http://purl.org/linked-data/registry#> .
@prefix dct:   <http://purl.org/dc/terms/> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix skos:  <http://www.w3.org/2004/02/skos/core#> .
@prefix terms: <http://unstats.un.org/unsd/cr/references/terms/> .

<10-7>  a           skos:Concept ;
        rdfs:label      "Social exclusion n.e.c." ;
        skos:broader    <10> ;
        skos:narrower   <10-7-0> ;
        skos:notation   "10.7" ;
        skos:prefLabel  "Вопросы социальной неустроенности, не отнесенные к другим категориям"@ru , "Exclusión social n.e.p."@es , "Exclusion sociale n.c.a."@fr , "Social exclusion n.e.c."@en .

<09-3>  a           skos:Concept ;
        rdfs:label      "Post-secondary non-tertiary education" ;
        skos:broader    <09> ;
        skos:narrower   <09-3-0> ;
        skos:notation   "09.3" ;
        skos:prefLabel  "Продолженное среднее образование"@ru , "Enseignement postsecondaire non supérieur"@fr , "Post-secondary non-tertiary education"@en , "Enseñanza postsecundaria no terciaria"@es .

... [lots more]...
dr-shorthair commented 9 years ago

This one worked:

@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix dc:    <http://purl.org/dc/elements/1.1/> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix reg:   <http://purl.org/linked-data/registry#> .
@prefix dct:   <http://purl.org/dc/terms/> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix skos:  <http://www.w3.org/2004/02/skos/core#> .
@prefix terms: <http://unstats.un.org/unsd/cr/references/terms/> .

<_10-7> a reg:RegisterItem ; 
reg:definition [ reg:entity <10-7> ]; 
. 

<10-7>  a           skos:Concept ;
        rdfs:label      "Social exclusion n.e.c." ;
        skos:broader    <10> ;
        skos:narrower   <10-7-0> ;
        skos:notation   "10.7" ;
        skos:prefLabel  "Вопросы социальной неустроенности, не отнесенные к другим категориям"@ru , "Exclusión social n.e.p."@es , "Exclusion sociale n.c.a."@fr , "Social exclusion n.e.c."@en .

<_09-3> a reg:RegisterItem ; 
reg:definition [ reg:entity <09-3> ]; 
. 

<09-3>  a           skos:Concept ;
        rdfs:label      "Post-secondary non-tertiary education" ;
        skos:broader    <09> ;
        skos:narrower   <09-3-0> ;
        skos:notation   "09.3" ;
        skos:prefLabel  "Продолженное среднее образование"@ru , "Enseignement postsecondaire non supérieur"@fr , "Post-secondary non-tertiary education"@en , "Enseñanza postsecundaria no terciaria"@es .

...[lots more]...
6a6d74 commented 9 years ago

From the api documentation:

"""

Registration

In the common case (called simple below) the RDF payload supplied to the POST contains a set of statements about a single root resource, which is the entity being registered. An advanced usage (compound payload) is also supported in which the payload also contains a description of a reg:RegisterItem whose reg:definition / reg:entity reference indicates the entity being registered, whose description is also included in the payload. [...] """

and

"""

Batch Registration

The advanced usage also permits bulk registration of items by including multiple reg:RegisterItem instances, and multiple entities, within a single POST call. In that case the returned Content-Location header will be to the register itself. This mode does not support automatic allocation of URIs since the root resource would then be ambiguous.

[...] """

Whilst this is not 100% clear, it suggests that the payload validation of advanced registration (with multiple items) needs both reg-item and the entity.

If this is correct, then the documentation should be made clearer.

@dr-shorthair: does the need to provide the reg-item cause a lot of difficulty for your case?

der commented 9 years ago

We now support content-only batch upload (and content only batch edit). Plus all changes should now be properly wrapped in a transaction so a failure will now cleanly abort the entire batch.

dr-shorthair commented 9 years ago

You've just negated hours of SPARQL development! (Good stuff.)