/[drupal]/contributions/modules/semantic_search/tests/arctest.php
ViewVC logotype

Contents of /contributions/modules/semantic_search/tests/arctest.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Tue Jun 5 06:37:07 2007 UTC (2 years, 5 months ago) by hendler
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5
File MIME type: text/x-php
adding files from our SVN
1 <?php
2
3 /**
4 * This test is against arc to verify that a field can be updated (incremented)
5 * @package SONIA
6 *
7 * */
8
9 define('ARC_LOCATION','/var/biz/sonia_civic/trunk/contrib/arc/');
10 define('ARC_DB_PREFIX_NAME','semantic_search');
11 define ('ARC_DEFAULT_NS_PREFIX', 'semantic_search');
12 define ('ARC_DEFAULT_PREFIXES',
13 'PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
14 PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
15 PREFIX owl: <http://www.w3.org/2002/07/owl#>
16 PREFIX foaf: <http://xmlns.com/foaf/0.1/> ');
17
18 $rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
19 $rdfs = "http://www.w3.org/2000/01/rdf-schema#";
20 $owl = "http://www.w3.org/2002/07/owl#";
21 $dc ="http://purl.org/dc/elements/1.1/";
22
23 define('SONIA_DEFAULT_MODEL_PREFIX','sonia_test');
24 define('SONIA_DEFAULT_MODEL_IRI','http://fsearch.org/ns/'.SONIA_DEFAULT_MODEL_PREFIX.'');
25 define('SONIA_SPECIAL_SUBJECT','http://arc.web-semantics.org/');
26 define('SONIA_SPECIAL_PREDICATE',SONIA_DEFAULT_MODEL_IRI.'#count');
27
28 $config = array(
29 /* db */
30 "db_host"=>"localhost",
31 "db_name"=>"arc_test",
32 "db_user"=>"root",
33 "db_pwd"=>"",
34 "prefix"=> ARC_DB_PREFIX_NAME,
35 /* store */
36 "store_type"=>"basic",
37 "id_type"=>"hash_int",
38 "reversible_consolidation"=>false,
39 "encode_values"=>false,
40 "index_type"=>"advanced",
41 "index_graph_iris"=>true,
42 "index_words"=>true,
43 "charset"=>"utf8",
44 "prefixes"=>array(
45 "rdf"=> $rdf,
46 "rdfs"=> $rdfs,
47 "owl"=> $owl,
48 "dc"=> $dc,
49 "dct"=>"http://purl.org/dc/terms/",
50 "foaf"=>"http://xmlns.com/foaf/0.1/"
51 )
52 );
53
54
55 $api_args = array(
56 "inc_path"=>ARC_LOCATION,
57 "config"=>$config
58 );
59
60 include(ARC_LOCATION."ARC_api.php");
61 $api = new ARC_api($api_args);
62 $api->db_connect();
63
64 if (!$api->store_exists()) $success=$api->create_store();
65
66 echo (isset($success)) ? 'created store' : 'store not created: it exists ';
67 echo '<br />';
68
69
70
71 $args = array(
72 "result_type"=>"array", // (plain|array|json|xml)
73 "graph_iri"=>SONIA_DEFAULT_MODEL_IRI, // required
74 "add_triple"=>'<'.SONIA_SPECIAL_SUBJECT.'> <'.SONIA_SPECIAL_PREDICATE.'> "1" .'
75 );
76
77 $tmp =$api->add_data($args);
78
79 print_r($tmp);
80
81 // now update the data
82 $args = array();
83 $args['result_type'] = 'array';
84 $args['del_s'] = SONIA_SPECIAL_SUBJECT;
85 $args['del_p'] = SONIA_SPECIAL_PREDICATE;
86 $args['add_triple'] = '<'.SONIA_SPECIAL_SUBJECT.'> <'.SONIA_SPECIAL_PREDICATE.'> "11" .';
87 $args['graph_iri'] = SONIA_DEFAULT_MODEL_IRI;
88 $result = $api->update_data($args);
89
90 print_r($result);
91
92 $query = ARC_DEFAULT_PREFIXES;
93 //get if exists
94 $query .= 'SELECT ?s
95 WHERE {
96 <'.SONIA_SPECIAL_SUBJECT.'> <'.SONIA_SPECIAL_PREDICATE.'> ?s .
97 }';
98 //echo nl2br(htmlentities($query)).'<br>';
99 $qr1 = $api->query(array("query"=>$query, "result_type"=>"rows"));
100 $rows = $qr1["result"];
101 $row_count = $qr1["row_count"];
102 $temp_facet_hiercharchy = array();
103 $answer = $rows[0]['s'];
104 echo "\$answer $answer<hr>";
105 print_r($qr1);
106 $answer = $answer +10;
107
108
109
110 // now update the data
111 $args = array();
112 $args['result_type'] = 'array';
113 $args['del_s'] = SONIA_SPECIAL_SUBJECT;
114 $args['del_p'] = SONIA_SPECIAL_PREDICATE;
115 $args['add_triple'] = '<'.SONIA_SPECIAL_SUBJECT.'> <'.SONIA_SPECIAL_PREDICATE.'> "'.$answer.'" .';
116 $args['graph_iri'] = SONIA_DEFAULT_MODEL_IRI;
117 $result = $api->update_data($args);
118
119 print_r($result);
120
121 $query = ARC_DEFAULT_PREFIXES;
122 //get if exists
123 $query .= 'SELECT ?s
124 WHERE {
125 <'.SONIA_SPECIAL_SUBJECT.'> <'.SONIA_SPECIAL_PREDICATE.'> ?s .
126 }';
127 //echo nl2br(htmlentities($query)).'<br>';
128 $qr1 = $api->query(array("query"=>$query, "result_type"=>"rows"));
129 $rows = $qr1["result"];
130 $row_count = $qr1["row_count"];
131 $temp_facet_hiercharchy = array();
132 $answer = $rows[0]['s'];
133 echo "\$answer $answer<hr>";
134 print_r($qr1);
135 $answer = $answer +10;
136
137
138 //$success=$api->delete_store();
139 //$success=$api->reset_store();
140
141
142
143 ?>

  ViewVC Help
Powered by ViewVC 1.1.2