Added upgrade of db to erase the obsoleted fields on tables Courses y
Groups. Exists a problem with the queries
This commit is contained in:
parent
1f7a176419
commit
5631e62e27
|
@ -26,7 +26,9 @@
|
|||
<string name="about_preferences">Qui som?</string>
|
||||
<string name="versionTitle_preferences">Versió de l\'aplicació</string>
|
||||
<string name="author_preferences">Coordinat per l\'Antonio Cañas Vargas
|
||||
\nImplementat per l\'Juan Miguel Boyero Corral</string>
|
||||
\nImplementat per Juan Miguel Boyero Corral
|
||||
\nHelena Rodríguez Gijón
|
||||
\nAntonio Aguilera Malagónl</string>
|
||||
<string name="organization_preferences">Universidad de Granada</string>
|
||||
<string name="loginTitle_menu">Connectar</string>
|
||||
<string name="loginProgressTitle">Identificació</string>
|
||||
|
|
|
@ -29,8 +29,11 @@
|
|||
<string name="cleanDatabaseTitle_menu">saubere Datenbank</string>
|
||||
<string name="about_preferences">über</string>
|
||||
<string name="versionTitle_preferences">Anwendungs-Version</string>
|
||||
<string name="author_preferences">koordiniert von Antonio Cañas Vargas
|
||||
\nprogrammiert von Juan Miguel Boyero Corral</string>
|
||||
<string name="author_preferences">koordiniert bei Antonio Cañas Vargas
|
||||
\nprogrammiert bei
|
||||
Juan Miguel Boyero Corral
|
||||
\nHelena Rodríguez Gijón
|
||||
\nAntonio Aguilera Malagónl</string>
|
||||
<string name="organization_preferences">Universität Granada</string>
|
||||
<string name="loginTitle_menu">anmelden</string>
|
||||
<string name="loginProgressTitle">anmelden</string>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<string name="versionTitle_preferences">Versión de la aplicación</string>
|
||||
<string name="author_preferences">Coordinador: Antonio Cañas Vargas
|
||||
\nProgramadores:
|
||||
\nJuan Miguel Boyero Corral
|
||||
Juan Miguel Boyero Corral
|
||||
\nHelena Rodríguez Gijón
|
||||
\nAntonio Aguilera Malagón</string>
|
||||
<string name="organization_preferences">Universidad de Granada</string>
|
||||
|
@ -155,7 +155,6 @@
|
|||
<string name="msg_default_type">Tipo</string>
|
||||
<string name="msg_default_time">Tiempo</string>
|
||||
<string name="msg_default_meta">Metadata</string>
|
||||
<string name="button_google_shopper">Google Shopper</string>
|
||||
<string name="msg_default_status">Coloque un código de barras en el interior del rectángulo del visor para escanear.</string>
|
||||
<string name="msg_camera_framework_bug">Lo sentimos, la cámara de Android ha encontrado un problema. Es posible que necesite reiniciar el dispositivo.</string>
|
||||
<string name="button_ok">OK</string>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<string name="versionTitle_preferences">Application version</string>
|
||||
<string name="author_preferences">Coordinator: Antonio Cañas Vargas
|
||||
\nProgrammers:
|
||||
\nJuan Miguel Boyero Corral
|
||||
Juan Miguel Boyero Corral
|
||||
\nHelena Rodríguez Gijón
|
||||
\nAntonio Aguilera Malagón</string>
|
||||
<string name="organization_preferences">University of Granada</string>
|
||||
|
@ -160,7 +160,6 @@
|
|||
<string name="msg_default_type">Type</string>
|
||||
<string name="msg_default_time">Time</string>
|
||||
<string name="msg_default_meta">Metadata</string>
|
||||
<string name="button_google_shopper">Google Shopper</string>
|
||||
<string name="msg_default_status">Place a barcode inside the viewfinder rectangle to scan it.</string>
|
||||
<string name="msg_camera_framework_bug">Sorry, the Android camera encountered a problem. You may need to restart the device.</string>
|
||||
<string name="button_ok">OK</string>
|
||||
|
|
|
@ -301,7 +301,7 @@
|
|||
obligatory="true"
|
||||
type="integer" />
|
||||
<field
|
||||
name="membership"
|
||||
name="member"
|
||||
new-in-version="13"
|
||||
obligatory="true"
|
||||
type="integer"/>
|
||||
|
|
|
@ -24,6 +24,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.android.dataframework.DataFramework;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -329,9 +331,10 @@ public class SWADMain extends MenuExpandableListActivity {
|
|||
SecureConnection.initSecureConnection();
|
||||
|
||||
//Check if this is the first run after an install or upgrade
|
||||
lastVersion = prefs.getLastVersion();
|
||||
currentVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
|
||||
|
||||
// lastVersion = prefs.getLastVersion();
|
||||
// currentVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
|
||||
lastVersion = 41;
|
||||
currentVersion = 42;
|
||||
// Get rollcall course
|
||||
Global.setSelectedRollcallCourseCode(prefs.getRollcallCourseSelected());
|
||||
|
||||
|
@ -355,7 +358,7 @@ public class SWADMain extends MenuExpandableListActivity {
|
|||
//If this is an upgrade, show upgrade dialog
|
||||
} else if(lastVersion < currentVersion) {
|
||||
//showUpgradeDialog();
|
||||
dbHelper.upgradeDB(this);
|
||||
dbHelper.upgradeDB(this);
|
||||
//prefs.upgradeCredentials();
|
||||
|
||||
//Configure automatic synchronization
|
||||
|
@ -364,7 +367,10 @@ public class SWADMain extends MenuExpandableListActivity {
|
|||
|
||||
prefs.setLastVersion(currentVersion);
|
||||
}
|
||||
listCourses = dbHelper.getAllRows(Global.DB_TABLE_COURSES,"","name");
|
||||
Cursor dbCursor = db.getDB().query(Global.DB_TABLE_COURSES, null, null, null, null, null, null);
|
||||
String [] columnNames = dbCursor.getColumnNames();
|
||||
|
||||
listCourses = dbHelper.getAllRows(Global.DB_TABLE_COURSES,"","shortName");
|
||||
if(listCourses.size() >0){
|
||||
Course c =(Course) listCourses.get(prefs.getLastCourseSelected());
|
||||
Global.setSelectedCourseCode(c.getId());
|
||||
|
@ -416,15 +422,26 @@ public class SWADMain extends MenuExpandableListActivity {
|
|||
|
||||
private void createSpinnerAdapter(){
|
||||
Spinner spinner = (Spinner) this.findViewById(R.id.spinner);
|
||||
listCourses = dbHelper.getAllRows(Global.DB_TABLE_COURSES, null, "name");
|
||||
dbCursor = dbHelper.getDb().getCursor(Global.DB_TABLE_COURSES, null, "name");
|
||||
listCourses = dbHelper.getAllRows(Global.DB_TABLE_COURSES, null, "shortName");
|
||||
Cursor dbCursorColum = db.getDB().query(Global.DB_TABLE_GROUPS, null, null, null, null, null, null);
|
||||
String [] columnNames = dbCursor.getColumnNames();
|
||||
dbCursor = dbHelper.getDb().getCursor(Global.DB_TABLE_COURSES, null, "shortName");
|
||||
startManagingCursor(dbCursor);
|
||||
if(listCourses.size() != 0){
|
||||
SimpleCursorAdapter adapter = new SimpleCursorAdapter (this,
|
||||
android.R.layout.simple_spinner_item,
|
||||
dbCursor,
|
||||
new String[]{"name"},
|
||||
new String[]{"shortName"},
|
||||
new int[]{android.R.id.text1});
|
||||
/* listCourses = dbHelper.getAllRows(Global.DB_TABLE_COURSES, null, "name");
|
||||
dbCursor = dbHelper.getDb().getCursor(Global.DB_TABLE_COURSES, null, "name");
|
||||
startManagingCursor(dbCursor);
|
||||
if(listCourses.size() != 0){
|
||||
SimpleCursorAdapter adapter = new SimpleCursorAdapter (this,
|
||||
android.R.layout.simple_spinner_item,
|
||||
dbCursor,
|
||||
new String[]{"name"},
|
||||
new int[]{android.R.id.text1}); */
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
spinner.setAdapter(adapter);
|
||||
spinner.setOnItemSelectedListener(new onItemSelectedListener());
|
||||
|
|
|
@ -31,12 +31,10 @@ public class Course extends Model {
|
|||
/**
|
||||
* Course name
|
||||
*/
|
||||
private String name;
|
||||
private int userRole;
|
||||
private String shortName;
|
||||
private String fullName;
|
||||
private static PropertyInfo PI_id = new PropertyInfo();
|
||||
private static PropertyInfo PI_name = new PropertyInfo();
|
||||
private static PropertyInfo PI_userRole = new PropertyInfo();
|
||||
private static PropertyInfo PI_shortName = new PropertyInfo();
|
||||
private static PropertyInfo PI_fullName = new PropertyInfo();
|
||||
|
@ -44,7 +42,6 @@ public class Course extends Model {
|
|||
private static PropertyInfo[] PI_PROP_ARRAY =
|
||||
{
|
||||
PI_id,
|
||||
PI_name,
|
||||
PI_userRole,
|
||||
PI_shortName,
|
||||
PI_fullName
|
||||
|
@ -55,29 +52,13 @@ public class Course extends Model {
|
|||
* @param id Course identifier
|
||||
* @param name Course name
|
||||
*/
|
||||
public Course(long id, String name, int userRole, String shortName, String fullName) {
|
||||
public Course(long id, int userRole, String shortName, String fullName) {
|
||||
super(id);
|
||||
this.name = name;
|
||||
this.userRole = userRole;
|
||||
this.shortName = shortName;
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets course name
|
||||
* @return Course name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets course name
|
||||
* @param name Course name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets user role inside the course
|
||||
|
@ -127,7 +108,6 @@ public class Course extends Model {
|
|||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + userRole;
|
||||
result = prime * result + ((shortName == null) ? 0 : shortName.hashCode());
|
||||
result = prime * result + ((fullName == null) ? 0 : fullName.hashCode());
|
||||
|
@ -139,7 +119,7 @@ public class Course extends Model {
|
|||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Course [name=" + name + ", getId()=" + getId() + " getUserRole()="+ getUserRole()+ "getShortName="+ shortName + "getFullName="+ fullName +"]";
|
||||
return "Course [getId()=" + getId() + " getUserRole()="+ getUserRole()+ "getShortName="+ shortName + "getFullName="+ fullName +"]";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -150,10 +130,9 @@ public class Course extends Model {
|
|||
switch(param)
|
||||
{
|
||||
case 0 : object = this.getId();break;
|
||||
case 1 : object = name;break;
|
||||
case 2 : object = userRole;break;
|
||||
case 3 : object = shortName;break;
|
||||
case 4 : object = fullName;break;
|
||||
case 1 : object = userRole;break;
|
||||
case 2 : object = shortName;break;
|
||||
case 3 : object = fullName;break;
|
||||
}
|
||||
|
||||
return object;
|
||||
|
@ -163,7 +142,7 @@ public class Course extends Model {
|
|||
* @see org.ksoap2.serialization.KvmSerializable#getPropertyCount()
|
||||
*/
|
||||
public int getPropertyCount() {
|
||||
return 5;
|
||||
return PI_PROP_ARRAY.length;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -176,18 +155,14 @@ public class Course extends Model {
|
|||
propertyInfo.name = "id";
|
||||
break;
|
||||
case 1:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "name";
|
||||
break;
|
||||
case 2:
|
||||
propertyInfo.type = PropertyInfo.INTEGER_CLASS;
|
||||
propertyInfo.name = "userRole";
|
||||
break;
|
||||
case 3:
|
||||
case 2:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "shortName";
|
||||
break;
|
||||
case 4:
|
||||
case 3:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "fullName";
|
||||
break;
|
||||
|
@ -202,10 +177,9 @@ public class Course extends Model {
|
|||
switch(param)
|
||||
{
|
||||
case 0 : this.setId((Long)obj); break;
|
||||
case 1 : name = (String)obj; break;
|
||||
case 2 : userRole = (Integer)obj; break;
|
||||
case 3 : shortName = (String)obj; break;
|
||||
case 4 : fullName = (String)obj; break;
|
||||
case 1 : userRole = (Integer)obj; break;
|
||||
case 2 : shortName = (String)obj; break;
|
||||
case 3 : fullName = (String)obj; break;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +188,6 @@ public class Course extends Model {
|
|||
public boolean equals(Object obj) {
|
||||
if (!super.equals(obj)) return false;
|
||||
Course other = (Course) obj;
|
||||
if(name.compareTo(other.getName()) != 0) return false;
|
||||
if(userRole != other.getUserRole()) return false;
|
||||
if(shortName.compareTo(other.getShortName()) != 0) return false;
|
||||
if(fullName.compareTo(other.getFullName()) != 0) return false;
|
||||
|
|
|
@ -142,7 +142,6 @@ public class DataBaseHelper {
|
|||
|
||||
if(table.equals(Global.DB_TABLE_COURSES)) {
|
||||
o = new Course(ent.getInt("id"),
|
||||
ent.getString("name"),
|
||||
ent.getInt("userRole"),
|
||||
ent.getString("shortName"),
|
||||
ent.getString("fullName"));
|
||||
|
@ -238,7 +237,7 @@ public class DataBaseHelper {
|
|||
ent.getInt("students"),
|
||||
ent.getInt("open"),
|
||||
ent.getInt("fileZones"),
|
||||
ent.getInt("membership"));
|
||||
ent.getInt("member"));
|
||||
}else if (table.equals(Global.DB_TABLE_GROUP_TYPES)){
|
||||
o = new GroupType(ent.getLong("id"),
|
||||
ent.getString("groupTypeName"),
|
||||
|
@ -527,7 +526,7 @@ public class DataBaseHelper {
|
|||
Iterator<Long> iter = groupCodes.iterator();
|
||||
while(iter.hasNext()){
|
||||
Group g = (Group) getRow(Global.DB_TABLE_GROUPS,"id",String.valueOf(iter.next()));
|
||||
if(g.isMembership()) groups.add(g);
|
||||
if(g.isMember()) groups.add(g);
|
||||
}
|
||||
}
|
||||
return groups;
|
||||
|
@ -633,7 +632,6 @@ public class DataBaseHelper {
|
|||
{
|
||||
Entity ent = new Entity(Global.DB_TABLE_COURSES);
|
||||
ent.setValue("id", c.getId());
|
||||
ent.setValue("name", c.getName());
|
||||
ent.setValue("userRole", c.getUserRole());
|
||||
ent.setValue("shortName", c.getShortName());
|
||||
ent.setValue("fullName", c.getFullName());
|
||||
|
@ -789,7 +787,7 @@ public class DataBaseHelper {
|
|||
ent.setValue("students", g.getCurrentStudents());
|
||||
ent.setValue("open", g.isOpen());
|
||||
ent.setValue("fileZones", g.exitsDocumentsArea());
|
||||
ent.setValue("membership", g.isMembership());
|
||||
ent.setValue("member", g.isMember());
|
||||
ent.save();
|
||||
}
|
||||
|
||||
|
@ -886,10 +884,12 @@ public class DataBaseHelper {
|
|||
}else returnValue = false;
|
||||
|
||||
long groupTypeCode = g.getGroupTypeCode();
|
||||
GroupType groupType = (GroupType) getRow(Global.DB_TABLE_GROUP_TYPES,"groupTypeCode",String.valueOf(groupTypeCode));
|
||||
|
||||
//WHILE THE WEB SERVICE TO GET GROUP TYPES STILL UNAVAILABLE, this condition is not evaluated
|
||||
//GroupType groupType = (GroupType) getRow(Global.DB_TABLE_GROUP_TYPES,"id",String.valueOf(groupTypeCode));
|
||||
//group type code is a foreign key. Therefore, to avoid a database error,
|
||||
//it should not insert/modify rows in the relationship table if the group type does not exists
|
||||
if(groupType != null){
|
||||
//if(groupType != null){
|
||||
rows = db.getEntityList(Global.DB_TABLE_GROUPS_GROUPTYPES,"grpCod="+groupCode);
|
||||
if(!rows.isEmpty()){
|
||||
Pair<String,String> params = selectParamsPairTable(Global.DB_TABLE_GROUP_TYPES);
|
||||
|
@ -905,7 +905,7 @@ public class DataBaseHelper {
|
|||
//rows.get(0).setValue("grpTypCod", groupTypeCode[0]);
|
||||
//rows.get(0).save();
|
||||
}
|
||||
}else returnValue = false;
|
||||
/*}else returnValue = false;*/
|
||||
|
||||
return returnValue;
|
||||
} else
|
||||
|
@ -1021,7 +1021,6 @@ public class DataBaseHelper {
|
|||
List<Entity> rows = db.getEntityList(Global.DB_TABLE_COURSES, "id = " + prev.getId());
|
||||
Entity ent = rows.get(0);
|
||||
ent.setValue("id", actual.getId());
|
||||
ent.setValue("name", actual.getName());
|
||||
ent.setValue("userRole", actual.getUserRole());
|
||||
ent.setValue("shortName", actual.getShortName());
|
||||
ent.setValue("fullName", actual.getFullName());
|
||||
|
@ -1039,7 +1038,6 @@ public class DataBaseHelper {
|
|||
if(!rows.isEmpty()){
|
||||
Entity ent = rows.get(0);
|
||||
ent.setValue("id", actual.getId());
|
||||
ent.setValue("name", actual.getName());
|
||||
ent.setValue("userRole", actual.getUserRole());
|
||||
ent.setValue("shortName", actual.getShortName());
|
||||
ent.setValue("fullName", actual.getFullName());
|
||||
|
@ -1228,7 +1226,7 @@ public class DataBaseHelper {
|
|||
ent.setValue("students", currentGroup.getCurrentStudents());
|
||||
ent.setValue("open", currentGroup.isOpen());
|
||||
ent.setValue("fileZones", currentGroup.exitsDocumentsArea());
|
||||
ent.setValue("membership", currentGroup.isMembership());
|
||||
ent.setValue("member", currentGroup.isMember());
|
||||
ent.save();
|
||||
|
||||
rows = db.getEntityList(Global.DB_TABLE_GROUPS_COURSES,"grpCod =" + groupCode);
|
||||
|
@ -1674,8 +1672,99 @@ public class DataBaseHelper {
|
|||
//cleanTables();
|
||||
//initializeDB();
|
||||
compactDB();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Modify database keeping data:
|
||||
* 1. Create temporary table __DB_TABLE_GROUPS (with the new model)
|
||||
* 2. insert in the temporary table all the data (in the new model) from the old table
|
||||
* 3. drop table DB_TABLE_GROUPS
|
||||
* 4. create DB_TABLE_GROUPS with the new model.
|
||||
* 5. insert in DB_TABLE_GROUPS all the data from __DB_TABLE_GROUPS
|
||||
* 6. insert in DB_TABLE_GROUPS_GROUPTYPES the relationships between the deleted groups and group types
|
||||
* 7. drop __DB_TABLE_GROUPS
|
||||
* Just to modify database without to keep data just 7,6.
|
||||
*
|
||||
* */
|
||||
/*TODO Àesto se deber’a ejecutar s—lo cuando se pase una version < 12 a una mayor de 13? en el resto de los casos no
|
||||
Àcon la version de swadroid?*/
|
||||
|
||||
/* From version 11 to 12
|
||||
* changes on courses table:
|
||||
* - old field name is erased
|
||||
* The rest of the changes are only new fields and they are added automatic by Dataframework. */
|
||||
Cursor dbCursor = db.getDB().query(Global.DB_TABLE_COURSES, null, null, null, null, null, null);
|
||||
String[] columnNames = dbCursor.getColumnNames();
|
||||
boolean found = false;
|
||||
int i = 0;
|
||||
while(i < columnNames.length && !found){
|
||||
if(columnNames[i].compareTo("name") == 0) found = true;
|
||||
++i;
|
||||
}
|
||||
if(found){
|
||||
//without to keep data
|
||||
db.getDB().execSQL( "DROP TABLE " + Global.DB_TABLE_COURSES + ";");//+
|
||||
db.getDB().execSQL("CREATE TABLE "+ Global.DB_TABLE_COURSES
|
||||
+ " (_id integer primary key autoincrement, id long, userRole integer,shortName text, fullName text);");
|
||||
//Keeping data (It will have columns without data):
|
||||
/*
|
||||
* db.getDB().execSQL("CREATE TEMPORARY TABLE __"+ Global.DB_TABLE_COURSES
|
||||
+ " (_id integer primary key autoincrement, id long, userRole integer,"
|
||||
+ " shortName text, fullName text); ");
|
||||
db.getDB().execSQL(
|
||||
"INSERT INTO __" + Global.DB_TABLE_COURSES + " SELECT _id, id, userRole, name, name "
|
||||
+ " FROM "+ Global.DB_TABLE_COURSES + ";");
|
||||
db.getDB().execSQL( "DROP TABLE " + Global.DB_TABLE_COURSES + ";");
|
||||
db.getDB().execSQL("CREATE TABLE "+ Global.DB_TABLE_COURSES
|
||||
+ " (_id integer primary key autoincrement, id long, userRole integer,"
|
||||
+ " shortName text, fullName text); ");
|
||||
db.getDB().execSQL(
|
||||
"INSERT INTO " + Global.DB_TABLE_COURSES + " SELECT _id, id, userRole, shortName, fullName "
|
||||
+ " FROM __"+ Global.DB_TABLE_COURSES + ";");*/
|
||||
|
||||
}
|
||||
|
||||
dbCursor = db.getDB().query(Global.DB_TABLE_COURSES, null, null, null, null, null, null);
|
||||
columnNames = dbCursor.getColumnNames();
|
||||
|
||||
/* version 12 - 13
|
||||
* changes on groups table:
|
||||
* - old field groupCode is now id
|
||||
* - old field groupTypeCode is erased
|
||||
* - old field groupTypeName is erased
|
||||
* The rest of the changes are only new fields and they are added automatic by Dataframework.
|
||||
* */
|
||||
dbCursor = db.getDB().query(Global.DB_TABLE_GROUPS, null, null, null, null, null, null);
|
||||
columnNames = dbCursor.getColumnNames();
|
||||
found = false;
|
||||
i = 0;
|
||||
while(i < columnNames.length && !found){
|
||||
if(columnNames[i].compareTo("groupCode") == 0) found = true;
|
||||
++i;
|
||||
}
|
||||
if(found){
|
||||
//without to keep data
|
||||
db.getDB().execSQL( "DROP TABLE " + Global.DB_TABLE_GROUPS + ";");
|
||||
db.getDB().execSQL("CREATE TABLE " + Global.DB_TABLE_GROUPS+ " (_id integer primary key autoincrement, id long, groupName text, maxStudents integer,"
|
||||
+ " students integer, open integer, fileZones integer, member integer); ");
|
||||
/*db.getDB().execSQL(
|
||||
"CREATE TEMPORARY TABLE __"+ Global.DB_TABLE_GROUPS
|
||||
+ " (_id integer primary key autoincrement, id long, groupName text, maxStudents integer,"
|
||||
+ " students integer, open integer, fileZones integer, member integer); ");
|
||||
db.getDB().execSQL(
|
||||
"INSERT INTO __" + Global.DB_TABLE_GROUPS + " SELECT _id, groupCode, groupName, maxStudents, "
|
||||
+ "students, open, fileZones, member FROM "+ Global.DB_TABLE_GROUPS + ";");
|
||||
db.getDB().execSQL( "DROP TABLE " + Global.DB_TABLE_GROUPS + ";");
|
||||
db.getDB().execSQL("CREATE TABLE " + Global.DB_TABLE_GROUPS+ " (_id integer primary key autoincrement, id long, groupName text, maxStudents integer,"
|
||||
+ " students integer, open integer, fileZones integer, member integer); ");
|
||||
db.getDB().execSQL("INSERT INTO " + Global.DB_TABLE_GROUPS + " SELECT _id, id, groupName, maxStudents, "
|
||||
+ "students, open, fileZones, member FROM __"+ Global.DB_TABLE_GROUPS + ";");
|
||||
db.getDB().execSQL( "DROP TABLE __" + Global.DB_TABLE_GROUPS + ";");*/
|
||||
|
||||
}
|
||||
dbCursor = db.getDB().query(Global.DB_TABLE_GROUPS, null, null, null, null, null, null);
|
||||
columnNames = dbCursor.getColumnNames();
|
||||
|
||||
/*db.getDB().execSQL("CREATE TEMPORARY TABLE __"
|
||||
+ Global.DB_TABLE_NOTIFICATIONS
|
||||
+ " (_id INTEGER PRIMARY KEY AUTOINanCREMENT, id INTEGER, eventType TEXT, eventTime TEXT,"
|
||||
|
|
|
@ -21,23 +21,23 @@ public class Group extends Model {
|
|||
/**
|
||||
* Maximum number of students allowed in this group
|
||||
*/
|
||||
private int maxStudents;
|
||||
private int maxStudents = -1;
|
||||
/**
|
||||
* Current number of students that belong to this group
|
||||
* */
|
||||
private int students;
|
||||
private int students = -1;
|
||||
/**
|
||||
* Indicates whether the enrollment to this group is allowed or not
|
||||
* */
|
||||
private int open;
|
||||
private int open = 0;
|
||||
/**
|
||||
* Indicates whether the group has an area of documents related to or not
|
||||
* */
|
||||
private int fileZones;
|
||||
private int fileZones = 0;
|
||||
/**
|
||||
* Indicates if the logged user is a membership of this group
|
||||
* Indicates if the logged user is a member of this group
|
||||
* */
|
||||
private int membership;
|
||||
private int member;
|
||||
|
||||
private static PropertyInfo PI_id = new PropertyInfo();
|
||||
private static PropertyInfo PI_groupName = new PropertyInfo();
|
||||
|
@ -45,7 +45,7 @@ public class Group extends Model {
|
|||
private static PropertyInfo PI_students = new PropertyInfo();
|
||||
private static PropertyInfo PI_open = new PropertyInfo();
|
||||
private static PropertyInfo PI_fileZones = new PropertyInfo();
|
||||
private static PropertyInfo PI_membership = new PropertyInfo();
|
||||
private static PropertyInfo PI_member = new PropertyInfo();
|
||||
private static PropertyInfo PI_groupTypeCode = new PropertyInfo();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -57,7 +57,7 @@ public class Group extends Model {
|
|||
PI_students,
|
||||
PI_open,
|
||||
PI_fileZones,
|
||||
PI_membership
|
||||
PI_member
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -68,9 +68,9 @@ public class Group extends Model {
|
|||
* @param students Current number of students that belong to this group
|
||||
* @param open Indicates whether the enrollment to this group is allowed or not
|
||||
* @param fileZones Indicates whether the group has an area of documents related to or not
|
||||
* @param membership Indicates if the logged user is a membership of this group
|
||||
* @param member Indicates if the logged user is a member of this group
|
||||
*/
|
||||
public Group(long id, String groupName,long groupTypeCode, int maxStudents, int open, int students, int fileZones, int membership) {
|
||||
public Group(long id, String groupName,long groupTypeCode, int maxStudents, int open, int students, int fileZones, int member) {
|
||||
super(id);
|
||||
this.groupName = groupName;
|
||||
this.maxStudents = maxStudents;
|
||||
|
@ -92,7 +92,7 @@ public class Group extends Model {
|
|||
case 4 : object = students;break;
|
||||
case 5 : object = open;break;
|
||||
case 6 : object = fileZones;break;
|
||||
case 7 : object = membership;break;
|
||||
case 7 : object = member;break;
|
||||
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class Group extends Model {
|
|||
break;
|
||||
case 7:
|
||||
propertyInfo.type = PropertyInfo.INTEGER_CLASS;
|
||||
propertyInfo.name = "membership";
|
||||
propertyInfo.name = "member";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ public class Group extends Model {
|
|||
case 5 : students = (Integer)obj; break;
|
||||
case 6 : open = (Integer)obj; break;
|
||||
case 7 : fileZones = (Integer)obj; break;
|
||||
case 8 : membership = (Integer)obj; break;
|
||||
case 8 : member = (Integer)obj; break;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ public class Group extends Model {
|
|||
@Override
|
||||
public String toString() {
|
||||
return "Group [name="+groupName+", getId()="+getId()+", getGroupTypeCode()=" + getGroupTypeCode()+", getMaxStudents()=" + getMaxStudents()+", getCurrentStudents()="
|
||||
+ getCurrentStudents()+", isOpen()=" + isOpen()+", exitsDocumentsArea()=" + exitsDocumentsArea() +", isMembership()= "+ isMembership();
|
||||
+ getCurrentStudents()+", isOpen()=" + isOpen()+", exitsDocumentsArea()=" + exitsDocumentsArea() +", isMember()= "+ isMember();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -230,12 +230,12 @@ public class Group extends Model {
|
|||
return fileZones == 1? true:false;
|
||||
}
|
||||
/**
|
||||
* Indicates if the logged user is a membership of this group
|
||||
* @return true if the logged user is a membership of this group
|
||||
* Indicates if the logged user is a member of this group
|
||||
* @return true if the logged user is a member of this group
|
||||
* false otherwise
|
||||
* */
|
||||
public boolean isMembership(){
|
||||
return membership == 1? true:false;
|
||||
public boolean isMember(){
|
||||
return member == 1? true:false;
|
||||
}
|
||||
//TODO relate Group to Group Type
|
||||
|
||||
|
@ -258,7 +258,7 @@ public class Group extends Model {
|
|||
result = prime * result + students;
|
||||
result = prime * result + open;
|
||||
result = prime * result + fileZones;
|
||||
result = prime * result + membership;
|
||||
result = prime * result + member;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ public class Group extends Model {
|
|||
return false;
|
||||
if (fileZones != other.fileZones)
|
||||
return false;
|
||||
if (membership != other.membership)
|
||||
if (member != other.member)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -129,11 +129,11 @@ public class Courses extends Module {
|
|||
for (int i = 0; i < csSize; i++) {
|
||||
SoapObject pii = (SoapObject)soap.getProperty(i);
|
||||
long id = Long.parseLong(pii.getProperty("courseCode").toString());
|
||||
String name = pii.getProperty("courseName").toString();
|
||||
//String name = pii.getProperty("courseName").toString(); this field is obsolete, and will be erased in the future
|
||||
int userRole = Integer.parseInt(pii.getProperty("userRole").toString());
|
||||
String shortName = pii.getProperty("courseShortName").toString();
|
||||
String fullName = pii.getProperty("courseFullName").toString();
|
||||
Course c = new Course(id, name, userRole,shortName, fullName);
|
||||
Course c = new Course(id, userRole,shortName, fullName);
|
||||
coursesSWAD.add(c);
|
||||
|
||||
/*if(isDebuggable)
|
||||
|
|
|
@ -116,8 +116,8 @@ public class Groups extends Module {
|
|||
int open = Integer.parseInt(pii.getProperty("open").toString());
|
||||
int numStudents = Integer.parseInt(pii.getProperty("numStudents").toString());
|
||||
int fileZones = Integer.parseInt(pii.getProperty("fileZones").toString());
|
||||
int membership = Integer.parseInt(pii.getProperty("membership").toString());
|
||||
Group g = new Group(id,groupName,groupTypeCode,maxStudents,open,numStudents,fileZones,membership);
|
||||
int member = Integer.parseInt(pii.getProperty("member").toString());
|
||||
Group g = new Group(id,groupName,groupTypeCode,maxStudents,open,numStudents,fileZones,member);
|
||||
|
||||
groupsSWAD.add(g);
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ import es.ugr.swad.swadroid.modules.Module;
|
|||
* Notifications module for get user's notifications
|
||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
* @author Antonio Aguilera Malagon <aguilerin@gmail.com>
|
||||
* @author Helena Rodríguez Gijon <hrgijon@gmail.com>
|
||||
* @author Helena Rodriguez Gijon <hrgijon@gmail.com>
|
||||
*/
|
||||
public class Notifications extends Module {
|
||||
/**
|
||||
|
|
|
@ -144,8 +144,8 @@ public class NewPracticeSession extends Module {
|
|||
|
||||
// Get selected course
|
||||
String where = "id =" + String.valueOf(Global.getSelectedCourseCode());
|
||||
Course selectedCourse = (Course) dbHelper.getAllRows(Global.DB_TABLE_COURSES, where, "name").get(0);
|
||||
String courseName = selectedCourse.getName();
|
||||
Course selectedCourse = (Course) dbHelper.getAllRows(Global.DB_TABLE_COURSES, where, "fullName").get(0);
|
||||
String courseName = selectedCourse.getFullName();
|
||||
|
||||
// Get selected groupCode, groupName
|
||||
Intent i = getIntent();
|
||||
|
|
|
@ -70,8 +70,8 @@ public class SessionsHistory extends Module {
|
|||
|
||||
// Get selected course
|
||||
String where = "id =" + String.valueOf(Global.getSelectedCourseCode());
|
||||
Course selectedCourse = (Course) dbHelper.getAllRows(Global.DB_TABLE_COURSES, where, "name").get(0);
|
||||
String courseName = selectedCourse.getName();
|
||||
Course selectedCourse = (Course) dbHelper.getAllRows(Global.DB_TABLE_COURSES, where, "fullName").get(0);
|
||||
String courseName = selectedCourse.getFullName();
|
||||
|
||||
// Get selected groupCode, groupName
|
||||
Intent intent = getIntent();
|
||||
|
|
|
@ -106,7 +106,7 @@ public class SessionsList extends Module {
|
|||
boolean existSessions = false;
|
||||
|
||||
// Get practice groups of selected course
|
||||
List<Long> groupIdList = dbHelper.getGroupsCourse(courseCode);
|
||||
List<Long> groupIdList = dbHelper.getGroupCodesCourse(courseCode);
|
||||
|
||||
ListView lv = new ListView(this);
|
||||
SeparatedListAdapter adapter = new SeparatedListAdapter(this);
|
||||
|
|
|
@ -69,8 +69,8 @@ public class StudentsHistory extends Module {
|
|||
|
||||
// Get selected course
|
||||
String where = "id =" + String.valueOf(Global.getSelectedCourseCode());
|
||||
Course selectedCourse = (Course) dbHelper.getAllRows(Global.DB_TABLE_COURSES, where, "name").get(0);
|
||||
String courseName = selectedCourse.getName();
|
||||
Course selectedCourse = (Course) dbHelper.getAllRows(Global.DB_TABLE_COURSES, where, "fullName").get(0);
|
||||
String courseName = selectedCourse.getFullName();
|
||||
|
||||
// Get selected groupName
|
||||
Intent intent = getIntent();
|
||||
|
|
Loading…
Reference in New Issue
Block a user