Skip to content

Commit

Permalink
General chnages to make the code more portable
Browse files Browse the repository at this point in the history
In particular central inc folder included in all php scripts via include.inc.php sym links
Added more parameterization for BASH scripts

--HG--
rename : 4store/scripts/sqs_help.txt => 4store/scripts/sqs_help.sh
rename : 4store/README => README
rename : http/inc/4storefunc.inc.php => inc/4storefunc.inc.php
rename : rdfgen/inc/atomfunc.inc.php => inc/atomfunc.inc.php
rename : http/inc/changeddata.inc.php => inc/changeddata.inc.php
rename : rdfgen/inc/data.inc.php => inc/data.inc.php
rename : rdfgen/inc/datatypes.inc.php => inc/datatypes.inc.php
rename : rdfgen/inc/defaultsettings.inc.php => inc/defaultsettings.inc.php
rename : http/inc/footer.inc.php => inc/footer.inc.php
rename : rdfgen/inc/functions.inc.php => inc/functions.inc.php
rename : rdfgen/inc/genrdf.inc.php => inc/genrdf.inc.php
rename : http/inc/header.inc.php => inc/header.inc.php
rename : rdfgen/inc/miscfunc.inc.php => inc/miscfunc.inc.php
rename : http/inc/ontconnect.inc.php => inc/ontoconnect.inc.php
rename : rdfgen/inc/orefunc.inc.php => inc/orefunc.inc.php
rename : http/inc/owl_specqueries.inc.php => inc/owl_specqueries.inc.php
rename : http/inc/rdfs_specqueries.inc.php => inc/rdfs_specqueries.inc.php
rename : rdfgen/inc/snarmfunc.inc.php => inc/snarmfunc.inc.php
rename : http/inc/sq_connect.inc.php => inc/sparqlconnect.inc.php
rename : http/inc/specfooter.inc.php => inc/specfooter.inc.php
rename : http/inc/specheader.inc.php => inc/specheader.inc.php
rename : http/inc/specqueries.inc.php => inc/specqueries.inc.php
rename : rdfgen/inc/sqlfunc.inc.php => inc/sqlfunc.inc.php
rename : http/inc/xmlfunc.inc.php => inc/xmlfunc.inc.php
rename : rdfgen/inc/datatypes.txt => rdfgen/datatypes.txt
  • Loading branch information
[email protected] committed May 23, 2010
1 parent 99e14fd commit b81725f
Show file tree
Hide file tree
Showing 69 changed files with 443 additions and 1,057 deletions.
5 changes: 1 addition & 4 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ syntax: glob
*.log
*.pid
*~
http/inc/settings.inc.php
http/inc/connect.inc.php
rdfgen/inc/settings.inc.php
rdfgen/inc/connect.inc.php
inc/settings.inc.php

19 changes: 8 additions & 11 deletions 4store/scripts/CreateLogFiles.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
#!/bin/bash
cd /var/4store/log
export settings.sh
cd $STORE4_PATH/log
touch database.log
touch myexp_private_4store.log
touch myexp_private_triples.log
touch myexp_private_sparql.log
touch myexp_private_update_time.log
touch myexp_public_4store.log
touch myexp_public_triples.log
touch myexp_public_sparql.log
touch myexp_public_update_time.log
touch $TRIPLESTORE"_4store.log"
touch $TRIPLESTORE"_triples.log"
touch $TRIPLESTORE"_sparql.log"
touch $TRIPLESTORE"_updatedlog"
touch $TRIPLESTORE"_update_time.log"
touch ontologies_4store.log
touch ontologies_triples.log
touch ontologies_sparql.log
touch ontologies_updated.log
touch ontologies_update_time.log


16 changes: 7 additions & 9 deletions 4store/scripts/cacheSpec.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
#!/bin/bash
JENALIB="/var/4store/lib";
JAVA_CP=".:$JENALIB/jena.jar:$JENALIB/iri.jar:$JENALIB/arq.jar:$JENALIB/xercesImpl.jar:$JENALIB/xml-apis.jar:$JENALIB/icu4j_3_4.jar:$JENALIB/json.jar:$JENALIB/concurrent.jar:$JENALIB/antlr-2.7.5.jar:$JENALIB/junit.jar:$JENALIB/log4j-1.2.12.jar:$JENALIB/wstx-asl-3.0.0.jar:$JENALIB/stax-api-1.0.jar:$JENALIB/mysql-connector-java-5.0.8-bin.jar:$JENALIB/commons-logging-1.1.1.jar:$JENALIB/commons-logging-1.1.1-javadoc.jar:$JENALIB/commons-logging-1.1.1-sources.jar:$JENALIB/commons-logging-adapters-1.1.1.jar:$JENALIB/commons-logging-api-1.1.1.jar:$JENALIB/commons-logging-tests.jar:$JENALIB/axis.jar:$JENALIB/bcpg-jdk15-139.jar:$JENALIB/bcprov-jdk15-139.jar:$JENALIB/commons-lang-2.0.jar:$JENALIB/grddl.jar:$JENALIB/hsqldb-1.8.0.7.jar:$JENALIB/jakarta-oro-2.0.5.jar:$JENALIB/nekohtml.jar:$JENALIB/ng4j.jar:$JENALIB/saxon8.jar:$JENALIB/tagsoup-1.0.4.jar:";

cd /var/4store/scripts
source settings.sh
cd $STORE4_PATH/scripts
echo "============== `date` =============="
wget -O /var/data/ontologies/cachedspec/$3_$2_spec.html -q "http://rdf.myexperiment.org/generic/spec?ontology=$3&uncached=1"
errors=`grep '<!-- Errors -->' /var/data/ontologies/cachedspec/$3_$2_spec.html`
errors2=`grep 'XML error: Empty document at line ' /var/data/ontologies/cachedspec/$3_$2_spec.html`
wget -O $DATA_PATH/ontologies/cachedspec/$3_$2_spec.html -q "$HTTPRDF_PATH/generic/spec?ontology=$3&uncached=1"
errors=`grep '<!-- Errors -->' $DATA_PATH/ontologies/cachedspec/$3_$2_spec.html`
errors2=`grep 'XML error: Empty document at line ' $DATA_PATH/ontologies/cachedspec/$3_$2_spec.html`
if [ ${#errors} -gt 0 ]; then
echo "[`date +%T`] Cached spec of $1 at /var/data/ontologies/cachedspec/$3_$2_spec.html <b>with Query Failures</b>";
echo "[`date +%T`] Cached spec of $1 at $DATA_PATH/ontologies/cachedspec/$3_$2_spec.html <b>with Query Failures</b>";
elif [ ${#errors2} -gt 0 ]; then
echo "[`date +%T`] XML Error prevented $1 from being cached properly";
else
echo "[`date +%T`] Cached spec of $1 at /var/data/ontologies/cachedspec/$3_$2_spec.html";
echo "[`date +%T`] Cached spec of $1 at $DATA_PATH/ontologies/cachedspec/$3_$2_spec.html";
fi
echo "[`date +%T`] Finished";
51 changes: 17 additions & 34 deletions 4store/scripts/changeddata.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
#!/usr/bin/php
<?php
if ($argv[1]=="myexp_private"){
$domain="private";
$ts=$argv[1];
}
else{
$domain="public";
$ts="myexp_public";
}
$start=2;

include('seetings.inc.php');
include('include.inc.php');
include('changeddata.inc.php');
include('genxml.inc.php');
include('genrdf.inc.php');
$domain="public";
$ts=$triplestore;
$start=2;


function saveEntities($ts,$type,$xml,$id,$userid,$hasuserid,$fileext=null){
global $curids;
global $curids, $datapath;
$xml.=pagefooter();
if ($hasuserid) $fid=$userid;
else $fid=$id;
if ($fileext && $fileext!="_") $fid.="_$fileext";
$curids[]=$fid;
$file="/var/data/tmp/$ts/".getGroup($type)."/$fid";
$fileold="/var/data/$ts/".getGroup($type)."/$fid";
$file=$datapath."tmp/$ts/".getGroup($type)."/$fid";
$fileold=$datapath.$ts"/".getGroup($type)."/$fid";
$fh=fopen($file,'w');
fwrite($fh,$xml);
fclose($fh);
Expand All @@ -38,12 +32,9 @@ function saveEntities($ts,$type,$xml,$id,$userid,$hasuserid,$fileext=null){
}
}
$cdsql=$sql;
$fh=fopen("/var/data/tmp/$ts/delete_files",'w');
$fh=fopen($datapath."tmp/$ts/delete_files",'w');
fclose($fh);
$useuid=array('Downloads','Viewings');
unset($cdsql['Downloads']);
unset($cdsql['Viewings']);
$sepusage=array('Workflow','Pack','File');
$sepusage=array('workflows','packs','files');
if (sizeof($argv)>$start){
$newcsql=array();
for ($a=$start; $a<sizeof($argv); $a++){
Expand All @@ -64,7 +55,6 @@ function saveEntities($ts,$type,$xml,$id,$userid,$hasuserid,$fileext=null){
$fileno=1;
$curuserid="";
$curcontrib="";
// echo $rows;
for ($i=0; $i<$rows; $i++){
$row=mysql_fetch_assoc($res);
if ($insepusage==1){
Expand All @@ -75,7 +65,6 @@ function saveEntities($ts,$type,$xml,$id,$userid,$hasuserid,$fileext=null){
if (!$row['user_id']) $row['user_id']="AnonymousUser";
if (!$curuserid) $curuserid=$row['user_id'];
if (!$curcontrib) $curcontrib=$row['contributable_type']."_".$row['contributable_id'];
//print_r($currow);
if (!$inuseuid || $row['user_id']!=$curuserid){
if (!in_array($k,$useuid)){
$xml.=printEntity($row,$k,$mappings[$k],"$datauri$k/",'id','');
Expand Down Expand Up @@ -128,17 +117,17 @@ function saveEntities($ts,$type,$xml,$id,$userid,$hasuserid,$fileext=null){
$urow=mysql_fetch_assoc($ures);
$uxml.=printUsage($k,$urow['id'],$urow['viewings_count'],$urow['downloads_count']);
}
saveEntities($ts,$k,$uxml,'Usage','','');
saveEntities($ts,$k,$uxml,'usage','','');
}
$ph=popen("/var/jena/scripts/sqs.sh $ts list-graphs | grep '/".getGroup($k)."/' | grep '[0-9]'",'r');
$ph=popen($ldpath."4store/scripts/sqs.sh $ts list-graphs | grep '/".getGroup($k)."/' | grep '[0-9]'",'r');
$fnums=array();
while (!feof($ph)){
$curf=fgets($ph,8192);
$curfb=explode("/",$curf);
if(strlen(trim($curfb[sizeof($curfb)-1]))>0) $fnums[]=trim($curfb[sizeof($curfb)-1]);
}
pclose($ph);
$ph=popen("ls /var/data/$ts/".getGroup($k)."/ | grep '[0-9]'",'r');
$ph=popen("ls $datapath$ts/".getGroup($k)."/ | grep '[0-9]'",'r');
$fnums2=array();
while (!feof($ph)){
$curf=fgets($ph,8192);
Expand All @@ -147,25 +136,19 @@ function saveEntities($ts,$type,$xml,$id,$userid,$hasuserid,$fileext=null){
pclose($ph);
$dels=array_diff($fnums,$curids);
$dels2=array_diff($fnums2,$curids);
/* for ($d=0; $d<max(sizeof($curids),sizeof($dels),sizeof($dels2)); $d++){
echo $curids[$d].",".$dels[$d].",".$dels2[$d]."\n";
}*/
foreach ($dels2 as $d2){
if (!in_array($d2,$dels)) $dels[]=$d2;
}
// print_r($curid);
// echo "\n#####\n";
// print_r($dels);
if (is_array($dels)){
$fh=fopen("/var/data/tmp/$ts/delete_files",'a');
$fh=fopen($datapath."tmp/$ts/delete_files",'a');
foreach ($dels as $del){
$filedel="/var/data/$ts/".getGroup($k)."/$del\n";
$filedel="$datapath$ts/".getGroup($k)."/$del\n";
fwrite($fh,$filedel);
}
fclose($fh);
}
}
$fh=fopen("/var/jena/log/".$ts."_updated.log","w");
$fh=fopen($ldpath."4store/log/".$ts."_updated.log","w");
$lastupdated=mktime(0,0,0)-120;
fwrite($fh,$lastupdated);
fclose($fh);
Expand Down
29 changes: 11 additions & 18 deletions 4store/scripts/datadump.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
#!/usr/bin/php
<?php
if ($argv[1]=="myexp_private"){
$domain="private";
$ts=$argv[1];
}
else{
$domain="public";
$ts="myexp_public";
}
$domain="public";
$ts="myexp_public";

include('include.inc.php');
include('changeddata.inc.php');
include('genrdf.inc.php');

$start=2;
$rdffile="/var/data/tmp/$ts/data.rdf";
$rdfgzfile="/var/data/$ts/data.rdf.gz";
$rdffile=$datapath."tmp/$ts/data.rdf";
$rdfgzfile="$datapath$ts/data.rdf.gz";

ini_set('include_path','/var/www/html/rdf/inc/');
include('changeddata.inc.php');
include('genxml.inc.php');

$ddsql=$sql;
unset($ddsql['Downloads']);
unset($ddsql['Viewings']);
echo "[".date("H:i:s")."] Creating temporary file $rdffile\n";
$fh=fopen($rdffile,"w");
fwrite($fh,pageheader());
Expand All @@ -44,8 +37,8 @@
fwrite($fh,$xml);
}
fclose($fh);
echo "[".date("H:i:s")."] Adding Dataflows\n";
exec("for dffile in `ls /var/data/dataflows/rdf/*`; do
echo "[".date("H:i:s")."] Adding dataflows\n";
exec("for dffile in `ls ".$datapath."dataflows/rdf/*`; do
head -$[`wc -l \$dffile | awk 'BEGIN{FS=\" \"}{print $1}'`] \$dffile | tail -$[`wc -l \$dffile | awk 'BEGIN{FS=\" \"}{print $1}'`-46] >> $rdffile
done");
$fh=fopen($rdffile,"a");
Expand Down
18 changes: 9 additions & 9 deletions 4store/scripts/generateDataflowRDF.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/php
<?php
ini_set('include_path','/var/www/html/rdf/inc');
include('genxml.inc.php');
$ph=popen('ls /var/data/dataflows/xml/','r');
$ph2=popen('ls /var/data/dataflows/reasoned/','r');
include('include.inc.php');
include('genrdf.inc.php');
$ph=popen('ls '.$datapath.'dataflows/xml/','r');
$ph2=popen('ls '.$datapath.'dataflows/reasoned/','r');
$temp="";
while (!feof($ph)){
$temp.=fread($ph,8192);
Expand All @@ -23,19 +23,19 @@
//$xmlfiles=array('542');
foreach ($xmlfiles as $xf){
if (!in_array($xf,$resfiles)){
$xmllines=file("/var/data/dataflows/xml/$xf");
$xmllines=file($datapath."dataflows/xml/$xf");
if (sizeof($xmllines)<=2){
exec("rm /var/data/$argv[1]/reasoned/$xf /var/data/dataflows/rdf/$xf 2> /dev/null");
if ($argv[1]=="myexp_public") fwrite($dellist,"/var/data/$argv[1]/dataflows/$xf\n");
exec("rm $datapath$argv[1]/reasoned/$xf ".$datapath."dataflows/rdf/$xf 2> /dev/null");
if ($argv[1]=="myexp_public") fwrite($dellist,"$datapath$argv[1]/dataflows/$xf\n");
}
else{
$dataflows=pageheader();
$dataflows.=getDataflowComponents(array('id'=>$xf),"workflow_versions","uris");
$dataflows.=pagefooter();
$fh=fopen("/var/data/dataflows/rdf/$xf",'w');
$fh=fopen($datapath."dataflows/rdf/$xf",'w');
fwrite($fh,$dataflows);
fclose($fh);
fwrite($fhlist,"/var/data/dataflows/rdf/$xf\n");
fwrite($fhlist,$datapath."dataflows/rdf/$xf\n");
echo "[".date("H:i:s")."] Generated RDF for components of workflow_versions $xf\n";
}
}
Expand Down
4 changes: 2 additions & 2 deletions 4store/scripts/getDateFromFilename.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/php
<?php

$lines=@file('/var/data/log/'.$argv[1].'_update_time.log');
include('include.inc.php');
$lines=@file($ldpath."4store/log/".$argv[1].'_update_time.log');
$lastupdated=$lines[0];
$filetimes=@file("php://stdin");
foreach ($filetimes as $filetime){
Expand Down
6 changes: 3 additions & 3 deletions 4store/scripts/getNewWorkflowVersions.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/php
<?php
include('/var/www/html/rdf/inc/connect.inc.php');
//$sql="select workflow_versions.id, workflow_versions.workflow_id, workflow_versions.version from workflow_versions inner join contributions on workflow_versions.workflow_id=contributions.contributable_id and contributions.contributable_type='Workflow' inner join policies on contributions.policy_id=policies.id where content_type='application/vnd.taverna.scufl+xml' and policies.share_mode in (0,1,2)";
include('include.inc.php');
include('myexpconnect.inc.php');
$sql="select workflow_versions.id, workflow_versions.workflow_id, workflow_versions.version from workflow_versions inner join content_types on workflow_versions.content_type_id=content_types.id inner join contributions on workflow_versions.workflow_id=contributions.contributable_id and contributions.contributable_type='Workflow' inner join policies on contributions.policy_id=policies.id where content_types.mime_type in ('application/vnd.taverna.scufl+xml','application/vnd.taverna.t2flow+xml') and policies.share_mode in (0,1,2)";
$res=mysql_query($sql);
for ($i=0; $i<mysql_num_rows($res); $i++){
$wfv_db[]=mysql_result($res,$i,'id');
$wfv_wv[]=mysql_result($res,$i,'id').",".mysql_result($res,$i,'workflow_id').",".mysql_result($res,$i,'version');

}
$cmd="ls /var/data/dataflows/xml/";
$cmd="ls ".$datapath."/dataflows/xml/";
$ph=popen($cmd,'r');
$lswfv="";
while (!feof($ph)){
Expand Down
2 changes: 1 addition & 1 deletion 4store/scripts/getUpdatedFiles.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/php
<?php

$lines=@file('/var/data/log/'.$argv[1].'_update_time.log');
$lines=@file($ldpath.'4store/log/'.$argv[1].'_update_time.log');
$lastupdated=$lines[0];
$filetimes=@file("php://stdin");
foreach ($filetimes as $filetime){
Expand Down
6 changes: 3 additions & 3 deletions 4store/scripts/getdataflows.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash
cd /var/jena/code/
/usr/bin/php ../scripts/getNewWorkflowVersions.php | awk 'BEGIN{FS=","}{ print " -O /var/data/dataflows/xml/" $1 " -q http://www.myexperiment.org/workflow.xml?id=" $2 "&version=" $3 "&elements=components" }' > /tmp/wgets.txt
source settings.sh
cd $STORE4_PATH/scripts
/usr/bin/php getNewWorkflowVersions.php | awk -v datapath="$DATA_PATH" -v httpwwwpath="$HTTPWWW_PATH" 'BEGIN{FS=","}{ print " -O " datapath "/dataflows/xml/" $1 " -q " httpwwwpath "/workflow.xml?id=" $2 "&version=" $3 "&elements=components" }' > /tmp/wgets.txt
exec</tmp/wgets.txt
while read line
do
wget $line
echo "[`date +%T`] Executed wget $line"
#sleep 2
done

1 change: 1 addition & 0 deletions 4store/scripts/include.inc.php
3 changes: 2 additions & 1 deletion 4store/scripts/listGraphs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/php
<?php
include('/var/www/html/rdf/inc/xmlfunc.inc.php');
include('include.inc.php');
include('xmlfunc.inc.php');
if (!$argv[1]) die("No Knowledge Base specified!\n");
$query="4s-query $argv[1] ".'"select distinct ?g where { graph ?g {?s ?p ?o} }"';
$ph=popen($query,'r');
Expand Down
6 changes: 3 additions & 3 deletions 4store/scripts/processRemoteOntology.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
ini_set('include_path','/var/www/html/rdf/inc');
include('include.inc.php');
include('xmlfunc.inc.php');
include('ontconnect.inc.php');
include('ontoconnect.inc.php');
$sql="select * from ontologies where id=$argv[1]";
$res=mysql_query($sql);
$ont=mysql_fetch_assoc($res);
$fh=fopen("/var/data/ontologies/remoteont/$argv[1]_$ont[name].owl",'r');
$fh=fopen($datapath."ontologies/remoteont/$argv[1]_$ont[name].owl",'r');
$xml="";
while (!feof($fh)){
$data=fgets($fh,8096);
Expand Down
11 changes: 5 additions & 6 deletions 4store/scripts/reasonDataflows.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#!/bin/bash
cd /var/4store/code
source settings.sh
cd $STORE4_PATH/code
LC_ALL=c
JENALIB="/var/4store/lib";
JAVA_CP=".:$JENALIB/jena.jar:$JENALIB/iri.jar:$JENALIB/arq.jar:$JENALIB/xercesImpl.jar:$JENALIB/xml-apis.jar:$JENALIB/icu4j_3_4.jar:$JENALIB/json.jar:$JENALIB/concurrent.jar:$JENALIB/antlr-2.7.5.jar:$JENALIB/junit.jar:$JENALIB/log4j-1.2.12.jar:$JENALIB/wstx-asl-3.0.0.jar:$JENALIB/stax-api-1.0.jar:$JENALIB/mysql-connector-java-5.0.8-bin.jar:$JENALIB/commons-logging-1.1.1.jar:$JENALIB/commons-logging-1.1.1-javadoc.jar:$JENALIB/commons-logging-1.1.1-sources.jar:$JENALIB/commons-logging-adapters-1.1.1.jar:$JENALIB/commons-logging-api-1.1.1.jar:$JENALIB/commons-logging-tests.jar:$JENALIB/axis.jar:$JENALIB/bcpg-jdk15-139.jar:$JENALIB/bcprov-jdk15-139.jar:$JENALIB/commons-lang-2.0.jar:$JENALIB/grddl.jar:$JENALIB/hsqldb-1.8.0.7.jar:$JENALIB/jakarta-oro-2.0.5.jar:$JENALIB/nekohtml.jar:$JENALIB/ng4j.jar:$JENALIB/saxon8.jar:$JENALIB/tagsoup-1.0.4.jar:";

echo "[`date +%T`] Generating Dataflow RDF"
/usr/bin/php ../scripts/generateDataflowRDF.php $1
$PHPEXEC_PATH/php $STORE4_PATH/scripts/generateDataflowRDF.php $1
if [ `cat /tmp/dataflows.txt | wc -l` -gt 0 ]; then
echo "[`date +%T`] Reasoning Dataflow RDF"
java -cp $JAVA_CP RDFSDataReasoner ../config/myexp_public_ontologies.txt /tmp/dataflows.txt /var/data/dataflows/reasoned/
java -cp $JAVA_CP RDFSDataReasoner $STORE4_PATH/config/myexp_public_ontologies.txt /tmp/dataflows.txt $DATA_PATH/dataflows/reasoned/
echo "[`date +%T`] Reasoned Dataflow RDF"
else
echo "[`date +%T`] No Dataflow RDF to reason"
echo "[`date +%T`] No Dataflow RDF to reason"
fi

Loading

0 comments on commit b81725f

Please sign in to comment.