[chronojump] DB:1.22 Encoder laterality in english



commit 2042afba1c16146c971b3d5db7bd90799740bdfd
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Feb 27 12:48:37 2015 +0100

    DB:1.22 Encoder laterality in english

 po/POTFILES.in        |    1 +
 src/encoder.cs        |   20 ++++++++++++++++++++
 src/gui/encoder.cs    |    4 ++--
 src/sqlite/encoder.cs |    9 +++++----
 src/sqlite/main.cs    |   22 +++++++++++++++++++++-
 5 files changed, 49 insertions(+), 7 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 44f13ba..e00e7b6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -57,6 +57,7 @@ src/server.cs
 src/serverPing.cs
 src/sqlite/main.cs
 src/sqlite/country.cs
+src/sqlite/encoder.cs
 src/sqlite/personSession.cs
 src/sqlite/server.cs
 src/sqlite/session.cs
diff --git a/src/encoder.cs b/src/encoder.cs
index 38b0f72..601c016 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -654,6 +654,26 @@ public class EncoderSQL
        }
 
 
+       /* 
+        * translations stuff
+        * used to store in english and show translated in GUI
+        */
+               
+       private string [] lateralityOptionsEnglish = { "RL", "R", "L" }; //attention: if this changes, change 
it also in gui/encoder.cs createEncoderCombos()
+       public string LateralityToEnglish() 
+       {
+               int count = 0;
+               foreach(string option in lateralityOptionsEnglish) {
+                       if(Catalog.GetString(option) == laterality)
+                               return lateralityOptionsEnglish[count];
+                       count ++;
+               }
+               //default return first value
+               return lateralityOptionsEnglish[0];
+       }
+
+
+
        //used in NUnit
        public string Filename
        {
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 6514d8b..629e63b 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -3095,8 +3095,8 @@ public partial class ChronoJumpWindow
                                Catalog.GetString(comboEcconOptions[0]));
                combo_encoder_eccon.Changed += new EventHandler (on_combo_encoder_eccon_changed);
                
-               //create combo laterality
-               string [] comboLateralityOptions = { "RL", "R", "L" };
+               //create combo laterality. SqliteEncoder Inserts and Update in english. Select is done 
translated
+               string [] comboLateralityOptions = { "RL", "R", "L" }; //attention: if this changes, change 
it also in encoder.cs (EncoderSQL)
                string [] comboLateralityOptionsTranslated = { 
                        Catalog.GetString("RL"), Catalog.GetString("R"), Catalog.GetString("L") };
                encoderLateralityTranslation = new String [comboLateralityOptions.Length];
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index e542e9b..3db3455 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -23,6 +23,7 @@ using System.Data;
 using System.IO;
 using System.Collections; //ArrayList
 using Mono.Data.Sqlite;
+using Mono.Unix;
 
 
 class SqliteEncoder : Sqlite
@@ -45,7 +46,7 @@ class SqliteEncoder : Sqlite
                        "sessionID INT, " +
                        "exerciseID INT, " +
                        "eccon TEXT, " +        //"c" or "ec"
-                       "laterality TEXT, " +   //"left" "right" "both"
+                       "laterality TEXT, " +   //"RL" "R" "L". stored in english
                        "extraWeight TEXT, " +  //string because can contain "33%" or "50Kg"
                        "signalOrCurve TEXT, " + //"signal" or "curve"
                        "filename TEXT, " +
@@ -82,7 +83,7 @@ class SqliteEncoder : Sqlite
                        " VALUES (" + es.uniqueID + ", " +
                        es.personID + ", " + es.sessionID + ", " +
                        es.exerciseID + ", '" + es.eccon + "', '" +
-                       es.laterality + "', '" + es.extraWeight + "', '" +
+                       es.LateralityToEnglish() + "', '" + es.extraWeight + "', '" +
                        es.signalOrCurve + "', '" + es.filename + "', '" +
                        removeURLpath(es.url) + "', " + 
                        es.time + ", " + es.minHeight + ", '" + es.description + 
@@ -128,7 +129,7 @@ class SqliteEncoder : Sqlite
                                ", sessionID = " + es.sessionID +
                                ", exerciseID = " + es.exerciseID +
                                ", eccon = '" + es.eccon +
-                               "', laterality = '" + es.laterality +
+                               "', laterality = '" + es.LateralityToEnglish() +
                                "', extraWeight = '" + es.extraWeight +
                                "', signalOrCurve = '" + es.signalOrCurve +
                                "', filename = '" + es.filename +
@@ -283,7 +284,7 @@ class SqliteEncoder : Sqlite
                                        Convert.ToInt32(reader[2].ToString()),  //sessionID
                                        Convert.ToInt32(reader[3].ToString()),  //exerciseID
                                        reader[4].ToString(),                   //eccon
-                                       reader[5].ToString(),                   //laterality
+                                       Catalog.GetString(reader[5].ToString()),//laterality
                                        reader[6].ToString(),                   //extraWeight
                                        reader[7].ToString(),                   //signalOrCurve
                                        reader[8].ToString(),                   //filename
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 0ce6121..eeae579 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -73,7 +73,7 @@ class Sqlite
        /*
         * Important, change this if there's any update to database
         */
-       static string lastChronojumpDatabaseVersion = "1.21";
+       static string lastChronojumpDatabaseVersion = "1.22";
 
        public Sqlite() {
        }
@@ -1764,6 +1764,25 @@ class Sqlite
 
                                currentVersion = "1.21";
                        }
+                       if(currentVersion == "1.21") {
+                               LogB.SQL("Encoder laterality in english again");
+                               
+                               Sqlite.Open();
+               
+                               if(Catalog.GetString("RL") != "RL")     
+                                       Update(true, Constants.EncoderTable, "laterality", 
Catalog.GetString("RL"), "RL", "", "");
+                               
+                               if(Catalog.GetString("R") != "R")       
+                                       Update(true, Constants.EncoderTable, "laterality", 
Catalog.GetString("R"), "R", "", "");
+                               
+                               if(Catalog.GetString("L") != "L")       
+                                       Update(true, Constants.EncoderTable, "laterality", 
Catalog.GetString("L"), "L", "", "");
+
+                               SqlitePreferences.Update ("databaseVersion", "1.22", true); 
+                               Sqlite.Close();
+
+                               currentVersion = "1.22";
+                       }
        
                }
 
@@ -1908,6 +1927,7 @@ class Sqlite
                SqliteExecuteAuto.addChronojumpProfileAndBilateral();
                
                //changes [from - to - desc]
+               //1.21 - 1.22 Converted DB to 1.22 Encoder laterality in english again
                //1.20 - 1.21 Converted DB to 1.21 Fixing loosing of encoder videoURL after recalculate
                //1.19 - 1.20 Converted DB to 1.20 Preferences: added user email
                //1.18 - 1.19 Converted DB to 1.19 Preferences deleted showHeight, added showStiffness


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