Permalink
Browse files

proper graph deletion, file recursion

  • Loading branch information...
1 parent 605e51f commit 73089cd7d05bcc2ec4d138145c96c6344c248817 @micheldumontier committed May 21, 2012
Showing with 43 additions and 33 deletions.
  1. +43 −33 lib/php/virtuoso_load.php
@@ -3,7 +3,7 @@
/*
http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/VirtFacetBrowserInstallConfig
*/
-$isql = "/opt/test/v-install/bin/isql";
+$isql = "/usr/local/virtuoso-opensource/bin/isql";
$isql = "/virtuoso-opensource/bin/isql";
$options = array(
@@ -61,7 +61,7 @@
// do delete graph option
-if($options['deletegraph'] == "true") {
+if($options['deletegraph'] == "true" && $options['graph'] != "graphname") {
$cmd = "log_enable(3,1);sparql clear graph <".$options['graph'].">";
echo "Deleting ".$options['graph'].PHP_EOL;
echo $out = shell_exec($cmd_pre.$cmd.$cmd_post);
@@ -82,7 +82,7 @@
exit;
}
// get the files
- $files = GetFiles($options['dir']);
+ $files = GetFiles($options['dir']);
$files = getFileR($options['dir']);
}
@@ -94,7 +94,7 @@
// $program = "DB.DBA.TTLP_MT_LOCAL_FILE";
} else {
// http://docs.openlinksw.com/virtuoso/fn_rdf_load_rdfxml_mt.html
- $program = 'DB.DBA.RDF_LOAD_RDFXML';
+ $program = 'DB.DBA.RDF_LOAD_RDFXML_MT';
}
foreach($files AS $file) {
@@ -119,6 +119,16 @@
$graph = "http://bio2rdf.org/graph/".$graph;
}
+
+ // delete individual graphs
+ if($options['deletegraph'] == "true" && $options['graph'] == "graphname") {
+ $cmd = "log_enable(3,1);sparql clear graph <$graph>";
+ echo "Deleting ".$graph.PHP_EOL;
+ echo $out = shell_exec($cmd_pre.$cmd.$cmd_post);
+ }
+
+ echo 'Adding '.$file."\n";
+
$path = '';
$pos = strrpos($file,"/");
if($pos !== FALSE) {
@@ -232,7 +242,7 @@
// Facet update : http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/VirtFacetBrowserInstallConfig
if($options['updatefacet'] == "true") {
- $cmd = "RDF_OBJ_FT_RULE_ADD (null, null, 'All');VT_INC_INDEX_DB_DBA_RDF_OBJ ();urilbl_ac_init_db();s_rank();";
+ $cmd = "RDF_OBJ_FT_RULE_ADD (null, null, 'All');VT_INC_INDEX_DB_DBA_RDF_OBJ ();urilbl_ac_init_db();";
echo "Updating facet";
echo $out = shell_exec($cmd_pre.$cmd.$cmd_post);
}
@@ -260,33 +270,33 @@ function GetFiles($dirname)
sort($files);
$d->close();
return $files;
-}
-
-function getFileR($directory, $recursive=true) {
- //This function generates an array of paths to the files of extension $extension
- $array_items = array();
- if ($handle = opendir($directory)) {
- while (false !== ($file = readdir($handle))) {
- if ($file != "." && $file != "..") {
- if (is_dir($directory. "/" . $file)) {
- if($recursive) {
- $array_items = array_merge($array_items, getFileR($directory. "/" . $file, $recursive));
- }//if
- $file = $directory . "/" . $file;
- if(is_file($file)){
- $array_items[] = preg_replace("/\/\//si", "/", $file);
- }
-
- } else {
- $file = $directory . "/" . $file;
- if(is_file($file)){
- $array_items[] = preg_replace("/\/\//si", "/", $file);
- }
- }//else
- }//if
- }//while
- closedir($handle);
- }//if
- return $array_items;
+}
+
+function getFileR($directory, $recursive=true) {
+ //This function generates an array of paths to the files of extension $extension
+ $array_items = array();
+ if ($handle = opendir($directory)) {
+ while (false !== ($file = readdir($handle))) {
+ if ($file != "." && $file != "..") {
+ if (is_dir($directory. "/" . $file)) {
+ if($recursive) {
+ $array_items = array_merge($array_items, getFileR($directory. "/" . $file, $recursive));
+ }//if
+ $file = $directory . "/" . $file;
+ if(is_file($file)){
+ $array_items[] = preg_replace("/\/\//si", "/", $file);
+ }
+
+ } else {
+ $file = $directory . "/" . $file;
+ if(is_file($file)){
+ $array_items[] = preg_replace("/\/\//si", "/", $file);
+ }
+ }//else
+ }//if
+ }//while
+ closedir($handle);
+ }//if
+ return $array_items;
}//getFileR
?>

0 comments on commit 73089cd

Please sign in to comment.