Re-uploaded the project in only one repository

This commit is contained in:
Daniel Cortes
2017-07-31 13:07:07 -04:00
commit e5853c8de6
1098 changed files with 220719 additions and 0 deletions

View File

@@ -0,0 +1,542 @@
package logica;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import orm.*;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import static org.junit.Assert.*;
public class CRUDTest {
@Before
public void setUp() throws Exception {
ExNihilo.deleteAll();
}
public void crearColegio() {
String nombre = "Jhon";
Colegio antes = Search.buscarColegio(nombre);
assertNull(antes);
ExNihilo.crearColegio(nombre);
Colegio despues = Search.buscarColegio(nombre);
assertNotNull(despues);
assertNotEquals(antes, despues);
}
public void buscarColegio() {
assertNotNull(Search.buscarColegios());
assertNotNull(Search.buscarColegio("Jhon"));
}
public void modificarColegio() {
String aNombre = "Jhon";
String dNombre = "Doe";
Colegio colegio = Search.buscarColegio(aNombre);
assertNotNull(colegio);
boolean exitoso = ExNihilo.modificarColegio(colegio, dNombre);
assertEquals(dNombre, colegio.getNombre());
}
public void eliminarColegio() {
String nombre = "Doe";
Colegio antes = Search.buscarColegio(nombre);
assertNotNull(antes);
ExNihilo.eliminarColegio(antes);
Colegio despues = Search.buscarColegio(nombre);
assertNull(despues);
}
@Test
public void crudColegio() {
crearColegio();
buscarColegio();
modificarColegio();
eliminarColegio();
}
public void crearCurso() {
ExNihilo.crearColegio("Jhon");
Colegio colegio = Search.buscarColegio("Jhon");
int nivel = 1;
String letra = "A";
Curso curso = Search.buscarCurso(nivel, letra);
assertNull(curso);
ExNihilo.crearCurso(nivel, letra, colegio);
curso = Search.buscarCurso(nivel, letra);
assertNotNull(curso);
}
public void buscarCurso() {
assertNotNull(Search.buscarCursos());
assertNotNull(Search.buscarCursos(Search.buscarColegios()[0]));
assertNotNull(Search.buscarCurso(1, "A"));
}
public void modificarCurso() {
int aNivel = 1;
String aLetra = "A";
int dNivel = 2;
String dLetra = "B";
Curso curso = Search.buscarCurso(aNivel, aLetra);
assertNotNull(curso);
assertEquals(curso.getLetra(), aLetra);
ExNihilo.modificarCurso(curso, dNivel, dLetra, null);
assertNotNull(curso);
assertEquals(curso.getLetra(), dLetra);
}
public void eliminarCurso() {
Curso curso = Search.buscarCurso(2, "B");
assertNotNull(curso);
ExNihilo.eliminarCurso(curso);
Curso despues = Search.buscarCurso(2, "B");
assertNull(despues);
}
@Test
public void crudCurso() {
crearCurso();
buscarCurso();
modificarCurso();
eliminarCurso();
}
public void crearApoderado() {
ExNihilo.crearColegio("Jhon");
String nombre = "Jhon";
String rut = "197638990";
Apoderado antes = Search.buscarApoderado(rut);
assertNull(antes);
ExNihilo.crearApoderado(Search.buscarColegio("Jhon"), nombre, rut);
Apoderado despues = Search.buscarApoderado(rut);
assertNotNull(despues);
assertNotEquals(antes, despues);
assertEquals(despues.getNombre(), nombre);
assertEquals(despues.getRut(), rut);
}
public void buscarApoderado() {
assertNotNull(Search.buscarApoderado("197638990"));
assertNotNull(Search.buscarApoderados(Search.buscarColegios()[0]));
assertNotNull(Search.buscarApoderados());
}
public void modificarApoderado() {
String rut = "197638990";
String aNombre = "Jhon";
String dNombre = "Doe";
Apoderado apoderado = Search.buscarApoderado(rut);
assertNotNull(apoderado);
ExNihilo.modificarApoderado(apoderado, dNombre, null);
apoderado = Search.buscarApoderado(rut);
assertNotEquals(apoderado.getNombre(), aNombre);
assertEquals(apoderado.getNombre(), dNombre);
}
public void eliminarApoderado() {
String rut = "197638990";
Apoderado apoderado = Search.buscarApoderado(rut);
assertNotNull(apoderado);
ExNihilo.eliminarApoderado(apoderado);
apoderado = Search.buscarApoderado(rut);
assertNull(apoderado);
}
@Test
public void crudApoderado() {
crearApoderado();
buscarApoderado();
modificarApoderado();
eliminarApoderado();
}
public void crearEstudiante() {
ExNihilo.crearColegio("Jhon");
Colegio colegio = Search.buscarColegio("Jhon");
ExNihilo.crearCurso(1, "A", colegio);
Curso curso = Search.buscarCurso(1, "A");
ExNihilo.crearApoderado(colegio, "Jhon", "108583320");
Apoderado apoderado = Search.buscarApoderado("108583320");
Estudiante estudiante = Search.buscarEstudiante("197638990");
assertNull(estudiante);
ExNihilo.crearEstudiante("Jhon", "197638990", curso, apoderado);
estudiante = Search.buscarEstudiante("197638990");
assertNotNull(estudiante);
}
public void buscarEstudiante() {
assertNotNull(Search.buscarEstudiante("197638990"));
assertNotNull(Search.buscarEstudiantes());
assertNotNull(Search.buscarEstudiantes(Search.buscarCurso(1, "A")));
assertNotNull(Search.buscarEstudiantes(Search.buscarApoderado("108583320")));
}
public void modificarEstudiante() {
String rut = "197638990";
String nRut = "99875372";
Estudiante estudiante = Search.buscarEstudiante(rut);
assertNotNull(estudiante);
ExNihilo.modificarEstudiante(estudiante, null, nRut, null, null);
estudiante = Search.buscarEstudiante(nRut);
assertEquals(estudiante.getRut(), nRut);
}
public void eliminarEstudiante() {
String rut = "99875372";
Estudiante estudiante = Search.buscarEstudiante(rut);
assertNotNull(estudiante);
ExNihilo.eliminarEstudiante(estudiante);
estudiante = Search.buscarEstudiante(rut);
assertNull(estudiante);
}
@Test
public void crudEstudiante() {
crearEstudiante();
buscarEstudiante();
modificarEstudiante();
eliminarEstudiante();
}
public void crearProfesor() {
ExNihilo.crearColegio("Jhon");
Colegio colegio = Search.buscarColegio("Jhon");
Profesor profesor = Search.buscarProfesor("108583320");
assertNull(profesor);
ExNihilo.crearProfesor(colegio, "Jhon", "108583320");
profesor = Search.buscarProfesor("108583320");
assertNotNull(profesor);
}
public void buscarProfesor() {
assertNotNull(Search.buscarProfesor("108583320"));
assertNotNull(Search.buscarProfesores());
assertNotNull(Search.buscarProfesores(Search.buscarColegio("Jhon")));
}
public void modificarProfesor() {
Profesor profesor = Search.buscarProfesor("108583320");
String vNombre = "Jhon";
assertEquals(profesor.getNombre(), vNombre);
String nNombre = "Doe";
ExNihilo.modificarProfesor(profesor, nNombre, null);
assertEquals(profesor.getNombre(), nNombre);
assertNotEquals(profesor.getNombre(), vNombre);
}
public void eliminarProfesor() {
Profesor profesor = Search.buscarProfesor("108583320");
assertNotNull(profesor);
ExNihilo.eliminarProfesor(profesor);
profesor = Search.buscarProfesor("108583320");
assertNull(profesor);
}
@Test
public void crudProfesor() {
crearProfesor();
buscarProfesor();
modificarProfesor();
eliminarProfesor();
}
public void crearAsignatura() {
ExNihilo.crearColegio("Jhon");
Colegio colegio = Search.buscarColegio("Jhon");
ExNihilo.crearCurso(1, "A", colegio);
Curso curso = Search.buscarCurso(1, "A");
ExNihilo.crearProfesor(colegio, "Jhon", "108583320");
Profesor profesor = Search.buscarProfesor("108583320");
Asignatura asignatura = Search.buscarAsignatura("Historia", curso);
assertNull(asignatura);
ExNihilo.crearAsignatura("Historia", curso, profesor);
asignatura = Search.buscarAsignatura("Historia", curso);
assertNotNull(asignatura);
}
public void buscarAsignatura() {
assertNotNull(Search.buscarAsignatura("Historia", Search.buscarCurso(1, "A")));
assertNotNull(Search.buscarAsignaturas(Search.buscarCurso(1, "A")));
assertNotNull(Search.buscarAsignaturas(Search.buscarProfesor("108583320")));
assertNotNull(Search.buscarAsignaturas());
}
public void modificarAsignatura() {
String nNombre = "Matematicas";
String vNombre = "Historia";
Curso curso = Search.buscarCurso(1, "A");
Asignatura asignatura = Search.buscarAsignatura(vNombre, curso);
assertEquals(asignatura.getNombre(), vNombre);
ExNihilo.modificarAsignatura(asignatura, nNombre, null, null);
assertEquals(asignatura.getNombre(), nNombre);
}
public void eliminarAsignatura() {
Curso curso = Search.buscarCurso(1, "A");
Asignatura asignatura = Search.buscarAsignatura("Matematicas", curso);
assertNotNull(asignatura);
ExNihilo.eliminarAsignatura(asignatura);
asignatura = Search.buscarAsignatura("Historia", curso);
assertNull(asignatura);
}
@Test
public void crudAsignatura() {
crearAsignatura();
buscarAsignatura();
modificarAsignatura();
eliminarAsignatura();
}
public void crearAsistencia() {
ExNihilo.crearColegio("Jhon");
Colegio colegio = Search.buscarColegio("Jhon");
ExNihilo.crearCurso(1, "A", colegio);
Curso curso = Search.buscarCurso(1, "A");
ExNihilo.crearApoderado(colegio, "Jhon", "108583320");
Apoderado apoderado = Search.buscarApoderado("108583320");
ExNihilo.crearEstudiante("Jhon", "197638990", curso, apoderado);
Estudiante estudiante = Search.buscarEstudiante("197638990");
Date fecha = new GregorianCalendar(2017, Calendar.JANUARY, 1).getTime();
boolean asistio = true;
Asistencia asistencia = Search.buscarAsistencia(estudiante, fecha, asistio);
assertNull(asistencia);
ExNihilo.crearAsistencia(fecha, asistio, estudiante);
asistencia = Search.buscarAsistencia(estudiante, fecha, asistio);
assertNotNull(asistencia);
}
public void buscarAsistencia() {
assertNotNull(Search.buscarAsistencias());
assertNotNull(Search.buscarAsistencias(Search.buscarEstudiante("197638990")));
assertNotNull(Search.buscarAsistencia(Search.buscarEstudiante("197638990"), new GregorianCalendar(2017, Calendar.JANUARY, 1).getTime(), true));
}
public void modificarAsistencia() {
Estudiante estudiante = Search.buscarEstudiante("197638990");
Date fecha = new GregorianCalendar(2017, Calendar.JANUARY, 1).getTime();
boolean asistio = true;
Asistencia asistencia = Search.buscarAsistencia(estudiante, fecha, asistio);
assertNotNull(asistencia);
ExNihilo.modificarAsistencia(asistencia, null, !asistio, null);
asistencia = Search.buscarAsistencia(estudiante, fecha, !asistio);
assertNotEquals(asistencia.getAsistio(), asistio);
assertEquals(asistencia.getAsistio(), !asistio);
}
public void eliminarAsistencia() {
Estudiante estudiante = Search.buscarEstudiante("197638990");
Date fecha = new GregorianCalendar(2017, Calendar.JANUARY, 1).getTime();
boolean asistio = false;
Asistencia asistencia = Search.buscarAsistencia(estudiante, fecha, asistio);
assertNotNull(asistencia);
ExNihilo.eliminarAsistencia(asistencia);
asistencia = Search.buscarAsistencia(estudiante, fecha, asistio);
assertNull(asistencia);
}
@Test
public void crudAsistencia() {
crearAsistencia();
buscarAsistencia();
modificarAsistencia();
eliminarAsistencia();
}
public void crearNota() {
ExNihilo.crearColegio("Jhon");
Colegio colegio = Search.buscarColegio("Jhon");
ExNihilo.crearCurso(1, "A", colegio);
Curso curso = Search.buscarCurso(1, "A");
ExNihilo.crearApoderado(colegio, "Jhon", "108583320");
Apoderado apoderado = Search.buscarApoderado("108583320");
ExNihilo.crearEstudiante("Jhon", "197638990", curso, apoderado);
Estudiante estudiante = Search.buscarEstudiante("197638990");
ExNihilo.crearProfesor(colegio, "Jhon", "99875372");
Profesor profesor = Search.buscarProfesor("99875372");
ExNihilo.crearAsignatura("Historia", curso, profesor);
Asignatura asignatura = Search.buscarAsignatura("Historia", curso);
Nota nota = Search.buscarNota(estudiante, asignatura, 7.0D);
assertNull(nota);
ExNihilo.crearNota(7.0D, asignatura, estudiante);
nota = Search.buscarNota(estudiante, asignatura, 7.0D);
assertNotNull(nota);
}
public void buscarNota() {
assertNotNull(Search.buscarNotas());
assertNotNull(Search.buscarNota(Search.buscarEstudiante("197638990"), Search.buscarAsignatura("Historia", Search.buscarCurso(1, "A")), 7.0D));
assertNotNull(Search.buscarNotas(Search.buscarAsignatura("Historia", Search.buscarCurso(1, "A"))));
assertNotNull(Search.buscarNotas(Search.buscarEstudiante("197638990")));
}
public void modificarNota() {
Estudiante estudiante = Search.buscarEstudiante("197638990");
Curso curso = Search.buscarCurso(1, "A");
Asignatura asignatura = Search.buscarAsignatura("Historia", curso);
Nota nota = Search.buscarNota(estudiante, asignatura, 7.0D);
assertEquals(nota.getValor(), (Double) 7.0D);
double nNota = 5.0D;
ExNihilo.modificarNota(nota, nNota, null, null);
assertEquals(nota.getValor(), (Double) nNota);
}
public void eliminarNota() {
Estudiante estudiante = Search.buscarEstudiante("197638990");
Curso curso = Search.buscarCurso(1, "A");
Asignatura asignatura = Search.buscarAsignatura("Historia", curso);
Nota nota = Search.buscarNota(estudiante, asignatura, 5.0D);
assertNotNull(nota);
ExNihilo.eliminarNota(nota);
nota = Search.buscarNota(estudiante, asignatura, 5.0D);
assertNull(nota);
}
@Test
public void crudNota() {
crearNota();
buscarNota();
modificarNota();
eliminarNota();
}
public void crearAnotacion() {
ExNihilo.crearColegio("Jhon");
Colegio colegio = Search.buscarColegio("Jhon");
ExNihilo.crearCurso(1, "A", colegio);
Curso curso = Search.buscarCurso(1, "A");
ExNihilo.crearApoderado(colegio, "Jhon", "108583320");
Apoderado apoderado = Search.buscarApoderado("108583320");
ExNihilo.crearEstudiante("Jhon", "197638990", curso, apoderado);
Estudiante estudiante = Search.buscarEstudiante("197638990");
ExNihilo.crearProfesor(colegio, "Jhon", "99875372");
Profesor profesor = Search.buscarProfesor("99875372");
Anotacion anotacion = Search.buscarAnotacion(estudiante, profesor, "Random", true);
assertNull(anotacion);
ExNihilo.crearAnotacion(true, "Random", estudiante, profesor);
anotacion = Search.buscarAnotacion(estudiante, profesor, "Random", true);
assertNotNull(anotacion);
}
public void buscarAnotacion() {
assertNotNull(Search.buscarAnotacion(Search.buscarEstudiante("197638990"),
Search.buscarProfesor("99875372"),
"Random",
true));
assertNotNull(Search.buscarAnotaciones());
assertNotNull(Search.buscarAnotaciones(Search.buscarEstudiante("197638990")));
assertNotNull(Search.buscarAnotaciones(Search.buscarProfesor("99875372")));
}
public void modificarAnotacion() {
Estudiante estudiante = Search.buscarEstudiante("197638990");
Profesor profesor = Search.buscarProfesor("99875372");
Anotacion anotacion = Search.buscarAnotacion(estudiante, profesor, "Random", true);
assertNotNull(anotacion);
assertEquals(anotacion.getPositiva(), true);
ExNihilo.modificarAnotacion(anotacion, false, null, null, null);
anotacion = Search.buscarAnotacion(estudiante, profesor, "Random", false);
assertEquals(anotacion.getPositiva(), false);
}
public void eliminarAnotacion() {
Estudiante estudiante = Search.buscarEstudiante("197638990");
Profesor profesor = Search.buscarProfesor("99875372");
Anotacion anotacion = Search.buscarAnotacion(estudiante, profesor, "Random", false);
assertNotNull(anotacion);
ExNihilo.eliminarAnotacion(anotacion);
anotacion = Search.buscarAnotacion(estudiante, profesor, "Random", false);
assertNull(anotacion);
}
@Test
public void crudAnotacion() {
crearAnotacion();
buscarAnotacion();
modificarAnotacion();
eliminarAnotacion();
}
public void crearActividad() {
Date fecha = new GregorianCalendar(2017, Calendar.JANUARY, 1).getTime();
ExNihilo.crearColegio("Jhon");
Colegio colegio = Search.buscarColegio("Jhon");
ExNihilo.crearCurso(1, "A", colegio);
Curso curso = Search.buscarCurso(1, "A");
ExNihilo.crearProfesor(colegio, "Jhon", "99875372");
Profesor profesor = Search.buscarProfesor("99875372");
ExNihilo.crearAsignatura("Historia", curso, profesor);
Asignatura asignatura = Search.buscarAsignatura("Historia", curso);
Actividad actividad = Search.buscarActividad(asignatura, fecha, "Prueba");
assertNull(actividad);
ExNihilo.crearActividad(fecha, "Prueba", asignatura);
actividad = Search.buscarActividad(asignatura, fecha, "Prueba");
assertNotNull(actividad);
}
public void buscarActividad() {
assertNotNull(Search.buscarActividades());
assertNotNull(Search.buscarActividad(
Search.buscarAsignatura("Historia", Search.buscarCurso(1, "A")),
new GregorianCalendar(2017, Calendar.JANUARY, 1).getTime(),
"Prueba"));
assertNotNull(Search.buscarActividades(new GregorianCalendar(2017, Calendar.JANUARY, 1).getTime()));
assertNotNull(Search.buscarActividades(Search.buscarAsignatura("Historia", Search.buscarCurso(1, "A"))));
assertNotNull(Search.buscarActividades("Prueba"));
}
public void modificarActividad() {
Date fecha = new GregorianCalendar(2017, Calendar.JANUARY, 1).getTime();
Curso curso = Search.buscarCurso(1, "A");
Asignatura asignatura = Search.buscarAsignatura("Historia", curso);
Actividad actividad = Search.buscarActividad(asignatura, fecha, "Prueba");
assertNotNull(actividad);
ExNihilo.modificarActividad(actividad, null, "Taller", null);
actividad = Search.buscarActividad(asignatura, fecha, "Taller");
assertEquals(actividad.getTipo(), "Taller");
}
public void eliminarActividad() {
Date fecha = new GregorianCalendar(2017, Calendar.JANUARY, 1).getTime();
Curso curso = Search.buscarCurso(1, "A");
Asignatura asignatura = Search.buscarAsignatura("Historia", curso);
Actividad actividad = Search.buscarActividad(asignatura, fecha, "Taller");
assertNotNull(actividad);
ExNihilo.eliminarActividad(actividad);
actividad = Search.buscarActividad(asignatura, fecha, "Taller");
assertNull(actividad);
}
@Test
public void crudActividad() {
crearActividad();
buscarActividad();
modificarActividad();
eliminarActividad();
}
@After
public void tearDown() {
ExNihilo.deleteAll();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,310 @@
package logica;
import orm.*;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
public class Listas {
/**
* Entrega una lista con los datos de las actividades de una asignatura.
* Tiene 2 indices, el primero muestra la fecha, el segundo muestra el tipo.
*
* @param asignatura Asignatura a la que pertenecen las activiadades
* @return La lista con los datos de las actividades de la asignatura
*/
public static String[][] listaActividades(Asignatura asignatura) {
if (asignatura != null) {
Actividad[] actividades = Search.buscarActividades(asignatura);
if (actividades != null) {
String[][] lista = new String[actividades.length][2];
for (int x = 0; x < lista.length; x++) {
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
lista[x][0] = format.format(actividades[x].getFecha());
lista[x][1] = actividades[x].getTipo();
}
return lista;
}
}
return null;
}
/**
* Entrega la lista de cursos del sistema
*
* @return Retorna la lista de cursos con el formato nivel-letra
*/
public static String[] listaCursos() {
Curso[] cursos = Search.buscarCursos();
if (cursos != null) {
String[] lista = new String[cursos.length];
for (int x = 0; x < lista.length; x++) {
lista[x] = cursos[x].getNivel() + "-" + cursos[x].getLetra();
}
return lista;
} else {
return null;
}
}
/**
* Genera una lista con los profesores del colegio
*
* @return La lista con los ruts de los profesores del colegio.
*/
public static String[] listaProfesor() {
Profesor[] profesores = Search.buscarProfesores();
if (profesores != null) {
String[] lista = new String[profesores.length];
for (int x = 0; x < lista.length; x++) {
lista[x] = profesores[x].getRut();
}
return lista;
}
return null;
}
/**
* Entrega la lista de los profesores de un curso del sistema.
*
* @param curso Curso al que le hace clase los profesores
* @return Lista con los ruts de los profesores del sistema.
*/
public static String[] listaProfesores(Curso curso) {
if (curso != null) {
Profesor[] profesores = Search.buscarProfesores(curso);
if (profesores != null) {
String[] lista = new String[profesores.length];
for (int x = 0; x < lista.length; x++) {
lista[x] = profesores[x].getRut();
}
return lista;
}
}
return null;
}
/**
* Genera la lista de profesores con nombre y rut
*
* @return Retorna la lista, en el primer indice muestra el nombre de un profesor y en el segundo almacena el rut.
*/
public static String[][] listaProfesores() {
Profesor[] profesores = Search.buscarProfesores();
if (profesores != null) {
String[][] list = new String[profesores.length][2];
for (int x = 0; x < list.length; x++) {
list[x][0] = profesores[x].getNombre();
list[x][1] = profesores[x].getRut();
}
return list;
}
return null;
}
/**
* Genera la lista de estudiantes de un curso.
*
* @param curso Curso del cual se quiere la lista de estudiantes
* @return La lista con los estudiantes, en el primer indice se encuentra el nombre y en el segundo el rut.
*/
public static String[][] listaEstudiantes(Curso curso) {
if (curso != null) {
Estudiante[] estudiantes = Search.buscarEstudiantes(curso);
if (estudiantes != null) {
String[][] lista = new String[estudiantes.length][2];
for (int x = 0; x < lista.length; x++) {
lista[x][0] = estudiantes[x].getNombre();
lista[x][1] = estudiantes[x].getRut();
}
return lista;
}
}
return null;
}
/**
* Genera la lista de apoderados del sistema
*
* @return La lista con los apoderados del sistema, en el primer indice se encuentra el nombre y en el segundo el rut.
*/
public static String[][] listaApoderados() {
Apoderado[] apoderados = Search.buscarApoderados();
if (apoderados != null) {
String[][] lista = new String[apoderados.length][2];
for (int x = 0; x < lista.length; x++) {
lista[x][0] = apoderados[x].getNombre();
lista[x][1] = apoderados[x].getRut();
}
return lista;
} else {
return null;
}
}
/**
* Genera la lista de estudiantes de un apoderado.
*
* @param apoderado Apoderado al cual pertencen los estudiantes que se buscan.
* @return La lista de estudiantes del apoderado, en el primer indice se encontrara el nombre, y en el segundo el rut.
*/
public static String[][] listaEstudiantes(Apoderado apoderado) {
if (apoderado != null) {
Estudiante[] estudiantes = Search.buscarEstudiantes(apoderado);
if (estudiantes != null) {
String[][] lista = new String[estudiantes.length][3];
for (int x = 0; x < lista.length; x++) {
lista[x][0] = estudiantes[x].getNombre();
lista[x][1] = estudiantes[x].getRut();
lista[x][2] = estudiantes[x].getCurso_id_fk().getNivel() + "-" + estudiantes[x].getCurso_id_fk().getLetra();
}
return lista;
}
}
return null;
}
/**
* Genera la lista de anotaciones de un estudiante
*
* @param estudiante Estudiante al que pertenecen estas anotaciones
* @return Retorna la lista generada, en el primer indice almacenara el nombre y en el segundo el rut.
*/
public static String[][] listaAnotaciones(Estudiante estudiante) {
if (estudiante != null) {
Anotacion[] anotaciones = Search.buscarAnotaciones(estudiante);
if (anotaciones != null) {
String[][] lista = new String[anotaciones.length][3];
for (int x = 0; x < lista.length; x++) {
lista[x][0] = anotaciones[x].getProfesor_id_fk().getRut();
lista[x][1] = anotaciones[x].getDescripcion();
if (anotaciones[x].getPositiva()) {
lista[x][2] = "Positiva";
} else {
lista[x][2] = "Negativa";
}
}
return lista;
}
}
return null;
}
/**
* Genera la lista de asistencias de un estudiante.
*
* @param estudiante Estudiante al que pertencen las asistencias
* @return Retorna la lista de asistencias del estudiante indicando la fecha y si asistio o no.
*/
public static String[][] listaAsistencia(Estudiante estudiante) {
if (estudiante != null) {
Asistencia[] asistencias = Search.buscarAsistencias(estudiante);
if (asistencias != null) {
String[][] lista = new String[asistencias.length][2];
for (int x = 0; x < lista.length; x++) {
SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");
lista[x][0] = format.format(asistencias[x].getDia());
if (asistencias[x].getAsistio()) {
lista[x][1] = "Si";
} else {
lista[x][1] = "No";
}
}
return lista;
}
}
return null;
}
/**
* Genera la lista de notas de un estudiante en una asignatura.
*
* @param estudiante Estudiante al que pertencen las notas
* @param asignatura Asignatura al que pertenecen las notas del estudiante.
* @return La lista generada solo tienen un indice apesar de que entrege un array doble.
*/
public static String[][] listaNotas(Estudiante estudiante, Asignatura asignatura) {
if (estudiante != null && asignatura != null) {
Nota[] notas = Search.buscarNotas(estudiante);
if (notas != null) {
ArrayList<Nota> notasAsignatura = new ArrayList<>();
for (Nota nota : notas) {
if (nota.getAsignatura_id_fk().equals(asignatura)) {
notasAsignatura.add(nota);
}
}
String[][] lista = new String[notasAsignatura.size()][1];
DecimalFormat df = new DecimalFormat("#.#");
df.setRoundingMode(RoundingMode.CEILING);
for (int x = 0; x < lista.length; x++) {
lista[x][0] = df.format(notasAsignatura.get(x).getValor());
}
return lista;
}
}
return null;
}
/**
* Genera la lista de asignaturas presente en un curso
*
* @param curso Curso al que se le buscaran sus asignaturas.
* @return La lista con los nombres de las asignaturas
*/
public static String[] listaAsignaturas(Curso curso) {
if (curso != null) {
Asignatura[] asignaturas = Search.buscarAsignaturas(curso);
if (asignaturas != null) {
String[] lista = new String[asignaturas.length];
for (int x = 0; x < lista.length; x++) {
lista[x] = asignaturas[x].getNombre();
}
return lista;
}
}
return null;
}
/**
* Genera una lista con las asignaturas y el profesor de estas de un curso
*
* @param curso Curso al que pertencen las asignaturas
* @return La lista generada, en el primer indice esta el nombre de la asignatura y en el segundo el rut del profesor
*/
public static String[][] listaAsignaturasProfesor(Curso curso) {
if (curso != null) {
Asignatura[] asignaturas = Search.buscarAsignaturas(curso);
if (asignaturas != null) {
String[][] lista = new String[asignaturas.length][2];
for (int x = 0; x < lista.length; x++) {
lista[x][0] = asignaturas[x].getNombre();
lista[x][1] = asignaturas[x].getProfesor_id_fk().getNombre();
}
return lista;
}
}
return null;
}
/**
* Genera la lista de asignaturas que imparte un profesor
* @param profesor Profesor que imparte las asignaturas
* @return Retorna la lista generada, en el primer indice el nombre de la asignatura y en el segundo el curso en el que la imparte
*/
public static String[][] listaAsignaturas(Profesor profesor) {
if (profesor != null) {
Asignatura[] asignaturas = Search.buscarAsignaturas(profesor);
if (asignaturas != null) {
String[][] lista = new String[asignaturas.length][2];
for (int x = 0; x < lista.length; x++) {
lista[x][0] = asignaturas[x].getNombre();
lista[x][1] = asignaturas[x].getCurso_id_fk().getNivel() + "-" + asignaturas[x].getCurso_id_fk().getLetra();
}
return lista;
}
}
return null;
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,185 @@
package logica;
import org.apache.commons.lang3.RandomUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Stream;
/**
* Clase con metodos utiles para distintas partes del programa
* Como la creacion y validacion de ruts con codigo verificador con modulo 11
* y la generacion de nombres a partir de un archivo con nombre y otro con archivos
*/
public class Utilities {
/**
* Valida rut comprobando el digito verificador
*
* @param vrut Rut a comprobar
* @param vverificador Supuesto digito verificador del rut
* @return True si es que el digito verificador es correcto y false si no lo es
*/
public static boolean validarRut(String vrut, String vverificador) {
boolean flag;
String rut = vrut.trim();
String posibleVerificador = vverificador.trim();
int cantidad = rut.length();
int factor = 2;
int suma = 0;
String verificador;
for (int i = cantidad; i > 0; i--) {
if (factor > 7) {
factor = 2;
}
suma += (Integer.parseInt(rut.substring((i - 1), i))) * factor;
factor++;
}
verificador = String.valueOf(11 - suma % 11);
flag = verificador.equals(posibleVerificador) || (verificador.equals("10")) && (posibleVerificador.toLowerCase().equals("k")) || (verificador.equals("11") && posibleVerificador.equals("0"));
return flag;
}
/**
* Genera un rut aleatorio entre 10 millones y 21 millones con digito verificador
*
* @return rut y su digito verificador segun modulo 11
*/
public static String getRandomRut() {
int randomNum = new Random().nextInt((21000000 - 10000000) + 1) + 10000000;
String rut = String.valueOf(randomNum);
int cantidad = rut.length();
int factor = 2;
int suma = 0;
String verificador;
for (int i = cantidad; i > 0; i--) {
if (factor > 7) {
factor = 2;
}
suma += (Integer.parseInt(rut.substring((i - 1), i))) * factor;
factor++;
}
verificador = String.valueOf(11 - suma % 11);
if (verificador.equals("11")) {
verificador = "0";
} else if (verificador.equals("10")) {
verificador = "K";
}
return rut + verificador;
}
/**
* Genera un nombre aleatorio tomando un nombre y un apellidos de los archivos y juntandolos en un solo string
*
* @return Nombre aleatorio
*/
public static String getRandomName() {
ArrayList<String> firstNames = new ArrayList<>();
try (BufferedReader br = new BufferedReader(new FileReader("files/nombre.txt"))) {
String line = br.readLine();
while (line != null) {
line = br.readLine();
if (line != null) {
firstNames.add(line);
}
}
} catch (IOException e) {
e.printStackTrace();
}
ArrayList<String> lastNames = new ArrayList<>();
try (BufferedReader br = new BufferedReader(new FileReader("files/apellidos.txt"))) {
String line = br.readLine();
while (line != null) {
line = br.readLine();
if (line != null) {
lastNames.add(line);
}
}
} catch (IOException e) {
e.printStackTrace();
}
int fnRandom = ThreadLocalRandom.current().nextInt(0, firstNames.size());
int lnRandom = ThreadLocalRandom.current().nextInt(0, lastNames.size());
return firstNames.get(fnRandom) + " " + lastNames.get(lnRandom);
}
/**
* Metodo que calcula una nota
* @param puntajeTotal puntaje total de la evaluacion
* @param puntajeObtenido puntaje obtenido del estudiante
* @return Nota en un double, con solo un decimal
*/
public static double calcularNota(double puntajeTotal, double puntajeObtenido) {
return Math.floor((((puntajeObtenido / puntajeTotal) * 6) + 1)*10d)/10d;
}
/**
* Calcula el promedio de un array de doubles
* @param notas array de notas a ser promediadas
* @return la nota promediada con solo 1 decimal
*/
public static double calcularPromedio(double[] notas){
double sum = 0;
for (double nota : notas) {
sum+=nota;
}
return Math.floor((sum/notas.length)*10d)/10d;
}
/**
* Genera una fecha aleatoria
*
* @return Una fecha aleatoria entre 1/1/2017 y el 31/12/2017
*/
public static Date getRandomDate() {
GregorianCalendar gc = new GregorianCalendar();
int year = 2017;
gc.set(gc.YEAR, year);
int dayOfYear = RandomUtils.nextInt(1, gc.getActualMaximum(gc.DAY_OF_YEAR));
gc.set(gc.DAY_OF_YEAR, dayOfYear);
return gc.getTime();
}
/**
* Lee el contenido de un archivo y lo entrega como string
* @param filePath Ruta del archivo
* @return El contenido del archivo
*/
public static String readFile(String filePath){
StringBuilder builder = new StringBuilder();
try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
String line;
while ((line = br.readLine()) != null) {
builder.append(line);
}
} catch (IOException e) {
e.printStackTrace();
}
return builder.toString();
}
}

View File

@@ -0,0 +1,253 @@
package logica.reportes;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.extended.NamedMapConverter;
import logica.Search;
import org.json.XML;
import orm.*;
import javax.xml.transform.TransformerException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.HashMap;
/**
* Clase generadora de reportes, inicia, configura y genera el reporte requerido
* los guarda en xml, json, docx, xlsx y html
* @deprecated Ya no se utiliza :3 se usan las clases de los reportes directamente
*/
public class Reporte {
private File xslPath;
public Reporte(File xslPath) {
this.xslPath = xslPath;
}
public File getXslPath() {
return xslPath;
}
public void setXslPath(File xslPath) {
this.xslPath = xslPath;
}
/**
* Inicia XStream con propiedades deseadas, para no mostrar datos innecesarios de las clases y asignarles alias a las clases para no mostrar las rutas completas de estas.
*
* @param xstream Instancia de XStream a modificar.
*/
public void setXStream(XStream xstream) {
xstream.alias("Actividad", Actividad.class);
xstream.alias("Anotacion", Anotacion.class);
xstream.alias("Apoderado", Apoderado.class);
xstream.alias("Asignatura", Asignatura.class);
xstream.alias("Asistencia", Asistencia.class);
xstream.alias("Colegio", Colegio.class);
xstream.alias("Curso", Curso.class);
xstream.alias("Estudiante", Estudiante.class);
xstream.alias("Nota", Nota.class);
xstream.alias("Profesor", Profesor.class);
xstream.omitField(Actividad.class, "id_pk");
xstream.omitField(Actividad.class, "_ormAdapter");
xstream.omitField(Anotacion.class, "id_pk");
xstream.omitField(Anotacion.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "id_pk");
xstream.omitField(Apoderado.class, "colegio_id_fk");
xstream.omitField(Apoderado.class, "ORM_estudiante");
xstream.omitField(Apoderado.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "estudiante");
xstream.omitField(Asignatura.class, "id_pk");
xstream.omitField(Asignatura.class, "_ormAdapter");
xstream.omitField(Asignatura.class, "ORM_actividad");
xstream.omitField(Asignatura.class, "ORM_nota");
xstream.omitField(Asignatura.class, "actividad");
xstream.omitField(Asignatura.class, "nota");
xstream.omitField(Asistencia.class, "id_pk");
xstream.omitField(Asistencia.class, "_ormAdapter");
xstream.omitField(Colegio.class, "id_pk");
xstream.omitField(Colegio.class, "_ormAdapter");
xstream.omitField(Colegio.class, "ORM_curso");
xstream.omitField(Colegio.class, "ORM_apoderado");
xstream.omitField(Colegio.class, "ORM_profesor");
xstream.omitField(Colegio.class, "curso");
xstream.omitField(Colegio.class, "apoderado");
xstream.omitField(Colegio.class, "profesor");
xstream.omitField(Curso.class, "id_pk");
xstream.omitField(Curso.class, "_ormAdapter");
xstream.omitField(Curso.class, "ORM_asignatura");
xstream.omitField(Curso.class, "ORM_estudiante");
xstream.omitField(Curso.class, "asignatura");
xstream.omitField(Curso.class, "estudiante");
xstream.omitField(Estudiante.class, "id_pk");
xstream.omitField(Estudiante.class, "_ormAdapter");
xstream.omitField(Estudiante.class, "ORM_anotacion");
xstream.omitField(Estudiante.class, "ORM_nota");
xstream.omitField(Estudiante.class, "ORM_asistencia");
xstream.omitField(Estudiante.class, "anotacion");
xstream.omitField(Estudiante.class, "nota");
xstream.omitField(Estudiante.class, "asistencia");
xstream.omitField(Nota.class, "id_pk");
xstream.omitField(Nota.class, "_ormAdapter");
xstream.omitField(Profesor.class, "id_pk");
xstream.omitField(Profesor.class, "_ormAdapter");
xstream.omitField(Profesor.class, "ORM_asignatura");
xstream.omitField(Profesor.class, "ORM_anotacion");
xstream.omitField(Profesor.class, "asignatura");
xstream.omitField(Profesor.class, "anotacion");
}
/**
* Genera el reporte de notas de los alumnos en la asignatura que imparte un profesor
*
* @param profesor El profesor del cual se quiere sacar la informacion.
*/
public void reporteNotasProfesor(File reportesPath, String html, String xlsx, String docx, Profesor profesor) {
XStream xstream = new XStream();
setXStream(xstream);
xstream.setMode(XStream.NO_REFERENCES);
ReporteNotasProfesor reporte = new ReporteNotasProfesor(profesor);
String xml = xstream.toXML(reporte);
String json = XML.toJSONObject(xml).toString();
try {
PrintWriter outXml = new PrintWriter(reportesPath.getPath() + "/" + profesor.getRut() + "-NotasProfesor.xml");
outXml.println(xml);
outXml.close();
PrintWriter outJson = new PrintWriter(reportesPath.getPath() + "/" + profesor.getRut() + "-NotasProfesor.json");
outJson.println(json);
outJson.close();
if(html!=null) {
XslTransformer.transform(
xslPath.getPath() + "/toHtmlNotasProfesor.xsl",
reportesPath.getPath() + "/" + profesor.getRut() + "-NotasProfesor.xml",
reportesPath.getPath() + "/" + html + ".html"
);
}
if(xlsx!=null) {
XslTransformer.transform(
xslPath.getPath() + "/toExcelNotasProfesor.xsl",
reportesPath.getPath() + "/" + profesor.getRut() + "-NotasProfesor.xml",
reportesPath.getPath() + "/" + xlsx + ".xlsx"
);
}
if(docx!=null) {
XslTransformer.transform(
xslPath.getPath() + "/toWordNotasProfesor.xsl",
reportesPath.getPath() + "/" + profesor.getRut() + "-NotasProfesor.xml",
reportesPath.getPath() + "/" + docx + ".docx"
);
}
} catch (FileNotFoundException | TransformerException e) {
e.printStackTrace();
}
}
/**
* Genera el reporte de planificaciones de los alumnos de un apoderado
*
* @param apoderado Apoderado al cual pertence los estudiantes
*/
public void reportePlanificaciones(File reportesPath, String html, String xlsx, String docx, Apoderado apoderado) {
XStream xstream = new XStream();
setXStream(xstream);
xstream.setMode(XStream.NO_REFERENCES);
ReportePlanificaciones reporte = new ReportePlanificaciones(apoderado);
String xml = xstream.toXML(reporte);
String json = XML.toJSONObject(xml).toString();
try {
PrintWriter outXml = new PrintWriter(reportesPath.getPath() + "/" + apoderado.getRut() + "-Planificaciones.xml");
outXml.println(xml);
outXml.close();
PrintWriter outJson = new PrintWriter(reportesPath.getPath() + "/" + apoderado.getRut() + "-Planificaciones.json");
outJson.println(json);
outJson.close();
if(html!=null) {
XslTransformer.transform(
xslPath.getPath() + "/toHtmlPlanificaciones.xsl",
reportesPath.getPath() + "/" + apoderado.getRut() + "-Planificaciones.xml",
reportesPath.getPath() + "/" + html + ".html"
);
}
if(xlsx!=null) {
XslTransformer.transform(
xslPath.getPath() + "/toExcelPlanificaciones.xsl",
reportesPath.getPath() + "/" + apoderado.getRut() + "-Planificaciones.xml",
reportesPath.getPath() + "/" + xlsx + ".xlsx"
);
}
if(docx!=null) {
XslTransformer.transform(
xslPath.getPath() + "/toWordPlanificaciones.xsl",
reportesPath.getPath() + "/" + apoderado.getRut() + "-Planificaciones.xml",
reportesPath.getPath() + "/" + docx + ".docx"
);
}
} catch (FileNotFoundException | TransformerException e) {
e.printStackTrace();
}
}
/**
* Genera el reporte que muestra los alumnos que estan reprobando en el colegio
*/
public void reporteReprobado(File reportesPath, String html, String xlsx, String docx) {
XStream xstream = new XStream();
setXStream(xstream);
xstream.setMode(XStream.NO_REFERENCES);
ReporteReprobando reporte = new ReporteReprobando();
String xml = xstream.toXML(reporte);
String json = XML.toJSONObject(xml).toString();
try {
PrintWriter outXml = new PrintWriter(reportesPath.getPath() + "/reporteReprobado.xml");
outXml.println(xml);
outXml.close();
PrintWriter outJson = new PrintWriter(reportesPath.getPath() + "/reporteReprobado.json");
outJson.println(json);
outJson.close();
if(html!=null) {
XslTransformer.transform(
xslPath.getPath() + "/toHtmlReprobando.xsl",
reportesPath.getPath() + "/reporteReprobado.xml",
reportesPath.getPath() + "/"+html+".html"
);
}
if(xlsx!=null) {
XslTransformer.transform(
xslPath.getPath() + "/toExcelReprobando.xsl",
reportesPath.getPath() + "/reporteReprobado.xml",
reportesPath.getPath() + "/"+xlsx+".xlsx"
);
}
if(docx!=null) {
XslTransformer.transform(
xslPath.getPath() + "/toWordReprobando.xsl",
reportesPath.getPath() + "/reporteReprobado.xml",
reportesPath.getPath() + "/"+docx+".docx"
);
}
} catch (FileNotFoundException | TransformerException e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,199 @@
package logica.reportes;
import com.thoughtworks.xstream.XStream;
import logica.Search;
import logica.Utilities;
import org.json.XML;
import orm.*;
import javax.xml.transform.TransformerException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.HashMap;
/**
* Clase que almacena los datos de notas, planificaciones y anotaciones de los alumnos de un apoderado
*/
public class ReporteApoderado {
private HashMap<Estudiante, Nota[]> notas;
private HashMap<Estudiante, HashMap<Asignatura, Actividad[]>> planificaciones;
private HashMap<Estudiante, Anotacion[]> anotaciones;
private ReporteApoderado(Apoderado apoderado) {
notas = new HashMap<>();
planificaciones = new HashMap<>();
anotaciones = new HashMap<>();
Estudiante[] estudiantes = Search.buscarEstudiantes(apoderado);
if (estudiantes != null) {
for (Estudiante estudiante : estudiantes) {
notas.put(estudiante, Search.buscarNotas(estudiante));
anotaciones.put(estudiante, Search.buscarAnotaciones(estudiante));
Asignatura[] asignaturas = Search.buscarAsignaturas(estudiante.getCurso_id_fk());
if (asignaturas != null) {
for (Asignatura asignatura : asignaturas) {
if (planificaciones.containsKey(estudiante)) {
Actividad[] actividades = Search.buscarActividades(asignatura);
planificaciones.get(estudiante).put(asignatura, actividades);
} else {
HashMap<Asignatura, Actividad[]> temp = new HashMap<>();
Actividad[] actividades = Search.buscarActividades(asignatura);
temp.put(asignatura, actividades);
planificaciones.put(estudiante, temp);
}
}
}
}
}
}
/**
* Guarda el reporte generado segun lo indicado en los boleanos entregados
*
* @param xslPath ruta en la cual se encuentran los xsl para la transformacion
* @param xml Si se guardara el xml
* @param json Si se guardara el json
* @param html Si se guardara el html
* @param xlsx Si se guardara el xlsx
* @param docx Si se guardara el docx
* @return un hashmap con los reportes generados en el
*/
public static HashMap<String, String> generar(File xslPath, boolean xml, boolean json, boolean html, boolean xlsx, boolean docx) {
HashMap<String, String> reportes = new HashMap<>();
XStream xstream = new XStream();
xstream.setMode(XStream.NO_REFERENCES);
setXStream(xstream);
HashMap<Apoderado, ReporteApoderado> reporte = new HashMap<>();
Apoderado[] apoderados = Search.buscarApoderados();
if (apoderados != null) {
for (Apoderado apoderado : apoderados) {
reporte.put(apoderado, new ReporteApoderado(apoderado));
}
}
String xmlResult = xstream.toXML(reporte);
try {
PrintWriter outXml = new PrintWriter("files/reportes/reporteApoderado/reporteGeneral.xml");
outXml.println(xmlResult);
outXml.close();
if (json) {
PrintWriter outJson = new PrintWriter("files/reportes/reporteApoderado/reporteGeneral.json");
String jsonResult = XML.toJSONObject(xmlResult).toString();
reportes.put("json",jsonResult);
outJson.println(jsonResult);
outJson.close();
}
if (html) {
XslTransformer.transform(
xslPath.getPath() + "/toHtmlReporteGeneral.xsl",
"files/reportes/reporteApoderado/reporteGeneral.xml",
"files/reportes/reporteApoderado/reporteGeneral.html"
);
reportes.put("html",Utilities.readFile("files/reportes/reporteApoderado/reporteGeneral.html"));
}
if (xlsx) {
XslTransformer.transform(
xslPath.getPath() + "/toExcelReporteGeneral.xsl",
"files/reportes/reporteApoderado/reporteGeneral.xml",
"files/reportes/reporteApoderado/reporteGeneral.xlsx"
);
reportes.put("xlsx",Utilities.readFile("files/reportes/reporteApoderado/reporteGeneral.xlsx"));
}
if (docx) {
XslTransformer.transform(
xslPath.getPath() + "/toWordReporteGeneral.xsl",
"files/reportes/reporteApoderado/reporteGeneral.xml",
"files/reportes/reporteApoderado/reporteGeneral.docx"
);
reportes.put("docx",Utilities.readFile("files/reportes/reporteApoderado/reporteGeneral.docx"));
}
if (!xml) {
File deleteFile = new File("files/reportes/reporteApoderado/reporteGeneral.xml");
deleteFile.delete();
} else {
reportes.put("xml",Utilities.readFile("files/reportes/reporteApoderado/reporteGeneral.xml"));
}
} catch (FileNotFoundException | TransformerException e) {
e.printStackTrace();
}
return reportes;
}
/**
* Inicia XStream con propiedades deseadas, para no mostrar datos innecesarios de las clases y asignarles alias a las clases para no mostrar las rutas completas de estas.
*
* @param xstream Instancia de XStream a modificar.
*/
public static void setXStream(XStream xstream) {
xstream.alias("Actividad", Actividad.class);
xstream.alias("Anotacion", Anotacion.class);
xstream.alias("Apoderado", Apoderado.class);
xstream.alias("Asignatura", Asignatura.class);
xstream.alias("Asistencia", Asistencia.class);
xstream.alias("Colegio", Colegio.class);
xstream.alias("Curso", Curso.class);
xstream.alias("Estudiante", Estudiante.class);
xstream.alias("Nota", Nota.class);
xstream.alias("Profesor", Profesor.class);
xstream.omitField(Actividad.class, "id_pk");
xstream.omitField(Actividad.class, "_ormAdapter");
xstream.omitField(Anotacion.class, "id_pk");
xstream.omitField(Anotacion.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "id_pk");
xstream.omitField(Apoderado.class, "colegio_id_fk");
xstream.omitField(Apoderado.class, "ORM_estudiante");
xstream.omitField(Apoderado.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "estudiante");
xstream.omitField(Asignatura.class, "id_pk");
xstream.omitField(Asignatura.class, "_ormAdapter");
xstream.omitField(Asignatura.class, "ORM_actividad");
xstream.omitField(Asignatura.class, "ORM_nota");
xstream.omitField(Asignatura.class, "actividad");
xstream.omitField(Asignatura.class, "nota");
xstream.omitField(Asistencia.class, "id_pk");
xstream.omitField(Asistencia.class, "_ormAdapter");
xstream.omitField(Colegio.class, "id_pk");
xstream.omitField(Colegio.class, "_ormAdapter");
xstream.omitField(Colegio.class, "ORM_curso");
xstream.omitField(Colegio.class, "ORM_apoderado");
xstream.omitField(Colegio.class, "ORM_profesor");
xstream.omitField(Colegio.class, "curso");
xstream.omitField(Colegio.class, "apoderado");
xstream.omitField(Colegio.class, "profesor");
xstream.omitField(Curso.class, "id_pk");
xstream.omitField(Curso.class, "_ormAdapter");
xstream.omitField(Curso.class, "ORM_asignatura");
xstream.omitField(Curso.class, "ORM_estudiante");
xstream.omitField(Curso.class, "asignatura");
xstream.omitField(Curso.class, "estudiante");
xstream.omitField(Estudiante.class, "id_pk");
xstream.omitField(Estudiante.class, "_ormAdapter");
xstream.omitField(Estudiante.class, "ORM_anotacion");
xstream.omitField(Estudiante.class, "ORM_nota");
xstream.omitField(Estudiante.class, "ORM_asistencia");
xstream.omitField(Estudiante.class, "anotacion");
xstream.omitField(Estudiante.class, "nota");
xstream.omitField(Estudiante.class, "asistencia");
xstream.omitField(Nota.class, "id_pk");
xstream.omitField(Nota.class, "_ormAdapter");
xstream.omitField(Profesor.class, "id_pk");
xstream.omitField(Profesor.class, "_ormAdapter");
xstream.omitField(Profesor.class, "ORM_asignatura");
xstream.omitField(Profesor.class, "ORM_anotacion");
xstream.omitField(Profesor.class, "asignatura");
xstream.omitField(Profesor.class, "anotacion");
}
}

View File

@@ -0,0 +1,192 @@
package logica.reportes;
import com.thoughtworks.xstream.XStream;
import logica.Search;
import logica.Utilities;
import org.json.XML;
import orm.*;
import javax.xml.transform.TransformerException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Clase que almacena a los apoderados con mas de un estudiante.
*/
public class ReporteApoderadosMasEstudiantes {
private HashMap<Apoderado, ArrayList<Estudiante>> apoderadosDuplicados;
/**
* Crea el objeto de reporte realizando la query para almacenar los apoderados con mas de un estudiante en un hashmap
*/
public ReporteApoderadosMasEstudiantes() {
apoderadosDuplicados = new HashMap<>();
HashMap<Apoderado, Estudiante> apoderados = new HashMap<>();
Curso[] cursos = Search.buscarCursos();
if (cursos != null) {
for (Curso c : cursos) {
Estudiante[] estudiantes = Search.buscarEstudiantes(c);
if (estudiantes != null) {
for (Estudiante e : estudiantes) {
if (apoderados.containsKey(e.getApoderado_id_fk())) {
if (apoderadosDuplicados.containsKey(e.getApoderado_id_fk())) {
apoderadosDuplicados.get(e.getApoderado_id_fk()).add(e);
} else {
ArrayList<Estudiante> temp = new ArrayList<>();
temp.add(apoderados.get(e.getApoderado_id_fk()));
temp.add(e);
apoderadosDuplicados.put(e.getApoderado_id_fk(), temp);
}
}
apoderados.put(e.getApoderado_id_fk(), e);
}
}
}
}
}
/**
* Genera los archivos del reporte, xml, json, html, xlsx o docx segun se indique a travez de transformaciones xls
*
* @param xslPath La carpeta en la que se encuentran los archivos xsl
* @param xml Si se guarda el archivo xml
* @param json Si se guarda el archivo json
* @param html Si se guarda el archivo html
* @param xlsx Si se guarda el archivo xlsx
* @param docx Si se guarda el archivo docx
*/
public HashMap<String, String> generar(File xslPath, boolean xml, boolean json, boolean html, boolean xlsx, boolean docx) {
HashMap<String, String> reportes = new HashMap<>();
XStream xstream = new XStream();
xstream.setMode(XStream.NO_REFERENCES);
setXStream(xstream);
String xmlResult = xstream.toXML(this);
String jsonResult = XML.toJSONObject(xmlResult).toString();
try {
PrintWriter outXml = new PrintWriter("files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.xml");
outXml.println(xmlResult);
outXml.close();
if (json) {
PrintWriter outJson = new PrintWriter("files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.json");
outJson.println(jsonResult);
outJson.close();
reportes.put("json", jsonResult);
}
if (html) {
XslTransformer.transform(
xslPath.getPath() + "/toHtmlApoderadosMasEstudiantes.xsl",
"files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.xml",
"files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.html"
);
reportes.put("html", Utilities.readFile("files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.html"));
}
if (xlsx) {
XslTransformer.transform(
xslPath.getPath() + "/toExcelApoderadosMasEstudiantes.xsl",
"files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.xml",
"files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.xlsx"
);
reportes.put("xlsx", Utilities.readFile("files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.xlsx"));
}
if (docx) {
XslTransformer.transform(
xslPath.getPath() + "/toWordApoderadosMasEstudiantes.xsl",
"files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.xml",
"files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.docx"
);
reportes.put("docx", Utilities.readFile("files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.docx"));
}
if (!xml) {
File deleteFile = new File("files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.xml");
deleteFile.delete();
} else {
reportes.put("xml", xmlResult);
}
} catch (FileNotFoundException | TransformerException e) {
e.printStackTrace();
}
return reportes;
}
/**
* Inicia XStream con propiedades deseadas, para no mostrar datos innecesarios de las clases y asignarles alias a las clases para no mostrar las rutas completas de estas.
*
* @param xstream Instancia de XStream a modificar.
*/
public void setXStream(XStream xstream) {
xstream.alias("Actividad", Actividad.class);
xstream.alias("Anotacion", Anotacion.class);
xstream.alias("Apoderado", Apoderado.class);
xstream.alias("Asignatura", Asignatura.class);
xstream.alias("Asistencia", Asistencia.class);
xstream.alias("Colegio", Colegio.class);
xstream.alias("Curso", Curso.class);
xstream.alias("Estudiante", Estudiante.class);
xstream.alias("Nota", Nota.class);
xstream.alias("Profesor", Profesor.class);
xstream.omitField(Actividad.class, "id_pk");
xstream.omitField(Actividad.class, "_ormAdapter");
xstream.omitField(Anotacion.class, "id_pk");
xstream.omitField(Anotacion.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "id_pk");
xstream.omitField(Apoderado.class, "colegio_id_fk");
xstream.omitField(Apoderado.class, "ORM_estudiante");
xstream.omitField(Apoderado.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "estudiante");
xstream.omitField(Asignatura.class, "id_pk");
xstream.omitField(Asignatura.class, "_ormAdapter");
xstream.omitField(Asignatura.class, "ORM_actividad");
xstream.omitField(Asignatura.class, "ORM_nota");
xstream.omitField(Asignatura.class, "actividad");
xstream.omitField(Asignatura.class, "nota");
xstream.omitField(Asistencia.class, "id_pk");
xstream.omitField(Asistencia.class, "_ormAdapter");
xstream.omitField(Colegio.class, "id_pk");
xstream.omitField(Colegio.class, "_ormAdapter");
xstream.omitField(Colegio.class, "ORM_curso");
xstream.omitField(Colegio.class, "ORM_apoderado");
xstream.omitField(Colegio.class, "ORM_profesor");
xstream.omitField(Colegio.class, "curso");
xstream.omitField(Colegio.class, "apoderado");
xstream.omitField(Colegio.class, "profesor");
xstream.omitField(Curso.class, "id_pk");
xstream.omitField(Curso.class, "_ormAdapter");
xstream.omitField(Curso.class, "ORM_asignatura");
xstream.omitField(Curso.class, "ORM_estudiante");
xstream.omitField(Curso.class, "asignatura");
xstream.omitField(Curso.class, "estudiante");
xstream.omitField(Estudiante.class, "id_pk");
xstream.omitField(Estudiante.class, "_ormAdapter");
xstream.omitField(Estudiante.class, "ORM_anotacion");
xstream.omitField(Estudiante.class, "ORM_nota");
xstream.omitField(Estudiante.class, "ORM_asistencia");
xstream.omitField(Estudiante.class, "anotacion");
xstream.omitField(Estudiante.class, "nota");
xstream.omitField(Estudiante.class, "asistencia");
xstream.omitField(Nota.class, "id_pk");
xstream.omitField(Nota.class, "_ormAdapter");
xstream.omitField(Profesor.class, "id_pk");
xstream.omitField(Profesor.class, "_ormAdapter");
xstream.omitField(Profesor.class, "ORM_asignatura");
xstream.omitField(Profesor.class, "ORM_anotacion");
xstream.omitField(Profesor.class, "asignatura");
xstream.omitField(Profesor.class, "anotacion");
}
}

View File

@@ -0,0 +1,198 @@
package logica.reportes;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.extended.NamedMapConverter;
import logica.Search;
import logica.Utilities;
import org.json.XML;
import orm.*;
import javax.xml.transform.TransformerException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.HashMap;
/**
* Clase que almacena los datos de los estudiantes con una asistencia bajo un %X
*/
public class ReporteAsistenciaBajo {
private HashMap<Estudiante, Integer> map;
/**
* Crea el reporte e inicia sus variables
* @param porcentaje Porcentaje minimo para considerar que un estudiante no tiene baja asistencia.
*/
public ReporteAsistenciaBajo(int porcentaje) {
map = new HashMap<>();
Curso[] cursos = Search.buscarCursos();
if (cursos != null) {
for (Curso curso : cursos) {
Estudiante[] estudiantes = Search.buscarEstudiantes(curso);
if (estudiantes != null) {
for (Estudiante estudiante : estudiantes) {
Asistencia[] asistenciaList = Search.buscarAsistencias(estudiante);
float counterTotal = 0.0f, counterAsistio = 0.0f;
if (asistenciaList != null) {
for (Asistencia a : asistenciaList) {
counterTotal++;
if (a.getAsistio()) counterAsistio++;
}
}
int porcentajeAsistencia = (int) Math.floor(counterAsistio / counterTotal * 100);
if (porcentajeAsistencia <= porcentaje) {
map.put(estudiante, porcentajeAsistencia);
}
}
}
}
}
}
/**
* Guarda el reporte generado segun lo indicado en los boleanos entregados
*
* @param xslPath ruta en la cual se encuentran los xsl para la transformacion
* @param xml Si se guardara el xml
* @param json Si se guardara el json
* @param html Si se guardara el html
* @param xlsx Si se guardara el xlsx
* @param docx Si se guardara el docx
* @return un hashmap con los reportes generados en el
*/
public HashMap<String, String> generar(File xslPath, boolean xml, boolean json, boolean html, boolean xlsx, boolean docx) {
HashMap<String, String> reporte = new HashMap<>();
XStream xstream = new XStream();
setXStream(xstream);
xstream.setMode(XStream.NO_REFERENCES);
NamedMapConverter namedMapConverter = new NamedMapConverter(
xstream.getMapper(), "Atribute", "Estudiante", Estudiante.class, "PorcentajeAsistencia", Integer.class);
xstream.registerConverter(namedMapConverter);
String xmlResult = xstream.toXML(this);
String jsonResult = XML.toJSONObject(xmlResult).toString();
try {
PrintWriter outXml = new PrintWriter("files/reportes/reporteBajaAsistencia/reporteAsistenciaBajo.xml");
outXml.println(xmlResult);
outXml.close();
if(json){
PrintWriter outJson = new PrintWriter("files/reportes/reporteBajaAsistencia/reporteAsistenciaBajo.json");
outJson.println(jsonResult);
reporte.put("json",jsonResult);
outJson.close();
}
if (html) {
XslTransformer.transform(
xslPath.getPath() + "/toHtmlAsistenciaBaja.xsl",
"files/reportes/reporteBajaAsistencia/reporteAsistenciaBajo.xml",
"files/reportes/reporteBajaAsistencia/reporteAsistenciaBajo.html"
);
reporte.put("html",Utilities.readFile("files/reportes/reporteBajaAsistencia/reporteAsistenciaBajo.html"));
}
if (xlsx) {
XslTransformer.transform(
xslPath.getPath() + "/toExcelAsistenciaBaja.xsl",
"files/reportes/reporteBajaAsistencia/reporteAsistenciaBajo.xml",
"files/reportes/reporteBajaAsistencia/reporteAsistenciaBajo.xlsx"
);
reporte.put("xlxs",Utilities.readFile("files/reportes/reporteBajaAsistencia/reporteAsistenciaBajo.xlsx"));
}
if (docx) {
XslTransformer.transform(
xslPath.getPath() + "/toWordAsistenciaBaja.xsl",
"files/reportes/reporteBajaAsistencia/reporteAsistenciaBajo.xml",
"files/reportes/reporteBajaAsistencia/reportesAsistenciaBajo.docx"
);
reporte.put("docx",Utilities.readFile("files/reportes/reporteBajaAsistencia/reportesAsistenciaBajo.docx"));
}
if(!xml){
File deleteFile = new File("files/reportes/reporteBajaAsistencia/reporteAsistenciaBajo.xml");
deleteFile.delete();
}else{
reporte.put("xml",xmlResult);
}
} catch (FileNotFoundException | TransformerException e) {
e.printStackTrace();
}
return reporte;
}
/**
* Inicia XStream con propiedades deseadas, para no mostrar datos innecesarios de las clases y asignarles alias a las clases para no mostrar las rutas completas de estas.
*
* @param xstream Instancia de XStream a modificar.
*/
public void setXStream(XStream xstream) {
xstream.alias("Actividad", Actividad.class);
xstream.alias("Anotacion", Anotacion.class);
xstream.alias("Apoderado", Apoderado.class);
xstream.alias("Asignatura", Asignatura.class);
xstream.alias("Asistencia", Asistencia.class);
xstream.alias("Colegio", Colegio.class);
xstream.alias("Curso", Curso.class);
xstream.alias("Estudiante", Estudiante.class);
xstream.alias("Nota", Nota.class);
xstream.alias("Profesor", Profesor.class);
xstream.omitField(Actividad.class, "id_pk");
xstream.omitField(Actividad.class, "_ormAdapter");
xstream.omitField(Anotacion.class, "id_pk");
xstream.omitField(Anotacion.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "id_pk");
xstream.omitField(Apoderado.class, "colegio_id_fk");
xstream.omitField(Apoderado.class, "ORM_estudiante");
xstream.omitField(Apoderado.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "estudiante");
xstream.omitField(Asignatura.class, "id_pk");
xstream.omitField(Asignatura.class, "_ormAdapter");
xstream.omitField(Asignatura.class, "ORM_actividad");
xstream.omitField(Asignatura.class, "ORM_nota");
xstream.omitField(Asignatura.class, "actividad");
xstream.omitField(Asignatura.class, "nota");
xstream.omitField(Asistencia.class, "id_pk");
xstream.omitField(Asistencia.class, "_ormAdapter");
xstream.omitField(Colegio.class, "id_pk");
xstream.omitField(Colegio.class, "_ormAdapter");
xstream.omitField(Colegio.class, "ORM_curso");
xstream.omitField(Colegio.class, "ORM_apoderado");
xstream.omitField(Colegio.class, "ORM_profesor");
xstream.omitField(Colegio.class, "curso");
xstream.omitField(Colegio.class, "apoderado");
xstream.omitField(Colegio.class, "profesor");
xstream.omitField(Curso.class, "id_pk");
xstream.omitField(Curso.class, "_ormAdapter");
xstream.omitField(Curso.class, "ORM_asignatura");
xstream.omitField(Curso.class, "ORM_estudiante");
xstream.omitField(Curso.class, "asignatura");
xstream.omitField(Curso.class, "estudiante");
xstream.omitField(Estudiante.class, "id_pk");
xstream.omitField(Estudiante.class, "_ormAdapter");
xstream.omitField(Estudiante.class, "ORM_anotacion");
xstream.omitField(Estudiante.class, "ORM_nota");
xstream.omitField(Estudiante.class, "ORM_asistencia");
xstream.omitField(Estudiante.class, "anotacion");
xstream.omitField(Estudiante.class, "nota");
xstream.omitField(Estudiante.class, "asistencia");
xstream.omitField(Nota.class, "id_pk");
xstream.omitField(Nota.class, "_ormAdapter");
xstream.omitField(Profesor.class, "id_pk");
xstream.omitField(Profesor.class, "_ormAdapter");
xstream.omitField(Profesor.class, "ORM_asignatura");
xstream.omitField(Profesor.class, "ORM_anotacion");
xstream.omitField(Profesor.class, "asignatura");
xstream.omitField(Profesor.class, "anotacion");
}
}

View File

@@ -0,0 +1,190 @@
package logica.reportes;
import com.thoughtworks.xstream.XStream;
import logica.Search;
import logica.Utilities;
import org.json.XML;
import orm.*;
import javax.xml.transform.TransformerException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Clase que almancena la lista de asistencia y la lista de notas por asignatura de un alumno
*/
public class ReporteAsistenciaYNotas {
private Estudiante estudiante;
private Asistencia[] asistencia;
private HashMap<Asignatura, ArrayList<Nota>> notas;
private float porcentajeAsistencia;
public ReporteAsistenciaYNotas(Estudiante estudiante) {
this.estudiante = estudiante;
notas = new HashMap<>();
asistencia = Search.buscarAsistencias(estudiante);
float counterTotal = 0, counterAsistio = 0;
if (asistencia != null) {
for (Asistencia a : asistencia) {
counterTotal++;
if (a.getAsistio()) counterAsistio++;
}
}
porcentajeAsistencia = (float) Math.floor(counterAsistio / counterTotal * 100);
Nota[] notasList = Search.buscarNotas(estudiante);
if (notasList != null) {
for (Nota nota : notasList) {
ArrayList<Nota> notaArray = new ArrayList<>();
if (notas.containsKey(nota.getAsignatura_id_fk())) {
notas.get(nota.getAsignatura_id_fk()).add(nota);
} else {
notaArray.add(nota);
notas.put(nota.getAsignatura_id_fk(), notaArray);
}
}
}
}
/**
* Genera los archivos del reporte segun sea indicado
* @param xslPath La ruta de los archivos xsl
* @param xml Si se guardara el xml
* @param json Si se guardara el json
* @param html Si se guardara el html
* @param xlsx Si se guardara el xlsx
* @param docx Si se guardara el docx
* @return Un hashmap con los reportes.
*/
public HashMap<String, String> generar(File xslPath, boolean xml, boolean json, boolean html, boolean xlsx, boolean docx) {
HashMap<String, String> reporte = new HashMap<>();
XStream xstream = new XStream();
setXStream(xstream);
xstream.setMode(XStream.NO_REFERENCES);
String xmlResult = xstream.toXML(this);
try {
PrintWriter outXml = new PrintWriter( "files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.xml");
outXml.println(xmlResult);
outXml.close();
if(json) {
PrintWriter outJson = new PrintWriter("files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.json");
String jsonResult = XML.toJSONObject(xmlResult).toString();
reporte.put("json",jsonResult);
outJson.println(jsonResult);
outJson.close();
}
if (html) {
XslTransformer.transform(
xslPath.getPath() + "/toHtmlAsistenciaYNotas.xsl",
"files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.xml",
"files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.html"
);
reporte.put("html", Utilities.readFile("files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.html"));
}
if (xlsx) {
XslTransformer.transform(
xslPath.getPath() + "/toExcelAsistenciaYNotas.xsl",
"files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.xml",
"files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.xlsx"
);
reporte.put("xlsx", Utilities.readFile("files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.xlsx"));
}
if (docx) {
XslTransformer.transform(
xslPath.getPath() + "/toWordAsistenciaYNotas.xsl",
"files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.xml",
"files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.docx"
);
reporte.put("docx", Utilities.readFile("files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.docx"));
}
if(!xml){
File deleteFile = new File("files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.xml");
deleteFile.delete();
}else{
reporte.put("xml",xmlResult);
}
} catch (FileNotFoundException | TransformerException e) {
e.printStackTrace();
}
return reporte;
}
/**
* Inicia XStream con propiedades deseadas, para no mostrar datos innecesarios de las clases y asignarles alias a las clases para no mostrar las rutas completas de estas.
*
* @param xstream Instancia de XStream a modificar.
*/
public void setXStream(XStream xstream) {
xstream.alias("Actividad", Actividad.class);
xstream.alias("Anotacion", Anotacion.class);
xstream.alias("Apoderado", Apoderado.class);
xstream.alias("Asignatura", Asignatura.class);
xstream.alias("Asistencia", Asistencia.class);
xstream.alias("Colegio", Colegio.class);
xstream.alias("Curso", Curso.class);
xstream.alias("Estudiante", Estudiante.class);
xstream.alias("Nota", Nota.class);
xstream.alias("Profesor", Profesor.class);
xstream.omitField(Actividad.class, "id_pk");
xstream.omitField(Actividad.class, "_ormAdapter");
xstream.omitField(Anotacion.class, "id_pk");
xstream.omitField(Anotacion.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "id_pk");
xstream.omitField(Apoderado.class, "colegio_id_fk");
xstream.omitField(Apoderado.class, "ORM_estudiante");
xstream.omitField(Apoderado.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "estudiante");
xstream.omitField(Asignatura.class, "id_pk");
xstream.omitField(Asignatura.class, "_ormAdapter");
xstream.omitField(Asignatura.class, "ORM_actividad");
xstream.omitField(Asignatura.class, "ORM_nota");
xstream.omitField(Asignatura.class, "actividad");
xstream.omitField(Asignatura.class, "nota");
xstream.omitField(Asistencia.class, "id_pk");
xstream.omitField(Asistencia.class, "_ormAdapter");
xstream.omitField(Colegio.class, "id_pk");
xstream.omitField(Colegio.class, "_ormAdapter");
xstream.omitField(Colegio.class, "ORM_curso");
xstream.omitField(Colegio.class, "ORM_apoderado");
xstream.omitField(Colegio.class, "ORM_profesor");
xstream.omitField(Colegio.class, "curso");
xstream.omitField(Colegio.class, "apoderado");
xstream.omitField(Colegio.class, "profesor");
xstream.omitField(Curso.class, "id_pk");
xstream.omitField(Curso.class, "_ormAdapter");
xstream.omitField(Curso.class, "ORM_asignatura");
xstream.omitField(Curso.class, "ORM_estudiante");
xstream.omitField(Curso.class, "asignatura");
xstream.omitField(Curso.class, "estudiante");
xstream.omitField(Estudiante.class, "id_pk");
xstream.omitField(Estudiante.class, "_ormAdapter");
xstream.omitField(Estudiante.class, "ORM_anotacion");
xstream.omitField(Estudiante.class, "ORM_nota");
xstream.omitField(Estudiante.class, "ORM_asistencia");
xstream.omitField(Estudiante.class, "anotacion");
xstream.omitField(Estudiante.class, "nota");
xstream.omitField(Estudiante.class, "asistencia");
xstream.omitField(Nota.class, "id_pk");
xstream.omitField(Nota.class, "_ormAdapter");
xstream.omitField(Profesor.class, "id_pk");
xstream.omitField(Profesor.class, "_ormAdapter");
xstream.omitField(Profesor.class, "ORM_asignatura");
xstream.omitField(Profesor.class, "ORM_anotacion");
xstream.omitField(Profesor.class, "asignatura");
xstream.omitField(Profesor.class, "anotacion");
}
}

View File

@@ -0,0 +1,207 @@
package logica.reportes;
import com.thoughtworks.xstream.XStream;
import logica.Search;
import logica.Utilities;
import org.json.XML;
import orm.*;
import javax.xml.transform.TransformerException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Clase que almacena las notas por cada estudiante al cual un profesor le da clases.
*/
public class ReporteNotasProfesor {
private HashMap<Estudiante, ArrayList<Nota>> lista;
private Profesor profesor;
/**
* Crea el reporte de las notas ingresadas en la asignatura de un profesor
*
* @param profesor Profesor al que le pertencen las asignaturas.
*/
public ReporteNotasProfesor(Profesor profesor) {
lista = new HashMap<>();
this.profesor = profesor;
Curso[] cursos = Search.buscarCursos();
if (cursos != null) {
for (Curso c : cursos) {
Asignatura[] asignaturas = Search.buscarAsignaturas(c);
if (asignaturas != null) {
for (Asignatura asignatura : asignaturas) {
if (asignatura.getProfesor_id_fk().equals(profesor)) {
Estudiante[] estudiantes = Search.buscarEstudiantes(c);
if (estudiantes != null) {
for (Estudiante estudiante : estudiantes) {
Nota[] notas = Search.buscarNotas(estudiante);
if (notas != null) {
for (Nota nota : notas) {
if (nota.getAsignatura_id_fk().equals(asignatura)) {
if (lista.containsKey(estudiante)) {
lista.get(estudiante).add(nota);
} else {
ArrayList<Nota> temp = new ArrayList<>();
temp.add(nota);
lista.put(estudiante, temp);
}
}
}
}
}
}
}
}
}
}
}
}
/**
* Guarda el reporte generado segun lo indicado en los boleanos entregados
*
* @param xslPath ruta en la cual se encuentran los xsl para la transformacion
* @param xml Si se guardara el xml
* @param json Si se guardara el json
* @param html Si se guardara el html
* @param xlsx Si se guardara el xlsx
* @param docx Si se guardara el docx
* @return un hashmap con los reportes generados en el
*/
public HashMap<String, String> generar(File xslPath, boolean xml, boolean json, boolean html, boolean xlsx, boolean docx) {
HashMap<String, String> reporte = new HashMap<>();
XStream xstream = new XStream();
setXStream(xstream);
xstream.setMode(XStream.NO_REFERENCES);
String xmlResult = xstream.toXML(this);
String jsonResult = XML.toJSONObject(xmlResult).toString();
try {
PrintWriter outXml = new PrintWriter("files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.xml");
outXml.println(xmlResult);
outXml.close();
if (json) {
PrintWriter outJson = new PrintWriter("files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.json");
outJson.println(jsonResult);
outJson.close();
reporte.put("json", jsonResult);
}
if (html) {
XslTransformer.transform(
xslPath.getPath() + "/toHtmlNotasProfesor.xsl",
"files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.xml",
"files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.html"
);
reporte.put("html", Utilities.readFile("files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.html"));
}
if (xlsx) {
XslTransformer.transform(
xslPath.getPath() + "/toExcelNotasProfesor.xsl",
"files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.xml",
"files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.xlsx"
);
reporte.put("xslx", Utilities.readFile("files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.xlsx"));
}
if (docx) {
XslTransformer.transform(
xslPath.getPath() + "/toWordNotasProfesor.xsl",
"files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.xml",
"files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.docx"
);
reporte.put("docx", Utilities.readFile("files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.docx"));
}
if (!xml) {
File deleteFile = new File("files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.xml");
deleteFile.delete();
} else {
reporte.put("xml", xmlResult);
}
} catch (FileNotFoundException | TransformerException e) {
e.printStackTrace();
}
return reporte;
}
/**
* Inicia XStream con propiedades deseadas, para no mostrar datos innecesarios de las clases y asignarles alias a las clases para no mostrar las rutas completas de estas.
*
* @param xstream Instancia de XStream a modificar.
*/
public void setXStream(XStream xstream) {
xstream.alias("Actividad", Actividad.class);
xstream.alias("Anotacion", Anotacion.class);
xstream.alias("Apoderado", Apoderado.class);
xstream.alias("Asignatura", Asignatura.class);
xstream.alias("Asistencia", Asistencia.class);
xstream.alias("Colegio", Colegio.class);
xstream.alias("Curso", Curso.class);
xstream.alias("Estudiante", Estudiante.class);
xstream.alias("Nota", Nota.class);
xstream.alias("Profesor", Profesor.class);
xstream.omitField(Actividad.class, "id_pk");
xstream.omitField(Actividad.class, "_ormAdapter");
xstream.omitField(Anotacion.class, "id_pk");
xstream.omitField(Anotacion.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "id_pk");
xstream.omitField(Apoderado.class, "colegio_id_fk");
xstream.omitField(Apoderado.class, "ORM_estudiante");
xstream.omitField(Apoderado.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "estudiante");
xstream.omitField(Asignatura.class, "id_pk");
xstream.omitField(Asignatura.class, "_ormAdapter");
xstream.omitField(Asignatura.class, "ORM_actividad");
xstream.omitField(Asignatura.class, "ORM_nota");
xstream.omitField(Asignatura.class, "actividad");
xstream.omitField(Asignatura.class, "nota");
xstream.omitField(Asistencia.class, "id_pk");
xstream.omitField(Asistencia.class, "_ormAdapter");
xstream.omitField(Colegio.class, "id_pk");
xstream.omitField(Colegio.class, "_ormAdapter");
xstream.omitField(Colegio.class, "ORM_curso");
xstream.omitField(Colegio.class, "ORM_apoderado");
xstream.omitField(Colegio.class, "ORM_profesor");
xstream.omitField(Colegio.class, "curso");
xstream.omitField(Colegio.class, "apoderado");
xstream.omitField(Colegio.class, "profesor");
xstream.omitField(Curso.class, "id_pk");
xstream.omitField(Curso.class, "_ormAdapter");
xstream.omitField(Curso.class, "ORM_asignatura");
xstream.omitField(Curso.class, "ORM_estudiante");
xstream.omitField(Curso.class, "asignatura");
xstream.omitField(Curso.class, "estudiante");
xstream.omitField(Estudiante.class, "id_pk");
xstream.omitField(Estudiante.class, "_ormAdapter");
xstream.omitField(Estudiante.class, "ORM_anotacion");
xstream.omitField(Estudiante.class, "ORM_nota");
xstream.omitField(Estudiante.class, "ORM_asistencia");
xstream.omitField(Estudiante.class, "anotacion");
xstream.omitField(Estudiante.class, "nota");
xstream.omitField(Estudiante.class, "asistencia");
xstream.omitField(Nota.class, "id_pk");
xstream.omitField(Nota.class, "_ormAdapter");
xstream.omitField(Profesor.class, "id_pk");
xstream.omitField(Profesor.class, "_ormAdapter");
xstream.omitField(Profesor.class, "ORM_asignatura");
xstream.omitField(Profesor.class, "ORM_anotacion");
xstream.omitField(Profesor.class, "asignatura");
xstream.omitField(Profesor.class, "anotacion");
xstream.omitField(ReporteNotasProfesor.class, "profesor");
}
}

View File

@@ -0,0 +1,194 @@
package logica.reportes;
import com.thoughtworks.xstream.XStream;
import logica.Search;
import logica.Utilities;
import org.json.XML;
import orm.*;
import javax.xml.transform.TransformerException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.HashMap;
/**
* Clase que almancena las planificaciones de los pupilos de un apoderado
*/
public class ReportePlanificaciones {
private HashMap<Estudiante, HashMap<Asignatura, Actividad[]>> planificaciones;
private Apoderado apoderado;
public ReportePlanificaciones(Apoderado apoderado) {
this.apoderado = apoderado;
planificaciones = new HashMap<>();
Curso[] cursos = Search.buscarCursos();
if (cursos != null) {
for (Curso c : cursos) {
Estudiante[] estudiantes = Search.buscarEstudiantes(c);
if (estudiantes != null) {
for (Estudiante e : estudiantes) {
if (e.getApoderado_id_fk().equals(apoderado)) {
HashMap<Asignatura, Actividad[]> map = new HashMap<>();
Asignatura[] asignaturas = Search.buscarAsignaturas(c);
if (asignaturas != null) {
for (Asignatura asignatura : asignaturas) {
Actividad[] actividades = Search.buscarActividades(asignatura);
map.put(asignatura, actividades);
}
}
planificaciones.put(e, map);
}
}
}
}
}
}
/**
* Guarda el reporte generado segun lo indicado en los boleanos entregados
*
* @param xslPath ruta en la cual se encuentran los xsl para la transformacion
* @param xml Si se guardara el xml
* @param json Si se guardara el json
* @param html Si se guardara el html
* @param xlsx Si se guardara el xlsx
* @param docx Si se guardara el docx
* @return un hashmap con los reportes generados en el
*/
public HashMap<String, String> generar(File xslPath, boolean xml, boolean json, boolean html, boolean xlsx, boolean docx) {
HashMap<String, String> reporte = new HashMap<>();
XStream xstream = new XStream();
setXStream(xstream);
xstream.setMode(XStream.NO_REFERENCES);
String xmlResult = xstream.toXML(this);
try {
PrintWriter outXml = new PrintWriter("files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.xml");
outXml.println(xmlResult);
outXml.close();
if(json){
PrintWriter outJson = new PrintWriter("files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.json");
String jsonResult = XML.toJSONObject(xmlResult).toString();
outJson.println(jsonResult);
outJson.close();
reporte.put("json", Utilities.readFile("files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.json"));
}
if (html) {
XslTransformer.transform(
xslPath.getPath() + "/toHtmlPlanificaciones.xsl",
"files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.xml",
"files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.html"
);
reporte.put("html", Utilities.readFile("files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.html"));
}
if (xlsx) {
XslTransformer.transform(
xslPath.getPath() + "/toExcelPlanificaciones.xsl",
"files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.xml",
"files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.xlsx"
);
reporte.put("xlsx", Utilities.readFile("files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.xlsx"));
}
if (docx) {
XslTransformer.transform(
xslPath.getPath() + "/toWordPlanificaciones.xsl",
"files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.xml",
"files/reportes/reportePlanificaciones/"+ apoderado.getRut() + "-Planificaciones.docx"
);
reporte.put("docx", Utilities.readFile("files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.docx"));
}
if(!xml){
File deleteFile = new File("files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.xml");
deleteFile.delete();
}else{
reporte.put("xml",xmlResult);
}
} catch (FileNotFoundException | TransformerException e) {
e.printStackTrace();
}
return reporte;
}
/**
* Inicia XStream con propiedades deseadas, para no mostrar datos innecesarios de las clases y asignarles alias a las clases para no mostrar las rutas completas de estas.
*
* @param xstream Instancia de XStream a modificar.
*/
public void setXStream(XStream xstream) {
xstream.alias("Actividad", Actividad.class);
xstream.alias("Anotacion", Anotacion.class);
xstream.alias("Apoderado", Apoderado.class);
xstream.alias("Asignatura", Asignatura.class);
xstream.alias("Asistencia", Asistencia.class);
xstream.alias("Colegio", Colegio.class);
xstream.alias("Curso", Curso.class);
xstream.alias("Estudiante", Estudiante.class);
xstream.alias("Nota", Nota.class);
xstream.alias("Profesor", Profesor.class);
xstream.omitField(Actividad.class, "id_pk");
xstream.omitField(Actividad.class, "_ormAdapter");
xstream.omitField(Anotacion.class, "id_pk");
xstream.omitField(Anotacion.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "id_pk");
xstream.omitField(Apoderado.class, "colegio_id_fk");
xstream.omitField(Apoderado.class, "ORM_estudiante");
xstream.omitField(Apoderado.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "estudiante");
xstream.omitField(Asignatura.class, "id_pk");
xstream.omitField(Asignatura.class, "_ormAdapter");
xstream.omitField(Asignatura.class, "ORM_actividad");
xstream.omitField(Asignatura.class, "ORM_nota");
xstream.omitField(Asignatura.class, "actividad");
xstream.omitField(Asignatura.class, "nota");
xstream.omitField(Asistencia.class, "id_pk");
xstream.omitField(Asistencia.class, "_ormAdapter");
xstream.omitField(Colegio.class, "id_pk");
xstream.omitField(Colegio.class, "_ormAdapter");
xstream.omitField(Colegio.class, "ORM_curso");
xstream.omitField(Colegio.class, "ORM_apoderado");
xstream.omitField(Colegio.class, "ORM_profesor");
xstream.omitField(Colegio.class, "curso");
xstream.omitField(Colegio.class, "apoderado");
xstream.omitField(Colegio.class, "profesor");
xstream.omitField(Curso.class, "id_pk");
xstream.omitField(Curso.class, "_ormAdapter");
xstream.omitField(Curso.class, "ORM_asignatura");
xstream.omitField(Curso.class, "ORM_estudiante");
xstream.omitField(Curso.class, "asignatura");
xstream.omitField(Curso.class, "estudiante");
xstream.omitField(Estudiante.class, "id_pk");
xstream.omitField(Estudiante.class, "_ormAdapter");
xstream.omitField(Estudiante.class, "ORM_anotacion");
xstream.omitField(Estudiante.class, "ORM_nota");
xstream.omitField(Estudiante.class, "ORM_asistencia");
xstream.omitField(Estudiante.class, "anotacion");
xstream.omitField(Estudiante.class, "nota");
xstream.omitField(Estudiante.class, "asistencia");
xstream.omitField(Nota.class, "id_pk");
xstream.omitField(Nota.class, "_ormAdapter");
xstream.omitField(Profesor.class, "id_pk");
xstream.omitField(Profesor.class, "_ormAdapter");
xstream.omitField(Profesor.class, "ORM_asignatura");
xstream.omitField(Profesor.class, "ORM_anotacion");
xstream.omitField(Profesor.class, "asignatura");
xstream.omitField(Profesor.class, "anotacion");
xstream.omitField(ReportePlanificaciones.class, "apoderado");
}
}

View File

@@ -0,0 +1,190 @@
package logica.reportes;
import com.thoughtworks.xstream.XStream;
import logica.Search;
import logica.Utilities;
import org.json.XML;
import orm.*;
import javax.xml.transform.TransformerException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.HashMap;
/**
* Clase que almacena los estudiantes que estan reprobando en el sistema.
*/
public class ReporteReprobando {
private HashMap<Estudiante, Float> estudiantesRepobando;
public ReporteReprobando() {
estudiantesRepobando = new HashMap<>();
Curso[] cursos = Search.buscarCursos();
if (cursos != null) {
for (Curso curso : cursos) {
Estudiante[] estudiantes = Search.buscarEstudiantes(curso);
if (estudiantes != null) {
for (Estudiante estudiante : estudiantes) {
float promedio = 0;
Nota[] notas = Search.buscarNotas(estudiante);
if (notas != null) {
for (Nota nota : notas) {
promedio += nota.getValor();
}
promedio /= notas.length;
}
promedio = Math.round(promedio * 10.0f) / 10.0f;
if (promedio < 4) {
estudiantesRepobando.put(estudiante, promedio);
}
}
}
}
}
}
/**
* Guarda el reporte generado segun lo indicado en los boleanos entregados
*
* @param xslPath ruta en la cual se encuentran los xsl para la transformacion
* @param xml Si se guardara el xml
* @param json Si se guardara el json
* @param html Si se guardara el html
* @param xlsx Si se guardara el xlsx
* @param docx Si se guardara el docx
* @return un hashmap con los reportes generados en el
*/
public HashMap<String, String> generar(File xslPath, boolean xml, boolean json, boolean html, boolean xlsx, boolean docx) {
HashMap<String, String> reporte = new HashMap<>();
XStream xstream = new XStream();
setXStream(xstream);
xstream.setMode(XStream.NO_REFERENCES);
String xmlResult = xstream.toXML(this);
try {
PrintWriter outXml = new PrintWriter("files/reportes/reporteReprobando/reporteReprobado.xml");
outXml.println(xmlResult);
outXml.close();
if(json) {
PrintWriter outJson = new PrintWriter("files/reportes/reporteReprobando/reporteReprobado.json");
String jsonResult = XML.toJSONObject(xmlResult).toString();
outJson.println(jsonResult);
outJson.close();
reporte.put("json", jsonResult);
}
if(html) {
XslTransformer.transform(
xslPath.getPath() + "/toHtmlReprobando.xsl",
"files/reportes/reporteReprobando/reporteReprobado.xml",
"files/reportes/reporteReprobando/reporteReprobando.html"
);
reporte.put("html", Utilities.readFile("files/reportes/reporteReprobando/reporteReprobando.html"));
}
if(xlsx) {
XslTransformer.transform(
xslPath.getPath() + "/toExcelReprobando.xsl",
"files/reportes/reporteReprobando/reporteReprobado.xml",
"files/reportes/reporteReprobando/reporteReprobando.xlsx"
);
reporte.put("xlsx", Utilities.readFile("files/reportes/reporteReprobando/reporteReprobando.xlsx"));
}
if(docx) {
XslTransformer.transform(
xslPath.getPath() + "/toWordReprobando.xsl",
"files/reportes/reporteReprobando/reporteReprobado.xml",
"files/reportes/reporteReprobando/reporteReprobando.docx"
);
reporte.put("docx", Utilities.readFile("files/reportes/reporteReprobando/reporteReprobando.docx"));
}
if(!xml){
File deleteFile = new File("files/reportes/reporteReprobando/reporteReprobando.xml");
deleteFile.delete();
}else{
reporte.put("xml",xmlResult);
}
} catch (FileNotFoundException | TransformerException e) {
e.printStackTrace();
}
return reporte;
}
/**
* Inicia XStream con propiedades deseadas, para no mostrar datos innecesarios de las clases y asignarles alias a las clases para no mostrar las rutas completas de estas.
*
* @param xstream Instancia de XStream a modificar.
*/
public void setXStream(XStream xstream) {
xstream.alias("Actividad", Actividad.class);
xstream.alias("Anotacion", Anotacion.class);
xstream.alias("Apoderado", Apoderado.class);
xstream.alias("Asignatura", Asignatura.class);
xstream.alias("Asistencia", Asistencia.class);
xstream.alias("Colegio", Colegio.class);
xstream.alias("Curso", Curso.class);
xstream.alias("Estudiante", Estudiante.class);
xstream.alias("Nota", Nota.class);
xstream.alias("Profesor", Profesor.class);
xstream.omitField(Actividad.class, "id_pk");
xstream.omitField(Actividad.class, "_ormAdapter");
xstream.omitField(Anotacion.class, "id_pk");
xstream.omitField(Anotacion.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "id_pk");
xstream.omitField(Apoderado.class, "colegio_id_fk");
xstream.omitField(Apoderado.class, "ORM_estudiante");
xstream.omitField(Apoderado.class, "_ormAdapter");
xstream.omitField(Apoderado.class, "estudiante");
xstream.omitField(Asignatura.class, "id_pk");
xstream.omitField(Asignatura.class, "_ormAdapter");
xstream.omitField(Asignatura.class, "ORM_actividad");
xstream.omitField(Asignatura.class, "ORM_nota");
xstream.omitField(Asignatura.class, "actividad");
xstream.omitField(Asignatura.class, "nota");
xstream.omitField(Asistencia.class, "id_pk");
xstream.omitField(Asistencia.class, "_ormAdapter");
xstream.omitField(Colegio.class, "id_pk");
xstream.omitField(Colegio.class, "_ormAdapter");
xstream.omitField(Colegio.class, "ORM_curso");
xstream.omitField(Colegio.class, "ORM_apoderado");
xstream.omitField(Colegio.class, "ORM_profesor");
xstream.omitField(Colegio.class, "curso");
xstream.omitField(Colegio.class, "apoderado");
xstream.omitField(Colegio.class, "profesor");
xstream.omitField(Curso.class, "id_pk");
xstream.omitField(Curso.class, "_ormAdapter");
xstream.omitField(Curso.class, "ORM_asignatura");
xstream.omitField(Curso.class, "ORM_estudiante");
xstream.omitField(Curso.class, "asignatura");
xstream.omitField(Curso.class, "estudiante");
xstream.omitField(Estudiante.class, "id_pk");
xstream.omitField(Estudiante.class, "_ormAdapter");
xstream.omitField(Estudiante.class, "ORM_anotacion");
xstream.omitField(Estudiante.class, "ORM_nota");
xstream.omitField(Estudiante.class, "ORM_asistencia");
xstream.omitField(Estudiante.class, "anotacion");
xstream.omitField(Estudiante.class, "nota");
xstream.omitField(Estudiante.class, "asistencia");
xstream.omitField(Nota.class, "id_pk");
xstream.omitField(Nota.class, "_ormAdapter");
xstream.omitField(Profesor.class, "id_pk");
xstream.omitField(Profesor.class, "_ormAdapter");
xstream.omitField(Profesor.class, "ORM_asignatura");
xstream.omitField(Profesor.class, "ORM_anotacion");
xstream.omitField(Profesor.class, "asignatura");
xstream.omitField(Profesor.class, "anotacion");
}
}

View File

@@ -0,0 +1,151 @@
package logica.reportes;
import logica.ExNihilo;
import logica.Search;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import orm.Apoderado;
import orm.Estudiante;
import orm.Profesor;
import java.io.File;
import java.util.HashMap;
import static org.junit.Assert.*;
public class ReportesTest {
@BeforeClass
public static void before() {
ExNihilo.deleteAll();
ExNihilo.fill();
}
@Test
public void reporteApoderado() {
HashMap<String, String> reportes = ReporteApoderado.generar(new File("files/xslt"), true, true, true, true, true);
assertNotNull(reportes);
assertEquals(5, reportes.size());
assertNotNull(reportes.get("xml"));
assertNotNull(reportes.get("json"));
assertNotNull(reportes.get("html"));
assertNotNull(reportes.get("xlsx"));
assertNotNull(reportes.get("docx"));
assertTrue(new File("files/reportes/reporteApoderado/reporteGeneral.xml").exists());
assertTrue(new File("files/reportes/reporteApoderado/reporteGeneral.json").exists());
assertTrue(new File("files/reportes/reporteApoderado/reporteGeneral.html").exists());
assertTrue(new File("files/reportes/reporteApoderado/reporteGeneral.xlsx").exists());
assertTrue(new File("files/reportes/reporteApoderado/reporteGeneral.docx").exists());
}
@Test
public void reporteApoderadoMasEstudiantes() {
ReporteApoderadosMasEstudiantes rame = new ReporteApoderadosMasEstudiantes();
HashMap<String, String> reportes = rame.generar(new File("files/xslt"), true, true, true, true, true);
assertNotNull(reportes);
assertEquals(5, reportes.size());
assertNotNull(reportes.get("xml"));
assertNotNull(reportes.get("json"));
assertNotNull(reportes.get("html"));
assertNotNull(reportes.get("xlsx"));
assertNotNull(reportes.get("docx"));
assertTrue(new File("files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.xml").exists());
assertTrue(new File("files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.json").exists());
assertTrue(new File("files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.html").exists());
assertTrue(new File("files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.xlsx").exists());
assertTrue(new File("files/reportes/reporteApoderadosMasEstudiantes/reporteApoderadosMasEstudiantes.docx").exists());
}
@Test
public void reporteAsistenciaBaja() {
ReporteAsistenciaBajo rab = new ReporteAsistenciaBajo(100);
HashMap<String, String> reportes = rab.generar(new File("files/xslt"), true, true, true, true, true);
assertNotNull(reportes);
assertEquals(5, reportes.size());
assertNotNull(reportes.get("xml"));
assertNotNull(reportes.get("json"));
assertNotNull(reportes.get("html"));
assertNotNull(reportes.get("xlxs"));
assertNotNull(reportes.get("docx"));
assertTrue(new File("files/reportes/reporteBajaAsistencia/reporteAsistenciaBajo.xml").exists());
assertTrue(new File("files/reportes/reporteBajaAsistencia/reporteAsistenciaBajo.json").exists());
assertTrue(new File("files/reportes/reporteBajaAsistencia/reporteAsistenciaBajo.html").exists());
assertTrue(new File("files/reportes/reporteBajaAsistencia/reporteAsistenciaBajo.xlsx").exists());
assertTrue(new File("files/reportes/reporteBajaAsistencia/reportesAsistenciaBajo.docx").exists());
}
@Test
public void reporteAsistenciaYNotas() {
Estudiante estudiante = Search.buscarEstudiantes()[0];
ReporteAsistenciaYNotas rayn = new ReporteAsistenciaYNotas(Search.buscarEstudiantes()[0]);
HashMap<String, String> reportes = rayn.generar(new File("files/xslt"), true, true, true, true, true);
assertNotNull(reportes);
assertEquals(5, reportes.size());
assertNotNull(reportes.get("xml"));
assertNotNull(reportes.get("json"));
assertNotNull(reportes.get("html"));
assertNotNull(reportes.get("xlsx"));
assertNotNull(reportes.get("docx"));
assertTrue(new File("files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.xml").exists());
assertTrue(new File("files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.json").exists());
assertTrue(new File("files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.html").exists());
assertTrue(new File("files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.xlsx").exists());
assertTrue(new File("files/reportes/reporteAsistenciaYNotas/" + estudiante.getRut() + "-AsistenciaYNotas.docx").exists());
}
@Test
public void reporteNotasProfesor() {
Profesor profesor = Search.buscarProfesores()[0];
ReporteNotasProfesor rnp = new ReporteNotasProfesor(profesor);
HashMap<String, String> reportes = rnp.generar(new File("files/xslt"), true, true, true, true, true);
assertNotNull(reportes);
assertEquals(5, reportes.size());
assertNotNull(reportes.get("xml"));
assertNotNull(reportes.get("json"));
assertNotNull(reportes.get("html"));
assertNotNull(reportes.get("xslx"));
assertNotNull(reportes.get("docx"));
assertTrue(new File("files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.xml").exists());
assertTrue(new File("files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.xml").exists());
assertTrue(new File("files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.xml").exists());
assertTrue(new File("files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.xml").exists());
assertTrue(new File("files/reportes/reporteNotasProfesor/" + profesor.getRut() + "-NotasProfesor.xml").exists());
}
@Test
public void reportePlanificaciones() {
Apoderado apoderado = Search.buscarApoderados()[0];
ReportePlanificaciones rp = new ReportePlanificaciones(apoderado);
HashMap<String, String> reportes = rp.generar(new File("files/xslt"), true, true, true, true, true);
assertNotNull(reportes);
assertEquals(5, reportes.size());
assertNotNull(reportes.get("xml"));
assertNotNull(reportes.get("json"));
assertNotNull(reportes.get("html"));
assertNotNull(reportes.get("xlsx"));
assertNotNull(reportes.get("docx"));
assertTrue(new File("files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.xml").exists());
assertTrue(new File("files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.json").exists());
assertTrue(new File("files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.html").exists());
assertTrue(new File("files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.xlsx").exists());
assertTrue(new File("files/reportes/reportePlanificaciones/" + apoderado.getRut() + "-Planificaciones.docx").exists());
}
@Test
public void reporteReprobando() {
ReporteReprobando rr = new ReporteReprobando();
HashMap<String, String> reportes = rr.generar(new File("files/xslt"), true, true, true, true, true);
assertNotNull(reportes);
assertEquals(5, reportes.size());
assertNotNull(reportes.get("xml"));
assertNotNull(reportes.get("json"));
assertNotNull(reportes.get("html"));
assertNotNull(reportes.get("xlsx"));
assertNotNull(reportes.get("docx"));
assertTrue(new File("files/reportes/reporteReprobando/reporteReprobado.xml").exists());
assertTrue(new File("files/reportes/reporteReprobando/reporteReprobado.json").exists());
assertTrue(new File("files/reportes/reporteReprobando/reporteReprobando.html").exists());
assertTrue(new File("files/reportes/reporteReprobando/reporteReprobando.xlsx").exists());
assertTrue(new File("files/reportes/reporteReprobando/reporteReprobando.docx").exists());
}
}

View File

@@ -0,0 +1,42 @@
package logica.reportes;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
/**
* Transformador de xml con xsl generalizado el cual utiliza un objeto Transformer.
*/
public class XslTransformer {
/**
* Transforma un xml a un archivo deseado con un xsl creado con anterioridad
* @param xslDocS Ruta del archivo xsl que realizara la transformacion
* @param xmlDocS Ruta al archivo xml al que se le aplicara la transformacion
* @param outputDocS Ruta en la cual se guardara el archivo resultante
* @throws FileNotFoundException
* @throws TransformerException
*/
public static void transform(String xslDocS, String xmlDocS, String outputDocS) throws FileNotFoundException, TransformerException {
//Se crea transformer factory el cual creara el objeto transformer
TransformerFactory tFactory = TransformerFactory.newInstance();
//Fuente del archivo xsl
Source xslDoc = new StreamSource(xslDocS);
//Fuente archivo xml
Source xmlDoc = new StreamSource(xmlDocS);
//Path del archivo de salida
String outputFileName = outputDocS;
//Se crea OutputStream con direccion al path de archivo de salida
OutputStream htmlFile = new FileOutputStream(outputFileName);
//Se crea el transformer respecto al archivo xsl
Transformer trasform = tFactory.newTransformer(xslDoc);
//Se transforma el documento xsl y se envia al documento de salida
trasform.transform(xmlDoc, new StreamResult(htmlFile));
}
}

View File

@@ -0,0 +1,13 @@
package main;
import logica.*;
import logica.reportes.*;
import orm.*;
import java.io.File;
class App {
public static void main(String[] args){
}
}

View File

@@ -0,0 +1,96 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
* <p>
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
* <p>
* Modifying its content may cause the program not work, or your work may lost.
* <p>
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
public class Actividad {
private int id_pk;
private orm.Asignatura asignatura_id_fk;
org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
public void setOwner(Object owner, int key) {
this_setOwner(owner, key);
}
};
private java.util.Date fecha;
private String tipo;
public Actividad() {
}
private void this_setOwner(Object owner, int key) {
if (key == orm.ORMConstants.KEY_ACTIVIDAD_ASIGNATURA_ID_FK) {
this.asignatura_id_fk = (orm.Asignatura) owner;
}
}
public int getId_pk() {
return id_pk;
}
private void setId_pk(int value) {
this.id_pk = value;
}
public int getORMID() {
return getId_pk();
}
public java.util.Date getFecha() {
return fecha;
}
public void setFecha(java.util.Date value) {
this.fecha = value;
}
public String getTipo() {
return tipo;
}
public void setTipo(String value) {
this.tipo = value;
}
public orm.Asignatura getAsignatura_id_fk() {
return asignatura_id_fk;
}
public void setAsignatura_id_fk(orm.Asignatura value) {
if (asignatura_id_fk != null) {
asignatura_id_fk.actividad.remove(this);
}
if (value != null) {
value.actividad.add(this);
}
}
private orm.Asignatura getORM_Asignatura_id_fk() {
return asignatura_id_fk;
}
/**
* This method is for internal use only.
*/
public void setORM_Asignatura_id_fk(orm.Asignatura value) {
this.asignatura_id_fk = value;
}
public String toString() {
return String.valueOf(getId_pk());
}
}

View File

@@ -0,0 +1,379 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
import org.hibernate.Query;
import org.hibernate.LockMode;
import java.util.List;
public class ActividadDAO {
public static Actividad loadActividadByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadActividadByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Actividad getActividadByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getActividadByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Actividad loadActividadByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadActividadByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Actividad getActividadByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getActividadByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Actividad loadActividadByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Actividad) session.load(orm.Actividad.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Actividad getActividadByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Actividad) session.get(orm.Actividad.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Actividad loadActividadByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Actividad) session.load(orm.Actividad.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Actividad getActividadByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Actividad) session.get(orm.Actividad.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryActividad(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryActividad(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryActividad(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryActividad(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Actividad[] listActividadByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listActividadByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Actividad[] listActividadByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listActividadByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryActividad(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Actividad as Actividad");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryActividad(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Actividad as Actividad");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Actividad", lockMode);
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Actividad[] listActividadByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
try {
List list = queryActividad(session, condition, orderBy);
return (Actividad[]) list.toArray(new Actividad[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Actividad[] listActividadByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
List list = queryActividad(session, condition, orderBy, lockMode);
return (Actividad[]) list.toArray(new Actividad[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Actividad loadActividadByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadActividadByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Actividad loadActividadByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadActividadByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Actividad loadActividadByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
Actividad[] actividads = listActividadByQuery(session, condition, orderBy);
if (actividads != null && actividads.length > 0)
return actividads[0];
else
return null;
}
public static Actividad loadActividadByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
Actividad[] actividads = listActividadByQuery(session, condition, orderBy, lockMode);
if (actividads != null && actividads.length > 0)
return actividads[0];
else
return null;
}
public static java.util.Iterator iterateActividadByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateActividadByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateActividadByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateActividadByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateActividadByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Actividad as Actividad");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateActividadByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Actividad as Actividad");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Actividad", lockMode);
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Actividad createActividad() {
return new orm.Actividad();
}
public static boolean save(orm.Actividad actividad) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().saveObject(actividad);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean delete(orm.Actividad actividad) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().deleteObject(actividad);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Actividad actividad)throws PersistentException {
try {
if (actividad.getAsignatura_id_fk() != null) {
actividad.getAsignatura_id_fk().actividad.remove(actividad);
}
return delete(actividad);
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Actividad actividad, org.orm.PersistentSession session)throws PersistentException {
try {
if (actividad.getAsignatura_id_fk() != null) {
actividad.getAsignatura_id_fk().actividad.remove(actividad);
}
try {
session.delete(actividad);
return true;
} catch (Exception e) {
return false;
}
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean refresh(orm.Actividad actividad) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().refresh(actividad);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean evict(orm.Actividad actividad) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().evict(actividad);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
}

View File

@@ -0,0 +1,106 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
* <p>
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
* <p>
* Modifying its content may cause the program not work, or your work may lost.
* <p>
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.PersistentException;
import org.orm.PersistentManager;
public class ActividadSetCollection extends org.orm.util.ORMSet {
public ActividadSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int targetKey, int collType) {
super(owner, adapter, ownerKey, targetKey, true, collType);
}
public ActividadSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int collType) {
super(owner, adapter, ownerKey, -1, false, collType);
}
/**
* Return an iterator over the persistent objects
* @return The persistent objects iterator
*/
public java.util.Iterator getIterator() {
return super.getIterator(_ownerAdapter);
}
/**
* Add the specified persistent object to ORMSet
* @param value the persistent object
*/
public void add(Actividad value) {
if (value != null) {
super.add(value, value._ormAdapter);
}
}
/**
* Remove the specified persistent object from ORMSet
* @param value the persistent object
*/
public void remove(Actividad value) {
super.remove(value, value._ormAdapter);
}
/**
* Return true if ORMSet contains the specified persistent object
* @param value the persistent object
* @return True if this contains the specified persistent object
*/
public boolean contains(Actividad value) {
return super.contains(value);
}
/**
* Return an array containing all of the persistent objects in ORMSet
* @return The persistent objects array
*/
public Actividad[] toArray() {
return (Actividad[]) super.toArray(new Actividad[size()]);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>fecha</li>
* <li>tipo</li>
* </ul>
* @return The persistent objects sorted array
*/
public Actividad[] toArray(String propertyName) {
return toArray(propertyName, true);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>fecha</li>
* <li>tipo</li>
* </ul>
* @param ascending true for ascending, false for descending
* @return The persistent objects sorted array
*/
public Actividad[] toArray(String propertyName, boolean ascending) {
return (Actividad[]) super.toArray(new Actividad[size()], propertyName, ascending);
}
protected PersistentManager getPersistentManager() throws PersistentException {
return orm.ColegioPersistentManager.instance();
}
}

View File

@@ -0,0 +1,127 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
* <p>
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
* <p>
* Modifying its content may cause the program not work, or your work may lost.
* <p>
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
public class Anotacion {
private int id_pk;
private orm.Estudiante estudiante_id_fk;
private orm.Profesor profesor_id_fk;
org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
public void setOwner(Object owner, int key) {
this_setOwner(owner, key);
}
};
private String descripcion;
private Boolean positiva;
public Anotacion() {
}
private void this_setOwner(Object owner, int key) {
if (key == orm.ORMConstants.KEY_ANOTACION_ESTUDIANTE_ID_FK) {
this.estudiante_id_fk = (orm.Estudiante) owner;
} else if (key == orm.ORMConstants.KEY_ANOTACION_PROFESOR_ID_FK) {
this.profesor_id_fk = (orm.Profesor) owner;
}
}
public int getId_pk() {
return id_pk;
}
private void setId_pk(int value) {
this.id_pk = value;
}
public int getORMID() {
return getId_pk();
}
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String value) {
this.descripcion = value;
}
public void setPositiva(boolean value) {
setPositiva(new Boolean(value));
}
public Boolean getPositiva() {
return positiva;
}
public void setPositiva(Boolean value) {
this.positiva = value;
}
public orm.Estudiante getEstudiante_id_fk() {
return estudiante_id_fk;
}
public void setEstudiante_id_fk(orm.Estudiante value) {
if (estudiante_id_fk != null) {
estudiante_id_fk.anotacion.remove(this);
}
if (value != null) {
value.anotacion.add(this);
}
}
private orm.Estudiante getORM_Estudiante_id_fk() {
return estudiante_id_fk;
}
/**
* This method is for internal use only.
*/
public void setORM_Estudiante_id_fk(orm.Estudiante value) {
this.estudiante_id_fk = value;
}
public orm.Profesor getProfesor_id_fk() {
return profesor_id_fk;
}
public void setProfesor_id_fk(orm.Profesor value) {
if (profesor_id_fk != null) {
profesor_id_fk.anotacion.remove(this);
}
if (value != null) {
value.anotacion.add(this);
}
}
private orm.Profesor getORM_Profesor_id_fk() {
return profesor_id_fk;
}
/**
* This method is for internal use only.
*/
public void setORM_Profesor_id_fk(orm.Profesor value) {
this.profesor_id_fk = value;
}
public String toString() {
return String.valueOf(getId_pk());
}
}

View File

@@ -0,0 +1,387 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
import org.hibernate.Query;
import org.hibernate.LockMode;
import java.util.List;
public class AnotacionDAO {
public static Anotacion loadAnotacionByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadAnotacionByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Anotacion getAnotacionByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getAnotacionByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Anotacion loadAnotacionByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadAnotacionByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Anotacion getAnotacionByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getAnotacionByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Anotacion loadAnotacionByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Anotacion) session.load(orm.Anotacion.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Anotacion getAnotacionByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Anotacion) session.get(orm.Anotacion.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Anotacion loadAnotacionByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Anotacion) session.load(orm.Anotacion.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Anotacion getAnotacionByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Anotacion) session.get(orm.Anotacion.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryAnotacion(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryAnotacion(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryAnotacion(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryAnotacion(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Anotacion[] listAnotacionByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listAnotacionByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Anotacion[] listAnotacionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listAnotacionByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryAnotacion(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Anotacion as Anotacion");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryAnotacion(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Anotacion as Anotacion");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Anotacion", lockMode);
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Anotacion[] listAnotacionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
try {
List list = queryAnotacion(session, condition, orderBy);
return (Anotacion[]) list.toArray(new Anotacion[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Anotacion[] listAnotacionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
List list = queryAnotacion(session, condition, orderBy, lockMode);
return (Anotacion[]) list.toArray(new Anotacion[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Anotacion loadAnotacionByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadAnotacionByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Anotacion loadAnotacionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadAnotacionByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Anotacion loadAnotacionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
Anotacion[] anotacions = listAnotacionByQuery(session, condition, orderBy);
if (anotacions != null && anotacions.length > 0)
return anotacions[0];
else
return null;
}
public static Anotacion loadAnotacionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
Anotacion[] anotacions = listAnotacionByQuery(session, condition, orderBy, lockMode);
if (anotacions != null && anotacions.length > 0)
return anotacions[0];
else
return null;
}
public static java.util.Iterator iterateAnotacionByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateAnotacionByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateAnotacionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateAnotacionByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateAnotacionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Anotacion as Anotacion");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateAnotacionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Anotacion as Anotacion");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Anotacion", lockMode);
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Anotacion createAnotacion() {
return new orm.Anotacion();
}
public static boolean save(orm.Anotacion anotacion) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().saveObject(anotacion);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean delete(orm.Anotacion anotacion) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().deleteObject(anotacion);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Anotacion anotacion)throws PersistentException {
try {
if (anotacion.getEstudiante_id_fk() != null) {
anotacion.getEstudiante_id_fk().anotacion.remove(anotacion);
}
if (anotacion.getProfesor_id_fk() != null) {
anotacion.getProfesor_id_fk().anotacion.remove(anotacion);
}
return delete(anotacion);
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Anotacion anotacion, org.orm.PersistentSession session)throws PersistentException {
try {
if (anotacion.getEstudiante_id_fk() != null) {
anotacion.getEstudiante_id_fk().anotacion.remove(anotacion);
}
if (anotacion.getProfesor_id_fk() != null) {
anotacion.getProfesor_id_fk().anotacion.remove(anotacion);
}
try {
session.delete(anotacion);
return true;
} catch (Exception e) {
return false;
}
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean refresh(orm.Anotacion anotacion) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().refresh(anotacion);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean evict(orm.Anotacion anotacion) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().evict(anotacion);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
}

View File

@@ -0,0 +1,102 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
public class AnotacionSetCollection extends org.orm.util.ORMSet {
public AnotacionSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int targetKey, int collType) {
super(owner, adapter, ownerKey, targetKey, true, collType);
}
public AnotacionSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int collType) {
super(owner, adapter, ownerKey, -1, false, collType);
}
/**
* Return an iterator over the persistent objects
* @return The persistent objects iterator
*/
public java.util.Iterator getIterator() {
return super.getIterator(_ownerAdapter);
}
/**
* Add the specified persistent object to ORMSet
* @param value the persistent object
*/
public void add(Anotacion value) {
if (value != null) {
super.add(value, value._ormAdapter);
}
}
/**
* Remove the specified persistent object from ORMSet
* @param value the persistent object
*/
public void remove(Anotacion value) {
super.remove(value, value._ormAdapter);
}
/**
* Return true if ORMSet contains the specified persistent object
* @param value the persistent object
* @return True if this contains the specified persistent object
*/
public boolean contains(Anotacion value) {
return super.contains(value);
}
/**
* Return an array containing all of the persistent objects in ORMSet
* @return The persistent objects array
*/
public Anotacion[] toArray() {
return (Anotacion[]) super.toArray(new Anotacion[size()]);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>descripcion</li>
* <li>positiva</li>
* </ul>
* @return The persistent objects sorted array
*/
public Anotacion[] toArray(String propertyName) {
return toArray(propertyName, true);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>descripcion</li>
* <li>positiva</li>
* </ul>
* @param ascending true for ascending, false for descending
* @return The persistent objects sorted array
*/
public Anotacion[] toArray(String propertyName, boolean ascending) {
return (Anotacion[]) super.toArray(new Anotacion[size()], propertyName, ascending);
}
protected PersistentManager getPersistentManager() throws PersistentException {
return orm.ColegioPersistentManager.instance();
}
}

View File

@@ -0,0 +1,121 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
* <p>
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
* <p>
* Modifying its content may cause the program not work, or your work may lost.
* <p>
* Licensee: Universidad de La Frontera
* License Type: Academic
* <p>
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
public class Apoderado {
private int id_pk;
private orm.Colegio colegio_id_fk;
private String nombre;
private String rut;
private java.util.Set ORM_estudiante = new java.util.HashSet();
org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
public java.util.Set getSet(int key) {
return this_getSet(key);
}
public void setOwner(Object owner, int key) {
this_setOwner(owner, key);
}
};
public final orm.EstudianteSetCollection estudiante = new orm.EstudianteSetCollection(this, _ormAdapter, orm.ORMConstants.KEY_APODERADO_ESTUDIANTE, orm.ORMConstants.KEY_ESTUDIANTE_APODERADO_ID_FK, orm.ORMConstants.KEY_MUL_ONE_TO_MANY);
public Apoderado() {
}
private java.util.Set this_getSet(int key) {
if (key == orm.ORMConstants.KEY_APODERADO_ESTUDIANTE) {
return ORM_estudiante;
}
return null;
}
private void this_setOwner(Object owner, int key) {
if (key == orm.ORMConstants.KEY_APODERADO_COLEGIO_ID_FK) {
this.colegio_id_fk = (orm.Colegio) owner;
}
}
public int getId_pk() {
return id_pk;
}
private void setId_pk(int value) {
this.id_pk = value;
}
public int getORMID() {
return getId_pk();
}
public String getNombre() {
return nombre;
}
public void setNombre(String value) {
this.nombre = value;
}
public String getRut() {
return rut;
}
public void setRut(String value) {
this.rut = value;
}
public orm.Colegio getColegio_id_fk() {
return colegio_id_fk;
}
public void setColegio_id_fk(orm.Colegio value) {
if (colegio_id_fk != null) {
colegio_id_fk.apoderado.remove(this);
}
if (value != null) {
value.apoderado.add(this);
}
}
private orm.Colegio getORM_Colegio_id_fk() {
return colegio_id_fk;
}
/**
* This method is for internal use only.
*/
public void setORM_Colegio_id_fk(orm.Colegio value) {
this.colegio_id_fk = value;
}
private java.util.Set getORM_Estudiante() {
return ORM_estudiante;
}
private void setORM_Estudiante(java.util.Set value) {
this.ORM_estudiante = value;
}
public String toString() {
return String.valueOf(getId_pk());
}
}

View File

@@ -0,0 +1,387 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
import org.hibernate.Query;
import org.hibernate.LockMode;
import java.util.List;
public class ApoderadoDAO {
public static Apoderado loadApoderadoByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadApoderadoByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Apoderado getApoderadoByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getApoderadoByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Apoderado loadApoderadoByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadApoderadoByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Apoderado getApoderadoByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getApoderadoByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Apoderado loadApoderadoByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Apoderado) session.load(orm.Apoderado.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Apoderado getApoderadoByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Apoderado) session.get(orm.Apoderado.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Apoderado loadApoderadoByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Apoderado) session.load(orm.Apoderado.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Apoderado getApoderadoByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Apoderado) session.get(orm.Apoderado.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryApoderado(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryApoderado(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryApoderado(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryApoderado(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Apoderado[] listApoderadoByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listApoderadoByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Apoderado[] listApoderadoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listApoderadoByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryApoderado(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Apoderado as Apoderado");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryApoderado(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Apoderado as Apoderado");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Apoderado", lockMode);
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Apoderado[] listApoderadoByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
try {
List list = queryApoderado(session, condition, orderBy);
return (Apoderado[]) list.toArray(new Apoderado[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Apoderado[] listApoderadoByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
List list = queryApoderado(session, condition, orderBy, lockMode);
return (Apoderado[]) list.toArray(new Apoderado[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Apoderado loadApoderadoByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadApoderadoByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Apoderado loadApoderadoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadApoderadoByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Apoderado loadApoderadoByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
Apoderado[] apoderados = listApoderadoByQuery(session, condition, orderBy);
if (apoderados != null && apoderados.length > 0)
return apoderados[0];
else
return null;
}
public static Apoderado loadApoderadoByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
Apoderado[] apoderados = listApoderadoByQuery(session, condition, orderBy, lockMode);
if (apoderados != null && apoderados.length > 0)
return apoderados[0];
else
return null;
}
public static java.util.Iterator iterateApoderadoByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateApoderadoByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateApoderadoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateApoderadoByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateApoderadoByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Apoderado as Apoderado");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateApoderadoByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Apoderado as Apoderado");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Apoderado", lockMode);
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Apoderado createApoderado() {
return new orm.Apoderado();
}
public static boolean save(orm.Apoderado apoderado) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().saveObject(apoderado);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean delete(orm.Apoderado apoderado) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().deleteObject(apoderado);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Apoderado apoderado)throws PersistentException {
try {
if (apoderado.getColegio_id_fk() != null) {
apoderado.getColegio_id_fk().apoderado.remove(apoderado);
}
orm.Estudiante[] lEstudiantes = apoderado.estudiante.toArray();
for(int i = 0; i < lEstudiantes.length; i++) {
lEstudiantes[i].setApoderado_id_fk(null);
}
return delete(apoderado);
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Apoderado apoderado, org.orm.PersistentSession session)throws PersistentException {
try {
if (apoderado.getColegio_id_fk() != null) {
apoderado.getColegio_id_fk().apoderado.remove(apoderado);
}
orm.Estudiante[] lEstudiantes = apoderado.estudiante.toArray();
for(int i = 0; i < lEstudiantes.length; i++) {
lEstudiantes[i].setApoderado_id_fk(null);
}
try {
session.delete(apoderado);
return true;
} catch (Exception e) {
return false;
}
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean refresh(orm.Apoderado apoderado) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().refresh(apoderado);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean evict(orm.Apoderado apoderado) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().evict(apoderado);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
}

View File

@@ -0,0 +1,102 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
public class ApoderadoSetCollection extends org.orm.util.ORMSet {
public ApoderadoSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int targetKey, int collType) {
super(owner, adapter, ownerKey, targetKey, true, collType);
}
public ApoderadoSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int collType) {
super(owner, adapter, ownerKey, -1, false, collType);
}
/**
* Return an iterator over the persistent objects
* @return The persistent objects iterator
*/
public java.util.Iterator getIterator() {
return super.getIterator(_ownerAdapter);
}
/**
* Add the specified persistent object to ORMSet
* @param value the persistent object
*/
public void add(Apoderado value) {
if (value != null) {
super.add(value, value._ormAdapter);
}
}
/**
* Remove the specified persistent object from ORMSet
* @param value the persistent object
*/
public void remove(Apoderado value) {
super.remove(value, value._ormAdapter);
}
/**
* Return true if ORMSet contains the specified persistent object
* @param value the persistent object
* @return True if this contains the specified persistent object
*/
public boolean contains(Apoderado value) {
return super.contains(value);
}
/**
* Return an array containing all of the persistent objects in ORMSet
* @return The persistent objects array
*/
public Apoderado[] toArray() {
return (Apoderado[]) super.toArray(new Apoderado[size()]);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>nombre</li>
* <li>rut</li>
* </ul>
* @return The persistent objects sorted array
*/
public Apoderado[] toArray(String propertyName) {
return toArray(propertyName, true);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>nombre</li>
* <li>rut</li>
* </ul>
* @param ascending true for ascending, false for descending
* @return The persistent objects sorted array
*/
public Apoderado[] toArray(String propertyName, boolean ascending) {
return (Apoderado[]) super.toArray(new Apoderado[size()], propertyName, ascending);
}
protected PersistentManager getPersistentManager() throws PersistentException {
return orm.ColegioPersistentManager.instance();
}
}

View File

@@ -0,0 +1,148 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
* <p>
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
* <p>
* Modifying its content may cause the program not work, or your work may lost.
* <p>
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
public class Asignatura {
private int id_pk;
private orm.Curso curso_id_fk;
private orm.Profesor profesor_id_fk;
private String nombre;
private java.util.Set ORM_actividad = new java.util.HashSet();
private java.util.Set ORM_nota = new java.util.HashSet();
org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
public java.util.Set getSet(int key) {
return this_getSet(key);
}
public void setOwner(Object owner, int key) {
this_setOwner(owner, key);
}
};
public final orm.ActividadSetCollection actividad = new orm.ActividadSetCollection(this, _ormAdapter, orm.ORMConstants.KEY_ASIGNATURA_ACTIVIDAD, orm.ORMConstants.KEY_ACTIVIDAD_ASIGNATURA_ID_FK, orm.ORMConstants.KEY_MUL_ONE_TO_MANY);
public final orm.NotaSetCollection nota = new orm.NotaSetCollection(this, _ormAdapter, orm.ORMConstants.KEY_ASIGNATURA_NOTA, orm.ORMConstants.KEY_NOTA_ASIGNATURA_ID_FK, orm.ORMConstants.KEY_MUL_ONE_TO_MANY);
public Asignatura() {
}
private java.util.Set this_getSet(int key) {
if (key == orm.ORMConstants.KEY_ASIGNATURA_ACTIVIDAD) {
return ORM_actividad;
} else if (key == orm.ORMConstants.KEY_ASIGNATURA_NOTA) {
return ORM_nota;
}
return null;
}
private void this_setOwner(Object owner, int key) {
if (key == orm.ORMConstants.KEY_ASIGNATURA_CURSO_ID_FK) {
this.curso_id_fk = (orm.Curso) owner;
} else if (key == orm.ORMConstants.KEY_ASIGNATURA_PROFESOR_ID_FK) {
this.profesor_id_fk = (orm.Profesor) owner;
}
}
public int getId_pk() {
return id_pk;
}
private void setId_pk(int value) {
this.id_pk = value;
}
public int getORMID() {
return getId_pk();
}
public String getNombre() {
return nombre;
}
public void setNombre(String value) {
this.nombre = value;
}
public orm.Curso getCurso_id_fk() {
return curso_id_fk;
}
public void setCurso_id_fk(orm.Curso value) {
if (curso_id_fk != null) {
curso_id_fk.asignatura.remove(this);
}
if (value != null) {
value.asignatura.add(this);
}
}
private orm.Curso getORM_Curso_id_fk() {
return curso_id_fk;
}
/**
* This method is for internal use only.
*/
public void setORM_Curso_id_fk(orm.Curso value) {
this.curso_id_fk = value;
}
public orm.Profesor getProfesor_id_fk() {
return profesor_id_fk;
}
public void setProfesor_id_fk(orm.Profesor value) {
if (profesor_id_fk != null) {
profesor_id_fk.asignatura.remove(this);
}
if (value != null) {
value.asignatura.add(this);
}
}
private orm.Profesor getORM_Profesor_id_fk() {
return profesor_id_fk;
}
/**
* This method is for internal use only.
*/
public void setORM_Profesor_id_fk(orm.Profesor value) {
this.profesor_id_fk = value;
}
private java.util.Set getORM_Actividad() {
return ORM_actividad;
}
private void setORM_Actividad(java.util.Set value) {
this.ORM_actividad = value;
}
private java.util.Set getORM_Nota() {
return ORM_nota;
}
private void setORM_Nota(java.util.Set value) {
this.ORM_nota = value;
}
public String toString() {
return String.valueOf(getId_pk());
}
}

View File

@@ -0,0 +1,403 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
import org.hibernate.Query;
import org.hibernate.LockMode;
import java.util.List;
public class AsignaturaDAO {
public static Asignatura loadAsignaturaByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadAsignaturaByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asignatura getAsignaturaByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getAsignaturaByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asignatura loadAsignaturaByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadAsignaturaByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asignatura getAsignaturaByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getAsignaturaByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asignatura loadAsignaturaByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Asignatura) session.load(orm.Asignatura.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asignatura getAsignaturaByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Asignatura) session.get(orm.Asignatura.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asignatura loadAsignaturaByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Asignatura) session.load(orm.Asignatura.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asignatura getAsignaturaByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Asignatura) session.get(orm.Asignatura.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryAsignatura(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryAsignatura(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryAsignatura(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryAsignatura(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asignatura[] listAsignaturaByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listAsignaturaByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asignatura[] listAsignaturaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listAsignaturaByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryAsignatura(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Asignatura as Asignatura");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryAsignatura(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Asignatura as Asignatura");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Asignatura", lockMode);
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asignatura[] listAsignaturaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
try {
List list = queryAsignatura(session, condition, orderBy);
return (Asignatura[]) list.toArray(new Asignatura[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asignatura[] listAsignaturaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
List list = queryAsignatura(session, condition, orderBy, lockMode);
return (Asignatura[]) list.toArray(new Asignatura[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asignatura loadAsignaturaByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadAsignaturaByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asignatura loadAsignaturaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadAsignaturaByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asignatura loadAsignaturaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
Asignatura[] asignaturas = listAsignaturaByQuery(session, condition, orderBy);
if (asignaturas != null && asignaturas.length > 0)
return asignaturas[0];
else
return null;
}
public static Asignatura loadAsignaturaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
Asignatura[] asignaturas = listAsignaturaByQuery(session, condition, orderBy, lockMode);
if (asignaturas != null && asignaturas.length > 0)
return asignaturas[0];
else
return null;
}
public static java.util.Iterator iterateAsignaturaByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateAsignaturaByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateAsignaturaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateAsignaturaByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateAsignaturaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Asignatura as Asignatura");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateAsignaturaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Asignatura as Asignatura");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Asignatura", lockMode);
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asignatura createAsignatura() {
return new orm.Asignatura();
}
public static boolean save(orm.Asignatura asignatura) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().saveObject(asignatura);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean delete(orm.Asignatura asignatura) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().deleteObject(asignatura);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Asignatura asignatura)throws PersistentException {
try {
if (asignatura.getCurso_id_fk() != null) {
asignatura.getCurso_id_fk().asignatura.remove(asignatura);
}
if (asignatura.getProfesor_id_fk() != null) {
asignatura.getProfesor_id_fk().asignatura.remove(asignatura);
}
orm.Actividad[] lActividads = asignatura.actividad.toArray();
for(int i = 0; i < lActividads.length; i++) {
lActividads[i].setAsignatura_id_fk(null);
}
orm.Nota[] lNotas = asignatura.nota.toArray();
for(int i = 0; i < lNotas.length; i++) {
lNotas[i].setAsignatura_id_fk(null);
}
return delete(asignatura);
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Asignatura asignatura, org.orm.PersistentSession session)throws PersistentException {
try {
if (asignatura.getCurso_id_fk() != null) {
asignatura.getCurso_id_fk().asignatura.remove(asignatura);
}
if (asignatura.getProfesor_id_fk() != null) {
asignatura.getProfesor_id_fk().asignatura.remove(asignatura);
}
orm.Actividad[] lActividads = asignatura.actividad.toArray();
for(int i = 0; i < lActividads.length; i++) {
lActividads[i].setAsignatura_id_fk(null);
}
orm.Nota[] lNotas = asignatura.nota.toArray();
for(int i = 0; i < lNotas.length; i++) {
lNotas[i].setAsignatura_id_fk(null);
}
try {
session.delete(asignatura);
return true;
} catch (Exception e) {
return false;
}
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean refresh(orm.Asignatura asignatura) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().refresh(asignatura);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean evict(orm.Asignatura asignatura) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().evict(asignatura);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
}

View File

@@ -0,0 +1,100 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
public class AsignaturaSetCollection extends org.orm.util.ORMSet {
public AsignaturaSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int targetKey, int collType) {
super(owner, adapter, ownerKey, targetKey, true, collType);
}
public AsignaturaSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int collType) {
super(owner, adapter, ownerKey, -1, false, collType);
}
/**
* Return an iterator over the persistent objects
* @return The persistent objects iterator
*/
public java.util.Iterator getIterator() {
return super.getIterator(_ownerAdapter);
}
/**
* Add the specified persistent object to ORMSet
* @param value the persistent object
*/
public void add(Asignatura value) {
if (value != null) {
super.add(value, value._ormAdapter);
}
}
/**
* Remove the specified persistent object from ORMSet
* @param value the persistent object
*/
public void remove(Asignatura value) {
super.remove(value, value._ormAdapter);
}
/**
* Return true if ORMSet contains the specified persistent object
* @param value the persistent object
* @return True if this contains the specified persistent object
*/
public boolean contains(Asignatura value) {
return super.contains(value);
}
/**
* Return an array containing all of the persistent objects in ORMSet
* @return The persistent objects array
*/
public Asignatura[] toArray() {
return (Asignatura[]) super.toArray(new Asignatura[size()]);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>nombre</li>
* </ul>
* @return The persistent objects sorted array
*/
public Asignatura[] toArray(String propertyName) {
return toArray(propertyName, true);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>nombre</li>
* </ul>
* @param ascending true for ascending, false for descending
* @return The persistent objects sorted array
*/
public Asignatura[] toArray(String propertyName, boolean ascending) {
return (Asignatura[]) super.toArray(new Asignatura[size()], propertyName, ascending);
}
protected PersistentManager getPersistentManager() throws PersistentException {
return orm.ColegioPersistentManager.instance();
}
}

View File

@@ -0,0 +1,100 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
* <p>
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
* <p>
* Modifying its content may cause the program not work, or your work may lost.
* <p>
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
public class Asistencia {
private int id_pk;
private orm.Estudiante estudiante_id_fk;
org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
public void setOwner(Object owner, int key) {
this_setOwner(owner, key);
}
};
private java.util.Date dia;
private Boolean asistio;
public Asistencia() {
}
private void this_setOwner(Object owner, int key) {
if (key == orm.ORMConstants.KEY_ASISTENCIA_ESTUDIANTE_ID_FK) {
this.estudiante_id_fk = (orm.Estudiante) owner;
}
}
public int getId_pk() {
return id_pk;
}
private void setId_pk(int value) {
this.id_pk = value;
}
public int getORMID() {
return getId_pk();
}
public java.util.Date getDia() {
return dia;
}
public void setDia(java.util.Date value) {
this.dia = value;
}
public void setAsistio(boolean value) {
setAsistio(new Boolean(value));
}
public Boolean getAsistio() {
return asistio;
}
public void setAsistio(Boolean value) {
this.asistio = value;
}
public orm.Estudiante getEstudiante_id_fk() {
return estudiante_id_fk;
}
public void setEstudiante_id_fk(orm.Estudiante value) {
if (estudiante_id_fk != null) {
estudiante_id_fk.asistencia.remove(this);
}
if (value != null) {
value.asistencia.add(this);
}
}
private orm.Estudiante getORM_Estudiante_id_fk() {
return estudiante_id_fk;
}
/**
* This method is for internal use only.
*/
public void setORM_Estudiante_id_fk(orm.Estudiante value) {
this.estudiante_id_fk = value;
}
public String toString() {
return String.valueOf(getId_pk());
}
}

View File

@@ -0,0 +1,379 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
import org.hibernate.Query;
import org.hibernate.LockMode;
import java.util.List;
public class AsistenciaDAO {
public static Asistencia loadAsistenciaByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadAsistenciaByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asistencia getAsistenciaByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getAsistenciaByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asistencia loadAsistenciaByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadAsistenciaByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asistencia getAsistenciaByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getAsistenciaByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asistencia loadAsistenciaByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Asistencia) session.load(orm.Asistencia.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asistencia getAsistenciaByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Asistencia) session.get(orm.Asistencia.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asistencia loadAsistenciaByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Asistencia) session.load(orm.Asistencia.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asistencia getAsistenciaByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Asistencia) session.get(orm.Asistencia.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryAsistencia(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryAsistencia(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryAsistencia(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryAsistencia(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asistencia[] listAsistenciaByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listAsistenciaByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asistencia[] listAsistenciaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listAsistenciaByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryAsistencia(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Asistencia as Asistencia");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryAsistencia(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Asistencia as Asistencia");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Asistencia", lockMode);
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asistencia[] listAsistenciaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
try {
List list = queryAsistencia(session, condition, orderBy);
return (Asistencia[]) list.toArray(new Asistencia[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asistencia[] listAsistenciaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
List list = queryAsistencia(session, condition, orderBy, lockMode);
return (Asistencia[]) list.toArray(new Asistencia[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asistencia loadAsistenciaByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadAsistenciaByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asistencia loadAsistenciaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadAsistenciaByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asistencia loadAsistenciaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
Asistencia[] asistencias = listAsistenciaByQuery(session, condition, orderBy);
if (asistencias != null && asistencias.length > 0)
return asistencias[0];
else
return null;
}
public static Asistencia loadAsistenciaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
Asistencia[] asistencias = listAsistenciaByQuery(session, condition, orderBy, lockMode);
if (asistencias != null && asistencias.length > 0)
return asistencias[0];
else
return null;
}
public static java.util.Iterator iterateAsistenciaByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateAsistenciaByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateAsistenciaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateAsistenciaByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateAsistenciaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Asistencia as Asistencia");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateAsistenciaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Asistencia as Asistencia");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Asistencia", lockMode);
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Asistencia createAsistencia() {
return new orm.Asistencia();
}
public static boolean save(orm.Asistencia asistencia) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().saveObject(asistencia);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean delete(orm.Asistencia asistencia) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().deleteObject(asistencia);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Asistencia asistencia)throws PersistentException {
try {
if (asistencia.getEstudiante_id_fk() != null) {
asistencia.getEstudiante_id_fk().asistencia.remove(asistencia);
}
return delete(asistencia);
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Asistencia asistencia, org.orm.PersistentSession session)throws PersistentException {
try {
if (asistencia.getEstudiante_id_fk() != null) {
asistencia.getEstudiante_id_fk().asistencia.remove(asistencia);
}
try {
session.delete(asistencia);
return true;
} catch (Exception e) {
return false;
}
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean refresh(orm.Asistencia asistencia) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().refresh(asistencia);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean evict(orm.Asistencia asistencia) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().evict(asistencia);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
}

View File

@@ -0,0 +1,102 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
public class AsistenciaSetCollection extends org.orm.util.ORMSet {
public AsistenciaSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int targetKey, int collType) {
super(owner, adapter, ownerKey, targetKey, true, collType);
}
public AsistenciaSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int collType) {
super(owner, adapter, ownerKey, -1, false, collType);
}
/**
* Return an iterator over the persistent objects
* @return The persistent objects iterator
*/
public java.util.Iterator getIterator() {
return super.getIterator(_ownerAdapter);
}
/**
* Add the specified persistent object to ORMSet
* @param value the persistent object
*/
public void add(Asistencia value) {
if (value != null) {
super.add(value, value._ormAdapter);
}
}
/**
* Remove the specified persistent object from ORMSet
* @param value the persistent object
*/
public void remove(Asistencia value) {
super.remove(value, value._ormAdapter);
}
/**
* Return true if ORMSet contains the specified persistent object
* @param value the persistent object
* @return True if this contains the specified persistent object
*/
public boolean contains(Asistencia value) {
return super.contains(value);
}
/**
* Return an array containing all of the persistent objects in ORMSet
* @return The persistent objects array
*/
public Asistencia[] toArray() {
return (Asistencia[]) super.toArray(new Asistencia[size()]);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>dia</li>
* <li>asistio</li>
* </ul>
* @return The persistent objects sorted array
*/
public Asistencia[] toArray(String propertyName) {
return toArray(propertyName, true);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>dia</li>
* <li>asistio</li>
* </ul>
* @param ascending true for ascending, false for descending
* @return The persistent objects sorted array
*/
public Asistencia[] toArray(String propertyName, boolean ascending) {
return (Asistencia[]) super.toArray(new Asistencia[size()], propertyName, ascending);
}
protected PersistentManager getPersistentManager() throws PersistentException {
return orm.ColegioPersistentManager.instance();
}
}

View File

@@ -0,0 +1,98 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
* <p>
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
* <p>
* Modifying its content may cause the program not work, or your work may lost.
* <p>
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
public class Colegio {
private int id_pk;
private String nombre;
private java.util.Set ORM_curso = new java.util.HashSet();
private java.util.Set ORM_apoderado = new java.util.HashSet();
private java.util.Set ORM_profesor = new java.util.HashSet();
org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
public java.util.Set getSet(int key) {
return this_getSet(key);
}
};
public final orm.CursoSetCollection curso = new orm.CursoSetCollection(this, _ormAdapter, orm.ORMConstants.KEY_COLEGIO_CURSO, orm.ORMConstants.KEY_CURSO_COLEGIO_ID_FK, orm.ORMConstants.KEY_MUL_ONE_TO_MANY);
public final orm.ApoderadoSetCollection apoderado = new orm.ApoderadoSetCollection(this, _ormAdapter, orm.ORMConstants.KEY_COLEGIO_APODERADO, orm.ORMConstants.KEY_APODERADO_COLEGIO_ID_FK, orm.ORMConstants.KEY_MUL_ONE_TO_MANY);
public final orm.ProfesorSetCollection profesor = new orm.ProfesorSetCollection(this, _ormAdapter, orm.ORMConstants.KEY_COLEGIO_PROFESOR, orm.ORMConstants.KEY_PROFESOR_COLEGIO_ID_FK, orm.ORMConstants.KEY_MUL_ONE_TO_MANY);
public Colegio() {
}
private java.util.Set this_getSet(int key) {
if (key == orm.ORMConstants.KEY_COLEGIO_CURSO) {
return ORM_curso;
} else if (key == orm.ORMConstants.KEY_COLEGIO_APODERADO) {
return ORM_apoderado;
} else if (key == orm.ORMConstants.KEY_COLEGIO_PROFESOR) {
return ORM_profesor;
}
return null;
}
public int getId_pk() {
return id_pk;
}
private void setId_pk(int value) {
this.id_pk = value;
}
public int getORMID() {
return getId_pk();
}
public String getNombre() {
return nombre;
}
public void setNombre(String value) {
this.nombre = value;
}
private java.util.Set getORM_Curso() {
return ORM_curso;
}
private void setORM_Curso(java.util.Set value) {
this.ORM_curso = value;
}
private java.util.Set getORM_Apoderado() {
return ORM_apoderado;
}
private void setORM_Apoderado(java.util.Set value) {
this.ORM_apoderado = value;
}
private java.util.Set getORM_Profesor() {
return ORM_profesor;
}
private void setORM_Profesor(java.util.Set value) {
this.ORM_profesor = value;
}
public String toString() {
return String.valueOf(getId_pk());
}
}

View File

@@ -0,0 +1,395 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
import org.hibernate.Query;
import org.hibernate.LockMode;
import java.util.List;
public class ColegioDAO {
public static Colegio loadColegioByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadColegioByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Colegio getColegioByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getColegioByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Colegio loadColegioByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadColegioByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Colegio getColegioByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getColegioByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Colegio loadColegioByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Colegio) session.load(orm.Colegio.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Colegio getColegioByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Colegio) session.get(orm.Colegio.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Colegio loadColegioByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Colegio) session.load(orm.Colegio.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Colegio getColegioByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Colegio) session.get(orm.Colegio.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryColegio(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryColegio(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryColegio(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryColegio(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Colegio[] listColegioByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listColegioByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Colegio[] listColegioByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listColegioByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryColegio(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Colegio as Colegio");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryColegio(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Colegio as Colegio");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Colegio", lockMode);
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Colegio[] listColegioByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
try {
List list = queryColegio(session, condition, orderBy);
return (Colegio[]) list.toArray(new Colegio[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Colegio[] listColegioByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
List list = queryColegio(session, condition, orderBy, lockMode);
return (Colegio[]) list.toArray(new Colegio[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Colegio loadColegioByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadColegioByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Colegio loadColegioByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadColegioByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Colegio loadColegioByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
Colegio[] colegios = listColegioByQuery(session, condition, orderBy);
if (colegios != null && colegios.length > 0)
return colegios[0];
else
return null;
}
public static Colegio loadColegioByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
Colegio[] colegios = listColegioByQuery(session, condition, orderBy, lockMode);
if (colegios != null && colegios.length > 0)
return colegios[0];
else
return null;
}
public static java.util.Iterator iterateColegioByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateColegioByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateColegioByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateColegioByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateColegioByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Colegio as Colegio");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateColegioByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Colegio as Colegio");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Colegio", lockMode);
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Colegio createColegio() {
return new orm.Colegio();
}
public static boolean save(orm.Colegio colegio) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().saveObject(colegio);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean delete(orm.Colegio colegio) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().deleteObject(colegio);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Colegio colegio)throws PersistentException {
try {
orm.Curso[] lCursos = colegio.curso.toArray();
for(int i = 0; i < lCursos.length; i++) {
lCursos[i].setColegio_id_fk(null);
}
orm.Apoderado[] lApoderados = colegio.apoderado.toArray();
for(int i = 0; i < lApoderados.length; i++) {
lApoderados[i].setColegio_id_fk(null);
}
orm.Profesor[] lProfesors = colegio.profesor.toArray();
for(int i = 0; i < lProfesors.length; i++) {
lProfesors[i].setColegio_id_fk(null);
}
return delete(colegio);
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Colegio colegio, org.orm.PersistentSession session)throws PersistentException {
try {
orm.Curso[] lCursos = colegio.curso.toArray();
for(int i = 0; i < lCursos.length; i++) {
lCursos[i].setColegio_id_fk(null);
}
orm.Apoderado[] lApoderados = colegio.apoderado.toArray();
for(int i = 0; i < lApoderados.length; i++) {
lApoderados[i].setColegio_id_fk(null);
}
orm.Profesor[] lProfesors = colegio.profesor.toArray();
for(int i = 0; i < lProfesors.length; i++) {
lProfesors[i].setColegio_id_fk(null);
}
try {
session.delete(colegio);
return true;
} catch (Exception e) {
return false;
}
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean refresh(orm.Colegio colegio) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().refresh(colegio);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean evict(orm.Colegio colegio) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().evict(colegio);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
}

View File

@@ -0,0 +1,105 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
import org.orm.cfg.JDBCConnectionSetting;
import org.hibernate.*;
import java.util.Properties;
public class ColegioPersistentManager extends PersistentManager {
private static final String PROJECT_NAME = "Colegio";
private static PersistentManager _instance = null;
private static SessionType _sessionType = SessionType.THREAD_BASE;
private static int _timeToAlive = 60000;
private static JDBCConnectionSetting _connectionSetting = null;
private static Properties _extraProperties = null;
private static String _configurationFile = null;
private ColegioPersistentManager() throws PersistentException {
super(_connectionSetting, _sessionType, _timeToAlive, new String[] {}, _extraProperties, _configurationFile);
setFlushMode(FlushMode.AUTO);
}
public String getProjectName() {
return PROJECT_NAME;
}
public static synchronized final PersistentManager instance() throws PersistentException {
if (_instance == null) {
_instance = new ColegioPersistentManager();
}
return _instance;
}
public void disposePersistentManager() throws PersistentException {
_instance = null;
super.disposePersistentManager();
}
public static void setSessionType(SessionType sessionType) throws PersistentException {
if (_instance != null) {
throw new PersistentException("Cannot set session type after create PersistentManager instance");
}
else {
_sessionType = sessionType;
}
}
public static void setAppBaseSessionTimeToAlive(int timeInMs) throws PersistentException {
if (_instance != null) {
throw new PersistentException("Cannot set session time to alive after create PersistentManager instance");
}
else {
_timeToAlive = timeInMs;
}
}
public static void setJDBCConnectionSetting(JDBCConnectionSetting aConnectionSetting) throws PersistentException {
if (_instance != null) {
throw new PersistentException("Cannot set connection setting after create PersistentManager instance");
}
else {
_connectionSetting = aConnectionSetting;
}
}
public static void setHibernateProperties(Properties aProperties) throws PersistentException {
if (_instance != null) {
throw new PersistentException("Cannot set hibernate properties after create PersistentManager instance");
}
else {
_extraProperties = aProperties;
}
}
public static void setConfigurationFile(String aConfigurationFile) throws PersistentException {
if (_instance != null) {
throw new PersistentException("Cannot set configuration file after create PersistentManager instance");
}
else {
_configurationFile = aConfigurationFile;
}
}
public static void saveJDBCConnectionSetting() {
PersistentManager.saveJDBCConnectionSetting(PROJECT_NAME, _connectionSetting);
}
}

View File

@@ -0,0 +1,134 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
* <p>
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
* <p>
* Modifying its content may cause the program not work, or your work may lost.
* <p>
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
public class Curso {
private int id_pk;
private orm.Colegio colegio_id_fk;
private Integer nivel;
private String letra;
private java.util.Set ORM_asignatura = new java.util.HashSet();
private java.util.Set ORM_estudiante = new java.util.HashSet();
org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
public java.util.Set getSet(int key) {
return this_getSet(key);
}
public void setOwner(Object owner, int key) {
this_setOwner(owner, key);
}
};
public final orm.AsignaturaSetCollection asignatura = new orm.AsignaturaSetCollection(this, _ormAdapter, orm.ORMConstants.KEY_CURSO_ASIGNATURA, orm.ORMConstants.KEY_ASIGNATURA_CURSO_ID_FK, orm.ORMConstants.KEY_MUL_ONE_TO_MANY);
public final orm.EstudianteSetCollection estudiante = new orm.EstudianteSetCollection(this, _ormAdapter, orm.ORMConstants.KEY_CURSO_ESTUDIANTE, orm.ORMConstants.KEY_ESTUDIANTE_CURSO_ID_FK, orm.ORMConstants.KEY_MUL_ONE_TO_MANY);
public Curso() {
}
private java.util.Set this_getSet(int key) {
if (key == orm.ORMConstants.KEY_CURSO_ASIGNATURA) {
return ORM_asignatura;
} else if (key == orm.ORMConstants.KEY_CURSO_ESTUDIANTE) {
return ORM_estudiante;
}
return null;
}
private void this_setOwner(Object owner, int key) {
if (key == orm.ORMConstants.KEY_CURSO_COLEGIO_ID_FK) {
this.colegio_id_fk = (orm.Colegio) owner;
}
}
public int getId_pk() {
return id_pk;
}
private void setId_pk(int value) {
this.id_pk = value;
}
public int getORMID() {
return getId_pk();
}
public void setNivel(int value) {
setNivel(new Integer(value));
}
public Integer getNivel() {
return nivel;
}
public void setNivel(Integer value) {
this.nivel = value;
}
public String getLetra() {
return letra;
}
public void setLetra(String value) {
this.letra = value;
}
public orm.Colegio getColegio_id_fk() {
return colegio_id_fk;
}
public void setColegio_id_fk(orm.Colegio value) {
if (colegio_id_fk != null) {
colegio_id_fk.curso.remove(this);
}
if (value != null) {
value.curso.add(this);
}
}
private orm.Colegio getORM_Colegio_id_fk() {
return colegio_id_fk;
}
/**
* This method is for internal use only.
*/
public void setORM_Colegio_id_fk(orm.Colegio value) {
this.colegio_id_fk = value;
}
private java.util.Set getORM_Asignatura() {
return ORM_asignatura;
}
private void setORM_Asignatura(java.util.Set value) {
this.ORM_asignatura = value;
}
private java.util.Set getORM_Estudiante() {
return ORM_estudiante;
}
private void setORM_Estudiante(java.util.Set value) {
this.ORM_estudiante = value;
}
public String toString() {
return String.valueOf(getId_pk());
}
}

View File

@@ -0,0 +1,395 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
import org.hibernate.Query;
import org.hibernate.LockMode;
import java.util.List;
public class CursoDAO {
public static Curso loadCursoByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadCursoByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Curso getCursoByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getCursoByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Curso loadCursoByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadCursoByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Curso getCursoByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getCursoByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Curso loadCursoByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Curso) session.load(orm.Curso.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Curso getCursoByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Curso) session.get(orm.Curso.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Curso loadCursoByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Curso) session.load(orm.Curso.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Curso getCursoByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Curso) session.get(orm.Curso.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryCurso(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryCurso(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryCurso(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryCurso(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Curso[] listCursoByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listCursoByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Curso[] listCursoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listCursoByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryCurso(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Curso as Curso");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryCurso(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Curso as Curso");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Curso", lockMode);
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Curso[] listCursoByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
try {
List list = queryCurso(session, condition, orderBy);
return (Curso[]) list.toArray(new Curso[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Curso[] listCursoByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
List list = queryCurso(session, condition, orderBy, lockMode);
return (Curso[]) list.toArray(new Curso[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Curso loadCursoByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadCursoByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Curso loadCursoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadCursoByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Curso loadCursoByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
Curso[] cursos = listCursoByQuery(session, condition, orderBy);
if (cursos != null && cursos.length > 0)
return cursos[0];
else
return null;
}
public static Curso loadCursoByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
Curso[] cursos = listCursoByQuery(session, condition, orderBy, lockMode);
if (cursos != null && cursos.length > 0)
return cursos[0];
else
return null;
}
public static java.util.Iterator iterateCursoByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateCursoByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateCursoByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateCursoByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateCursoByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Curso as Curso");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateCursoByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Curso as Curso");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Curso", lockMode);
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Curso createCurso() {
return new orm.Curso();
}
public static boolean save(orm.Curso curso) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().saveObject(curso);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean delete(orm.Curso curso) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().deleteObject(curso);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Curso curso)throws PersistentException {
try {
if (curso.getColegio_id_fk() != null) {
curso.getColegio_id_fk().curso.remove(curso);
}
orm.Asignatura[] lAsignaturas = curso.asignatura.toArray();
for(int i = 0; i < lAsignaturas.length; i++) {
lAsignaturas[i].setCurso_id_fk(null);
}
orm.Estudiante[] lEstudiantes = curso.estudiante.toArray();
for(int i = 0; i < lEstudiantes.length; i++) {
lEstudiantes[i].setCurso_id_fk(null);
}
return delete(curso);
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Curso curso, org.orm.PersistentSession session)throws PersistentException {
try {
if (curso.getColegio_id_fk() != null) {
curso.getColegio_id_fk().curso.remove(curso);
}
orm.Asignatura[] lAsignaturas = curso.asignatura.toArray();
for(int i = 0; i < lAsignaturas.length; i++) {
lAsignaturas[i].setCurso_id_fk(null);
}
orm.Estudiante[] lEstudiantes = curso.estudiante.toArray();
for(int i = 0; i < lEstudiantes.length; i++) {
lEstudiantes[i].setCurso_id_fk(null);
}
try {
session.delete(curso);
return true;
} catch (Exception e) {
return false;
}
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean refresh(orm.Curso curso) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().refresh(curso);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean evict(orm.Curso curso) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().evict(curso);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
}

View File

@@ -0,0 +1,102 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
public class CursoSetCollection extends org.orm.util.ORMSet {
public CursoSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int targetKey, int collType) {
super(owner, adapter, ownerKey, targetKey, true, collType);
}
public CursoSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int collType) {
super(owner, adapter, ownerKey, -1, false, collType);
}
/**
* Return an iterator over the persistent objects
* @return The persistent objects iterator
*/
public java.util.Iterator getIterator() {
return super.getIterator(_ownerAdapter);
}
/**
* Add the specified persistent object to ORMSet
* @param value the persistent object
*/
public void add(Curso value) {
if (value != null) {
super.add(value, value._ormAdapter);
}
}
/**
* Remove the specified persistent object from ORMSet
* @param value the persistent object
*/
public void remove(Curso value) {
super.remove(value, value._ormAdapter);
}
/**
* Return true if ORMSet contains the specified persistent object
* @param value the persistent object
* @return True if this contains the specified persistent object
*/
public boolean contains(Curso value) {
return super.contains(value);
}
/**
* Return an array containing all of the persistent objects in ORMSet
* @return The persistent objects array
*/
public Curso[] toArray() {
return (Curso[]) super.toArray(new Curso[size()]);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>nivel</li>
* <li>letra</li>
* </ul>
* @return The persistent objects sorted array
*/
public Curso[] toArray(String propertyName) {
return toArray(propertyName, true);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>nivel</li>
* <li>letra</li>
* </ul>
* @param ascending true for ascending, false for descending
* @return The persistent objects sorted array
*/
public Curso[] toArray(String propertyName, boolean ascending) {
return (Curso[]) super.toArray(new Curso[size()], propertyName, ascending);
}
protected PersistentManager getPersistentManager() throws PersistentException {
return orm.ColegioPersistentManager.instance();
}
}

View File

@@ -0,0 +1,169 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
* <p>
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
* <p>
* Modifying its content may cause the program not work, or your work may lost.
* <p>
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
public class Estudiante {
private int id_pk;
private orm.Curso curso_id_fk;
private orm.Apoderado apoderado_id_fk;
private String nombre;
private String rut;
private java.util.Set ORM_anotacion = new java.util.HashSet();
private java.util.Set ORM_nota = new java.util.HashSet();
private java.util.Set ORM_asistencia = new java.util.HashSet();
org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
public java.util.Set getSet(int key) {
return this_getSet(key);
}
public void setOwner(Object owner, int key) {
this_setOwner(owner, key);
}
};
public final orm.AnotacionSetCollection anotacion = new orm.AnotacionSetCollection(this, _ormAdapter, orm.ORMConstants.KEY_ESTUDIANTE_ANOTACION, orm.ORMConstants.KEY_ANOTACION_ESTUDIANTE_ID_FK, orm.ORMConstants.KEY_MUL_ONE_TO_MANY);
public final orm.NotaSetCollection nota = new orm.NotaSetCollection(this, _ormAdapter, orm.ORMConstants.KEY_ESTUDIANTE_NOTA, orm.ORMConstants.KEY_NOTA_ESTUDIANTE_ID_FK, orm.ORMConstants.KEY_MUL_ONE_TO_MANY);
public final orm.AsistenciaSetCollection asistencia = new orm.AsistenciaSetCollection(this, _ormAdapter, orm.ORMConstants.KEY_ESTUDIANTE_ASISTENCIA, orm.ORMConstants.KEY_ASISTENCIA_ESTUDIANTE_ID_FK, orm.ORMConstants.KEY_MUL_ONE_TO_MANY);
public Estudiante() {
}
private java.util.Set this_getSet(int key) {
if (key == orm.ORMConstants.KEY_ESTUDIANTE_ANOTACION) {
return ORM_anotacion;
} else if (key == orm.ORMConstants.KEY_ESTUDIANTE_NOTA) {
return ORM_nota;
} else if (key == orm.ORMConstants.KEY_ESTUDIANTE_ASISTENCIA) {
return ORM_asistencia;
}
return null;
}
private void this_setOwner(Object owner, int key) {
if (key == orm.ORMConstants.KEY_ESTUDIANTE_CURSO_ID_FK) {
this.curso_id_fk = (orm.Curso) owner;
} else if (key == orm.ORMConstants.KEY_ESTUDIANTE_APODERADO_ID_FK) {
this.apoderado_id_fk = (orm.Apoderado) owner;
}
}
public int getId_pk() {
return id_pk;
}
private void setId_pk(int value) {
this.id_pk = value;
}
public int getORMID() {
return getId_pk();
}
public String getNombre() {
return nombre;
}
public void setNombre(String value) {
this.nombre = value;
}
public String getRut() {
return rut;
}
public void setRut(String value) {
this.rut = value;
}
public orm.Curso getCurso_id_fk() {
return curso_id_fk;
}
public void setCurso_id_fk(orm.Curso value) {
if (curso_id_fk != null) {
curso_id_fk.estudiante.remove(this);
}
if (value != null) {
value.estudiante.add(this);
}
}
private orm.Curso getORM_Curso_id_fk() {
return curso_id_fk;
}
/**
* This method is for internal use only.
*/
public void setORM_Curso_id_fk(orm.Curso value) {
this.curso_id_fk = value;
}
public orm.Apoderado getApoderado_id_fk() {
return apoderado_id_fk;
}
public void setApoderado_id_fk(orm.Apoderado value) {
if (apoderado_id_fk != null) {
apoderado_id_fk.estudiante.remove(this);
}
if (value != null) {
value.estudiante.add(this);
}
}
private orm.Apoderado getORM_Apoderado_id_fk() {
return apoderado_id_fk;
}
/**
* This method is for internal use only.
*/
public void setORM_Apoderado_id_fk(orm.Apoderado value) {
this.apoderado_id_fk = value;
}
private java.util.Set getORM_Anotacion() {
return ORM_anotacion;
}
private void setORM_Anotacion(java.util.Set value) {
this.ORM_anotacion = value;
}
private java.util.Set getORM_Nota() {
return ORM_nota;
}
private void setORM_Nota(java.util.Set value) {
this.ORM_nota = value;
}
private java.util.Set getORM_Asistencia() {
return ORM_asistencia;
}
private void setORM_Asistencia(java.util.Set value) {
this.ORM_asistencia = value;
}
public String toString() {
return String.valueOf(getId_pk());
}
}

View File

@@ -0,0 +1,411 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
import org.hibernate.Query;
import org.hibernate.LockMode;
import java.util.List;
public class EstudianteDAO {
public static Estudiante loadEstudianteByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadEstudianteByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Estudiante getEstudianteByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getEstudianteByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Estudiante loadEstudianteByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadEstudianteByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Estudiante getEstudianteByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getEstudianteByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Estudiante loadEstudianteByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Estudiante) session.load(orm.Estudiante.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Estudiante getEstudianteByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Estudiante) session.get(orm.Estudiante.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Estudiante loadEstudianteByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Estudiante) session.load(orm.Estudiante.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Estudiante getEstudianteByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Estudiante) session.get(orm.Estudiante.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryEstudiante(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryEstudiante(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryEstudiante(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryEstudiante(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Estudiante[] listEstudianteByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listEstudianteByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Estudiante[] listEstudianteByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listEstudianteByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryEstudiante(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Estudiante as Estudiante");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryEstudiante(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Estudiante as Estudiante");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Estudiante", lockMode);
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Estudiante[] listEstudianteByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
try {
List list = queryEstudiante(session, condition, orderBy);
return (Estudiante[]) list.toArray(new Estudiante[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Estudiante[] listEstudianteByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
List list = queryEstudiante(session, condition, orderBy, lockMode);
return (Estudiante[]) list.toArray(new Estudiante[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Estudiante loadEstudianteByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadEstudianteByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Estudiante loadEstudianteByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadEstudianteByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Estudiante loadEstudianteByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
Estudiante[] estudiantes = listEstudianteByQuery(session, condition, orderBy);
if (estudiantes != null && estudiantes.length > 0)
return estudiantes[0];
else
return null;
}
public static Estudiante loadEstudianteByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
Estudiante[] estudiantes = listEstudianteByQuery(session, condition, orderBy, lockMode);
if (estudiantes != null && estudiantes.length > 0)
return estudiantes[0];
else
return null;
}
public static java.util.Iterator iterateEstudianteByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateEstudianteByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateEstudianteByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateEstudianteByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateEstudianteByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Estudiante as Estudiante");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateEstudianteByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Estudiante as Estudiante");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Estudiante", lockMode);
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Estudiante createEstudiante() {
return new orm.Estudiante();
}
public static boolean save(orm.Estudiante estudiante) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().saveObject(estudiante);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean delete(orm.Estudiante estudiante) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().deleteObject(estudiante);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Estudiante estudiante)throws PersistentException {
try {
if (estudiante.getCurso_id_fk() != null) {
estudiante.getCurso_id_fk().estudiante.remove(estudiante);
}
if (estudiante.getApoderado_id_fk() != null) {
estudiante.getApoderado_id_fk().estudiante.remove(estudiante);
}
orm.Anotacion[] lAnotacions = estudiante.anotacion.toArray();
for(int i = 0; i < lAnotacions.length; i++) {
lAnotacions[i].setEstudiante_id_fk(null);
}
orm.Nota[] lNotas = estudiante.nota.toArray();
for(int i = 0; i < lNotas.length; i++) {
lNotas[i].setEstudiante_id_fk(null);
}
orm.Asistencia[] lAsistencias = estudiante.asistencia.toArray();
for(int i = 0; i < lAsistencias.length; i++) {
lAsistencias[i].setEstudiante_id_fk(null);
}
return delete(estudiante);
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Estudiante estudiante, org.orm.PersistentSession session)throws PersistentException {
try {
if (estudiante.getCurso_id_fk() != null) {
estudiante.getCurso_id_fk().estudiante.remove(estudiante);
}
if (estudiante.getApoderado_id_fk() != null) {
estudiante.getApoderado_id_fk().estudiante.remove(estudiante);
}
orm.Anotacion[] lAnotacions = estudiante.anotacion.toArray();
for(int i = 0; i < lAnotacions.length; i++) {
lAnotacions[i].setEstudiante_id_fk(null);
}
orm.Nota[] lNotas = estudiante.nota.toArray();
for(int i = 0; i < lNotas.length; i++) {
lNotas[i].setEstudiante_id_fk(null);
}
orm.Asistencia[] lAsistencias = estudiante.asistencia.toArray();
for(int i = 0; i < lAsistencias.length; i++) {
lAsistencias[i].setEstudiante_id_fk(null);
}
try {
session.delete(estudiante);
return true;
} catch (Exception e) {
return false;
}
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean refresh(orm.Estudiante estudiante) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().refresh(estudiante);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean evict(orm.Estudiante estudiante) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().evict(estudiante);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
}

View File

@@ -0,0 +1,102 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
public class EstudianteSetCollection extends org.orm.util.ORMSet {
public EstudianteSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int targetKey, int collType) {
super(owner, adapter, ownerKey, targetKey, true, collType);
}
public EstudianteSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int collType) {
super(owner, adapter, ownerKey, -1, false, collType);
}
/**
* Return an iterator over the persistent objects
* @return The persistent objects iterator
*/
public java.util.Iterator getIterator() {
return super.getIterator(_ownerAdapter);
}
/**
* Add the specified persistent object to ORMSet
* @param value the persistent object
*/
public void add(Estudiante value) {
if (value != null) {
super.add(value, value._ormAdapter);
}
}
/**
* Remove the specified persistent object from ORMSet
* @param value the persistent object
*/
public void remove(Estudiante value) {
super.remove(value, value._ormAdapter);
}
/**
* Return true if ORMSet contains the specified persistent object
* @param value the persistent object
* @return True if this contains the specified persistent object
*/
public boolean contains(Estudiante value) {
return super.contains(value);
}
/**
* Return an array containing all of the persistent objects in ORMSet
* @return The persistent objects array
*/
public Estudiante[] toArray() {
return (Estudiante[]) super.toArray(new Estudiante[size()]);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>nombre</li>
* <li>rut</li>
* </ul>
* @return The persistent objects sorted array
*/
public Estudiante[] toArray(String propertyName) {
return toArray(propertyName, true);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>nombre</li>
* <li>rut</li>
* </ul>
* @param ascending true for ascending, false for descending
* @return The persistent objects sorted array
*/
public Estudiante[] toArray(String propertyName, boolean ascending) {
return (Estudiante[]) super.toArray(new Estudiante[size()], propertyName, ascending);
}
protected PersistentManager getPersistentManager() throws PersistentException {
return orm.ColegioPersistentManager.instance();
}
}

View File

@@ -0,0 +1,118 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
* <p>
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
* <p>
* Modifying its content may cause the program not work, or your work may lost.
* <p>
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
public class Nota {
private int id_pk;
private orm.Estudiante estudiante_id_fk;
private orm.Asignatura asignatura_id_fk;
org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
public void setOwner(Object owner, int key) {
this_setOwner(owner, key);
}
};
private Double valor;
public Nota() {
}
private void this_setOwner(Object owner, int key) {
if (key == orm.ORMConstants.KEY_NOTA_ESTUDIANTE_ID_FK) {
this.estudiante_id_fk = (orm.Estudiante) owner;
} else if (key == orm.ORMConstants.KEY_NOTA_ASIGNATURA_ID_FK) {
this.asignatura_id_fk = (orm.Asignatura) owner;
}
}
public int getId_pk() {
return id_pk;
}
private void setId_pk(int value) {
this.id_pk = value;
}
public int getORMID() {
return getId_pk();
}
public void setValor(double value) {
setValor(new Double(value));
}
public Double getValor() {
return valor;
}
public void setValor(Double value) {
this.valor = value;
}
public orm.Estudiante getEstudiante_id_fk() {
return estudiante_id_fk;
}
public void setEstudiante_id_fk(orm.Estudiante value) {
if (estudiante_id_fk != null) {
estudiante_id_fk.nota.remove(this);
}
if (value != null) {
value.nota.add(this);
}
}
private orm.Estudiante getORM_Estudiante_id_fk() {
return estudiante_id_fk;
}
/**
* This method is for internal use only.
*/
public void setORM_Estudiante_id_fk(orm.Estudiante value) {
this.estudiante_id_fk = value;
}
public orm.Asignatura getAsignatura_id_fk() {
return asignatura_id_fk;
}
public void setAsignatura_id_fk(orm.Asignatura value) {
if (asignatura_id_fk != null) {
asignatura_id_fk.nota.remove(this);
}
if (value != null) {
value.nota.add(this);
}
}
private orm.Asignatura getORM_Asignatura_id_fk() {
return asignatura_id_fk;
}
/**
* This method is for internal use only.
*/
public void setORM_Asignatura_id_fk(orm.Asignatura value) {
this.asignatura_id_fk = value;
}
public String toString() {
return String.valueOf(getId_pk());
}
}

View File

@@ -0,0 +1,387 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
import org.hibernate.Query;
import org.hibernate.LockMode;
import java.util.List;
public class NotaDAO {
public static Nota loadNotaByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadNotaByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Nota getNotaByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getNotaByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Nota loadNotaByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadNotaByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Nota getNotaByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getNotaByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Nota loadNotaByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Nota) session.load(orm.Nota.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Nota getNotaByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Nota) session.get(orm.Nota.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Nota loadNotaByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Nota) session.load(orm.Nota.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Nota getNotaByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Nota) session.get(orm.Nota.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryNota(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryNota(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryNota(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryNota(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Nota[] listNotaByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listNotaByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Nota[] listNotaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listNotaByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryNota(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Nota as Nota");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryNota(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Nota as Nota");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Nota", lockMode);
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Nota[] listNotaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
try {
List list = queryNota(session, condition, orderBy);
return (Nota[]) list.toArray(new Nota[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Nota[] listNotaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
List list = queryNota(session, condition, orderBy, lockMode);
return (Nota[]) list.toArray(new Nota[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Nota loadNotaByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadNotaByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Nota loadNotaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadNotaByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Nota loadNotaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
Nota[] notas = listNotaByQuery(session, condition, orderBy);
if (notas != null && notas.length > 0)
return notas[0];
else
return null;
}
public static Nota loadNotaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
Nota[] notas = listNotaByQuery(session, condition, orderBy, lockMode);
if (notas != null && notas.length > 0)
return notas[0];
else
return null;
}
public static java.util.Iterator iterateNotaByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateNotaByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateNotaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateNotaByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateNotaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Nota as Nota");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateNotaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Nota as Nota");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Nota", lockMode);
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Nota createNota() {
return new orm.Nota();
}
public static boolean save(orm.Nota nota) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().saveObject(nota);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean delete(orm.Nota nota) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().deleteObject(nota);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Nota nota)throws PersistentException {
try {
if (nota.getEstudiante_id_fk() != null) {
nota.getEstudiante_id_fk().nota.remove(nota);
}
if (nota.getAsignatura_id_fk() != null) {
nota.getAsignatura_id_fk().nota.remove(nota);
}
return delete(nota);
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Nota nota, org.orm.PersistentSession session)throws PersistentException {
try {
if (nota.getEstudiante_id_fk() != null) {
nota.getEstudiante_id_fk().nota.remove(nota);
}
if (nota.getAsignatura_id_fk() != null) {
nota.getAsignatura_id_fk().nota.remove(nota);
}
try {
session.delete(nota);
return true;
} catch (Exception e) {
return false;
}
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean refresh(orm.Nota nota) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().refresh(nota);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean evict(orm.Nota nota) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().evict(nota);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
}

View File

@@ -0,0 +1,100 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
public class NotaSetCollection extends org.orm.util.ORMSet {
public NotaSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int targetKey, int collType) {
super(owner, adapter, ownerKey, targetKey, true, collType);
}
public NotaSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int collType) {
super(owner, adapter, ownerKey, -1, false, collType);
}
/**
* Return an iterator over the persistent objects
* @return The persistent objects iterator
*/
public java.util.Iterator getIterator() {
return super.getIterator(_ownerAdapter);
}
/**
* Add the specified persistent object to ORMSet
* @param value the persistent object
*/
public void add(Nota value) {
if (value != null) {
super.add(value, value._ormAdapter);
}
}
/**
* Remove the specified persistent object from ORMSet
* @param value the persistent object
*/
public void remove(Nota value) {
super.remove(value, value._ormAdapter);
}
/**
* Return true if ORMSet contains the specified persistent object
* @param value the persistent object
* @return True if this contains the specified persistent object
*/
public boolean contains(Nota value) {
return super.contains(value);
}
/**
* Return an array containing all of the persistent objects in ORMSet
* @return The persistent objects array
*/
public Nota[] toArray() {
return (Nota[]) super.toArray(new Nota[size()]);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>valor</li>
* </ul>
* @return The persistent objects sorted array
*/
public Nota[] toArray(String propertyName) {
return toArray(propertyName, true);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>valor</li>
* </ul>
* @param ascending true for ascending, false for descending
* @return The persistent objects sorted array
*/
public Nota[] toArray(String propertyName, boolean ascending) {
return (Nota[]) super.toArray(new Nota[size()], propertyName, ascending);
}
protected PersistentManager getPersistentManager() throws PersistentException {
return orm.ColegioPersistentManager.instance();
}
}

View File

@@ -0,0 +1,69 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
public interface ORMConstants extends org.orm.util.ORMBaseConstants {
final int KEY_ACTIVIDAD_ASIGNATURA_ID_FK = 381350015;
final int KEY_ANOTACION_ESTUDIANTE_ID_FK = 1002360231;
final int KEY_ANOTACION_PROFESOR_ID_FK = 4678271;
final int KEY_APODERADO_COLEGIO_ID_FK = 1670226414;
final int KEY_APODERADO_ESTUDIANTE = -852510826;
final int KEY_ASIGNATURA_ACTIVIDAD = 641196177;
final int KEY_ASIGNATURA_CURSO_ID_FK = 837022810;
final int KEY_ASIGNATURA_NOTA = -1609688294;
final int KEY_ASIGNATURA_PROFESOR_ID_FK = 853127168;
final int KEY_ASISTENCIA_ESTUDIANTE_ID_FK = -363679775;
final int KEY_COLEGIO_APODERADO = -2056049596;
final int KEY_COLEGIO_CURSO = -834365371;
final int KEY_COLEGIO_PROFESOR = 1113051553;
final int KEY_CURSO_ASIGNATURA = 986371350;
final int KEY_CURSO_COLEGIO_ID_FK = 1355959215;
final int KEY_CURSO_ESTUDIANTE = 1452035445;
final int KEY_ESTUDIANTE_ANOTACION = 959065863;
final int KEY_ESTUDIANTE_APODERADO_ID_FK = -1719600648;
final int KEY_ESTUDIANTE_ASISTENCIA = 1305407431;
final int KEY_ESTUDIANTE_CURSO_ID_FK = -1580149191;
final int KEY_ESTUDIANTE_NOTA = 479462939;
final int KEY_NOTA_ASIGNATURA_ID_FK = 1961909422;
final int KEY_NOTA_ESTUDIANTE_ID_FK = -1993879091;
final int KEY_PROFESOR_ANOTACION = 224231711;
final int KEY_PROFESOR_ASIGNATURA = 2059970248;
final int KEY_PROFESOR_COLEGIO_ID_FK = 319276221;
}

View File

@@ -0,0 +1,133 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
* <p>
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
* <p>
* Modifying its content may cause the program not work, or your work may lost.
* <p>
* Licensee: Universidad de La Frontera
* License Type: Academic
* <p>
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
public class Profesor {
private int id_pk;
private orm.Colegio colegio_id_fk;
private String nombre;
private String rut;
private java.util.Set ORM_asignatura = new java.util.HashSet();
private java.util.Set ORM_anotacion = new java.util.HashSet();
org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
public java.util.Set getSet(int key) {
return this_getSet(key);
}
public void setOwner(Object owner, int key) {
this_setOwner(owner, key);
}
};
public final orm.AsignaturaSetCollection asignatura = new orm.AsignaturaSetCollection(this, _ormAdapter, orm.ORMConstants.KEY_PROFESOR_ASIGNATURA, orm.ORMConstants.KEY_ASIGNATURA_PROFESOR_ID_FK, orm.ORMConstants.KEY_MUL_ONE_TO_MANY);
public final orm.AnotacionSetCollection anotacion = new orm.AnotacionSetCollection(this, _ormAdapter, orm.ORMConstants.KEY_PROFESOR_ANOTACION, orm.ORMConstants.KEY_ANOTACION_PROFESOR_ID_FK, orm.ORMConstants.KEY_MUL_ONE_TO_MANY);
public Profesor() {
}
private java.util.Set this_getSet(int key) {
if (key == orm.ORMConstants.KEY_PROFESOR_ASIGNATURA) {
return ORM_asignatura;
} else if (key == orm.ORMConstants.KEY_PROFESOR_ANOTACION) {
return ORM_anotacion;
}
return null;
}
private void this_setOwner(Object owner, int key) {
if (key == orm.ORMConstants.KEY_PROFESOR_COLEGIO_ID_FK) {
this.colegio_id_fk = (orm.Colegio) owner;
}
}
public int getId_pk() {
return id_pk;
}
private void setId_pk(int value) {
this.id_pk = value;
}
public int getORMID() {
return getId_pk();
}
public String getNombre() {
return nombre;
}
public void setNombre(String value) {
this.nombre = value;
}
public String getRut() {
return rut;
}
public void setRut(String value) {
this.rut = value;
}
public orm.Colegio getColegio_id_fk() {
return colegio_id_fk;
}
public void setColegio_id_fk(orm.Colegio value) {
if (colegio_id_fk != null) {
colegio_id_fk.profesor.remove(this);
}
if (value != null) {
value.profesor.add(this);
}
}
private orm.Colegio getORM_Colegio_id_fk() {
return colegio_id_fk;
}
/**
* This method is for internal use only.
*/
public void setORM_Colegio_id_fk(orm.Colegio value) {
this.colegio_id_fk = value;
}
private java.util.Set getORM_Asignatura() {
return ORM_asignatura;
}
private void setORM_Asignatura(java.util.Set value) {
this.ORM_asignatura = value;
}
private java.util.Set getORM_Anotacion() {
return ORM_anotacion;
}
private void setORM_Anotacion(java.util.Set value) {
this.ORM_anotacion = value;
}
public String toString() {
return String.valueOf(getId_pk());
}
}

View File

@@ -0,0 +1,395 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
import org.hibernate.Query;
import org.hibernate.LockMode;
import java.util.List;
public class ProfesorDAO {
public static Profesor loadProfesorByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadProfesorByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Profesor getProfesorByORMID(int id_pk) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getProfesorByORMID(session, id_pk);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Profesor loadProfesorByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadProfesorByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Profesor getProfesorByORMID(int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return getProfesorByORMID(session, id_pk, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Profesor loadProfesorByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Profesor) session.load(orm.Profesor.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Profesor getProfesorByORMID(PersistentSession session, int id_pk) throws PersistentException {
try {
return (Profesor) session.get(orm.Profesor.class, new Integer(id_pk));
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Profesor loadProfesorByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Profesor) session.load(orm.Profesor.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Profesor getProfesorByORMID(PersistentSession session, int id_pk, org.hibernate.LockMode lockMode) throws PersistentException {
try {
return (Profesor) session.get(orm.Profesor.class, new Integer(id_pk), lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryProfesor(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryProfesor(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryProfesor(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return queryProfesor(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Profesor[] listProfesorByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listProfesorByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Profesor[] listProfesorByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return listProfesorByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryProfesor(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Profesor as Profesor");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static List queryProfesor(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Profesor as Profesor");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Profesor", lockMode);
return query.list();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Profesor[] listProfesorByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
try {
List list = queryProfesor(session, condition, orderBy);
return (Profesor[]) list.toArray(new Profesor[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Profesor[] listProfesorByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
List list = queryProfesor(session, condition, orderBy, lockMode);
return (Profesor[]) list.toArray(new Profesor[list.size()]);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Profesor loadProfesorByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadProfesorByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Profesor loadProfesorByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return loadProfesorByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Profesor loadProfesorByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
Profesor[] profesors = listProfesorByQuery(session, condition, orderBy);
if (profesors != null && profesors.length > 0)
return profesors[0];
else
return null;
}
public static Profesor loadProfesorByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
Profesor[] profesors = listProfesorByQuery(session, condition, orderBy, lockMode);
if (profesors != null && profesors.length > 0)
return profesors[0];
else
return null;
}
public static java.util.Iterator iterateProfesorByQuery(String condition, String orderBy) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateProfesorByQuery(session, condition, orderBy);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateProfesorByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
try {
PersistentSession session = orm.ColegioPersistentManager.instance().getSession();
return iterateProfesorByQuery(session, condition, orderBy, lockMode);
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateProfesorByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Profesor as Profesor");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static java.util.Iterator iterateProfesorByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
StringBuffer sb = new StringBuffer("From orm.Profesor as Profesor");
if (condition != null)
sb.append(" Where ").append(condition);
if (orderBy != null)
sb.append(" Order By ").append(orderBy);
try {
Query query = session.createQuery(sb.toString());
query.setLockMode("Profesor", lockMode);
return query.iterate();
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static Profesor createProfesor() {
return new orm.Profesor();
}
public static boolean save(orm.Profesor profesor) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().saveObject(profesor);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean delete(orm.Profesor profesor) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().deleteObject(profesor);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Profesor profesor)throws PersistentException {
try {
if (profesor.getColegio_id_fk() != null) {
profesor.getColegio_id_fk().profesor.remove(profesor);
}
orm.Asignatura[] lAsignaturas = profesor.asignatura.toArray();
for(int i = 0; i < lAsignaturas.length; i++) {
lAsignaturas[i].setProfesor_id_fk(null);
}
orm.Anotacion[] lAnotacions = profesor.anotacion.toArray();
for(int i = 0; i < lAnotacions.length; i++) {
lAnotacions[i].setProfesor_id_fk(null);
}
return delete(profesor);
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean deleteAndDissociate(orm.Profesor profesor, org.orm.PersistentSession session)throws PersistentException {
try {
if (profesor.getColegio_id_fk() != null) {
profesor.getColegio_id_fk().profesor.remove(profesor);
}
orm.Asignatura[] lAsignaturas = profesor.asignatura.toArray();
for(int i = 0; i < lAsignaturas.length; i++) {
lAsignaturas[i].setProfesor_id_fk(null);
}
orm.Anotacion[] lAnotacions = profesor.anotacion.toArray();
for(int i = 0; i < lAnotacions.length; i++) {
lAnotacions[i].setProfesor_id_fk(null);
}
try {
session.delete(profesor);
return true;
} catch (Exception e) {
return false;
}
}
catch(Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean refresh(orm.Profesor profesor) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().refresh(profesor);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
public static boolean evict(orm.Profesor profesor) throws PersistentException {
try {
orm.ColegioPersistentManager.instance().getSession().evict(profesor);
return true;
}
catch (Exception e) {
e.printStackTrace();
throw new PersistentException(e);
}
}
}

View File

@@ -0,0 +1,102 @@
/**
* "Visual Paradigm: DO NOT MODIFY THIS FILE!"
*
* This is an automatic generated file. It will be regenerated every time
* you generate persistence class.
*
* Modifying its content may cause the program not work, or your work may lost.
*/
/**
* Licensee: Universidad de La Frontera
* License Type: Academic
*/
package orm;
import org.orm.*;
public class ProfesorSetCollection extends org.orm.util.ORMSet {
public ProfesorSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int targetKey, int collType) {
super(owner, adapter, ownerKey, targetKey, true, collType);
}
public ProfesorSetCollection(Object owner, org.orm.util.ORMAdapter adapter, int ownerKey, int collType) {
super(owner, adapter, ownerKey, -1, false, collType);
}
/**
* Return an iterator over the persistent objects
* @return The persistent objects iterator
*/
public java.util.Iterator getIterator() {
return super.getIterator(_ownerAdapter);
}
/**
* Add the specified persistent object to ORMSet
* @param value the persistent object
*/
public void add(Profesor value) {
if (value != null) {
super.add(value, value._ormAdapter);
}
}
/**
* Remove the specified persistent object from ORMSet
* @param value the persistent object
*/
public void remove(Profesor value) {
super.remove(value, value._ormAdapter);
}
/**
* Return true if ORMSet contains the specified persistent object
* @param value the persistent object
* @return True if this contains the specified persistent object
*/
public boolean contains(Profesor value) {
return super.contains(value);
}
/**
* Return an array containing all of the persistent objects in ORMSet
* @return The persistent objects array
*/
public Profesor[] toArray() {
return (Profesor[]) super.toArray(new Profesor[size()]);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>nombre</li>
* <li>rut</li>
* </ul>
* @return The persistent objects sorted array
*/
public Profesor[] toArray(String propertyName) {
return toArray(propertyName, true);
}
/**
* Return an sorted array containing all of the persistent objects in ORMSet
* @param propertyName Name of the property for sorting:<ul>
* <li>id_pk</li>
* <li>nombre</li>
* <li>rut</li>
* </ul>
* @param ascending true for ascending, false for descending
* @return The persistent objects sorted array
*/
public Profesor[] toArray(String propertyName, boolean ascending) {
return (Profesor[]) super.toArray(new Profesor[size()], propertyName, ascending);
}
protected PersistentManager getPersistentManager() throws PersistentException {
return orm.ColegioPersistentManager.instance();
}
}

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Licensee: Universidad de La Frontera License Type: Academic -->
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- properties -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/colegio</property>
<property name="connection.username">root</property>
<property name="connection.password">daniel980</property>
<property name="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.idle_test_period">0</property>
<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.max_size">15</property>
<property name="hibernate.c3p0.timeout">0</property>
<property name="show_sql">false</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<!-- mapping files -->
<mapping resource="ormmapping/orm/Actividad.hbm.xml" />
<mapping resource="ormmapping/orm/Anotacion.hbm.xml" />
<mapping resource="ormmapping/orm/Apoderado.hbm.xml" />
<mapping resource="ormmapping/orm/Asignatura.hbm.xml" />
<mapping resource="ormmapping/orm/Asistencia.hbm.xml" />
<mapping resource="ormmapping/orm/Colegio.hbm.xml" />
<mapping resource="ormmapping/orm/Curso.hbm.xml" />
<mapping resource="ormmapping/orm/Estudiante.hbm.xml" />
<mapping resource="ormmapping/orm/Nota.hbm.xml" />
<mapping resource="ormmapping/orm/Profesor.hbm.xml" />
</session-factory>
</hibernate-configuration>

View File

@@ -0,0 +1,608 @@
<?xml version="1.0" encoding="UTF-8"?>
<Model quotesql="1" tablecharset="UTF8" mysql_version="504"
mssql_version="2005" derby_version="106" ingres_version="9">
<Entity name="colegio" Unlogged="false" PKClustered="0">
<Column name="id_pk">
<PrimaryKey>true</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>increment</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="nombre">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>27</Type>
<Length>100</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
</Entity>
<Entity name="curso" Unlogged="false" PKClustered="0">
<Column name="id_pk">
<PrimaryKey>true</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>increment</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="colegio_id_fk">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>true</ForeignKey>
<ReferencedColumn>colegio.id_pk</ReferencedColumn>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="nivel">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>9</Type>
<Length>10</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="letra">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>27</Type>
<Length>1</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
</Entity>
<Entity name="asignatura" Unlogged="false" PKClustered="0">
<Column name="id_pk">
<PrimaryKey>true</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>increment</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="curso_id_fk">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>true</ForeignKey>
<ReferencedColumn>curso.id_pk</ReferencedColumn>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="profesor_id_fk">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>true</ForeignKey>
<ReferencedColumn>profesor.id_pk</ReferencedColumn>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="nombre">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>27</Type>
<Length>100</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
</Entity>
<Entity name="estudiante" Unlogged="false" PKClustered="0">
<Column name="id_pk">
<PrimaryKey>true</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>increment</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="curso_id_fk">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>true</ForeignKey>
<ReferencedColumn>curso.id_pk</ReferencedColumn>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="apoderado_id_fk">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>true</ForeignKey>
<ReferencedColumn>apoderado.id_pk</ReferencedColumn>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="nombre">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>27</Type>
<Length>100</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="rut">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>27</Type>
<Length>100</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
</Entity>
<Entity name="apoderado" Unlogged="false" PKClustered="0">
<Column name="id_pk">
<PrimaryKey>true</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>increment</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="colegio_id_fk">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>true</ForeignKey>
<ReferencedColumn>colegio.id_pk</ReferencedColumn>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="nombre">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>27</Type>
<Length>100</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="rut">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>27</Type>
<Length>100</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
</Entity>
<Entity name="nota" Unlogged="false" PKClustered="0">
<Column name="id_pk">
<PrimaryKey>true</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>increment</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="estudiante_id_fk">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>true</ForeignKey>
<ReferencedColumn>estudiante.id_pk</ReferencedColumn>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="asignatura_id_fk">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>true</ForeignKey>
<ReferencedColumn>asignatura.id_pk</ReferencedColumn>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="valor">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>6</Type>
<Length>0</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
</Entity>
<Entity name="anotacion" Unlogged="false" PKClustered="0">
<Column name="id_pk">
<PrimaryKey>true</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>increment</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="estudiante_id_fk">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>true</ForeignKey>
<ReferencedColumn>estudiante.id_pk</ReferencedColumn>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="profesor_id_fk">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>true</ForeignKey>
<ReferencedColumn>profesor.id_pk</ReferencedColumn>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="descripcion">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>27</Type>
<Length>100</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="positiva">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>1</Type>
<Length>1</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
</Entity>
<Entity name="asistencia" Unlogged="false" PKClustered="0">
<Column name="id_pk">
<PrimaryKey>true</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>increment</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="estudiante_id_fk">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>true</ForeignKey>
<ReferencedColumn>estudiante.id_pk</ReferencedColumn>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="dia">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>17</Type>
<Length>0</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="asistio">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>1</Type>
<Length>1</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
</Entity>
<Entity name="profesor" Unlogged="false" PKClustered="0">
<Column name="id_pk">
<PrimaryKey>true</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>increment</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="colegio_id_fk">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>true</ForeignKey>
<ReferencedColumn>colegio.id_pk</ReferencedColumn>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="nombre">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>27</Type>
<Length>100</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="rut">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>27</Type>
<Length>100</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
</Entity>
<Entity name="actividad" Unlogged="false" PKClustered="0">
<Column name="id_pk">
<PrimaryKey>true</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>increment</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="asignatura_id_fk">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>true</ForeignKey>
<ReferencedColumn>asignatura.id_pk</ReferencedColumn>
<Type>9</Type>
<Length>10</Length>
<Nullable>false</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="fecha">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>17</Type>
<Length>0</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
<Column name="tipo">
<PrimaryKey>false</PrimaryKey>
<ForeignKey>false</ForeignKey>
<Type>27</Type>
<Length>100</Length>
<Nullable>true</Nullable>
<IDGenerator>native</IDGenerator>
<Unique>false</Unique>
<Index>false</Index>
<UserTypes />
</Column>
</Entity>
<ForeignKey name="FKanotacion106484">
<ReferenceTable>anotacion</ReferenceTable>
<ReferencedTable>estudiante</ReferencedTable>
<Columns>
<Column>estudiante_id_fk</Column>
</Columns>
<RefColumns>
<Column>id_pk</Column>
</RefColumns>
</ForeignKey>
<ForeignKey name="FKnota970842">
<ReferenceTable>nota</ReferenceTable>
<ReferencedTable>estudiante</ReferencedTable>
<Columns>
<Column>estudiante_id_fk</Column>
</Columns>
<RefColumns>
<Column>id_pk</Column>
</RefColumns>
</ForeignKey>
<ForeignKey name="FKasignatura734940">
<ReferenceTable>asignatura</ReferenceTable>
<ReferencedTable>curso</ReferencedTable>
<Columns>
<Column>curso_id_fk</Column>
</Columns>
<RefColumns>
<Column>id_pk</Column>
</RefColumns>
</ForeignKey>
<ForeignKey name="FKestudiante399501">
<ReferenceTable>estudiante</ReferenceTable>
<ReferencedTable>curso</ReferencedTable>
<Columns>
<Column>curso_id_fk</Column>
</Columns>
<RefColumns>
<Column>id_pk</Column>
</RefColumns>
</ForeignKey>
<ForeignKey name="FKactividad385633">
<ReferenceTable>actividad</ReferenceTable>
<ReferencedTable>asignatura</ReferencedTable>
<Columns>
<Column>asignatura_id_fk</Column>
</Columns>
<RefColumns>
<Column>id_pk</Column>
</RefColumns>
</ForeignKey>
<ForeignKey name="FKestudiante816093">
<ReferenceTable>estudiante</ReferenceTable>
<ReferencedTable>apoderado</ReferencedTable>
<Columns>
<Column>apoderado_id_fk</Column>
</Columns>
<RefColumns>
<Column>id_pk</Column>
</RefColumns>
</ForeignKey>
<ForeignKey name="FKcurso1967">
<ReferenceTable>curso</ReferenceTable>
<ReferencedTable>colegio</ReferencedTable>
<Columns>
<Column>colegio_id_fk</Column>
</Columns>
<RefColumns>
<Column>id_pk</Column>
</RefColumns>
</ForeignKey>
<ForeignKey name="FKasistencia331039">
<ReferenceTable>asistencia</ReferenceTable>
<ReferencedTable>estudiante</ReferencedTable>
<Columns>
<Column>estudiante_id_fk</Column>
</Columns>
<RefColumns>
<Column>id_pk</Column>
</RefColumns>
</ForeignKey>
<ForeignKey name="FKasignatura442837">
<ReferenceTable>asignatura</ReferenceTable>
<ReferencedTable>profesor</ReferencedTable>
<Columns>
<Column>profesor_id_fk</Column>
</Columns>
<RefColumns>
<Column>id_pk</Column>
</RefColumns>
</ForeignKey>
<ForeignKey name="FKanotacion379168">
<ReferenceTable>anotacion</ReferenceTable>
<ReferencedTable>profesor</ReferencedTable>
<Columns>
<Column>profesor_id_fk</Column>
</Columns>
<RefColumns>
<Column>id_pk</Column>
</RefColumns>
</ForeignKey>
<ForeignKey name="FKnota157065">
<ReferenceTable>nota</ReferenceTable>
<ReferencedTable>asignatura</ReferencedTable>
<Columns>
<Column>asignatura_id_fk</Column>
</Columns>
<RefColumns>
<Column>id_pk</Column>
</RefColumns>
</ForeignKey>
<ForeignKey name="FKapoderado153902">
<ReferenceTable>apoderado</ReferenceTable>
<ReferencedTable>colegio</ReferencedTable>
<Columns>
<Column>colegio_id_fk</Column>
</Columns>
<RefColumns>
<Column>id_pk</Column>
</RefColumns>
</ForeignKey>
<ForeignKey name="FKprofesor406122">
<ReferenceTable>profesor</ReferenceTable>
<ReferencedTable>colegio</ReferencedTable>
<Columns>
<Column>colegio_id_fk</Column>
</Columns>
<RefColumns>
<Column>id_pk</Column>
</RefColumns>
</ForeignKey>
</Model>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Licensee: Universidad de La Frontera License Type: Academic -->
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- properties -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/colegio</property>
<property name="connection.username">root</property>
<property name="connection.password">admin</property>
<property name="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.idle_test_period">0</property>
<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.max_size">15</property>
<property name="hibernate.c3p0.timeout">0</property>
<property name="show_sql">false</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<!-- mapping files -->
<mapping resource="ormmapping/orm/Actividad.hbm.xml" />
<mapping resource="ormmapping/orm/Anotacion.hbm.xml" />
<mapping resource="ormmapping/orm/Apoderado.hbm.xml" />
<mapping resource="ormmapping/orm/Asignatura.hbm.xml" />
<mapping resource="ormmapping/orm/Asistencia.hbm.xml" />
<mapping resource="ormmapping/orm/Colegio.hbm.xml" />
<mapping resource="ormmapping/orm/Curso.hbm.xml" />
<mapping resource="ormmapping/orm/Estudiante.hbm.xml" />
<mapping resource="ormmapping/orm/Nota.hbm.xml" />
<mapping resource="ormmapping/orm/Profesor.hbm.xml" />
</session-factory>
</hibernate-configuration>

View File

@@ -0,0 +1,304 @@
<?xml version="1.0" encoding="UTF-8"?>
<Database>
<Setting type="512">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="1024">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="131072">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="128">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="32">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="16384">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="2048">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="262144">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="256">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="65536">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="64">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="16">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="8192">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="32768">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="8">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="4096">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="33554432">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="524288">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="16777216">
<Driver></Driver>
<DriverFiles></DriverFiles>
<Dialect></Dialect>
<DriverClass></DriverClass>
<URL></URL>
<UserName></UserName>
<EncryptedPassword>32F3ACE632ECEBAFB24DCAF99A8C6CDC</EncryptedPassword>
<HostName></HostName>
<PortNO></PortNO>
<DBName></DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
<Setting type="2">
<Driver>MySQL (Connector/J Driver)</Driver>
<DriverFiles>&lt;&lt;MySQL Connector/J 5.1.33&gt;&gt;</DriverFiles>
<Dialect>org.hibernate.dialect.MySQLDialect</Dialect>
<DriverClass>com.mysql.jdbc.Driver</DriverClass>
<URL>jdbc:mysql://localhost:3306/colegio</URL>
<UserName>root</UserName>
<EncryptedPassword>AC56CC10CDF6B07FCCD3D10F3C1884D2</EncryptedPassword>
<HostName>localhost</HostName>
<PortNO>3306</PortNO>
<DBName>colegio</DBName>
<ServiceName></ServiceName>
<ServerName></ServerName>
<SelectedForm>true</SelectedForm>
</Setting>
</Database>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Licensee: Universidad de La Frontera License Type: Academic -->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="orm.Actividad" table="actividad" lazy="false">
<id name="id_pk" column="id_pk" type="integer" unsaved-value="0">
<generator class="increment">
</generator>
</id>
<many-to-one name="asignatura_id_fk" cascade="lock"
column="asignatura_id_fk" class="orm.Asignatura" not-null="true"
lazy="no-proxy" access="field">
</many-to-one>
<property name="fecha" column="fecha" type="date" not-null="false"
lazy="false" />
<property name="tipo" column="tipo" type="string" length="100"
not-null="false" lazy="false" />
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Licensee: Universidad de La Frontera License Type: Academic -->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="orm.Anotacion" table="anotacion" lazy="false">
<id name="id_pk" column="id_pk" type="integer" unsaved-value="0">
<generator class="increment">
</generator>
</id>
<many-to-one name="estudiante_id_fk" cascade="lock"
column="estudiante_id_fk" class="orm.Estudiante" not-null="true"
lazy="no-proxy" access="field">
</many-to-one>
<many-to-one name="profesor_id_fk" cascade="lock"
column="profesor_id_fk" class="orm.Profesor" not-null="true" lazy="no-proxy"
access="field">
</many-to-one>
<property name="descripcion" column="descripcion" type="string"
length="100" not-null="false" lazy="false" />
<property name="positiva" column="positiva" type="boolean"
length="1" not-null="false" lazy="false" />
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Licensee: Universidad de La Frontera License Type: Academic -->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="orm.Apoderado" table="apoderado" lazy="false">
<id name="id_pk" column="id_pk" type="integer" unsaved-value="0">
<generator class="increment">
</generator>
</id>
<many-to-one name="colegio_id_fk" cascade="lock" column="colegio_id_fk"
class="orm.Colegio" not-null="true" lazy="no-proxy" access="field">
</many-to-one>
<property name="nombre" column="nombre" type="string" length="100"
not-null="false" lazy="false" />
<property name="rut" column="rut" type="string" length="100"
not-null="false" lazy="false" />
<set name="ORM_Estudiante" lazy="true" cascade="save-update,lock"
inverse="true">
<key column="apoderado_id_fk" not-null="true" />
<one-to-many class="orm.Estudiante" />
</set>
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Licensee: Universidad de La Frontera License Type: Academic -->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="orm.Asignatura" table="asignatura" lazy="false">
<id name="id_pk" column="id_pk" type="integer" unsaved-value="0">
<generator class="increment">
</generator>
</id>
<many-to-one name="curso_id_fk" cascade="lock" column="curso_id_fk"
class="orm.Curso" not-null="true" lazy="no-proxy" access="field">
</many-to-one>
<many-to-one name="profesor_id_fk" cascade="lock"
column="profesor_id_fk" class="orm.Profesor" not-null="true" lazy="no-proxy"
access="field">
</many-to-one>
<property name="nombre" column="nombre" type="string" length="100"
not-null="false" lazy="false" />
<set name="ORM_Actividad" lazy="true" cascade="save-update,lock"
inverse="true">
<key column="asignatura_id_fk" not-null="true" />
<one-to-many class="orm.Actividad" />
</set>
<set name="ORM_Nota" lazy="true" cascade="save-update,lock"
inverse="true">
<key column="asignatura_id_fk" not-null="true" />
<one-to-many class="orm.Nota" />
</set>
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Licensee: Universidad de La Frontera License Type: Academic -->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="orm.Asistencia" table="asistencia" lazy="false">
<id name="id_pk" column="id_pk" type="integer" unsaved-value="0">
<generator class="increment">
</generator>
</id>
<many-to-one name="estudiante_id_fk" cascade="lock"
column="estudiante_id_fk" class="orm.Estudiante" not-null="true"
lazy="no-proxy" access="field">
</many-to-one>
<property name="dia" column="dia" type="date" not-null="false"
lazy="false" />
<property name="asistio" column="asistio" type="boolean"
length="1" not-null="false" lazy="false" />
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Licensee: Universidad de La Frontera License Type: Academic -->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="orm.Colegio" table="colegio" lazy="false">
<id name="id_pk" column="id_pk" type="integer" unsaved-value="0">
<generator class="increment">
</generator>
</id>
<property name="nombre" column="nombre" type="string" length="100"
not-null="false" lazy="false" />
<set name="ORM_Curso" lazy="true" cascade="save-update,lock"
inverse="true">
<key column="colegio_id_fk" not-null="true" />
<one-to-many class="orm.Curso" />
</set>
<set name="ORM_Apoderado" lazy="true" cascade="save-update,lock"
inverse="true">
<key column="colegio_id_fk" not-null="true" />
<one-to-many class="orm.Apoderado" />
</set>
<set name="ORM_Profesor" lazy="true" cascade="save-update,lock"
inverse="true">
<key column="colegio_id_fk" not-null="true" />
<one-to-many class="orm.Profesor" />
</set>
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Licensee: Universidad de La Frontera License Type: Academic -->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="orm.Curso" table="curso" lazy="false">
<id name="id_pk" column="id_pk" type="integer" unsaved-value="0">
<generator class="increment">
</generator>
</id>
<many-to-one name="colegio_id_fk" cascade="lock" column="colegio_id_fk"
class="orm.Colegio" not-null="true" lazy="no-proxy" access="field">
</many-to-one>
<property name="nivel" column="nivel" type="integer" length="10"
not-null="false" lazy="false" />
<property name="letra" column="letra" type="string" length="1"
not-null="false" lazy="false" />
<set name="ORM_Asignatura" lazy="true" cascade="save-update,lock"
inverse="true">
<key column="curso_id_fk" not-null="true" />
<one-to-many class="orm.Asignatura" />
</set>
<set name="ORM_Estudiante" lazy="true" cascade="save-update,lock"
inverse="true">
<key column="curso_id_fk" not-null="true" />
<one-to-many class="orm.Estudiante" />
</set>
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Licensee: Universidad de La Frontera License Type: Academic -->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="orm.Estudiante" table="estudiante" lazy="false">
<id name="id_pk" column="id_pk" type="integer" unsaved-value="0">
<generator class="increment">
</generator>
</id>
<many-to-one name="curso_id_fk" cascade="lock" column="curso_id_fk"
class="orm.Curso" not-null="true" lazy="no-proxy" access="field">
</many-to-one>
<many-to-one name="apoderado_id_fk" cascade="lock"
column="apoderado_id_fk" class="orm.Apoderado" not-null="true" lazy="no-proxy"
access="field">
</many-to-one>
<property name="nombre" column="nombre" type="string" length="100"
not-null="false" lazy="false" />
<property name="rut" column="rut" type="string" length="100"
not-null="false" lazy="false" />
<set name="ORM_Anotacion" lazy="true" cascade="save-update,lock"
inverse="true">
<key column="estudiante_id_fk" not-null="true" />
<one-to-many class="orm.Anotacion" />
</set>
<set name="ORM_Nota" lazy="true" cascade="save-update,lock"
inverse="true">
<key column="estudiante_id_fk" not-null="true" />
<one-to-many class="orm.Nota" />
</set>
<set name="ORM_Asistencia" lazy="true" cascade="save-update,lock"
inverse="true">
<key column="estudiante_id_fk" not-null="true" />
<one-to-many class="orm.Asistencia" />
</set>
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Licensee: Universidad de La Frontera License Type: Academic -->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="orm.Nota" table="nota" lazy="false">
<id name="id_pk" column="id_pk" type="integer" unsaved-value="0">
<generator class="increment">
</generator>
</id>
<many-to-one name="estudiante_id_fk" cascade="lock"
column="estudiante_id_fk" class="orm.Estudiante" not-null="true"
lazy="no-proxy" access="field">
</many-to-one>
<many-to-one name="asignatura_id_fk" cascade="lock"
column="asignatura_id_fk" class="orm.Asignatura" not-null="true"
lazy="no-proxy" access="field">
</many-to-one>
<property name="valor" column="valor" type="double" not-null="false"
lazy="false" />
</class>
</hibernate-mapping>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Licensee: Universidad de La Frontera License Type: Academic -->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="orm.Profesor" table="profesor" lazy="false">
<id name="id_pk" column="id_pk" type="integer" unsaved-value="0">
<generator class="increment">
</generator>
</id>
<many-to-one name="colegio_id_fk" cascade="lock" column="colegio_id_fk"
class="orm.Colegio" not-null="true" lazy="no-proxy" access="field">
</many-to-one>
<property name="nombre" column="nombre" type="string" length="100"
not-null="false" lazy="false" />
<property name="rut" column="rut" type="string" length="100"
not-null="false" lazy="false" />
<set name="ORM_Asignatura" lazy="true" cascade="save-update,lock"
inverse="true">
<key column="profesor_id_fk" not-null="true" />
<one-to-many class="orm.Asignatura" />
</set>
<set name="ORM_Anotacion" lazy="true" cascade="save-update,lock"
inverse="true">
<key column="profesor_id_fk" not-null="true" />
<one-to-many class="orm.Anotacion" />
</set>
</class>
</hibernate-mapping>