/**
  * Listar algunos Prestamo dado el $prestamoComputadoraId
  * 
  * @param $prestamoComputadoraId
  * @param $performSize
  * @param $firstResultNumber
  * @param $numResults
  */
 public function listPrestamosByPrestamoComputadoraId($prestamoComputadoraId, $performSize = false, $firstResultNumber = null, $numResults = null, $orderBy = null, $orderPriority = SQL_ASCENDING_ORDER)
 {
     $objBean = new ComputadoraBean($this->persistenceManager);
     $obj = new Computadora();
     $obj->setId($prestamoComputadoraId);
     # 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($prestamoComputadoraId)) {
         throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 115);
     }
     # Verificamos que la entidad exista
     if (!$objBean->getComputadora($obj)) {
         throw new Exception(SALAS_COMP_ALERT_E_ENTITY_NOT_FOUND_FAIL, $this->ID + 117);
     }
     # Listamos las entidades
     if ($performSize) {
         $this->lastRequestSize = $this->prestamoBean->countGetPrestamosByPrestamoComputadora($obj);
     }
     return PrestamoDTO::loadFromEntities($this->prestamoBean->listPrestamosByPrestamoComputadora($obj, $firstResultNumber, $numResults, $orderBy, $orderPriority));
 }
Пример #2
0
 public static function loadFromXML($xmlDaos)
 {
     $daos = array();
     $doc = new DOMDocument('1.0', 'utf-8');
     $doc->loadXML($xmlDaos);
     $nodes = $doc->getElementsByTagName("Prestamo");
     foreach ($nodes as $node) {
         $dao = new PrestamoDTO();
         $data = $node->getElementsByTagName("Prestamo_Id");
         if ($data->length > 0) {
             $data = $data->item(0)->nodeValue;
         } else {
             $data = null;
         }
         $dao->setId($data);
         $data = $node->getElementsByTagName("prestamoEntrada");
         if ($data->length > 0 && !PrestamoDTO::isEmpty($data->item(0)->nodeValue)) {
             $data = $data->item(0)->nodeValue;
         } else {
             $data = null;
         }
         $dao->setPrestamoEntrada($data);
         $data = $node->getElementsByTagName("prestamoSalida");
         if ($data->length > 0 && !PrestamoDTO::isEmpty($data->item(0)->nodeValue)) {
             $data = $data->item(0)->nodeValue;
         } else {
             $data = null;
         }
         $dao->setPrestamoSalida($data);
         $data = $node->getElementsByTagName("prestamoComentarios");
         if ($data->length > 0 && !PrestamoDTO::isEmpty($data->item(0)->nodeValue)) {
             $data = $data->item(0)->nodeValue;
         } else {
             $data = null;
         }
         $dao->setPrestamoComentarios($data);
         $data = $node->getElementsByTagName("prestamoEstudiante");
         if ($data->length > 0 && !empty($data->item(0)->nodeValue)) {
             $data = $data->item(0)->nodeValue;
         } else {
             $data = null;
         }
         $dao->setPrestamoEstudiante($data);
         $data = $node->getElementsByTagName("prestamoComputadora");
         if ($data->length > 0 && !empty($data->item(0)->nodeValue)) {
             $data = $data->item(0)->nodeValue;
         } else {
             $data = null;
         }
         $dao->setPrestamoComputadora($data);
         $daos[] = $dao;
     }
     return $daos;
 }
Пример #3
0
 public function toDTO()
 {
     $prestamoDTO = new PrestamoDTO();
     $prestamoDTO->setId($this->getId());
     $prestamoDTO->setPrestamoEntrada($this->unscapeString($this->getPrestamoEntrada()));
     $prestamoDTO->setPrestamoSalida($this->unscapeString($this->getPrestamoSalida()));
     $prestamoDTO->setPrestamoComentarios($this->unscapeString($this->getPrestamoComentarios()));
     $prestamoDTO->setPrestamoEstudiante($this->unscapeString($this->getPrestamoEstudiante()));
     $prestamoDTO->setPrestamoComputadora($this->unscapeString($this->getPrestamoComputadora()));
     return $prestamoDTO;
 }
 public function updatePrestamo($prestamoDTO)
 {
     try {
         $ctrl = new PrestamoController($this->persistenceManager);
         $prestamo = new PrestamoDTO();
         $prestamo->setId($prestamoDTO->getId());
         $ctrl->getPrestamo($prestamo);
         $prestamo->setPrestamoEntrada($prestamoDTO->getPrestamoEntrada());
         $prestamo->setPrestamoSalida($prestamoDTO->getPrestamoSalida());
         $prestamo->setPrestamoComentarios($prestamoDTO->getPrestamoComentarios());
         $prestamo->setPrestamoComputadora($prestamoDTO->getPrestamoComputadora());
         $ctrl->updatePrestamo($prestamo);
         $cm = new CommunicationMensaje(true, SALAS_COMP_ALERT_A_OPERATION_SUCCESS, $this->ID + 67, $prestamo);
         return $cm;
     } catch (Exception $e) {
         return new CommunicationMensaje(false, $e->getMessage(), $this->ID + 68 . "->" . $e->getCode());
     }
 }