From 914ae3c7bc78f5f519213518bad3083ab45dfb21 Mon Sep 17 00:00:00 2001 From: Samu Date: Sun, 24 Mar 2013 14:03:33 +0000 Subject: Seleccion aleatoria y de utilidad maxima implementada --- diff --git a/EjercitarClient/.pydevproject b/EjercitarClient/.pydevproject index 0b0da7e..6121ef5 100644 --- a/EjercitarClient/.pydevproject +++ b/EjercitarClient/.pydevproject @@ -4,10 +4,9 @@ /EjercitarClient +/EjercitarClient/lib/suds-0.4-py2.6.egg python 2.7 Default - -C:\Users\Samu\Downloads\suds-0.4-py2.6.egg - + diff --git a/EjercitarClient/gui/ContenedorTemas.py b/EjercitarClient/gui/ContenedorTareas.py index fd0d81c..ff60a10 100644 --- a/EjercitarClient/gui/ContenedorTemas.py +++ b/EjercitarClient/gui/ContenedorTareas.py @@ -6,18 +6,20 @@ Created on Feb 4, 2013 import gtk from gui.Ejercitario import Ejercitario -class ContenedorTemas(gtk.HBox): +class ContenedorTareas(gtk.HBox): # This is a callback function. The data arguments are ignored # in this example. More on callbacks below. - def __init__(self, id_tema, descripcion, ventana_padre, vista_temas, cliente_WS): + def __init__(self, id_alumno, id_tarea, descripcion, ventana_padre, vista_temas, cliente_WS): # create a new window - super(ContenedorTemas, self).__init__() + super(ContenedorTareas, self).__init__() self.ventana_padre = ventana_padre self.vista_temas = vista_temas self.cliente_WS = cliente_WS + self.id_alumno = id_alumno + self.id_tarea = id_tarea label_descripcion = gtk.Label(descripcion) @@ -29,6 +31,6 @@ class ContenedorTemas(gtk.HBox): def __comenzar_cb(self, boton): self.ventana_padre.remove(self.vista_temas) - ejercitario = Ejercitario(self.cliente_WS) + ejercitario = Ejercitario(self.cliente_WS, self.id_tarea, self.id_alumno) self.ventana_padre.add (ejercitario) \ No newline at end of file diff --git a/EjercitarClient/gui/ContenedorTareas.pyc b/EjercitarClient/gui/ContenedorTareas.pyc new file mode 100644 index 0000000..ef396c3 --- /dev/null +++ b/EjercitarClient/gui/ContenedorTareas.pyc Binary files differ diff --git a/EjercitarClient/gui/ContenedorTemas.pyc b/EjercitarClient/gui/ContenedorTemas.pyc deleted file mode 100644 index 2e3c80f..0000000 --- a/EjercitarClient/gui/ContenedorTemas.pyc +++ /dev/null Binary files differ diff --git a/EjercitarClient/gui/Ejercitario.py b/EjercitarClient/gui/Ejercitario.py index 16d3c44..7d60441 100644 --- a/EjercitarClient/gui/Ejercitario.py +++ b/EjercitarClient/gui/Ejercitario.py @@ -15,12 +15,17 @@ class Ejercitario(gtk.VBox): # in this example. More on callbacks below. - def __init__(self, cliente_WS): + def __init__(self, cliente_WS, id_tarea, id_alumno): # create a new window super(Ejercitario, self).__init__() + + self.id_tarea = id_tarea + self.id_alumno = id_alumno + self.cliente_WS = cliente_WS + self.__inicializar_componentes() - siguiente_ejercicio = self.__obtener_siguiente_ejercicio(cliente_WS) - self.__organizar_gui(siguiente_ejercicio) + self.siguiente_ejercicio = self.__obtener_siguiente_ejercicio(cliente_WS) + self.__organizar_gui(self.siguiente_ejercicio) #self.__sincronizar_temas() self.show_all() @@ -40,13 +45,13 @@ class Ejercitario(gtk.VBox): def __organizar_gui(self, siguiente_ejercicio): - #prueba - self.solucion1.set_label("prueba1") - self.solucion2.set_label("prueba2") - self.solucion3.set_label("prueba3") - self.solucion4.set_label("prueba4") + self.solucion1.set_label(siguiente_ejercicio.respuestaList.respuestaList[0].descripcion) + self.solucion2.set_label(siguiente_ejercicio.respuestaList.respuestaList[1].descripcion) + self.solucion3.set_label(siguiente_ejercicio.respuestaList.respuestaList[2].descripcion) + self.solucion4.set_label(siguiente_ejercicio.respuestaList.respuestaList[3].descripcion) + self.label_enunciado.set_label(siguiente_ejercicio.enunciado) - #prueba + contenedor_soluciones = gtk.HBox() contenedor_soluciones.add(self.solucion1) @@ -65,11 +70,22 @@ class Ejercitario(gtk.VBox): def __obtener_siguiente_ejercicio(self, cliente_WS): try: #cliente_WS = Client(self.WSDL_URL) - siguiente_ejercicio = cliente_WS.service.getSiguienteEjercicio() + siguiente_ejercicio = cliente_WS.service.getSiguienteEjercicio(self.id_tarea, self.id_alumno, self.siguiente_ejercicio.idEjercicio, "respuesta") except: print "\n\nERROR al instanciar el SINCRONIZAR PROXY:" return siguiente_ejercicio def __responder_cb(self, boton): - pass + siguiente_ejercicio = self.__obtener_siguiente_ejercicio(self.cliente_WS) + self.__actualizar_gui(siguiente_ejercicio) + + def __actualizar_gui(self, siguiente_ejercicio): + self.solucion1.set_label(siguiente_ejercicio.respuestaList.respuestaList[0].descripcion) + self.solucion2.set_label(siguiente_ejercicio.respuestaList.respuestaList[1].descripcion) + self.solucion3.set_label(siguiente_ejercicio.respuestaList.respuestaList[2].descripcion) + self.solucion4.set_label(siguiente_ejercicio.respuestaList.respuestaList[3].descripcion) + + self.label_enunciado.set_label(siguiente_ejercicio.enunciado) + + diff --git a/EjercitarClient/gui/Ejercitario.pyc b/EjercitarClient/gui/Ejercitario.pyc index 8109dfb..a162375 100644 --- a/EjercitarClient/gui/Ejercitario.pyc +++ b/EjercitarClient/gui/Ejercitario.pyc Binary files differ diff --git a/EjercitarClient/gui/Login.py b/EjercitarClient/gui/Login.py index 3e0c3d1..6afe9f7 100644 --- a/EjercitarClient/gui/Login.py +++ b/EjercitarClient/gui/Login.py @@ -120,5 +120,6 @@ class Login(gtk.VBox): def __ingresar_cb(self, boton): self.ventana_padre.remove(self) - temas = Temas(self.ventana_padre) + id_alumno = int(self.id_estudiante_entry.get_text()) + temas = Temas(self.ventana_padre, id_alumno) self.ventana_padre.add(temas) diff --git a/EjercitarClient/gui/Login.pyc b/EjercitarClient/gui/Login.pyc index 18a58e5..fbf3991 100644 --- a/EjercitarClient/gui/Login.pyc +++ b/EjercitarClient/gui/Login.pyc Binary files differ diff --git a/EjercitarClient/gui/Temas.py b/EjercitarClient/gui/Temas.py index db18821..eee8826 100644 --- a/EjercitarClient/gui/Temas.py +++ b/EjercitarClient/gui/Temas.py @@ -9,7 +9,7 @@ Created on Feb 2, 2013 @author: Samu ''' import gtk -from gui.ContenedorTemas import ContenedorTemas +from gui.ContenedorTareas import ContenedorTareas import suds from suds.client import Client @@ -21,10 +21,11 @@ class Temas(gtk.VBox): WSDL_URL = 'http://localhost:8080/EjercitarServer/EjercitarWSBean?wsdl' - def __init__(self, ventana_padre): + def __init__(self, ventana_padre, id_alumno): # create a new window super(Temas, self).__init__() self.ventana_padre = ventana_padre + self.id_alumno = id_alumno self.__inicializar_componentes() self.cliente_WS = self.__sincronizar_temas() @@ -38,10 +39,10 @@ class Temas(gtk.VBox): contenedor_lista = gtk.VBox() - lista_temas = cliente_WS.service.getTemas() - for tema in lista_temas: - nuevo_tema = ContenedorTemas(tema.idTema, tema.nombre, self.ventana_padre, self, self.cliente_WS) - contenedor_lista.add(nuevo_tema) + lista_tareas = cliente_WS.service.getTareas(self.id_alumno) + for tarea in lista_tareas: + nueva_tarea = ContenedorTareas(self.id_alumno, tarea.idTarea, tarea.descripcion, self.ventana_padre, self, self.cliente_WS) + contenedor_lista.add(nueva_tarea) self.add(contenedor_lista) diff --git a/EjercitarClient/gui/Temas.pyc b/EjercitarClient/gui/Temas.pyc index f31e2e3..e07d867 100644 --- a/EjercitarClient/gui/Temas.pyc +++ b/EjercitarClient/gui/Temas.pyc Binary files differ diff --git a/EjercitarClient/lib/suds-0.4-py2.6.egg b/EjercitarClient/lib/suds-0.4-py2.6.egg new file mode 100644 index 0000000..a4a16a8 --- /dev/null +++ b/EjercitarClient/lib/suds-0.4-py2.6.egg Binary files differ diff --git a/EjercitarJPA/build/classes/META-INF/persistence.xml b/EjercitarJPA/build/classes/META-INF/persistence.xml index 13dec83..390a351 100644 --- a/EjercitarJPA/build/classes/META-INF/persistence.xml +++ b/EjercitarJPA/build/classes/META-INF/persistence.xml @@ -1,15 +1,18 @@ - - model.Ejercicio + + java:/EjercitarDS model.Alumno model.Concepto model.Curso + model.Ejercicio model.Escuela model.Profesor model.Respuesta model.Sesion model.Tarea model.Tema + model.Asignatura + model.EjercicioResueltoAlumno diff --git a/EjercitarJPA/build/classes/model/Concepto.class b/EjercitarJPA/build/classes/model/Concepto.class index 0db5da0..1740ce0 100644 --- a/EjercitarJPA/build/classes/model/Concepto.class +++ b/EjercitarJPA/build/classes/model/Concepto.class Binary files differ diff --git a/EjercitarJPA/build/classes/model/Ejercicio.class b/EjercitarJPA/build/classes/model/Ejercicio.class index ba30a53..954d4d5 100644 --- a/EjercitarJPA/build/classes/model/Ejercicio.class +++ b/EjercitarJPA/build/classes/model/Ejercicio.class Binary files differ diff --git a/EjercitarJPA/build/classes/model/Escuela.class b/EjercitarJPA/build/classes/model/Escuela.class index 3f4fb5e..ecff4a8 100644 --- a/EjercitarJPA/build/classes/model/Escuela.class +++ b/EjercitarJPA/build/classes/model/Escuela.class Binary files differ diff --git a/EjercitarJPA/build/classes/model/Respuesta.class b/EjercitarJPA/build/classes/model/Respuesta.class index 6a52ea2..3c244e3 100644 --- a/EjercitarJPA/build/classes/model/Respuesta.class +++ b/EjercitarJPA/build/classes/model/Respuesta.class Binary files differ diff --git a/EjercitarJPA/build/classes/model/Tema.class b/EjercitarJPA/build/classes/model/Tema.class index 0d144b3..b0a7a5d 100644 --- a/EjercitarJPA/build/classes/model/Tema.class +++ b/EjercitarJPA/build/classes/model/Tema.class Binary files differ diff --git a/EjercitarJPA/src/META-INF/persistence.xml b/EjercitarJPA/src/META-INF/persistence.xml index 13dec83..390a351 100644 --- a/EjercitarJPA/src/META-INF/persistence.xml +++ b/EjercitarJPA/src/META-INF/persistence.xml @@ -1,15 +1,18 @@ - - model.Ejercicio + + java:/EjercitarDS model.Alumno model.Concepto model.Curso + model.Ejercicio model.Escuela model.Profesor model.Respuesta model.Sesion model.Tarea model.Tema + model.Asignatura + model.EjercicioResueltoAlumno diff --git a/EjercitarJPA/src/model/Alumno.java b/EjercitarJPA/src/model/Alumno.java index 2265447..d84bd1e 100644 --- a/EjercitarJPA/src/model/Alumno.java +++ b/EjercitarJPA/src/model/Alumno.java @@ -1,94 +1,191 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ package model; import java.io.Serializable; -import javax.persistence.*; -import java.util.Date; - +import java.util.Date; +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; /** - * The persistent class for the alumno database table. - * + * + * @author Ceci */ @Entity +@Table(name = "ALUMNO") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Alumno.findAll", query = "SELECT a FROM Alumno a"), + @NamedQuery(name = "Alumno.findByIdAlumno", query = "SELECT a FROM Alumno a WHERE a.idAlumno = :idAlumno"), + @NamedQuery(name = "Alumno.findBySerial", query = "SELECT a FROM Alumno a WHERE a.serial = :serial"), + @NamedQuery(name = "Alumno.findByNombre", query = "SELECT a FROM Alumno a WHERE a.nombre = :nombre"), + @NamedQuery(name = "Alumno.findByApellido", query = "SELECT a FROM Alumno a WHERE a.apellido = :apellido"), + @NamedQuery(name = "Alumno.findByFechaNacimiento", query = "SELECT a FROM Alumno a WHERE a.fechaNacimiento = :fechaNacimiento"), + @NamedQuery(name = "Alumno.findByGenero", query = "SELECT a FROM Alumno a WHERE a.genero = :genero")}) public class Alumno implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @Column(name="\"idAlumno\"") - private Integer idAlumno; - - private String apellido; - - private Integer cedula; - - @Temporal(TemporalType.DATE) - @Column(name="fecha_nacimiento") - private Date fechaNacimiento; - - private String genero; - - @Column(name="\"idCurso\"") - private Integer idCurso; - - private String nombre; - - public Alumno() { - } - - public Integer getIdAlumno() { - return this.idAlumno; - } - - public void setIdAlumno(Integer idAlumno) { - this.idAlumno = idAlumno; - } - - public String getApellido() { - return this.apellido; - } - - public void setApellido(String apellido) { - this.apellido = apellido; - } - - public Integer getCedula() { - return this.cedula; - } - - public void setCedula(Integer cedula) { - this.cedula = cedula; - } - - public Date getFechaNacimiento() { - return this.fechaNacimiento; - } - - public void setFechaNacimiento(Date fechaNacimiento) { - this.fechaNacimiento = fechaNacimiento; - } - - public String getGenero() { - return this.genero; - } - - public void setGenero(String genero) { - this.genero = genero; - } - - public Integer getIdCurso() { - return this.idCurso; - } - - public void setIdCurso(Integer idCurso) { - this.idCurso = idCurso; - } - - public String getNombre() { - return this.nombre; - } - - public void setNombre(String nombre) { - this.nombre = nombre; - } - -} \ No newline at end of file + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic(optional = false) + @Column(name = "id_alumno") + private Integer idAlumno; + @Basic(optional = false) + @NotNull + @Column(name = "serial") + private int serial; + @Size(max = 2147483647) + @Column(name = "nombre") + private String nombre; + @Size(max = 2147483647) + @Column(name = "apellido") + private String apellido; + @Column(name = "fecha_nacimiento") + @Temporal(TemporalType.DATE) + private Date fechaNacimiento; + @Size(max = 1) + @Column(name = "genero") + private String genero; + @JoinTable(name = "ALUMNO_SESION", joinColumns = { + @JoinColumn(name = "id_alumno", referencedColumnName = "id_alumno")}, inverseJoinColumns = { + @JoinColumn(name = "id_sesion", referencedColumnName = "id_sesion")}) + @ManyToMany + private List sesionList; + @OneToMany(mappedBy = "idAlumno") + private List ejercicioResueltoAlumnoList; + @JoinColumn(name = "id_curso", referencedColumnName = "id_curso") + @ManyToOne + private Curso curso; + + public Alumno() { + } + + public Alumno(Integer idAlumno) { + this.idAlumno = idAlumno; + } + + public Alumno(Integer idAlumno, int serial) { + this.idAlumno = idAlumno; + this.serial = serial; + } + + public Integer getIdAlumno() { + return idAlumno; + } + + public void setIdAlumno(Integer idAlumno) { + this.idAlumno = idAlumno; + } + + public int getSerial() { + return serial; + } + + public void setSerial(int serial) { + this.serial = serial; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public String getApellido() { + return apellido; + } + + public void setApellido(String apellido) { + this.apellido = apellido; + } + + public Date getFechaNacimiento() { + return fechaNacimiento; + } + + public void setFechaNacimiento(Date fechaNacimiento) { + this.fechaNacimiento = fechaNacimiento; + } + + public String getGenero() { + return genero; + } + + public void setGenero(String genero) { + this.genero = genero; + } + + @XmlTransient + public List getSesionList() { + return sesionList; + } + + public void setSesionList(List sesionList) { + this.sesionList = sesionList; + } + + @XmlTransient + public List getEjercicioResueltoAlumnoList() { + return ejercicioResueltoAlumnoList; + } + + public void setEjercicioResueltoAlumnoList(List ejercicioResueltoAlumnoList) { + this.ejercicioResueltoAlumnoList = ejercicioResueltoAlumnoList; + } + + public Curso getCurso() { + return curso; + } + + public void setCurso(Curso curso) { + this.curso = curso; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (idAlumno != null ? idAlumno.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Alumno)) { + return false; + } + Alumno other = (Alumno) object; + if ((this.idAlumno == null && other.idAlumno != null) || (this.idAlumno != null && !this.idAlumno.equals(other.idAlumno))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "model.Alumno[ idAlumno=" + idAlumno + " ]"; + } + +} diff --git a/EjercitarJPA/src/model/Asignatura.java b/EjercitarJPA/src/model/Asignatura.java new file mode 100644 index 0000000..de5fc9d --- /dev/null +++ b/EjercitarJPA/src/model/Asignatura.java @@ -0,0 +1,129 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package model; + +import java.io.Serializable; +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; + +/** + * + * @author Ceci + */ +@Entity +@Table(name = "ASIGNATURA") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Asignatura.findAll", query = "SELECT a FROM Asignatura a"), + @NamedQuery(name = "Asignatura.findByIdAsignatura", query = "SELECT a FROM Asignatura a WHERE a.idAsignatura = :idAsignatura"), + @NamedQuery(name = "Asignatura.findByNombre", query = "SELECT a FROM Asignatura a WHERE a.nombre = :nombre"), + @NamedQuery(name = "Asignatura.findByDescripcion", query = "SELECT a FROM Asignatura a WHERE a.descripcion = :descripcion")}) +public class Asignatura implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic(optional = false) + @Column(name = "id_asignatura") + private Integer idAsignatura; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 2147483647) + @Column(name = "nombre") + private String nombre; + @Size(max = 2147483647) + @Column(name = "descripcion") + private String descripcion; + @JoinTable(name = "PROFESOR_ASIGNATURA", joinColumns = { + @JoinColumn(name = "id_asignatura", referencedColumnName = "id_asignatura")}, inverseJoinColumns = { + @JoinColumn(name = "id_profesor", referencedColumnName = "id_profesor")}) + @ManyToMany + private List profesorList; + + public Asignatura() { + } + + public Asignatura(Integer idAsignatura) { + this.idAsignatura = idAsignatura; + } + + public Asignatura(Integer idAsignatura, String nombre) { + this.idAsignatura = idAsignatura; + this.nombre = nombre; + } + + public Integer getIdAsignatura() { + return idAsignatura; + } + + public void setIdAsignatura(Integer idAsignatura) { + this.idAsignatura = idAsignatura; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public String getDescripcion() { + return descripcion; + } + + public void setDescripcion(String descripcion) { + this.descripcion = descripcion; + } + + @XmlTransient + public List getProfesorList() { + return profesorList; + } + + public void setProfesorList(List profesorList) { + this.profesorList = profesorList; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (idAsignatura != null ? idAsignatura.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Asignatura)) { + return false; + } + Asignatura other = (Asignatura) object; + if ((this.idAsignatura == null && other.idAsignatura != null) || (this.idAsignatura != null && !this.idAsignatura.equals(other.idAsignatura))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "model.Asignatura[ idAsignatura=" + idAsignatura + " ]"; + } + +} diff --git a/EjercitarJPA/src/model/Concepto.java b/EjercitarJPA/src/model/Concepto.java index ade496b..af2e8b9 100644 --- a/EjercitarJPA/src/model/Concepto.java +++ b/EjercitarJPA/src/model/Concepto.java @@ -1,49 +1,144 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ package model; import java.io.Serializable; -import javax.persistence.*; - +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; /** - * The persistent class for the concepto database table. - * + * + * @author Ceci */ @Entity +@Table(name = "CONCEPTO") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Concepto.findAll", query = "SELECT c FROM Concepto c"), + @NamedQuery(name = "Concepto.findByIdConcepto", query = "SELECT c FROM Concepto c WHERE c.idConcepto = :idConcepto"), + @NamedQuery(name = "Concepto.findByNombre", query = "SELECT c FROM Concepto c WHERE c.nombre = :nombre"), + @NamedQuery(name = "Concepto.findByDescripcion", query = "SELECT c FROM Concepto c WHERE c.descripcion = :descripcion")}) public class Concepto implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic(optional = false) + @Column(name = "id_concepto") + private Integer idConcepto; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 2147483647) + @Column(name = "nombre") + private String nombre; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 2147483647) + @Column(name = "descripcion") + private String descripcion; + @JoinTable(name = "EJERCICIO_CONCEPTO", joinColumns = { + @JoinColumn(name = "id_concepto", referencedColumnName = "id_concepto")}, inverseJoinColumns = { + @JoinColumn(name = "id_ejercicio", referencedColumnName = "id_ejercicio")}) + @ManyToMany + private List ejercicioList; + @OneToMany(mappedBy = "idConcepto") + private List temaList; + + public Concepto() { + } + + public Concepto(Integer idConcepto) { + this.idConcepto = idConcepto; + } + + public Concepto(Integer idConcepto, String nombre, String descripcion) { + this.idConcepto = idConcepto; + this.nombre = nombre; + this.descripcion = descripcion; + } + + public Integer getIdConcepto() { + return idConcepto; + } + + public void setIdConcepto(Integer idConcepto) { + this.idConcepto = idConcepto; + } - @Id - private Integer idconcepto; + public String getNombre() { + return nombre; + } - private String descripcion; + public void setNombre(String nombre) { + this.nombre = nombre; + } - private String nombre; + public String getDescripcion() { + return descripcion; + } - public Concepto() { - } + public void setDescripcion(String descripcion) { + this.descripcion = descripcion; + } - public Integer getIdconcepto() { - return this.idconcepto; - } + @XmlTransient + public List getEjercicioList() { + return ejercicioList; + } - public void setIdconcepto(Integer idconcepto) { - this.idconcepto = idconcepto; - } + public void setEjercicioList(List ejercicioList) { + this.ejercicioList = ejercicioList; + } - public String getDescripcion() { - return this.descripcion; - } + @XmlTransient + public List getTemaList() { + return temaList; + } - public void setDescripcion(String descripcion) { - this.descripcion = descripcion; - } + public void setTemaList(List temaList) { + this.temaList = temaList; + } - public String getNombre() { - return this.nombre; - } + @Override + public int hashCode() { + int hash = 0; + hash += (idConcepto != null ? idConcepto.hashCode() : 0); + return hash; + } - public void setNombre(String nombre) { - this.nombre = nombre; - } + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Concepto)) { + return false; + } + Concepto other = (Concepto) object; + if ((this.idConcepto == null && other.idConcepto != null) || (this.idConcepto != null && !this.idConcepto.equals(other.idConcepto))) { + return false; + } + return true; + } -} \ No newline at end of file + @Override + public String toString() { + return "model.Concepto[ idConcepto=" + idConcepto + " ]"; + } + +} diff --git a/EjercitarJPA/src/model/Curso.java b/EjercitarJPA/src/model/Curso.java index 302ad7c..79eafe0 100644 --- a/EjercitarJPA/src/model/Curso.java +++ b/EjercitarJPA/src/model/Curso.java @@ -1,52 +1,157 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ package model; import java.io.Serializable; -import javax.persistence.*; - +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.validation.constraints.Size; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; /** - * The persistent class for the curso database table. - * + * + * @author Ceci */ @Entity +@Table(name = "CURSO") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Curso.findAll", query = "SELECT c FROM Curso c"), + @NamedQuery(name = "Curso.findByIdCurso", query = "SELECT c FROM Curso c WHERE c.idCurso = :idCurso"), + @NamedQuery(name = "Curso.findBySeccion", query = "SELECT c FROM Curso c WHERE c.seccion = :seccion"), + @NamedQuery(name = "Curso.findByTurno", query = "SELECT c FROM Curso c WHERE c.turno = :turno")}) public class Curso implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic(optional = false) + @Column(name = "id_curso") + private Integer idCurso; + @Size(max = 1) + @Column(name = "seccion") + private String seccion; + @Size(max = 1) + @Column(name = "turno") + private String turno; + @JoinTable(name = "CURSO_PROFESOR", joinColumns = { + @JoinColumn(name = "id_curso", referencedColumnName = "id_curso")}, inverseJoinColumns = { + @JoinColumn(name = "id_profesor", referencedColumnName = "id_profesor")}) + @ManyToMany + private List profesorList; + @OneToMany(mappedBy = "curso", fetch = FetchType.EAGER) + private List tareaList; + @JoinColumn(name = "id_escuela", referencedColumnName = "id_escuela") + @ManyToOne + private Escuela idEscuela; + @OneToMany(mappedBy = "curso") + private List alumnoList; + + public Curso() { + } + + public Curso(Integer idCurso) { + this.idCurso = idCurso; + } + + public Integer getIdCurso() { + return idCurso; + } + + public void setIdCurso(Integer idCurso) { + this.idCurso = idCurso; + } + + public String getSeccion() { + return seccion; + } + + public void setSeccion(String seccion) { + this.seccion = seccion; + } + + public String getTurno() { + return turno; + } + + public void setTurno(String turno) { + this.turno = turno; + } - @Id - @Column(name="\"idCurso\"") - private Integer idCurso; + @XmlTransient + public List getProfesorList() { + return profesorList; + } - @Column(name="\"idEscuela\"") - private Integer idEscuela; + public void setProfesorList(List profesorList) { + this.profesorList = profesorList; + } - @Column(name="\"idProfesor\"") - private Integer idProfesor; + @XmlTransient + public List getTareaList() { + return tareaList; + } - public Curso() { - } + public void setTareaList(List tareaList) { + this.tareaList = tareaList; + } - public Integer getIdCurso() { - return this.idCurso; - } + public Escuela getIdEscuela() { + return idEscuela; + } - public void setIdCurso(Integer idCurso) { - this.idCurso = idCurso; - } + public void setIdEscuela(Escuela idEscuela) { + this.idEscuela = idEscuela; + } - public Integer getIdEscuela() { - return this.idEscuela; - } + @XmlTransient + public List getAlumnoList() { + return alumnoList; + } - public void setIdEscuela(Integer idEscuela) { - this.idEscuela = idEscuela; - } + public void setAlumnoList(List alumnoList) { + this.alumnoList = alumnoList; + } - public Integer getIdProfesor() { - return this.idProfesor; - } + @Override + public int hashCode() { + int hash = 0; + hash += (idCurso != null ? idCurso.hashCode() : 0); + return hash; + } - public void setIdProfesor(Integer idProfesor) { - this.idProfesor = idProfesor; - } + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Curso)) { + return false; + } + Curso other = (Curso) object; + if ((this.idCurso == null && other.idCurso != null) || (this.idCurso != null && !this.idCurso.equals(other.idCurso))) { + return false; + } + return true; + } -} \ No newline at end of file + @Override + public String toString() { + return "model.Curso[ idCurso=" + idCurso + " ]"; + } + +} diff --git a/EjercitarJPA/src/model/Ejercicio.java b/EjercitarJPA/src/model/Ejercicio.java index aa47e76..afda88c 100644 --- a/EjercitarJPA/src/model/Ejercicio.java +++ b/EjercitarJPA/src/model/Ejercicio.java @@ -1,72 +1,194 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ package model; import java.io.Serializable; -import javax.persistence.*; - +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; + +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.Lob; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; /** - * The persistent class for the "Ejercicio" database table. - * + * + * @author Ceci */ @Entity -@Table(name="\"Ejercicio\"") +@Table(name = "EJERCICIO") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Ejercicio.findAll", query = "SELECT e FROM Ejercicio e"), + @NamedQuery(name = "Ejercicio.findByIdEjercicio", query = "SELECT e FROM Ejercicio e WHERE e.idEjercicio = :idEjercicio"), + @NamedQuery(name = "Ejercicio.findByEnunciado", query = "SELECT e FROM Ejercicio e WHERE e.enunciado = :enunciado"), + @NamedQuery(name = "Ejercicio.findByNivelDificultad", query = "SELECT e FROM Ejercicio e WHERE e.nivelDificultad = :nivelDificultad"), + @NamedQuery(name = "Ejercicio.findByTitulo", query = "SELECT e FROM Ejercicio e WHERE e.titulo = :titulo")}) public class Ejercicio implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @Column(name="\"idEjercicio\"") - private Integer idEjercicio; - - private Integer dificultad; - - private String enunciado; - - private byte[] imagen; - - @Column(name="repuesta_correcta") - private String repuestaCorrecta; - - public Ejercicio() { - } - - public Integer getIdEjercicio() { - return this.idEjercicio; - } - - public void setIdEjercicio(Integer idEjercicio) { - this.idEjercicio = idEjercicio; - } - - public Integer getDificultad() { - return this.dificultad; - } - - public void setDificultad(Integer dificultad) { - this.dificultad = dificultad; - } - - public String getEnunciado() { - return this.enunciado; - } - - public void setEnunciado(String enunciado) { - this.enunciado = enunciado; - } - - public byte[] getImagen() { - return this.imagen; - } - - public void setImagen(byte[] imagen) { - this.imagen = imagen; - } - - public String getRepuestaCorrecta() { - return this.repuestaCorrecta; - } - - public void setRepuestaCorrecta(String repuestaCorrecta) { - this.repuestaCorrecta = repuestaCorrecta; - } - -} \ No newline at end of file + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic(optional = false) + @Column(name = "id_ejercicio") + private Integer idEjercicio; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 2147483647) + @Column(name = "enunciado") + private String enunciado; + @Lob + @Column(name = "imagen") + private byte[] imagen; + @Column(name = "nivel_dificultad") + private Integer nivelDificultad; + @Size(max = 2147483647) + @Column(name = "titulo") + private String titulo; + @JoinTable(name = "RESPUESTA_EJERCICIO", joinColumns = { + @JoinColumn(name = "id_ejercicio", referencedColumnName = "id_ejercicio")}, inverseJoinColumns = { + @JoinColumn(name = "id_respuesta", referencedColumnName = "id_respuesta")}) + @ManyToMany() + @XmlElementWrapper + private Collection respuestaList; + @ManyToMany(mappedBy = "ejercicioList") + private List conceptoList; + @OneToMany(mappedBy = "idEjercicio") + private List ejercicioResueltoAlumnoList; + @JoinColumn(name = "id_respuesta", referencedColumnName = "id_respuesta") + @ManyToOne + private Respuesta idRespuesta; + + public Ejercicio() { + } + + public Ejercicio(Integer idEjercicio) { + this.idEjercicio = idEjercicio; + } + + public Ejercicio(Integer idEjercicio, String enunciado) { + this.idEjercicio = idEjercicio; + this.enunciado = enunciado; + } + + public Integer getIdEjercicio() { + return idEjercicio; + } + + public void setIdEjercicio(Integer idEjercicio) { + this.idEjercicio = idEjercicio; + } + + public String getEnunciado() { + return enunciado; + } + + public void setEnunciado(String enunciado) { + this.enunciado = enunciado; + } + + public byte[] getImagen() { + return imagen; + } + + public void setImagen(byte[] imagen) { + this.imagen = imagen; + } + + public Integer getNivelDificultad() { + return nivelDificultad; + } + + public void setNivelDificultad(Integer nivelDificultad) { + this.nivelDificultad = nivelDificultad; + } + + public String getTitulo() { + return titulo; + } + + public void setTitulo(String titulo) { + this.titulo = titulo; + } + + @XmlTransient + public Collection getRespuestaList() { + return new ArrayList(respuestaList); + } + + public void setRespuestaList(Collection respuestaList) { + this.respuestaList = respuestaList; + } + + @XmlTransient + public List getConceptoList() { + return conceptoList; + } + + public void setConceptoList(List conceptoList) { + this.conceptoList = conceptoList; + } + + @XmlTransient + public List getEjercicioResueltoAlumnoList() { + return ejercicioResueltoAlumnoList; + } + + public void setEjercicioResueltoAlumnoList(List ejercicioResueltoAlumnoList) { + this.ejercicioResueltoAlumnoList = ejercicioResueltoAlumnoList; + } + + public Respuesta getIdRespuesta() { + return idRespuesta; + } + + public void setIdRespuesta(Respuesta idRespuesta) { + this.idRespuesta = idRespuesta; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (idEjercicio != null ? idEjercicio.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Ejercicio)) { + return false; + } + Ejercicio other = (Ejercicio) object; + if ((this.idEjercicio == null && other.idEjercicio != null) || (this.idEjercicio != null && !this.idEjercicio.equals(other.idEjercicio))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "model.Ejercicio[ idEjercicio=" + idEjercicio + " ]"; + } + +} diff --git a/EjercitarJPA/src/model/EjercicioResueltoAlumno.java b/EjercitarJPA/src/model/EjercicioResueltoAlumno.java new file mode 100644 index 0000000..e0d56c2 --- /dev/null +++ b/EjercitarJPA/src/model/EjercicioResueltoAlumno.java @@ -0,0 +1,116 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package model; + +import java.io.Serializable; +import java.util.Date; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + * @author Ceci + */ +@Entity +@Table(name = "EJERCICIO_RESUELTO_ALUMNO") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "EjercicioResueltoAlumno.findAll", query = "SELECT e FROM EjercicioResueltoAlumno e"), + @NamedQuery(name = "EjercicioResueltoAlumno.findByIdEjercicioResueltoAlumno", query = "SELECT e FROM EjercicioResueltoAlumno e WHERE e.idEjercicioResueltoAlumno = :idEjercicioResueltoAlumno"), + @NamedQuery(name = "EjercicioResueltoAlumno.findByFecha", query = "SELECT e FROM EjercicioResueltoAlumno e WHERE e.fecha = :fecha")}) +public class EjercicioResueltoAlumno implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic(optional = false) + @Column(name = "id_ejercicio_resuelto_alumno") + private Integer idEjercicioResueltoAlumno; + @Column(name = "fecha") + @Temporal(TemporalType.DATE) + private Date fecha; + @JoinColumn(name = "id_ejercicio", referencedColumnName = "id_ejercicio") + @ManyToOne + private Ejercicio idEjercicio; + @JoinColumn(name = "id_alumno", referencedColumnName = "id_alumno") + @ManyToOne + private Alumno idAlumno; + + public EjercicioResueltoAlumno() { + } + + public EjercicioResueltoAlumno(Integer idEjercicioResueltoAlumno) { + this.idEjercicioResueltoAlumno = idEjercicioResueltoAlumno; + } + + public Integer getIdEjercicioResueltoAlumno() { + return idEjercicioResueltoAlumno; + } + + public void setIdEjercicioResueltoAlumno(Integer idEjercicioResueltoAlumno) { + this.idEjercicioResueltoAlumno = idEjercicioResueltoAlumno; + } + + public Date getFecha() { + return fecha; + } + + public void setFecha(Date fecha) { + this.fecha = fecha; + } + + public Ejercicio getIdEjercicio() { + return idEjercicio; + } + + public void setIdEjercicio(Ejercicio idEjercicio) { + this.idEjercicio = idEjercicio; + } + + public Alumno getIdAlumno() { + return idAlumno; + } + + public void setIdAlumno(Alumno idAlumno) { + this.idAlumno = idAlumno; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (idEjercicioResueltoAlumno != null ? idEjercicioResueltoAlumno.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof EjercicioResueltoAlumno)) { + return false; + } + EjercicioResueltoAlumno other = (EjercicioResueltoAlumno) object; + if ((this.idEjercicioResueltoAlumno == null && other.idEjercicioResueltoAlumno != null) || (this.idEjercicioResueltoAlumno != null && !this.idEjercicioResueltoAlumno.equals(other.idEjercicioResueltoAlumno))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "model.EjercicioResueltoAlumno[ idEjercicioResueltoAlumno=" + idEjercicioResueltoAlumno + " ]"; + } + +} diff --git a/EjercitarJPA/src/model/Escuela.java b/EjercitarJPA/src/model/Escuela.java index b699396..8d42d65 100644 --- a/EjercitarJPA/src/model/Escuela.java +++ b/EjercitarJPA/src/model/Escuela.java @@ -1,83 +1,147 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ package model; import java.io.Serializable; -import javax.persistence.*; -import java.util.List; - +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; /** - * The persistent class for the escuela database table. - * + * + * @author Ceci */ @Entity +@Table(name = "ESCUELA") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Escuela.findAll", query = "SELECT e FROM Escuela e"), + @NamedQuery(name = "Escuela.findByIdEscuela", query = "SELECT e FROM Escuela e WHERE e.idEscuela = :idEscuela"), + @NamedQuery(name = "Escuela.findByNombre", query = "SELECT e FROM Escuela e WHERE e.nombre = :nombre"), + @NamedQuery(name = "Escuela.findByRegistroMec", query = "SELECT e FROM Escuela e WHERE e.registroMec = :registroMec"), + @NamedQuery(name = "Escuela.findByDireccion", query = "SELECT e FROM Escuela e WHERE e.direccion = :direccion"), + @NamedQuery(name = "Escuela.findByPublica", query = "SELECT e FROM Escuela e WHERE e.publica = :publica")}) public class Escuela implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @Column(name="\"idEscuela\"") - private Integer idEscuela; - - private String direccion; - - private String nombre; - - private String registro; - - private String tipo; - - //bi-directional many-to-one association to Profesor - @OneToMany(mappedBy="escuela") - private List profesors; - - public Escuela() { - } - - public Integer getIdEscuela() { - return this.idEscuela; - } - - public void setIdEscuela(Integer idEscuela) { - this.idEscuela = idEscuela; - } - - public String getDireccion() { - return this.direccion; - } - - public void setDireccion(String direccion) { - this.direccion = direccion; - } - - public String getNombre() { - return this.nombre; - } - - public void setNombre(String nombre) { - this.nombre = nombre; - } - - public String getRegistro() { - return this.registro; - } - - public void setRegistro(String registro) { - this.registro = registro; - } - - public String getTipo() { - return this.tipo; - } - - public void setTipo(String tipo) { - this.tipo = tipo; - } - - public List getProfesors() { - return this.profesors; - } - - public void setProfesors(List profesors) { - this.profesors = profesors; - } - -} \ No newline at end of file + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic(optional = false) + @Column(name = "id_escuela") + private Integer idEscuela; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 2147483647) + @Column(name = "nombre") + private String nombre; + @Size(max = 2147483647) + @Column(name = "registro_mec") + private String registroMec; + @Size(max = 2147483647) + @Column(name = "direccion") + private String direccion; + @Column(name = "publica") + private Boolean publica; + @OneToMany(mappedBy = "idEscuela") + private List cursoList; + + public Escuela() { + } + + public Escuela(Integer idEscuela) { + this.idEscuela = idEscuela; + } + + public Escuela(Integer idEscuela, String nombre) { + this.idEscuela = idEscuela; + this.nombre = nombre; + } + + public Integer getIdEscuela() { + return idEscuela; + } + + public void setIdEscuela(Integer idEscuela) { + this.idEscuela = idEscuela; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public String getRegistroMec() { + return registroMec; + } + + public void setRegistroMec(String registroMec) { + this.registroMec = registroMec; + } + + public String getDireccion() { + return direccion; + } + + public void setDireccion(String direccion) { + this.direccion = direccion; + } + + public Boolean getPublica() { + return publica; + } + + public void setPublica(Boolean publica) { + this.publica = publica; + } + + @XmlTransient + public List getCursoList() { + return cursoList; + } + + public void setCursoList(List cursoList) { + this.cursoList = cursoList; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (idEscuela != null ? idEscuela.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Escuela)) { + return false; + } + Escuela other = (Escuela) object; + if ((this.idEscuela == null && other.idEscuela != null) || (this.idEscuela != null && !this.idEscuela.equals(other.idEscuela))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "model.Escuela[ idEscuela=" + idEscuela + " ]"; + } + +} diff --git a/EjercitarJPA/src/model/Profesor.java b/EjercitarJPA/src/model/Profesor.java index bfd1553..60d757a 100644 --- a/EjercitarJPA/src/model/Profesor.java +++ b/EjercitarJPA/src/model/Profesor.java @@ -1,70 +1,152 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ package model; import java.io.Serializable; -import javax.persistence.*; - +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; /** - * The persistent class for the profesor database table. - * + * + * @author Ceci */ @Entity +@Table(name = "PROFESOR") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Profesor.findAll", query = "SELECT p FROM Profesor p"), + @NamedQuery(name = "Profesor.findByIdProfesor", query = "SELECT p FROM Profesor p WHERE p.idProfesor = :idProfesor"), + @NamedQuery(name = "Profesor.findByNombre", query = "SELECT p FROM Profesor p WHERE p.nombre = :nombre"), + @NamedQuery(name = "Profesor.findByApellido", query = "SELECT p FROM Profesor p WHERE p.apellido = :apellido"), + @NamedQuery(name = "Profesor.findByCedula", query = "SELECT p FROM Profesor p WHERE p.cedula = :cedula")}) public class Profesor implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @Column(name="\"idProfesor\"") - private Integer idProfesor; - - private String apellido; - - private Integer cedula; - - private String grado; - - private String nombre; - - public Profesor() { - } - - public Integer getIdProfesor() { - return this.idProfesor; - } - - public void setIdProfesor(Integer idProfesor) { - this.idProfesor = idProfesor; - } - - public String getApellido() { - return this.apellido; - } - - public void setApellido(String apellido) { - this.apellido = apellido; - } - - public Integer getCedula() { - return this.cedula; - } - - public void setCedula(Integer cedula) { - this.cedula = cedula; - } - - public String getGrado() { - return this.grado; - } - - public void setGrado(String grado) { - this.grado = grado; - } - - public String getNombre() { - return this.nombre; - } - - public void setNombre(String nombre) { - this.nombre = nombre; - } - -} \ No newline at end of file + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic(optional = false) + @Column(name = "id_profesor") + private Integer idProfesor; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 2147483647) + @Column(name = "nombre") + private String nombre; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 2147483647) + @Column(name = "apellido") + private String apellido; + @Basic(optional = false) + @NotNull + @Column(name = "cedula") + private int cedula; + @ManyToMany(mappedBy = "profesorList") + private List asignaturaList; + @ManyToMany(mappedBy = "profesorList") + private List cursoList; + + public Profesor() { + } + + public Profesor(Integer idProfesor) { + this.idProfesor = idProfesor; + } + + public Profesor(Integer idProfesor, String nombre, String apellido, int cedula) { + this.idProfesor = idProfesor; + this.nombre = nombre; + this.apellido = apellido; + this.cedula = cedula; + } + + public Integer getIdProfesor() { + return idProfesor; + } + + public void setIdProfesor(Integer idProfesor) { + this.idProfesor = idProfesor; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public String getApellido() { + return apellido; + } + + public void setApellido(String apellido) { + this.apellido = apellido; + } + + public int getCedula() { + return cedula; + } + + public void setCedula(int cedula) { + this.cedula = cedula; + } + + @XmlTransient + public List getAsignaturaList() { + return asignaturaList; + } + + public void setAsignaturaList(List asignaturaList) { + this.asignaturaList = asignaturaList; + } + + @XmlTransient + public List getCursoList() { + return cursoList; + } + + public void setCursoList(List cursoList) { + this.cursoList = cursoList; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (idProfesor != null ? idProfesor.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Profesor)) { + return false; + } + Profesor other = (Profesor) object; + if ((this.idProfesor == null && other.idProfesor != null) || (this.idProfesor != null && !this.idProfesor.equals(other.idProfesor))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "model.Profesor[ idProfesor=" + idProfesor + " ]"; + } + +} diff --git a/EjercitarJPA/src/model/Respuesta.java b/EjercitarJPA/src/model/Respuesta.java index 0c648c2..079d8a6 100644 --- a/EjercitarJPA/src/model/Respuesta.java +++ b/EjercitarJPA/src/model/Respuesta.java @@ -1,40 +1,124 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ package model; import java.io.Serializable; -import javax.persistence.*; - +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; /** - * The persistent class for the respuesta database table. - * + * + * @author Ceci */ @Entity +@Table(name = "RESPUESTA") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Respuesta.findAll", query = "SELECT r FROM Respuesta r"), + @NamedQuery(name = "Respuesta.findByIdRespuesta", query = "SELECT r FROM Respuesta r WHERE r.idRespuesta = :idRespuesta"), + @NamedQuery(name = "Respuesta.findByDescripcion", query = "SELECT r FROM Respuesta r WHERE r.descripcion = :descripcion")}) public class Respuesta implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic(optional = false) + @Column(name = "id_respuesta") + private Integer idRespuesta; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 2147483647) + @Column(name = "descripcion") + private String descripcion; + @ManyToMany(mappedBy = "respuestaList") + private List ejercicioList; + @OneToMany(mappedBy = "idRespuesta") + private List ejercicioList1; + + public Respuesta() { + } + + public Respuesta(Integer idRespuesta) { + this.idRespuesta = idRespuesta; + } + + public Respuesta(Integer idRespuesta, String descripcion) { + this.idRespuesta = idRespuesta; + this.descripcion = descripcion; + } + + public Integer getIdRespuesta() { + return idRespuesta; + } + + public void setIdRespuesta(Integer idRespuesta) { + this.idRespuesta = idRespuesta; + } + + public String getDescripcion() { + return descripcion; + } - @Id - @Column(name="\"idRespuesta\"") - private Integer idRespuesta; + public void setDescripcion(String descripcion) { + this.descripcion = descripcion; + } - private String descripcion; + @XmlTransient + public List getEjercicioList() { + return ejercicioList; + } - public Respuesta() { - } + public void setEjercicioList(List ejercicioList) { + this.ejercicioList = ejercicioList; + } - public Integer getIdRespuesta() { - return this.idRespuesta; - } + @XmlTransient + public List getEjercicioList1() { + return ejercicioList1; + } - public void setIdRespuesta(Integer idRespuesta) { - this.idRespuesta = idRespuesta; - } + public void setEjercicioList1(List ejercicioList1) { + this.ejercicioList1 = ejercicioList1; + } - public String getDescripcion() { - return this.descripcion; - } + @Override + public int hashCode() { + int hash = 0; + hash += (idRespuesta != null ? idRespuesta.hashCode() : 0); + return hash; + } - public void setDescripcion(String descripcion) { - this.descripcion = descripcion; - } + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Respuesta)) { + return false; + } + Respuesta other = (Respuesta) object; + if ((this.idRespuesta == null && other.idRespuesta != null) || (this.idRespuesta != null && !this.idRespuesta.equals(other.idRespuesta))) { + return false; + } + return true; + } -} \ No newline at end of file + @Override + public String toString() { + return "model.Respuesta[ idRespuesta=" + idRespuesta + " ]"; + } + +} diff --git a/EjercitarJPA/src/model/Sesion.java b/EjercitarJPA/src/model/Sesion.java index 16145df..b7b195f 100644 --- a/EjercitarJPA/src/model/Sesion.java +++ b/EjercitarJPA/src/model/Sesion.java @@ -1,52 +1,176 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ package model; import java.io.Serializable; -import javax.persistence.*; - +import java.util.Date; +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; /** - * The persistent class for the sesion database table. - * + * + * @author Ceci */ @Entity +@Table(name = "SESION") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Sesion.findAll", query = "SELECT s FROM Sesion s"), + @NamedQuery(name = "Sesion.findByIdSesion", query = "SELECT s FROM Sesion s WHERE s.idSesion = :idSesion"), + @NamedQuery(name = "Sesion.findByEntrada", query = "SELECT s FROM Sesion s WHERE s.entrada = :entrada"), + @NamedQuery(name = "Sesion.findBySalida", query = "SELECT s FROM Sesion s WHERE s.salida = :salida"), + @NamedQuery(name = "Sesion.findByAyudaPadres", query = "SELECT s FROM Sesion s WHERE s.ayudaPadres = :ayudaPadres"), + @NamedQuery(name = "Sesion.findByDesdeHogar", query = "SELECT s FROM Sesion s WHERE s.desdeHogar = :desdeHogar"), + @NamedQuery(name = "Sesion.findByEstadoAnimo", query = "SELECT s FROM Sesion s WHERE s.estadoAnimo = :estadoAnimo")}) public class Sesion implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic(optional = false) + @Column(name = "id_sesion") + private Integer idSesion; + @Basic(optional = false) + @NotNull + @Column(name = "entrada") + @Temporal(TemporalType.TIMESTAMP) + private Date entrada; + @Basic(optional = false) + @NotNull + @Column(name = "salida") + @Temporal(TemporalType.TIMESTAMP) + private Date salida; + @Column(name = "ayuda_padres") + private Boolean ayudaPadres; + @Column(name = "desde_hogar") + private Boolean desdeHogar; + @Size(max = 5) + @Column(name = "estado_animo") + private String estadoAnimo; + @ManyToMany(mappedBy = "sesionList") + private List alumnoList; + @OneToMany(mappedBy = "idSesion") + private List tareaList; + + public Sesion() { + } + + public Sesion(Integer idSesion) { + this.idSesion = idSesion; + } + + public Sesion(Integer idSesion, Date entrada, Date salida) { + this.idSesion = idSesion; + this.entrada = entrada; + this.salida = salida; + } + + public Integer getIdSesion() { + return idSesion; + } + + public void setIdSesion(Integer idSesion) { + this.idSesion = idSesion; + } + + public Date getEntrada() { + return entrada; + } + + public void setEntrada(Date entrada) { + this.entrada = entrada; + } + + public Date getSalida() { + return salida; + } + + public void setSalida(Date salida) { + this.salida = salida; + } + + public Boolean getAyudaPadres() { + return ayudaPadres; + } + + public void setAyudaPadres(Boolean ayudaPadres) { + this.ayudaPadres = ayudaPadres; + } - @Id - @Column(name="\"idSesion\"") - private Integer idSesion; + public Boolean getDesdeHogar() { + return desdeHogar; + } - @Column(name="\"idAlumno\"") - private Integer idAlumno; + public void setDesdeHogar(Boolean desdeHogar) { + this.desdeHogar = desdeHogar; + } - @Column(name="\"idProfesor\"") - private Integer idProfesor; + public String getEstadoAnimo() { + return estadoAnimo; + } - public Sesion() { - } + public void setEstadoAnimo(String estadoAnimo) { + this.estadoAnimo = estadoAnimo; + } - public Integer getIdSesion() { - return this.idSesion; - } + @XmlTransient + public List getAlumnoList() { + return alumnoList; + } - public void setIdSesion(Integer idSesion) { - this.idSesion = idSesion; - } + public void setAlumnoList(List alumnoList) { + this.alumnoList = alumnoList; + } - public Integer getIdAlumno() { - return this.idAlumno; - } + @XmlTransient + public List getTareaList() { + return tareaList; + } - public void setIdAlumno(Integer idAlumno) { - this.idAlumno = idAlumno; - } + public void setTareaList(List tareaList) { + this.tareaList = tareaList; + } - public Integer getIdProfesor() { - return this.idProfesor; - } + @Override + public int hashCode() { + int hash = 0; + hash += (idSesion != null ? idSesion.hashCode() : 0); + return hash; + } - public void setIdProfesor(Integer idProfesor) { - this.idProfesor = idProfesor; - } + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Sesion)) { + return false; + } + Sesion other = (Sesion) object; + if ((this.idSesion == null && other.idSesion != null) || (this.idSesion != null && !this.idSesion.equals(other.idSesion))) { + return false; + } + return true; + } -} \ No newline at end of file + @Override + public String toString() { + return "model.Sesion[ idSesion=" + idSesion + " ]"; + } + +} diff --git a/EjercitarJPA/src/model/Tarea.java b/EjercitarJPA/src/model/Tarea.java index 73a35a1..c1e1484 100644 --- a/EjercitarJPA/src/model/Tarea.java +++ b/EjercitarJPA/src/model/Tarea.java @@ -1,52 +1,125 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ package model; import java.io.Serializable; -import javax.persistence.*; - +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.validation.constraints.Size; +import javax.xml.bind.annotation.XmlRootElement; /** - * The persistent class for the tarea database table. - * + * + * @author Ceci */ @Entity +@Table(name = "TAREA") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Tarea.findAll", query = "SELECT t FROM Tarea t"), + @NamedQuery(name = "Tarea.findByIdTarea", query = "SELECT t FROM Tarea t WHERE t.idTarea = :idTarea"), + @NamedQuery(name = "Tarea.findByDescripcion", query = "SELECT t FROM Tarea t WHERE t.descripcion = :descripcion")}) public class Tarea implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic(optional = false) + @Column(name = "id_tarea") + private Integer idTarea; + @Size(max = 2147483647) + @Column(name = "descripcion") + private String descripcion; + @JoinColumn(name = "id_tema", referencedColumnName = "id_tema") + @ManyToOne + private Tema tema; + @JoinColumn(name = "id_sesion", referencedColumnName = "id_sesion") + @ManyToOne + private Sesion idSesion; + @JoinColumn(name = "id_curso", referencedColumnName = "id_curso") + @ManyToOne + private Curso curso; + + public Tarea() { + } + + public Tarea(Integer idTarea) { + this.idTarea = idTarea; + } + + public Integer getIdTarea() { + return idTarea; + } + + public void setIdTarea(Integer idTarea) { + this.idTarea = idTarea; + } - @Id - @Column(name="\"idTarea\"") - private Integer idTarea; + public String getDescripcion() { + return descripcion; + } - @Column(name="\"idCurso\"") - private Integer idCurso; + public void setDescripcion(String descripcion) { + this.descripcion = descripcion; + } - @Column(name="\"idTema\"") - private Integer idTema; + public Tema getTema() { + return tema; + } - public Tarea() { - } + public void setTema(Tema tema) { + this.tema = tema; + } - public Integer getIdTarea() { - return this.idTarea; - } + public Sesion getIdSesion() { + return idSesion; + } - public void setIdTarea(Integer idTarea) { - this.idTarea = idTarea; - } + public void setIdSesion(Sesion idSesion) { + this.idSesion = idSesion; + } - public Integer getIdCurso() { - return this.idCurso; - } + public Curso getCurso() { + return curso; + } - public void setIdCurso(Integer idCurso) { - this.idCurso = idCurso; - } + public void setCurso(Curso curso) { + this.curso = curso; + } - public Integer getIdTema() { - return this.idTema; - } + @Override + public int hashCode() { + int hash = 0; + hash += (idTarea != null ? idTarea.hashCode() : 0); + return hash; + } - public void setIdTema(Integer idTema) { - this.idTema = idTema; - } + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Tarea)) { + return false; + } + Tarea other = (Tarea) object; + if ((this.idTarea == null && other.idTarea != null) || (this.idTarea != null && !this.idTarea.equals(other.idTarea))) { + return false; + } + return true; + } -} \ No newline at end of file + @Override + public String toString() { + return "model.Tarea[ idTarea=" + idTarea + " ]"; + } + +} diff --git a/EjercitarJPA/src/model/Tema.java b/EjercitarJPA/src/model/Tema.java index e9eef4e..1c6eb36 100644 --- a/EjercitarJPA/src/model/Tema.java +++ b/EjercitarJPA/src/model/Tema.java @@ -1,63 +1,137 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ package model; import java.io.Serializable; -import javax.persistence.*; -import java.util.List; - +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; /** - * The persistent class for the tema database table. - * + * + * @author Ceci */ @Entity +@Table(name = "TEMA") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Tema.findAll", query = "SELECT t FROM Tema t"), + @NamedQuery(name = "Tema.findByIdTema", query = "SELECT t FROM Tema t WHERE t.idTema = :idTema"), + @NamedQuery(name = "Tema.findByNombre", query = "SELECT t FROM Tema t WHERE t.nombre = :nombre"), + @NamedQuery(name = "Tema.findByDescripcion", query = "SELECT t FROM Tema t WHERE t.descripcion = :descripcion")}) public class Tema implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @Column(name="\"idTema\"") - private Integer idTema; - - private String descripcion; - - private String nombre; - - //bi-directional many-to-one association to Tarea - @OneToMany(mappedBy="tema") - private List tareas; - - public Tema() { - } - - public Integer getIdTema() { - return this.idTema; - } - - public void setIdTema(Integer idTema) { - this.idTema = idTema; - } - - public String getDescripcion() { - return this.descripcion; - } - - public void setDescripcion(String descripcion) { - this.descripcion = descripcion; - } - - public String getNombre() { - return this.nombre; - } - - public void setNombre(String nombre) { - this.nombre = nombre; - } - - public List getTareas() { - return this.tareas; - } - - public void setTareas(List tareas) { - this.tareas = tareas; - } - -} \ No newline at end of file + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic(optional = false) + @Column(name = "id_tema") + private Integer idTema; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 2147483647) + @Column(name = "nombre") + private String nombre; + @Size(max = 2147483647) + @Column(name = "descripcion") + private String descripcion; + @OneToMany(mappedBy = "tema") + private List tareaList; + @JoinColumn(name = "id_concepto", referencedColumnName = "id_concepto") + @ManyToOne + private Concepto idConcepto; + + public Tema() { + } + + public Tema(Integer idTema) { + this.idTema = idTema; + } + + public Tema(Integer idTema, String nombre) { + this.idTema = idTema; + this.nombre = nombre; + } + + public Integer getIdTema() { + return idTema; + } + + public void setIdTema(Integer idTema) { + this.idTema = idTema; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public String getDescripcion() { + return descripcion; + } + + public void setDescripcion(String descripcion) { + this.descripcion = descripcion; + } + + @XmlTransient + public List getTareaList() { + return tareaList; + } + + public void setTareaList(List tareaList) { + this.tareaList = tareaList; + } + + public Concepto getIdConcepto() { + return idConcepto; + } + + public void setIdConcepto(Concepto idConcepto) { + this.idConcepto = idConcepto; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (idTema != null ? idTema.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Tema)) { + return false; + } + Tema other = (Tema) object; + if ((this.idTema == null && other.idTema != null) || (this.idTema != null && !this.idTema.equals(other.idTema))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "model.Tema[ idTema=" + idTema + " ]"; + } + +} diff --git a/EjercitarServer/build/classes/beans/red_alumno_1.xdsl b/EjercitarServer/build/classes/beans/red_alumno_1.xdsl new file mode 100644 index 0000000..76e2209 --- /dev/null +++ b/EjercitarServer/build/classes/beans/red_alumno_1.xdsl @@ -0,0 +1,60 @@ + + + + + + + 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + + E1 + + + + 203 276 251 306 + + + E2 + + + + 365 272 413 302 + + + E3 + + + + 508 290 556 320 + + + C1 + + + + 354 101 390 123 + + + + diff --git a/EjercitarServer/build/classes/red_alumno_1.xdsl b/EjercitarServer/build/classes/red_alumno_1.xdsl new file mode 100644 index 0000000..76e2209 --- /dev/null +++ b/EjercitarServer/build/classes/red_alumno_1.xdsl @@ -0,0 +1,60 @@ + + + + + + + 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + + E1 + + + + 203 276 251 306 + + + E2 + + + + 365 272 413 302 + + + E3 + + + + 508 290 556 320 + + + C1 + + + + 354 101 390 123 + + + + diff --git a/EjercitarServer/build/classes/red_base_curso_1.xdsl b/EjercitarServer/build/classes/red_base_curso_1.xdsl new file mode 100644 index 0000000..76e2209 --- /dev/null +++ b/EjercitarServer/build/classes/red_base_curso_1.xdsl @@ -0,0 +1,60 @@ + + + + + + + 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + + E1 + + + + 203 276 251 306 + + + E2 + + + + 365 272 413 302 + + + E3 + + + + 508 290 556 320 + + + C1 + + + + 354 101 390 123 + + + + diff --git a/EjercitarServer/ejbModule/beans/EjercitarWSBean.java b/EjercitarServer/ejbModule/beans/EjercitarWSBean.java index 96c7a8d..b006864 100644 --- a/EjercitarServer/ejbModule/beans/EjercitarWSBean.java +++ b/EjercitarServer/ejbModule/beans/EjercitarWSBean.java @@ -1,7 +1,9 @@ package beans; +import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Random; import javax.ejb.LocalBean; import javax.ejb.Remote; @@ -15,7 +17,13 @@ import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.Query; +import smile.Network; + +import model.Alumno; +import model.Concepto; +import model.Curso; import model.Ejercicio; +import model.Tarea; import model.Tema; /** @@ -27,30 +35,55 @@ import model.Tema; @Stateless public class EjercitarWSBean implements EjercitarWSRemote { - @PersistenceContext EntityManager em; + @PersistenceContext + EntityManager em; /** * Default constructor. */ public EjercitarWSBean() { - // TODO Auto-generated constructor stub + } - /* (non-Javadoc) - * @see beans.EjercitarWSRemote#getTemas() - */ - + @WebMethod - public Collection getTemas() { + public List getTareas(int idAlumno) { // TODO Auto-generated method stub - Query query = em.createQuery("SELECT e FROM Tema e"); - return (Collection) query.getResultList(); + System.out.println(idAlumno); + Alumno alumno = em.find(Alumno.class, idAlumno); + System.out.println(alumno.getApellido()); + Curso curso = alumno.getCurso(); + List listaTareas = curso.getTareaList(); + return (List) listaTareas; } @WebMethod - public Ejercicio getSiguienteEjercicio() { + public Ejercicio getSiguienteEjercicio(int idTarea, int idAlumno, int idEjercicio, String respuesta) { // TODO Auto-generated method stub - Ejercicio ej = em.find(Ejercicio.class, 1); - return ej; + Tarea tarea = em.find(Tarea.class, idTarea); + Alumno alumno = em.find(Alumno.class, idAlumno); + // + responderEjercicio(idEjercicio, respuesta, alumno); + + // + + Ejercicio ejercicio = seleccionAleatoria(tarea); + seleccionUtilidadMax(tarea, alumno); + System.out.println(ejercicio.getRespuestaList().toString()); // NO BORRAR + return ejercicio; + } + + private void responderEjercicio(int idEjercicio, String respuesta, Alumno alumno) { + Ejercicio ejercicio = em.find(Ejercicio.class, idEjercicio); + Network net1 = new Network(); + String nombreRed = "red_alumno_" + alumno.getIdAlumno() + ".xdsl"; + net1.updateBeliefs(); + String nombreEjercicio = "E" + idEjercicio; + + if(respuesta.equals(ejercicio.getIdRespuesta().getDescripcion())){ + net1.setEvidence(nombreEjercicio, "Correcto"); + } else { + net1.setEvidence(nombreEjercicio, "Incorrecto"); + } } @WebMethod @@ -58,6 +91,78 @@ public class EjercitarWSBean implements EjercitarWSRemote { return "hola mundo"; } + private Ejercicio seleccionAleatoria(Tarea tarea) { + Tema tema = tarea.getTema(); + + //List = tema.getIdConcepto() + List ejercicios = em.createQuery("SELECT e FROM Ejercicio e").getResultList(); + System.out.println(ejercicios.size()); + Random rnd = new Random(); + int siguienteID = rnd.nextInt(ejercicios.size()); + System.out.println(siguienteID); + Ejercicio ejercicio = ejercicios.get(siguienteID); + System.out.println(ejercicio.getEnunciado()); + return ejercicio; + } + private Ejercicio seleccionUtilidadMax(Tarea tarea, Alumno alumno) { + Tema tema = tarea.getTema(); + List conceptoList = new ArrayList(); + conceptoList.add(tema.getIdConcepto()); // CAMBIAR + + // inicializacion + double utilidadMax = 0; + Ejercicio ejercicio = null; + + for (Concepto concepto : conceptoList) { + + //red + Network net1 = new Network(); + String nombreRed = "red_alumno_" + alumno.getIdAlumno() + ".xdsl"; + System.out.println("redes/" + nombreRed); + net1.readFile("redes/" + nombreRed); + net1.updateBeliefs(); + //Network net2 = new Network(); + //net2.readFile("redes/" + nombreRed); + //red + + String nombreConcepto = "C" + concepto.getIdConcepto(); + //prueba de evidencias 1 + + double [] values = net1.getNodeValue(nombreConcepto); + System.out.println("values"); + System.out.println(values.toString()); + double pC1 = values[0]; // P(C=1) + double pC0 = values[1]; // P(C=0) + + List ejercicios = concepto.getEjercicioList(); + for(Ejercicio ejercicioConcepto : ejercicios){ + String nombreEjercicio = "E" + ejercicioConcepto.getIdEjercicio(); + net1.setEvidence(nombreConcepto, "Conoce"); + net1.updateBeliefs(); + values = net1.getNodeValue(nombreEjercicio); + double pE1C1 = values[0]; // P(E=1/C=1) + + double utilidadParcial1 = pE1C1 * pC1; + + net1.clearEvidence(nombreConcepto); + net1.updateBeliefs(); + net1.setEvidence(nombreConcepto, "No_conoce"); + net1.updateBeliefs(); + double pE0C0 = values[1]; // P(E=0/C=0) + + double utilidadParcial2 = pE0C0 * pC0; + + double utilidadMaxParcial = utilidadParcial1 + utilidadParcial2; + + if(utilidadMaxParcial > utilidadMax) { + utilidadMax = utilidadMaxParcial; + ejercicio = ejercicioConcepto; + } + } + } + + return ejercicio; + } } diff --git a/EjercitarServer/ejbModule/beans/EjercitarWSRemote.java b/EjercitarServer/ejbModule/beans/EjercitarWSRemote.java new file mode 100644 index 0000000..e92d4c0 --- /dev/null +++ b/EjercitarServer/ejbModule/beans/EjercitarWSRemote.java @@ -0,0 +1,22 @@ +package beans; + +import java.util.Collection; +import java.util.List; + +import javax.jws.WebMethod; +import javax.jws.WebService; + +import model.Ejercicio; +import model.Tarea; +import model.Tema; + +@WebService +public interface EjercitarWSRemote { + + public List getTareas(int idAlumno); + + public Ejercicio getSiguienteEjercicio(int idTarea, int idAlumno, int idEjercicio, String respuesta); + + public String getText(); + +} \ No newline at end of file diff --git a/EjercitarServer/ejbModule/beans/Test.java b/EjercitarServer/ejbModule/beans/Test.java new file mode 100644 index 0000000..298955e --- /dev/null +++ b/EjercitarServer/ejbModule/beans/Test.java @@ -0,0 +1,20 @@ +package beans; + +import smile.Network; + +public class Test { + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + String path = System.getProperty("java.library.path"); + System.out.println(path); + + Network net = new Network(); + net.readFile("red_alumno_1.xdsl"); + + } + +} diff --git a/EjercitarServer/ejbModule/beans/red_alumno_1.xdsl b/EjercitarServer/ejbModule/beans/red_alumno_1.xdsl new file mode 100644 index 0000000..76e2209 --- /dev/null +++ b/EjercitarServer/ejbModule/beans/red_alumno_1.xdsl @@ -0,0 +1,60 @@ + + + + + + + 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + + E1 + + + + 203 276 251 306 + + + E2 + + + + 365 272 413 302 + + + E3 + + + + 508 290 556 320 + + + C1 + + + + 354 101 390 123 + + + + diff --git a/EjercitarServer/lib/jsmile.dll b/EjercitarServer/lib/jsmile.dll new file mode 100644 index 0000000..7ce81a6 --- /dev/null +++ b/EjercitarServer/lib/jsmile.dll Binary files differ diff --git a/EjercitarServer/lib/postgresql-9.0-801.jdbc4.jar b/EjercitarServer/lib/postgresql-9.0-801.jdbc4.jar new file mode 100644 index 0000000..63e5416 --- /dev/null +++ b/EjercitarServer/lib/postgresql-9.0-801.jdbc4.jar Binary files differ diff --git a/EjercitarServer/lib/smile.jar b/EjercitarServer/lib/smile.jar new file mode 100644 index 0000000..a7238e9 --- /dev/null +++ b/EjercitarServer/lib/smile.jar Binary files differ diff --git a/EjercitarServer/redes/red_alumno_1.xdsl b/EjercitarServer/redes/red_alumno_1.xdsl new file mode 100644 index 0000000..76e2209 --- /dev/null +++ b/EjercitarServer/redes/red_alumno_1.xdsl @@ -0,0 +1,60 @@ + + + + + + + 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + + E1 + + + + 203 276 251 306 + + + E2 + + + + 365 272 413 302 + + + E3 + + + + 508 290 556 320 + + + C1 + + + + 354 101 390 123 + + + + diff --git a/EjercitarServer/redes/red_base_curso_1.xdsl b/EjercitarServer/redes/red_base_curso_1.xdsl new file mode 100644 index 0000000..76e2209 --- /dev/null +++ b/EjercitarServer/redes/red_base_curso_1.xdsl @@ -0,0 +1,60 @@ + + + + + + + 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + C1 + 0.5 0.5 0.5 0.5 + + + + + + E1 + + + + 203 276 251 306 + + + E2 + + + + 365 272 413 302 + + + E3 + + + + 508 290 556 320 + + + C1 + + + + 354 101 390 123 + + + + -- cgit v0.9.1