Añadido campo id_scene a tabla student, escenas esperando que el json mande el…

Añadido campo id_scene a tabla student, escenas esperando que el json mande el id de esa escena para ese usuario
parent 7837de75
...@@ -177,8 +177,10 @@ public class Device extends SQLiteOpenHelper { ...@@ -177,8 +177,10 @@ public class Device extends SQLiteOpenHelper {
while (cursor.moveToNext() && user == null) while (cursor.moveToNext() && user == null)
if (cursor.getInt(0) == id_stu && cursor.getInt(9) == id_sup) if (cursor.getInt(0) == id_stu && cursor.getInt(9) == id_sup)
user = new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8), user = new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getInt(5),
cursor.getInt(9), cursor.getString(10), cursor.getString(11), cursor.getString(12), cursor.getString(13), cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17), cursor.getString(18)); cursor.getString(6), cursor.getString(7), cursor.getString(8),cursor.getString(9),cursor.getInt(10), cursor.getString(11),
cursor.getString(12), cursor.getString(13),cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17),
cursor.getString(18),cursor.getString(19));
cursor.close(); cursor.close();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ //db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
return user; return user;
...@@ -223,8 +225,10 @@ public class Device extends SQLiteOpenHelper { ...@@ -223,8 +225,10 @@ public class Device extends SQLiteOpenHelper {
Cursor cursor = db.query("users_detail", null, null, null, null, null, null, null); Cursor cursor = db.query("users_detail", null, null, null, null, null, null, null);
while (cursor.moveToNext()) while (cursor.moveToNext())
if (cursor.getInt(9) == id_sup) if (cursor.getInt(9) == id_sup)
users.add(new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8), users.add(new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getInt(5),
cursor.getInt(9), cursor.getString(10), cursor.getString(11), cursor.getString(12), cursor.getString(13), cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17), cursor.getString(18))); cursor.getString(6), cursor.getString(7), cursor.getString(8),cursor.getString(9),cursor.getInt(10), cursor.getString(11),
cursor.getString(12), cursor.getString(13),cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17),
cursor.getString(18),cursor.getString(19)));
cursor.close(); cursor.close();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ //db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
return users; return users;
...@@ -257,7 +261,7 @@ public class Device extends SQLiteOpenHelper { ...@@ -257,7 +261,7 @@ public class Device extends SQLiteOpenHelper {
if (user_found) if (user_found)
if (cursor.getString(2)!=null && cursor.getString(2).equals(apwd)) { if (cursor.getString(2)!=null && cursor.getString(2).equals(apwd)) {
users = new Vector<>(1); users = new Vector<>(1);
users.add(new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8), users.add(new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getInt(5), cursor.getString(6), cursor.getString(7), cursor.getString(8), cursor.getString(9),
User.NO_SUPERVISOR, "", "", "", "", "", "", "", "", "")); User.NO_SUPERVISOR, "", "", "", "", "", "", "", "", ""));
} }
else throw new LoginException("Student password incorrect", LoginException.BAD_LOGIN); else throw new LoginException("Student password incorrect", LoginException.BAD_LOGIN);
...@@ -284,8 +288,10 @@ public class Device extends SQLiteOpenHelper { ...@@ -284,8 +288,10 @@ public class Device extends SQLiteOpenHelper {
Cursor cursor = db.query("users_detail", null, null, null, null, null, null, null); Cursor cursor = db.query("users_detail", null, null, null, null, null, null, null);
Vector<User> users = new Vector<User>(cursor.getCount()); Vector<User> users = new Vector<User>(cursor.getCount());
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
user = new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8), user = new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getInt(5),
cursor.getInt(9), cursor.getString(10), cursor.getString(11), cursor.getString(12), cursor.getString(13), cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17), cursor.getString(18)); cursor.getString(6), cursor.getString(7), cursor.getString(8),cursor.getString(9),cursor.getInt(10), cursor.getString(11),
cursor.getString(12), cursor.getString(13),cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17),
cursor.getString(18),cursor.getString(19));
users.add(user); users.add(user);
} }
...@@ -295,6 +301,7 @@ public class Device extends SQLiteOpenHelper { ...@@ -295,6 +301,7 @@ public class Device extends SQLiteOpenHelper {
} }
public void insertUser(User user) { public void insertUser(User user) {
Log.e(LOG_TAG,"LLAMA A INSERT USER");
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
db.beginTransaction(); db.beginTransaction();
db.execSQL("INSERT INTO users_detail values (" + db.execSQL("INSERT INTO users_detail values (" +
...@@ -302,7 +309,8 @@ public class Device extends SQLiteOpenHelper { ...@@ -302,7 +309,8 @@ public class Device extends SQLiteOpenHelper {
"'" + user.get_nickname_stu() + "', " + "'" + user.get_nickname_stu() + "', " +
(user.get_pwd_stu()==null || user.get_pwd_stu().length()==0 ? "NULL" : "'"+user.get_pwd_stu()+"'") + ", "+ (user.get_pwd_stu()==null || user.get_pwd_stu().length()==0 ? "NULL" : "'"+user.get_pwd_stu()+"'") + ", "+
"'" + user.get_name_stu() + "', " + "'" + user.get_name_stu() + "', " +
"'" + user.get_surname_stu() + "', " + "'" + user.get_surname_stu() + "', "
+ user.get_active_scene() + ", " +
"'" + user.get_url_img_stu() + "', " + "'" + user.get_url_img_stu() + "', " +
"'" + user.get_gender_stu() + "', " + "'" + user.get_gender_stu() + "', " +
"'" + user.get_lang_stu() + "', " + "'" + user.get_lang_stu() + "', " +
......
...@@ -75,8 +75,10 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -75,8 +75,10 @@ public class PCBDBHelper extends SQLiteOpenHelper {
if (cursor.getCount() > 0) { if (cursor.getCount() > 0) {
cursor.moveToFirst(); cursor.moveToFirst();
try { try {
last_user = new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8), last_user = new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getInt(5),
cursor.getInt(9), cursor.getString(10), cursor.getString(11), cursor.getString(12), cursor.getString(13), cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17), cursor.getString(18)); cursor.getString(6), cursor.getString(7), cursor.getString(8),cursor.getString(9),cursor.getInt(10), cursor.getString(11),
cursor.getString(12), cursor.getString(13),cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17),
cursor.getString(18),cursor.getString(19));
} catch (JSONException e) { } catch (JSONException e) {
Log.e(LOG_TAG, e.getMessage() + " BAD FORMED JSON: " + cursor.getString(5)); Log.e(LOG_TAG, e.getMessage() + " BAD FORMED JSON: " + cursor.getString(5));
System.exit(-1); System.exit(-1);
...@@ -169,6 +171,9 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -169,6 +171,9 @@ public class PCBDBHelper extends SQLiteOpenHelper {
+"')"; +"')";
Log.i(LOG_TAG,"Scene to be inserted: "+sql_scene); Log.i(LOG_TAG,"Scene to be inserted: "+sql_scene);
getWritableDatabase().execSQL(sql_scene); getWritableDatabase().execSQL(sql_scene);
//Added
PCBcontext.getVocabulary().setId_scene(params.getInt("id"));
PCBcontext.getPcbdb().getCurrentUser().set_active_scene(params.getInt("id"));
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
Log.e(LOG_TAG,"Error setting active scene:"+e.getMessage()); Log.e(LOG_TAG,"Error setting active scene:"+e.getMessage());
...@@ -197,13 +202,15 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -197,13 +202,15 @@ public class PCBDBHelper extends SQLiteOpenHelper {
*/ */
public Vocabulary getStudentVocabulary(Vocabulary vocabulary ) throws JSONException { public Vocabulary getStudentVocabulary(Vocabulary vocabulary ) throws JSONException {
int id_stu = this.getCurrentUser().get_id_stu(); int id_stu = this.getCurrentUser().get_id_stu();
int id_scene = this.getCurrentUser().get_active_scene();
Log.i(LOG_TAG,"Active Scene: "+id_scene+" id_Stu: "+id_stu);
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT * FROM collection_detail WHERE id_stu = "+id_stu,null); Cursor cursor = db.rawQuery("SELECT * FROM collection_detail WHERE id_stu = "+id_stu+" AND id_scene = "+id_scene,null);
Log.i(LOG_TAG, "Local recovering " + cursor.getCount() + " pictos for student " + id_stu + " from local DB"); Log.i(LOG_TAG, "Local recovering " + cursor.getCount() + " pictos for student " + id_stu + " from local DB");
cursor.moveToFirst(); cursor.moveToFirst();
if (cursor.getCount()>0) do{ if (cursor.getCount()>0) do{
Picto picto = new Picto(cursor.getInt(1), cursor.getString(2), cursor.getString(3), cursor.getString(4)); Picto picto = new Picto(cursor.getInt(1), cursor.getString(3), cursor.getString(4), cursor.getString(5));
vocabulary.addPicto(picto); vocabulary.addPicto(picto);
}while (cursor.moveToNext()); }while (cursor.moveToNext());
cursor.close(); cursor.close();
......
...@@ -3,6 +3,7 @@ package com.yottacode.pictogram.dao; ...@@ -3,6 +3,7 @@ package com.yottacode.pictogram.dao;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import com.yottacode.pictogram.net.PictoUploader;
import com.yottacode.pictogram.tools.Img; import com.yottacode.pictogram.tools.Img;
import org.json.JSONException; import org.json.JSONException;
...@@ -45,6 +46,7 @@ public class User { ...@@ -45,6 +46,7 @@ public class User {
public static String HIGHLIGHT="highlight"; public static String HIGHLIGHT="highlight";
} }
private Img img_stu; private Img img_stu;
private int id_scene_stu;
private String nickname_stu, pwd_stu, name_stu, surname_stu, gender_stu, lang_stu; private String nickname_stu, pwd_stu, name_stu, surname_stu, gender_stu, lang_stu;
private JSONObject attributes_stu; private JSONObject attributes_stu;
private Img img_sup; private Img img_sup;
...@@ -53,16 +55,17 @@ public class User { ...@@ -53,16 +55,17 @@ public class User {
public User(int id_stu, String nickname_stu, String pwd_stu, String name_stu, String surname_stu, String url_img_stu, String gender_stu, String lang_stu, String attributes_stu) throws JSONException { public User(int id_stu, String nickname_stu, String pwd_stu, String name_stu, String surname_stu, int id_scene_stu, String url_img_stu, String gender_stu, String lang_stu, String attributes_stu) throws JSONException {
this(id_stu, nickname_stu, pwd_stu, name_stu, surname_stu, url_img_stu, gender_stu, lang_stu, attributes_stu,User.NO_SUPERVISOR,"","","","","","M","es-es",null,null); this(id_stu, nickname_stu, pwd_stu, name_stu, surname_stu,id_scene_stu, url_img_stu, gender_stu, lang_stu, attributes_stu,User.NO_SUPERVISOR,"","","","","","M","es-es",null,null);
} }
public User(int id_stu, String nickname_stu, String pwd_stu, String name_stu, String surname_stu, String url_img_stu, String gender_stu, String lang_stu, String attributes_stu, public User(int id_stu, String nickname_stu, String pwd_stu, String name_stu, String surname_stu,int id_scene_stu, String url_img_stu, String gender_stu, String lang_stu, String attributes_stu,
int id_sup, String email_sup, String pwd_sup, String name_sup, String surname_sup, String url_img_sup, String gender_sup, String lang_sup, String tts_engine_sup, String office_sup) throws JSONException { int id_sup, String email_sup, String pwd_sup, String name_sup, String surname_sup, String url_img_sup, String gender_sup, String lang_sup, String tts_engine_sup, String office_sup) throws JSONException {
this.img_stu=new Img(id_stu,url_img_stu,Img.STUDENT); this.img_stu=new Img(id_stu,url_img_stu,Img.STUDENT);
this.nickname_stu=nickname_stu; this.nickname_stu=nickname_stu;
this.pwd_stu=pwd_stu; this.pwd_stu=pwd_stu;
this.name_stu=name_stu; this.name_stu=name_stu;
this.surname_stu=surname_stu; this.surname_stu=surname_stu;
this.id_scene_stu=id_scene_stu;
this.gender_stu=gender_stu; this.gender_stu=gender_stu;
this.lang_stu=lang_stu; this.lang_stu=lang_stu;
this.attributes_stu= attributes_stu!=null && attributes_stu.trim().length()>0 ? new JSONObject(attributes_stu) : new JSONObject(); this.attributes_stu= attributes_stu!=null && attributes_stu.trim().length()>0 ? new JSONObject(attributes_stu) : new JSONObject();
...@@ -255,7 +258,8 @@ public class User { ...@@ -255,7 +258,8 @@ public class User {
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
return -1; return 134;
//return -1;
} }
public void set_active_scene(int id) { public void set_active_scene(int id) {
......
...@@ -27,6 +27,7 @@ public class UserLogin { ...@@ -27,6 +27,7 @@ public class UserLogin {
private static final String TAG_USER = "user"; private static final String TAG_USER = "user";
private static final String TAG_TOKEN = "token"; private static final String TAG_TOKEN = "token";
private static final String TAG_ID = "id"; private static final String TAG_ID = "id";
private static final String TAG_ID_SCENE = "id_active_scene";
private static final String TAG_NAME = "name"; private static final String TAG_NAME = "name";
private static final String TAG_SURNAME = "surname"; private static final String TAG_SURNAME = "surname";
private static final String TAG_GENDER = "gender"; private static final String TAG_GENDER = "gender";
...@@ -179,8 +180,9 @@ public class UserLogin { ...@@ -179,8 +180,9 @@ public class UserLogin {
if(progressDialog.isShowing()) progressDialog.dismiss(); if(progressDialog.isShowing()) progressDialog.dismiss();
try { try {
JSONObject user = result.getJSONObject(TAG_USER); JSONObject user = result.getJSONObject(TAG_USER);
Log.i(LOG_TAG,user.toString());
int st_id_int = user.getInt(TAG_ID); int st_id_int = user.getInt(TAG_ID);
//int st_id_scene = user.getInt(TAG_ID_SCENE);
String st_name = user.getString(TAG_NAME); String st_name = user.getString(TAG_NAME);
String st_surname = user.getString(TAG_SURNAME); String st_surname = user.getString(TAG_SURNAME);
String st_pic = user.getString(TAG_PIC); String st_pic = user.getString(TAG_PIC);
...@@ -193,6 +195,7 @@ public class UserLogin { ...@@ -193,6 +195,7 @@ public class UserLogin {
password, password,
st_name, st_name,
st_surname, st_surname,
134/*st_id_scene*/,
st_pic, st_pic,
st_gender, st_gender,
st_lang, st_lang,
......
...@@ -194,7 +194,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -194,7 +194,7 @@ public class Vocabulary implements Iterable<Picto> {
try { try {
setHas_categories(result.getBoolean("categories")); setHas_categories(result.getBoolean("categories"));
setId_scene(result.getInt("id")); setId_scene(result.getInt("id"));
PCBcontext.getPcbdb().getCurrentUser().set_active_scene(result.getInt("id")); //PCBcontext.getPcbdb().getCurrentUser().set_active_scene(result.getInt("id"));
JSONArray stu_pictos = result.getJSONArray("pictos"); //Obtengo el JSONArray de los pictos JSONArray stu_pictos = result.getJSONArray("pictos"); //Obtengo el JSONArray de los pictos
Picto[] pictos = new Picto[stu_pictos.length()]; Picto[] pictos = new Picto[stu_pictos.length()];
......
...@@ -323,7 +323,9 @@ public class PictoUploader { ...@@ -323,7 +323,9 @@ public class PictoUploader {
params.put("attributes", picto.get_json_server_attrs()); params.put("attributes", picto.get_json_server_attrs());
params.put("id_stu", Integer.toString(PCBcontext.getPcbdb().getCurrentUser().get_id_stu())); params.put("id_stu", Integer.toString(PCBcontext.getPcbdb().getCurrentUser().get_id_stu()));
params.put("id_pic", Integer.toString(this.picto.get_id())); params.put("id_pic", Integer.toString(this.picto.get_id()));
params.put("id_scene" , Integer.toString(PCBcontext.getPcbdb().getCurrentUser().get_active_scene()));
//params.put("id_stuPicto", Integer.toString(this.picto.get_stupicto_id()));
Log.i(LOG_TAG, "Picto "+ this.picto.get_id()+" stupicto id:"+this.picto.get_stupicto_id()+" Uploading " + params.toString()); Log.i(LOG_TAG, "Picto "+ this.picto.get_id()+" stupicto id:"+this.picto.get_stupicto_id()+" Uploading " + params.toString());
PCBcontext.getRestapiWrapper().ask( PCBcontext.getRestapiWrapper().ask(
PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + "/picto", PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + "/picto",
......
...@@ -46,7 +46,8 @@ public class StudentTalk implements Emitter.Listener { ...@@ -46,7 +46,8 @@ public class StudentTalk implements Emitter.Listener {
String lang=msg.getString("lang"); String lang=msg.getString("lang");
String attributes=msg.getString("attributes"); String attributes=msg.getString("attributes");
User user=PCBcontext.getPcbdb().getCurrentUser(); User user=PCBcontext.getPcbdb().getCurrentUser();
User updatedUser=new User(id, username, user.get_pwd_stu(), name, surname, pic, gender, lang, attributes, //TODO: Obtener el id de la scene del JSONObject en lugar de poner 134
User updatedUser=new User(id, username, user.get_pwd_stu(), name, surname,134, pic, gender, lang, attributes,
user.get_id_sup(), user.get_email_sup(), user.get_pwd_sup(), user.get_name_sup(), user.get_surname_sup(), user.get_url_img_sup(), user.get_gender_sup(), user.get_id_sup(), user.get_email_sup(), user.get_pwd_sup(), user.get_name_sup(), user.get_surname_sup(), user.get_url_img_sup(), user.get_gender_sup(),
user.get_lang_sup(), user.get_tts_engine_sup(), user.get_office()); user.get_lang_sup(), user.get_tts_engine_sup(), user.get_office());
Log.i(this.getClass().getName(), "Attributes" +attributes+" listeners:"+listeners.length); Log.i(this.getClass().getName(), "Attributes" +attributes+" listeners:"+listeners.length);
......
...@@ -53,7 +53,7 @@ public class VocabularyTalk implements Emitter.Listener { ...@@ -53,7 +53,7 @@ public class VocabularyTalk implements Emitter.Listener {
JSONObject picto_stupicto = stu_picto.optJSONObject(param_picto); JSONObject picto_stupicto = stu_picto.optJSONObject(param_picto);
int picto_id = picto_stupicto.getInt(param_picto_id); int picto_id = picto_stupicto.getInt(param_picto_id);
int picto_cat = attrs_stu_picto!=null ? attrs_stu_picto.optInt(param_picto_cat, Picto.NO_CATEGORY) : 0; int picto_cat = attrs_stu_picto!=null ? attrs_stu_picto.optInt(param_picto_cat, Picto.NO_CATEGORY) : 0;
if(PCBcontext.getVocabulary().getId_scene() == PCBcontext.getPcbdb().getCurrentUser().get_active_scene()) { /*TODO: if(PCBcontext.getVocabulary().getId_scene() == msg.get("id_scene")) {*/
PCBcontext.getNetService().nextSynchro(new Date().getTime() + PCBcontext.getNetService().getSynchroTimingLength() * 2); //nos saltamos una sincronización para evitar que llegue antes que los websockets PCBcontext.getNetService().nextSynchro(new Date().getTime() + PCBcontext.getNetService().getSynchroTimingLength() * 2); //nos saltamos una sincronización para evitar que llegue antes que los websockets
Log.i(LOG_TAG, "Received message '" + action + Log.i(LOG_TAG, "Received message '" + action +
"' for picto " + picto_id + " (cat " + picto_cat + ", picto: " + picto_stupicto); "' for picto " + picto_id + " (cat " + picto_cat + ", picto: " + picto_stupicto);
...@@ -63,7 +63,7 @@ public class VocabularyTalk implements Emitter.Listener { ...@@ -63,7 +63,7 @@ public class VocabularyTalk implements Emitter.Listener {
: action.equals(action_add) ? iVocabularyListener.action.add : action.equals(action_add) ? iVocabularyListener.action.add
: iVocabularyListener.action.delete : iVocabularyListener.action.delete
, picto_cat, picto_id, stu_picto); , picto_cat, picto_id, stu_picto);
} //}
} catch (JSONException e) { } catch (JSONException e) {
Log.e(LOG_TAG, e.getClass().getCanonicalName() + "--" + e); Log.e(LOG_TAG, e.getClass().getCanonicalName() + "--" + e);
} }
......
...@@ -32,7 +32,8 @@ nickname TEXT(40) NOT NULL, ...@@ -32,7 +32,8 @@ nickname TEXT(40) NOT NULL,
pwd TEXT(40) NULL, pwd TEXT(40) NULL,
name TEXT(40) NOT NULL, name TEXT(40) NOT NULL,
surname TEXT(60) NOT NULL, surname TEXT(60) NOT NULL,
url_img VARCHAR(250) NOT NULL, id_scene INTEGER NOT NULL REFERENCES scene,
url_img VARCHAR(250) NOT NULL,
gender TEXT(1) NOT NULL CHECK (gender IN ('M','F')), gender TEXT(1) NOT NULL CHECK (gender IN ('M','F')),
lang TEXT(5) NOT NULL CHECK (lang in ('en-gb','en-us','es-es')), lang TEXT(5) NOT NULL CHECK (lang in ('en-gb','en-us','es-es')),
attributes TEXT(1024) NULL attributes TEXT(1024) NULL
...@@ -133,6 +134,7 @@ CREATE VIEW users_detail AS ...@@ -133,6 +134,7 @@ CREATE VIEW users_detail AS
a.pwd pwd_stu, a.pwd pwd_stu,
a.name name_stu, a.name name_stu,
a.surname surname_stu, a.surname surname_stu,
a.id_scene id_scene_stu,
a.url_img url_img_stu, a.url_img url_img_stu,
a.gender gender_stu, a.gender gender_stu,
a.lang lang_stu, a.lang lang_stu,
...@@ -280,7 +282,7 @@ INSTEAD OF INSERT ON users_detail ...@@ -280,7 +282,7 @@ INSTEAD OF INSERT ON users_detail
FOR EACH ROW FOR EACH ROW
WHEN NEW.pwd_stu IS NOT NULL WHEN NEW.pwd_stu IS NOT NULL
BEGIN BEGIN
INSERT OR REPLACE INTO student VALUES (NEW.id_stu, NEW.nickname_stu, NEW.pwd_stu, NEW.name_stu, NEW.surname_stu, NEW.url_img_stu, NEW.gender_stu, NEW.lang_stu, NEW.attributes_stu); INSERT OR REPLACE INTO student VALUES (NEW.id_stu, NEW.nickname_stu, NEW.pwd_stu, NEW.name_stu, NEW.surname_stu, NEW.id_scene_stu, NEW.url_img_stu, NEW.gender_stu, NEW.lang_stu, NEW.attributes_stu);
INSERT OR REPLACE INTO supervisor VALUES (NEW.id_sup, NEW.email_sup, NEW.pwd_sup, NEW.name_sup, NEW.surname_sup, NEW.url_img_sup, NEW.gender_sup, NEW.lang_sup, NEW.tts_engine_sup, NEW.office_sup); INSERT OR REPLACE INTO supervisor VALUES (NEW.id_sup, NEW.email_sup, NEW.pwd_sup, NEW.name_sup, NEW.surname_sup, NEW.url_img_sup, NEW.gender_sup, NEW.lang_sup, NEW.tts_engine_sup, NEW.office_sup);
INSERT OR REPLACE INTO users VALUES (NEW.id_stu,NEW.id_sup); INSERT OR REPLACE INTO users VALUES (NEW.id_stu,NEW.id_sup);
END END
...@@ -295,8 +297,8 @@ INSTEAD OF INSERT ON users_detail ...@@ -295,8 +297,8 @@ INSTEAD OF INSERT ON users_detail
FOR EACH ROW FOR EACH ROW
WHEN NEW.pwd_stu IS NULL WHEN NEW.pwd_stu IS NULL
BEGIN BEGIN
INSERT OR REPLACE INTO student(id,nickname, pwd, name, surname, url_img, gender, lang, attributes) INSERT OR REPLACE INTO student(id,nickname, pwd, name, surname, id_scene, url_img, gender, lang, attributes)
VALUES (NEW.id_stu, NEW.nickname_stu, (SELECT pwd FROM student WHERE id=NEW.id_stu), NEW.name_stu, NEW.surname_stu, NEW.url_img_stu, NEW.gender_stu, NEW.lang_stu, NEW.attributes_stu); VALUES (NEW.id_stu, NEW.nickname_stu, (SELECT pwd FROM student WHERE id=NEW.id_stu), NEW.name_stu, NEW.surname_stu,NEW.id_scene_stu, NEW.url_img_stu, NEW.gender_stu, NEW.lang_stu, NEW.attributes_stu);
INSERT OR REPLACE INTO supervisor VALUES (NEW.id_sup, NEW.email_sup, NEW.pwd_sup, NEW.name_sup, NEW.surname_sup, NEW.url_img_sup, NEW.gender_sup, NEW.lang_sup, NEW.tts_engine_sup, NEW.office_sup); INSERT OR REPLACE INTO supervisor VALUES (NEW.id_sup, NEW.email_sup, NEW.pwd_sup, NEW.name_sup, NEW.surname_sup, NEW.url_img_sup, NEW.gender_sup, NEW.lang_sup, NEW.tts_engine_sup, NEW.office_sup);
INSERT OR REPLACE INTO users VALUES (NEW.id_stu,NEW.id_sup); INSERT OR REPLACE INTO users VALUES (NEW.id_stu,NEW.id_sup);
END END
......
...@@ -43,8 +43,9 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -43,8 +43,9 @@ public class StudentFragmentGrid extends Fragment{
final String TAG_ID = "id"; final String TAG_ID = "id";
final String TAG_USERNAME = "username"; final String TAG_USERNAME = "username";
final String TAG_NAME = "name"; final String TAG_NAME = "name";
final String TAG_SURNAME = "surname"; final String TAG_SURNAME = "surname";
final String TAG_ID_SCENE = "id_active_scene";
final String TAG_GENDER = "gender"; final String TAG_GENDER = "gender";
final String TAG_PIC = "pic"; final String TAG_PIC = "pic";
final String TAG_LANG = "lang"; final String TAG_LANG = "lang";
...@@ -100,6 +101,7 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -100,6 +101,7 @@ public class StudentFragmentGrid extends Fragment{
null, null,
st.getString(TAG_NAME), st.getString(TAG_NAME),
st.getString(TAG_SURNAME), st.getString(TAG_SURNAME),
105/*st.getInt(TAG_ID_SCENE)*/,
st.getString(TAG_PIC), st.getString(TAG_PIC),
st.getString(TAG_GENDER), st.getString(TAG_GENDER),
st.getString(TAG_LANG), st.getString(TAG_LANG),
...@@ -239,9 +241,10 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -239,9 +241,10 @@ public class StudentFragmentGrid extends Fragment{
supervisor = supervisors.getJSONObject(i); supervisor = supervisors.getJSONObject(i);
idSupervisoresJSON.add(supervisor.getString("email")); idSupervisoresJSON.add(supervisor.getString("email"));
if(!PCBcontext.getDevice().isSupervisorOnLocal((int) supervisor.get("id"))) {//Para comprobar si ya existe en local if(!PCBcontext.getDevice().isSupervisorOnLocal((int) supervisor.get("id"))) {//Para comprobar si ya existe en local
PCBcontext.getDevice().insertUser(new User(stu_id, PCBcontext.getPcbdb().getCurrentUser().get_nickname_stu(), PCBcontext.getPcbdb().getCurrentUser().get_pwd_stu() User currentUser = PCBcontext.getPcbdb().getCurrentUser();
, PCBcontext.getPcbdb().getCurrentUser().get_name_stu(), PCBcontext.getPcbdb().getCurrentUser().get_surname_stu(), PCBcontext.getPcbdb().getCurrentUser().get_url_img_stu() PCBcontext.getDevice().insertUser(new User(stu_id, currentUser.get_nickname_stu(), currentUser.get_pwd_stu()
, PCBcontext.getPcbdb().getCurrentUser().get_gender_stu(), PCBcontext.getPcbdb().getCurrentUser().get_lang_stu(), PCBcontext.getPcbdb().getCurrentUser().get_json_attrs(), , currentUser.get_name_stu(),currentUser.get_surname_stu(),currentUser.get_active_scene(), currentUser.get_url_img_stu()
, currentUser.get_gender_stu(), currentUser.get_lang_stu(), currentUser.get_json_attrs(),
(int) supervisor.get("id"), supervisor.get("email").toString(), "_", supervisor.get("name").toString(), supervisor.get("surname").toString(), supervisor.get("pic").toString(), (int) supervisor.get("id"), supervisor.get("email").toString(), "_", supervisor.get("name").toString(), supervisor.get("surname").toString(), supervisor.get("pic").toString(),
supervisor.get("gender").toString(), supervisor.get("lang").toString(), supervisor.get("ttsEngine").toString(), supervisor.get("office").toString())); supervisor.get("gender").toString(), supervisor.get("lang").toString(), supervisor.get("ttsEngine").toString(), supervisor.get("office").toString()));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment