/** * Eliminar un Computadora Dado el $computadoraId * * @param $computadoraId */ public function removeComputadora($computadoraId) { $computadoraSoftwareBean = new ComputadoraSoftwareBean($this->persistenceManager); $prestamoBean = new PrestamoBean($this->persistenceManager); $objetoEnInventarioBean = new ObjetoEnInventarioBean($this->persistenceManager); $computadora = new Computadora(); $computadora->setId($computadoraId); # Validamos los campos if (!EntityValidator::validateId($computadoraId)) { throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 271); } # Verificamos que la entidad exista. if (!$this->computadoraBean->getComputadora($computadora)) { throw new Exception(SALAS_COMP_ALERT_E_ENTITY_NOT_FOUND_FAIL, $this->ID + 272); } # Verificamos que la entidad no esté siendo utilziada en alguna otra. # Verificamos que la entidad no esté siendo utilziada en ComputadoraSoftware->computadora $computadoraSoftwares = $computadoraSoftwareBean->getComputadoraSoftwaresByComputadora($computadora); if (count($computadoraSoftwares) > 0) { throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_LINKED_FAIL, $this->ID + 268); } # Verificamos que la entidad no esté siendo utilziada en Prestamo->prestamoComputadora $prestamos = $prestamoBean->getPrestamosByPrestamoComputadora($computadora); if (count($prestamos) > 0) { throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_LINKED_FAIL, $this->ID + 269); } # Verificamos que no esté relacionada con ObjetoEnInventario $objetoEnInventarios = $objetoEnInventarioBean->getObjetoEnInventariosByComputadora($computadora); if (count($objetoEnInventarios) > 0) { throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_LINKED_FAIL, $this->ID + 270); } # Eliminamos la entidad if (!$this->computadoraBean->removeComputadora($computadora)) { throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_FAIL, $this->ID + 273); } }
/** * Eliminar un Software Dado el $softwareId * * @param $softwareId */ public function removeSoftware($softwareId) { $computadoraSoftwareBean = new ComputadoraSoftwareBean($this->persistenceManager); $software = new Software(); $software->setId($softwareId); # Validamos los campos if (!EntityValidator::validateId($softwareId)) { throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 249); } # Verificamos que la entidad exista. if (!$this->softwareBean->getSoftware($software)) { throw new Exception(SALAS_COMP_ALERT_E_ENTITY_NOT_FOUND_FAIL, $this->ID + 250); } # Verificamos que la entidad no esté siendo utilziada en alguna otra. # Verificamos que la entidad no esté siendo utilziada en ComputadoraSoftware->software $computadoraSoftwares = $computadoraSoftwareBean->getComputadoraSoftwaresBySoftware($software); if (count($computadoraSoftwares) > 0) { throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_LINKED_FAIL, $this->ID + 248); } # Eliminamos la entidad if (!$this->softwareBean->removeSoftware($software)) { throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_FAIL, $this->ID + 251); } }