[chronojump] Changes for Networks v3.1: * Use always the word player instead of person in all Networks requests *



commit d7a43c88f1a71cd3ac9afad57d26027dcebb49d2
Author: Leninux <arnau lenin sobtec cat>
Date:   Mon Jul 19 13:18:55 2021 +0200

    Changes for Networks v3.1:
    * Use always the word player instead of person in all Networks requests
    * Changed the upload endpoints (removed suffix Data)
    * Task no longer have station_id
    * Station_id is not needed in authenticated requests, information already known by the server
    * getStationExercises is a GET request without params

 src/gui/dialogPersonPopup.cs |  4 ++--
 src/json/compujump.cs        | 53 +++++++++++---------------------------------
 src/json/compujumpOther.cs   |  7 +-----
 src/json/json.cs             |  2 --
 4 files changed, 16 insertions(+), 50 deletions(-)
---
diff --git a/src/gui/dialogPersonPopup.cs b/src/gui/dialogPersonPopup.cs
index f77b6cb86..929273f90 100644
--- a/src/gui/dialogPersonPopup.cs
+++ b/src/gui/dialogPersonPopup.cs
@@ -150,13 +150,13 @@ public class DialogPersonPopup
                        {
                                Gtk.VBox vboxRL = new Gtk.VBox(false, 4);
 
-                               Task taskCopy = new Task(t.Id, t.PersonId, t.StationId, t.ExerciseId, 
t.ExerciseName,
+                               Task taskCopy = new Task(t.Id, t.PersonId, t.ExerciseId, t.ExerciseName,
                                        t.Sets, t.Nreps, t.Load, t.Speed, t.PercentMaxSpeed,
                                        "R", t.Comment);
                                Gtk.HBox hboxStartAndLabel = createHBoxStartAndLabel(taskCopy, pixbuf);
                                vboxRL.PackStart(hboxStartAndLabel, false, false, 0);
 
-                               taskCopy = new Task(t.Id, t.PersonId, t.StationId, t.ExerciseId, 
t.ExerciseName,
+                               taskCopy = new Task(t.Id, t.PersonId, t.ExerciseId, t.ExerciseName,
                                        t.Sets, t.Nreps, t.Load, t.Speed, t.PercentMaxSpeed,
                                        "L", t.Comment);
                                hboxStartAndLabel = createHBoxStartAndLabel(taskCopy, pixbuf);
diff --git a/src/json/compujump.cs b/src/json/compujump.cs
index 661570067..6a8fc0e82 100644
--- a/src/json/compujump.cs
+++ b/src/json/compujump.cs
@@ -47,7 +47,7 @@ public class JsonCompujump : Json
                Person person = new Person(-1);
 
                // Create a request using a URL that can receive a post.
-               if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/getPersonByRFID"))
+               if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/getPlayerByRFID"))
                        return person;
 
                // Set the Method property of the request to POST.
@@ -67,7 +67,6 @@ public class JsonCompujump : Json
                        return person;
 
                dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);
-
                dataStream.Close ();
                
                HttpWebResponse response;
@@ -175,9 +174,7 @@ public class JsonCompujump : Json
 
                // Creates the json object
                JsonObject json = new JsonObject();
-
-               json.Add("person_id", personID.ToString());
-               json.Add("station_id", stationID.ToString());
+               json.Add("player_id", personID.ToString());
 
                // Converts it to a String
                String js = json.ToString();
@@ -222,12 +219,10 @@ public class JsonCompujump : Json
 
                foreach (JsonValue jsonTask in jsonTasks) {
                        Int32 id = jsonTask ["id"];
-                       //char type = jsonTask ["type"];
+                       int personId = jsonTask ["player_id"];
                        int exerciseId = jsonTask ["exercise_id"];
                        string exerciseName = jsonTask ["exercise_name"];
 
-                       int personId = jsonTask ["person"];
-                       int stationId = jsonTask ["station"];
                        int sets = jsonTask ["sets"];
                        int nreps = jsonTask ["nreps"];
                        float load = jsonTask ["load"];
@@ -235,7 +230,7 @@ public class JsonCompujump : Json
                        float percentMaxSpeed = jsonTask ["percent_max_speed"];
                        string laterality = jsonTask ["laterality"];
                        string comment = jsonTask ["comment"];
-                       tasks.Add(new Task(id, personId, stationId, exerciseId, exerciseName,
+                       tasks.Add(new Task(id, personId, exerciseId, exerciseName,
                                                sets, nreps, load, speed, percentMaxSpeed,
                                                laterality, comment));
                }
@@ -266,7 +261,6 @@ public class JsonCompujump : Json
                        return false;
 
                dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);
-
                dataStream.Close ();
 
                // Get the response.
@@ -297,8 +291,7 @@ public class JsonCompujump : Json
 
                // Creates the json object
                JsonObject json = new JsonObject();
-               json.Add("person_id", personID.ToString());
-               json.Add("station_id", stationID.ToString());
+               json.Add("player_id", personID.ToString());
 
                // Converts it to a String
                String js = json.ToString();
@@ -351,30 +344,13 @@ public class JsonCompujump : Json
                if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/getStationExercises"))
                        return ex_list;
 
-               // Set the Method property of the request to POST.
-               request.Method = "POST";
-
-               // Creates the json object
-               JsonObject json = new JsonObject();
-               json.Add("station_id", stationId);
-
-               // Converts it to a String
-               String js = json.ToString();
-
-               // Writes the json object into the request dataStream
-               Stream dataStream;
-               if(! getWebRequestStream (request, out dataStream, Catalog.GetString("Could not get station 
exercises.")))
-                       return ex_list;
-
-               dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);
-
-               dataStream.Close ();
+               // Set the Method property of the request to GET.
+               request.Method = "GET";
 
                HttpWebResponse response;
                if(! getHttpWebResponse (request, out response, Catalog.GetString("Could not get station 
exercises.")))
                        return ex_list;
 
-
                string responseFromServer;
                using (var sr = new StreamReader(response.GetResponseStream()))
                {
@@ -497,7 +473,7 @@ public class JsonCompujump : Json
        {
                LogB.Information("calling upload sprint");
                // Create a request using a URL that can receive a post.
-               if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/uploadSprintData"))
+               if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/uploadSprint"))
                        return false;
 
                /*
@@ -511,7 +487,7 @@ public class JsonCompujump : Json
 
                // Creates the json object
                JsonObject json = new JsonObject();
-               json.Add("person_id", o.personId);
+               json.Add("player_id", o.personId);
                json.Add("distances", o.sprintPositions);
                json.Add("t1", o.splitTimesL[1]);
 
@@ -556,7 +532,6 @@ public class JsonCompujump : Json
                        return false;
 
                dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);
-
                dataStream.Close ();
 
                // Get the response.
@@ -586,7 +561,7 @@ public class JsonCompujump : Json
        public bool UploadEncoderData(UploadEncoderDataFullObject o)
        {
                // Create a request using a URL that can receive a post.
-               if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/uploadEncoderData"))
+               if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/uploadEncoder"))
                        return false;
 
                // Set the Method property of the request to POST.
@@ -594,7 +569,7 @@ public class JsonCompujump : Json
 
                // Creates the json object
                JsonObject json = new JsonObject();
-               json.Add("person_id", o.personId);
+               json.Add("player_id", o.personId);
                json.Add("station_id", o.stationId);
                //json.Add("exercise_name", Util.RemoveAccents(exerciseName));
                json.Add("exercise_id", o.exerciseId);
@@ -628,7 +603,6 @@ public class JsonCompujump : Json
                        return false;
 
                dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);
-
                dataStream.Close ();
 
                // Get the response.
@@ -650,7 +624,7 @@ public class JsonCompujump : Json
        public bool UploadForceSensorData(UploadForceSensorDataFullObject o)
        {
                // Create a request using a URL that can receive a post.
-               if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/uploadForceSensorData"))
+               if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/uploadForce"))
                        return false;
 
                // Set the Method property of the request to POST.
@@ -658,7 +632,7 @@ public class JsonCompujump : Json
 
                // Creates the json object
                JsonObject json = new JsonObject();
-               json.Add("person_id", o.personId);
+               json.Add("player_id", o.personId);
                json.Add("station_id", o.stationId);
                //json.Add("exercise_name", Util.RemoveAccents(exerciseName));
                json.Add("exercise_id", o.exerciseId);
@@ -697,7 +671,6 @@ public class JsonCompujump : Json
                        return false;
 
                dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);
-
                dataStream.Close ();
 
                // Get the response.
diff --git a/src/json/compujumpOther.cs b/src/json/compujumpOther.cs
index f546f65e7..e81659e29 100644
--- a/src/json/compujumpOther.cs
+++ b/src/json/compujumpOther.cs
@@ -28,9 +28,7 @@ using Mono.Unix;
 public class Task
 {
        public int Id;
-       public char Type; //initially 'P'arametrized or 'F'ree. Now all are 'P'
        public int PersonId;
-       public int StationId;
        public int ExerciseId;
        public string ExerciseName;
        public int Sets;
@@ -47,15 +45,12 @@ public class Task
                Comment = "";
        }
 
-       public Task(int id, int personId, int stationId, int exerciseId, string exerciseName,
+       public Task(int id, int personId, int exerciseId, string exerciseName,
                        int sets, int nreps, float load, float speed, float percentMaxSpeed,
                        string laterality, string comment)
        {
-               Type = 'P'; //parametrized
-
                Id = id;
                PersonId = personId;
-               StationId = stationId;
                ExerciseId = exerciseId;
                ExerciseName = exerciseName;
                Sets = sets;
diff --git a/src/json/json.cs b/src/json/json.cs
index 0d40c620e..64b0259e3 100644
--- a/src/json/json.cs
+++ b/src/json/json.cs
@@ -417,7 +417,6 @@ public class Json
                }
 
                dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);
-
                dataStream.Close ();
 
                // Get the response.
@@ -477,7 +476,6 @@ public class Json
                        return false;
 
                dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);
-
                dataStream.Close ();
 
                // Get the response.


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