public function findAll() { $reponse = $this->db->query(self::FIND_ALL); $responsables = array(); while ($data = $reponse->fetch()) { $responsable = new Responsable(); $responsable->setId($data['NUMERO_RESPONSABLE']); $responsable->setPrenom($data['PRENOM_RESPONSABLE']); $responsable->setNom($data['NOM_RESPONSABLE']); $responsable->setFonction($data['FONCTION']); array_push($responsables, $responsable); } $reponse->closeCursor(); return $responsables; }
/** * Eliminar un Responsable Dado el $responsableId * * @param $responsableId */ public function removeResponsable($responsableId) { $reservaBean = new ReservaBean($this->persistenceManager); $responsable = new Responsable(); $responsable->setId($responsableId); # Validamos los campos if (!EntityValidator::validateId($responsableId)) { throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 103); } # Verificamos que la entidad exista. if (!$this->responsableBean->getResponsable($responsable)) { throw new Exception(SALAS_COMP_ALERT_E_ENTITY_NOT_FOUND_FAIL, $this->ID + 104); } # Verificamos que la entidad no esté siendo utilziada en alguna otra. # Verificamos que la entidad no esté siendo utilziada en Reserva->reservaResponsable $reservas = $reservaBean->getReservasByReservaResponsable($responsable); if (count($reservas) > 0) { throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_LINKED_FAIL, $this->ID + 102); } # Eliminamos la entidad if (!$this->responsableBean->removeResponsable($responsable)) { throw new Exception(SALAS_COMP_ALERT_E_PERSISTENCE_REMOVE_FAIL, $this->ID + 105); } }
/** * Listar algunos Reserva dado el $reservaResponsableId * * @param $reservaResponsableId * @param $performSize * @param $firstResultNumber * @param $numResults */ public function listReservasByReservaResponsableId($reservaResponsableId, $performSize = false, $firstResultNumber = null, $numResults = null, $orderBy = null, $orderPriority = SQL_ASCENDING_ORDER) { $objBean = new ResponsableBean($this->persistenceManager); $obj = new Responsable(); $obj->setId($reservaResponsableId); # 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($reservaResponsableId)) { throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 107); } # Verificamos que la entidad exista if (!$objBean->getResponsable($obj)) { throw new Exception(SALAS_COMP_ALERT_E_ENTITY_NOT_FOUND_FAIL, $this->ID + 109); } # Listamos las entidades if ($performSize) { $this->lastRequestSize = $this->reservaBean->countGetReservasByReservaResponsable($obj); } return ReservaDTO::loadFromEntities($this->reservaBean->listReservasByReservaResponsable($obj, $firstResultNumber, $numResults, $orderBy, $orderPriority)); }
public static function toEntity(ResponsableDTO $responsableDTO) { $responsable = new Responsable(); $responsable->setId($responsableDTO->getId()); $responsable->setResponsableFacultad($responsableDTO->getResponsableFacultad()); $responsable->setResponsableAsignatura($responsableDTO->getResponsableAsignatura()); $responsable->setResponsablePersona($responsableDTO->getResponsablePersona()); return $responsable; }