[Swift-commit] r7249 - provenancedb/tags
wilde at ci.uchicago.edu
wilde at ci.uchicago.edu
Tue Oct 29 23:39:58 CDT 2013
Author: wilde
Date: 2013-10-29 23:39:58 -0500 (Tue, 29 Oct 2013)
New Revision: 7249
Added:
provenancedb/tags/provdb.php
provenancedb/tags/tag.server
provenancedb/tags/types
Modified:
provenancedb/tags/locate.server
Log:
Initial version of client-server locate.
Modified: provenancedb/tags/locate.server
===================================================================
--- provenancedb/tags/locate.server 2013-10-30 04:34:01 UTC (rev 7248)
+++ provenancedb/tags/locate.server 2013-10-30 04:39:58 UTC (rev 7249)
@@ -1,20 +1,47 @@
#! /bin/sh
-TAGDB=${TAGDB:-provdb}
+database=${TAGDB:-provdb}
-SQLCMD="psql -U provdb -h swift.rcc.uchicago.edu $TAGDB"
-
format=default
echo
+echo $(date): STARTING >./locate.log
+echo $(date): "$*" >./locate.log
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ -u|--user) user=$2; shift 2 ;;
+ -p|--password) password=$2; shift 2 ;;
+ -d|--database) database=$2; shift 2 ;;
+ -h|-?|--help|-*|--*) usage; exit ;;
+ *) break ;;
+ esac
+done
+
+# Authenticate the user
+
+dbpass=$(grep -w "^$user " users | awk '{print $2}')
+
+echo user=$user password=$password dbpass=$dbpass >>./locate.log
+
+if [ _$dbpass != _$password ]; then
+ echo ERROR: authentication failed.
+ exit 1
+fi
+
+SQLCMD="psql -U provdb -h swift.rcc.uchicago.edu $database"
+
+# Translate query
+
if [ _"$1" = _ -o _"$1" = '_*' ]; then
WHERE="(select distinct dataset_id from annot_dataset_text)"
else
WHERE=$(echo $* | sed -e "s/\([[:alnum:]_-]\+\)[[:space:]]*\([!=<>]\+\|like\|ilike\)[[:space:]]*\([[:alnum:] *%.:_-]\+\)/(select dataset_id from annot_dataset_text where name = '\1' AND value \2 '\3')/g" -e "s/ and / INTERSECT /g" -e "s/ or / UNION /g")
fi
-QUERY="select * from annot_dataset_text where dataset_id in ($WHERE);"
+fields="dataset_id, name, value"
+QUERY="select $fields from annot_dataset_text where dataset_id in ($WHERE);"
TQUERY="select * from annot_dataset_text where dataset_id in (
select dataset_id from annot_dataset_text where (name='owner' and value='wilde') intersect
@@ -29,7 +56,7 @@
$SQLCMD -c "$QUERY" >$tout
head -2 $tout >$thdr
-tail -n +3 $tout | sort >$tbody
+tail -n +3 $tout | grep -v '(.*rows)' | grep -v '^$' | sort >$tbody
if [ $format = default ]; then
@@ -85,7 +112,3 @@
fi
rm -f $tout $tbody $thdr
-
-exit
-
-locate owner=sinitzkiy or owner=wilde
Added: provenancedb/tags/provdb.php
===================================================================
--- provenancedb/tags/provdb.php (rev 0)
+++ provenancedb/tags/provdb.php 2013-10-30 04:39:58 UTC (rev 7249)
@@ -0,0 +1,6 @@
+<?PHP
+ header('Content-Type: text/plain');
+ $cmd = $_GET['cmd'];
+ system(escapeshellcmd("/home/provdb/provdb/bin/$cmd"));
+# system("/home/provdb/provdb/bin/$cmd");
+?>
Property changes on: provenancedb/tags/provdb.php
___________________________________________________________________
Added: svn:executable
+ *
Copied: provenancedb/tags/tag.server (from rev 7243, provenancedb/tags/ttag)
===================================================================
--- provenancedb/tags/tag.server (rev 0)
+++ provenancedb/tags/tag.server 2013-10-30 04:39:58 UTC (rev 7249)
@@ -0,0 +1,76 @@
+#! /bin/sh
+
+#TAGDB=${TAGDB:-provdb}
+
+usage()
+{
+ echo $0: usage:
+ cat <<END
+ -m|--multiple allow multiple tags with the same name
+ -h|-?|?|--help print this help
+END
+}
+
+echo $(date): $* >./locate.log
+
+multiple=false
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ -u|--user) user=$2; shift 2 ;;
+ -p|--password) password=$2; shift 2 ;;
+ -m|--multiple) multiple=true; shift 1 ;;
+ -h|-?|--help|-*|--*) usage; exit ;;
+ *) break ;;
+ esac
+done
+
+# Authenticate the user
+
+dbpass=$(grep -w "^$user " users | awk '{print $2}')
+
+echo user=$user password=$password dbpass=$dbpass >>./locate.log
+
+if [ _$dbpass != _$password ]; then
+ echo ERROR: authentication failed.
+ exit 1
+fi
+
+object=$1
+shift
+
+SQLCMD="psql -U provdb -h swift.rcc.uchicago.edu $TAGDB"
+
+$SQLCMD -c "insert into ds (id) values ('$object');"
+
+for anno in "$@"; do
+ name=$(echo "$anno" | awk -F= '{print $1}')
+ value=$(echo "$anno" | awk -F= '{print $2}')
+ echo anno=$anno name=$name value="$value"
+ if [ $multiple = false ]; then
+ $SQLCMD -c "
+ DO
+ \$\$
+ BEGIN
+ IF EXISTS ( SELECT 1 FROM annot_dataset_text WHERE dataset_id = '$object' and name = '$name' ) THEN
+ UPDATE annot_dataset_text SET value = '$value' WHERE dataset_id = '$object' and name = '$name' ;
+ ELSE
+ INSERT INTO annot_dataset_text (dataset_id, name, value) VALUES ('$object', '$name', '$value') ;
+ END IF;
+ END;
+ \$\$"
+ else
+ $SQLCMD -c "insert into annot_dataset_text (dataset_id, name, value) values ('$object', '$name', '$value');"
+ fi
+done
+
+exit
+
+insert into annot_dataset_text (dataset_id, name, value) values ('/d1/d2/f1', 'owner', 'wilde');
+insert into annot_dataset_text (dataset_id, name, value) values ('/d1/d2/f1', 'group', 'cmts-cyber');
+insert into annot_dataset_text (dataset_id, name, value) values ('/d1/d2/f1', 'create-date', '2013.0123.23:07:29.123');
+insert into annot_dataset_text (dataset_id, name, value) values ('/d1/d2/f1', 'type', 'pdb');
+insert into annot_dataset_text (dataset_id, name, value) values ('/d1/d2/f1', 'state', 'unverified');
+insert into annot_dataset_text (dataset_id, name, value) values ('/d1/d2/f1', 'note','Initial structure prediction from loop model. mw');
+
+END
Added: provenancedb/tags/types
===================================================================
--- provenancedb/tags/types (rev 0)
+++ provenancedb/tags/types 2013-10-30 04:39:58 UTC (rev 7249)
@@ -0,0 +1,14 @@
+dataset-required name create_date location nfiles size
+dataset-allowed member*
+
+script-required name version source repo_url
+script-allowed none
+
+app-required name version source
+app-required none
+
+run-required start_date id script
+run-allowed restarts
+
+unknown-required none
+unknown-allowed any
More information about the Swift-commit
mailing list