[chronojump] Prepare jump profile on executeAuto



commit 19976ea0eaaa812d1aa6761d97c60c2964e4d69f
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sat Oct 18 15:37:32 2014 -0300

    Prepare jump profile on executeAuto

 chronojump_server/Makefile.am |    1 +
 src/Makefile.am               |    1 +
 src/executeAuto.cs            |    9 ++++--
 src/genericObjects.cs         |   53 +++++++++++++++++++++++++++++++++++++++++
 src/sqlite/executeAuto.cs     |   32 +++++++++++++++++++++---
 src/sqlite/main.cs            |    4 +++
 6 files changed, 93 insertions(+), 7 deletions(-)
---
diff --git a/chronojump_server/Makefile.am b/chronojump_server/Makefile.am
index abef8d4..968540e 100644
--- a/chronojump_server/Makefile.am
+++ b/chronojump_server/Makefile.am
@@ -12,6 +12,7 @@ SOURCES = \
        ../src/encoder.cs\
        ../src/executeAuto.cs\
        ../src/event.cs\
+       ../src/genericObjects.cs\
        ../src/jump.cs\
        ../src/run.cs\
        ../src/person.cs\
diff --git a/src/Makefile.am b/src/Makefile.am
index efdd7a7..c1f58d9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -119,6 +119,7 @@ SOURCES = \
        executeAuto.cs\
        event.cs\
        eventType.cs\
+       genericObjects.cs\
        jump.cs\
        jumpType.cs\
        person.cs\
diff --git a/src/executeAuto.cs b/src/executeAuto.cs
index 1fac9db..a5f4daf 100644
--- a/src/executeAuto.cs
+++ b/src/executeAuto.cs
@@ -142,7 +142,7 @@ public class ExecuteAutoSQL
                this.serie3IDs = serie3IDs;
        }
 
-       private string serieIDsToStr(List<int> serieIDs) 
+       public string SerieIDsToStr(List<int> serieIDs) 
        {
                string str = "";
                string sep = "";
@@ -175,8 +175,7 @@ public class ExecuteAutoSQL
                if(Sqlite.Exists(false, Constants.ExecuteAutoTable, name))
                        return false; //not saved because name exists
 
-               SqliteExecuteAuto.Insert(false, name, mode.ToString(), description, 
-                               serieIDsToStr(serie1IDs), serieIDsToStr(serie2IDs), serieIDsToStr(serie3IDs));
+               SqliteExecuteAuto.Insert(false, this);
                        
                return true; //saved
        }
@@ -210,6 +209,10 @@ public class ExecuteAutoSQL
        public ExecuteAuto.ModeTypes Mode {
                get { return mode; }
        }
+       
+       public string Description {
+               get { return description; }
+       }
 
        public List<int> Serie1IDs {
                get { return serie1IDs; }
diff --git a/src/genericObjects.cs b/src/genericObjects.cs
new file mode 100644
index 0000000..887d489
--- /dev/null
+++ b/src/genericObjects.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic; //List<T>
+
+public class IDName
+{
+       private int uniqueID;
+       private string name;
+
+       public IDName(int uniqueID, string name) {
+               this.uniqueID = uniqueID;
+               this.name = name;
+       }
+
+       public int UniqueID {
+              get { return uniqueID; }
+       }              
+       
+       public string Name {
+              get { return name; }
+       }
+}
+
+public class IDNameList
+{
+       private List<IDName> l;
+
+       public IDNameList() {
+       }
+       
+       //some string [], divided by ":" have first and second strings: uniqueID and name
+       public IDNameList(string [] strArray, char sep) 
+       {
+               l = new List<IDName>();
+               foreach(string strJump in strArray) {
+                       string [] strFull = strJump.Split(new char[] {sep});
+                       l.Add(new IDName(Convert.ToInt32(strFull[0]), strFull[1]));
+               }
+       }
+
+       public int FindID(string name) {
+               foreach(IDName i in l)
+                       if(i.Name == name)
+                               return i.UniqueID;
+               return -1;
+       }
+
+       public string FindName(int uniqueID) {
+               foreach(IDName i in l)
+                       if(i.UniqueID == uniqueID)
+                               return i.Name;
+               return "";
+       }
+}
diff --git a/src/sqlite/executeAuto.cs b/src/sqlite/executeAuto.cs
index 11d9d2f..cddf2b7 100644
--- a/src/sqlite/executeAuto.cs
+++ b/src/sqlite/executeAuto.cs
@@ -57,7 +57,7 @@ class SqliteExecuteAuto : Sqlite
         * class methods
         */
        
-       public static void Insert(bool dbconOpened, string name, string mode, string description, string 
serie1IDs, string serie2IDs, string serie3IDs)
+       public static void Insert(bool dbconOpened, ExecuteAutoSQL eaSQL)
        {
                if(! dbconOpened)
                        dbcon.Open();
@@ -67,8 +67,10 @@ class SqliteExecuteAuto : Sqlite
                        " serie1IDs, serie2IDs, serie3IDs, " + 
                        " future1, future2, future3)" +
                        " VALUES ( NULL, '" +
-                       name + "', '" + mode + "', '" + description + "', '" +
-                       serie1IDs + "', '" + serie2IDs + "', '" + serie3IDs + "', " + 
+                       eaSQL.name + "', '" + eaSQL.Mode.ToString() + "', '" + eaSQL.Description + "', '" +
+                       eaSQL.SerieIDsToStr(eaSQL.Serie1IDs) + "', '" + 
+                       eaSQL.SerieIDsToStr(eaSQL.Serie2IDs) + "', '" + 
+                       eaSQL.SerieIDsToStr(eaSQL.Serie3IDs) + "', " + 
                        "'', '', '')"; //future1, future2, future3
                Log.WriteLine(dbcmd.CommandText.ToString());
                dbcmd.ExecuteNonQuery();
@@ -77,9 +79,31 @@ class SqliteExecuteAuto : Sqlite
                        dbcon.Close();
        }
 
+       protected internal static void addChronojumpProfileAndBilateral()
+       {
+               string [] jumps = SqliteJumpType.SelectJumpTypes(true, "", "", false);
+               IDNameList jList = new IDNameList(jumps,':');
+
+               List <ExecuteAutoSQL> eaSQLlist = new List<ExecuteAutoSQL> {
+                       new ExecuteAutoSQL( -1, "Chronojump profile", ExecuteAuto.ModeTypes.BY_PERSONS, 
"Complete profile using jumps",
+                                       new List<int> { jList.FindID("SJ"), jList.FindID("SJl"), 
jList.FindID("CMJ"), jList.FindID("ABK"), jList.FindID("DJa") },
+                                       new List<int>{}, 
+                                       new List<int>{} ),
+                       
+                       //new ExecuteAutoSQL( -1, "Bilateral tests", ExecuteAuto.ModeTypes.BY_PERSONS, 
"Bilateral / Unilateral measurements with jumps",
+                       //              new List<int> {TODO: ints hereCMJ_R, CMJ_}, new List<int>{}, new 
List<int>{} ),
+                       //TODO: add the BY_SERIES
+               };
+
+               foreach(ExecuteAutoSQL eaSQL in eaSQLlist) {
+                       Insert(true, eaSQL);
+               }
+       }
+
+
 
        //uniqueID == -1 selects all ExecuteAutoSQLs
-       //uniqueID > 0 selects one ExecuteAutoSQL
+       //uniqueID > 0 selects one ExecuteAutoSQL       
        public static List<ExecuteAutoSQL> Select(bool dbconOpened, int uniqueID) 
        {
                if(! dbconOpened)
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 67db621..7440012 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -458,6 +458,10 @@ class Sqlite
 
                currentVersion = SqlitePreferences.Select("databaseVersion");
 
+//dbcon.Open();
+//SqliteExecuteAuto.addChronojumpProfileAndBilateral();
+//dbcon.Close();
+
                //Log.WriteLine("lastDB: {0}", Convert.ToDouble(lastChronojumpDatabaseVersion));
                //Log.WriteLine("currentVersion: {0}", Convert.ToDouble(currentVersion));
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]