r46923 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46922‎ | r46923 | r46924 >
Date:15:22, 6 February 2009
Author:mkroetzsch
Status:deferred
Tags:
Comment:
remove obsolete code
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_RAPStore2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_RAPStore2.php
@@ -4,7 +4,7 @@
55 * SMW SQL 2 Store for everything SMW does, but it decorates all edits to
66 * the store with calls to a RAP store, so it keeps in parallel a second
77 * store with all the semantic data. This allows for a SPARQL endpoint.
8 - *
 8+ *
99 * @todo It is not good that SMW_RAPStore2 is basically
1010 * a copy of SMW_RAPStore. The architecture of these two stores need to be
1111 * rethought so that code duplication can be avoided.
@@ -41,48 +41,48 @@
4242 public function SMWRAPStore2() {
4343 global $smwgRAPPath,$wgServer;
4444
45 -
 45+
4646 $this->modeluri = SMWExporter::expandURI($wgServer."/model");
47 - $this->baseuri = SMWExporter::expandURI($wgServer."/id");
 47+ $this->baseuri = SMWExporter::expandURI($wgServer."/id");
4848 }
4949
5050 ///// Writing methods /////
5151
5252 function deleteSubject(Title $subject) {
53 -
 53+
5454 // Translate SMWSemanticData to a RAP Model
5555 $rdfmodel = $this->getRAPModel();
56 -
 56+
5757 $rapsub = new Resource(SMWExporter::expandURI($this->getURI($subject)));
5858 $this->removeSubjectFromRAP($rdfmodel, $rapsub);
59 -
 59+
6060 return parent::deleteSubject($subject);
6161 }
6262
6363 function updateData(SMWSemanticData $data){
6464 // Create a local memmodel
6565 $model = ModelFactory::getDefaultModel();
66 -
 66+
6767 // Get DB-Model
6868 $rdfmodel = $this->getRAPModel();
6969
7070 $ed = SMWExporter::makeExportData($data); //ExpData
71 -
 71+
7272 // Delete all we know about the subject!
7373 $rapsub = new Resource(SMWExporter::expandURI($ed->getSubject()->getName()));
7474 $this->removeSubjectFromRAP($rdfmodel, $rapsub);
75 -
 75+
7676 $tl = $ed->getTripleList(); // list of tenary arrays
77 -
 77+
7878 // Temporary List of all Blank Nodes in this dataobject
7979 $blankNodes = array();
80 -
 80+
8181 foreach ($tl as $triple) {
8282 $s = $triple[0]->getName(); // Subject
8383 $p = $triple[1]->getName(); // Predicate
8484 $o = $triple[2]->getName(); // Object
85 -
86 -
 85+
 86+
8787 // -------------------------------------------------------------------
8888 // Subject
8989 // -------------------------------------------------------------------
@@ -103,14 +103,14 @@
104104 $rap_subj = $blankNodes[$bNodeId];
105105 }
106106 }
107 -
 107+
108108 // -------------------------------------------------------------------
109109 // Predicate
110110 // -------------------------------------------------------------------
111111 $rap_pred = new Resource(SMWExporter::expandURI($triple[1]->getName()));
112 -
 112+
113113 // -------------------------------------------------------------------
114 - // Object
 114+ // Object
115115 // -------------------------------------------------------------------
116116 $rap_obj = new Resource(SMWExporter::expandURI($triple[2]->getName()));
117117 if($triple[2] instanceof SMWExpLiteral){
@@ -128,31 +128,31 @@
129129 $blankNodes[$bNodeId] = $rap_obj;
130130 }
131131 }
132 -
 132+
133133 // now add the new Statement
134 - $statement = new Statement($rap_subj, $rap_pred, $rap_obj);
 134+ $statement = new Statement($rap_subj, $rap_pred, $rap_obj);
135135 $model->add($statement);
136136 }
137 -
 137+
138138 // Add the mem-model to the store
139139 $rdfmodel->addModel($model);
140140
141 -
 141+
142142 // Close connections
143143 $model->close();
144144 $rdfmodel->close();
145145 $this->closeRAP();
146 -
147 -
 146+
 147+
148148 return parent::updateData($data);
149149 }
150150
151151 function changeTitle(Title $oldtitle, Title $newtitle, $pageid, $redirid=0) {
152 -
 152+
153153 // Save it in parent store now!
154154 // We need that so we get all information correctly!
155155 $result = parent::changeTitle($oldtitle, $newtitle, $pageid, $redirid);
156 -
 156+
157157 // Delete the old stuff
158158 $nameOld = SMWExporter::expandURI($this->getURI($oldtitle));
159159 $rdfmodel = $this->getRAPModel();
@@ -169,7 +169,7 @@
170170 $oldpage->setValues($oldtitle->getDBKey(), $oldtitle->getNamespace(), $redirid);
171171 $semdata = $this->getSemanticData($oldpage);
172172 $this->updateData($semdata,false);
173 -
 173+
174174 return $result;
175175 }
176176
@@ -199,7 +199,7 @@
200200 }
201201 $this->reportProgress("Checking RAP model...\n",$verbose);
202202 if ($rdfstore->modelExists($this->modeluri)) {
203 - $this->reportProgress("RAP model exiists.\n",$verbose);
 203+ $this->reportProgress("RAP model exiists.\n",$verbose);
204204 } else {
205205 $this->reportProgress("Creating RAP model...\n",$verbose);
206206 $rdfstore->getNewModel($this->modeluri, $this->baseuri);
@@ -230,7 +230,7 @@
231231 $this->rapstore = ModelFactory::getDbStore('MySQL', $smwgRapDBserver, $smwgRapDBname, $smwgRapDBuser, $smwgRapDBpassword);
232232 return $this->rapstore;
233233 }
234 -
 234+
235235 /**
236236 * Returns the actual model where all the triples are saved.
237237 */
@@ -238,7 +238,7 @@
239239 $rapstore = $this->getRAPStore();
240240 return $rapstore->getModel($this->modeluri);
241241 }
242 -
 242+
243243 /**
244244 * Closes the connection to the RAP DB. As of now, this is disabled since it
245245 * seems to close the connection to the MW DB as well (probably, because it
@@ -249,27 +249,10 @@
250250 //$this->rapstore->close();
251251 }
252252
253 - /**
254 - * Print some output to indicate progress. The output message is given by
255 - * $msg, while $verbose indicates whether or not output is desired at all.
256 - * Copied from SMW_SQLStore.
257 - */
258 - protected function reportProgress($msg, $verbose) {
259 - if (!$verbose) {
260 - return;
261 - }
262 - if (ob_get_level() == 0) { // be sure to have some buffer, otherwise some PHPs complain
263 - ob_start();
264 - }
265 - print $msg;
266 - ob_flush();
267 - flush();
268 - }
269 -
270253 ///// Additional helpers
271254 /**
272255 * Deletes all relations for the given subject from RAP.
273 - * This especially also handles n-ary relations recursevly as we would lose them
 256+ * This especially also handles n-ary relations recursevly as we would lose them
274257 **/
275258 protected function removeSubjectFromRAP($rdfmodel, Resource $subject){
276259 $oldmodel = $rdfmodel->find($subject, null, null);
@@ -277,21 +260,21 @@
278261 $i->moveFirst();
279262 while ($i->current() != null) {
280263 $stmt = $i->current();
281 -
 264+
282265 $rdfmodel->remove($stmt);
283 -
 266+
284267 $obj = $stmt->object();
285268 if($obj instanceof BlankNode){
286269 // It's a blank node in the object, this means a n-ary relation has been saved
287270 // So delete everything for this blank node as well!
288271 $this->removeSubjectFromRAP($rdfmodel, $obj);
289272 }
290 -
 273+
291274 $i->next();
292275 }
293276 // TODO Delete More Stuff, if we save more stuff
294277 }
295 -
 278+
296279 /**
297280 * Having a title of a page, what is the URI that is described by that page?
298281 *
@@ -302,12 +285,12 @@
303286 if($title instanceof Title){
304287 $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
305288 $dv->setTitle($title);
306 - $exp = $dv->getExportData();
307 - $uri = $exp->getSubject()->getName();
 289+ $exp = $dv->getExportData();
 290+ $uri = $exp->getSubject()->getName();
308291 }else{
309292 // There could be other types as well that we do NOT handle here
310293 }
311 -
 294+
312295 return $uri; // still requires expandURI()
313296 }
314297 }

Status & tagging log