Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d9c3fac8
authored
May 18, 2017
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
#issue
#237
closed
parent
1604f61d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
8 deletions
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/PCBDBHelper.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/User.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/PCBDBHelper.java
View file @
d9c3fac8
...
@@ -55,7 +55,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
...
@@ -55,7 +55,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
* @see PCBDBHelper#getCurrentUser()
* @see PCBDBHelper#getCurrentUser()
*/
*/
public
void
setCurrentUser
(
User
user
)
{
public
void
setCurrentUser
(
User
user
)
{
Log
.
i
(
LOG_TAG
,
"user "
+
user
.
get_name_stu
()+
" "
+
user
.
get_json_attrs
());
Log
.
i
(
LOG_TAG
,
"user "
+
user
.
get_name_stu
()+
" "
+
" Scene:"
+
user
.
get_active_scene
()+
" attributes:"
+
user
.
get_json_attrs
());
this
.
currentUser
=
user
;
this
.
currentUser
=
user
;
PCBcontext
.
getDevice
().
setLastStuId
(
user
.
get_id_stu
());
PCBcontext
.
getDevice
().
setLastStuId
(
user
.
get_id_stu
());
if
(
user
.
is_supervisor
())
PCBcontext
.
getDevice
().
setLastSupId
(
user
.
get_id_sup
());
if
(
user
.
is_supervisor
())
PCBcontext
.
getDevice
().
setLastSupId
(
user
.
get_id_sup
());
...
@@ -168,7 +168,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
...
@@ -168,7 +168,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
+
"','"
+
params
.
getBoolean
(
"active"
)
+
"','"
+
params
.
getBoolean
(
"active"
)
+
"','"
+
params
.
getBoolean
(
"categories"
)
+
"','"
+
params
.
getBoolean
(
"categories"
)
+
"')"
;
+
"')"
;
Log
.
i
(
LOG_TAG
,
"Scene to be inserted: "
+
sql_scene
);
Log
.
i
(
LOG_TAG
,
"Scene to be inserted: "
+
sql_scene
+
" scenes:"
+
params
.
getBoolean
(
"categories"
)
);
getWritableDatabase
().
execSQL
(
sql_scene
);
getWritableDatabase
().
execSQL
(
sql_scene
);
//Added
//Added
...
@@ -187,14 +187,37 @@ public class PCBDBHelper extends SQLiteOpenHelper {
...
@@ -187,14 +187,37 @@ public class PCBDBHelper extends SQLiteOpenHelper {
public
int
getActiveSceneForStudent
(
int
id_stu
){
public
int
getActiveSceneForStudent
(
int
id_stu
){
SQLiteDatabase
db
=
this
.
getReadableDatabase
();
SQLiteDatabase
db
=
this
.
getReadableDatabase
();
Cursor
cursor
=
db
.
rawQuery
(
"SELECT id FROM scene WHERE id_stu = "
+
id_stu
,
null
);
Cursor
cursor
=
db
.
rawQuery
(
"SELECT id FROM scene WHERE id_stu = "
+
id_stu
,
null
);
cursor
.
moveToFirst
();
cursor
.
moveToFirst
();
int
id
;
if
(
cursor
.
getCount
()
>
0
){
if
(
cursor
.
getCount
()
>
0
){
id
=
cursor
.
getInt
(
0
);
Log
.
e
(
LOG_TAG
,
" Active scene id:"
+
id
);
return
cursor
.
getInt
(
0
);
return
cursor
.
getInt
(
0
);
}
}
return
-
1
;
return
-
1
;
}
}
/**
/**
* Return if a given scene has categories
* @param id_scene
* @return
*/
private
boolean
getHasCategories
(
int
id_scene
){
SQLiteDatabase
db
=
this
.
getReadableDatabase
();
Cursor
cursor
=
db
.
query
(
"scene"
,
new
String
[]{
"categories"
},
"id=?"
,
new
String
[]{
String
.
valueOf
(
id_scene
)},
null
,
null
,
null
,
null
);
boolean
has_categories
;
cursor
.
moveToFirst
();
int
id
;
if
(
cursor
.
getCount
()
>
0
){
has_categories
=
cursor
.
getString
(
0
).
equals
(
"true"
);
}
else
has_categories
=
false
;
return
has_categories
;
}
/**
* the collection (set of pictos) of the current student
* the collection (set of pictos) of the current student
*
*
* @see com.yottacode.pictogram.dao.Picto
* @see com.yottacode.pictogram.dao.Picto
...
@@ -205,8 +228,8 @@ public class PCBDBHelper extends SQLiteOpenHelper {
...
@@ -205,8 +228,8 @@ public class PCBDBHelper extends SQLiteOpenHelper {
SQLiteDatabase
db
=
this
.
getReadableDatabase
();
SQLiteDatabase
db
=
this
.
getReadableDatabase
();
Cursor
cursor
=
db
.
rawQuery
(
"SELECT
*
FROM collection_detail WHERE id_stu = "
+
id_stu
+
" AND id_scene = "
+
id_scene
,
null
);
Cursor
cursor
=
db
.
rawQuery
(
"SELECT
id_stu, id_picto, id_scene, id_stupicto, url, translation, attributes
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
Scene:"
+
id_scene
);
cursor
.
moveToFirst
();
cursor
.
moveToFirst
();
if
(
cursor
.
getCount
()>
0
)
do
{
if
(
cursor
.
getCount
()>
0
)
do
{
Picto
picto
=
new
Picto
(
cursor
.
getInt
(
1
),
cursor
.
getString
(
4
),
cursor
.
getInt
(
3
),
new
JSONObject
(
cursor
.
getString
(
6
)));
Picto
picto
=
new
Picto
(
cursor
.
getInt
(
1
),
cursor
.
getString
(
4
),
cursor
.
getInt
(
3
),
new
JSONObject
(
cursor
.
getString
(
6
)));
...
@@ -214,7 +237,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
...
@@ -214,7 +237,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
}
while
(
cursor
.
moveToNext
());
}
while
(
cursor
.
moveToNext
());
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
vocabulary
.
setHas_categories
(
getHasCategories
(
id_scene
));
return
vocabulary
;
return
vocabulary
;
}
}
...
@@ -233,7 +256,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
...
@@ -233,7 +256,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
values
.
put
(
"id_stu"
,
id_stu
);
values
.
put
(
"id_stu"
,
id_stu
);
db
.
beginTransaction
();
db
.
beginTransaction
();
for
(
Picto
picto
:
vocabulary
)
{
for
(
Picto
picto
:
vocabulary
)
{
Log
.
i
(
LOG_TAG
,
"inserting "
+
picto
.
get_id
()+
":"
+
picto
.
get_translation
()+
":"
+
picto
.
get_json_attrs
()+
"-id_sce: "
+
getActiveSceneForStudent
(
id_stu
));
Log
.
i
(
LOG_TAG
,
"inserting "
+
picto
.
get_id
()+
":"
+
picto
.
get_translation
()+
":"
+
picto
.
get_json_attrs
()+
"-id_sce: "
+
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_active_scene
(
));
values
.
put
(
"id_picto"
,
picto
.
get_id
());
values
.
put
(
"id_picto"
,
picto
.
get_id
());
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/User.java
View file @
d9c3fac8
...
@@ -3,7 +3,6 @@ package com.yottacode.pictogram.dao;
...
@@ -3,7 +3,6 @@ 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
;
...
@@ -31,7 +30,6 @@ public class User {
...
@@ -31,7 +30,6 @@ public class User {
public
final
static
class
JSON_STUDENT_ATTTRS
{
public
final
static
class
JSON_STUDENT_ATTTRS
{
public
enum
delivery
{
clean
,
one
,
many
}
public
enum
delivery
{
clean
,
one
,
many
}
static
String
ID_ACTIVE_SCENE
=
"id_active_scene"
;
static
String
INPUT_FEEDBACK
=
"input_feedback"
;
static
String
INPUT_FEEDBACK
=
"input_feedback"
;
static
String
INPUT_SELECTION
=
"input_selection"
;
static
String
INPUT_SELECTION
=
"input_selection"
;
static
String
PICTOGRAM_SIZE
=
"size"
;
static
String
PICTOGRAM_SIZE
=
"size"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment