comparison sparql/mod_audiodb/mod_audiodb.c @ 599:c6debbac3216

End-to-end functioning SPARQL with audioDB storage module * AudioDB RDF storage module now works correctly with dimension and vectors * Apache module now returns a sparql version of the query results. * (including cleanup close/free calls).
author mas01mj
date Thu, 13 Aug 2009 11:20:56 +0000
parents e3790284fd4a
children 337e5962218a
comparison
equal deleted inserted replaced
598:b2a941a372fb 599:c6debbac3216
7 #include <librdf.h> 7 #include <librdf.h>
8 #include <apreq_module.h> 8 #include <apreq_module.h>
9 #include <apreq_parser.h> 9 #include <apreq_parser.h>
10 #include <apreq_param.h> 10 #include <apreq_param.h>
11 #include "apreq2/apreq_module_apache2.h" 11 #include "apreq2/apreq_module_apache2.h"
12 #include <rasqal.h>
12 13
13 static int ap_dump_table(void *baton, const char *key, const char *value) 14 static int ap_dump_table(void *baton, const char *key, const char *value)
14 { 15 {
15 if (key && value) 16 if (key && value)
16 fprintf(stderr, "%s:%s\n", key, value); 17 fprintf(stderr, "%s:%s\n", key, value);
44 return DECLINED; 45 return DECLINED;
45 46
46 const unsigned char *query_string = apr_table_get(form_table, "query"); 47 const unsigned char *query_string = apr_table_get(form_table, "query");
47 48
48 int rc = 0; 49 int rc = 0;
49
50 librdf_world* world = librdf_new_world(); 50 librdf_world* world = librdf_new_world();
51 if(!world)
52 {
53 rc = 1;
54 goto error;
55 }
56
57
58 librdf_world_open(world); 51 librdf_world_open(world);
59 librdf_world_set_logger(world, NULL, log_out); 52 librdf_world_set_logger(world, NULL, log_out);
60 librdf_storage* storage = librdf_new_storage(world, "audiodb", "/tmp/test.adb", "new='yes'"); 53 librdf_storage* storage = librdf_new_storage(world, "audiodb", "/tmp/test_database.adb", NULL);
61 if(!storage) 54 if(!storage)
62 { 55 {
63 rc = 2; 56 rc = 2;
64 goto error; 57 goto error;
65 } 58 }
83 { 76 {
84 rc = 4; 77 rc = 4;
85 goto error; 78 goto error;
86 } 79 }
87 80
88 ap_rprintf(r, "Everything went awesomely!"); 81 librdf_uri *sparql_uri = librdf_new_uri( world, "http://www.w3.org/TR/2006/WD-rdf-sparql-XMLres-20070614/");
82
83 unsigned char* out = librdf_query_results_to_string(results, sparql_uri, librdf_new_uri(world, "http://purl.org/ontology/af/"));
84 librdf_storage_close(storage);
85 librdf_free_storage(storage);
86 librdf_free_world(world);
87 ap_rprintf(r, out);
89 88
90 rc = 0; 89 rc = 0;
91 return r->status; 90 return r->status;
92 91
93 error: 92 error: