/**
  * Eliminar un Estudiante Dado el $estudianteId
  *
  * @param $estudianteId
  */
 public function removeEstudiante($estudianteId)
 {
     $objetoPerdidoBean = new ObjetoPerdidoBean($this->persistenceManager);
     $prestamoBean = new PrestamoBean($this->persistenceManager);
     $impresionBean = new ImpresionBean($this->persistenceManager);
     $monitorBean = new MonitorBean($this->persistenceManager);
     $estudiante = new Estudiante();
     $estudiante->setId($estudianteId);
     # Validamos los campos
     if (!EntityValidator::validateId($estudianteId)) {
         throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 148);
     }
     # Verificamos que la entidad exista.
     if (!$this->estudianteBean->getEstudiante($estudiante)) {
         throw new Exception(SALAS_COMP_ALERT_E_ENTITY_NOT_FOUND_FAIL, $this->ID + 149);
     }
     # Verificamos que la entidad no esté siendo utilziada en alguna otra.
     # Verificamos que la entidad no esté siendo utilziada en ObjetoPerdido->objetoPerdidoEstudiante
     $objetoPerdidos = $objetoPerdidoBean->getObjetoPerdidosByObjetoPerdidoEstudiante($estudiante);
     if (count($objetoPerdidos) > 0) {
         throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_LINKED_FAIL, $this->ID + 144);
     }
     # Verificamos que la entidad no esté siendo utilziada en Prestamo->prestamoEstudiante
     $prestamos = $prestamoBean->getPrestamosByPrestamoEstudiante($estudiante);
     if (count($prestamos) > 0) {
         throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_LINKED_FAIL, $this->ID + 145);
     }
     # Verificamos que la entidad no esté siendo utilziada en Impresion->impresionEstudiante
     $impresions = $impresionBean->getImpresionsByImpresionEstudiante($estudiante);
     if (count($impresions) > 0) {
         throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_LINKED_FAIL, $this->ID + 146);
     }
     # Verificamos que la entidad no esté siendo utilziada en Monitor->monitorEstudiante
     $monitors = $monitorBean->getMonitorsByMonitorEstudiante($estudiante);
     if (count($monitors) > 0) {
         throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_LINKED_FAIL, $this->ID + 147);
     }
     # Eliminamos la entidad
     if (!$this->estudianteBean->removeEstudiante($estudiante)) {
         throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_FAIL, $this->ID + 150);
     }
 }
 /**
  * Listar algunos Prestamo dado el $prestamoEstudianteId
  * 
  * @param $prestamoEstudianteId
  * @param $performSize
  * @param $firstResultNumber
  * @param $numResults
  */
 public function listPrestamosByPrestamoEstudianteId($prestamoEstudianteId, $performSize = false, $firstResultNumber = null, $numResults = null, $orderBy = null, $orderPriority = SQL_ASCENDING_ORDER)
 {
     $objBean = new EstudianteBean($this->persistenceManager);
     $obj = new Estudiante();
     $obj->setId($prestamoEstudianteId);
     # Validamos los campos
     if ($firstResultNumber !== null && !EntityValidator::validatePositiveNumber($firstResultNumber)) {
         throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 103);
     }
     if (!EntityValidator::validateGlobalOrderPriority($orderPriority)) {
         throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 105);
     }
     if (!EntityValidator::validateId($prestamoEstudianteId)) {
         throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 107);
     }
     # Verificamos que la entidad exista
     if (!$objBean->getEstudiante($obj)) {
         throw new Exception(SALAS_COMP_ALERT_E_ENTITY_NOT_FOUND_FAIL, $this->ID + 109);
     }
     # Listamos las entidades
     if ($performSize) {
         $this->lastRequestSize = $this->prestamoBean->countGetPrestamosByPrestamoEstudiante($obj);
     }
     return PrestamoDTO::loadFromEntities($this->prestamoBean->listPrestamosByPrestamoEstudiante($obj, $firstResultNumber, $numResults, $orderBy, $orderPriority));
 }
Ejemplo n.º 3
0
 public static function toEntity(EstudianteDTO $estudianteDTO)
 {
     $estudiante = new Estudiante();
     $estudiante->setId($estudianteDTO->getId());
     $estudiante->setEstudianteCodigo($estudianteDTO->getEstudianteCodigo());
     $estudiante->setEstudianteFacultad($estudianteDTO->getEstudianteFacultad());
     $estudiante->setEstudianteCarrerra($estudianteDTO->getEstudianteCarrerra());
     $estudiante->setEstudiantePersona($estudianteDTO->getEstudiantePersona());
     return $estudiante;
 }