PageRenderTime 28ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Ultra/ControlDocumentoBundle/Entity/Perfil.php

https://gitlab.com/hersan/ultra
PHP | 1158 lines | 461 code | 151 blank | 546 comment | 13 complexity | 8cbec2724f23546d56f43cd27f99c339 MD5 | raw file
  1. <?php
  2. namespace Ultra\ControlDocumentoBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use Symfony\Component\HttpFoundation\File\UploadedFile;
  6. use Symfony\Component\Filesystem\Filesystem;
  7. use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
  8. use Symfony\Component\Filesystem\Exception\IOException;
  9. /**
  10. * Perfil
  11. * @ORM\Table()
  12. * @ORM\Entity(repositoryClass="Ultra\ControlDocumentoBundle\Entity\PerfilRepository")
  13. * @ORM\HasLifecycleCallbacks
  14. */
  15. class Perfil
  16. {
  17. /**
  18. * @var integer
  19. *
  20. * @ORM\Column(name="id", type="integer")
  21. * @ORM\Id
  22. * @ORM\GeneratedValue(strategy="AUTO")
  23. */
  24. private $id;
  25. /**
  26. * @var String
  27. * @Assert\Regex(
  28. * pattern="/^\w[\w\d-]+/",
  29. * match=true,
  30. * message="La clave debe de comenzar con una letra, seguida de letras, numeros o guion"
  31. * )
  32. * @Assert\NotBlank(message = "Escriba una clave")
  33. * @ORM\Column(name="clave", type="string", length=50)
  34. */
  35. private $clave;
  36. /**
  37. * @var integer
  38. * @Assert\NotBlank(message="Proporcione la revisiĆ³n")
  39. * @Assert\Type(type="numeric", message="El valor {{ value }} no es de tipo {{ type }}.")
  40. * @ORM\Column(name="revision", type="integer")
  41. */
  42. private $revision;
  43. /**
  44. * @var string
  45. * @Assert\NotBlank(message="Escriba un titulo")
  46. * @Assert\Type(type="string", message="El valor {{ value }} no es de tipo {{ type }}.")
  47. * @ORM\Column(name="titulo", type="string", length=150)
  48. */
  49. private $titulo;
  50. /**
  51. * @var string
  52. * Assert\NotBlank(message="Este campo es requerido")
  53. * Assert\Type(type="string", message="El valor {{ value }} no es de tipo {{ type }}.")
  54. * @ORM\Column(name="titulo_corto", type="string", length=45, nullable=true)
  55. */
  56. private $tituloCorto;
  57. /**
  58. *
  59. * @Assert\NotBlank(message="Selecione una fecha")
  60. * @Assert\Date(message="Este valor no es una fecha")
  61. * @ORM\Column(name="aprobado", type="date")
  62. */
  63. private $aprobado;
  64. /**
  65. *
  66. * @Assert\NotBlank(message="Selecione una fecha")
  67. * @Assert\Date(message="Este valor no es una fecha")
  68. * @ORM\Column(name="vigencia", type="date")
  69. */
  70. private $vigencia;
  71. /**
  72. * @var \DateTime
  73. * @Assert\Date(message="El formato de fecha no es valido")
  74. * @ORM\Column(name="liberado", type="date", nullable=true)
  75. */
  76. private $liberado;
  77. /**
  78. * @var \DateTime
  79. * @Assert\Date(message="El formato de fecha no es valido")
  80. * @ORM\Column(name="transmitido", type="date")
  81. */
  82. private $transmitido;
  83. /**
  84. *
  85. * @ORM\Column(name="pdf", type="string", length=255, nullable=true)
  86. */
  87. private $pdf;
  88. /**
  89. * @var \Symfony\Component\HttpFoundation\File\UploadedFile
  90. *
  91. * @Assert\File(maxSize = "10M", mimeTypes = {
  92. * "application/pdf",
  93. * "application/x-pdf"
  94. * })
  95. */
  96. private $file;
  97. /**
  98. *
  99. * @ORM\Column(name="doc", type="string", length=255, nullable=true)
  100. */
  101. private $doc;
  102. /**
  103. * @var \DateTime
  104. *
  105. * @ORM\Column(name="fecha_uad", type="date", nullable=true, options={"default" = null})
  106. */
  107. private $fechaUad;
  108. /**
  109. * @var
  110. *
  111. * @ORM\Column(name="creado", type="date", nullable=true)
  112. */
  113. private $creado;
  114. /**
  115. * @var
  116. *
  117. * @ORM\Column(name="actualizado", type="date", nullable=true)
  118. */
  119. private $actualizado;
  120. /**
  121. * @var integer
  122. *
  123. * @ORM\Column(name="revision_uad", type="smallint")
  124. */
  125. private $revisionUad;
  126. /**
  127. * Assert\Type(type="Ultra\ControlDocumentoBundle\Entity\TipoDocumento", message="El valor {{ value }} no es de tipo {{ type }}.")
  128. * @ORM\ManyToOne(targetEntity="Ultra\ControlDocumentoBundle\Entity\TipoDocumento")
  129. */
  130. private $tipoDocumento;
  131. /**
  132. * @Assert\NotNull(message="Seleccione")
  133. * Assert\Type(type="Ultra\ControlDocumentoBundle\Entity\PerfilCurricula", message="El valor {{value}} no es de tipo {{type}}.")
  134. * @ORM\OneToMany(targetEntity="Ultra\ControlDocumentoBundle\Entity\PerfilCurricula", mappedBy="perfil", cascade={"persist"})
  135. */
  136. private $perfiles;
  137. /**
  138. *
  139. * @Assert\NotNull(message="Seleccione un estado valido")
  140. * Assert\Type(type="Ultra\ControlDocumentoBundle\Entity\Condicion",
  141. * message="El valor {{ value }} no es de tipo {{ type }}.")
  142. * @ORM\ManyToOne(targetEntity="Ultra\ControlDocumentoBundle\Entity\Condicion")
  143. */
  144. private $estado;
  145. /**
  146. *
  147. *
  148. * @Assert\NotNull(message="Seleccione una disciplina")
  149. * @Assert\NotBlank(message="Debe seleccionar una disciplina")
  150. * @ORM\ManyToMany(targetEntity="Ultra\ControlDocumentoBundle\Entity\Disciplina", inversedBy="perfiles")
  151. */
  152. private $disciplinas;
  153. /**
  154. * @var
  155. *
  156. * Assert\Valid(traverse=true)
  157. * @ORM\OneToMany(targetEntity="Ultra\ControlDocumentoBundle\Entity\Actividad", mappedBy="perfil", cascade={"persist"})
  158. */
  159. private $actividades;
  160. /**
  161. * @var
  162. *
  163. * @Assert\Valid(traverse=true)
  164. * @ORM\OneToMany(targetEntity="Ultra\ControlDocumentoBundle\Entity\Escolaridad", mappedBy="perfil", cascade={"persist"})
  165. */
  166. private $escolaridad;
  167. /**
  168. * @var
  169. *
  170. * Assert\Valid(traverse=true)
  171. * @ORM\OneToMany(targetEntity="Ultra\ControlDocumentoBundle\Entity\Experiencia", mappedBy="perfil", cascade={"persist"})
  172. */
  173. private $expertise;
  174. /**
  175. *
  176. * Assert\Valid(traverse=true)
  177. * @ORM\OneToMany(targetEntity="\Ultra\ControlDocumentoBundle\Entity\Capacitacion", mappedBy="perfil", cascade={"persist"})
  178. */
  179. private $capacitacion;
  180. /**
  181. * @var
  182. *
  183. * Assert\Valid(traverse=true)
  184. * @ORM\OneToMany(targetEntity="Ultra\ControlDocumentoBundle\Entity\Habilidad", mappedBy="perfil", cascade={"persist"})
  185. */
  186. private $habilidades;
  187. /**
  188. * @var
  189. *
  190. * Assert\Valid(traverse=true)
  191. * @ORM\OneToMany(targetEntity="Ultra\ControlDocumentoBundle\Entity\ConocimientoEspecial", mappedBy="perfil", cascade={"persist"})
  192. */
  193. private $conocimientoEspecial;
  194. /**
  195. * @var
  196. *
  197. * Assert\Valid(traverse=true)
  198. * @ORM\OneToMany(targetEntity="Ultra\ControlDocumentoBundle\Entity\Nota", mappedBy="perfil", cascade={"persist"})
  199. */
  200. private $notas;
  201. /**
  202. * @var String
  203. *
  204. * Varianle para almacenar archivos que se van a borrar del sistema
  205. */
  206. private $temp;
  207. /**
  208. * @var string
  209. *
  210. * Variable que almacena como prefijo una parte de la ruta de un archivo
  211. * en el sistema.
  212. */
  213. private $path;
  214. /**
  215. * @var string
  216. *
  217. * @ORM\Column(name="hash", type="string", length=40, nullable=true)
  218. */
  219. private $hash = null;
  220. /**
  221. * Constructor
  222. */
  223. public function __construct()
  224. {
  225. $this->perfiles = new \Doctrine\Common\Collections\ArrayCollection();
  226. $this->disciplinas = new \Doctrine\Common\Collections\ArrayCollection();
  227. $this->actividades = new \Doctrine\Common\Collections\ArrayCollection();
  228. $this->escolaridad = new \Doctrine\Common\Collections\ArrayCollection();
  229. $this->expertise = new \Doctrine\Common\Collections\ArrayCollection();
  230. $this->capacitacion = new \Doctrine\Common\Collections\ArrayCollection();
  231. $this->habilidades = new \Doctrine\Common\Collections\ArrayCollection();
  232. $this->conocimientoEspecial = new \Doctrine\Common\Collections\ArrayCollection();
  233. $this->notas = new \Doctrine\Common\Collections\ArrayCollection();
  234. }
  235. /**
  236. * Get id
  237. *
  238. * @return integer
  239. */
  240. public function getId()
  241. {
  242. return $this->id;
  243. }
  244. /**
  245. * Set clave
  246. *
  247. * @param string $clave
  248. * @return Perfil
  249. */
  250. public function setClave($clave)
  251. {
  252. $this->clave = $clave;
  253. return $this;
  254. }
  255. /**
  256. * Get clave
  257. *
  258. * @return string
  259. */
  260. public function getClave()
  261. {
  262. return $this->clave;
  263. }
  264. /**
  265. * Set revision
  266. *
  267. * @param integer $revision
  268. * @return Perfil
  269. */
  270. public function setRevision($revision)
  271. {
  272. $this->revision = $revision;
  273. return $this;
  274. }
  275. /**
  276. * Get revision
  277. *
  278. * @return integer
  279. */
  280. public function getRevision()
  281. {
  282. return $this->revision;
  283. }
  284. /**
  285. * Set titulo
  286. *
  287. * @param string $titulo
  288. * @return Perfil
  289. */
  290. public function setTitulo($titulo)
  291. {
  292. $this->titulo = $titulo;
  293. return $this;
  294. }
  295. /**
  296. * Get titulo
  297. *
  298. * @return string
  299. */
  300. public function getTitulo()
  301. {
  302. return $this->titulo;
  303. }
  304. /**
  305. * Set tituloCorto
  306. *
  307. * @param string $tituloCorto
  308. * @return Perfil
  309. */
  310. public function setTituloCorto($tituloCorto)
  311. {
  312. $this->tituloCorto = $tituloCorto;
  313. return $this;
  314. }
  315. /**
  316. * Get tituloCorto
  317. *
  318. * @return string
  319. */
  320. public function getTituloCorto()
  321. {
  322. return $this->tituloCorto;
  323. }
  324. /**
  325. * Set aprobado
  326. *
  327. * @param \DateTime $aprobado
  328. * @return Perfil
  329. */
  330. public function setAprobado($aprobado)
  331. {
  332. $this->aprobado = $aprobado;
  333. return $this;
  334. }
  335. /**
  336. * Get aprobado
  337. *
  338. * @return \DateTime
  339. */
  340. public function getAprobado()
  341. {
  342. return $this->aprobado;
  343. }
  344. /**
  345. * Set vigencia
  346. *
  347. * @param \DateTime $vigencia
  348. * @return Perfil
  349. */
  350. public function setVigencia($vigencia)
  351. {
  352. $this->vigencia = $vigencia;
  353. return $this;
  354. }
  355. /**
  356. * Get vigencia
  357. *
  358. * @return \DateTime
  359. */
  360. public function getVigencia()
  361. {
  362. return $this->vigencia;
  363. }
  364. /**
  365. * Set liberado
  366. *
  367. * @param \DateTime $liberado
  368. * @return Documento
  369. */
  370. public function setLiberado($liberado)
  371. {
  372. $this->liberado = $liberado;
  373. return $this;
  374. }
  375. /**
  376. * Get liberado
  377. *
  378. * @return \DateTime
  379. */
  380. public function getLiberado()
  381. {
  382. return $this->liberado;
  383. }
  384. /**
  385. * Set transmitido
  386. *
  387. * @param \DateTime $transmitido
  388. * @return Documento
  389. */
  390. public function setTransmitido($transmitido)
  391. {
  392. $this->transmitido = $transmitido;
  393. return $this;
  394. }
  395. /**
  396. * Get transmitido
  397. *
  398. * @return \DateTime
  399. */
  400. public function getTransmitido()
  401. {
  402. return $this->transmitido;
  403. }
  404. /**
  405. * Set pdf
  406. *
  407. * @param string $pdf
  408. * @return Perfil
  409. */
  410. public function setPdf($pdf)
  411. {
  412. $this->pdf = $pdf;
  413. return $this;
  414. }
  415. /**
  416. * Get pdf
  417. *
  418. * @return string
  419. */
  420. public function getPdf()
  421. {
  422. return $this->pdf;
  423. }
  424. /**
  425. * Set doc
  426. *
  427. * @param string $doc
  428. * @return Perfil
  429. */
  430. public function setDoc($doc)
  431. {
  432. $this->doc = $doc;
  433. return $this;
  434. }
  435. /**
  436. * Get doc
  437. *
  438. * @return string
  439. */
  440. public function getDoc()
  441. {
  442. return $this->doc;
  443. }
  444. /**
  445. * Set tipoDocumento
  446. *
  447. * @param \Ultra\ControlDocumentoBundle\Entity\TipoDocumento $tipoDocumento
  448. * @return Perfil
  449. */
  450. public function setTipoDocumento(\Ultra\ControlDocumentoBundle\Entity\TipoDocumento $tipoDocumento = null)
  451. {
  452. $this->tipoDocumento = $tipoDocumento;
  453. return $this;
  454. }
  455. /**
  456. * Get tipoDocumento
  457. *
  458. * @return \Ultra\ControlDocumentoBundle\Entity\TipoDocumento
  459. */
  460. public function getTipoDocumento()
  461. {
  462. return $this->tipoDocumento;
  463. }
  464. /**
  465. * Add perfiles
  466. *
  467. * @param \Ultra\ControlDocumentoBundle\Entity\PerfilCurricula $perfiles
  468. * @return Perfil
  469. */
  470. public function addPerfile(\Ultra\ControlDocumentoBundle\Entity\PerfilCurricula $perfiles)
  471. {
  472. $perfiles->setPerfil($this);
  473. $this->perfiles[] = $perfiles;
  474. return $this;
  475. }
  476. /**
  477. * Remove perfiles
  478. *
  479. * @param \Ultra\ControlDocumentoBundle\Entity\PerfilCurricula $perfiles
  480. */
  481. public function removePerfile(\Ultra\ControlDocumentoBundle\Entity\PerfilCurricula $perfiles)
  482. {
  483. $this->perfiles->removeElement($perfiles);
  484. }
  485. /**
  486. * Get perfiles
  487. *
  488. * @return \Doctrine\Common\Collections\Collection
  489. */
  490. public function getPerfiles()
  491. {
  492. return $this->perfiles;
  493. }
  494. /**
  495. * Set estado
  496. *
  497. * @param \Ultra\ControlDocumentoBundle\Entity\Condicion $estado
  498. * @return Perfil
  499. */
  500. public function setEstado(\Ultra\ControlDocumentoBundle\Entity\Condicion $estado = null)
  501. {
  502. $this->estado = $estado;
  503. return $this;
  504. }
  505. /**
  506. * Get estado
  507. *
  508. * @return \Ultra\ControlDocumentoBundle\Entity\Condicion
  509. */
  510. public function getEstado()
  511. {
  512. return $this->estado;
  513. }
  514. /**
  515. * Add disciplinas
  516. *
  517. * @param \Ultra\ControlDocumentoBundle\Entity\Disciplina $disciplinas
  518. * @return Perfil
  519. */
  520. public function addDisciplina(\Ultra\ControlDocumentoBundle\Entity\Disciplina $disciplinas)
  521. {
  522. $this->disciplinas[] = $disciplinas;
  523. return $this;
  524. }
  525. /**
  526. * Remove disciplinas
  527. *
  528. * @param \Ultra\ControlDocumentoBundle\Entity\Disciplina $disciplinas
  529. */
  530. public function removeDisciplina(\Ultra\ControlDocumentoBundle\Entity\Disciplina $disciplinas)
  531. {
  532. $this->disciplinas->removeElement($disciplinas);
  533. }
  534. /**
  535. * Get disciplinas
  536. *
  537. * @return \Doctrine\Common\Collections\Collection
  538. */
  539. public function getDisciplinas()
  540. {
  541. return $this->disciplinas;
  542. }
  543. /**
  544. * Add actividades
  545. *
  546. * @param \Ultra\ControlDocumentoBundle\Entity\Actividad $actividades
  547. * @return Perfil
  548. */
  549. public function addActividade(\Ultra\ControlDocumentoBundle\Entity\Actividad $actividades)
  550. {
  551. $actividades->setPerfil($this);
  552. $this->actividades[] = $actividades;
  553. return $this;
  554. }
  555. /**
  556. * Remove actividades
  557. *
  558. * @param \Ultra\ControlDocumentoBundle\Entity\Actividad $actividades
  559. */
  560. public function removeActividade(\Ultra\ControlDocumentoBundle\Entity\Actividad $actividades)
  561. {
  562. $this->actividades->removeElement($actividades);
  563. }
  564. /**
  565. * Get actividades
  566. *
  567. * @return \Doctrine\Common\Collections\Collection
  568. */
  569. public function getActividades()
  570. {
  571. return $this->actividades;
  572. }
  573. /**
  574. * Add escolaridad
  575. *
  576. * @param \Ultra\ControlDocumentoBundle\Entity\Escolaridad $escolaridad
  577. * @return Perfil
  578. */
  579. public function addEscolaridad(\Ultra\ControlDocumentoBundle\Entity\Escolaridad $escolaridad)
  580. {
  581. $escolaridad->setPerfil($this);
  582. $this->escolaridad[] = $escolaridad;
  583. return $this;
  584. }
  585. /**
  586. * Remove escolaridad
  587. *
  588. * @param \Ultra\ControlDocumentoBundle\Entity\Escolaridad $escolaridad
  589. */
  590. public function removeEscolaridad(\Ultra\ControlDocumentoBundle\Entity\Escolaridad $escolaridad)
  591. {
  592. $this->escolaridad->removeElement($escolaridad);
  593. }
  594. /**
  595. * Get escolaridad
  596. *
  597. * @return \Doctrine\Common\Collections\Collection
  598. */
  599. public function getEscolaridad()
  600. {
  601. return $this->escolaridad;
  602. }
  603. /**
  604. * Add experiencia
  605. *
  606. * @param \Ultra\ControlDocumentoBundle\Entity\Experiencia $experiencia
  607. * @return Perfil
  608. */
  609. public function addExpertise(\Ultra\ControlDocumentoBundle\Entity\Experiencia $experiencia)
  610. {
  611. $experiencia->setPerfil($this);
  612. $this->expertise[] = $experiencia;
  613. return $this;
  614. }
  615. /**
  616. * Remove experiencia
  617. *
  618. * @param \Ultra\ControlDocumentoBundle\Entity\Experiencia $experiencia
  619. */
  620. public function removeExpertise(\Ultra\ControlDocumentoBundle\Entity\Experiencia $experiencia)
  621. {
  622. $this->expertise->removeElement($experiencia);
  623. }
  624. /**
  625. * Get experiencia
  626. *
  627. * @return \Doctrine\Common\Collections\Collection
  628. */
  629. public function getExpertise()
  630. {
  631. return $this->expertise;
  632. }
  633. /**
  634. * Add capacitacion
  635. *
  636. * @param \Ultra\ControlDocumentoBundle\Entity\Capacitacion $capacitacion
  637. * @return Perfil
  638. */
  639. public function addCapacitacion(\Ultra\ControlDocumentoBundle\Entity\Capacitacion $capacitacion)
  640. {
  641. $capacitacion->setPerfil($this);
  642. $this->capacitacion->add($capacitacion);
  643. return $this;
  644. }
  645. /**
  646. * Remove capacitacion
  647. *
  648. * @param \Ultra\ControlDocumentoBundle\Entity\Capacitacion $capacitacion
  649. */
  650. public function removeCapacitacion(\Ultra\ControlDocumentoBundle\Entity\Capacitacion $capacitacion)
  651. {
  652. $this->capacitacion->removeElement($capacitacion);
  653. }
  654. /**
  655. * Get capacitacion
  656. *
  657. * @return \Doctrine\Common\Collections\Collection
  658. */
  659. public function getCapacitacion()
  660. {
  661. return $this->capacitacion;
  662. }
  663. /**
  664. * Add habilidades
  665. *
  666. * @param \Ultra\ControlDocumentoBundle\Entity\Habilidad $habilidades
  667. * @return Perfil
  668. */
  669. public function addHabilidade(\Ultra\ControlDocumentoBundle\Entity\Habilidad $habilidades)
  670. {
  671. $habilidades->setPerfil($this);
  672. $this->habilidades[] = $habilidades;
  673. return $this;
  674. }
  675. /**
  676. * Remove habilidades
  677. *
  678. * @param \Ultra\ControlDocumentoBundle\Entity\Habilidad $habilidades
  679. */
  680. public function removeHabilidade(\Ultra\ControlDocumentoBundle\Entity\Habilidad $habilidades)
  681. {
  682. $this->habilidades->removeElement($habilidades);
  683. }
  684. /**
  685. * Get habilidades
  686. *
  687. * @return \Doctrine\Common\Collections\Collection
  688. */
  689. public function getHabilidades()
  690. {
  691. return $this->habilidades;
  692. }
  693. /**
  694. * Add notas
  695. *
  696. * @param \Ultra\ControlDocumentoBundle\Entity\Nota $notas
  697. * @return Perfil
  698. */
  699. public function addNota(\Ultra\ControlDocumentoBundle\Entity\Nota $notas)
  700. {
  701. $notas->setPerfil($this);
  702. $this->notas[] = $notas;
  703. return $this;
  704. }
  705. /**
  706. * Remove notas
  707. *
  708. * @param \Ultra\ControlDocumentoBundle\Entity\Nota $notas
  709. */
  710. public function removeNota(\Ultra\ControlDocumentoBundle\Entity\Nota $notas)
  711. {
  712. $this->notas->removeElement($notas);
  713. }
  714. /**
  715. * Get notas
  716. *
  717. * @return \Doctrine\Common\Collections\Collection
  718. */
  719. public function getNotas()
  720. {
  721. return $this->notas;
  722. }
  723. /**
  724. * Set hash
  725. *
  726. * @param string $hash
  727. * @return Perfil
  728. */
  729. public function setHash($hash)
  730. {
  731. $this->hash = sha1_file($hash);
  732. return $this;
  733. }
  734. /**
  735. * Get hash
  736. *
  737. * @return string
  738. */
  739. public function getHash()
  740. {
  741. return $this->hash;
  742. }
  743. public function getTemp(){
  744. return $this->temp;
  745. }
  746. public function setTemp($temp){
  747. $this->temp = $temp;
  748. }
  749. public function __toString(){
  750. return $this->getClave().' '.$this->getTitulo().' Rev.'.$this->getRevision();
  751. }
  752. /**
  753. * Add conocimientoEspecial
  754. *
  755. * @param \Ultra\ControlDocumentoBundle\Entity\ConocimientoEspecial $conocimientoEspecial
  756. * @return Perfil
  757. */
  758. public function addConocimientoEspecial(\Ultra\ControlDocumentoBundle\Entity\ConocimientoEspecial $conocimientoEspecial)
  759. {
  760. $conocimientoEspecial->setPerfil($this);
  761. $this->conocimientoEspecial[] = $conocimientoEspecial;
  762. return $this;
  763. }
  764. /**
  765. * Remove conocimientoEspecial
  766. *
  767. * @param \Ultra\ControlDocumentoBundle\Entity\ConocimientoEspecial $conocimientoEspecial
  768. */
  769. public function removeConocimientoEspecial(\Ultra\ControlDocumentoBundle\Entity\ConocimientoEspecial $conocimientoEspecial)
  770. {
  771. $this->conocimientoEspecial->removeElement($conocimientoEspecial);
  772. }
  773. /**
  774. * Get conocimientoEspecial
  775. *
  776. * @return \Doctrine\Common\Collections\Collection
  777. */
  778. public function getConocimientoEspecial()
  779. {
  780. return $this->conocimientoEspecial;
  781. }
  782. /**
  783. * Set fechaUad
  784. *
  785. * @param \DateTime $fechaUad
  786. * @return Perfil
  787. */
  788. public function setFechaUad($fechaUad)
  789. {
  790. $this->fechaUad = $fechaUad;
  791. return $this;
  792. }
  793. /**
  794. * Get fechaUad
  795. *
  796. * @return \DateTime
  797. */
  798. public function getFechaUad()
  799. {
  800. return $this->fechaUad;
  801. }
  802. /**
  803. * Set revisionUad
  804. *
  805. * @param integer $revisionUad
  806. * @return Perfil
  807. */
  808. public function setRevisionUad($revisionUad)
  809. {
  810. $this->revisionUad = $revisionUad;
  811. return $this;
  812. }
  813. /**
  814. * Get revisionUad
  815. *
  816. * @return integer
  817. */
  818. public function getRevisionUad()
  819. {
  820. return $this->revisionUad;
  821. }
  822. public function __clone()
  823. {
  824. if($this->id)
  825. {
  826. $this->id = null;
  827. }
  828. }
  829. /**
  830. * @param mixed $creado
  831. */
  832. public function setCreado($creado)
  833. {
  834. $this->creado = $creado;
  835. }
  836. /**
  837. * @return mixed
  838. */
  839. public function getCreado()
  840. {
  841. return $this->creado;
  842. }
  843. /**
  844. * @param mixed $actualizado
  845. */
  846. public function setActualizado($actualizado)
  847. {
  848. $this->actualizado = $actualizado;
  849. }
  850. /**
  851. * @return mixed
  852. */
  853. public function getActualizado()
  854. {
  855. return $this->actualizado;
  856. }
  857. /**
  858. *
  859. * Comienza manejo de archivos
  860. *
  861. */
  862. /**
  863. * Set file
  864. *
  865. * @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
  866. * @return UploadedFile
  867. */
  868. public function setFile(UploadedFile $file = null)
  869. {
  870. $this->file = $file;
  871. if (is_file($this->getAbsolutePath())) {
  872. $this->setTemp($this->getAbsolutePath());
  873. $this->pdf = null;
  874. } else {
  875. $this->pdf = sha1(uniqid(mt_rand(), true));
  876. }
  877. }
  878. /**
  879. * Get file
  880. *
  881. * @return string
  882. */
  883. public function getFile()
  884. {
  885. return $this->file;
  886. }
  887. public function getAbsolutePath()
  888. {
  889. return null === $this->pdf
  890. ? null
  891. : $this->getUploadRootDir().'/'.$this->pdf;
  892. }
  893. public function getWebPath()
  894. {
  895. return null === $this->pdf
  896. ? null
  897. : $this->getUploadDir().'/'.$this->pdf;
  898. }
  899. private function getUploadRootDir()
  900. {
  901. return '/var/sad/'.$this->getUploadDir();
  902. }
  903. private function getUploadDir()
  904. {
  905. return 'uploads/perfiles/'.$this->getEstado();
  906. }
  907. private function temporaryPath($path){
  908. $this->path = $path;
  909. }
  910. private function getTemporaryPath(){
  911. return $this->path;
  912. }
  913. /**
  914. *
  915. * @ORM\PrePersist()
  916. */
  917. public function preUpload()
  918. {
  919. if (null !== $this->getFile()) {
  920. $this->setPdf(
  921. $this->getClave().'-r'.$this->getRevision().'.'.$this->getFile()->guessExtension()
  922. );
  923. $this->setHash($this->getFile()->getPathname());
  924. $this->creado = new \DateTime();
  925. }
  926. }
  927. /**
  928. *
  929. * @ORM\PreUpdate()
  930. */
  931. public function preUpdate(){
  932. if (null != $this->getFile()) {
  933. //Nombre del archivo con formato Numero de contrato - clave.pdf
  934. $this->setPdf(
  935. $this->getClave().'-r'.$this->getRevision().'.'.$this->getFile()->guessExtension()
  936. );
  937. $this->actualizado = new \DateTime();
  938. }
  939. }
  940. /**
  941. *
  942. * @ORM\PostPersist()
  943. */
  944. public function upload()
  945. {
  946. if(null == $this->getFile())
  947. {
  948. return;
  949. }
  950. $this->getFile()->move(
  951. $this->getUploadRootDir(),
  952. $this->pdf
  953. );
  954. $this->temp = null;
  955. $this->file = null;
  956. }
  957. /**
  958. *
  959. * @ORM\PostUpdate()
  960. */
  961. public function postUpdate()
  962. {
  963. if(null !== $this->getFile())
  964. {
  965. if (isset($this->temp)) {
  966. unlink($this->temp);
  967. }
  968. $this->getFile()->move(
  969. $this->getUploadRootDir(),
  970. $this->pdf
  971. );
  972. }
  973. $this->temp = null;
  974. $this->file = null;
  975. }
  976. /**
  977. * @ORM\PostRemove()
  978. */
  979. public function removeUpload()
  980. {
  981. if ($file = $this->getAbsolutePath()) {
  982. unlink($file);
  983. }
  984. }
  985. public function move($previousPath, $previousState)
  986. {
  987. if($this->getEstado()->getId() !== $previousState->getId())
  988. {
  989. $fs = new Filesystem();
  990. //En este punto el valor de Condicion ya es 2, por lo cual se busca por la ruta anterior
  991. if($fs->exists($previousPath))
  992. {
  993. try{
  994. $fs->copy($previousPath, $this->getAbsolutePath(), true);
  995. //$fs->remove($previousPath);
  996. }
  997. catch (FileNotFoundException $e){
  998. return $e->getTrace();
  999. }
  1000. catch (IOException $e){
  1001. return $e->getTrace();
  1002. }
  1003. }
  1004. $fs = null;
  1005. }
  1006. }
  1007. }