public function retornaSoftwaresComId()
 {
     $sql = "SELECT * FROM software ORDER BY id_software DESC LIMIT 10";
     $result = $this->conexao->query($sql);
     foreach ($result as $linha) {
         $software = new Software();
         $software->setNome($linha['nome']);
         $software->setLinguagem($linha['linguagem']);
         $software->setId($linha['id_software']);
         $softwares[] = $software;
     }
     if (isset($softwares)) {
         return $softwares;
     } else {
         return null;
     }
 }
Esempio n. 2
0
 public static function toEntity(SoftwareDTO $softwareDTO)
 {
     $software = new Software();
     $software->setId($softwareDTO->getId());
     $software->setSoftwareNumeroSerie($softwareDTO->getSoftwareNumeroSerie());
     $software->setSoftwareNombre($softwareDTO->getSoftwareNombre());
     $software->setSoftwareVersion($softwareDTO->getSoftwareVersion());
     $software->setSoftwareFechaCaducidad($softwareDTO->getSoftwareFechaCaducidad());
     $software->setSoftwareFechaAquisicion($softwareDTO->getSoftwareFechaAquisicion());
     $software->setSoftwareEquiposPermitidos($softwareDTO->getSoftwareEquiposPermitidos());
     $software->setSoftwareComentarios($softwareDTO->getSoftwareComentarios());
     return $software;
 }
<body>

	<div id="topo">
		<img src="images/logo.png" alt="" />
	</div>

	<div id="conteiner">
		<?php 
if ($_GET['idsoftware']) {
    // vou fechar isso lá no final
    $_SESSION['meuSoftwareId'] = $_GET['idsoftware'];
    $conexao = Conexao::retornaConexaoComBanco();
    $softwaredao = new SoftwareDAO();
    $softwaredao->setConexao($conexao);
    $software = new Software();
    $software->setId($_GET['idsoftware']);
    $software = $softwaredao->retornaSoftwareDetalhado($software);
    ?>
	
				
		<div id="esquerda">

			<?php 
    echo '<h1>' . $software->getNome() . '</h1>';
    echo '<h2>Informações:</h2>
				<p>Linguagem: ' . $software->getLinguagem();
    if ($software->getBancoDeDados()) {
        echo '; Banco: ' . $software->getBancoDeDados()->getSistemaGerenciadorDeBancoDeDados() . '</p>';
    }
    ?>
 
	<div id="conteiner">
		
		<div id="esquerda">
			<?php 
if ($_SESSION['meuSoftwareId'] && $_POST['nomedoatributo']) {
    $atributo = new Atributo();
    $atributo->setNome($_POST['nomedoatributo']);
    $atributo->setTipo($_POST['tipodeatributo']);
    $atributo->setIndice($_POST['indice']);
    $atributo->setTipoDeRelacionamentoComObjeto($_POST['relacionamento_com_outro_tipo']);
    $objeto = new Objeto();
    $objeto->setId($_POST['objeto']);
    $objeto->addAtributo($atributo);
    $software = new Software();
    $software->setId($_SESSION['meuSoftwareId']);
    $software->addObjetoNaLista($objeto);
    $conexao = Conexao::retornaConexaoComBanco();
    $atributodao = new AtributoDAO();
    $atributodao->setConexao($conexao);
    if ($atributodao->inserir($objeto, $atributo)) {
        echo "Atributo Inserido Com sucesso!";
        echo '<META HTTP-EQUIV="REFRESH" CONTENT="0; URL=software.php?idsoftware=' . $_SESSION['meuSoftwareId'] . '">';
    } else {
        echo "Atributo Não Inserido";
        echo '<META HTTP-EQUIV="REFRESH" CONTENT="0; URL=software.php?idsoftware=' . $_SESSION['meuSoftwareId'] . '">';
    }
}
?>

			
 /**
  * Listar algunos ComputadoraSoftware dado el $softwareId
  * 
  * @param $softwareId
  * @param $performSize
  * @param $firstResultNumber
  * @param $numResults
  */
 public function listComputadoraSoftwaresBySoftwareId($softwareId, $performSize = false, $firstResultNumber = null, $numResults = null, $orderBy = null, $orderPriority = SQL_ASCENDING_ORDER)
 {
     $objBean = new SoftwareBean($this->persistenceManager);
     $obj = new Software();
     $obj->setId($softwareId);
     # Validamos los campos
     if ($firstResultNumber !== null && !EntityValidator::validatePositiveNumber($firstResultNumber)) {
         throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 105);
     }
     if (!EntityValidator::validateGlobalOrderPriority($orderPriority)) {
         throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 107);
     }
     if (!EntityValidator::validateId($softwareId)) {
         throw new Exception(SALAS_COMP_ALERT_E_VALIDATION_FAIL, $this->ID + 109);
     }
     # Verificamos que la entidad exista
     if (!$objBean->getSoftware($obj)) {
         throw new Exception(SALAS_COMP_ALERT_E_ENTITY_NOT_FOUND_FAIL, $this->ID + 111);
     }
     # Listamos las entidades
     if ($performSize) {
         $this->lastRequestSize = $this->computadoraSoftwareBean->countGetComputadoraSoftwaresBySoftware($obj);
     }
     return ComputadoraSoftwareDTO::loadFromEntities($this->computadoraSoftwareBean->listComputadoraSoftwaresBySoftware($obj, $firstResultNumber, $numResults, $orderBy, $orderPriority));
 }
 /**
  * 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);
     }
 }