Index: trunk/MagicSoft/Mars/datacenter/scripts/sourcefile
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/sourcefile	(revision 7925)
+++ trunk/MagicSoft/Mars/datacenter/scripts/sourcefile	(revision 7927)
@@ -70,7 +70,9 @@
 Ffillganymed=21
 
+#
 # setup for jobmanager
+#
 steps=$mars/steps.rc
-
+# resetting values
 pno=0
 totalpno=0
@@ -79,5 +81,5 @@
 runningscript=0
 queuedscript=0
-
+stillinqueue=0
 
 function setzero()
@@ -100,5 +102,4 @@
 
 
-
 # in the following the function, which are needed by several scripts, are 
 # defined
@@ -113,14 +114,10 @@
 }
 
-# function to do continue in a loop or exit the program depending on what is needed
-function contex()
-{
+# function to do continue in a loop and produce according logging
+function cont()
+{
+   date
    echo ""
-   if [ "$singleprocess" = "yes" ]
-   then 
-      continue
-   else
-      finish
-   fi
+   continue
 }
 
@@ -148,5 +145,5 @@
        1)   echo " checklock0=$checklock0 -> file $lockfile exists -> exit"
             date 
-            contex;;
+            exit;;
        *)   echo " checklock0=$checklock0 -> something went completely wrong" ;;
    esac
@@ -154,5 +151,5 @@
 
 # function calling the macro, which is producing the todo-list
-function getdolist()
+function getdolistroot()
 {
    datetime=`date +%F-%H-%M-%S`
@@ -278,12 +275,8 @@
 
 # function to get todolist
-function gettodo()
-{
-   echo "getting todo..."
+function getdolist()
+{
+   echo "getting todolist..."
    getdbsetup 
-   if [ "$singleprocess" = "yes" ]
-   then 
-      column=${scriptscolname[$i]}
-   fi
    getstepinfo
    # get query
@@ -296,24 +289,12 @@
       done
    fi
-   if ! echo $influences | grep '#' > /dev/null 
-   then 
-      for influence in $influences
-      do 
-         query=$query" isnull($influence) and"
-      done
-   fi
    query=$query" isnull($column) "
    query=$query" and isnull(fStartTime) and isnull(fFailedTime) and isnull(fFailedCode) and isnull(fFailedCodeAdd) and isnull(fReturnCode) "
    query=$query" order by $primary desc "
-   if [ "$singleprocess" = "yes" ]
-   then 
-      query=$query" limit 0, 1 "
-   fi
 #   echo " QUERY: "$query
    if ! process=`mysql -s -u $us --password=$pw --host=hercules $db -e " $query "`
    then
-      echo "ERROR could not query process from db -> contex"
-      rm -v $lockfile
-      contex
+      echo "ERROR could not query process from db -> exit"
+      finish
    fi
 
@@ -321,24 +302,77 @@
    then
       echo "  => nothing to do" 
-      rm -v $lockfile
-      contex 
+      finish
    else 
-      if [ "$singleprocess" = "yes" ]
-      then 
-         todofile=$listpath/ToDo-$table-$column-$process.txt
-         echo "  => found $process"
-      else
-         todofile=$listpath/ToDo-$table-$column.txt
-         echo "found processes"
-      fi
-#      echo " list: "$todofile
+      todofile=$listpath/ToDo-$table-$column.txt
       
       if ls $todofile > /dev/null 2>&1
       then
          echo "$todofile exists already"
-         rm -v $lockfile
-         contex 
+         finish
       fi
+      echo "found processes, writing todofile..."
       echo $process > $todofile
+   fi
+}
+
+# function to get todo (process)
+function gettodo()
+{
+   process=
+   echo "getting todo..."
+   getdbsetup 
+   getstepinfo
+   # get query
+   query=" select $primary from $table where "
+   if ! echo $needs | grep '#' > /dev/null 
+   then 
+      for need in $needs
+      do
+         query=$query" not isnull($need) and"
+      done
+   fi
+   query=$query" isnull($column) "
+   query=$query" and isnull(fStartTime) and isnull(fFailedTime) and isnull(fFailedCode) and isnull(fFailedCodeAdd) and isnull(fReturnCode) "
+   query=$query" order by $primary desc "
+   query=$query" limit 0, 1 "
+#   echo " QUERY: "$query
+   if ! process=`mysql -s -u $us --password=$pw --host=hercules $db -e " $query "`
+   then
+      echo "ERROR could not query process from db -> exit"
+      finish
+   fi
+
+   if [ "$process" = "" ]
+   then
+      echo "  => nothing to do -> exit" 
+      finish
+   fi
+}
+
+# function to get the number of processes which still have to be done
+function getstatus()
+{
+   numproc=
+   echo "getting status..."
+   getdbsetup 
+   column=${scriptscolname[$i]}
+   getstepinfo
+   # get query
+   query=" select count(*) from $table where "
+   if ! echo $needs | grep '#' > /dev/null 
+   then 
+      for need in $needs
+      do
+         query=$query" not isnull($need) and"
+      done
+   fi
+   query=$query" isnull($column) "
+   query=$query" and isnull(fStartTime) and isnull(fFailedTime) and isnull(fFailedCode) and isnull(fFailedCodeAdd) and isnull(fReturnCode) "
+   query=$query" group by $column "
+#   echo " QUERY: "$query
+   if ! numproc=`mysql -s -u $us --password=$pw --host=hercules $db -e " $query "`
+   then
+      echo "ERROR could not query number of todo proceses from db -> continue"
+      cont
    fi
 }
@@ -349,11 +383,8 @@
    resetstatusvalues
    evalstatus $@
-
-   echo "setting todo..."
    getdbsetup 
    getstepinfo
    # get query
    reset=`grep "$coltab[.]Reset:" $steps | sed -e "s/$coltab[.]Reset://" -e 's/ //g'`
-   echo -$reset-
    if [ "$reset" = "no" ]
    then
