public static function toEntity(SalonDTO $salonDTO) { $salon = new Salon(); $salon->setId($salonDTO->getId()); $salon->setSalonNombre($salonDTO->getSalonNombre()); return $salon; }
/** * Listar algunos Reserva dado el $reservaSalonId * * @param $reservaSalonId * @param $performSize * @param $firstResultNumber * @param $numResults */ public function listReservasByReservaSalonId($reservaSalonId, $performSize = false, $firstResultNumber = null, $numResults = null, $orderBy = null, $orderPriority = SQL_ASCENDING_ORDER) { $objBean = new SalonBean($this->persistenceManager); $obj = new Salon(); $obj->setId($reservaSalonId); # Validamos los campos if ($firstResultNumber !== null && !EntityValidator::validatePositiveNumber($firstResultNumber)) { throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 111); } if (!EntityValidator::validateGlobalOrderPriority($orderPriority)) { throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 113); } if (!EntityValidator::validateId($reservaSalonId)) { throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 115); } # Verificamos que la entidad exista if (!$objBean->getSalon($obj)) { throw new Exception(SALAS_COMP_ALERT_E_ENTITY_NOT_FOUND_FAIL, $this->ID + 117); } # Listamos las entidades if ($performSize) { $this->lastRequestSize = $this->reservaBean->countGetReservasByReservaSalon($obj); } return ReservaDTO::loadFromEntities($this->reservaBean->listReservasByReservaSalon($obj, $firstResultNumber, $numResults, $orderBy, $orderPriority)); }
/** * Eliminar un Salon Dado el $salonId * * @param $salonId */ public function removeSalon($salonId) { $objetoEnInventarioBean = new ObjetoEnInventarioBean($this->persistenceManager); $objetoPerdidoBean = new ObjetoPerdidoBean($this->persistenceManager); $monitorSalonBean = new MonitorSalonBean($this->persistenceManager); $reservaBean = new ReservaBean($this->persistenceManager); $salon = new Salon(); $salon->setId($salonId); # Validamos los campos if (!EntityValidator::validateId($salonId)) { throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 54); } # Verificamos que la entidad exista. if (!$this->salonBean->getSalon($salon)) { throw new Exception(SALAS_COMP_ALERT_E_ENTITY_NOT_FOUND_FAIL, $this->ID + 55); } # Verificamos que la entidad no esté siendo utilziada en alguna otra. # Verificamos que la entidad no esté siendo utilziada en ObjetoEnInventario->inventarioSalon $objetoEnInventarios = $objetoEnInventarioBean->getObjetoEnInventariosByInventarioSalon($salon); if (count($objetoEnInventarios) > 0) { throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_LINKED_FAIL, $this->ID + 50); } # Verificamos que la entidad no esté siendo utilziada en ObjetoPerdido->objetoPerdidoSalon $objetoPerdidos = $objetoPerdidoBean->getObjetoPerdidosByObjetoPerdidoSalon($salon); if (count($objetoPerdidos) > 0) { throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_LINKED_FAIL, $this->ID + 51); } # Verificamos que la entidad no esté siendo utilziada en MonitorSalon->salon $monitorSalons = $monitorSalonBean->getMonitorSalonsBySalon($salon); if (count($monitorSalons) > 0) { throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_LINKED_FAIL, $this->ID + 52); } # Verificamos que la entidad no esté siendo utilziada en Reserva->reservaSalon $reservas = $reservaBean->getReservasByReservaSalon($salon); if (count($reservas) > 0) { throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_LINKED_FAIL, $this->ID + 53); } # Eliminamos la entidad if (!$this->salonBean->removeSalon($salon)) { throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_FAIL, $this->ID + 56); } }