Última versão estável do projeto

Esse commit está contido em:
Paulo Henrique
2014-11-19 20:10:00 -03:00
commit 19956e040f
860 arquivos alterados com 104482 adições e 0 exclusões
@@ -0,0 +1,19 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_game;
public class Constantes {
public static final String gameUrl = "http://127.0.0.1:8080/AmadeusGames";
}
@@ -0,0 +1,51 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_middleware;
import java.io.IOException;
import java.util.List;
import javax.mail.MessagingException;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Keyword;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.AccessInfo;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.Person;
import br.ufpe.cin.amadeus.amadeus_web.exception.CourseInvalidException;
import br.ufpe.cin.amadeus.amadeus_web.exception.InvalidLogonException;
import br.ufpe.cin.amadeus.amadeus_web.exception.InvalidUserException;
import br.ufpe.cin.middleware.exceptions.AmadeusMiddlewareException;
import br.ufpe.cin.middleware.services.naming.RemoteInterface;
public interface DBWrapper extends RemoteInterface {
List<Keyword> getMostPopularKeywords() throws AmadeusMiddlewareException;
Person insertPerson(Person person) throws InvalidUserException, AmadeusMiddlewareException;
Course insertCourse(Course course) throws CourseInvalidException, AmadeusMiddlewareException;
Course updateCourse(Course course) throws AmadeusMiddlewareException;
void validateCourseStepOne(Course c) throws CourseInvalidException, AmadeusMiddlewareException;
Keyword insertKeyword(Keyword keyword) throws AmadeusMiddlewareException;
String remindPassword(String email) throws MessagingException, IOException, AmadeusMiddlewareException;
List<Course> getCoursesByKeyword(String keyword) throws AmadeusMiddlewareException;
List<Course>[] getCoursesByRule(String rule) throws AmadeusMiddlewareException;
boolean existLogin(String login) throws AmadeusMiddlewareException;
AccessInfo searchUserByLogin(String login) throws AmadeusMiddlewareException;
AccessInfo searchUserById(int id) throws AmadeusMiddlewareException;
Person editUser(Person person) throws Exception, AmadeusMiddlewareException;
boolean existEmail(String email) throws AmadeusMiddlewareException;
AccessInfo logon(AccessInfo accessInfo) throws InvalidLogonException, AmadeusMiddlewareException;
int getNumberOfPendingTasks(AccessInfo userInfo) throws AmadeusMiddlewareException;
List<Course> searchCoursesByAccessInfo(AccessInfo userInfo) throws AmadeusMiddlewareException;
}
@@ -0,0 +1,121 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_middleware;
import java.io.IOException;
import java.util.List;
import javax.mail.MessagingException;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Keyword;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.AccessInfo;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.Person;
import br.ufpe.cin.amadeus.amadeus_web.exception.CourseInvalidException;
import br.ufpe.cin.amadeus.amadeus_web.exception.InvalidLogonException;
import br.ufpe.cin.amadeus.amadeus_web.exception.InvalidUserException;
import br.ufpe.cin.amadeus.amadeus_web.facade.Controller;
/**
* Corresponde ao Facade anterior.
*
* Ficará do lado "servidor" do serviço de banco de dados,
* e será invocada pelo skeleton.
*
* @author Bruno Barros (blbs at cin ufpe br)
*
*/
public class DBWrapper_impl implements DBWrapper {
private static final long serialVersionUID = 1L;
private Controller controller = null;
public DBWrapper_impl() {
this.controller = Controller.getInstance();
}
public Person editUser(Person person) throws Exception {
return controller.editUser(person);
}
public boolean existEmail(String email) {
return controller.existEmail(email);
}
public boolean existLogin(String login) {
return controller.existLogin(login);
}
public List<Course> getCoursesByKeyword(String keyword) {
return controller.getCoursesByKeyword(keyword);
}
public List<Course>[] getCoursesByRule(String rule) {
return controller.getClassifiedCoursesByRule(rule);
}
public List<Keyword> getMostPopularKeywords() {
return controller.getMostPopularKeywords();
}
public int getNumberOfPendingTasks(AccessInfo userInfo) {
return controller.getNumberOfPendingTasks(userInfo);
}
public Course insertCourse(Course c) throws CourseInvalidException {
return controller.insertCourse(c);
}
public Keyword insertKeyword(Keyword keyword) {
return controller.insertKeyword(keyword);
}
public Person insertPerson(Person p) throws InvalidUserException {
return controller.insertPerson(p);
}
public AccessInfo logon(AccessInfo accessInfo) throws InvalidLogonException {
return controller.logon(accessInfo);
}
public String remindPassword(String email) throws MessagingException, IOException {
return controller.remindPassword(email);
}
public List<Course> searchCoursesByAccessInfo(AccessInfo userInfo) {
return controller.searchCoursesByAccessInfo(userInfo);
}
public AccessInfo searchUserById(int id) {
return controller.searchUserById(id);
}
public AccessInfo searchUserByLogin(String login) {
return controller.searchUserByLogin(login);
}
public Course updateCourse(Course c) {
return controller.updateCourse(c);
}
public AccessInfo updateUser(AccessInfo ai) {
return controller.updateUser(ai);
}
public void validateCourseStepOne(Course c) throws CourseInvalidException {
controller.validateCourseStepOne(c);
}
}
@@ -0,0 +1,60 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_middleware;
import java.net.InetAddress;
import java.util.Calendar;
import br.ufpe.cin.middleware.services.naming.Naming;
import br.ufpe.cin.middleware.services.naming.RemoteProcess;
import br.ufpe.cin.middleware.services.naming.exceptions.AlreadyBoundException;
import br.ufpe.cin.middleware.util.Properties;
/**
* Inicia conexão com o servidor de nomes -
* br.ufpe.cin.middleware.services.naming.NameServer
* - enviando a interface da fachada para o mesmo,
* para que seus métodos sejam acessados pelos clientes
*
* Ficará do lado "servidor" do serviço de banco de dados,
* e será responsável por instanciar o skeleton, bem como
* a classe que contém a implementação
*
* @author Bruno Barros (blbs at cin ufpe br)
*
*/
public class DBWrapper_server {
public static void main(String[] args) {
RemoteProcess remoteProcess = null;
try {
remoteProcess = new RemoteProcess(InetAddress.getLocalHost().getHostAddress(), DBWrapper.class);
Naming.connect(Properties.services_naming_host, Properties.services_naming_port);
Naming.bind("Facade", remoteProcess);
System.out.println("===== Autentication Server is Running Since " + Calendar.getInstance().getTime() + " ====");
} catch (AlreadyBoundException e) {
try {
Naming.connect(Properties.services_naming_host, Properties.services_naming_port);
Naming.rebind("Facade", remoteProcess);
System.out.println("===== Autentication Server is Running Since " + Calendar.getInstance().getTime() + " ====");
} catch (Exception e1) {
e1.printStackTrace();
}
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,35 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_middleware;
import br.ufpe.cin.middleware.exceptions.AmadeusMiddlewareException;
import br.ufpe.cin.middleware.proxies.Skeleton_abstract;
/**
* Responsável por receber as requisições vindas
* do stub do lado cliente e delegá-las à classe
* que contém a implementação dos métodos.
*
* Ficará do lado "servidor" do serviço de banco de dados.
*
* @author Bruno Barros (blbs at cin ufpe br)
*
*/
public class DBWrapper_skeleton extends Skeleton_abstract {
public DBWrapper_skeleton() throws AmadeusMiddlewareException {
super(new DBWrapper_impl());
}
}
@@ -0,0 +1,122 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_middleware;
import br.ufpe.cin.middleware.proxies.Stub_abstract;
import javax.mail.MessagingException;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Keyword;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.AccessInfo;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.Person;
import br.ufpe.cin.amadeus.amadeus_web.exception.CourseInvalidException;
import br.ufpe.cin.amadeus.amadeus_web.exception.InvalidLogonException;
import br.ufpe.cin.amadeus.amadeus_web.exception.InvalidUserException;
import java.util.List;
import java.io.IOException;
import br.ufpe.cin.middleware.exceptions.AmadeusMiddlewareException;
/**
* Responsável por receber as chamadas dos métodos
* do lado cliente, construir mensagens correspondentes
* e enviar estas requisições ao skeleton do lado
* servidor.
*
* Ficará do lado "cliente" do serviço de banco de dados.
*
* @author Bruno Barros (blbs at cin ufpe br)
*
*/
public class DBWrapper_stub extends Stub_abstract implements DBWrapper {
private static final long serialVersionUID = 1L;
public DBWrapper_stub(String host, int port) throws AmadeusMiddlewareException {
super(host, port);
}
@SuppressWarnings("unchecked")
public List<Keyword> getMostPopularKeywords() throws AmadeusMiddlewareException {
return (List<Keyword>) this.process("getMostPopularKeywords");
}
public Person insertPerson(Person p0) throws InvalidUserException, AmadeusMiddlewareException {
return (Person) this.process("insertPerson",p0);
}
public Course insertCourse(Course p0) throws CourseInvalidException, AmadeusMiddlewareException {
return (Course) this.process("insertCourse",p0);
}
public Course updateCourse(Course p0) throws AmadeusMiddlewareException {
return (Course) this.process("updateCourse",p0);
}
public void validateCourseStepOne(Course p0) throws CourseInvalidException, AmadeusMiddlewareException {
this.process("validateCourseStepOne",p0);
}
public Keyword insertKeyword(Keyword p0) throws AmadeusMiddlewareException {
return (Keyword) this.process("insertKeyword",p0);
}
public String remindPassword(String p0) throws MessagingException, IOException, AmadeusMiddlewareException {
return (String) this.process("remindPassword",p0);
}
@SuppressWarnings("unchecked")
public List<Course> getCoursesByKeyword(String p0) throws AmadeusMiddlewareException {
return (List<Course>) this.process("getCoursesByKeyword",p0);
}
@SuppressWarnings("unchecked")
public List<Course>[] getCoursesByRule(String p0) throws AmadeusMiddlewareException {
return (List<Course>[]) this.process("getCoursesByRule",p0);
}
public boolean existLogin(String p0) throws AmadeusMiddlewareException {
return (Boolean) this.process("existLogin",p0);
}
public AccessInfo searchUserByLogin(String p0) throws AmadeusMiddlewareException {
return (AccessInfo) this.process("searchUserByLogin",p0);
}
public AccessInfo searchUserById(int p0) throws AmadeusMiddlewareException {
return (AccessInfo) this.process("searchUserById",p0);
}
public Person editUser(Person p0) throws Exception, AmadeusMiddlewareException {
return (Person) this.process("editUser",p0);
}
public boolean existEmail(String p0) throws AmadeusMiddlewareException {
return (Boolean) this.process("existEmail",p0);
}
public AccessInfo logon(AccessInfo accessInfo) throws InvalidLogonException, AmadeusMiddlewareException {
return (AccessInfo) this.process("logon", accessInfo);
}
public int getNumberOfPendingTasks(AccessInfo p0) throws AmadeusMiddlewareException {
return (Integer) this.process("getNumberOfPendingTasks",p0);
}
@SuppressWarnings("unchecked")
public List<Course> searchCoursesByAccessInfo(AccessInfo p0) throws AmadeusMiddlewareException {
return (List<Course>) this.process("searchCoursesByAccessInfo",p0);
}
}
@@ -0,0 +1,69 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_middleware;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.AccessInfo;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.Person;
import br.ufpe.cin.middleware.exceptions.AmadeusMiddlewareException;
import br.ufpe.cin.middleware.exceptions.SerializationException;
import br.ufpe.cin.middleware.services.naming.Naming;
import br.ufpe.cin.middleware.services.naming.exceptions.NamingServiceException;
public class FacadeMiddleware {
private static DBWrapper instance;
public static DBWrapper getInstance() {
if (instance == null) {
try {
//Basta saber onde o servidor de nomes está rodando...
Naming.connect("localhost", 1900);
//... e pedir a ele uma instância da fachada, que foi
// criada e enviada pelo servidor
instance = (DBWrapper) Naming.resolve("Facade");
} catch (AmadeusMiddlewareException e) {
//exceção levantada caso haja algum erro dentro do middleware
System.err.println("O servidor de nomes não foi encontrado!");
System.exit(-1);
} catch (NamingServiceException e) {
//exceção levantada caso haja algum erro específico do servidor de nomes
System.err.println("Problema no servidor de nomes: " + e.getMessage());
System.exit(-1);
} catch (SerializationException e) {
//exceção levantada caso o objeto enviado pelo servidor não possa ser
//instanciado do lado cliente.
System.err.println("O objeto não pôde ser instanciado: " + e.getMessage());
System.exit(-1);
}
}
return instance;
}
//main para testes
public static void main(String[] args) {
DBWrapper f = FacadeMiddleware.getInstance();
try {
//a partir daqui, o restante é feito como antes
AccessInfo user = f.searchUserByLogin("vcp");
user.getLogin();
user.getPassword();
Person person = user.getPerson();
System.out.println(person.getName() + ":" + person.getGender());
} catch (AmadeusMiddlewareException e) {
//agora todos os métodos lançam esta exceção, ela deve ser tratada
e.printStackTrace();
}
}
}
@@ -0,0 +1,57 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.basics;
import java.util.Date;
public class AnswerMobile {
private int id;
private PersonMobile person;
private Date answerDate;
public AnswerMobile() {}
public AnswerMobile(PersonMobile p, Date d) {
this.person = p;
this.answerDate =d;
}
public Date getAnswerDate() {
return answerDate;
}
public void setAnswerDate(Date answerDate) {
this.answerDate = answerDate;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public PersonMobile getPerson() {
return person;
}
public void setPerson(PersonMobile person) {
this.person = person;
}
}
@@ -0,0 +1,69 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.basics;
public class ChoiceMobile {
private int id;
private String alternative;
private int votes;
private double percentage;
public ChoiceMobile() {
super();
}
public ChoiceMobile(int id, String alternative, int votes, double percentage) {
this.id = id;
this.alternative = alternative;
this.votes = votes;
this.percentage = percentage;
}
public String getAlternative() {
return alternative;
}
public void setAlternative(String alternative) {
this.alternative = alternative;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public double getPercentage() {
return percentage;
}
public void setPercentage(double percentage) {
this.percentage = percentage;
}
public int getVotes() {
return votes;
}
public void setVotes(int votes) {
this.votes = votes;
}
}
@@ -0,0 +1,232 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.basics;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.HashSet;
import java.util.List;
public class CourseMobile {
private int id;
private String name;
private List<ModuleMobile> modules;
private List<String> teachers;
private List<String> helpers;
private List<NoticeMobile> notices;
private String objectives;
private String content;
private int maxAmountStudents;
private Date initialCourseDate;
private Date finalCourseDate;
private HashSet<KeywordMobile> keywords;
private String color;
private boolean sms;
private int count;
private int idCourse;
private String login;
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public CourseMobile() {
super();
}
public CourseMobile(int id, String name, List<ModuleMobile> modules,
List<String> teachers, List<String> helpers, List<NoticeMobile> notices,
String objectives, String content, int maxAmountStudents,
Date initialCourseDate, Date finalCourseDate,
HashSet<KeywordMobile> keywords, String color, boolean sms, int count) {
super();
this.id = id;
this.name = name;
this.modules = modules;
this.teachers = teachers;
this.helpers = helpers;
this.notices = notices;
this.objectives = objectives;
this.content = content;
this.maxAmountStudents = maxAmountStudents;
this.initialCourseDate = initialCourseDate;
this.finalCourseDate = finalCourseDate;
this.keywords = keywords;
this.color = color;
this.sms = sms;
this.count = count;
}
public List<NoticeMobile> getNotices() {
return notices;
}
public void setNotices(List<NoticeMobile> notices) {
this.notices = notices;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public Date getFinalCourseDate() {
return finalCourseDate;
}
public void setFinalCourseDate(Date finalCourseDate) {
this.finalCourseDate = finalCourseDate;
}
public List<String> getHelpers() {
return helpers;
}
public void setHelpers(List<String> helpers) {
this.helpers = helpers;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Date getInitialCourseDate() {
return initialCourseDate;
}
public void setInitialCourseDate(Date initialCourseDate) {
this.initialCourseDate = initialCourseDate;
}
public int getMaxAmountStudents() {
return maxAmountStudents;
}
public void setMaxAmountStudents(int maxAmountStudents) {
this.maxAmountStudents = maxAmountStudents;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getObjectives() {
return objectives;
}
public void setObjectives(String objectives) {
this.objectives = objectives;
}
public boolean getSms() {
return sms;
}
public void setSms(boolean sms) {
this.sms = sms;
}
public List<String> getTeachers() {
return teachers;
}
public void setTeachers(List<String> teachers) {
this.teachers = teachers;
}
public HashSet<KeywordMobile> getKeywords() {
return keywords;
}
public void setKeywords(HashSet<KeywordMobile> keywords) {
this.keywords = keywords;
}
public List<ModuleMobile> getModules() {
return modules;
}
public void setModules(List<ModuleMobile> modules) {
this.modules = modules;
}
public String getDataInicio() {
SimpleDateFormat sd = new SimpleDateFormat("dd/MM/yyyy");
String retorno = sd.format(this.initialCourseDate);
return retorno;
}
public String getDataFim() {
SimpleDateFormat sd = new SimpleDateFormat("dd/MM/yyyy");
String retorno = sd.format(this.finalCourseDate);
return retorno;
}
public int getIdCourse() {
return idCourse;
}
public void setIdCourse(int idCourse) {
this.idCourse = idCourse;
}
}
@@ -0,0 +1,60 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.basics;
import java.util.Date;
import java.util.Comparator;
public class HomeworkComparator implements Comparator<Object> {
/**
* Method that compares 2 objects that can be Homework or Poll
* if it's a homework, checks if both objects have the same deadline
* if it's a Poll, checks if both objects have the same FinishDate
* @param arg0 - first object
* @param arg1 - second object
* @return - result of the comparsion.
*/
public int compare(Object arg0, Object arg1) {
Date d1 = null;
Date d2 = null;
int retorno = -1;
if (arg0 instanceof PollMobile) {
d1 = ((PollMobile)arg0).getFinishDate();
}
else if (arg0 instanceof HomeworkMobile) {
d1 = ((HomeworkMobile) arg0).getDeadlineDate();
}
if (arg1 instanceof PollMobile) {
d2 = ((PollMobile)arg0).getFinishDate();
}
else if (arg1 instanceof HomeworkMobile) {
d2 = ((HomeworkMobile) arg1).getDeadlineDate();
}
if (d1!= null && d2!= null) {
retorno = d1.compareTo(d2);
}
else if((d1!= null && d2 ==null) || (d2!= null && d1==null)) {
retorno = -1;
}
else {
retorno = 1;
}
return retorno;
}
}
@@ -0,0 +1,154 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.basics;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
public class HomeworkMobile {
public static final String FORUM = "FORUM";
public static final String HOMEWORK = "HOMEWORK";
public static final String GAME = "GAME";
public static final String POLL = "POLL";
public static final String MULTIMEDIA = "MULTIMEDIA";
public static final String VIDEO = "VIDEO";
public static final String LEARNING_OBJECT = "LEARNING_OBJECT";
private int id;
private String name;
private String description;
private Date initDate;
private Date deadline;
private Date alowPostponing;
private int idCourse;
private String typeActivity;
private String infoExtra;
private String url;
public HomeworkMobile() {}
public HomeworkMobile(int id, String name, String description, Date initDate,
Date deadline, Date alowPostponing, int idCourse) {
this.id = id;
this.name = name;
this.description = description;
this.initDate = initDate;
this.deadline = deadline;
this.alowPostponing = alowPostponing;
this.idCourse = idCourse;
}
public String getTypeActivity() {
return typeActivity;
}
public void setTypeActivity(String typeActivity) {
this.typeActivity = typeActivity;
}
public String getInfoExtra() {
return infoExtra;
}
public void setInfoExtra(String infoExtra) {
this.infoExtra = infoExtra;
}
public Date getAlowPostponing() {
return alowPostponing;
}
public void setAlowPostponing(Date alowPostponing) {
this.alowPostponing = alowPostponing;
}
public String getDeadline() {
DateFormat df = new SimpleDateFormat("dd/MM/yy");
if (deadline != null){
return df.format(deadline);
}
return "Sem Prazo Final!";
}
public Date getDeadlineDate() {
return this.deadline;
}
public void setDeadline(Date deadline) {
this.deadline = deadline;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getInitDate() {
DateFormat df = new SimpleDateFormat("dd/MM/yy");
String data = df.format(initDate);
return data;
}
public void setInitDate(Date initDate) {
this.initDate = initDate;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getIdCourse() {
return idCourse;
}
public void setIdCourse(int idCourse) {
this.idCourse = idCourse;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
@@ -0,0 +1,57 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.basics;
public class KeywordMobile {
private int id;
private String name;
private int popularity;
public KeywordMobile() {}
public KeywordMobile(int id, String name, int popularity) {
super();
this.id = id;
this.name = name;
this.popularity = popularity;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPopularity() {
return popularity;
}
public void setPopularity(int popularity) {
this.popularity = popularity;
}
}
@@ -0,0 +1,80 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.basics;
import java.util.Date;
public class LearningObjectMobile {
private int id;
private String name;
private String url;
private String description;
private Date datePublication;
public LearningObjectMobile() {
// TODO Auto-generated constructor stub
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Date getDatePublication() {
return datePublication;
}
public void setDatePublication(Date datePublication) {
this.datePublication = datePublication;
}
}
@@ -0,0 +1,69 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.basics;
import java.util.Date;
public class MaterialMobile {
private int id;
private String name;
private Date postDate;
private PersonMobile author;
public MaterialMobile() {}
public MaterialMobile(int id, String nome, Date postDate, PersonMobile author) {
this.id = id;
this.name = nome;
this.postDate = postDate;
this.author = author;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String nome) {
this.name = nome;
}
public PersonMobile getAuthor() {
return author;
}
public void setAuthor(PersonMobile author) {
this.author = author;
}
public Date getPostDate() {
return postDate;
}
public void setPostDate(Date postDate) {
this.postDate = postDate;
}
}
@@ -0,0 +1,86 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.basics;
import java.util.List;
public class ModuleMobile {
private int id;
private List<NoticeMobile> noticies;
private List<MaterialMobile> materials;
private List<HomeworkMobile> homeworks;
private String nome;
public ModuleMobile() {}
public ModuleMobile(int id, String nome) {
this.id = id;
this.nome = nome;
}
public ModuleMobile(int id, List<NoticeMobile> noticies, List<MaterialMobile> materials, List<HomeworkMobile> homeworks, String nome) {
super();
this.id = id;
this.noticies = noticies;
this.materials = materials;
this.homeworks = homeworks;
this.nome = nome;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public List<HomeworkMobile> getHomeworks() {
return homeworks;
}
public void setHomeworks(List<HomeworkMobile> homeworks) {
this.homeworks = homeworks;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public List<MaterialMobile> getMaterials() {
return materials;
}
public void setMaterials(List<MaterialMobile> materials) {
this.materials = materials;
}
public List<NoticeMobile> getNoticies() {
return noticies;
}
public void setNoticies(List<NoticeMobile> noticies) {
this.noticies = noticies;
}
}
@@ -0,0 +1,45 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.basics;
import java.util.Date;
import java.util.Comparator;
public class NoticeComparator implements Comparator<NoticeMobile> {
/**
* Method that compares 2 objects that are Notice
* checking if they have the same creation date
* @param arg0 - first object
* @param arg1 - second object
* @return - result of the comparsion.
*/
public int compare(NoticeMobile arg0, NoticeMobile arg1) {
Date d1 = arg0.getDateCreation();
Date d2 = arg1.getDateCreation();
int retorno = -1;
if (d1!= null && d2!= null) {
retorno = d1.compareTo(d2);
}
else if((d1!= null && d2 ==null) || (d2!= null && d1==null)) {
retorno = -1;
}
else {
retorno = 1;
}
return retorno;
}
}
@@ -0,0 +1,143 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.basics;
import java.util.Date;
public class NoticeMobile {
public static final int TIPO_ATIVIDADE = 0;
public static final int TIPO_CURSO = 1;
public static final int TIPO_MATERIAL = 2;
public static final int TIPO_ENQUETE = 3;
public static final int TIPO_AMADEUS = 4;
private int id;
private String title;
private String content;
private int idModule;
private int idCourse;
private int type;
private boolean read;
private int idElement;
private Date dateCreation;
public int getIdElement() {
return idElement;
}
public void setIdElement(int idElement) {
this.idElement = idElement;
}
public NoticeMobile() {}
public NoticeMobile(int id, String title, String content, int idModule, int idCourse, int type, boolean read, int idElement, Date data_criacao) {
super();
this.id = id;
this.title = title;
this.content = content;
this.idModule = idModule;
this.idCourse = idCourse;
this.type = type;
this.read = read;
this.idElement = idElement;
this.dateCreation = data_criacao;
}
public NoticeMobile(String title, String content, int idModule, int idCourse, int type, boolean read, int idElement, Date data_criacao) {
super();
this.title = title;
this.content = content;
this.idModule = idModule;
this.idCourse = idCourse;
this.type = type;
this.read = read;
this.idElement = idElement;
this.dateCreation = data_criacao;
}
public String getContent() {
return " " + content;
}
public void setContent(String content) {
this.content = content;
}
public int getIdModule() {
return idModule;
}
public void setIdModule(int idModule) {
this.idModule = idModule;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public boolean isRead() {
return read;
}
public void setRead(boolean read) {
this.read = read;
}
public Date getDateCreation() {
return dateCreation;
}
public void setDateCreation(Date data_criacao) {
this.dateCreation = data_criacao;
}
public int getIdCourse() {
return idCourse;
}
public void setIdCourse(int idCourse) {
this.idCourse = idCourse;
}
}
@@ -0,0 +1,56 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.basics;
public class PersonMobile {
private int id;
private String name;
private String phoneNumber;
public PersonMobile() {}
public PersonMobile(int id, String name, String phoneNumber) {
this.id = id;
this.name = name;
this.phoneNumber = phoneNumber;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
}
@@ -0,0 +1,114 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.basics;
import java.util.Date;
import java.util.List;
public class PollMobile {
private int id;
private String name;
private String question;
private Date initDate;
private Date finishDate;
private List<ChoiceMobile> choices;
private List<AnswerMobile> ansewered;
private boolean answered;
public PollMobile() {}
public PollMobile(int id, String name, String question, Date initDate, Date finishDate, List<ChoiceMobile> choices, List<AnswerMobile> ansewered, boolean answered) {
this.id = id;
this.name = name;
this.question = question;
this.initDate = initDate;
this.finishDate = finishDate;
this.choices = choices;
this.ansewered = ansewered;
this.answered = answered;
}
public boolean isAnswered() {
return answered;
}
public void setAnswered(boolean answered) {
this.answered = answered;
}
public List<ChoiceMobile> getChoices() {
return choices;
}
public void setChoices(List<ChoiceMobile> choices) {
this.choices = choices;
}
public String getQuestion() {
return question;
}
public void setQuestion(String question) {
this.question = question;
}
public Date getFinishDate() {
return finishDate;
}
public void setFinishDate(Date finishDate) {
this.finishDate = finishDate;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Date getInitDate() {
return initDate;
}
public void setInitDate(Date initDate) {
this.initDate = initDate;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<AnswerMobile> getAnsewered() {
return ansewered;
}
public void setAnsewered(List<AnswerMobile> ansewered) {
this.ansewered = ansewered;
}
}
@@ -0,0 +1,56 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.basics;
public class UserMobile {
private int id; // User Id
private String login; // User Login
private String password; // User Passowrd
public UserMobile() {}
public UserMobile(int id, String login, String senha) {
this.id = id;
this.login = login;
this.password = senha;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
@@ -0,0 +1,173 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.bussiness;
import java.util.ArrayList;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.MaterialMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.ModuleMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.repository.ICourseRepositoryMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.repository.CourseRepositoryMobile;
public class CourseBussinessMobile implements ICourseBussinessMobile{
private ICourseRepositoryMobile repCourse;
private String[] colors;
private AmadeusFacade amadeusFacade = AmadeusFacade.getInstance();
public CourseBussinessMobile(){
repCourse = new CourseRepositoryMobile();
this.fillColors();
}
private void fillColors() {
this.colors = new String[8];
this.colors[0] = "#FFDAB9";
this.colors[1] = "#778899";
this.colors[2] = "#87cefa";
this.colors[3] = "#00FF00";
this.colors[4] = "#FFFF00";
this.colors[5] = "#D2691E";
this.colors[6] = "#FF0000";
this.colors[7] = "#8B8989";
}
/**
* Method that searches if the user has a color defined.
* if not, create one for the user
* @param colors - User color list
* @return - a color
*/
private String verifyColor(List<String> colors) {
String color = "";
String colorTemp = "";
String newColor = "";
boolean find = false;
for(int i = 0; i < this.colors.length; i++) {
color = this.colors[i];
find = false;
for (int j = 0; j < colors.size(); j++) {
colorTemp = colors.get(j);
if(colorTemp!= null && colorTemp.equals(color)) {
find = true;
break;
}
}
if(!find) {
newColor = color;
break;
}
}
return newColor;
}
/**
* Method that Searches for all of the User courses,
* returning a list of Courses
* @param login - User login to search for
* @return - Course List
*/
public List<CourseMobile> listCourses(String login) {
return repCourse.listCourses(login);
}
/**
* Method that gets a specific User course
* @param idCourse - Desired Course ID
* if the user has this course registered at the Mobile Database,
* it sets the course details, like if he wants to receive SMS and the color.
* If the user doesn't have the course registered at the Mobile Database,
* Adds the course to the database
* @param login - login of the user that is searching the course for
* @return - Course information
*/
public CourseMobile getCourse(int idCourse, String login) {
AmadeusFacade f = AmadeusFacade.getInstance();
CourseMobile c = repCourse.getCourse(idCourse, login);
CourseMobile d = f.getCourse(idCourse);
if(c == null){
repCourse.insertCourse(d, login);
List<String> colors = repCourse.getUserColors(login);
if(colors.size() < 8) {
d.setColor(verifyColor(colors));
d.setSms(true);
updateCourse(d, login);
}else{
d.setColor(this.colors[0]);
updateCourse(d, login);
}
}else {
d.setColor(c.getColor());
d.setSms(c.getSms());
d.setCount(c.getCount());
}
return d;
}
/**
* Method that returns a specific Module requested
* @param idModulo - Module Id
* @return - the requested Module
*/
public ModuleMobile getModule(int idModulo) {
return repCourse.getModule(idModulo);
}
/**
* Method that updates a User Course
* @param c - Course to be updated
* @param login - User login that has the couse
*/
public void updateCourse(CourseMobile c, String login) {
repCourse.updateCourse(c, login);
}
//@Override
public List<Object> getAllCoursesActivities(String login) {
ArrayList<Object> retorno = new ArrayList<Object>();
List<CourseMobile> cursos = amadeusFacade.listCourses(login);
for (CourseMobile cm : cursos){
List<ModuleMobile> modules = cm.getModules();
for (ModuleMobile mm : modules) {
retorno.addAll(mm.getHomeworks());
}
}
return retorno;
}
//@Override
public List<MaterialMobile> getAllCoursesMaterials(String login) {
List<MaterialMobile> retorno = new ArrayList<MaterialMobile>();
List<CourseMobile> cursos = amadeusFacade.listCourses(login);
for (CourseMobile cm : cursos) {
List<ModuleMobile> modules = cm.getModules();
for (ModuleMobile mm : modules) {
retorno.addAll(mm.getMaterials());
}
}
return retorno;
}
}
@@ -0,0 +1,40 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.bussiness;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.repository.IHomeworkRepositoryMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.repository.HomeworkRepositoryMobile;
public class HomeworkBussinessMobile implements IHomeworkBussinessMobile{
private IHomeworkRepositoryMobile repHomework;
/**
* Constructor
*/
public HomeworkBussinessMobile(){
repHomework = new HomeworkRepositoryMobile();
}
/**
* Method that returns a specific homework
* @param id - Homework id
* @return - Homework requested
*/
public HomeworkMobile getHomework(int id) {
return repHomework.getHomework(id);
}
}
@@ -0,0 +1,59 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.bussiness;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.MaterialMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.ModuleMobile;
public interface ICourseBussinessMobile {
/**
* Method that Searches for all of the User courses,
* returning a list of Courses
* @param login - User login to search for
* @return - Course List
*/
public List<CourseMobile> listCourses(String login);
/**
* Method that gets a specific User course
* @param idCourse - Desired Course ID
* if the user has this course registered at the Mobile Database,
* it sets the course details, like if he wants to receive SMS and the color.
* If the user doesn't have the course registered at the Mobile Database,
* Adds the course to the database
* @param login - login of the user that is searching the course for
* @return - Course information
*/
public CourseMobile getCourse(int idCourse, String login);
/**
* Method that returns a specific Module requested
* @param idModulo - Module Id
* @return - the requested Module
*/
public ModuleMobile getModule(int idModulo);
/**
* Method that updates a User Course
* @param c - Course to be updated
* @param login - User login that has the couse
*/
public void updateCourse(CourseMobile c, String login);
public List<Object> getAllCoursesActivities(String login);
public List<MaterialMobile> getAllCoursesMaterials(String login);
}
@@ -0,0 +1,27 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.bussiness;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile;
public interface IHomeworkBussinessMobile {
/**
* Method that returns a specific homework
* @param id - Homework id
* @return - Homework requested
*/
public HomeworkMobile getHomework(int id);
}
@@ -0,0 +1,53 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.bussiness;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.UserMobile;
public interface ILoginBussinessMobile {
/**
* Method that verifies the existence of a user and it´s password.
* If the user and password match on the database, returns the User
* Else returns null.
* @param login - User login
* @param password - User password
* @return - User
*/
public UserMobile verifyLogin(String login, String password);
/**
* Method that update a cell number for the login passed
* @param login - User login
*/
public void updateLogin(PersonMobile p);
/**
* Method that verifies the existence of a login.
* If the login match on the database, returns the login
* Else returns null.
* @param login - User login
* @return - String login
*/
public PersonMobile getLogin(String login) ;
/**
* Method that insert a login for the login passed
* @param login - User login
*/
public void insertLogin(String login);
}
@@ -0,0 +1,86 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.bussiness;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
public interface INoticeBussinessMobile {
/**
* Method that returns a Notice List from the User´s Course
* @param idCouse - Course Id
* @param login - User login
* @return - User´s Course Notice List
*/
public List<NoticeMobile> getNoticesCourse(int idCourse, String login);
/**
* Method that returns a Notice List from the User´s Module
* @param idModule - Module Id
* @param login - User login
* @return - User´s Module Notice List
*/
public List<NoticeMobile> getNoticesModule(int idModule, String login);
/**
* Method that returns the User Notice requested
* @param idNotice - Notice Id
* @param login - User login that has the Notice Id
* @return - Notice
*/
public NoticeMobile getNotice(int idNotice, String login);
/**
* Method that returns the AMADeUs Notice List for the User
* @param login - User login
* @return - Notice List
*/
public List<NoticeMobile> getNoticesAmadeus(String login);
/**
* Method that Checks if a Notice was sent
* @param idNotice - Notice Id
* @return - Boolean if the Notice was sent or not
*/
public boolean sent(int idNotice);
/**
* Method that Adds a Notice
* @param notice - Notice to add
*/
public void addNotice(NoticeMobile notice);
/**
* Method that Updates a User Notice
* @param notice - Notice Updated
* @param login - User Login that has the Notice
*/
public void updateNotice(NoticeMobile n, String login);
/**
* Method that checks if there is a Notice. If exists, returns the Notice id.
* If it doesn't exist, returns -1
* @param not - Notice to be searched
* @return - Notice Id
*/
public int existNotice(NoticeMobile notice);
/**
* Method that returns the Notice requested
* @param idNotice - Notice Id
* @return - Notice
*/
public NoticeMobile getNoticeSMS(int noticeId);
/**
* Method that returns the last id of a notice by course
* @param idCourse
* @return notice id
*/
public int getLastId(int idCourse);
}
@@ -0,0 +1,25 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.bussiness;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PollMobile;
public interface IPoolBussinessMobile {
/**
* Method that returns a Poll
* @param id - PollId
* @return - Poll
*/
public PollMobile getPool(int id);
}
@@ -0,0 +1,70 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.bussiness;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.UserMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.repository.ILoginRepositoryMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.repository.LoginRepositoryMobile;
public class LoginBussinessMobile implements ILoginBussinessMobile{
private ILoginRepositoryMobile repLogin;
public LoginBussinessMobile(){
repLogin = new LoginRepositoryMobile();
}
/**
* Method that verifies the existence of a user and it´s password.
* If the user and password match on the database, returns the User
* Else returns null.
* @param login - User login
* @param password - User password
* @return - User
*/
public UserMobile verifyLogin(String login, String password) {
return repLogin.verifyLogin(login, password);
}
/**
* Method that update a cell number for the login passed
* @param login - User login
*/
public void updateLogin(PersonMobile p){
repLogin.updateLogin(p);
}
/**
* Method that verifies the existence of a login.
* If the login match on the database, returns the login
* Else returns null.
* @param login - User login
* @return - String login
*/
public PersonMobile getLogin(String login) {
return repLogin.getLogin(login);
}
/**
* Method that insert a login for the login passed
* @param login - User login
*/
public void insertLogin(String login){
repLogin.insertLogin(login);
}
}
@@ -0,0 +1,114 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.bussiness;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.repository.INoticeRepositoryMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.repository.NoticeRepositoryMobile;
public class NoticeBussinessMobile implements INoticeBussinessMobile {
private INoticeRepositoryMobile repNotice;
public NoticeBussinessMobile() {
this.repNotice = new NoticeRepositoryMobile();
}
/**
* Method that returns a Notice List from the User´s Course
* @param idCouse - Course Id
* @param login - User login
* @return - User´s Course Notice List
*/
public List<NoticeMobile> getNoticesCourse(int idCourse, String login) {
return repNotice.getNoticesCourse(idCourse, login);
}
/**
* Method that returns the User Notice requested
* @param idNotice - Notice Id
* @param login - User login that has the Notice Id
* @return - Notice
*/
public NoticeMobile getNotice(int idNotice, String login) {
return repNotice.getNotice(idNotice, login);
}
/**
* Method that returns a Notice List from the User´s Module
* @param idModule - Module Id
* @param login - User login
* @return - User´s Module Notice List
*/
public List<NoticeMobile> getNoticesModule(int idModule, String login) {
return repNotice.getNoticesModule(idModule, login);
}
/**
* Method that returns the AMADeUs Notice List for the User
* @param login - User login
* @return - Notice List
*/
public List<NoticeMobile> getNoticesAmadeus(String login) {
return repNotice.getNoticesAmadeus(login);
}
/**
* Method that Checks if a Notice was sent
* @param idNotice - Notice Id
* @return - Boolean if the Notice was sent or not
*/
public boolean sent(int idNotice) {
return repNotice.sent(idNotice);
}
/**
* Method that Adds a Notice
* @param notice - Notice to add
*/
public void addNotice(NoticeMobile notice) {
this.repNotice.addNotice(notice);
}
/**
* Method that Updates a User Notice
* @param notice - Notice Updated
* @param login - User Login that has the Notice
*/
public void updateNotice(NoticeMobile n, String login){
this.repNotice.updateNotice(n, login);
}
/**
* Method that checks if there is a Notice. If exists, returns the Notice id.
* If it doesn't exist, returns -1
* @param not - Notice to be searched
* @return - Notice Id
*/
public int existNotice(NoticeMobile notice) {
return this.repNotice.existNotice(notice);
}
/**
* Method that returns the Notice requested
* @param idNotice - Notice Id
* @return - Notice
*/
public NoticeMobile getNoticeSMS(int noticeId) {
return this.repNotice.getNoticeSMS(noticeId);
}
/**
* Method that returns the last id of a notice by course
* @param idCourse
* @return notice id
*/
public int getLastId(int idCourse) {
return this.repNotice.getLastId(idCourse);
}
}
@@ -0,0 +1,36 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.bussiness;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PollMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.repository.IPoolRepositoryMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.repository.PoolRepositoryMobile;
public class PoolBussinessMobile implements IPoolBussinessMobile{
private IPoolRepositoryMobile repPool;
public PoolBussinessMobile() {
this.repPool = new PoolRepositoryMobile();
}
/**
* Method that returns a Poll
* @param id - PollId
* @return - Poll
*/
public PollMobile getPool(int id) {
return repPool.getPool(id);
}
}
@@ -0,0 +1,248 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.facade;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.UserMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.util.Conversor;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Answer;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.AccessInfo;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.Person;
import br.ufpe.cin.amadeus.amadeus_web.exception.InvalidLogonException;
import br.ufpe.cin.amadeus.amadeus_web.facade.Facade;
public class AmadeusFacade{
private static AmadeusFacade facade;
private AmadeusFacade() {
}
public static AmadeusFacade getInstance() {
if (facade == null) {
facade = new AmadeusFacade();
}
return facade;
}
public UserMobile verifylogin(String login, String password) {
UserMobile user = null;
if (login != null && password != null) {
try {
AccessInfo ai = new AccessInfo();
ai.setLogin(login);
ai.setPassword(password);
ai = Facade.getInstance().logon(ai);
user = new UserMobile(ai.getId(), ai.getLogin(), ai.getPassword());
} catch (InvalidLogonException e) {
e.printStackTrace();
}
}
return user;
}
public ArrayList<String> findLoginsByCourse(int idCourse){
ArrayList<String> returnList = new ArrayList<String>();
Course c = Facade.getInstance().getCoursesById(idCourse);
List<Person> persons = Facade.getInstance().listStudentsByCourse(c);
persons.addAll(Facade.getInstance().listTeachersByCourse(c));
for (Person p : persons){
returnList.add(p.getAccessInfo().getLogin());
}
return returnList;
}
public List<br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile> listCourses(String login) {
List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course> coursesAm = null;
try {
AccessInfo ai = Facade.getInstance().searchUserByLogin(login);
coursesAm = Facade.getInstance().searchCoursesByAccessInfo(ai);
} catch (RuntimeException e) {
e.printStackTrace();
}
return Conversor.converterCursos(coursesAm);
}
public br.ufpe.cin.amadeus.amadeus_mobile.basics.ModuleMobile getModule(int idModule) {
br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Module mod = Facade.getInstance().getModuleById(idModule);
ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile> lista = new ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile>();
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Game g : mod.getGames()){
lista.add(Conversor.converterGameToHomework(g));
}
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Forum f : mod.getForums()){
lista.add(Conversor.converterForumToHomework(f));
}
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Poll p : mod.getPolls()){
lista.add(Conversor.converterPollToHomework(p));
}
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.LearningObject learning : mod.getLearningObjects()){
lista.add(Conversor.converterLearningObjectToHomework(learning));
}
br.ufpe.cin.amadeus.amadeus_mobile.basics.ModuleMobile m = Conversor.converterModulo(mod);
m.getHomeworks().addAll(lista);
return m;
}
public br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile getHomework(int idHome){
br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Homework home = Facade.getInstance().getHomeworkByID(idHome);
return Conversor.converterHomework(home);
}
public br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile getHomework(int id, String tipo){
br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile retorno = null;
if (tipo.equals(HomeworkMobile.HOMEWORK)){
retorno = Conversor.converterHomework(Facade.getInstance().getHomeworkByID(id));
}
else if (tipo.equals(HomeworkMobile.FORUM)){
retorno = Conversor.converterForumToHomework(Facade.getInstance().getForumById(id));
}
else if (tipo.equals(HomeworkMobile.POLL)){
retorno = Conversor.converterPollToHomework(Facade.getInstance().getPollByID(id));
}
else if (tipo.equals(HomeworkMobile.GAME)){
retorno = Conversor.converterGameToHomework(Facade.getInstance().getGameById(id));
}
return retorno;
}
public br.ufpe.cin.amadeus.amadeus_mobile.basics.PollMobile getPoll(int idPool){
br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Poll pl = Facade.getInstance().getPollByID(idPool);
return Conversor.converterPool(pl);
}
public br.ufpe.cin.amadeus.amadeus_mobile.basics.LearningObjectMobile getLearningObject (int idLearningObject){
br.ufpe.cin.amadeus.amadeus_web.domain.content_management.LearningObject learning = Facade.getInstance().getLearningObjectById(idLearningObject);
return Conversor.converterLearningObject(learning);
}
public br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile getCourse(int idC){
br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course c = Facade.getInstance().getCoursesById(idC);
return Conversor.converterCurso(c);
}
public br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile getPerson(String login){
br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile p = null;
try {
AccessInfo ai = Facade.getInstance().searchUserByLogin(login);
p = Conversor.converterPerson(ai.getPerson());
} catch (RuntimeException e) {
e.printStackTrace();
}
return p;
}
public ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile> getGamesLikeHomeworks(int idCourse){
ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile> retorno = new ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile>();
br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course c = Facade.getInstance().getCoursesById(idCourse);
List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Module> mods = c.getModules();
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Module m : mods){
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Game g : m.getGames()){
retorno.add(Conversor.converterGameToHomework(g));
}
}
return retorno;
}
public ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile> getForunsLikeHomeworks(int idCourse){
ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile> retorno = new ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile>();
br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course c = Facade.getInstance().getCoursesById(idCourse);
List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Module> mods = c.getModules();
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Module m : mods){
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Forum f : m.getForums()){
retorno.add(Conversor.converterForumToHomework(f));
}
}
return retorno;
}
public ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile> getPollsLikeHomeworks(int idCourse){
ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile> retorno = new ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile>();
br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course c = Facade.getInstance().getCoursesById(idCourse);
List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Module> mods = c.getModules();
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Module m : mods){
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Poll p : m.getPolls()){
retorno.add(Conversor.converterPollToHomework(p));
}
}
return retorno;
}
public ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile> getLearningObjectsLikeHomeworks(int idCourse){
ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile> retorno = new ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile>();
br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course c = Facade.getInstance().getCoursesById(idCourse);
List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Module> mods = c.getModules();
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Module m : mods){
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.LearningObject learning : m.getLearningObjects()){
retorno.add(Conversor.converterLearningObjectToHomework(learning));
}
}
return retorno;
}
public void updatePoll(String login, int id, List<br.ufpe.cin.amadeus.amadeus_mobile.basics.ChoiceMobile> choicesMM){
br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Poll pollAW = Facade.getInstance().getPollByID(id);
br.ufpe.cin.amadeus.amadeus_web.domain.register.Person personAW = Facade.getInstance().searchUserByLogin(login).getPerson();
br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Answer answerAW = new Answer();
answerAW.setPerson(personAW);
answerAW.setAnswerDate(new Date());
pollAW.getAnswers().add(answerAW);
for (int i = 0; i < pollAW.getChoices().size(); i++){
pollAW.getChoices().get(i).setVotes(choicesMM.get(i).getVotes());
pollAW.getChoices().get(i).setPercentage(choicesMM.get(i).getPercentage());
}
}
}
@@ -0,0 +1,231 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.facade;
import java.util.ArrayList;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.LearningObjectMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.MaterialMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.ModuleMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PollMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.UserMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.bussiness.CourseBussinessMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.bussiness.HomeworkBussinessMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.bussiness.LoginBussinessMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.bussiness.NoticeBussinessMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.bussiness.PoolBussinessMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.bussiness.ICourseBussinessMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.bussiness.IHomeworkBussinessMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.bussiness.ILoginBussinessMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.bussiness.INoticeBussinessMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.bussiness.IPoolBussinessMobile;
public class FacadeMobile {
private ILoginBussinessMobile cadLogin;
private ICourseBussinessMobile cadCurso;
private INoticeBussinessMobile cadNotice;
private IHomeworkBussinessMobile cadHomework;
private IPoolBussinessMobile cadPool;
private static FacadeMobile facade;
private static AmadeusFacade amadeusFacade;
public FacadeMobile() {
this.cadLogin = new LoginBussinessMobile();
this.cadCurso = new CourseBussinessMobile();
this.cadNotice = new NoticeBussinessMobile();
this.cadHomework = new HomeworkBussinessMobile();
this.cadPool = new PoolBussinessMobile();
}
public static FacadeMobile getInstance() {
if(facade == null) {
facade = new FacadeMobile();
}
if (amadeusFacade == null){
amadeusFacade = AmadeusFacade.getInstance();
}
return facade;
}
public UserMobile verifyLogin(String login, String senha) {
UserMobile user = amadeusFacade.verifylogin(login, senha);
return user;
}
public List<CourseMobile> listCourses(String login) {
// return cadCurso.listarCursos(login);
return amadeusFacade.listCourses(login);
}
public br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile getCourse(int idCourse, String login) {
return cadCurso.getCourse(idCourse, login);
}
public List<NoticeMobile> getNoticesCourse(int idCourse, String login) {
return cadNotice.getNoticesCourse(idCourse, login);
}
public List<NoticeMobile> getNoticesModule(int idModule, String login) {
return cadNotice.getNoticesModule(idModule, login);
}
public List<NoticeMobile> getNoticesAmadeus(String login) {
return cadNotice.getNoticesAmadeus(login);
}
public NoticeMobile getNotice(int idNotice, String login) {
return cadNotice.getNotice(idNotice, login);
}
public void addNotice(NoticeMobile n){
cadNotice.addNotice(n);
}
public NoticeMobile getNoticeSMS(int idNotice) {
return cadNotice.getNoticeSMS(idNotice);
}
public int existNotice(NoticeMobile not) {
return cadNotice.existNotice(not);
}
public ModuleMobile getModule(int idModule) {
return amadeusFacade.getModule(idModule);
}
public void updateCourse(CourseMobile c, String login){
cadCurso.updateCourse(c, login);
}
public HomeworkMobile getHomework(int id){
return amadeusFacade.getHomework(id);
}
public PollMobile getPoll(int id){
return amadeusFacade.getPoll(id);
}
public LearningObjectMobile getLearningObject (int id){
return amadeusFacade.getLearningObject(id);
}
public boolean sent(int idNotice) {
return cadNotice.sent(idNotice);
}
public int pagesQuantity(List elements) {
int size = elements.size();
int result = -1;
if(size <= 5) {
result = 1;
}else {
result = size / 5;
if(elements.size() % 5 != 0) {
result++;
}
}
return result;
}
//Método que retorna todas os homeworks e Enquetes do usuário
public List<Object> getAllCoursesActivities(String login) {
return this.cadCurso.getAllCoursesActivities(login);
}
//método que retorna todos os materiais de todos os cursos no qual o login está matriculado.
public List<MaterialMobile> getAllCoursesMaterials(String login){
return this.cadCurso.getAllCoursesMaterials(login);
}
// Método que retorna todas os homeworks e Enquetes do módulo do curso
public List<Object> getModuleActivities(int idModule) {
ModuleMobile m = this.getModule(idModule);
List<Object> l = new ArrayList<Object>();
l.addAll(m.getHomeworks());
return l;
}
// Método que retorna todas os homeworks e Enquetes do curso
public List<Object> getCourseActivities(int idCourse) {
List<Object> retorno = new ArrayList<Object>();
List<HomeworkMobile> homes = null;
br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile c = this.getCourse(idCourse, "bigode");
for (ModuleMobile mod : c.getModules()){
homes = mod.getHomeworks();
retorno.addAll(homes);
}
retorno.addAll(amadeusFacade.getForunsLikeHomeworks(idCourse));
retorno.addAll(amadeusFacade.getGamesLikeHomeworks(idCourse));
retorno.addAll(amadeusFacade.getPollsLikeHomeworks(idCourse));
retorno.addAll(amadeusFacade.getLearningObjectsLikeHomeworks(idCourse));
for(int i =0; i< retorno.size(); i++) {
HomeworkMobile h =(HomeworkMobile)retorno.get(i);
h.setIdCourse(idCourse);
retorno.set(i, h);
}
return retorno;
}
public void updatePoll(String login, int id, List<br.ufpe.cin.amadeus.amadeus_mobile.basics.ChoiceMobile> choices){
amadeusFacade.updatePoll(login, id, choices);
}
public PersonMobile getPerson(String login){
// return amadeusFacade.getPerson(login);
return cadLogin.getLogin(login);
}
public HomeworkMobile getHomework(int id, String tipo) {
return amadeusFacade.getHomework(id, tipo);
}
public void updateLogin(PersonMobile p){
cadLogin.updateLogin(p);
}
public PersonMobile getLogin(String login) {
return cadLogin.getLogin(login);
}
public void insertLogin(String login){
cadLogin.insertLogin(login);
}
public void updateNotice(NoticeMobile n, String login) {
cadNotice.updateNotice(n, login);
}
public int getLastId(int idCourse) {
return this.cadNotice.getLastId(idCourse);
}
}
@@ -0,0 +1,183 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.repository;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.ModuleMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.UserMobile;
public class CourseRepositoryMobile extends RepositoryMobile implements ICourseRepositoryMobile{
/**
* Constructor
* Creates a Database connection to the .reply Mobile DB
*/
public CourseRepositoryMobile(){
this.createConnectionDotReply();
}
/**
* Method that returns the User Course list
* @param login - User login
* @return - User course list
*/
public List<CourseMobile> listCourses(String login) {
Connection con = this.getConnectionDotReply();
List<CourseMobile> cursos = new ArrayList<CourseMobile>();
try {
String SQL = " select * from Curso where login like ?";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setString(1, login);
ResultSet rs = (ResultSet) pstmt.executeQuery();
while (rs.next()) {
String finalName = rs.getString("nome");
List<UserMobile> users = new ArrayList<UserMobile>();
CourseMobile u = new CourseMobile();
cursos.add(u);
}
con.close();
} catch (Exception e) {
e.printStackTrace();
}
return cursos;
}
/**
* Method that returns a specific User Course
* @param idCouse - Course ID
* @param login - User login
* @return - Course requested
*/
public CourseMobile getCourse(int idCourse, String login) {
Connection con = this.getConnectionDotReply();
CourseMobile retorno = null;
try {
String SQL = " select * from Course where idCourse = ? and login like ?";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setInt(1, idCourse);
pstmt.setString(2, login);
ResultSet rs = (ResultSet) pstmt.executeQuery();
while (rs.next()) {
retorno = new CourseMobile();
int id = rs.getInt("id");
String color = rs.getString("color");
boolean sms = rs.getBoolean("sms");
String loginTemp = rs.getString("login");
int idTemp = rs.getInt("idCourse");
retorno.setColor(color);
retorno.setId(id);
retorno.setSms(sms);
retorno.setLogin(loginTemp);
retorno.setIdCourse(idTemp);
}
con.close();
} catch (Exception e) {
e.printStackTrace();
}
return retorno;
}
/**
* Method that returns a the User Color List, used to display the information
* to the user it's predefined colored coursed
* @param login - User login
* @return - Color list (string)
*/
public List<String> getUserColors(String login) {
Connection con = this.getConnectionDotReply();
List<String> cores = new ArrayList<String>();
try {
String SQL = " select distinct(color) from course where login = ? and color is not null";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setString(1, login);
ResultSet rs = (ResultSet) pstmt.executeQuery();
while (rs.next()) {
String color = rs.getString("color");
cores.add(color);
}
con.close();
} catch (Exception e) {
e.printStackTrace();
}
return cores;
}
/**
* Method that returns a specific module, by its Id
* @param idModule - Module Id
* @return - requested module
*/
public ModuleMobile getModule(int idModule) {
// TODO Auto-generated method stub
return null;
}
/**
* Method that updates a User Course
* @param c - Course settings to be updated
* It's updated the Color and the user wants to receive the SMS for this course
* @param login - User that has the course
*/
public void updateCourse(CourseMobile c, String login) {
Connection con = this.getConnectionDotReply();
try {
String SQL = " update course set sms = ?, color = ? where idcourse = ? and login = ?";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setBoolean(1, c.getSms());
pstmt.setString(2, c.getColor());
pstmt.setInt(3, c.getId());
pstmt.setString(4, login);
pstmt.executeUpdate();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* Method that inserts a reference in the database adding a course to the user
* @param c - course which the user added
* @param login - user login
*/
public void insertCourse(CourseMobile c, String login) {
Connection con = this.getConnectionDotReply();
try {
String SQL = " insert into course(id,idcourse,login) values (nextval('sequencia_curso'),?,?)";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setInt(1, c.getId());
pstmt.setString(2, login);
pstmt.executeUpdate();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
@@ -0,0 +1,34 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.repository;
import java.util.Date;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile;
public class HomeworkRepositoryMobile implements IHomeworkRepositoryMobile{
/**
* Method that returns a Homework, giving it´s Id
* @param id - HomeWork Id
* @return Homework
*/
public HomeworkMobile getHomework(int id) {
Date d = new Date(10,10,10);
HomeworkMobile h1 = new HomeworkMobile(1,"exercicio 1","fazer os exercicios da classe 1",d,d,new Date(),1);
return h1;
}
}
@@ -0,0 +1,64 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.repository;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.ModuleMobile;
public interface ICourseRepositoryMobile {
/**
* Method that returns the User Course list
* @param login - User login
* @return - User course list
*/
public List<CourseMobile> listCourses(String login);
/**
* Method that returns a specific User Course
* @param idCouse - Course ID
* @param login - User login
* @return - Course requested
*/
public CourseMobile getCourse(int idCourse, String login);
/**
* Method that returns a specific module, by its Id
* @param idModule - Module Id
* @return - requested module
*/
public ModuleMobile getModule(int idModule);
/**
* Method that updates a User Course
* @param c - Course settings to be updated
* It's updated the Color and the user wants to receive the SMS for this course
* @param login - User that has the course
*/
public void updateCourse(CourseMobile c, String login);
/**
* Method that inserts a reference in the database adding a course to the user
* @param c - course which the user added
* @param login - user login
*/
public void insertCourse(CourseMobile c, String login);
/**
* Method that returns a the User Color List, used to display the information
* to the user it's predefined colored coursed
* @param login - User login
* @return - Color list (string)
*/
public List<String> getUserColors(String login);
}
@@ -0,0 +1,25 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.repository;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile;
public interface IHomeworkRepositoryMobile {
/**
* Method that returns a Homework, giving it´s Id
* @param id - HomeWork Id
* @return Homework
*/
public HomeworkMobile getHomework(int id);
}
@@ -0,0 +1,54 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.repository;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.UserMobile;
public interface ILoginRepositoryMobile {
/**
* Method that verifies the existence of a user and it´s password.
* If the user and password match on the database, returns the User
* Else returns null.
* @param login - User login
* @param password - User password
* @return - User
*/
public UserMobile verifyLogin(String login, String senha);
/**
* Method that update a cell number for the login passed
* @param login - User login
*/
public void updateLogin(PersonMobile p);
/**
* Method that verifies the existence of a login.
* If the login match on the database, returns the login
* Else returns null.
* @param login - User login
* @return - String login
*/
public PersonMobile getLogin(String login) ;
/**
* Method that insert a login for the login passed
* @param login - User login
*/
public void insertLogin(String login);
}
@@ -0,0 +1,87 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.repository;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
public interface INoticeRepositoryMobile {
/**
* Method that returns a Notice List from the User´s Course
* @param idCouse - Course Id
* @param login - User login
* @return - User´s Course Notice List
*/
public List<NoticeMobile> getNoticesCourse(int idCourse, String login);
/**
* Method that returns a Notice List from the User´s Module
* @param idModule - Module Id
* @param login - User login
* @return - User´s Module Notice List
*/
public List<NoticeMobile> getNoticesModule(int idModule, String login);
/**
* Method that returns the User Notice requested
* @param idNotice - Notice Id
* @param login - User login that has the Notice Id
* @return - Notice
*/
public NoticeMobile getNotice(int idNotice, String login);
/**
* Method that returns the AMADeUs Notice List for the User
* @param login - User login
* @return - Notice List
*/
public List<NoticeMobile> getNoticesAmadeus(String login);
/**
* Method that Adds a Notice
* @param notice - Notice to add
*/
public void addNotice(NoticeMobile notice);
/**
* Method that Updates a User Notice
* @param notice - Notice Updated
* @param login - User Login that has the Notice
*/
public void updateNotice(NoticeMobile n, String login);
/**
* Method that Checks if a Notice was sent
* @param idNotice - Notice Id
* @return - Boolean if the Notice was sent or not
*/
public boolean sent(int idNotice);
/**
* Method that returns the Notice requested
* @param idNotice - Notice Id
* @return - Notice
*/
public NoticeMobile getNoticeSMS(int idNotice);
/**
* Method that checks if there is a Notice. If exists, returns the Notice id.
* If it doesn't exist, returns -1
* @param not - Notice to be searched
* @return - Notice Id
*/
public int existNotice(NoticeMobile not);
/**
* Method that returns the last id of a notice of a determinated course inserted
* @param - idCurse
* @return - Notice Id
*/
public int getLastId(int idCourse);
}
@@ -0,0 +1,27 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.repository;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PollMobile;
public interface IPoolRepositoryMobile {
/**
* Method that returns a Poll
* @param id - PollId
* @return - Poll
*/
public PollMobile getPool(int id);
}
@@ -0,0 +1,104 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.repository;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.UserMobile;
public class LoginRepositoryMobile extends RepositoryMobile implements ILoginRepositoryMobile{
public LoginRepositoryMobile(){
this.createConnectionDotReply();
}
/**
* Method that verifies the existence of a user and it´s password.
* If the user and password match on the database, returns the User
* Else returns null.
* @param login - User login
* @param password - User password
* @return - User
*/
public UserMobile verifyLogin(String login, String senha) {
// TODO Auto-generated method stub
return null;
}
public void updateLogin(PersonMobile p) {
Connection con = this.getConnectionDotReply();
try {
String SQL = " update login_numero set numero_celular = ? where login = ?";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setString(1, p.getPhoneNumber());
pstmt.setString(2, p.getName());
pstmt.executeUpdate();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public PersonMobile getLogin(String login) {
Connection con = this.getConnectionDotReply();
PersonMobile retorno = null;
try {
String SQL = " select * from login_numero where login like ? ";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setString(1, login);
ResultSet rs = (ResultSet) pstmt.executeQuery();
while (rs.next()) {
retorno = new PersonMobile();
int id = rs.getInt("id");
String loginTemp = rs.getString("login");
String numero = rs.getString("numero_celular");
retorno.setId(id);
retorno.setName(loginTemp);
retorno.setPhoneNumber(numero);
}
con.close();
} catch (Exception e) {
e.printStackTrace();
}
return retorno;
}
public void insertLogin(String login) {
Connection con = this.getConnectionDotReply();
try {
String SQL = " insert into login_numero(id,login,numero_celular) values (nextval('sequencia_login_numero'),?,?)";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setString(1, login);
pstmt.setString(2, null);
pstmt.executeUpdate();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,426 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.repository;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
public class NoticeRepositoryMobile extends RepositoryMobile implements INoticeRepositoryMobile{
public NoticeRepositoryMobile(){
this.createConnectionDotReply();
}
/**
* Method that returns a Notice List from the User´s Course
* @param idCouse - Course Id
* @param login - User login
* @return - User´s Course Notice List
*/
public List<NoticeMobile> getNoticesCourse(int idCourse, String login) {
Connection con = this.getConnectionDotReply();
List<NoticeMobile> notices = new ArrayList<NoticeMobile>();
try {
String SQL = "SELECT * FROM notice notice, login_notice login " +
"WHERE notice.id = login.idnotice AND login.login = ? AND notice.idcourse = ? " +
"ORDER BY notice.date_creation";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setString(1, login);
pstmt.setInt(2, idCourse);
ResultSet rs = (ResultSet) pstmt.executeQuery();
NoticeMobile notice = null;
while (rs.next()) {
int id = rs.getInt("id");
String title = rs.getString("title");
String content = rs.getString("content");
int type = rs.getInt("type");
boolean lido = rs.getBoolean("isread");
Date data= rs.getDate("date_creation");
notice = new NoticeMobile();
notice.setId(id);
notice.setTitle(title);
notice.setContent(content);
notice.setType(type);
notice.setRead(lido);
notice.setDateCreation(data);
notices.add(notice);
}
con.close();
} catch (Exception e) {
e.printStackTrace();
}
return notices;
}
/**
* Method that returns a Notice List from the User´s Module
* @param idModule - Module Id
* @param login - User login
* @return - User´s Module Notice List
*/
public List<NoticeMobile> getNoticesModule(int idModule, String login) {
Connection con = this.getConnectionDotReply();
List<NoticeMobile> notices = new ArrayList<NoticeMobile>();
try {
String SQL = "SELECT * FROM notice notice, login_notice login " +
"WHERE notice.id = login.idnotice AND login.login = ? AND notice.idmodule = ? " +
"ORDER BY notice.date_creation";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setString(1, login);
pstmt.setInt(2, idModule);
ResultSet rs = (ResultSet) pstmt.executeQuery();
NoticeMobile notice = null;
while (rs.next()) {
int id = rs.getInt("id");
String title = rs.getString("title");
String content = rs.getString("content");
int type = rs.getInt("type");
boolean lido = rs.getBoolean("isread");
Date data= rs.getDate("date_creation");
notice = new NoticeMobile();
notice.setId(id);
notice.setTitle(title);
notice.setContent(content);
notice.setType(type);
notice.setRead(lido);
notice.setDateCreation(data);
notices.add(notice);
}
con.close();
} catch (Exception e) {
e.printStackTrace();
}
return notices;
}
/**
* Method that returns the User Notice requested
* @param idNotice - Notice Id
* @param login - User login that has the Notice Id
* @return - Notice
*/
public NoticeMobile getNotice(int idNotice, String login) {
Connection con = this.getConnectionDotReply();
NoticeMobile notice = null;
try {
String SQL = " select * from notice notice, login_notice login" +
" where login.idnotice = ? and " +
"login.login like ? and notice.id = login.idnotice ";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setInt(1, idNotice);
pstmt.setString(2, login);
ResultSet rs = (ResultSet) pstmt.executeQuery();
while (rs.next()) {
int id = rs.getInt("id");
String title = rs.getString("title");
String content = rs.getString("content");
int idModule = rs.getInt("idModule");
int idElemento = rs.getInt("idelement");
int type = rs.getInt("type");
boolean read = rs.getBoolean("isread");
Date data= rs.getDate("date_creation");
notice = new NoticeMobile();
notice.setId(id);
notice.setTitle(title);
notice.setContent(content);
notice.setType(type);
notice.setIdModule(idModule);
notice.setIdElement(idElemento);
notice.setRead(read);
notice.setDateCreation(data);
}
pstmt.close();
if(!notice.isRead()){
String sqlUpdate = "UPDATE login_notice SET isread=TRUE WHERE login=? AND idnotice=?";
PreparedStatement pstmtUpdate = (PreparedStatement) con.prepareStatement(sqlUpdate);
pstmtUpdate.setString(1, login);
pstmtUpdate.setInt(2, idNotice);
pstmtUpdate.executeUpdate();
pstmtUpdate.close();
notice.setRead(true);
}
con.commit();
con.close();
} catch (Exception e) {
e.printStackTrace();
}
return notice;
}
/**
* Method that returns the Notice requested
* @param idNotice - Notice Id
* @return - Notice
*/
public NoticeMobile getNoticeSMS(int idNotice) {
Connection con = this.getConnectionDotReply();
NoticeMobile notice = null;
try {
String SQL = " select * from notice notice where notice.id like ?";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setInt(1, idNotice);
ResultSet rs = (ResultSet) pstmt.executeQuery();
while (rs.next()) {
int id = rs.getInt("id");
String title = rs.getString("title");
String content = rs.getString("content");
int idModule = rs.getInt("idModule");
int type = rs.getInt("type");
//boolean read = rs.getBoolean("isread");
notice = new NoticeMobile();
notice.setId(id);
notice.setTitle(title);
notice.setContent(content);
notice.setType(type);
notice.setIdModule(idModule);
//notice.setRead(read);
}
con.close();
} catch (Exception e) {
e.printStackTrace();
}
return notice;
}
/**
* Method that returns the AMADeUs Notice List for the User
* @param login - User login
* @return - Notice List
*/
public List<NoticeMobile> getNoticesAmadeus(String login) {
Connection con = this.getConnectionDotReply();
NoticeMobile notice = null;
List<NoticeMobile> notices = new ArrayList<NoticeMobile>();
try {
String SQL = " select * from notice notice, login_notice login" +
" where notice.type = ? and " +
"login.login like ? and notice.id = login.idnotice";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setInt(1, NoticeMobile.TIPO_AMADEUS);
pstmt.setString(2, login);
ResultSet rs = (ResultSet) pstmt.executeQuery();
while (rs.next()) {
int id = rs.getInt("id");
String title = rs.getString("title");
String content = rs.getString("content");
int idModule = rs.getInt("idModule");
int type = rs.getInt("type");
boolean read = rs.getBoolean("isread");
Date data= rs.getDate("date_creation");
notice = new NoticeMobile();
notice.setId(id);
notice.setTitle(title);
notice.setContent(content);
notice.setType(type);
notice.setIdModule(idModule);
notice.setRead(read);
notice.setDateCreation(data);
notices.add(notice);
}
con.close();
} catch (Exception e) {
e.printStackTrace();
}
return notices;
}
/**
* Method that Adds a Notice
* @param notice - Notice to add
* Notice.Type => [Atividade] = 0
* [Curso] = 1
* [Material] = 2
* [Enquete] = 3
*/
public void addNotice(NoticeMobile notice) {
Connection con = this.getConnectionDotReply();
java.sql.Date date = new java.sql.Date(notice.getDateCreation().getTime());
try {
PreparedStatement ps = (PreparedStatement) con.prepareStatement("INSERT INTO notice(id, title, content, " +
"idmodule, idcourse, type, idelement, date_creation, sent) values (nextval('sequence_notice'), " +
"?, ?, ?, ?, ?, ?, ?, ?)");
ps.setString(1, notice.getTitle());
ps.setString(2, notice.getContent());
ps.setInt(3, notice.getIdModule());
ps.setInt(4, notice.getIdCourse());
ps.setInt(5, notice.getType());
ps.setInt(6, notice.getIdElement());
ps.setDate(7, date);
ps.setBoolean(8, false);
ps.executeUpdate();
ArrayList<String> logins = AmadeusFacade.getInstance().findLoginsByCourse(notice.getIdCourse());
PreparedStatement ps1 = (PreparedStatement) con.prepareStatement("INSERT INTO login_notice(id_key, login, idnotice, isread)" +
" VALUES (nextval('sequencia_login_notice'),?,?,?)");
for (String login : logins){
ps1.setString(1, login);
ps1.setInt(2, notice.getId());
ps1.setBoolean(3, notice.isRead());
ps1.executeUpdate();
ps1.clearParameters();
}
ps.close();
ps1.close();
con.close();
} catch(Exception e) {
e.printStackTrace();
}
}
/**
* Method that Updates a User Notice
* @param notice - Notice Updated
* @param login - User Login that has the Notice
*/
public void updateNotice(NoticeMobile notice, String login) {
Connection con = this.getConnectionDotReply();
try {
String SQL = " update notice set title = ?, content = ?, idmodule = ?, idcourse = ?, type = ?, idelement = ?, date_creation = ?, sent = ? where id = ? and login = ?";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setString(1, notice.getTitle());
pstmt.setString(2, notice.getContent());
pstmt.setInt(3, notice.getIdModule());
pstmt.setInt(4, notice.getIdCourse());
pstmt.setInt(5, notice.getType());
pstmt.setInt(6, notice.getIdElement());
pstmt.setDate(7, new java.sql.Date(notice.getDateCreation().getTime()));
pstmt.setBoolean(8, false);
pstmt.setInt(9, notice.getId());
pstmt.setString(10, login);
pstmt.executeUpdate();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* Method that Checks if a Notice was sent
* @param idNotice - Notice Id
* @return - Boolean if the Notice was sent or not
*/
public boolean sent(int idNotice) {
boolean sent = false;
Connection con = this.getConnectionDotReply();
try {
PreparedStatement ps = (PreparedStatement) con.prepareStatement("SELECT * FROM notice WHERE id = ?");
ps.setInt(1, idNotice);
ResultSet rs = ps.executeQuery();
if(rs.next()) {
sent = rs.getBoolean("sent");
}
}catch(Exception e) {
e.printStackTrace();
}
return sent;
}
/**
* Method that checks if there is a Notice. If exists, returns the Notice id.
* If it doesn't exist, returns -1
* @param not - Notice to be searched
* @return - Notice Id
*/
public int existNotice(NoticeMobile not){
int retorno = -1;
Connection con = this.getConnectionDotReply();
try {
String SQL = "SELECT id FROM notice WHERE title=? AND content=? AND " +
"idmodule=? AND idcourse=? AND type=? AND idelement=? AND date_creation=?";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setString(1, not.getTitle());
pstmt.setString(2, not.getContent());
pstmt.setInt(3, not.getIdModule());
pstmt.setInt(4, not.getIdCourse());
pstmt.setInt(5, not.getType());
pstmt.setInt(6, not.getIdElement());
java.sql.Date dt = new java.sql.Date(not.getDateCreation().getTime());
pstmt.setDate(7, dt);
ResultSet rs = (ResultSet) pstmt.executeQuery();
if (rs.next()){
retorno = rs.getInt("id");
}
con.close();
} catch (Exception e) {
e.printStackTrace();
}
return retorno;
}
public static void main(String[] args) {
NoticeMobile n1 = new NoticeMobile(1, "Teste de usuarios","estamos atrasados",1, 1500, 3, false, 0, new Date(2005, 10, 23));
NoticeRepositoryMobile rn = new NoticeRepositoryMobile();
rn.addNotice(n1);
}
/**
* Method that returns the last id of a course notice
* @param idCouse - Course Id
* @param login - User login
* @return - User´s Course Notice List
*/
public int getLastId(int idCourse) {
Connection con = this.getConnectionDotReply();
int id = -1;
try {
String SQL = "SELECT MAX(notice.id) as id FROM notice " +
"WHERE notice.idcourse = ?";
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement(SQL);
pstmt.setInt(1, idCourse);
ResultSet rs = (ResultSet) pstmt.executeQuery();
if (rs.next()) {
id = rs.getInt("id");
}
con.close();
} catch (Exception e) {
e.printStackTrace();
}
return id;
}
}
@@ -0,0 +1,52 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.repository;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.ChoiceMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PollMobile;
public class PoolRepositoryMobile implements IPoolRepositoryMobile{
/**
* Method that returns a Poll
* @param id - PollId
* @return - Poll
*/
public PollMobile getPool(int id) {
PollMobile p = new PollMobile();
p.setId(1);
p.setName("Linguagens para projeto");
p.setFinishDate(new Date(Calendar.getInstance().getTimeInMillis()));
p.setInitDate(new Date(Calendar.getInstance().getTimeInMillis()));
p.setQuestion("Qual a liguagem de sua preferência para este projeto?");
List<ChoiceMobile> choices = new ArrayList<ChoiceMobile>();
ChoiceMobile c1 = new ChoiceMobile(1, "Java",0, 0);
ChoiceMobile c2 = new ChoiceMobile(2, "C++",0, 0);
ChoiceMobile c3 = new ChoiceMobile(3, "Python",0, 0);
ChoiceMobile c4 = new ChoiceMobile(4, "Outra",0, 0);
choices.add(c1);
choices.add(c2);
choices.add(c3);
choices.add(c4);
p.setChoices(choices);
return p;
}
}
@@ -0,0 +1,50 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo � parte do programa Amadeus Sistema de Gest�o de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS � um software livre; voc� pode redistribui-lo e/ou modifica-lo dentro dos termos da Licen�a P�blica Geral GNU como
publicada pela Funda��o do Software Livre (FSF); na vers�o 2 da Licen�a.
Este programa � distribu�do na esperan�a que possa ser �til, mas SEM NENHUMA GARANTIA; sem uma garantia impl�cita de ADEQUA��O a qualquer MERCADO ou APLICA��O EM PARTICULAR. Veja a Licen�a P�blica Geral GNU para maiores detalhes.
Voc� deve ter recebido uma c�pia da Licen�a P�blica Geral GNU, sob o t�tulo "LICENCA.txt", junto com este programa, se n�o, escreva para a Funda��o do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.repository;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import br.ufpe.cin.amadeus.amadeus_mobile.settings.MobileSettings;
public class RepositoryMobile {
public static final MobileSettings mobileSettings = MobileSettings.getInstance();
private Connection connectionDotReply;
public void createConnectionDotReply() {
try {
Class.forName(mobileSettings.getDatabaseDriverClass());
this.connectionDotReply = (Connection) DriverManager.getConnection(
mobileSettings.getDatabaseUrl(), mobileSettings.getDatabaseUsername(), mobileSettings.getDatabasePassword());
} catch (ClassNotFoundException e) {
System.out.println("O driver especificado não foi encontrado.");
} catch (SQLException e) {
System.out.println("Não foi possível conectar-se ao Banco de Dados");
}
}
public Connection getConnectionDotReply() {
createConnectionDotReply();
return connectionDotReply;
}
public void setConnectionDotReply(Connection connectionDotReply) {
this.connectionDotReply = connectionDotReply;
}
}
@@ -0,0 +1,81 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo parte do programa Amadeus Sistema de Gesto de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS um software livre; voc pode redistribui-lo e/ou modifica-lo dentro dos termos da Licena Pblica Geral GNU como
publicada pela Fundao do Software Livre (FSF); na verso 2 da Licena.
Este programa distribudo na esperana que possa ser til, mas SEM NENHUMA GARANTIA; sem uma garantia implcita de ADEQUAO a qualquer MERCADO ou APLICAO EM PARTICULAR. Veja a Licena Pblica Geral GNU para maiores detalhes.
Voc deve ter recebido uma cpia da Licena Pblica Geral GNU, sob o ttulo "LICENCA.txt", junto com este programa, se no, escreva para a Fundao do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.settings;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
public class MobileSettings extends XMLConfiguration {
public static MobileSettings instance;
//Database connection settings
private String databaseDriverClass;
private String databaseUrl;
private String databaseUsername;
private String databasePassword;
private MobileSettings(String path) throws ConfigurationException {
super(path);
}
public static MobileSettings getInstance() {
if(instance == null) {
try {
instance = new MobileSettings("settings/amadeus.mobile.settings.xml");
} catch (ConfigurationException e) {
e.printStackTrace();
}
}
return instance;
}
public String getDatabaseDriverClass() {
this.databaseDriverClass = this.getString("database-connection.driver-class");
return this.databaseDriverClass;
}
public void setDatabaseDriverClass(String driverClass) {
this.databaseDriverClass = driverClass;
}
public String getDatabaseUrl() {
this.databaseUrl = this.getString("database-connection.url");
return this.databaseUrl;
}
public void setDatabaseUrl(String url) {
this.databaseUrl = url;
}
public String getDatabaseUsername() {
this.databaseUsername = this.getString("database-connection.username");
return this.databaseUsername;
}
public void setDatabaseUsername(String username) {
this.databaseUsername = username;
}
public String getDatabasePassword() {
this.databasePassword = this.getString("database-connection.password");
return databasePassword;
}
public void setDatabasePassword(String password) {
this.databasePassword = password;
}
}
@@ -0,0 +1,73 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import sun.awt.windows.ThemeReader;
public class AddCourseThread extends Thread {
private NoticeMobile sms;
private FacadeMobile fac;
private String courseName;
public AddCourseThread(NoticeMobile notice, String courseName) {
super();
this.sms = notice;
this.courseName = courseName;;
this.fac = FacadeMobile.getInstance();
}
public NoticeMobile getSms() {
return sms;
}
public void setSms(NoticeMobile sms) {
this.sms = sms;
}
public boolean check() {
boolean check = false;
for(Thread t : Receiver.threads) {
if(t instanceof AddCourseThread) {
if(((AddCourseThread)t).equals(this)) continue;
if(((AddCourseThread)t).getSms().getIdCourse() == this.getSms().getIdCourse()) {
check = true;
}
}
}
return check;
}
public void run() {
long time = 20000;
long initialTime = System.currentTimeMillis();
System.out.println("comecou");
while((System.currentTimeMillis() - initialTime) < time) {}
if(!this.check()) {
System.out.println("!check");
Sender sender = new Sender();
sender.createSMS(this.sms, this.courseName);
} else {
System.err.println("não enviou");
}
this.interrupt();
Receiver.threads.remove(this);
}
}
@@ -0,0 +1,73 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import sun.awt.windows.ThemeReader;
public class AddHomeworkThread extends Thread {
private NoticeMobile sms;
private FacadeMobile fac;
private String courseName;
public AddHomeworkThread(NoticeMobile notice, String courseName) {
super();
this.sms = notice;
this.courseName = courseName;;
this.fac = FacadeMobile.getInstance();
}
public NoticeMobile getSms() {
return sms;
}
public void setSms(NoticeMobile sms) {
this.sms = sms;
}
public boolean check() {
boolean check = false;
for(Thread t : Receiver.threads) {
if(t instanceof AddHomeworkThread) {
if(((AddHomeworkThread)t).equals(this)) continue;
if(((AddHomeworkThread)t).getSms().getIdCourse() == this.getSms().getIdCourse()) {
check = true;
}
}
}
return check;
}
public void run() {
long time = 20000;
long initialTime = System.currentTimeMillis();
System.out.println("comecou");
while((System.currentTimeMillis() - initialTime) < time) {}
if(!this.check()) {
System.out.println("!check");
Sender sender = new Sender();
sender.createSMS(this.sms, this.courseName);
} else {
System.err.println("não enviou");
}
this.interrupt();
Receiver.threads.remove(this);
}
}
@@ -0,0 +1,73 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import sun.awt.windows.ThemeReader;
public class AddMaterialThread extends Thread {
private NoticeMobile sms;
private FacadeMobile fac;
private String courseName;
public AddMaterialThread(NoticeMobile notice, String courseName) {
super();
this.sms = notice;
this.courseName = courseName;;
this.fac = FacadeMobile.getInstance();
}
public NoticeMobile getSms() {
return sms;
}
public void setSms(NoticeMobile sms) {
this.sms = sms;
}
public boolean check() {
boolean check = false;
for(Thread t : Receiver.threads) {
if(t instanceof AddMaterialThread) {
if(((AddMaterialThread)t).equals(this)) continue;
if(((AddMaterialThread)t).getSms().getIdCourse() == this.getSms().getIdCourse()) {
check = true;
}
}
}
return check;
}
public void run() {
long time = 20000;
long initialTime = System.currentTimeMillis();
System.out.println("comecou");
while((System.currentTimeMillis() - initialTime) < time) {}
if(!this.check()) {
System.out.println("!check");
Sender sender = new Sender();
sender.createSMS(this.sms, this.courseName);
} else {
System.err.println("não enviou");
}
this.interrupt();
Receiver.threads.remove(this);
}
}
@@ -0,0 +1,73 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import sun.awt.windows.ThemeReader;
public class AddModuleThread extends Thread {
private NoticeMobile sms;
private FacadeMobile fac;
private String courseName;
public AddModuleThread(NoticeMobile notice, String courseName) {
super();
this.sms = notice;
this.courseName = courseName;;
this.fac = FacadeMobile.getInstance();
}
public NoticeMobile getSms() {
return sms;
}
public void setSms(NoticeMobile sms) {
this.sms = sms;
}
public boolean check() {
boolean check = false;
for(Thread t : Receiver.threads) {
if(t instanceof AddModuleThread) {
if(((AddModuleThread)t).equals(this)) continue;
if(((AddModuleThread)t).getSms().getIdCourse() == this.getSms().getIdCourse()) {
check = true;
}
}
}
return check;
}
public void run() {
long time = 20000;
long initialTime = System.currentTimeMillis();
System.out.println("comecou");
while((System.currentTimeMillis() - initialTime) < time) {}
if(!this.check()) {
System.out.println("!check");
Sender sender = new Sender();
sender.createSMS(this.sms, this.courseName);
} else {
System.err.println("não enviou");
}
this.interrupt();
Receiver.threads.remove(this);
}
}
@@ -0,0 +1,73 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import sun.awt.windows.ThemeReader;
public class AddPollThread extends Thread {
private NoticeMobile sms;
private FacadeMobile fac;
private String courseName;
public AddPollThread(NoticeMobile notice, String courseName) {
super();
this.sms = notice;
this.courseName = courseName;;
this.fac = FacadeMobile.getInstance();
}
public NoticeMobile getSms() {
return sms;
}
public void setSms(NoticeMobile sms) {
this.sms = sms;
}
public boolean check() {
boolean check = false;
for(Thread t : Receiver.threads) {
if(t instanceof AddPollThread) {
if(((AddPollThread)t).equals(this)) continue;
if(((AddPollThread)t).getSms().getIdCourse() == this.getSms().getIdCourse()) {
check = true;
}
}
}
return check;
}
public void run() {
long time = 20000;
long initialTime = System.currentTimeMillis();
System.out.println("comecou");
while((System.currentTimeMillis() - initialTime) < time) {}
if(!this.check()) {
System.out.println("!check");
Sender sender = new Sender();
sender.createSMS(this.sms, this.courseName);
} else {
System.err.println("não enviou");
}
this.interrupt();
Receiver.threads.remove(this);
}
}
@@ -0,0 +1,73 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import sun.awt.windows.ThemeReader;
public class AssistentsUpdateThread extends Thread {
private NoticeMobile sms;
private FacadeMobile fac;
private String courseName;
public AssistentsUpdateThread(NoticeMobile notice, String courseName) {
super();
this.sms = notice;
this.courseName = courseName;;
this.fac = FacadeMobile.getInstance();
}
public NoticeMobile getSms() {
return sms;
}
public void setSms(NoticeMobile sms) {
this.sms = sms;
}
public boolean check() {
boolean check = false;
for(Thread t : Receiver.threads) {
if(t instanceof AssistentsUpdateThread) {
if(((AssistentsUpdateThread)t).equals(this)) continue;
if(((AssistentsUpdateThread)t).getSms().getIdCourse() == this.getSms().getIdCourse()) {
check = true;
}
}
}
return check;
}
public void run() {
long time = 20000;
long initialTime = System.currentTimeMillis();
System.out.println("comecou");
while((System.currentTimeMillis() - initialTime) < time) {}
if(!this.check()) {
System.out.println("!check");
Sender sender = new Sender();
sender.createSMS(this.sms, this.courseName);
} else {
System.err.println("não enviou");
}
this.interrupt();
Receiver.threads.remove(this);
}
}
@@ -0,0 +1,73 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import sun.awt.windows.ThemeReader;
public class CourseUpdateThread extends Thread {
private NoticeMobile sms;
private FacadeMobile fac;
private String courseName;
public CourseUpdateThread(NoticeMobile notice, String courseName) {
super();
this.sms = notice;
this.courseName = courseName;;
this.fac = FacadeMobile.getInstance();
}
public NoticeMobile getSms() {
return sms;
}
public void setSms(NoticeMobile sms) {
this.sms = sms;
}
public boolean check() {
boolean check = false;
for(Thread t : Receiver.threads) {
if(t instanceof CourseUpdateThread) {
if(((CourseUpdateThread)t).equals(this)) continue;
if(((CourseUpdateThread)t).getSms().getIdCourse() == this.getSms().getIdCourse()) {
check = true;
}
}
}
return check;
}
public void run() {
long time = 20000;
long initialTime = System.currentTimeMillis();
System.out.println("comecou");
while((System.currentTimeMillis() - initialTime) < time) {}
if(!this.check()) {
System.out.println("!check");
Sender sender = new Sender();
sender.createSMS(this.sms, this.courseName);
} else {
System.err.println("não enviou");
}
this.interrupt();
Receiver.threads.remove(this);
}
}
@@ -0,0 +1,73 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import sun.awt.windows.ThemeReader;
public class HomeworkUpdateThread extends Thread {
private NoticeMobile sms;
private FacadeMobile fac;
private String courseName;
public HomeworkUpdateThread(NoticeMobile notice, String courseName) {
super();
this.sms = notice;
this.courseName = courseName;;
this.fac = FacadeMobile.getInstance();
}
public NoticeMobile getSms() {
return sms;
}
public void setSms(NoticeMobile sms) {
this.sms = sms;
}
public boolean check() {
boolean check = false;
for(Thread t : Receiver.threads) {
if(t instanceof HomeworkUpdateThread) {
if(((HomeworkUpdateThread)t).equals(this)) continue;
if(((HomeworkUpdateThread)t).getSms().getIdCourse() == this.getSms().getIdCourse()) {
check = true;
}
}
}
return check;
}
public void run() {
long time = 20000;
long initialTime = System.currentTimeMillis();
System.out.println("comecou");
while((System.currentTimeMillis() - initialTime) < time) {}
if(!this.check()) {
System.out.println("!check");
Sender sender = new Sender();
sender.createSMS(this.sms, this.courseName);
} else {
System.err.println("não enviou");
}
this.interrupt();
Receiver.threads.remove(this);
}
}
@@ -0,0 +1,73 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import sun.awt.windows.ThemeReader;
public class PollUpdateThread extends Thread {
private NoticeMobile sms;
private FacadeMobile fac;
private String courseName;
public PollUpdateThread(NoticeMobile notice, String courseName) {
super();
this.sms = notice;
this.courseName = courseName;;
this.fac = FacadeMobile.getInstance();
}
public NoticeMobile getSms() {
return sms;
}
public void setSms(NoticeMobile sms) {
this.sms = sms;
}
public boolean check() {
boolean check = false;
for(Thread t : Receiver.threads) {
if(t instanceof PollUpdateThread) {
if(((PollUpdateThread)t).equals(this)) continue;
if(((PollUpdateThread)t).getSms().getIdCourse() == this.getSms().getIdCourse()) {
check = true;
}
}
}
return check;
}
public void run() {
long time = 20000;
long initialTime = System.currentTimeMillis();
System.out.println("comecou");
while((System.currentTimeMillis() - initialTime) < time) {}
if(!this.check()) {
System.out.println("!check");
Sender sender = new Sender();
sender.createSMS(this.sms, this.courseName);
} else {
System.err.println("não enviou");
}
this.interrupt();
Receiver.threads.remove(this);
}
}
@@ -0,0 +1,353 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.ModuleMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import br.ufpe.cin.amadeus.amadeus_web.struts.messages.Messages;
public class Receiver {
private AmadeusFacade amadeusFacade;
private FacadeMobile facade;
public static ArrayList<Thread> threads = new ArrayList<Thread>();
public Receiver() {
this.amadeusFacade = AmadeusFacade.getInstance();
this.facade = FacadeMobile.getInstance();
}
private String truncate(String target, int maxSize) {
return (target.length() > maxSize ? target.substring(0, maxSize-3)+"..." : target);
}
/**
* Creates generic SMS messages about the course informations
* determina
* @param messageType
* @param courseName
* @return
*/
private String createMessage(String messageType, String courseName) {
String sms = Messages.getString(messageType);
return "[" + this.truncate(courseName, 130-sms.length()) + "] " + sms;
}
/**
* Creates specifics SMS messages about the module
* @param messageType
* @param courseName
* @param moduleNumber
* @return
*/
private String createMessage(String messageType, String courseName, int moduleNumber) {
String sms = Messages.getString(messageType);
return "[" + this.truncate(courseName, 130-sms.length()) + ", Módulo "+moduleNumber+"] " + sms;
}
/**
* Method that alters the course information
* @param courseId - Course id
*/
public void updatedCourse(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course course) {
String courseName = course.getName();
String sms = this.createMessage("mobile.course.courseUpdate", courseName);
java.util.Date date = new java.util.Date(System.currentTimeMillis());
NoticeMobile notice = new NoticeMobile("Atualização de Curso", sms, -1, course.getId(), 1, false, -1, date);
CourseUpdateThread thread = new CourseUpdateThread(notice, courseName);
this.threads.add(thread);
thread.start();
}
/**
* Method that updates the Teachers inside a Course
* @param courseId - Course Id
*/
public void teachersUpdate(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course course) {
String courseName = course.getName();
String sms = this.createMessage("mobile.course.teachersUpdate", courseName);
java.util.Date date = new java.util.Date(System.currentTimeMillis());
NoticeMobile notice = new NoticeMobile("Alteração de Professor", sms, -1, course.getId(), 1, false, -1, date);
TeacherUpdateThread thread = new TeacherUpdateThread(notice, courseName);
this.threads.add(thread);
thread.start();
}
/**
* Method that changes the Course Assistants in a Course
* @param courseId - Course Id
*/
public void assistentsUpdate(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course course) {
String courseName = course.getName();
String sms = this.createMessage("mobile.course.assistentsUpdate", courseName);
java.util.Date date = new java.util.Date(System.currentTimeMillis());
NoticeMobile notice = new NoticeMobile("Alteração de Assistente", sms, -1, course.getId(), 1, false, -1, date);
AssistentsUpdateThread thread = new AssistentsUpdateThread(notice, courseName);
this.threads.add(thread);
thread.start();
}
/**
* Method that Adds a Module in a Course
* @param courseId - Course Id
* @param moduleId - Module Id
*/
public void addModule(int courseId, int moduleId) {
String courseName = this.amadeusFacade.getCourse(courseId).getName();
String moduleName = this.amadeusFacade.getModule(moduleId).getNome();
String sms = this.createMessage("mobile.course.newModule", courseName);
sms = sms + this.truncate(moduleName, 130-sms.length());
java.util.Date date = new java.util.Date(System.currentTimeMillis());
NoticeMobile notice = new NoticeMobile("Inserção de Módulo", sms, moduleId, courseId, 1, false, -1, date);
AddModuleThread thread = new AddModuleThread(notice, courseName);
this.threads.add(thread);
thread.start();
}
/**
* Method that Removes a Module in a Course
* @param courseId - Course Id
* @param moduleId - Module Id
*/
public void removeModule(int courseId, int moduleId) {
String courseName = this.amadeusFacade.getCourse(courseId).getName();
String moduleName = this.amadeusFacade.getModule(moduleId).getNome();
String sms = this.createMessage("mobile.course.deletedModule", courseName);
sms = sms + this.truncate(moduleName, 130-sms.length());
java.util.Date date = new java.util.Date(System.currentTimeMillis());
NoticeMobile notice = new NoticeMobile("Remoção de Módulo", sms, moduleId, courseId, 1, false, -1, date);
RemoveModuleThread thread = new RemoveModuleThread(notice, courseName);
this.threads.add(thread);
thread.start();
}
/**
* Method that Adds a Material in a Module
* @param courseId - Course Id
* @param moduleId - Module Id
* @param materialId - Material Id
*/
public void addMaterial(int courseId, int moduleId, int materialId) {
CourseMobile course = this.amadeusFacade.getCourse(courseId);
String courseName = course.getName();
int modNumber = getModuleNumber(moduleId, course);
String sms = this.createMessage("mobile.course.newMaterial", courseName, modNumber);
java.util.Date date = new java.util.Date(System.currentTimeMillis());
NoticeMobile notice = new NoticeMobile("Material Adicionado", sms, moduleId, courseId, 2, false, materialId, date);
AddMaterialThread thread = new AddMaterialThread(notice, courseName);
this.threads.add(thread);
thread.start();
}
/**
* Returns the module number corresponding to the course
* @param moduleId
* @param course
* @return
*/
private int getModuleNumber(int moduleId, CourseMobile course) {
int modNumber = 1;
for (ModuleMobile m : course.getModules()) {
if (m.getId() == moduleId) break;
else modNumber++;
}
return modNumber;
}
/**
* Method that Removes a Material in a Module
* @param courseId - Course Id
* @param moduleId - Module Id
* @param materialId - Material Id
*/
public void removeMaterial(int courseId, int moduleId, int materialId) {
CourseMobile course = this.amadeusFacade.getCourse(courseId);
String courseName = course.getName();
int modNumber = getModuleNumber(moduleId, course);
String sms = this.createMessage("mobile.course.deletedMaterial", courseName, modNumber);
java.util.Date date = new java.util.Date(System.currentTimeMillis());
NoticeMobile notice = new NoticeMobile("Matarial Removido", sms, moduleId, courseId, 2, false, materialId, date);
RemoveMaterialThread thread = new RemoveMaterialThread(notice, courseName);
this.threads.add(thread);
thread.start();
}
/**
* Method that Adds a Homework in a Module
* @param courseId - Course Id
* @param moduleId - Module Id
* @param homeworkId - Homework Id
*/
public void addHomework(int courseId, int moduleId, int homeworkId) {
CourseMobile course = this.amadeusFacade.getCourse(courseId);
String courseName = course.getName();
int modNumber = getModuleNumber(moduleId, course);
String sms = this.createMessage("mobile.course.newActivity", courseName, modNumber);
java.util.Date date = new java.util.Date(System.currentTimeMillis());
NoticeMobile notice = new NoticeMobile("Atividade Adicionada", sms, moduleId, courseId, 0, false, homeworkId, date);
AddHomeworkThread thread = new AddHomeworkThread(notice, courseName);
this.threads.add(thread);
thread.start();
}
/**
* Method that Removes a Homework in a Module
* @param courseId - Course Id
* @param moduleId - Module Id
* @param homeworkId - Homework Id
*/
public void removeHomework(int courseId, int moduleId, int homeworkId) {
CourseMobile course = this.amadeusFacade.getCourse(courseId);
String courseName = course.getName();
int modNumber = getModuleNumber(moduleId, course);
String sms = this.createMessage("mobile.course.deletedActivity", courseName, modNumber);
java.util.Date date = new java.util.Date(System.currentTimeMillis());
NoticeMobile notice = new NoticeMobile("Atividade Removida", sms, moduleId, courseId, 0, false, homeworkId, date);
RemoveHomeworkThread thread = new RemoveHomeworkThread(notice, courseName);
this.threads.add(thread);
thread.start();
}
/**
* Method that Updates a Homework in a Module
* @param courseId - Course Id
* @param moduleId - Module Id
* @param homeworkId - Homework Id
*/
public void homeworkUpdate(int courseId, int moduleId, int homeworkId) {
CourseMobile course = this.amadeusFacade.getCourse(courseId);
String courseName = course.getName();
int modNumber = getModuleNumber(moduleId, course);
String sms = this.createMessage("mobile.course.activityUpdate", courseName, modNumber);
java.util.Date date = new java.util.Date(System.currentTimeMillis());
NoticeMobile notice = new NoticeMobile("Atividade Atualizada", sms, moduleId, courseId, 0, false, homeworkId, date);
HomeworkUpdateThread thread = new HomeworkUpdateThread(notice, courseName);
this.threads.add(thread);
thread.start();
}
/**
* Method that Inserts a Poll in a Module
* @param courseId - Course Id
* @param moduleId - Module Id
* @param pollId - Poll Id
*/
public void addPoll(int courseId, int moduleId, int pollId) {
CourseMobile course = this.amadeusFacade.getCourse(courseId);
String courseName = course.getName();
int modNumber = getModuleNumber(moduleId, course);
String sms = this.createMessage("mobile.course.newPoll", courseName, modNumber);
java.util.Date date = new java.util.Date(System.currentTimeMillis());
NoticeMobile notice = new NoticeMobile("Enquete Adicionada", sms, moduleId, courseId, 0, false, pollId, date);
AddPollThread thread = new AddPollThread(notice, courseName);
this.threads.add(thread);
thread.start();
}
/**
* Method that Removes a Poll in a Module
* @param courseId - Course Id
* @param moduleId - Module Id
* @param pollId - Poll Id
*/
public void removePoll(int courseId, int moduleId, int pollId) {
CourseMobile course = this.amadeusFacade.getCourse(courseId);
String courseName = course.getName();
int modNumber = getModuleNumber(moduleId, course);
String sms = this.createMessage("mobile.course.deletedPoll", courseName, modNumber);
java.util.Date date = new java.util.Date(System.currentTimeMillis());
NoticeMobile notice = new NoticeMobile("Enquete Removida", sms, moduleId, courseId, 0, false, pollId, date);
RemovePollThread thread = new RemovePollThread(notice, courseName);
this.threads.add(thread);
thread.start();
}
/**
* Method that Alters a Poll in a Module
* @param courseId - Course Id
* @param moduleId - Module Id
* @param pollId - Poll Id
*/
public void pollUpdate(int courseId, int moduleId, int pollId) {
CourseMobile course = this.amadeusFacade.getCourse(courseId);
String courseName = course.getName();
int modNumber = getModuleNumber(moduleId, course);
String sms = this.createMessage("mobile.course.pollUpdate", courseName, modNumber);
java.util.Date date = new java.util.Date(System.currentTimeMillis());
NoticeMobile notice = new NoticeMobile("Enquete Atualizada", sms, moduleId, courseId, 0, false, pollId, date);
PollUpdateThread thread = new PollUpdateThread(notice, courseName);
this.threads.add(thread);
thread.start();
}
/**
* Method that Adds a Course in AMADeUs
* @param couseId - Course Id
*/
public void addCourse(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course course) {
String courseName = course.getName();
String sms = Messages.getString("mobile.newCourse");
sms += this.truncate(courseName, 130-sms.length());
java.util.Date date = new java.util.Date(System.currentTimeMillis());
NoticeMobile notice = new NoticeMobile("Novo Curso", sms, -1, course.getId(), 4, false, -1, date);
AddCourseThread thread = new AddCourseThread(notice, courseName);
this.threads.add(thread);
thread.start();
}
/**
* Method that Removes a Course in AMADeUs
* @param couseId - Course Id
*/
public void removeCourse(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course course) {
String courseName = course.getName();
String sms = Messages.getString("mobile.deletedCourse");
sms += this.truncate(courseName, 130-sms.length());
java.util.Date date = new java.util.Date(System.currentTimeMillis());
NoticeMobile notice = new NoticeMobile("Curso Removido", sms, -1, course.getId(), 4, false, -1, date);
RemoveCourseThread thread = new RemoveCourseThread(notice, courseName);
this.threads.add(thread);
thread.start();
}
public AmadeusFacade getAmadeusFacade() {
return amadeusFacade;
}
public void setAmadeusFacade(AmadeusFacade amadeusFacade) {
this.amadeusFacade = amadeusFacade;
}
public FacadeMobile getFacade() {
return facade;
}
public void setFacade(FacadeMobile facade) {
this.facade = facade;
}
public static ArrayList<Thread> getThreads() {
return threads;
}
public static void setThreads(ArrayList<Thread> threads) {
Receiver.threads = threads;
}
}
@@ -0,0 +1,73 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import sun.awt.windows.ThemeReader;
public class RemoveCourseThread extends Thread {
private NoticeMobile sms;
private FacadeMobile fac;
private String courseName;
public RemoveCourseThread(NoticeMobile notice, String courseName) {
super();
this.sms = notice;
this.courseName = courseName;;
this.fac = FacadeMobile.getInstance();
}
public NoticeMobile getSms() {
return sms;
}
public void setSms(NoticeMobile sms) {
this.sms = sms;
}
public boolean check() {
boolean check = false;
for(Thread t : Receiver.threads) {
if(t instanceof RemoveCourseThread) {
if(((RemoveCourseThread)t).equals(this)) continue;
if(((RemoveCourseThread)t).getSms().getIdCourse() == this.getSms().getIdCourse()) {
check = true;
}
}
}
return check;
}
public void run() {
long time = 20000;
long initialTime = System.currentTimeMillis();
System.out.println("comecou");
while((System.currentTimeMillis() - initialTime) < time) {}
if(!this.check()) {
System.out.println("!check");
Sender sender = new Sender();
sender.createSMS(this.sms, this.courseName);
} else {
System.err.println("não enviou");
}
this.interrupt();
Receiver.threads.remove(this);
}
}
@@ -0,0 +1,73 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import sun.awt.windows.ThemeReader;
public class RemoveHomeworkThread extends Thread {
private NoticeMobile sms;
private FacadeMobile fac;
private String courseName;
public RemoveHomeworkThread(NoticeMobile notice, String courseName) {
super();
this.sms = notice;
this.courseName = courseName;;
this.fac = FacadeMobile.getInstance();
}
public NoticeMobile getSms() {
return sms;
}
public void setSms(NoticeMobile sms) {
this.sms = sms;
}
public boolean check() {
boolean check = false;
for(Thread t : Receiver.threads) {
if(t instanceof RemoveHomeworkThread) {
if(((RemoveHomeworkThread)t).equals(this)) continue;
if(((RemoveHomeworkThread)t).getSms().getIdCourse() == this.getSms().getIdCourse()) {
check = true;
}
}
}
return check;
}
public void run() {
long time = 20000;
long initialTime = System.currentTimeMillis();
System.out.println("comecou");
while((System.currentTimeMillis() - initialTime) < time) {}
if(!this.check()) {
System.out.println("!check");
Sender sender = new Sender();
sender.createSMS(this.sms, this.courseName);
} else {
System.err.println("não enviou");
}
this.interrupt();
Receiver.threads.remove(this);
}
}
@@ -0,0 +1,73 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import sun.awt.windows.ThemeReader;
public class RemoveMaterialThread extends Thread {
private NoticeMobile sms;
private FacadeMobile fac;
private String courseName;
public RemoveMaterialThread(NoticeMobile notice, String courseName) {
super();
this.sms = notice;
this.courseName = courseName;;
this.fac = FacadeMobile.getInstance();
}
public NoticeMobile getSms() {
return sms;
}
public void setSms(NoticeMobile sms) {
this.sms = sms;
}
public boolean check() {
boolean check = false;
for(Thread t : Receiver.threads) {
if(t instanceof RemoveMaterialThread) {
if(((RemoveMaterialThread)t).equals(this)) continue;
if(((RemoveMaterialThread)t).getSms().getIdCourse() == this.getSms().getIdCourse()) {
check = true;
}
}
}
return check;
}
public void run() {
long time = 20000;
long initialTime = System.currentTimeMillis();
System.out.println("comecou");
while((System.currentTimeMillis() - initialTime) < time) {}
if(!this.check()) {
System.out.println("!check");
Sender sender = new Sender();
sender.createSMS(this.sms, this.courseName);
} else {
System.err.println("não enviou");
}
this.interrupt();
Receiver.threads.remove(this);
}
}
@@ -0,0 +1,73 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import sun.awt.windows.ThemeReader;
public class RemoveModuleThread extends Thread {
private NoticeMobile sms;
private FacadeMobile fac;
private String courseName;
public RemoveModuleThread(NoticeMobile notice, String courseName) {
super();
this.sms = notice;
this.courseName = courseName;;
this.fac = FacadeMobile.getInstance();
}
public NoticeMobile getSms() {
return sms;
}
public void setSms(NoticeMobile sms) {
this.sms = sms;
}
public boolean check() {
boolean check = false;
for(Thread t : Receiver.threads) {
if(t instanceof RemoveModuleThread) {
if(((RemoveModuleThread)t).equals(this)) continue;
if(((RemoveModuleThread)t).getSms().getIdCourse() == this.getSms().getIdCourse()) {
check = true;
}
}
}
return check;
}
public void run() {
long time = 20000;
long initialTime = System.currentTimeMillis();
System.out.println("comecou");
while((System.currentTimeMillis() - initialTime) < time) {}
if(!this.check()) {
System.out.println("!check");
Sender sender = new Sender();
sender.createSMS(this.sms, this.courseName);
} else {
System.err.println("não enviou");
}
this.interrupt();
Receiver.threads.remove(this);
}
}
@@ -0,0 +1,73 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import sun.awt.windows.ThemeReader;
public class RemovePollThread extends Thread {
private NoticeMobile sms;
private FacadeMobile fac;
private String courseName;
public RemovePollThread(NoticeMobile notice, String courseName) {
super();
this.sms = notice;
this.courseName = courseName;;
this.fac = FacadeMobile.getInstance();
}
public NoticeMobile getSms() {
return sms;
}
public void setSms(NoticeMobile sms) {
this.sms = sms;
}
public boolean check() {
boolean check = false;
for(Thread t : Receiver.threads) {
if(t instanceof RemovePollThread) {
if(((RemovePollThread)t).equals(this)) continue;
if(((RemovePollThread)t).getSms().getIdCourse() == this.getSms().getIdCourse()) {
check = true;
}
}
}
return check;
}
public void run() {
long time = 20000;
long initialTime = System.currentTimeMillis();
System.out.println("comecou");
while((System.currentTimeMillis() - initialTime) < time) {}
if(!this.check()) {
System.out.println("!check");
Sender sender = new Sender();
sender.createSMS(this.sms, this.courseName);
} else {
System.err.println("não enviou");
}
this.interrupt();
Receiver.threads.remove(this);
}
}
@@ -0,0 +1,165 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo parte do programa Amadeus Sistema de Gesto de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS um software livre; voc pode redistribui-lo e/ou modifica-lo dentro dos termos da Licena Pblica Geral GNU como
publicada pela Fundao do Software Livre (FSF); na verso 2 da Licena.
Este programa distribudo na esperana que possa ser til, mas SEM NENHUMA GARANTIA; sem uma garantia implcita de ADEQUAO a qualquer MERCADO ou APLICAO EM PARTICULAR. Veja a Licena Pblica Geral GNU para maiores detalhes.
Voc deve ter recebido uma cpia da Licena Pblica Geral GNU, sob o ttulo "LICENCA.txt", junto com este programa, se no, escreva para a Fundao do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.hibernate.HibernateException;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.HibernateUtil;
import br.ufpe.cin.amadeus.amadeus_web.struts.action.SettingsActions;
import br.ufpe.cin.amadeus.amadeus_web.struts.action.SystemActions;
import java.io.IOException;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
public class Sender {
private final static Sender instance = new Sender();
private AmadeusFacade amadeusFacade;
private FacadeMobile facade;
public Sender() {
this.amadeusFacade = AmadeusFacade.getInstance();
this.facade = FacadeMobile.getInstance();
}
public synchronized void createSMS(NoticeMobile sms, String courseName) {
int id = this.facade.getLastId(sms.getIdCourse());
sms.setId(id + 1);
String stringId = "amadeus.mobile " + sms.getId();
try {
HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
ArrayList<String> users = amadeusFacade.findLoginsByCourse(sms.getIdCourse());
for(int i = 0; i < users.size(); i++) {
PersonMobile user = this.facade.getLogin(users.get(i));
if(user != null) {
//String ddd = user.getPhoneNumber().substring(1, 3);
//String number = "55"+ddd.toString() + user.getPhoneNumber().substring(4, 12);
String number = "55" + user.getPhoneNumber();
System.out.println("#: "+number);
//SENDING MESSAGE
System.out.println("Amadeus:" + sms.getContent());
//Para enviar sms, descomente o cdigo abaixo.
this.send(number, sms.getContent(), SettingsActions.mobileSettings.getLogin(), stringId);
}
}
this.facade.addNotice(sms);
HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit();
} catch (HibernateException e) {
HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().rollback();
}
}
/**
* Method that returns the instance of the class
* @return - Sender instance
*/
public static Sender getInstance() {
return instance;
}
/**
* Method that sends the message to the SMS Gateway (Human)
* Prints on the screen the sent message response status
*/
public void send(String to, String body, String from, String id) {
PostMethod http = new PostMethod("http://system.human.com.br/GatewayIntegration/msgSms.do");
if (body.length() + from.length() > 142) {
body = body.substring(0,142 - from.length());
}
http.addParameter("dispatch", "send");
http.addParameter("account", SystemActions.mobileSettings.getLogin()); // parametro passado pela Human
http.addParameter("code", SystemActions.mobileSettings.getPassword()); // parametro passado pela Human
http.addParameter("from", from);
http.addParameter("msg", body);
http.addParameter("to", to);
http.addParameter("id", id);
System.out.println("LALA: "+from);
System.out.println("LALA: "+body);
System.out.println("LALA: "+to);
System.out.println("LALA: "+id);
HttpClient httpclient = new HttpClient();
//httpclient.setTimeout(60000); // Timeout de 60s
try {
httpclient.executeMethod(http);
String response = http.getResponseBodyAsString();
String responseCode = "";
// Separa os 3 primeiros dgitos do retorno em responseCode
if (response != null && response.length() > 3) {
responseCode = response.substring(0, 3);
}
/**
* 000 - Message Sent
* 010 - Empty message content
* 011 - Message body invalid
* 012 - Message content overflow
* 012 - Empty 'to' mobile number
* 013 - Incorrect or incomplete 'to' mobile number
* 080 - Message with same ID already sent
* 900 - Authentication error
* 990 - Account Limit Reached
* 999 - Unknown Error
*/
if ("000".equals(responseCode)) {
System.out.println("Enviou Mensagem!");
} else if ("010".equals(responseCode)) {
System.out.println("Erro enviando (010 - Mensagem vazia)");
} else if ("011".equals(responseCode)) {
System.out.println("Erro enviando (011 - Mensagem invalida)");
} else if ("012".equals(responseCode)) {
System.out.println("Erro enviando (012 - Destinatario vazio)");
} else if ("013".equals(responseCode)) {
System.out.println("Erro enviando (013 - Destinatario invalido)");
} else if ("080".equals(responseCode)) {
System.out.println("Envio repetido (080 - Id ja usado)");
} else if ("900".equals(responseCode)) {
System.out.println("Erro de autenticacao na conta.");
} else if ("990".equals(responseCode)) {
System.out.println("Erro - Creditos terminaram na conta.");
} else if ("999".equals(responseCode)) {
System.out.println("Erro desconhecido (999 - desconhecido)");
} else {
System.out.println("Erro ao conectar com o HumanGateway "+responseCode);
}
} catch (ConnectException e) {
System.out.println("");
} catch (SocketTimeoutException e) {
System.out.println("");
} catch (IOException e) {
System.out.println("");
} catch (Exception e) {
System.out.println("");
}
}
}
@@ -0,0 +1,73 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.sms;
import java.util.ArrayList;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.NoticeMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.AmadeusFacade;
import br.ufpe.cin.amadeus.amadeus_mobile.facade.FacadeMobile;
import sun.awt.windows.ThemeReader;
public class TeacherUpdateThread extends Thread {
private NoticeMobile sms;
private FacadeMobile fac;
private String courseName;
public TeacherUpdateThread(NoticeMobile notice, String courseName) {
super();
this.sms = notice;
this.courseName = courseName;;
this.fac = FacadeMobile.getInstance();
}
public NoticeMobile getSms() {
return sms;
}
public void setSms(NoticeMobile sms) {
this.sms = sms;
}
public boolean check() {
boolean check = false;
for(Thread t : Receiver.threads) {
if(t instanceof TeacherUpdateThread) {
if(((TeacherUpdateThread)t).equals(this)) continue;
if(((TeacherUpdateThread)t).getSms().getIdCourse() == this.getSms().getIdCourse()) {
check = true;
}
}
}
return check;
}
public void run() {
long time = 20000;
long initialTime = System.currentTimeMillis();
System.out.println("comecou");
while((System.currentTimeMillis() - initialTime) < time) {}
if(!this.check()) {
System.out.println("!check");
Sender sender = new Sender();
sender.createSMS(this.sms, this.courseName);
} else {
System.err.println("não enviou");
}
this.interrupt();
Receiver.threads.remove(this);
}
}
@@ -0,0 +1,571 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_mobile.util;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Forum;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Game;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.LearningObject;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Poll;
public class Conversor {
/**
* Method that converts AMADeUs Course object into Mobile Course object
* @param curso - AMADeUs Course to be converted
* @return - Converted Mobile Course object
*/
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile converterCurso(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course curso){
br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile retorno = new br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile();
retorno.setId(curso.getId());
retorno.setName(curso.getName());
retorno.setContent(curso.getContent());
retorno.setObjectives(curso.getObjectives());
retorno.setModules(converterModulos(curso.getModules()));
retorno.setKeywords(converterKeywords(curso.getKeywords()));
ArrayList<String> nomes = new ArrayList<String>();
nomes.add(curso.getProfessor().getName());
retorno.setTeachers(nomes);
retorno.setCount(0);
retorno.setMaxAmountStudents(curso.getMaxAmountStudents());
retorno.setFinalCourseDate(curso.getFinalCourseDate());
retorno.setInitialCourseDate(curso.getInitialCourseDate());
return retorno;
}
/**
* Method that converts a AMADeUs Course object list into Mobile Course object list
* @param cursos - AMADeUs Course object list to be converted
* @return - Converted Mobile Course object list
*/
public static List<br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile> converterCursos(List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course> cursos){
ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile> retorno = new ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.CourseMobile>();
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course c : cursos){
retorno.add(Conversor.converterCurso(c));
}
return retorno;
}
/**
* Method that converts AMADeUs Module object into Mobile Module object
* @param modulo - AMADeUs Module object to be converted
* @return - Converted Mobile Module object
*/
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.ModuleMobile converterModulo(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Module modulo){
br.ufpe.cin.amadeus.amadeus_mobile.basics.ModuleMobile mod = new br.ufpe.cin.amadeus.amadeus_mobile.basics.ModuleMobile(modulo.getId(), modulo.getName());
List<HomeworkMobile> listHomeworks = new ArrayList<HomeworkMobile>();
for (Poll poll : modulo.getPolls()) {
listHomeworks.add( Conversor.converterPollToHomework(poll) );
}
for (Forum forum : modulo.getForums()) {
listHomeworks.add( Conversor.converterForumToHomework(forum) );
}
for(Game game : modulo.getGames()){
listHomeworks.add( Conversor.converterGameToHomework(game) );
}
for(LearningObject learning : modulo.getLearningObjects()){
listHomeworks.add( Conversor.converterLearningObjectToHomework(learning) );
}
mod.setHomeworks(listHomeworks);
mod.setMaterials(converterMaterials(modulo.getMaterials()));
return mod;
}
/**
* Mothod that converts a AMADeUs Module object list into Mobile Module object list
* @param modulos - AMADeUs Module object list to be converted
* @return - Converted Mobile Module object list
*/
public static List<br.ufpe.cin.amadeus.amadeus_mobile.basics.ModuleMobile> converterModulos(List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Module> modulos){
ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.ModuleMobile> retorno = new ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.ModuleMobile>();
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Module m : modulos){
retorno.add(Conversor.converterModulo(m));
}
return retorno;
}
/**
* Method that converts AMADeUs Homework object into Mobile Homework object
* @param home - AMADeUs Homework object to be converted
* @return - Converted Mobile Homework object
*/
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile converterHomework(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Homework home){
br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile retorno = new br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile();
retorno.setId(home.getId());
retorno.setName(home.getName());
retorno.setDescription(home.getDescription());
retorno.setInitDate(home.getInitDate());
retorno.setDeadline(home.getDeadline());
retorno.setAlowPostponing(home.getAllowPostponing());
retorno.setInfoExtra("");
retorno.setTypeActivity(HomeworkMobile.HOMEWORK);
return retorno;
}
/**
* Method that converts AMADeUs Game object into Mobile Homework object
* @param game - AMADeUs Game object to be converted
* @return - Converted Mobile Homework object
*/
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile converterGameToHomework(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Game game){
br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile retorno = new br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile();
retorno.setId(game.getId());
retorno.setName(game.getName());
retorno.setDescription(game.getDescription());
retorno.setInfoExtra(game.getUrl());
retorno.setTypeActivity(HomeworkMobile.GAME);
return retorno;
}
/**
* Method that converts AMADeUs Forum object into Mobile Homework object
* @param forum - AMADeUs Forum object to be converted
* @return - Converted Mobile Homework object
*/
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile converterForumToHomework(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Forum forum){
br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile retorno = new br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile();
retorno.setId(forum.getId());
retorno.setName(forum.getName());
retorno.setDescription(forum.getDescription());
retorno.setInitDate(forum.getCreationDate());
retorno.setInfoExtra("");
retorno.setTypeActivity(HomeworkMobile.FORUM);
return retorno;
}
/**
* Method that converts AMADeUs Poll object into Mobile Homework object
* @param poll - AMADeUs Poll object to be converted
* @return - Converted Mobile Homework object
*/
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile converterPollToHomework(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Poll poll){
br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile retorno = new br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile();
retorno.setId(poll.getId());
retorno.setName(poll.getName());
retorno.setDescription(poll.getQuestion());
retorno.setInitDate(poll.getCreationDate());
retorno.setDeadline(poll.getFinishDate());
retorno.setInfoExtra("");
retorno.setTypeActivity(HomeworkMobile.POLL);
return retorno;
}
/**
* Method that converts AMADeUs Multimedia object into Mobile Homework object
* @param media - AMADeUs Multimedia object to be converted
* @return - Converted Mobile Homework object
*/
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile converterMultimediaToHomework(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Multimedia media){
br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile retorno = new br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile();
retorno.setId(media.getId());
retorno.setName(media.getName());
retorno.setDescription(media.getDescription());
retorno.setInfoExtra(media.getUrl());
retorno.setTypeActivity(HomeworkMobile.MULTIMEDIA);
return retorno;
}
/**
* Method that converts AMADeUs Video object into Mobile Homework object
* @param video - AMADeUs Video object to be converted
* @return - Converted Mobile Homework object
*/
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile converterVideoToHomework(br.ufpe.cin.amadeus.amadeus_sdmm.dao.Video video){
br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile retorno = new br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile();
retorno.setId(video.getId());
retorno.setName(video.getName());
retorno.setDescription(video.getDescription());
retorno.setInitDate(video.getDateinsertion());
retorno.setInfoExtra(video.getTags());
retorno.setTypeActivity(HomeworkMobile.VIDEO);
return retorno;
}
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile converterLearningObjectToHomework(
br.ufpe.cin.amadeus.amadeus_web.domain.content_management.LearningObject learning) {
br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile retorno = new br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile();
retorno.setId(learning.getId());
retorno.setName(learning.getName());
retorno.setUrl(learning.getUrl());
retorno.setDescription(learning.getDescription());
retorno.setDeadline(learning.getCreationDate());
retorno.setTypeActivity(HomeworkMobile.LEARNING_OBJECT);
return retorno;
}
/**
* Method that converts AMADeUs Homework object list into Mobile Homework object list
* @param homes - AMADeUs Homework object list to be converted
* @return - Converted Mobile Homework object list
*/
public static List<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile> converterHomeworks(List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Homework> homes){
ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile> retorno = new ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.HomeworkMobile>();
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Homework h : homes){
retorno.add(Conversor.converterHomework(h));
}
return retorno;
}
/**
* Method that converts AMADeUs Material object into Mobile Material object
* @param mat - AMADeUs Material object to be converted
* @return - Mobile Material object converted
*/
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.MaterialMobile converterMaterial(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Material mat){
br.ufpe.cin.amadeus.amadeus_mobile.basics.MaterialMobile retorno = new br.ufpe.cin.amadeus.amadeus_mobile.basics.MaterialMobile();
retorno.setId(mat.getId());
retorno.setName(mat.getArchiveName());
retorno.setAuthor(converterPerson(mat.getAuthor()));
retorno.setPostDate(mat.getCreationDate());
return retorno;
}
/**
* Method that converts AMADeUs Mobile Material object list into Mobile Material object list
* @param mats - AMADeUs Material object list
* @return - Mobile Material object list
*/
public static List<br.ufpe.cin.amadeus.amadeus_mobile.basics.MaterialMobile> converterMaterials(List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Material> mats){
ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.MaterialMobile> retorno = new ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.MaterialMobile>();
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Material mat : mats){
retorno.add(Conversor.converterMaterial(mat));
}
return retorno;
}
/**
* Method that converts AMADeUs Keyword object into Mobile Keyword object
* @param key - AMADeUs Keyword object to be converted
* @return - Converted Keywork object
*/
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.KeywordMobile converterKeyword(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Keyword key){
br.ufpe.cin.amadeus.amadeus_mobile.basics.KeywordMobile retorno = new br.ufpe.cin.amadeus.amadeus_mobile.basics.KeywordMobile();
retorno.setId(key.getId());
retorno.setName(key.getName());
retorno.setPopularity(key.getPopularity());
return retorno;
}
/**
* Method that converts AMADeUs Keyword object list into a Mobile Keyword HashSet object
* @param keys - AMADeUs Keyword object list to be converted
* @return - Mobile Keywork HashSet object list
*/
public static HashSet<br.ufpe.cin.amadeus.amadeus_mobile.basics.KeywordMobile> converterKeywords(Set<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Keyword> keys){
HashSet<br.ufpe.cin.amadeus.amadeus_mobile.basics.KeywordMobile> retorno = new HashSet<br.ufpe.cin.amadeus.amadeus_mobile.basics.KeywordMobile>();
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Keyword k : keys){
retorno.add(Conversor.converterKeyword(k));
}
return retorno;
}
/**
* Method that converts AMADeUs Choice object into Mobile Choice object
* @param ch - AMADeUs Choice object to be converted
* @return - Converted Mobile Choice object
*/
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.ChoiceMobile converterChoice(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Choice ch){
br.ufpe.cin.amadeus.amadeus_mobile.basics.ChoiceMobile retorno = new br.ufpe.cin.amadeus.amadeus_mobile.basics.ChoiceMobile();
retorno.setId(ch.getId());
retorno.setAlternative(ch.getAlternative());
retorno.setVotes(ch.getVotes());
retorno.setPercentage(ch.getPercentage());
return retorno;
}
/**
* Method that converts AMADeUs Choice object list into Mobile Choice object list
* @param chs - AMADeUs Choice object list to be converted
* @return - Converted Mobile Choice object list
*/
public static List<br.ufpe.cin.amadeus.amadeus_mobile.basics.ChoiceMobile> converterChoices(List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Choice> chs){
List<br.ufpe.cin.amadeus.amadeus_mobile.basics.ChoiceMobile> retorno = new ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.ChoiceMobile>();
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Choice c : chs){
retorno.add(Conversor.converterChoice(c));
}
return retorno;
}
/**
* Method that converts AMADeUs Poll object into Mobile Poll Object
* @param p - AMADeUs Poll object to be converted
* @return - Converted Mobile Poll object
*/
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.PollMobile converterPool(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Poll p){
br.ufpe.cin.amadeus.amadeus_mobile.basics.PollMobile retorno = new br.ufpe.cin.amadeus.amadeus_mobile.basics.PollMobile();
retorno.setId(p.getId());
retorno.setName(p.getName());
retorno.setQuestion(p.getQuestion());
retorno.setInitDate(p.getCreationDate());
retorno.setFinishDate(p.getFinishDate());
retorno.setAnswered(false);
retorno.setChoices(converterChoices(p.getChoices()));
retorno.setAnsewered(converterAnswers(p.getAnswers()));
return retorno;
}
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.LearningObjectMobile converterLearningObject (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.LearningObject learning){
br.ufpe.cin.amadeus.amadeus_mobile.basics.LearningObjectMobile retorno = new br.ufpe.cin.amadeus.amadeus_mobile.basics.LearningObjectMobile();
retorno.setId(learning.getId());
retorno.setName(learning.getName());
retorno.setDescription(learning.getDescription());
retorno.setDatePublication(learning.getCreationDate());
retorno.setUrl(learning.getUrl());
return retorno;
}
/**
* Method that converts AMADeUs Poll object list into Mobile Poll object list
* @param pls - AMADeUs Poll object list
* @return - Converted Mobile object list
*/
public static List<br.ufpe.cin.amadeus.amadeus_mobile.basics.PollMobile> converterPools(List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Poll> pls){
List<br.ufpe.cin.amadeus.amadeus_mobile.basics.PollMobile> retorno = new ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.PollMobile>();
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Poll p : pls){
retorno.add(Conversor.converterPool(p));
}
return retorno;
}
/**
* Method that converts AMADeUs Answer object into Mobile Answer object
* @param ans - AMADeUs Answer object to be converted
* @return - Converted Mobile Answer object
*/
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.AnswerMobile converterAnswer(br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Answer ans){
br.ufpe.cin.amadeus.amadeus_mobile.basics.AnswerMobile retorno = new br.ufpe.cin.amadeus.amadeus_mobile.basics.AnswerMobile();
retorno.setId(ans.getId());
retorno.setAnswerDate(ans.getAnswerDate());
retorno.setPerson(converterPerson(ans.getPerson()));
return retorno;
}
/**
* Method that converts AMADeUs Answer object list into Mobile Answer object list
* @param anss - AMADeUs Answer object list
* @return - Converted Mobile object list
*/
public static List<br.ufpe.cin.amadeus.amadeus_mobile.basics.AnswerMobile> converterAnswers(List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Answer> anss){
List<br.ufpe.cin.amadeus.amadeus_mobile.basics.AnswerMobile> retorno = new ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.AnswerMobile>();
for (br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Answer an : anss){
retorno.add(Conversor.converterAnswer(an));
}
return retorno;
}
/**
* Method that converts AMADeUs Person object into Mobile Person object
* @param p - AMADeUs Person object to be converted
* @return - Converted Mobile Person object
*/
public static br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile converterPerson(br.ufpe.cin.amadeus.amadeus_web.domain.register.Person p){
return new br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile(p.getId(), p.getAccessInfo().getLogin(), p.getPhoneNumber());
}
/**
* Method that converts AMADeUs Person object list into Mobile Person object list
* @param persons - AMADeUs Person object list to be converted
* @return - Converted Mobile Person object list
*/
public static List<br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile> converterPersons(List<br.ufpe.cin.amadeus.amadeus_web.domain.register.Person> persons){
List<br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile> retorno = new ArrayList<br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile>();
for (br.ufpe.cin.amadeus.amadeus_web.domain.register.Person p : persons){
retorno.add(Conversor.converterPerson(p));
}
return retorno;
}
/**
* Method that converts Mobile Poll object into AMADeUs Poll Object
* @param p - Mobile Poll object to be converted
* @return - Converted AMADeUs Poll object
*/
public static br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Poll converterPool(br.ufpe.cin.amadeus.amadeus_mobile.basics.PollMobile p){
br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Poll retorno = new br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Poll();
retorno.setId(p.getId());
retorno.setName(p.getName());
retorno.setQuestion(p.getQuestion());
retorno.setCreationDate(p.getInitDate());
retorno.setFinishDate(p.getFinishDate());
retorno.setChoices(converterChoices2(p.getChoices()));
retorno.setAnswers(converterAnswers2(p.getAnsewered()));
return retorno;
}
/**
* Method that converts Mobile Choice object into AMADeUs Choice object
* @param ch - Mobile Choice object to be converted
* @return - Converted AMADeUs Choice object
*/
public static br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Choice converterChoice(br.ufpe.cin.amadeus.amadeus_mobile.basics.ChoiceMobile ch){
br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Choice retorno = new br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Choice();
retorno.setId(ch.getId());
retorno.setAlternative(ch.getAlternative());
retorno.setVotes(ch.getVotes());
retorno.setPercentage(ch.getPercentage());
return retorno;
}
/**
* Method that converts Mobile Choiceobject list into AMADeUs Choice object list
* @param chs - Mobile Choice object list to be converted
* @return - Converted AMADeUs Choice object list
*/
public static List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Choice> converterChoices2(List<br.ufpe.cin.amadeus.amadeus_mobile.basics.ChoiceMobile> chs){
List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Choice> retorno = new ArrayList<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Choice>();
for (br.ufpe.cin.amadeus.amadeus_mobile.basics.ChoiceMobile c : chs){
retorno.add(Conversor.converterChoice(c));
}
return retorno;
}
/**
* Method that converts Mobile Answer object into AMADeUs Answer object
* @param ans - Mobile Answer object to be converted
* @return - Converted AMADeUs Answer object
*/
public static br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Answer converterAnswer(br.ufpe.cin.amadeus.amadeus_mobile.basics.AnswerMobile ans){
br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Answer retorno = new br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Answer();
retorno.setId(ans.getId());
retorno.setAnswerDate(ans.getAnswerDate());
retorno.setPerson(converterPerson(ans.getPerson()));
return retorno;
}
/**
* Method that converts Mobile Answer object list into AMADeUs Answer object list
* @param anss - Mobile Answer object list
* @return - Converted AMADeUs Answer object list
*/
public static List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Answer> converterAnswers2(List<br.ufpe.cin.amadeus.amadeus_mobile.basics.AnswerMobile> anss){
List<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Answer> retorno = new ArrayList<br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Answer>();
for (br.ufpe.cin.amadeus.amadeus_mobile.basics.AnswerMobile an : anss){
retorno.add(Conversor.converterAnswer(an));
}
return retorno;
}
/**
* Method that converts Mobile Person object into AMADeUs Person object
* @param p - Mobile Person object to be converted
* @return - Converted AMADeUs Person object
*/
public static br.ufpe.cin.amadeus.amadeus_web.domain.register.Person converterPerson(br.ufpe.cin.amadeus.amadeus_mobile.basics.PersonMobile p){
br.ufpe.cin.amadeus.amadeus_web.domain.register.Person p1 = new br.ufpe.cin.amadeus.amadeus_web.domain.register.Person();
p1.setId(p.getId());
p1.setName(p.getName());
p1.setPhoneNumber(p.getPhoneNumber());
return p1;
}
}
@@ -0,0 +1,136 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_sdmm.dao;
/**
* @author Armando Soares Sousa / Antonio Nascimento
*
*/
/*
* DAO.java
*
* Created on 13 de Julho de 2007, 16:59
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import java.util.Vector;
import br.ufpe.cin.amadeus.amadeus_sdmm.general.Sdmm;
public class Dao {
private String usuario;
private String senha;
private String banco;
private String local;
private Connection con;
private Statement stat;
/** Creates a new instance of DAO */
public Dao() {
this.usuario = Sdmm.userDataBase;
this.senha = Sdmm.passwordDataBase;
this.banco = Sdmm.nameDataBase;
//this.local = Sdmm.ipAddressDataBase+":"+Sdmm.portDataBase;
this.local = Sdmm.ipAddressDataBase;
}
public Connection getCon() {
return this.con;
}
public void setCon(Connection con) {
this.con = con;
}
public Statement getStat() {
return stat;
}
public void setStat(Statement stat) {
this.stat = stat;
}
public void closeConnection(){
//Confere se ainda está conectada.
try {
if(con != null && !con.isClosed()){
con.close();
//System.out.println("Desconectado");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void getConnection(){
Connection con = null;
try {
try {
Class.forName("org.postgresql.Driver");
}
catch(Exception e) {
e.printStackTrace();
}
Properties jdbc = new Properties();
jdbc.put("user",usuario);
jdbc.put("password",senha);
String url = "jdbc:postgresql://"+local+"/"+banco;
System.out.println("url de conexao com o banco: "+url);
con = DriverManager.getConnection(url,jdbc);
this.con = con;
}
catch(SQLException e) {
System.out.println("Exception on DAO getConnection : "+e.getMessage());
}
}
public Statement createStament() throws SQLException{
Statement retorno = null;
if (this.con != null) {
retorno = this.con.createStatement();
}
return retorno;
}
public void executaComandoSQL(String pcomando){
try {
this.setStat(this.createStament());
this.getStat().executeUpdate(pcomando);
} catch (SQLException e) {
e.printStackTrace();
}
}
public ResultSet executaConsultaSQL(String pconsulta){
ResultSet retorno = null;
try{
this.setStat(this.createStament());
retorno = this.getStat().executeQuery(pconsulta);
} catch (SQLException e){
e.printStackTrace();
}
return retorno;
}
}
@@ -0,0 +1,195 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_sdmm.dao;
/**
* @author armando
*
*/
/*
* Thumbnail.java
*
* Created on 6 de Julho de 2007, 15:17
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.OutputStream;
import br.ufpe.cin.amadeus.amadeus_sdmm.general.Sdmm;
/**
*
* @author ANTONIO/ARMANDO
*/
public class Thumbnail {
/** Creates a new instance of Thumbnail */
public Thumbnail() {
}
/**
* Uses a Runtime.exec()to use imagemagick to perform the given conversion
* operation. Returns true on success, false on failure. Does not check if
* either file exists.
*
* @param in - InputFile that represents
* @param out - OutputFile that represents a new thumbnail
* @param width - width of thumbnail to be generated
* @param height - height of thumbnail to be generated
* @param quality - quality of new thumbnail
* @return exec - return true if is the command is sucessful
*/
public static boolean convert(File in, File out, int width, int height, int quality) {
ArrayList command = new ArrayList(10);
try{
if (quality < 0 || quality > 100) {
quality = 75;
}
// note: CONVERT_PROG is a class variable that stores the location of ImageMagicks convert command
// it might be something like “/usr/local/magick/bin/convert” or something else, depending on where you installed it.
command.add("convert");
command.add("-geometry");
command.add(width + "x" + height);
command.add("-quality");
command.add("" + quality);
command.add(in.getAbsolutePath());
command.add(out.getAbsolutePath());
System.out.println(command);
}
catch(Exception e){
System.out.println("Type of exception catched: "+e.toString());
System.out.println("Exception in method convert from MultimediaManipulator :"+e.getMessage());
//pode dá erro no in - inputfile
//pode dá erro no out - outputfile
//pode passar parametros invalidos para width, height ou quality
}
return exec((String[])command.toArray(new String[1]));
}
/**
* Uses a Runtime.exec()to use ffmpeg to perform the given conversion
* operation to create a thumbnail with witdh and high dimensions.
* As a result, the operation creates a new jpeg file contend the first frame of the video file.
* Returns true on success, false on failure. Does not check if
* either file exists.
* Example of command: ffmpeg -i videoname.mpeg -s 90x90 -vframes 1 firstframe%d.jpeg
*
* @param in - is the videofile to operation
* @param width - is the width of thumbnail
* @param hight - is the hight of thumbnail
* @param filePath - is the path of thumbnail created by operation
* @param id -is the identification number of thumbnail
* @return exec - returns true if the command is sucessful
*/
public static boolean videoGetFirstFrame(File in, int width, int hight, String filePath, int id){
ArrayList command = new ArrayList(10);
try{
command.add("ffmpeg");
command.add("-i");
command.add(in.getAbsolutePath());
command.add("-s");
command.add(width+"x"+hight);
command.add("-vframes");
command.add("1");
command.add(filePath+"thumbnail"+"%d"+"-"+id+".jpg");
System.out.println(command);
}catch(Exception e){
System.out.println("Type of exception catched: "+e.toString());
System.out.println("Exception in method videoGetFirstFrame from MultimediaManipulator :"+e.getMessage());
//pode dá erro no in - inputfile
//pode dá erro no thumbnailName - invalide name to thumbnail generated
//pode passar parametros invalidos para width, height
}
return exec((String[])command.toArray(new String[1]));
}
/**
* Tries to exec the command, waits for it to finsih, logs errors if exit
* status is nonzero, and returns true if exit status is 0 (success).
* audio "mp3;MP3#mp4;MPEG-4 AAC#ra;Real Audio#wma;WMA"
* video "avi;AVI#mp1;MPEG-1#mp2;MPEG-2#mp4;MPEG-4#ogg;OGG#rm;Real Video#wmv;WMV;flv#FLV"
*
* @param command - the command to be performed by ffmpeg process
* @return true if the command is successful
*/
private static boolean exec(String[] command) {
Process proc; //the process created by program to manipulate ffmpeg external program process
BufferedReader bInputStream = null; //buffer to store the input from ffmpeg process
BufferedWriter bOutputStream = null; //buffer to store the output from ffmpeg process
BufferedReader bErrorStream = null; //buffer to store the error from ffmpeg process
try {
proc = Runtime.getRuntime().exec(command);
bErrorStream = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
String s;
String sError="";
//block to store the string generated by error ffmpeg process
while ((s = bErrorStream.readLine())!= null) {
sError = sError + s;
}
bErrorStream.close();
bInputStream = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String s2;
String sInput="";
while ((s2 = bInputStream.readLine())!= null) {
sInput = sInput + s2;
}
bInputStream.close();
bOutputStream = new BufferedWriter(new OutputStreamWriter(proc.getOutputStream()));
bOutputStream.close();
proc.getInputStream().close();
proc.getOutputStream().close();
proc.getErrorStream().close();
} catch (IOException e) {
System.out.println("IOException while trying to execute " + command);
Thread.currentThread().interrupt();
return false;
} catch (Exception e){
System.out.println("Exception in "+e.toString());
System.out.println("Exception in Exec from MultimediaManipulator : "+e.getMessage());
System.out.println("Exception while trying to execute " + command);
Thread.currentThread().interrupt();
return false;
}
int exitStatus;
while (true) {
try {
exitStatus = proc.waitFor();
break;
} catch (java.lang.InterruptedException e) {
System.out.println("Interrupted: Ignoring and waiting");
Thread.currentThread().interrupt();
}
}
if (exitStatus != 0) {
System.out.println("Error executing command: " + exitStatus);
}
return (exitStatus == 0);
}
}
@@ -0,0 +1,223 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_sdmm.dao;
/**
* @author Armando Soares Sousa/Antonio Nascimento
*
*/
/*
* Video.java
*
* Created on 13 de Julho de 2007, 17:15
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import java.sql.Date;
public class Video {
private int id;
private String description;
private String name;
private String author;
private String tags;
private String video;
private long datemodification;
private char license;
private int width;
private int height;
private String thumbnail;
private long length;
private Date dateinsertion;
private String extension;
private int bitrate;
private double framerate;
private String duration;
private String standard;
/** Creates a new instance of Video */
public Video(int id,String description,String name,String author,String tags,
String video,long datemodification, char license,int width,int height,String thumbnail,
long length,Date dateinsertion,String extension,int bitrate,
double framerate,String duration,String standard) {
this.id = id;
this.description = description;
this.name = name;
this.author = author;
this.tags = tags;
this.video = video;
this.datemodification = datemodification;
this.license = license;
this.width = width;
this.height = height;
this.thumbnail = thumbnail;
this.length = length;
this.dateinsertion = dateinsertion;
this.extension = extension;
this.bitrate = bitrate;
this.framerate = framerate;
this.duration = duration;
this.standard = standard;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getTags() {
return tags;
}
public void setTags(String tags) {
this.tags = tags;
}
public String getVideo() {
return video;
}
public void setVideo(String video) {
this.video = video;
}
public long getDateModification() {
return datemodification;
}
public void setDateModification(long datemodification) {
this.datemodification = datemodification;
}
public char getLicense() {
return license;
}
public void setLicense(char license) {
this.license = license;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public String getThumbnail() {
return thumbnail;
}
public void setThumbnail(String thumbnail) {
this.thumbnail = thumbnail;
}
public long getLength() {
return length;
}
public void setLength(long length) {
this.length = length;
}
public Date getDateinsertion() {
return dateinsertion;
}
public void setDateinsertion(Date dateinsertion) {
this.dateinsertion = dateinsertion;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public int getBitrate() {
return bitrate;
}
public void setBitrate(int bitrate) {
this.bitrate = bitrate;
}
public double getFramerate() {
return framerate;
}
public void setFramerate(double framerate) {
this.framerate = framerate;
}
public String getDuration() {
return duration;
}
public void setDuration(String duration) {
this.duration = duration;
}
public String getStandard() {
return standard;
}
public void setStandard(String standard) {
this.standard = standard;
}
}
@@ -0,0 +1,330 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_sdmm.dao;
/**
* @author armando
*
*/
import java.io.File;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import br.ufpe.cin.amadeus.amadeus_sdmm.general.Sdmm;
//package javaapplication1;
/*
* ImagemDAO.java
*
* Created on 1 de Julho de 2007, 14:00
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
/**
*
* @author ANTONIO/ARMANDO
* TODO: Criar a classe DAO
*/
public class VideoDAO {
Dao dao = new Dao();
/** Creates a new instance of ImagemDAO */
public VideoDAO() {
}
public int getMaxId(){
int id = 0;
//String comando = "select id from videos where id = (select max(id) from videos)";
String comando = "select nextval('videos_pk_id_seq') as idf";
this.dao.getConnection();
ResultSet rs = this.dao.executaConsultaSQL(comando);
try {
if(rs.next()){
id = Integer.parseInt(rs.getString("idf"));
}
} catch (SQLException e) {
System.out.println("Exception em getMaxId em VideoDAO"+e.getMessage());
}
this.dao.closeConnection();
return id;
}
synchronized public void insertVideo(Video video){
try{
//TODO: Colocar thumbnail...
String sql = "INSERT INTO videos (id,description,name,author,tags,video,datemodification,license,"+
"width,height,thumbnail,length,dateinsertion,extension,bitrate,framerate,"+
"duration,standard) VALUES ("+video.getId()+",'"+video.getDescription()+"','"+
video.getName()+"','"+video.getAuthor()+"','"+video.getTags()+"',lo_import('"+video.getVideo()+"'),"+
video.getDateModification()+","+
video.getLicense()+","+video.getWidth()+","+video.getHeight()+",lo_import('"+video.getThumbnail()+"')," +
video.getLength()+",'"+video.getDateinsertion()+"','"+video.getExtension()+"',"+
video.getBitrate()+","+video.getFramerate()+",'"+video.getDuration()+"','"+
video.getStandard()+"')";
this.dao.getConnection();
this.dao.executaComandoSQL(sql);
this.dao.closeConnection();
}catch(Exception e){
System.out.println("Exception em InserVideo em videoDAO"+e.getMessage());
e.printStackTrace();
}
}
synchronized public void updateVideo(String description,String name,String author,String tags,
char license, int id){
try{
String sql = "update videos set description = '"+description+"', name = '"+
name+"', author = '"+author+"',tags = '"+tags+"',"+
"license = "+license+" where id = "+id;
this.dao.getConnection();
this.dao.executaComandoSQL(sql);
this.dao.closeConnection();
}catch(Exception e){
System.out.println("Exception em updateVideo em VideoDAO: "+e.getMessage());
e.printStackTrace();
}
}
//public void loadVideo(int id, String extension){
synchronized public void loadVideo(Video video, String extension){
String directoryVideos = Sdmm.directoryVideos;
try{
//File file = new File("C:/Program Files/Tomcat 5.0/webapps/ROOT/prototipo4/videos/video"+video.getId()+"."+extension);
File file = new File(directoryVideos+"video"+video.getId()+"."+extension);
//Video video = this.get(id);
//if(video.getLength() != file.length() || video.getDateModification() != file.lastModified()){
if(video.getLength() != file.length()){
/*String sql = "SELECT lo_export(videos.video, 'C:/Program Files/Tomcat 5.0/webapps/ROOT/prototipo4/videos/"
+"video"+video.getId()+"."+extension+"') FROM videos WHERE id = "+video.getId();*/
String sql = "SELECT lo_export(videos.video, '"+directoryVideos+"video"+video.getId()+"."+extension+"') FROM videos WHERE id = "+video.getId();
this.dao.getConnection();
this.dao.executaComandoSQL(sql);
this.dao.closeConnection();
//Após fz o lo_export é necessário corrigir a data de modificação do arquivo exportado, já que como ele cria um novo
//arquivo a data de modificação do exportado sempre seria diferente da do banco e o algoritmo bugaria...
//File fileLoaded = new File("C:/Program Files/Tomcat 5.0/webapps/ROOT/prototipo4/videos/video"+video.getId()+"."+extension);
File fileLoaded = new File(directoryVideos+"videos"+video.getId()+"."+extension);
fileLoaded.setLastModified(video.getDateModification());
}
}catch(Exception e){
System.out.println("Exception em loadVideo em VideoDAO: "+e.getMessage());
e.printStackTrace();
}
}
//public void loadThumbnail(int id){
synchronized void loadThumbnail(Video video){
String directoryVideos = Sdmm.directoryVideos;
try{
//File file = new File("C:/Program Files/Tomcat 5.0/webapps/ROOT/prototipo4/videos/video"+video.getId()+"."+extension);
File file = new File(directoryVideos+"thumbnail1-"+video.getId()+".jpg");
//Não guardamos na tabela de video o tamanho do thumnail então apenas comparando a data de modificação já resolve
if(video.getDateModification() != file.lastModified()){
/*String sql = "SELECT lo_export(images.thumbnail, 'C:/Program Files/Tomcat 5.0/webapps/ROOT/prototipo4/images/"
+"thumbnail"+image.getId()+".jpg') FROM images WHERE id = "+image.getId();*/
String sql = "SELECT lo_export(videos.thumbnail, '"+directoryVideos+"thumbnail1-"+video.getId()+".jpg') FROM videos WHERE id = "+video.getId();
this.dao.getConnection();
this.dao.executaComandoSQL(sql);
this.dao.closeConnection();
//Após fz o lo_export é necessário corrigir a data de modificação do arquivo exportado, já que como ele cria um novo
//arquivo a data de modificação do exportado sempre seria diferente da do banco e o algoritmo bugaria...
File fileLoaded = new File(directoryVideos+"thumbnail1-"+video.getId()+".jpg");
fileLoaded.setLastModified(video.getDateModification());
}
} catch(Exception e){
System.out.println("Exception em loadThumbnail em VideoDAO: "+e.getMessage());
e.printStackTrace();
}
}
synchronized public void deleteVideo(int id){
String videoOID="";
try{
String sqlSearch = "SELECT video FROM videos WHERE id = '" + id + "'";
String sqlDelete = "DELETE FROM videos WHERE id = '" + id + "'";
this.dao.getConnection();
ResultSet rs = this.dao.executaConsultaSQL(sqlSearch);
try{
if (rs.next()){
videoOID = rs.getString("video");
}else{
videoOID = null;
}
}catch(Exception e1){
System.out.println("Exception em deleteVideo em VideoDAO :"+e1.getMessage());
}
String sqlUnlinkVideo = "SELECT lo_unlink("+videoOID+")";
ResultSet rsUnlinkVideo = this.dao.executaConsultaSQL(sqlUnlinkVideo);
this.dao.executaComandoSQL(sqlDelete);
this.dao.closeConnection();
}catch(Exception e){
System.out.println("Exception em deleteVideo em VideoDAO :"+e.getMessage());
e.printStackTrace();
}
}
public Video get(int id){
Video video = null;
String sql = "select * from videos where id = "+id;
this.dao.getConnection();
ResultSet rs = this.dao.executaConsultaSQL(sql);
try {
if(rs.next()){
video = new Video(rs.getInt("id"),rs.getString("description"),rs.getString("name"),rs.getString("author"),
rs.getString("tags"),"",rs.getLong("datemodification"),rs.getString("license").charAt(0),rs.getInt("width"),rs.getInt("height"),
"",rs.getLong("length"),rs.getDate("dateinsertion"),rs.getString("extension"),rs.getInt("bitrate"),
rs.getDouble("framerate"),rs.getString("duration"),rs.getString("standard"));
video.setVideo("video"+video.getId()+"."+video.getExtension());
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.dao.closeConnection();
return video;
}
public Vector search(String kind, String value,int begin){
int offset = begin-1;
Vector retorno = new Vector();
String sql = "select * from videos where "+kind+" LIKE '%" + value + "%' ORDER BY id ASC LIMIT 10 OFFSET "+offset;
this.dao.getConnection();
ResultSet rs = this.dao.executaConsultaSQL(sql);
try {
while(rs.next()){
Video video = new Video(rs.getInt("id"),rs.getString("description"),rs.getString("name"),rs.getString("author"),
rs.getString("tags"),"",rs.getLong("datemodification"),rs.getString("license").charAt(0),rs.getInt("width"),rs.getInt("height"),
"",rs.getLong("length"),rs.getDate("dateinsertion"),rs.getString("extension"),rs.getInt("bitrate"),
rs.getDouble("framerate"),rs.getString("duration"),rs.getString("standard"));
video.setVideo("video"+video.getId()+"."+video.getExtension());
retorno.add(video);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("Excecao no search em VideoDAO"+e.getMessage());
e.printStackTrace();
}
this.dao.closeConnection();
return retorno;
}
public Vector searchAdvanced(String searchType, String value1, String value2, int begin){
int offset = begin-1;
Vector retorno = new Vector();
String sql = "";
if(searchType.equals("period")){
sql = "select * from videos where dateinsertion >= '"+value1+"' and dateinsertion <= '"+value2+
"' ORDER BY id ASC LIMIT 10 OFFSET "+offset;
}else if(searchType.equals("resolution")){
sql = "select * from videos where width = "+value1+" and height = "+value2+
" ORDER BY id ASC LIMIT 10 OFFSET "+offset;
}
this.dao.getConnection();
ResultSet rs = this.dao.executaConsultaSQL(sql);
try {
while(rs.next()){
Video video = new Video(rs.getInt("id"),rs.getString("description"),rs.getString("name"),rs.getString("author"),
rs.getString("tags"),"",rs.getLong("datemodification"),rs.getString("license").charAt(0),rs.getInt("width"),rs.getInt("height"),
"",rs.getLong("length"),rs.getDate("dateinsertion"),rs.getString("extension"),rs.getInt("bitrate"),
rs.getDouble("framerate"),rs.getString("duration"),rs.getString("standard"));
video.setVideo("video"+video.getId()+"."+video.getExtension());
retorno.add(video);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("Excecao no SearchAdvanced em VideoDao"+e.getMessage());
e.printStackTrace();
}
this.dao.closeConnection();
return retorno;
}
public int getAmount(String kind, String value){
int ret = 0;
String sql = "select count(*) from videos where "+kind+" like '%"+value+"%'";
this.dao.getConnection();
ResultSet rs = this.dao.executaConsultaSQL(sql);
try {
if(rs.next()){
ret = rs.getInt("count");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("Excecao no getAmount do VideoDAO"+e.getMessage());
e.printStackTrace();
}
this.dao.closeConnection();
return ret;
}
public int getAmountAdvanced(String searchType, String value1, String value2){
int ret = 0;
//String sql = "select count(*) from images where "+kind+" like '%"+value+"%'";
String sql = "";
if(searchType.equals("period")){
sql = "select count(*) from videos where dateinsertion >= '"+value1+"' and dateinsertion <= '"+value2+"'";
}else if(searchType.equals("resolution")){
sql = "select count(*) from videos where width = "+value1+" and height = "+value2;
}
this.dao.getConnection();
ResultSet rs = this.dao.executaConsultaSQL(sql);
try {
if(rs.next()){
ret = rs.getInt("count");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("Excecao no getAmountAdvanced do VideoDAO"+e.getMessage());
e.printStackTrace();
}
this.dao.closeConnection();
return ret;
}
}
@@ -0,0 +1,167 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_sdmm.general;
/*
* ConvertXMLtoHTML.java
*
* Created on December 23, 2007, 12:40 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.util.ArrayList;
import java.util.Hashtable;
import java.lang.reflect.Method;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class ConvertXMLtoHTML {
private static final String VIEWER_XML_PATH_FORMAT = "http://localhost:8080/AmadeusSDMM/VideoViewerXML.jsp?id=%d";
private static final String SEARCH_XML_PATH_FORMAT = "http://localhost:8080/AmadeusSDMM/PageSearchVideoXML.jsp?tipo=%s&valor=%s&page=%d";
private static final String VIEWER_PATH_FORMAT = "http://localhost:8080/AmadeusLMS/jsp/course/content_management/activities/ViewMultimediaActivities.jsp?id=%d";
public static String viewerConvert(int videoId) {
final String MODEL_PATH = "http://localhost:8080/AmadeusLMS/ModelViewer.html";
String html = null;
try {
InputStream xmlStream = new URL(String.format(VIEWER_XML_PATH_FORMAT, videoId)).openStream();
Document xmlDoc = parseXmlFile(xmlStream);
NodeList childNodes = xmlDoc.getFirstChild().getChildNodes();
Hashtable<String, String> table = new Hashtable<String, String>();
for (int i = 1; i < childNodes.getLength(); i += 2) {
Node item = childNodes.item(i);
String nodeName = item.getNodeName();
String nodeValue = item.getFirstChild().getNodeValue();
table.put(nodeName, nodeValue);
}
xmlStream.close();
InputStream modelStream = new URL(MODEL_PATH).openStream();
byte[] bytes = new byte[modelStream.available()];
modelStream.read(bytes);
modelStream.close();
String param = new String(bytes, Charset.forName("ISO-8859-1"));
//String param = new String(bytes);
String lengthInKB = String.valueOf(Long.parseLong(table.get("length"))/1024);
html = String.format(param,
table.get("url"),
table.get("name"),
table.get("author"),
table.get("description"),
table.get("tags"),
table.get("license"),
table.get("width"),
table.get("height"),
lengthInKB,
table.get("date-of-insertion")
);
} catch (IOException e) {
e.printStackTrace();
}
return html;
}
public static String searchConvert(String tipo, String valor, int pageNumber) {
final String internalFormat =
"<tr><td><center><a href='javascript:void(0)' onclick='viewMultimedia(%s);'><img src='%s' width='160' height='120' /></a></center></td></tr>\n" +
"<tr><td><b>Nome: </b>%s</td></tr>\n" +
"<tr><td><b>Autor: </b>%s</td></tr>\n" +
"<tr><td><b>Descrição: </b>%s</td></tr>\n" +
"<tr><td><b>Tags: </b>%s</td></tr>\n" +
"<tr><td><b>Data de Inserção: </b>%s</td></tr>\n";
final String internalLineDivisor = "<tr><td><hr size='1'/></td></tr>\n";
final String MODEL_PATH = "http://localhost:8080/AmadeusLMS/modelSearch.html";
String html = null;
try {
InputStream xmlStream = new URL(String.format(SEARCH_XML_PATH_FORMAT, tipo, valor, pageNumber)).openStream();
Document xmlDoc = parseXmlFile(xmlStream);
NodeList childNodes = xmlDoc.getFirstChild().getChildNodes();
ArrayList<Hashtable<String, String>> table = new ArrayList<Hashtable<String,String>>();
for (int i = 1; i < childNodes.getLength(); i += 2) {
NodeList video = childNodes.item(i).getChildNodes();
table.add(new Hashtable<String, String>());
for (int j = 1; j < video.getLength(); j += 2) {
Node item = video.item(j);
String nodeName = item.getNodeName();
String nodeValue = item.getFirstChild().getNodeValue();
table.get((i-1)/2).put(nodeName, nodeValue);
}
}
xmlStream.close();
InputStream modelStream = new URL(MODEL_PATH).openStream();
byte[] bytes = new byte[modelStream.available()];
modelStream.read(bytes);
modelStream.close();
String param = new String(bytes);
String concatInterno = "";
String idObjeto;
for (int i = 0; i < table.size(); i++) {
Hashtable<String, String> hash = table.get(i);
idObjeto = hash.get("id");
String thumb = hash.get("thumbnail");
thumb = (thumb != null) ? thumb : "http://localhost:8080/AmadeusSDMM/images/thumbnail1239.jpg";
String subHtml = String.format(internalFormat,
idObjeto,
thumb,
hash.get("name"),
hash.get("author"),
hash.get("description"),
hash.get("tags"),
hash.get("date-of-insertion")
);
concatInterno += subHtml;
if (i < table.size() - 1) {
concatInterno += internalLineDivisor + "\n";
}
}
html = String.format(param, concatInterno);
} catch (IOException e) {
e.printStackTrace();
}
return html;
}
private static Document parseXmlFile(InputStream inStream) {
Document doc = null;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
doc = factory.newDocumentBuilder().parse(inStream);
} catch (Exception e) { }
return doc;
}
public static void main(String[] args) {
String convert = ConvertXMLtoHTML.searchConvert("author","armando",-1);
System.out.println(convert);
}
}
@@ -0,0 +1,185 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_sdmm.general;
/**
* @author Armando Soares Sousa
*
*/
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Enumeration;
/**Class that init all set configurations to Sdmm application
*
* @author armando
* @version
*/
public final class Sdmm extends HttpServlet {
public static String tempDirectory;
public static String tempDirectoryImages;
public static String directoryImages;
public static String publicDirectoryImages;
public static String tempDirectoryAudios;
public static String directoryAudios;
public static String publicDirectoryAudios;
public static String tempDirectoryVideos;
public static String directoryVideos;
public static String publicDirectoryVideos;
public static String tempDirectoryVORs;
public static String directoryVORs;
public static String publicDirectoryVORs;
public static String ipAddress;
public static String soType;
public static String userDataBase;
public static String passwordDataBase;
public static String nameDataBase;
public static String portDataBase;
public static String ipAddressDataBase;
/*Starts all parameters to Sdmm application
*
*@param Config - all parameters from web.xml web configuration file
*/
public void init(ServletConfig config) throws ServletException{
Enumeration parameters = config.getInitParameterNames();
while(parameters.hasMoreElements()){
String parameter = (String) parameters.nextElement();
if (parameter.equals("tempDirectory")){
this.tempDirectory = config.getInitParameter("tempDirectory");
}
/*stars configuration parameters about image*/
if (parameter.equals("tempDirectoryImages")){
this.tempDirectoryImages = config.getInitParameter("tempDirectoryImages");
}
if (parameter.equals("directoryImages")){
this.directoryImages = config.getInitParameter("directoryImages");
}
if (parameter.equals("publicDirectoryImages")){
this.publicDirectoryImages = config.getInitParameter("publicDirectoryImages");
}
/*end of configuration parameters about image*/
/*stars configuration parameters about audio*/
if (parameter.equals("tempDirectoryAudios")){
this.tempDirectoryAudios = config.getInitParameter("tempDirectoryAudios");
}
if (parameter.equals("directoryAudios")){
this.directoryAudios = config.getInitParameter("directoryAudios");
}
if (parameter.equals("publicDirectoryAudios")){
this.publicDirectoryAudios = config.getInitParameter("publicDirectoryAudios");
}
/*end of configuration parameters about audio*/
/*stars configuration parameters about video*/
if (parameter.equals("tempDirectoryVideos")){
this.tempDirectoryVideos = config.getInitParameter("tempDirectoryVideos");
}
if (parameter.equals("directoryVideos")){
this.directoryVideos = config.getInitParameter("directoryVideos");
}
if (parameter.equals("publicDirectoryVideos")){
this.publicDirectoryVideos = config.getInitParameter("publicDirectoryVideos");
}
/*end of configuration parameters about video*/
/*stars configuration parameters about VOR - Virtual Object Reality*/
if (parameter.equals("tempDirectoryVORs")){
this.tempDirectoryVORs = config.getInitParameter("tempDirectoryVORs");
}
if (parameter.equals("directoryVORs")){
this.directoryVORs = config.getInitParameter("directoryVORs");
}
if (parameter.equals("publicDirectoryVORs")){
this.publicDirectoryVORs = config.getInitParameter("publicDirectoryVORs");
}
/*end of configuration parameters about VOR*/
if (parameter.equals("ipAddress")){
this.ipAddress = config.getInitParameter("ipAddress");
}
if (parameter.equals("soType")){
this.soType = config.getInitParameter("soType");
}
if (parameter.equals("userDataBase")){
this.userDataBase = config.getInitParameter("userDataBase");
}
if (parameter.equals("passwordDataBase")){
this.passwordDataBase = config.getInitParameter("passwordDataBase");
}
if (parameter.equals("nameDataBase")){
this.nameDataBase = config.getInitParameter("nameDataBase");
}
if (parameter.equals("portDataBase")){
this.portDataBase = config.getInitParameter("portDataBase");
}
if (parameter.equals("ipAddressDataBase")){
this.ipAddressDataBase = config.getInitParameter("ipAddressDataBase");
}
}
}
/** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet Sdmm</title>");
out.println("</head>");
out.println("<body>");
out.println("<h3>Servlet Sdmm at " + request.getContextPath () + "</h3>");
out.println("<p>Parametros de configuracao da aplicacao carregados!</p>");
out.println("<a href='Prototipo.jsp'>Prototipo SDMM</a>");
out.println("</body>");
out.println("</html>");
out.close();
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/** Returns a short description of the servlet.
*/
public String getServletInfo() {
return "Servlets that starts all configuration parameters to Sdmm application.";
}
// </editor-fold>
}
@@ -0,0 +1,92 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.ArchiveDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.CourseDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.DeliveryDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.ForumDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.GameDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.HistoryLearningObjectDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.HomeworkDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.KeywordDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.LearningObjectDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.MaterialDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.MaterialRequestDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.MessageDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.ModuleDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.PersonRoleCourseDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.PollDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.RoleDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.VideoIrizDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.register.AccessInfoDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.register.OpenIDDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.register.PersonDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.register.ResumeDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.register.UserRequestDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.evaluation.EvaluationDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.evaluation.EvaluationRealizedDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.externallink.ExternalLinkDAO;
public abstract class DAOFactory {
/**
* Creates a standalone DAOFactory that returns unmanaged DAO
* beans for use in any environment Hibernate has been configured
* for. Uses HibernateUtil/SessionFactory and Hibernate context
* propagation (CurrentSessionContext), thread-bound or transaction-bound,
* and transaction scoped.
*/
@SuppressWarnings("unchecked")
public static final Class HIBERNATE = br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.HibernateDAOFactory.class;
/**
* Factory method for instantiation of concrete factories.
*/
@SuppressWarnings("unchecked")
public static DAOFactory instance(Class factory) {
try {
return (DAOFactory)factory.newInstance();
} catch (Exception ex) {
throw new RuntimeException("Couldn't create DAOFactory: " + factory);
}
}
public abstract PersonDAO getPersonDAO();
public abstract AccessInfoDAO getAccessInfoDAO();
public abstract OpenIDDAO getOpenIDDAO();
public abstract KeywordDAO getKeywordDAO();
public abstract CourseDAO getCourseDAO();
public abstract UserRequestDAO getUserRequestDAO();
public abstract HomeworkDAO getHomeworkDAO();
public abstract RoleDAO getRoleDAO();
public abstract DeliveryDAO getDeliveryDAO();
public abstract PersonRoleCourseDAO getPersonRoleCourseDAO();
public abstract ModuleDAO getModuleDAO();
public abstract PollDAO getPollDAO();
public abstract MaterialDAO getMaterialDAO();
public abstract MaterialRequestDAO getMaterialRequestDAO();
public abstract ResumeDAO getResumeDAO();
public abstract GameDAO getGameDAO();
public abstract ForumDAO getForumDAO();
public abstract MessageDAO getMessageDAO();
public abstract ArchiveDAO getArchiveDAO();
public abstract VideoIrizDAO getVideoIrizDAO();
public abstract LearningObjectDAO getLearningObjectDAO();
public abstract HistoryLearningObjectDAO getHistoryLearningObjectDAO();
public abstract EvaluationDAO getEvaluationDAO();
public abstract EvaluationRealizedDAO getEvaluationRealizedDAO();
public abstract ExternalLinkDAO getExternalLinkDAO();
}
@@ -0,0 +1,39 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo parte do programa Amadeus Sistema de Gesto de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS um software livre; voc pode redistribui-lo e/ou modifica-lo dentro dos termos da Licena Pblica Geral GNU como
publicada pela Fundao do Software Livre (FSF); na verso 2 da Licena.
Este programa distribudo na esperana que possa ser til, mas SEM NENHUMA GARANTIA; sem uma garantia implcita de ADEQUAO a qualquer MERCADO ou APLICAO EM PARTICULAR. Veja a Licena Pblica Geral GNU para maiores detalhes.
Voc deve ter recebido uma cpia da Licena Pblica Geral GNU, sob o ttulo "LICENCA.txt", junto com este programa, se no, escreva para a Fundao do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao;
import java.io.Serializable;
import java.util.List;
public interface GenericDAO<T, ID extends Serializable> {
T findById(ID id, boolean lock);
List<T> findAll();
List<T> findByExample(T exampleInstance);
List<T> findByExample(T exampleInstance, String[] excludeProperty);
T findUniqueByExample(T exampleInstance, String[] excludeProperty);
T findUniqueByExample(T exampleInstance);
T makePersistent(T entity);
T merge(T entity);
void makeTransient(T entity);
}
@@ -0,0 +1,21 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Archive;
public interface ArchiveDAO extends GenericDAO <Archive, Integer> {
}
@@ -0,0 +1,43 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo parte do programa Amadeus Sistema de Gesto de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS um software livre; voc pode redistribui-lo e/ou modifica-lo dentro dos termos da Licena Pblica Geral GNU como
publicada pela Fundao do Software Livre (FSF); na verso 2 da Licena.
Este programa distribudo na esperana que possa ser til, mas SEM NENHUMA GARANTIA; sem uma garantia implcita de ADEQUAO a qualquer MERCADO ou APLICAO EM PARTICULAR. Veja a Licena Pblica Geral GNU para maiores detalhes.
Voc deve ter recebido uma cpia da Licena Pblica Geral GNU, sob o ttulo "LICENCA.txt", junto com este programa, se no, escreva para a Fundao do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import java.util.Date;
import java.util.List;
import java.util.Set;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Keyword;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.AccessInfo;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.Person;
public interface CourseDAO extends GenericDAO <Course, Integer>{
public List<Course> searchCoursesByUser(AccessInfo userInfo);
public List<Course> getCoursesByKeyword(Keyword key);
public List<Course> getCoursesByContent(String cont);
public List<Course> getCoursesByName(String name);
public List<Course> getCoursesByProfessors(List<Person> professors);
public List<Course> getCoursesByObjectives(String objs);
public List<Course> getCoursesByInitialDate(Date initialDate);
public List<Course> getCoursesByFinalDate(Date finalDate);
public List<Course> getCoursesByAdvancedRule(String name, String professorName, Date initialDate, Date finalDate);
public boolean courseNameExist(Course course);
public void deleteKeywordsOrphan();
public void incrementPopularityKeyword(int courseId, Set<Keyword> keywords);
public void decrementPopularityKeyword(int courseId, Set<Keyword> keywords);
}
@@ -0,0 +1,24 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Delivery;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Role;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.AccessInfo;
public interface DeliveryDAO extends GenericDAO <Delivery, Integer>{
int getNumberOfDoneHomeworks(AccessInfo user, Role studentRole);
}
@@ -0,0 +1,21 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Forum;
public interface ForumDAO extends GenericDAO <Forum, Integer> {
}
@@ -0,0 +1,21 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Game;
public interface GameDAO extends GenericDAO <Game, Integer>{
}
@@ -0,0 +1,23 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.HistoryLearningObject;
public interface HistoryLearningObjectDAO extends GenericDAO<HistoryLearningObject, Integer> {
public int getTotalAccessLearningObject(int idLearning);
}
@@ -0,0 +1,24 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Homework;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Role;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.AccessInfo;
public interface HomeworkDAO extends GenericDAO <Homework, Integer>{
int getTotalUserHomeworks(AccessInfo user, Role studentRole);
}
@@ -0,0 +1,29 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo parte do programa Amadeus Sistema de Gesto de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS um software livre; voc pode redistribui-lo e/ou modifica-lo dentro dos termos da Licena Pblica Geral GNU como
publicada pela Fundao do Software Livre (FSF); na verso 2 da Licena.
Este programa distribudo na esperana que possa ser til, mas SEM NENHUMA GARANTIA; sem uma garantia implcita de ADEQUAO a qualquer MERCADO ou APLICAO EM PARTICULAR. Veja a Licena Pblica Geral GNU para maiores detalhes.
Voc deve ter recebido uma cpia da Licena Pblica Geral GNU, sob o ttulo "LICENCA.txt", junto com este programa, se no, escreva para a Fundao do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Keyword;
public interface KeywordDAO extends GenericDAO<Keyword, Integer> {
public List<Keyword> getMostPopularKeywords();
public Keyword getKeywordByName(String name);
public List<Keyword> getKeywordsByCourse(Course c);
public Keyword getKeywordWithIdByName(String name);
}
@@ -0,0 +1,21 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.LearningObject;
public interface LearningObjectDAO extends GenericDAO<LearningObject, Integer>{
}
@@ -0,0 +1,25 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Material;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.MaterialRequest;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.Person;
public interface MaterialDAO extends GenericDAO<Material, Integer> {
Material getMaterial(Person person, MaterialRequest materialRequest);
}
@@ -0,0 +1,21 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.MaterialRequest;
public interface MaterialRequestDAO extends GenericDAO<MaterialRequest, Integer>{
}
@@ -0,0 +1,26 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Forum;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Message;
public interface MessageDAO extends GenericDAO <Message, Integer> {
public List<Message> searchMessageByPaging(int tamanhoBloco, int qtdBloco, Forum forum);
public int getSizeSearchMessageByForum(Forum forum);
}
@@ -0,0 +1,22 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo parte do programa Amadeus Sistema de Gesto de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS um software livre; voc pode redistribui-lo e/ou modifica-lo dentro dos termos da Licena Pblica Geral GNU como
publicada pela Fundao do Software Livre (FSF); na verso 2 da Licena.
Este programa distribudo na esperana que possa ser til, mas SEM NENHUMA GARANTIA; sem uma garantia implcita de ADEQUAO a qualquer MERCADO ou APLICAO EM PARTICULAR. Veja a Licena Pblica Geral GNU para maiores detalhes.
Voc deve ter recebido uma cpia da Licena Pblica Geral GNU, sob o ttulo "LICENCA.txt", junto com este programa, se no, escreva para a Fundao do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Module;
public interface ModuleDAO extends GenericDAO <Module, Integer>{
public int getNextPositionModule(Course course);
}
@@ -0,0 +1,26 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
/**
* @author armando
*
*/
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Multimedia;
public interface MultimediaDAO extends GenericDAO <Multimedia, Integer>{
}
@@ -0,0 +1,34 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo parte do programa Amadeus Sistema de Gesto de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS um software livre; voc pode redistribui-lo e/ou modifica-lo dentro dos termos da Licena Pblica Geral GNU como
publicada pela Fundao do Software Livre (FSF); na verso 2 da Licena.
Este programa distribudo na esperana que possa ser til, mas SEM NENHUMA GARANTIA; sem uma garantia implcita de ADEQUAO a qualquer MERCADO ou APLICAO EM PARTICULAR. Veja a Licena Pblica Geral GNU para maiores detalhes.
Voc deve ter recebido uma cpia da Licena Pblica Geral GNU, sob o ttulo "LICENCA.txt", junto com este programa, se no, escreva para a Fundao do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.PersonRoleCourse;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Role;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.Person;
public interface PersonRoleCourseDAO extends GenericDAO<PersonRoleCourse, Integer>{
public List<Person> searchUsersByCoursesAndRole(Course course, Role role);
public int getNumberOfStudentsInCourse(Course c, Role role);
public boolean isRegisteredUser(Person user, Course c);
public List<PersonRoleCourse> findUsersRegisteredInCourseByRole(Course course, Role role);
public List<PersonRoleCourse> canAssistanceRequest(Person person, Course course, Role role);
public boolean isStudent(Person person, Course course, Role role);
public List<PersonRoleCourse> getPossibleTeacherOrAssistantsInCourse(Person person, Role roleA, Role roleT, Course course);
public List<PersonRoleCourse> getByRoleInCourse(Person person, Course course, Role role);
public List<PersonRoleCourse> getStudentRolesCourses(int studentId);
}
@@ -0,0 +1,21 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Poll;
public interface PollDAO extends GenericDAO<Poll, Integer> {
}
@@ -0,0 +1,25 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo parte do programa Amadeus Sistema de Gesto de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS um software livre; voc pode redistribui-lo e/ou modifica-lo dentro dos termos da Licena Pblica Geral GNU como
publicada pela Fundao do Software Livre (FSF); na verso 2 da Licena.
Este programa distribudo na esperana que possa ser til, mas SEM NENHUMA GARANTIA; sem uma garantia implcita de ADEQUAO a qualquer MERCADO ou APLICAO EM PARTICULAR. Veja a Licena Pblica Geral GNU para maiores detalhes.
Voc deve ter recebido uma cpia da Licena Pblica Geral GNU, sob o ttulo "LICENCA.txt", junto com este programa, se no, escreva para a Fundao do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Role;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.Person;
public interface RoleDAO extends GenericDAO <Role, Integer>{
public List<Role> getRoleByPersonInCourse(Person person, Course course);
}
@@ -0,0 +1,21 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.VideoIriz;
public interface VideoIrizDAO extends GenericDAO<VideoIriz, Integer>{
}
@@ -0,0 +1,24 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo parte do programa Amadeus Sistema de Gesto de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS um software livre; voc pode redistribui-lo e/ou modifica-lo dentro dos termos da Licena Pblica Geral GNU como
publicada pela Fundao do Software Livre (FSF); na verso 2 da Licena.
Este programa distribudo na esperana que possa ser til, mas SEM NENHUMA GARANTIA; sem uma garantia implcita de ADEQUAO a qualquer MERCADO ou APLICAO EM PARTICULAR. Veja a Licena Pblica Geral GNU para maiores detalhes.
Voc deve ter recebido uma cpia da Licena Pblica Geral GNU, sob o ttulo "LICENCA.txt", junto com este programa, se no, escreva para a Fundao do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.evaluation;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.evaluation.Evaluation;
public interface EvaluationDAO extends GenericDAO <Evaluation, Integer> {
public List<Evaluation> getAllEvaluationFromCourse(Course course);
}
@@ -0,0 +1,21 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.evaluation;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.evaluation.realized.EvaluationRealized;
public interface EvaluationRealizedDAO extends GenericDAO <EvaluationRealized, Integer> {
}
@@ -0,0 +1,8 @@
package br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.externallink;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.ExternalLink;
public interface ExternalLinkDAO extends GenericDAO<ExternalLink, Integer>{
}
@@ -0,0 +1,155 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo parte do programa Amadeus Sistema de Gesto de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS um software livre; voc pode redistribui-lo e/ou modifica-lo dentro dos termos da Licena Pblica Geral GNU como
publicada pela Fundao do Software Livre (FSF); na verso 2 da Licena.
Este programa distribudo na esperana que possa ser til, mas SEM NENHUMA GARANTIA; sem uma garantia implcita de ADEQUAO a qualquer MERCADO ou APLICAO EM PARTICULAR. Veja a Licena Pblica Geral GNU para maiores detalhes.
Voc deve ter recebido uma cpia da Licena Pblica Geral GNU, sob o ttulo "LICENCA.txt", junto com este programa, se no, escreva para a Fundao do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.hibernate;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.util.List;
import javax.persistence.EntityManager;
import org.hibernate.Criteria;
import org.hibernate.LockMode;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Example;
import br.ufpe.cin.amadeus.amadeus_web.dao.GenericDAO;
public abstract class GenericHibernateDAO<T, ID extends Serializable>
implements GenericDAO<T, ID> {
private Class<T> persistentClass;
private Session session;
private EntityManager entityManager;
@SuppressWarnings("unchecked")
public GenericHibernateDAO() {
this.persistentClass = (Class<T>) ((ParameterizedType) getClass()
.getGenericSuperclass()).getActualTypeArguments()[0];
}
public void setSession(Session s) {
this.session = s;
}
protected Session getSession() {
if (session == null)
throw new IllegalStateException(
"Session has not been set on DAO before usage");
return session;
}
public Class<T> getPersistentClass() {
return persistentClass;
}
@SuppressWarnings("unchecked")
public T findById(ID id, boolean lock) {
T entity;;
if (lock)
entity = (T) getSession().load(getPersistentClass(), id,
LockMode.UPGRADE);
else
entity = (T) getSession().load(getPersistentClass(), id);
return entity;
}
public List<T> findAll() {
return findByCriteria();
}
@SuppressWarnings("unchecked")
public List<T> findByExample(T exampleInstance) {
Criteria crit = getSession().createCriteria(getPersistentClass());
Example example = Example.create(exampleInstance);
crit.add(example);
List<T> results = crit.list();
return results;
}
@SuppressWarnings("unchecked")
public T findUniqueByExample(T exampleInstance) {
Criteria crit = getSession().createCriteria(getPersistentClass());
Example example = Example.create(exampleInstance);
crit.add(example);
T result = (T)crit.uniqueResult();
return result;
}
@SuppressWarnings("unchecked")
public List<T> findByExample(T exampleInstance, String[] excludeProperty) {
Criteria crit = getSession().createCriteria(getPersistentClass());
Example example = Example.create(exampleInstance);
for (String exclude : excludeProperty) {
example.excludeProperty(exclude);
}
crit.add(example);
List<T> results = crit.list();
return results;
}
@SuppressWarnings("unchecked")
public T findUniqueByExample(T exampleInstance, String[] excludeProperty) {
Criteria crit = getSession().createCriteria(getPersistentClass());
Example example = Example.create(exampleInstance);
for (String exclude : excludeProperty) {
example.excludeProperty(exclude);
}
crit.add(example);
T result = (T)crit.uniqueResult();
return result;
}
public T makePersistent(T entity) {
getSession().saveOrUpdate(entity);
return entity;
}
public T merge(T entity) {
getSession().merge(entity);
return entity;
}
public void makeTransient(T entity) {
getSession().delete(entity);
}
public void flush() {
getSession().flush();
}
public void clear() {
getSession().clear();
}
/**
* Use this inside subclasses as a convenience method.
*/
@SuppressWarnings("unchecked")
protected List<T> findByCriteria(Criterion... criterion) {
Criteria crit = getSession().createCriteria(getPersistentClass());
for (Criterion c : criterion) {
crit.add(c);
}
List<T> results = crit.list();
return results;
}
}
@@ -0,0 +1,190 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.hibernate;
import org.hibernate.Session;
import br.ufpe.cin.amadeus.amadeus_web.dao.DAOFactory;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.ArchiveDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.CourseDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.DeliveryDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.ForumDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.GameDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.HistoryLearningObjectDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.HomeworkDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.KeywordDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.LearningObjectDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.MaterialDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.MaterialRequestDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.MessageDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.ModuleDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.PersonRoleCourseDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.PollDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.RoleDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.VideoIrizDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.evaluation.EvaluationDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.evaluation.EvaluationRealizedDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.externallink.ExternalLinkDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.ArchiveHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.CourseHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.DeliveryHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.ForumHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.GameHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.HistoryLearningObjectHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.HomeworkHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.KeywordHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.LearningObjectHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.MaterialHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.MaterialRequestHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.MessageHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.ModuleHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.PersonRoleCourseHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.PollHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.RoleHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.VideoIrizHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.evaluation.EvaluationHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.evaluation.EvaluationRealizedHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment.externallink.ExternalLinkHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.register.AccessInfoHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.register.OpenIDHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.register.PersonHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.register.ResumeHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.register.UserRequestHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.register.AccessInfoDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.register.OpenIDDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.register.PersonDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.register.ResumeDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.register.UserRequestDAO;
public class HibernateDAOFactory extends DAOFactory {
public PersonDAO getPersonDAO() {
return (PersonDAO)instantiateDAO(PersonHibernateDAO.class);
}
public UserRequestDAO getUserRequestDAO(){
return (UserRequestDAO) instantiateDAO(UserRequestHibernateDAO.class);
}
public AccessInfoDAO getAccessInfoDAO(){
return (AccessInfoDAO) instantiateDAO(AccessInfoHibernateDAO.class);
}
public DeliveryDAO getDeliveryDAO(){
return (DeliveryDAO) instantiateDAO(DeliveryHibernateDAO.class);
}
public KeywordDAO getKeywordDAO() {
return (KeywordDAO)instantiateDAO(KeywordHibernateDAO.class);
}
public CourseDAO getCourseDAO(){
return (CourseDAO) instantiateDAO(CourseHibernateDAO.class);
}
public ModuleDAO getModuleDAO(){
return (ModuleDAO) instantiateDAO(ModuleHibernateDAO.class);
}
public HomeworkDAO getHomeworkDAO(){
return (HomeworkDAO) instantiateDAO(HomeworkHibernateDAO.class);
}
public RoleDAO getRoleDAO() {
return (RoleDAO) instantiateDAO(RoleHibernateDAO.class);
}
public PersonRoleCourseDAO getPersonRoleCourseDAO() {
return (PersonRoleCourseDAO) instantiateDAO(PersonRoleCourseHibernateDAO.class);
}
@SuppressWarnings("unchecked")
private GenericHibernateDAO instantiateDAO(Class daoClass) {
try {
GenericHibernateDAO dao = (GenericHibernateDAO)daoClass.newInstance();
dao.setSession(getCurrentSession());
return dao;
} catch (Exception ex) {
throw new RuntimeException("Can not instantiate DAO: " + daoClass, ex);
}
}
// You could override this if you don't want HibernateUtil for lookup
protected Session getCurrentSession() {
return HibernateUtil.getSessionFactory().getCurrentSession();
}
public PollDAO getPollDAO() {
return (PollDAO) instantiateDAO(PollHibernateDAO.class);
}
public MaterialDAO getMaterialDAO() {
return (MaterialDAO) instantiateDAO(MaterialHibernateDAO.class);
}
public MaterialRequestDAO getMaterialRequestDAO() {
return (MaterialRequestDAO) instantiateDAO(MaterialRequestHibernateDAO.class);
}
public ResumeDAO getResumeDAO(){
return (ResumeDAO) instantiateDAO(ResumeHibernateDAO.class);
}
public GameDAO getGameDAO(){
return (GameDAO) instantiateDAO(GameHibernateDAO.class);
}
public ForumDAO getForumDAO(){
return (ForumDAO) instantiateDAO(ForumHibernateDAO.class);
}
public MessageDAO getMessageDAO(){
return (MessageDAO) instantiateDAO(MessageHibernateDAO.class);
}
public ArchiveDAO getArchiveDAO() {
return (ArchiveDAO) instantiateDAO(ArchiveHibernateDAO.class);
}
public VideoIrizDAO getVideoIrizDAO() {
return (VideoIrizDAO) instantiateDAO(VideoIrizHibernateDAO.class);
}
public LearningObjectDAO getLearningObjectDAO(){
return (LearningObjectDAO) instantiateDAO(LearningObjectHibernateDAO.class);
}
public HistoryLearningObjectDAO getHistoryLearningObjectDAO() {
return (HistoryLearningObjectDAO) instantiateDAO(HistoryLearningObjectHibernateDAO.class);
}
public EvaluationDAO getEvaluationDAO(){
return (EvaluationDAO) instantiateDAO(EvaluationHibernateDAO.class);
}
public EvaluationRealizedDAO getEvaluationRealizedDAO(){
return (EvaluationRealizedDAO) instantiateDAO(EvaluationRealizedHibernateDAO.class);
}
public OpenIDDAO getOpenIDDAO() {
return (OpenIDDAO) instantiateDAO(OpenIDHibernateDAO.class);
}
public ExternalLinkDAO getExternalLinkDAO(){
return (ExternalLinkDAO) instantiateDAO(ExternalLinkHibernateDAO.class);
}
}
@@ -0,0 +1,43 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.hibernate;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
public class HibernateUtil {
private static SessionFactory sessionFactory;
static {
try {
/*sessionFactory = new Configuration().configure()
.buildSessionFactory();*/
sessionFactory = new AnnotationConfiguration().configure("hibernate.cfg.xml").buildSessionFactory();
} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static void shutdown() {
getSessionFactory().close();
}
}
@@ -0,0 +1,15 @@
package br.ufpe.cin.amadeus.amadeus_web.dao.hibernate;
import org.hibernate.criterion.Example.PropertySelector;
import org.hibernate.type.Type;
public final class NotNullOrBlankPropertySelector implements PropertySelector {
private static final long serialVersionUID = 1L;
public boolean include(Object object, String propertyName, Type type) {
return object!=null || (
(object instanceof String) && !( (String) object ).equals("")
);
}
}
@@ -0,0 +1,24 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo parte do programa Amadeus Sistema de Gesto de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS um software livre; voc pode redistribui-lo e/ou modifica-lo dentro dos termos da Licena Pblica Geral GNU como
publicada pela Fundao do Software Livre (FSF); na verso 2 da Licena.
Este programa distribudo na esperana que possa ser til, mas SEM NENHUMA GARANTIA; sem uma garantia implcita de ADEQUAO a qualquer MERCADO ou APLICAO EM PARTICULAR. Veja a Licena Pblica Geral GNU para maiores detalhes.
Voc deve ter recebido uma cpia da Licena Pblica Geral GNU, sob o ttulo "LICENCA.txt", junto com este programa, se no, escreva para a Fundao do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.ArchiveDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.GenericHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Archive;
public class ArchiveHibernateDAO extends GenericHibernateDAO<Archive, Integer>
implements ArchiveDAO {
}
@@ -0,0 +1,280 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo � parte do programa Amadeus Sistema de Gest�o de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS � um software livre; voc� pode redistribui-lo e/ou modifica-lo dentro dos termos da Licen�a P�blica Geral GNU como
publicada pela Funda��o do Software Livre (FSF); na vers�o 2 da Licen�a.
Este programa � distribu�do na esperan�a que possa ser �til, mas SEM NENHUMA GARANTIA; sem uma garantia impl�cita de ADEQUA��O a qualquer MERCADO ou APLICA��O EM PARTICULAR. Veja a Licen�a P�blica Geral GNU para maiores detalhes.
Voc� deve ter recebido uma c�pia da Licen�a P�blica Geral GNU, sob o t�tulo "LICENCA.txt", junto com este programa, se n�o, escreva para a Funda��o do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import org.hibernate.Criteria;
import org.hibernate.NonUniqueResultException;
import org.hibernate.Query;
import org.hibernate.criterion.Example;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.CourseDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.GenericHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.NotNullOrBlankPropertySelector;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Course;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Keyword;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.AccessInfo;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.Person;
import br.ufpe.cin.middleware.services.session.Key;
import static org.hibernate.criterion.Expression.*;
public class CourseHibernateDAO extends GenericHibernateDAO<Course, Integer>
implements CourseDAO {
@SuppressWarnings("unchecked")
public List<Course> searchCoursesByUser(AccessInfo userInfo){
/*old
List<Course> results = getSession().createSQLQuery("SELECT * from course where " +
"id in (SELECT course_id from person_role_course where person_id = "
+userInfo.getPerson().getId() + ")").addEntity(Course.class).list();
*/
String hqlQuary = "select c from Course c,PersonRoleCourse prc where " +
"c.id = prc.course.id and prc.person.id = "+ userInfo.getPerson().getId();
List<Course> results = getSession().createQuery(hqlQuary).list();
return results;
}
@SuppressWarnings("unchecked")
public List<Course> getCoursesByKeyword(Keyword key){
/*old: List<Course> results = getSession().createSQLQuery("SELECT * from course where " +
"id in (SELECT course_id from keywordsofcourse where keywords_id = "
+ key.getId() + ")").addEntity(Course.class).list();
*/
String hqlQuery = "select c from Course c join c.keywords k where k.id = " + key.getId();
List<Course> results = getSession().createQuery(hqlQuery).list();
return results;
}
@SuppressWarnings("unchecked")
public List<Course> getCoursesByContent(String cont){
Criteria crit = getSession().createCriteria(Course.class);
crit.add(Restrictions.ilike("content", cont, MatchMode.ANYWHERE));
List<Course> results = crit.list();
return results;
}
@SuppressWarnings("unchecked")
public List<Course> getCoursesByObjectives(String objs){
Criteria crit = getSession().createCriteria(Course.class);
crit.add(Restrictions.ilike("objectives", objs, MatchMode.ANYWHERE));
List<Course> results = crit.list();
return results;
}
@SuppressWarnings("unchecked")
public List<Course> getCoursesByName(String name){
Criteria crit = getSession().createCriteria(Course.class);
crit.add(Restrictions.ilike("name", name, MatchMode.ANYWHERE));
List<Course> results = crit.list();
return results;
}
@SuppressWarnings("unchecked")
public List<Course> getCoursesByProfessors(List<Person> professors){
List<Course> results = new ArrayList<Course>();
java.util.Iterator<Person> iProfessors = professors.iterator();
while(iProfessors.hasNext()){
Person professor = iProfessors.next();
/*old: List<Course> partialResults = getSession().createSQLQuery("SELECT * from course where " +
"id in (SELECT course_id from person_role_course where person_id = "
+ professor.getId() + ")").addEntity(Course.class).list();
*/
String hql = "select c from Course c,PersonRoleCourse prc where " +
"c.id = prc.course.id and prc.person.id = " + professor.getId();
List<Course> partialResults = getSession().createQuery(hql).list();
if(!partialResults.isEmpty()){
java.util.Iterator<Course> iPartialResults = partialResults.iterator();
while(iPartialResults.hasNext()){
results.add(iPartialResults.next());
}
}
}
return results;
}
@SuppressWarnings("unchecked")
public List<Course> getCoursesByInitialDate(Date initialDate){
String hqlQuery = "select c from Course c where c.initialCourseDate = :date ";
Query objQuery = getSession().createQuery(hqlQuery);
objQuery.setDate("date", initialDate);
List<Course> results = objQuery.list();
return results;
}
@SuppressWarnings("unchecked")
public List<Course> getCoursesByFinalDate(Date finalDate){
String hqlQuery = "select c from Course c where c.finalCourseDate = :date ";
Query objQuery = getSession().createQuery(hqlQuery);
objQuery.setDate("date", finalDate);
List<Course> results = objQuery.list();
return results;
}
public List<Course> getCoursesByAdvancedRule(String name, String professorName, Date initialDate, Date finalDate){
Course course = new Course();
course.setName(name);
course.setInitialCourseDate(initialDate);
course.setFinalCourseDate(finalDate);
Example courseExample = Example.create(course)
.setPropertySelector(new NotNullOrBlankPropertySelector()) //elimina da consulta as propriedades que são nulas ou vazias
.excludeZeroes()
.ignoreCase()
.enableLike(MatchMode.ANYWHERE);
Criteria crit = getSession().createCriteria(Course.class);
crit.add(courseExample)
.createCriteria("professor")
.add(Restrictions.ilike("name", professorName, MatchMode.ANYWHERE));
List<Course> results = crit.list();
return results;
}
@Override
public Course makePersistent(Course course) {
if(course.getId() == 0) {
getSession().save(course);
} else {
getSession().merge(course);
}
return course;
}
/**
* increase the popularity of the keyword.
*
* @param course
*/
public void incrementPopularityKeyword(int courseId, Set<Keyword> keywords) {
for (Keyword keyword : keywords) {
/*old: Integer idMyKeyword = (Integer) getSession().createSQLQuery("SELECT keywords_id from keywordsofcourse where " +
"course_id = "+ courseId + " and keywords_id = "+ keyword.getId() +";").uniqueResult();
*/
String hqlQuery = "select k.id from Course c join c.keywords k where k.id = "+keyword.getId()+
" and c.id = "+courseId;
Integer idMyKeyword = (Integer)getSession().createQuery(hqlQuery).uniqueResult();
if(idMyKeyword == null) {
keyword.setPopularity(keyword.getPopularity() + 1);
}
}
}
/**
* Decrementa a popularity da keyword
* a keyword.
*
* @param course
*/
@SuppressWarnings("unchecked")
public void decrementPopularityKeyword(int courseId, Set<Keyword> keywords) {
try {
Set<Keyword> newListKeywordsOfCourse = keywords;
//Obt�m todas as keywords relacionada a este curso no bd.
/*old: List<Keyword> oldListKeywordsOfCourseBD = getSession().createSQLQuery("SELECT k.* from keyword k " +
"join keywordsofcourse kc on(kc.keywords_id = k.id and kc.course_id = "
+ courseId+");").addEntity(Keyword.class).list();
*/
String hqlQuery = "select c.keywords from Course c where c.id = "+courseId;
List<Keyword> oldListKeywordsOfCourseBD = getSession().createQuery(hqlQuery).list();
for (Keyword keywordDB : oldListKeywordsOfCourseBD) {
if (!this.listContainsKeyword(newListKeywordsOfCourse, keywordDB)) {
keywordDB.setPopularity(keywordDB.getPopularity() - 1);
getSession().update(keywordDB);
}
}
this.deleteKeywordsOrphan();
} catch(RuntimeException e) {
e.printStackTrace();
}
}
/**
* Verifica se uma determinada keyword existe em uma determinada
* lista de keywords pelo seu id.
*
* @param keywords
* @param keyword
* @return true or false
*/
public boolean listContainsKeyword(Set<Keyword> keywords, Keyword keyword) {
boolean retorno = false;
for (Keyword k : keywords) {
if(k.getId() == keyword.getId()) {
retorno = true;
break;
}
}
return retorno;
}
public boolean courseNameExist(Course course) {
boolean retorno = false;
try {
Criteria crit = getSession().createCriteria(getPersistentClass());
crit.add( eq("name", course.getName()).ignoreCase() );
Course c = (Course) crit.uniqueResult();
if(c != null && c.getId() != course.getId()) {
retorno = true;
}
} catch (NonUniqueResultException e) {
retorno = true;
}
return retorno;
}
@SuppressWarnings("unchecked")
public void deleteKeywordsOrphan(){//TODO Discutir sobre esse m�todo ele n�o faz sentido.
getSession().flush();
// List<Keyword> keywordOrphan = getSession().createSQLQuery(
// "select * from keyword "+
// "left join keywordsofcourse kc on(keyword.id = kc.keywords_id)" +
// "where keywords_id is null")
// .addEntity(Keyword.class).list();
String hql = "select k from Course c right outer join c.keywords k where c.id = null";
List<Keyword> keywordOrphan = getSession().createQuery(hql).list();
for (Keyword kOrphan : keywordOrphan) {
getSession().delete(kOrphan);
}
}
}
@@ -0,0 +1,47 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment;
import java.util.List;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.DeliveryDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.GenericHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Delivery;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Role;
import br.ufpe.cin.amadeus.amadeus_web.domain.register.AccessInfo;
public class DeliveryHibernateDAO extends GenericHibernateDAO<Delivery, Integer>
implements DeliveryDAO{
@SuppressWarnings("unchecked")
public int getNumberOfDoneHomeworks(AccessInfo userInfo, Role role) {
/* *old:
List<Delivery> results = getSession().createSQLQuery("select * from delivery where " +
"person_id =" + userInfo.getPerson().getId() +" and homework_id in " +
"(select id from homework where module_id in " +
"(select id from module where course_id in " +
"(select course_id from person_role_course where role_id = " + role.getId() +
" and person_id =" + userInfo.getPerson().getId() + ")))").addEntity(Delivery.class).list();
*/
String hqlQuery = "select d from Delivery d,Homework as h,Module as m,PersonRoleCourse as prc where "+
"d.person.id = " + userInfo.getPerson().getId()+
" h.module.id = m.id and prc.course.id = m.course.id and prc.role.id = " + role.getId() +
"prc.person.id = " + userInfo.getPerson().getId();
List<Delivery> results = (List<Delivery>) getSession().createQuery(hqlQuery);
return results.size();
}
}
@@ -0,0 +1,22 @@
/**
Copyright 2008, 2009 UFPE - Universidade Federal de Pernambuco
Este arquivo é parte do programa Amadeus Sistema de Gestão de Aprendizagem, ou simplesmente Amadeus LMS
O Amadeus LMS é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
**/
package br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.content_managment;
import br.ufpe.cin.amadeus.amadeus_web.dao.content_managment.ForumDAO;
import br.ufpe.cin.amadeus.amadeus_web.dao.hibernate.GenericHibernateDAO;
import br.ufpe.cin.amadeus.amadeus_web.domain.content_management.Forum;
public class ForumHibernateDAO extends GenericHibernateDAO<Forum, Integer> implements ForumDAO {
}

Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais