Advertisement
JPunto

Untitled

Nov 19th, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.65 KB | None | 0 0
  1. /******************************************************/
  2. /********************** PREGUNTA **********************/
  3. /******************************************************/
  4.  
  5. <?php
  6.  
  7. namespace W_Encuestas\EncuestasBundle\Entity;
  8.  
  9. use Doctrine\ORM\Mapping as ORM;
  10.  
  11. use Symfony\Component\Validator\Constraints as Assert;
  12.  
  13. /**
  14. * @ORM\Entity(repositoryClass="W_Encuestas\EncuestasBundle\Entity\Repositorios\PreguntaRepository")
  15. * @ORM\InheritanceType("JOINED")
  16. * @ORM\DiscriminatorColumn(name="tipo_pregunta", type="string")
  17. * @ORM\DiscriminatorMap({"SU" = "SelUnica", "SM" = "SelMultiple", "VE" = "ValorEntero", "VD" = "ValorDecimal", "TX" = "Texto"})
  18. */
  19. abstract class Pregunta
  20. {
  21. /**
  22. * @ORM\Id
  23. * @ORM\Column(type="integer")
  24. * @ORM\GeneratedValue(strategy="IDENTITY")
  25. */
  26. protected $id;
  27. /**
  28. * @ORM\Column(type="integer")
  29. */
  30. protected $orden;
  31. /**
  32. * @ORM\Column(type="boolean")
  33. * @Assert\Type(type="boolean", message="El valor de 'Respuesta obligatoria' no es correcto")
  34. */
  35. protected $respuesta_obligatoria;
  36. /**
  37. * @ORM\Column(type="string")
  38. * @Assert\NotBlank(message="El campo 'Texto' es obligatorio")
  39. */
  40. protected $texto;
  41. /**
  42. * @ORM\ManyToOne(targetEntity="Encuesta", inversedBy="preguntas")
  43. * @ORM\JoinColumn(name="encuesta_id", referencedColumnName="id")
  44. */
  45. protected $encuesta;
  46.  
  47. /**
  48. * Get id
  49. *
  50. * @return integer
  51. */
  52. public function getId()
  53. {
  54. return $this->id;
  55. }
  56.  
  57. /**
  58. * Set orden
  59. *
  60. * @param integer $orden
  61. */
  62. public function setOrden($orden)
  63. {
  64. $this->orden = $orden;
  65. }
  66.  
  67. /**
  68. * Get orden
  69. *
  70. * @return integer
  71. */
  72. public function getOrden()
  73. {
  74. return $this->orden;
  75. }
  76.  
  77. /**
  78. * Set respuesta_obligatoria
  79. *
  80. * @param boolean $respuestaObligatoria
  81. */
  82. public function setRespuestaObligatoria($respuestaObligatoria)
  83. {
  84. $this->respuesta_obligatoria = $respuestaObligatoria;
  85. }
  86.  
  87. /**
  88. * Get respuesta_obligatoria
  89. *
  90. * @return boolean
  91. */
  92. public function getRespuestaObligatoria()
  93. {
  94. return $this->respuesta_obligatoria;
  95. }
  96.  
  97. /**
  98. * Set encuesta
  99. *
  100. * @param W_Encuestas\EncuestasBundle\Entity\Encuesta $encuesta
  101. */
  102. public function setEncuesta(\W_Encuestas\EncuestasBundle\Entity\Encuesta $encuesta)
  103. {
  104. $this->encuesta = $encuesta;
  105. }
  106.  
  107. /**
  108. * Get encuesta
  109. *
  110. * @return W_Encuestas\EncuestasBundle\Entity\Encuesta
  111. */
  112. public function getEncuesta()
  113. {
  114. return $this->encuesta;
  115. }
  116.  
  117. /**
  118. * Get tipo_pregunta
  119. *
  120. * @return string
  121. */
  122. public function getTipoPregunta()
  123. {
  124. return $this->tipo_pregunta;
  125. }
  126.  
  127. /**
  128. * Set texto
  129. *
  130. * @param string $texto
  131. */
  132. public function setTexto($texto)
  133. {
  134. $this->texto = $texto;
  135. }
  136.  
  137. /**
  138. * Get texto
  139. *
  140. * @return string
  141. */
  142. public function getTexto()
  143. {
  144. return $this->texto;
  145. }
  146. }
  147.  
  148.  
  149. /******************************************************/
  150. /********************** SELECCION *********************/
  151. /******************************************************/
  152. <?php
  153.  
  154. namespace W_Encuestas\EncuestasBundle\Entity;
  155.  
  156. use Doctrine\ORM\Mapping as ORM;
  157.  
  158. use Doctrine\Common\Collections\ArrayCollection;
  159.  
  160. use Symfony\Component\Validator\Constraints as Assert;
  161.  
  162. /**
  163. * @ORM\MappedSuperclass
  164. */
  165. abstract class Seleccion extends Pregunta
  166. {
  167. /**
  168. * @ORM\Column(type="string")
  169. * @Assert\NotBlank(message="Debe seleccionarse una opción para 'Tipo presentación'")
  170. * @Assert\Choice(choices={"Horizontal", "Vertical"}, message="El valor de 'Tipo presentación' no es correcto")
  171. */
  172. protected $tipo_presentacion;
  173. /**
  174. * @ORM\Column(type="boolean")
  175. * @Assert\Type(type="boolean", message="El valor de 'Opciones con imágenes' no es correcto")
  176. */
  177. protected $opciones_con_imagenes;
  178. /**
  179. * @ORM\OneToMany(targetEntity="Opcion", mappedBy="seleccion")
  180. */
  181. protected $opciones;
  182.  
  183. public function __construct()
  184. {
  185. $this->opciones = new \Doctrine\Common\Collections\ArrayCollection();
  186. }
  187.  
  188. /**
  189. * Set tipo_presentacion
  190. *
  191. * @param string $tipoPresentacion
  192. */
  193. public function setTipoPresentacion($tipoPresentacion)
  194. {
  195. $this->tipo_presentacion = $tipoPresentacion;
  196. }
  197.  
  198. /**
  199. * Get tipo_presentacion
  200. *
  201. * @return string
  202. */
  203. public function getTipoPresentacion()
  204. {
  205. return $this->tipo_presentacion;
  206. }
  207.  
  208. /**
  209. * Set opciones_con_imagenes
  210. *
  211. * @param boolean $opcionesConImagenes
  212. */
  213. public function setOpcionesConImagenes($opcionesConImagenes)
  214. {
  215. $this->opciones_con_imagenes = $opcionesConImagenes;
  216. }
  217.  
  218. /**
  219. * Get opciones_con_imagenes
  220. *
  221. * @return boolean
  222. */
  223. public function getOpcionesConImagenes()
  224. {
  225. return $this->opciones_con_imagenes;
  226. }
  227.  
  228. /**
  229. * Add opciones
  230. *
  231. * @param W_Encuestas\EncuestasBundle\Entity\Opcion $opciones
  232. */
  233. public function addOpcion(\W_Encuestas\EncuestasBundle\Entity\Opcion $opciones)
  234. {
  235. $this->opciones[] = $opciones;
  236. }
  237.  
  238. public function setOpciones(ArrayCollection $opciones)
  239. {
  240. $this->opciones = $opciones;
  241. }
  242.  
  243. /**
  244. * Get opciones
  245. *
  246. * @return Doctrine\Common\Collections\Collection
  247. */
  248. public function getOpciones()
  249. {
  250. return $this->opciones;
  251. }
  252. }
  253.  
  254.  
  255. /******************************************************/
  256. /********************** SELUNICA **********************/
  257. /******************************************************/
  258. <?php
  259.  
  260. namespace W_Encuestas\EncuestasBundle\Entity;
  261.  
  262. use Doctrine\ORM\Mapping as ORM;
  263.  
  264. use Doctrine\Common\Collections\ArrayCollection;
  265.  
  266. use Symfony\Component\Validator\Constraints as Assert;
  267.  
  268. /**
  269. * @ORM\Entity
  270. */
  271. class SelUnica extends Seleccion
  272. {
  273. public function __construct()
  274. {
  275. $this->opciones = new \Doctrine\Common\Collections\ArrayCollection();
  276. }
  277.  
  278. /**
  279. * Get tipo_pregunta
  280. *
  281. * @var string
  282. */
  283. public function getTipoPregunta()
  284. {
  285. return 'SU';
  286. }
  287. /**
  288. * @var string $tipo_presentacion
  289. */
  290. protected $tipo_presentacion;
  291.  
  292. /**
  293. * @var boolean $opciones_con_imagenes
  294. */
  295. protected $opciones_con_imagenes;
  296.  
  297. /**
  298. * @var integer $id
  299. */
  300. protected $id;
  301.  
  302. /**
  303. * @var integer $orden
  304. */
  305. protected $orden;
  306.  
  307. /**
  308. * @var boolean $respuesta_obligatoria
  309. */
  310. protected $respuesta_obligatoria;
  311.  
  312. /**
  313. * @var string $texto
  314. */
  315. protected $texto;
  316.  
  317. /**
  318. * @var \Doctrine\Common\Collections\ArrayCollection
  319. */
  320. protected $opciones;
  321.  
  322. /**
  323. * @var W_Encuestas\EncuestasBundle\Entity\Encuesta
  324. */
  325. protected $encuesta;
  326.  
  327.  
  328. /**
  329. * Set tipo_presentacion
  330. *
  331. * @param string $tipoPresentacion
  332. * @return SelUnica
  333. */
  334. public function setTipoPresentacion($tipoPresentacion)
  335. {
  336. $this->tipo_presentacion = $tipoPresentacion;
  337.  
  338. return $this;
  339. }
  340.  
  341. /**
  342. * Get tipo_presentacion
  343. *
  344. * @return string
  345. */
  346. public function getTipoPresentacion()
  347. {
  348. return $this->tipo_presentacion;
  349. }
  350.  
  351. /**
  352. * Set opciones_con_imagenes
  353. *
  354. * @param boolean $opcionesConImagenes
  355. * @return SelUnica
  356. */
  357. public function setOpcionesConImagenes($opcionesConImagenes)
  358. {
  359. $this->opciones_con_imagenes = $opcionesConImagenes;
  360.  
  361. return $this;
  362. }
  363.  
  364. /**
  365. * Get opciones_con_imagenes
  366. *
  367. * @return boolean
  368. */
  369. public function getOpcionesConImagenes()
  370. {
  371. return $this->opciones_con_imagenes;
  372. }
  373.  
  374. /**
  375. * Get id
  376. *
  377. * @return integer
  378. */
  379. public function getId()
  380. {
  381. return $this->id;
  382. }
  383.  
  384. /**
  385. * Set orden
  386. *
  387. * @param integer $orden
  388. * @return SelUnica
  389. */
  390. public function setOrden($orden)
  391. {
  392. $this->orden = $orden;
  393.  
  394. return $this;
  395. }
  396.  
  397. /**
  398. * Get orden
  399. *
  400. * @return integer
  401. */
  402. public function getOrden()
  403. {
  404. return $this->orden;
  405. }
  406.  
  407. /**
  408. * Set respuesta_obligatoria
  409. *
  410. * @param boolean $respuestaObligatoria
  411. * @return SelUnica
  412. */
  413. public function setRespuestaObligatoria($respuestaObligatoria)
  414. {
  415. $this->respuesta_obligatoria = $respuestaObligatoria;
  416.  
  417. return $this;
  418. }
  419.  
  420. /**
  421. * Get respuesta_obligatoria
  422. *
  423. * @return boolean
  424. */
  425. public function getRespuestaObligatoria()
  426. {
  427. return $this->respuesta_obligatoria;
  428. }
  429.  
  430. /**
  431. * Set texto
  432. *
  433. * @param string $texto
  434. * @return SelUnica
  435. */
  436. public function setTexto($texto)
  437. {
  438. $this->texto = $texto;
  439.  
  440. return $this;
  441. }
  442.  
  443. /**
  444. * Get texto
  445. *
  446. * @return string
  447. */
  448. public function getTexto()
  449. {
  450. return $this->texto;
  451. }
  452.  
  453. /**
  454. * Add opciones
  455. *
  456. * @param W_Encuestas\EncuestasBundle\Entity\Opcion $opciones
  457. * @return SelUnica
  458. */
  459. public function addOpcione(\W_Encuestas\EncuestasBundle\Entity\Opcion $opciones)
  460. {
  461. $this->opciones[] = $opciones;
  462.  
  463. return $this;
  464. }
  465.  
  466. /**
  467. * Remove opciones
  468. *
  469. * @param W_Encuestas\EncuestasBundle\Entity\Opcion $opciones
  470. */
  471. public function removeOpcione(\W_Encuestas\EncuestasBundle\Entity\Opcion $opciones)
  472. {
  473. $this->opciones->removeElement($opciones);
  474. }
  475.  
  476. /**
  477. * Get opciones
  478. *
  479. * @return Doctrine\Common\Collections\Collection
  480. */
  481. public function getOpciones()
  482. {
  483. return $this->opciones;
  484. }
  485.  
  486. /**
  487. * Set encuesta
  488. *
  489. * @param W_Encuestas\EncuestasBundle\Entity\Encuesta $encuesta
  490. * @return SelUnica
  491. */
  492. public function setEncuesta(\W_Encuestas\EncuestasBundle\Entity\Encuesta $encuesta = null)
  493. {
  494. $this->encuesta = $encuesta;
  495.  
  496. return $this;
  497. }
  498.  
  499. /**
  500. * Get encuesta
  501. *
  502. * @return W_Encuestas\EncuestasBundle\Entity\Encuesta
  503. */
  504. public function getEncuesta()
  505. {
  506. return $this->encuesta;
  507. }
  508. }
  509.  
  510.  
  511. /******************************************************/
  512. /********************* SELMULTIPLE ********************/
  513. /******************************************************/
  514. <?php
  515.  
  516. namespace W_Encuestas\EncuestasBundle\Entity;
  517.  
  518. use Doctrine\ORM\Mapping as ORM;
  519.  
  520. use Doctrine\Common\Collections\ArrayCollection;
  521.  
  522. use Symfony\Component\Validator\Constraints as Assert;
  523.  
  524. /**
  525. * @ORM\Entity
  526. */
  527. class SelMultiple extends Seleccion
  528. {
  529. /**
  530. * @ORM\Column(type="integer", nullable=true)
  531. * @Assert\Type(type="numeric", message="El número mínimo de respuestas tiene que ser numérico")
  532. */
  533. protected $min_respuestas;
  534. /**
  535. * @ORM\Column(type="integer", nullable=true)
  536. * @Assert\Type(type="numeric", message="El número máximo de respuestas tiene que ser numérico")
  537. */
  538. protected $max_respuestas;
  539.  
  540. public function __construct()
  541. {
  542. $this->opciones = new \Doctrine\Common\Collections\ArrayCollection();
  543. }
  544.  
  545. /**
  546. * Set min_respuestas
  547. *
  548. * @param integer $minRespuestas
  549. */
  550. public function setMinRespuestas($minRespuestas)
  551. {
  552. $this->min_respuestas = $minRespuestas;
  553. }
  554.  
  555. /**
  556. * Get min_respuestas
  557. *
  558. * @return integer
  559. */
  560. public function getMinRespuestas()
  561. {
  562. return $this->min_respuestas;
  563. }
  564.  
  565. /**
  566. * Set max_respuestas
  567. *
  568. * @param integer $maxRespuestas
  569. */
  570. public function setMaxRespuestas($maxRespuestas)
  571. {
  572. $this->max_respuestas = $maxRespuestas;
  573. }
  574.  
  575. /**
  576. * Get max_respuestas
  577. *
  578. * @return integer
  579. */
  580. public function getMaxRespuestas()
  581. {
  582. return $this->max_respuestas;
  583. }
  584.  
  585. /**
  586. * Get tipo_pregunta
  587. *
  588. * @var string
  589. */
  590. public function getTipoPregunta()
  591. {
  592. return 'SM';
  593. }
  594. /**
  595. * @var string $tipo_presentacion
  596. */
  597. protected $tipo_presentacion;
  598.  
  599. /**
  600. * @var boolean $opciones_con_imagenes
  601. */
  602. protected $opciones_con_imagenes;
  603.  
  604. /**
  605. * @var integer $id
  606. */
  607. protected $id;
  608.  
  609. /**
  610. * @var integer $orden
  611. */
  612. protected $orden;
  613.  
  614. /**
  615. * @var boolean $respuesta_obligatoria
  616. */
  617. protected $respuesta_obligatoria;
  618.  
  619. /**
  620. * @var string $texto
  621. */
  622. protected $texto;
  623.  
  624. /**
  625. * @var \Doctrine\Common\Collections\ArrayCollection
  626. */
  627. protected $opciones;
  628.  
  629. /**
  630. * @var W_Encuestas\EncuestasBundle\Entity\Encuesta
  631. */
  632. protected $encuesta;
  633.  
  634.  
  635. /**
  636. * Set tipo_presentacion
  637. *
  638. * @param string $tipoPresentacion
  639. * @return SelMultiple
  640. */
  641. public function setTipoPresentacion($tipoPresentacion)
  642. {
  643. $this->tipo_presentacion = $tipoPresentacion;
  644.  
  645. return $this;
  646. }
  647.  
  648. /**
  649. * Get tipo_presentacion
  650. *
  651. * @return string
  652. */
  653. public function getTipoPresentacion()
  654. {
  655. return $this->tipo_presentacion;
  656. }
  657.  
  658. /**
  659. * Set opciones_con_imagenes
  660. *
  661. * @param boolean $opcionesConImagenes
  662. * @return SelMultiple
  663. */
  664. public function setOpcionesConImagenes($opcionesConImagenes)
  665. {
  666. $this->opciones_con_imagenes = $opcionesConImagenes;
  667.  
  668. return $this;
  669. }
  670.  
  671. /**
  672. * Get opciones_con_imagenes
  673. *
  674. * @return boolean
  675. */
  676. public function getOpcionesConImagenes()
  677. {
  678. return $this->opciones_con_imagenes;
  679. }
  680.  
  681. /**
  682. * Get id
  683. *
  684. * @return integer
  685. */
  686. public function getId()
  687. {
  688. return $this->id;
  689. }
  690.  
  691. /**
  692. * Set orden
  693. *
  694. * @param integer $orden
  695. * @return SelMultiple
  696. */
  697. public function setOrden($orden)
  698. {
  699. $this->orden = $orden;
  700.  
  701. return $this;
  702. }
  703.  
  704. /**
  705. * Get orden
  706. *
  707. * @return integer
  708. */
  709. public function getOrden()
  710. {
  711. return $this->orden;
  712. }
  713.  
  714. /**
  715. * Set respuesta_obligatoria
  716. *
  717. * @param boolean $respuestaObligatoria
  718. * @return SelMultiple
  719. */
  720. public function setRespuestaObligatoria($respuestaObligatoria)
  721. {
  722. $this->respuesta_obligatoria = $respuestaObligatoria;
  723.  
  724. return $this;
  725. }
  726.  
  727. /**
  728. * Get respuesta_obligatoria
  729. *
  730. * @return boolean
  731. */
  732. public function getRespuestaObligatoria()
  733. {
  734. return $this->respuesta_obligatoria;
  735. }
  736.  
  737. /**
  738. * Set texto
  739. *
  740. * @param string $texto
  741. * @return SelMultiple
  742. */
  743. public function setTexto($texto)
  744. {
  745. $this->texto = $texto;
  746.  
  747. return $this;
  748. }
  749.  
  750. /**
  751. * Get texto
  752. *
  753. * @return string
  754. */
  755. public function getTexto()
  756. {
  757. return $this->texto;
  758. }
  759.  
  760. /**
  761. * Add opciones
  762. *
  763. * @param W_Encuestas\EncuestasBundle\Entity\Opcion $opciones
  764. * @return SelMultiple
  765. */
  766. public function addOpcione(\W_Encuestas\EncuestasBundle\Entity\Opcion $opciones)
  767. {
  768. $this->opciones[] = $opciones;
  769.  
  770. return $this;
  771. }
  772.  
  773. /**
  774. * Remove opciones
  775. *
  776. * @param W_Encuestas\EncuestasBundle\Entity\Opcion $opciones
  777. */
  778. public function removeOpcione(\W_Encuestas\EncuestasBundle\Entity\Opcion $opciones)
  779. {
  780. $this->opciones->removeElement($opciones);
  781. }
  782.  
  783. /**
  784. * Get opciones
  785. *
  786. * @return Doctrine\Common\Collections\Collection
  787. */
  788. public function getOpciones()
  789. {
  790. return $this->opciones;
  791. }
  792.  
  793. /**
  794. * Set encuesta
  795. *
  796. * @param W_Encuestas\EncuestasBundle\Entity\Encuesta $encuesta
  797. * @return SelMultiple
  798. */
  799. public function setEncuesta(\W_Encuestas\EncuestasBundle\Entity\Encuesta $encuesta = null)
  800. {
  801. $this->encuesta = $encuesta;
  802.  
  803. return $this;
  804. }
  805.  
  806. /**
  807. * Get encuesta
  808. *
  809. * @return W_Encuestas\EncuestasBundle\Entity\Encuesta
  810. */
  811. public function getEncuesta()
  812. {
  813. return $this->encuesta;
  814. }
  815. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement