Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List listarPlanClase(String idAnoLectivo, String idMes, String idAsignaturaGrado, String idDocente, String idCurso) {
- IDefinitionConnection con = null;
- List listaSemanasPeriodo = new ArrayList();
- List listaDias = new ArrayList();
- PlanClaseDAO planClaseDAO = null;
- PlanClaseDiaDAO planClaseDiaDAO = null;
- PlanClaseVO planClaseVO = null;
- PlanClaseDiaVO planClaseDiaVO = null;
- Map mapaParametros = new HashMap();
- mapaParametros.put("idAnoLectivo", idAnoLectivo);
- mapaParametros.put("idMes", idMes);
- mapaParametros.put("idAsignaturaGrado", idAsignaturaGrado);
- mapaParametros.put("idDocente", idDocente);
- mapaParametros.put("idCurso", idCurso);
- try {
- con = new DefinitionConnectionAcademico();
- planClaseDAO = new PlanClaseDAO(con);
- planClaseDiaDAO = new PlanClaseDiaDAO(con);
- Object[] rangoFecha = null;
- Object[] rangoDia = null;
- int numeroSemana = 1;
- Calendar fechaInicio = Calendar.getInstance();
- fechaInicio.set(Integer.parseInt(idAnoLectivo), Integer.parseInt(idMes), 0);
- fechaInicio.set(fechaInicio.get(Calendar.YEAR),
- fechaInicio.get(Calendar.MONTH),
- fechaInicio.getActualMinimum(Calendar.DAY_OF_MONTH),
- 0,
- 0,
- 0);
- Calendar fechaFin = Calendar.getInstance();
- fechaFin.set(Integer.parseInt(idAnoLectivo), Integer.parseInt(idMes), 0);
- fechaFin.set(fechaFin.get(Calendar.YEAR),
- fechaFin.get(Calendar.MONTH),
- fechaFin.getActualMaximum(Calendar.DAY_OF_MONTH),
- 0,
- 0,
- 0);
- for (Calendar fecha = (Calendar) fechaInicio.clone(); (fecha.before(fechaFin) || fecha.equals(fechaFin)); fecha.add(Calendar.DATE, 7)) {
- rangoFecha = new Object[5];
- Calendar fechaInicioSemana = Format.parseCalendar(UtilFecha.obtenerInicioSemana(fecha, Constantes.FORMATO_D_M_Y), Constantes.FORMATO_D_M_Y);
- //fecha del inicio de la semana
- rangoFecha[0] = fechaInicioSemana;
- Calendar fechafinSemana = Format.parseCalendar(UtilFecha.obtenerInicioSemana(fecha, Constantes.FORMATO_D_M_Y), Constantes.FORMATO_D_M_Y);
- fechafinSemana.add(Calendar.DATE, 5);
- //fecha del fin de semana
- rangoFecha[1] = fechafinSemana;
- /*Calendar fechaCalculoSemana = (Calendar) fecha.clone();
- fechaCalculoSemana.setMinimalDaysInFirstWeek(1);
- numeroSemana = fechaCalculoSemana.get(Calendar.WEEK_OF_MONTH);
- **/
- mapaParametros.put("numeroSemana", numeroSemana);
- planClaseVO = (PlanClaseVO) planClaseDAO.consultar(mapaParametros);
- if (planClaseVO == null) {
- planClaseVO = new PlanClaseVO();
- planClaseVO.setIdDocente(idDocente);
- planClaseVO.setIdAsignaturaGrado(idAsignaturaGrado);
- planClaseVO.setIdAnoLectivo(idAnoLectivo);
- planClaseVO.setIdCurso(idCurso);
- planClaseVO.setIdMes(idMes);
- planClaseVO.setSemana(String.valueOf(numeroSemana));
- }
- for (Calendar fechaDia = (Calendar) fechaInicioSemana.clone(); fechaDia.before((Calendar) fechafinSemana.clone()); fechaDia.add(Calendar.DATE, 1)) {
- if (UtilFecha.obtenerNumeroDiaSemana(fechaDia, Format.printString("Horario")) != 6 && UtilFecha.obtenerNumeroDiaSemana(fechaDia, Format.printString("Horario")) != 7) {
- if (UtilFecha.mayorIgualQue(fechaDia, fechaInicio) && UtilFecha.menorIgualQue(fechaDia, fechaFin)) {
- rangoDia = new Object[6];
- //día
- rangoDia[0] = Format.lPad(String.valueOf(fechaDia.get(Calendar.DATE)), 2, '0');
- //fecha del día
- rangoDia[1] = Format.formatCalendar(fechaDia, Constantes.FORMATO_D_M_Y);
- //numero del día
- rangoDia[2] = String.valueOf(UtilFecha.obtenerNumeroDiaSemana(fechaDia, Format.printString("Horario")));
- //habilitado
- rangoDia[3] = "";
- if (!Format.isEmptyString(planClaseVO.getIdPlanClase())) {
- planClaseDiaVO = (PlanClaseDiaVO) planClaseDiaDAO.consultarPlanClaseDia(planClaseVO.getIdPlanClase(), fechaDia);
- } else {
- planClaseDiaVO = new PlanClaseDiaVO();
- planClaseDiaVO.setFecha((Calendar)fechaDia.clone());
- }
- //PlanClaseDia
- rangoDia[4] = planClaseDiaVO;
- //nombre día
- rangoDia[5] = UtilFecha.nombreDiaSemana(UtilFecha.obtenerNumeroDiaSemana(fechaDia, Format.printString("Calendar")));
- listaDias.add(rangoDia);
- } else {
- /*//fecha del día
- rangoDia[1] = Format.formatCalendar(fechaDia, Constantes.FORMATO_D_M_Y);
- //numero del día
- rangoDia[2] = String.valueOf(UtilFecha.obtenerNumeroDiaSemana(fechaDia, Format.printString("Horario")));
- //deshabilitado
- rangoDia[3] = "OFF";
- //PlanClaseDia
- rangoDia[4] = null;
- **/
- }
- }
- }
- //lista de los dias de la semana
- rangoFecha[2] = listaDias;
- // numero semana
- rangoFecha[3] = numeroSemana;
- //PlanClase
- rangoFecha[4] = planClaseVO;
- if(!listaDias.isEmpty()){
- numeroSemana++;
- listaSemanasPeriodo.add(rangoFecha);
- }
- listaDias = new ArrayList();
- }
- } catch (Exception e) {
- System.out.println(" :: Gnosoft :: MediadorHorarios :: listarPlanClase :: " + e.getMessage());
- e.printStackTrace();
- } finally {
- if (con != null) {
- con.close();
- }
- }
- return listaSemanasPeriodo;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement