Added model classes and methods for messages and marks tables
This commit is contained in:
parent
342b6c6f91
commit
4a7ecfd91b
|
@ -56,6 +56,22 @@ public class Global {
|
|||
* Table name for test's configuration
|
||||
*/
|
||||
public static final String DB_TABLE_TEST_CONFIG = "tst_config";
|
||||
/**
|
||||
* Table name for test's configuration
|
||||
*/
|
||||
public static final String DB_TABLE_MSG_CONTENT = "msg_content";
|
||||
/**
|
||||
* Table name for test's configuration
|
||||
*/
|
||||
public static final String DB_TABLE_MSG_RCV = "msg_rcv";
|
||||
/**
|
||||
* Table name for test's configuration
|
||||
*/
|
||||
public static final String DB_TABLE_MSG_SNT = "msg_snt";
|
||||
/**
|
||||
* Table name for test's configuration
|
||||
*/
|
||||
public static final String DB_TABLE_MARKS = "marks";
|
||||
/**
|
||||
* Table name for relationship between notices and courses
|
||||
*/
|
||||
|
|
|
@ -232,6 +232,36 @@ public class DataBaseHelper extends SQLiteOpenHelper {
|
|||
(Integer) rows.getInt(3),
|
||||
(Boolean) parseStringBool(rows.getString(4)),
|
||||
(Float) rows.getFloat(5));
|
||||
} else if(table.equals(Global.DB_TABLE_MSG_CONTENT)) {
|
||||
o = new MessageContent((Integer) rows.getInt(0),
|
||||
(String) rows.getString(1),
|
||||
(String) rows.getString(2),
|
||||
(Boolean) parseStringBool(rows.getString(3)),
|
||||
(Integer) rows.getInt(4));
|
||||
} else if(table.equals(Global.DB_TABLE_MSG_RCV)) {
|
||||
o = new MessageReceived((Integer) rows.getInt(0),
|
||||
(String) rows.getString(1),
|
||||
(String) rows.getString(2),
|
||||
(Integer) rows.getInt(3),
|
||||
(Boolean) parseStringBool(rows.getString(4)),
|
||||
(Boolean) parseStringBool(rows.getString(5)),
|
||||
(Boolean) parseStringBool(rows.getString(6)),
|
||||
(Boolean) parseStringBool(rows.getString(7)));
|
||||
} else if(table.equals(Global.DB_TABLE_MSG_SNT)) {
|
||||
o = new MessageSent((Integer) rows.getInt(0),
|
||||
(String) rows.getString(1),
|
||||
(String) rows.getString(2),
|
||||
(Boolean) parseStringBool(rows.getString(3)),
|
||||
(Integer) rows.getInt(4),
|
||||
(Integer) rows.getInt(5),
|
||||
(String) rows.getString(6));
|
||||
} else if(table.equals(Global.DB_TABLE_MARKS)) {
|
||||
o = new Mark((Integer) rows.getInt(0),
|
||||
(Integer) rows.getInt(1),
|
||||
(Integer) rows.getInt(2),
|
||||
(String) rows.getString(3),
|
||||
(Integer) rows.getInt(4),
|
||||
(Integer) rows.getInt(5));
|
||||
} else if(table.equals(Global.DB_TABLE_NOTICES_COURSES) ||
|
||||
table.equals(Global.DB_TABLE_STUDENTS_COURSES) ||
|
||||
table.equals(Global.DB_TABLE_TEST_QUESTIONS_COURSES)) {
|
||||
|
@ -312,6 +342,41 @@ public class DataBaseHelper extends SQLiteOpenHelper {
|
|||
+ q.getScore() + ", "
|
||||
+ parseBoolString(q.getShuffle())
|
||||
+ ")";
|
||||
} else if(row instanceof MessageContent) {
|
||||
MessageContent m = (MessageContent) row;
|
||||
command += Global.DB_TABLE_MSG_CONTENT + " (msgcod, subject, content) VALUES ("
|
||||
+ m.getId() + ", "
|
||||
+ m.getSubject() + ", "
|
||||
+ m.getContent()
|
||||
+ ")";
|
||||
} else if(row instanceof MessageReceived) {
|
||||
MessageReceived m = (MessageReceived) row;
|
||||
command += Global.DB_TABLE_MSG_RCV + " (msgcod, usrcod, notified, open, replied, expanded) VALUES ("
|
||||
+ m.getId() + ", "
|
||||
+ m.getUsrcod() + ", "
|
||||
+ parseBoolString(m.isNotified()) + ", "
|
||||
+ parseBoolString(m.isOpen()) + ", "
|
||||
+ parseBoolString(m.isReplied()) + ", "
|
||||
+ parseBoolString(m.isExpanded())
|
||||
+ ")";
|
||||
} else if(row instanceof MessageSent) {
|
||||
MessageSent m = (MessageSent) row;
|
||||
command += Global.DB_TABLE_MSG_SNT + " (msgcod, crscod, usrcod, creattime, expanded) VALUES ("
|
||||
+ m.getId() + ", "
|
||||
+ m.getCrscod() + ", "
|
||||
+ m.getUsrcod() + ", "
|
||||
+ m.getCreattime() + ", "
|
||||
+ parseBoolString(m.isExpanded())
|
||||
+ ")";
|
||||
} else if(row instanceof Mark) {
|
||||
Mark m = (Mark) row;
|
||||
command += Global.DB_TABLE_MARKS + " (crscod, grpcod, path, header, footer) VALUES ("
|
||||
+ m.getCrscod() + ", "
|
||||
+ m.getGrpcod() + ", "
|
||||
+ m.getPath() + ", "
|
||||
+ m.getHeader() + ", "
|
||||
+ m.getFooter()
|
||||
+ ")";
|
||||
} else if(row instanceof PairTable) {
|
||||
PairTable<?, ?> p = (PairTable<?, ?>) row;
|
||||
String table = p.getTable();
|
||||
|
|
145
SWADroid/src/es/ugr/swad/swadroid/model/Mark.java
Normal file
145
SWADroid/src/es/ugr/swad/swadroid/model/Mark.java
Normal file
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* This file is part of SWADroid.
|
||||
*
|
||||
* Copyright (C) 2010 Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
*
|
||||
* SWADroid is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* SWADroid is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with SWADroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package es.ugr.swad.swadroid.model;
|
||||
|
||||
/**
|
||||
* Class for store a mark
|
||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
*/
|
||||
public class Mark extends Model {
|
||||
/**
|
||||
* Course code
|
||||
*/
|
||||
private int crscod;
|
||||
/**
|
||||
* Group code
|
||||
*/
|
||||
private int grpcod;
|
||||
/**
|
||||
* Mark file path
|
||||
*/
|
||||
private String path;
|
||||
/**
|
||||
* Mark header
|
||||
*/
|
||||
private int header;
|
||||
/**
|
||||
* Mark footer
|
||||
*/
|
||||
private int footer;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param id Mark identifier
|
||||
* @param crscod Course code
|
||||
* @param grpcod Group code
|
||||
* @param path Mark file path
|
||||
* @param header Mark header
|
||||
* @param footer Mark footer
|
||||
*/
|
||||
public Mark(int id, int crscod, int grpcod, String path, int header,
|
||||
int footer) {
|
||||
super(id);
|
||||
this.crscod = crscod;
|
||||
this.grpcod = grpcod;
|
||||
this.path = path;
|
||||
this.header = header;
|
||||
this.footer = footer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets course code
|
||||
* @return Course code
|
||||
*/
|
||||
public int getCrscod() {
|
||||
return crscod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets course code
|
||||
* @param crscod Course code
|
||||
*/
|
||||
public void setCrscod(int crscod) {
|
||||
this.crscod = crscod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets group code
|
||||
* @return Group code
|
||||
*/
|
||||
public int getGrpcod() {
|
||||
return grpcod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets group code
|
||||
* @param grpcod Group code
|
||||
*/
|
||||
public void setGrpcod(int grpcod) {
|
||||
this.grpcod = grpcod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets mark file path
|
||||
* @return Mark file path
|
||||
*/
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets mark file path
|
||||
* @param path Mark file path
|
||||
*/
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets mark header
|
||||
* @return Mark header
|
||||
*/
|
||||
public int getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets mark header
|
||||
* @param header Mark header
|
||||
*/
|
||||
public void setHeader(int header) {
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets mark footer
|
||||
* @return Mark footer
|
||||
*/
|
||||
public int getFooter() {
|
||||
return footer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets mark footer
|
||||
* @param footer Mark footer
|
||||
*/
|
||||
public void setFooter(int footer) {
|
||||
this.footer = footer;
|
||||
}
|
||||
}
|
122
SWADroid/src/es/ugr/swad/swadroid/model/MessageContent.java
Normal file
122
SWADroid/src/es/ugr/swad/swadroid/model/MessageContent.java
Normal file
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* This file is part of SWADroid.
|
||||
*
|
||||
* Copyright (C) 2010 Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
*
|
||||
* SWADroid is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* SWADroid is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with SWADroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package es.ugr.swad.swadroid.model;
|
||||
|
||||
/**
|
||||
* Class for store a message
|
||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
*/
|
||||
public class MessageContent extends Model {
|
||||
/**
|
||||
* Message subject
|
||||
*/
|
||||
private String subject;
|
||||
/**
|
||||
* Message content
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* Flag of message expanded
|
||||
*/
|
||||
private boolean expanded;
|
||||
/**
|
||||
* User code
|
||||
*/
|
||||
private int usrcod;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param id Message identifier
|
||||
* @param subject Message subject
|
||||
* @param content Message content
|
||||
* @param expanded Flag of message expanded
|
||||
* @param usrcod User code
|
||||
*/
|
||||
public MessageContent(int id, String subject, String content, boolean expanded, int usrcod) {
|
||||
super(id);
|
||||
this.subject = subject;
|
||||
this.content = content;
|
||||
this.expanded = expanded;
|
||||
this.usrcod = usrcod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets message subject
|
||||
* @return Message subject
|
||||
*/
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets message subject
|
||||
* @param subject Message subject
|
||||
*/
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets message content
|
||||
* @return Message content
|
||||
*/
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets message content
|
||||
* @param content Message content
|
||||
*/
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets user code
|
||||
* @return User code
|
||||
*/
|
||||
public int getUsrcod() {
|
||||
return usrcod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets user code
|
||||
* @param usrcod User code
|
||||
*/
|
||||
public void setUsrcod(int usrcod) {
|
||||
this.usrcod = usrcod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets flag of message expanded
|
||||
* @return Flag of message expanded
|
||||
*/
|
||||
public boolean isExpanded() {
|
||||
return expanded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets flag of message expanded
|
||||
* @param expanded Flag of message expanded
|
||||
*/
|
||||
public void setExpanded(boolean expanded) {
|
||||
this.expanded = expanded;
|
||||
}
|
||||
}
|
104
SWADroid/src/es/ugr/swad/swadroid/model/MessageReceived.java
Normal file
104
SWADroid/src/es/ugr/swad/swadroid/model/MessageReceived.java
Normal file
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* This file is part of SWADroid.
|
||||
*
|
||||
* Copyright (C) 2010 Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
*
|
||||
* SWADroid is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* SWADroid is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with SWADroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package es.ugr.swad.swadroid.model;
|
||||
|
||||
/**
|
||||
* Class for store a received message
|
||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
*/
|
||||
public class MessageReceived extends MessageContent {
|
||||
/**
|
||||
* Flag of message notified
|
||||
*/
|
||||
private boolean notified;
|
||||
/**
|
||||
* Flag of message open
|
||||
*/
|
||||
private boolean open;
|
||||
/**
|
||||
* Flag of message replied
|
||||
*/
|
||||
private boolean replied;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param id Message identifier
|
||||
* @param subject Message subject
|
||||
* @param content Message content
|
||||
* @param notified Flag of message notified
|
||||
* @param open Flag of message open
|
||||
* @param replied Flag of message replied
|
||||
* @param expanded Flag of message expanded
|
||||
*/
|
||||
public MessageReceived(int id, String subject, String content, int usrcod,
|
||||
boolean notified, boolean open, boolean replied, boolean expanded) {
|
||||
super(id, subject, content, expanded, usrcod);
|
||||
this.notified = notified;
|
||||
this.open = open;
|
||||
this.replied = replied;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets flag of message notified
|
||||
* @return Flag of message notified
|
||||
*/
|
||||
public boolean isNotified() {
|
||||
return notified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets flag of message notified
|
||||
* @param notified Flag of message notified
|
||||
*/
|
||||
public void setNotified(boolean notified) {
|
||||
this.notified = notified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets flag of message open
|
||||
* @return Flag of message open
|
||||
*/
|
||||
public boolean isOpen() {
|
||||
return open;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets flag of message open
|
||||
* @param open Flag of message open
|
||||
*/
|
||||
public void setOpen(boolean open) {
|
||||
this.open = open;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets flag of message replied
|
||||
* @return Flag of message replied
|
||||
*/
|
||||
public boolean isReplied() {
|
||||
return replied;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets flag of message replied
|
||||
* @param replied Flag of message replied
|
||||
*/
|
||||
public void setReplied(boolean replied) {
|
||||
this.replied = replied;
|
||||
}
|
||||
}
|
83
SWADroid/src/es/ugr/swad/swadroid/model/MessageSent.java
Normal file
83
SWADroid/src/es/ugr/swad/swadroid/model/MessageSent.java
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* This file is part of SWADroid.
|
||||
*
|
||||
* Copyright (C) 2010 Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
*
|
||||
* SWADroid is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* SWADroid is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with SWADroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package es.ugr.swad.swadroid.model;
|
||||
|
||||
/**
|
||||
* Class for store a sent message
|
||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
*/
|
||||
public class MessageSent extends MessageContent {
|
||||
/**
|
||||
* Course code
|
||||
*/
|
||||
private int crscod;
|
||||
/**
|
||||
* Date and time's creation of message
|
||||
*/
|
||||
private String creattime;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param id Message identifier
|
||||
* @param subject Message subject
|
||||
* @param content Message content
|
||||
* @param expanded Flag of message expanded
|
||||
* @param usrcod User code
|
||||
* @param crscod Course code
|
||||
* @param creattime Date and time's creation of message
|
||||
*/
|
||||
public MessageSent(int id, String subject, String content,
|
||||
boolean expanded, int usrcod, int crscod, String creattime) {
|
||||
super(id, subject, content, expanded, usrcod);
|
||||
this.crscod = crscod;
|
||||
this.creattime = creattime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets course code
|
||||
* @return Course code
|
||||
*/
|
||||
public int getCrscod() {
|
||||
return crscod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets course code
|
||||
* @param crscod Course code
|
||||
*/
|
||||
public void setCrscod(int crscod) {
|
||||
this.crscod = crscod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets date and time's creation of message
|
||||
* @return Date and time's creation of message
|
||||
*/
|
||||
public String getCreattime() {
|
||||
return creattime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets date and time's creation of message
|
||||
* @param creattime Date and time's creation of message
|
||||
*/
|
||||
public void setCreattime(String creattime) {
|
||||
this.creattime = creattime;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user