ali1k / ld-r

Linked Data Reactor (LD-R)
http://ld-r.org
Other
127 stars 30 forks source link

blank nodes cannot be viewed as subjects #77

Open mathib opened 4 years ago

mathib commented 4 years ago

Expected Behavior

Being able to view triples with a BN as the subject, either through the details view on the BN when in object position or when focusing on the BN directly.

Actual Behavior

I can see BNs appear in the facet browser list and when viewing individual resources as long as the BNs are in the object position of triples. If I want to view details of a BN object, I cannot see the triples with this BN as the subject. If I click on the blank node, I end up on an empty LD-R page of that BN (no triples are shown, only the BN ID is presented). I played a bit with the settings in reactor.js for the property pointing to BNs and set hasBlankNode: 1, but without success.

I did some tests with GraphDB and Stardog.

With GraphDB, I receive an error from GraphDB, that it received an erroneous SPARQL query (BN is treated as an absolute URI):

SELECT ?p ?o (count(DISTINCT ?extendedVal) AS ?hasExtendedValue) (SAMPLE(?olb) AS ?oLabel) (SAMPLE(?otb) AS ?oTitle) WHERE {
                    <genid-53084fa0d170462385c61b802e2a8c51-54A3A8A758360AD4000A05D1876753C6> ?p ?o .
                    OPTIONAL {?o ?uri ?extendedVal .}
                    OPTIONAL {?o rdfs:label ?ol .}
                    OPTIONAL {?o dcterms:title ?ot .}
                    BIND ( IF (BOUND (?ol), ?ol, '' )  as ?olb  ) .
                    BIND ( IF (BOUND (?ot), ?ot, '' )  as ?otb  ) .
            } GROUP BY ?p ?o

'MALFORMED QUERY: Not a valid (absolute) IRI: genid-0ec5327183c642a3aff8f0b3208583c7-130'

With Stardog, I only get an error from LD-R

TypeError: Cannot read property 'value' of undefined
    at C:\Users\username\Desktop\ld-r-mathib\services\utils\ResourceUtil.js:354:92
    at eachfn (C:\Users\username\Desktop\ld-r-mathib\node_modules\async\dist\async.js:2948:28)
    at replenish (C:\Users\username\Desktop\ld-r-mathib\node_modules\async\dist\async.js:440:21)
    at C:\Users\username\Desktop\ld-r-mathib\node_modules\async\dist\async.js:445:13
    at awaitify (C:\Users\username\Desktop\ld-r-mathib\node_modules\async\dist\async.js:2947:9)
    at awaitable (C:\Users\username\Desktop\ld-r-mathib\node_modules\async\dist\async.js:208:32)
    at Object.parallelLimit (C:\Users\username\Desktop\ld-r-mathib\node_modules\async\dist\async.js:3053:16)
    at C:\Users\username\Desktop\ld-r-mathib\services\utils\ResourceUtil.js:411:26
    at C:\Users\username\Desktop\ld-r-mathib\services\utils\Configurator.js:344:11
    at DynamicConfigurator.prepareDynamicPropertyConfig (C:\Users\username\Desktop\ld-r-mathib\plugins\dynamicConfiguration\DynamicConfigurator.js:655:9)
    at C:\Users\username\Desktop\ld-r-mathib\services\utils\Configurator.js:219:29
    at C:\Users\username\Desktop\ld-r-mathib\services\utils\Configurator.js:193:11
    at DynamicConfigurator.prepareDynamicResourceConfig (C:\Users\username\Desktop\ld-r-mathib\plugins\dynamicConfiguration\DynamicConfigurator.js:571:9)
    at C:\Users\username\Desktop\ld-r-mathib\services\utils\Configurator.js:124:29
    at C:\Users\username\Desktop\ld-r-mathib\services\utils\Configurator.js:99:9
    at DynamicConfigurator.prepareDynamicDatasetConfig (C:\Users\username\Desktop\ld-r-mathib\plugins\dynamicConfiguration\DynamicConfigurator.js:333:9)
    at Configurator.prepareDatasetConfig (C:\Users\username\Desktop\ld-r-mathib\services\utils\Configurator.js:83:27)
    at Configurator.prepareResourceConfig (C:\Users\username\Desktop\ld-r-mathib\services\utils\Configurator.js:118:12)
    at Configurator.preparePropertyConfig (C:\Users\username\Desktop\ld-r-mathib\services\utils\Configurator.js:212:12)
    at ResourceUtil.parseObjectProperties (C:\Users\username\Desktop\ld-r-mathib\services\utils\ResourceUtil.js:343:20)
    at C:\Users\username\Desktop\ld-r-mathib\services\resource.js:236:22
From previous event:
    at Request.RP$exposed [as then] (C:\Users\username\Desktop\ld-r-mathib\node_modules\request-promise-core\lib\plumbing.js:145:61)
    at C:\Users\username\Desktop\ld-r-mathib\services\resource.js:235:12
    at C:\Users\username\Desktop\ld-r-mathib\services\utils\dynamicHelpers.js:98:7
    at C:\Users\username\Desktop\ld-r-mathib\services\utils\dynamicHelpers.js:69:5
    at DynamicConfigurator.prepareDynamicServerConfig (C:\Users\username\Desktop\ld-r-mathib\plugins\dynamicConfiguration\DynamicConfigurator.js:122:9)
    at prepareDGFunc (C:\Users\username\Desktop\ld-r-mathib\services\utils\dynamicHelpers.js:32:23)
    at getDynamicEndpointParameters (C:\Users\username\Desktop\ld-r-mathib\services\utils\dynamicHelpers.js:79:5)
    at Object.read (C:\Users\username\Desktop\ld-r-mathib\services\resource.js:227:56)
    at Immediate.executeRequest (C:\Users\username\Desktop\ld-r-mathib\node_modules\fetchr\libs\fetcher.js:234:21)
    at runCallback (timers.js:706:11)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)

Steps to Reproduce the Problem

  1. Set up a triplestore and load some blank nodes (incl. incoming and outgoing triples)
  2. Try to view the outgoing triples using either detail view (object position) or by focusing on the BN

Specifications

mathib commented 4 years ago

At least with GraphDB, I might have found a workaround but it's specific for GraphDB. It's possible to get the internal GraphDB ID of each URI, BN, literal, etc.: http://graphdb.ontotext.com/documentation/free/query-behaviour.html?highlight=blank%20node

With the following query, the ID can be retrieved of a BN:

PREFIX ent: <http://www.ontotext.com/owlim/entity#>
SELECT * WHERE {
       FILTER (isBlank(?bn))
    ?bn ent:id ?id .
} ORDER BY ?id

And with this query, the ID (xsd:long, eg 5660) can be used to query information

PREFIX ent: <http://www.ontotext.com/owlim/entity#>
SELECT * WHERE {
    ?s ent:id 5660 ; ?p ?o .
}
mathib commented 4 years ago

A more generic solution might be to find blank nodes by matching their projected string.

SELECT *
WHERE { 
    ?bn ?p ?o .
    BIND(STR(?bn) AS ?bnString)
    FILTER(?bnString = "genid-6aa0586592bf40cc83e34d1771ad8adf-0")
}

This works for Stardog, but sadly not for GraphDB... (empty strings are returned for ?bnString)