Hi,

I have some content types on my site, all of them have the rdf mapping
uid | sioc:has_creator | rel

for the user that creates a node.

I can see the property correctly appearing in any node's page source code.

<span class="submitted"><span property="dc:date dc:created" content="2012-01-28T22:29:18+02:00" datatype="xsd:dateTime" rel="sioc:has_creator">By <span class="username" xml:lang="" about="/el/users/a_user" typeof="sioc:UserAccount" property="foaf:name">a_user</span> on Sat, 01/28/2012 - 22:29</span></span>

But I get no triples containing the sioc:has_creator predicate using the SPARQL endpoint. The only sioc predicate, that my endpoint returns triples for, is the num_replies.

I looked at the tables in the database and there are no sioc:has_creator there. That means this property was not indexed in the first place.

Is this a known issue?

Comments

scor’s picture

Project: SPARQL » RDF Extensions
Version: 7.x-2.0-alpha4 » 7.x-2.x-dev
Component: SPARQL Endpoint » Code

Thanks for the bug report! RDFx is the module responsible for building the RDF model of the node. moving to RDFx issue. I suspect this is related to entity not providing the right property, or rdfx not looking for the right property in entity API.

A quicker way to reproduce this bug without SPARQL is to install http://drupal.org/project/restws with rdfx and browse to node/1.rdf: the triple should be missing there too.

larjohn’s picture

You are welcome!

I did install the REST Web services module and I found what you expected: the nodes obly have num_replies from sioc...

Isn't rdfx supposed to look at every mapped property of the entity? Isn't that also true for special properties like the uid of a node?

I wish I was a little less busier to track it down..

larjohn’s picture

Can anyone confirm this happens on other installations?

The easy way, go to your sparql endpoint (www.example.org/sparql) and query the following

SELECT ?n WHERE {

?a 	"http://rdfs.org/sioc/ns#has_creator" ?n
}
djevans’s picture

Status: Active » Needs review
StatusFileSize
new1.08 KB

Confirmed on a base install of 7.x with RDFx, Rest WS, SPARQL modules, also using Devel Generate.

rdfx_get_rdf_model() loops over the node entity's property info, which is supplied by entity_metadata_node_entity_property_info() in entity/modules/node.info.inc, and includes the following:

function entity_metadata_node_entity_property_info() {
  $info = array();
  // Add meta-data about the basic node properties.
  $properties = &$info['node']['properties'];

  // .. snipped
  $properties['author'] = array(
    'label' => t("Author"),
    'type' => 'user',
    'description' => t("The author of the node."),
    'setter callback' => 'entity_property_verbatim_set',
    'setter permission' => 'administer nodes',
    'required' => TRUE,
    'schema field' => 'uid',
  );
  // .. snipped
}

'author' doesn't exist in the node entity's default RDF mappings (found in node_rdf_mapping() in node.module), but 'uid' does.
The patch checks for a 'schema field' key in the property array and uses that value ('uid') instead of the property index ('author') to look up the correct RDF mapping for that field.

Note that the changes won't be reflected in the triplestore until each existing node is re-saved.

scor’s picture

Super, thanks for nailing this down @djevans! I've tried the patch and it works. I'd like @larjohn to check if this works for him too, then I'll commit this patch.

larjohn’s picture

I have applied the patch @djevans posted. It seems to work form me too, even with my additions for the rev predicates (http://drupal.org/node/1073986#comment-5586796). Thanks @djevans!!

scor’s picture

Status: Needs review » Fixed

Thanks @larjohn for the bug report and @djevans for the patch. Fixed with http://drupalcode.org/project/rdfx.git/commit/4b67de7

scor’s picture

Status: Fixed » Active
Issue tags: +Needs tests, +RDF, +sprint

Now that I think about it, I forgot we have some tests in rdfx. Coverage for this bug could easily be added in the node serialization test.

scor’s picture

Issue tags: +Novice

this needs a patch to add a bunch of lines to an existing test at the end of rdfx.test. should not be too hard.