Advertisement
Guest User

Submission.php

a guest
Jan 14th, 2014
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.28 KB | None | 0 0
  1. <?php
  2.  
  3. namespace SciForum\Version2Bundle\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6.  
  7. use Symfony\Component\Validator\Mapping\ClassMetadata;
  8. use Symfony\Component\Validator\Constraints\NotBlank;
  9. use Symfony\Component\Validator\Constraints\MinLength;
  10. use Symfony\Component\Validator\Constraints\MaxLength;
  11.  
  12. /**
  13.  * @ORM\Entity(repositoryClass="SciForum\Version2Bundle\Repository\SubmissionRepository")
  14.  * @ORM\Table(name="submission")
  15.  * @ORM\HasLifecycleCallbacks()
  16.  */
  17. class Submission
  18. {
  19.     /**
  20.      * @ORM\Column(name="`id`", type="integer", unique=true, nullable=true)
  21.      */
  22.     protected $id;
  23.    
  24.     /**
  25.      * @ORM\Id
  26.      * @ORM\Column(name="`hash_key`", type="text", unique=true)
  27.      */
  28.     protected $hash_key;
  29.  
  30.     /**
  31.      * @ORM\Column(type="integer")
  32.      */
  33.     protected $user_id;
  34.  
  35.     /**
  36.      * @ORM\Column(type="integer")
  37.      */
  38.     protected $page_id;
  39.  
  40.     /**
  41.      * @ORM\Column(type="integer")
  42.      */
  43.     protected $conference_id;
  44.  
  45.     /**
  46.      * @ORM\Column(type="integer")
  47.      */
  48.     protected $section_id;
  49.  
  50.     /**
  51.      * @ORM\Column(type="text")
  52.      */
  53.     protected $title;
  54.  
  55.     /**
  56.      * @ORM\Column(type="text")
  57.      */
  58.     protected $abstract;
  59.  
  60.     /**
  61.      * @ORM\Column(type="text")
  62.      */
  63.     protected $keywords;
  64.  
  65.     /**
  66.      * @ORM\Column(type="integer")
  67.      */
  68.     protected $status_id;
  69.  
  70.     /**
  71.      * @ORM\ManyToOne(targetEntity="PaperState", inversedBy="submission_states")
  72.      * @ORM\JoinColumn(name="status_id", referencedColumnName="id")
  73.      */
  74.     protected $state;
  75.  
  76.     /**
  77.      * @ORM\Column(type="datetime")
  78.      */
  79.     protected $last_action;
  80.  
  81.     /**
  82.      * @ORM\Column(type="datetime")
  83.      */
  84.     protected $submission_date;
  85.    
  86.     /**
  87.      * @ORM\OneToOne(targetEntity="SubmissionPage", mappedBy="submission")
  88.      */
  89.     protected $page;
  90.    
  91.     /**
  92.      * @ORM\ManyToOne(targetEntity="Conference", inversedBy="submissions")
  93.      * @ORM\JoinColumn(name="conference_id", referencedColumnName="id")
  94.      */
  95.     protected $conference;
  96.    
  97.     /**
  98.      * @ORM\ManyToOne(targetEntity="Section", inversedBy="submission")
  99.      * @ORM\JoinColumn(name="section_id", referencedColumnName="id")
  100.      **/
  101.     protected $section;
  102.    
  103.     /**
  104.      * @ORM\OneToMany(targetEntity="SubmissionAuthor", mappedBy="submission")
  105.      * @ORM\OrderBy({"sortings" = "ASC"})
  106.      */
  107.     protected $authors;
  108.    
  109.     /**
  110.      * @ORM\OneToMany(targetEntity="SubmissionHistory", mappedBy="submission")
  111.      */
  112.     protected $histories;
  113.    
  114.     /**
  115.      * @ORM\ManyToOne(targetEntity="User", inversedBy="submissions")
  116.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
  117.      */
  118.     protected $user;
  119.    
  120.     /**
  121.      * @ORM\OneToOne(targetEntity="Paper", inversedBy="submission")
  122.      * @ORM\JoinColumn(name="id", referencedColumnName="id")
  123.      */
  124.     protected $paper;
  125.  
  126.    
  127.     public function __construct()
  128.     {
  129.         $randNbr = rand();
  130.         $this->hash_key = md5( time() * $randNbr );
  131.     }
  132.  
  133.     /**
  134.      * Get id
  135.      *
  136.      * @return integer
  137.      */
  138.     public function getId()
  139.     {
  140.         return $this->id;
  141.     }
  142.  
  143.     /**
  144.      * Set hash_key
  145.      *
  146.      * @param text $hashKey
  147.      */
  148.     public function setHashKey($hashKey)
  149.     {
  150.         $this->hash_key = $hashKey;
  151.     }
  152.  
  153.     /**
  154.      * Get hash_key
  155.      *
  156.      * @return text
  157.      */
  158.     public function getHashKey()
  159.     {
  160.         return $this->hash_key;
  161.     }
  162.  
  163.     /**
  164.      * Set user_id
  165.      *
  166.      * @param integer $userId
  167.      */
  168.     public function setUserId($userId)
  169.     {
  170.         $this->user_id = $userId;
  171.     }
  172.  
  173.     /**
  174.      * Get user_id
  175.      *
  176.      * @return integer
  177.      */
  178.     public function getUserId()
  179.     {
  180.         return $this->user_id;
  181.     }
  182.  
  183.     /**
  184.      * Set page_id
  185.      *
  186.      * @param integer $pageId
  187.      */
  188.     public function setPageId($pageId)
  189.     {
  190.         $this->page_id = $pageId;
  191.     }
  192.  
  193.     /**
  194.      * Get page_id
  195.      *
  196.      * @return integer
  197.      */
  198.     public function getPageId()
  199.     {
  200.         return $this->page_id;
  201.     }
  202.  
  203.     /**
  204.      * Set conference_id
  205.      *
  206.      * @param integer $conferenceId
  207.      */
  208.     public function setConferenceId($conferenceId)
  209.     {
  210.         $this->conference_id = $conferenceId;
  211.     }
  212.  
  213.     /**
  214.      * Get conference_id
  215.      *
  216.      * @return integer
  217.      */
  218.     public function getConferenceId()
  219.     {
  220.         return $this->conference_id;
  221.     }
  222.  
  223.     /**
  224.      * Set section_id
  225.      *
  226.      * @param integer $sectionId
  227.      */
  228.     public function setSectionId($sectionId)
  229.     {
  230.         $this->section_id = $sectionId;
  231.     }
  232.  
  233.     /**
  234.      * Get section_id
  235.      *
  236.      * @return integer
  237.      */
  238.     public function getSectionId()
  239.     {
  240.         return $this->section_id;
  241.     }
  242.  
  243.     /**
  244.      * Set title
  245.      *
  246.      * @param text $title
  247.      */
  248.     public function setTitle($title)
  249.     {
  250.         $title = trim( $title );
  251.         $this->title = $title;
  252.     }
  253.  
  254.     /**
  255.      * Get title
  256.      *
  257.      * @return text
  258.      */
  259.     public function getTitle()
  260.     {
  261.         return $this->title;
  262.     }
  263.  
  264.     /**
  265.      * Set abstract
  266.      *
  267.      * @param text $abstract
  268.      */
  269.     public function setAbstract($abstract)
  270.     {
  271.         $abstract = trim( $abstract );
  272.         $this->abstract = $abstract;
  273.     }
  274.  
  275.     /**
  276.      * Get abstract
  277.      *
  278.      * @return text
  279.      */
  280.     public function getAbstract()
  281.     {
  282.         return $this->abstract;
  283.     }
  284.  
  285.     /**
  286.      * Set keywords
  287.      *
  288.      * @param text $keywords
  289.      */
  290.     public function setKeywords($keywords)
  291.     {
  292.         $keywords = trim( $keywords );
  293.         $this->keywords = $keywords;
  294.     }
  295.  
  296.     /**
  297.      * Get keywords
  298.      *
  299.      * @return text
  300.      */
  301.     public function getKeywords()
  302.     {
  303.         return $this->keywords;
  304.     }
  305.  
  306.     /**
  307.      * Set status_id
  308.      *
  309.      * @param integer $statusId
  310.      */
  311.     public function setStatusId($statusId)
  312.     {
  313.         $this->status_id = $statusId;
  314.     }
  315.  
  316.     /**
  317.      * Get status_id
  318.      *
  319.      * @return integer
  320.      */
  321.     public function getStatusId()
  322.     {
  323.         return $this->status_id;
  324.     }
  325.  
  326.     /**
  327.      * Set last_action
  328.      *
  329.      * @param datetime $lastAction
  330.      */
  331.     public function setLastAction($lastAction)
  332.     {
  333.         $this->last_action = $lastAction;
  334.     }
  335.  
  336.     /**
  337.      * Get last_action
  338.      *
  339.      * @return datetime
  340.      */
  341.     public function getLastAction()
  342.     {
  343.         return $this->last_action;
  344.     }
  345.  
  346.     /**
  347.      * Set submission_date
  348.      *
  349.      * @param datetime $submissionDate
  350.      */
  351.     public function setSubmissionDate($submissionDate)
  352.     {
  353.         $this->submission_date = $submissionDate;
  354.     }
  355.  
  356.     /**
  357.      * Get submission_date
  358.      *
  359.      * @return datetime
  360.      */
  361.     public function getSubmissionDate()
  362.     {
  363.         return $this->submission_date;
  364.     }
  365.  
  366.     /**
  367.      * Set id
  368.      *
  369.      * @param integer $id
  370.      */
  371.     public function setId($id)
  372.     {
  373.         $this->id = $id;
  374.     }
  375.  
  376.     /**
  377.      * Set page
  378.      *
  379.      * @param SciForum\Version2Bundle\Entity\SubmissionPage $page
  380.      */
  381.     public function setPage(\SciForum\Version2Bundle\Entity\SubmissionPage $page)
  382.     {
  383.         $this->page = $page;
  384.     }
  385.  
  386.     /**
  387.      * Get page
  388.      *
  389.      * @return SciForum\Version2Bundle\Entity\SubmissionPage
  390.      */
  391.     public function getPage()
  392.     {
  393.         return $this->page;
  394.     }
  395.  
  396.     /**
  397.      * Set conference
  398.      *
  399.      * @param SciForum\Version2Bundle\Entity\Conference $conference
  400.      */
  401.     public function setConference(\SciForum\Version2Bundle\Entity\Conference $conference)
  402.     {
  403.         $this->conference = $conference;
  404.     }
  405.  
  406.     /**
  407.      * Get conference
  408.      *
  409.      * @return SciForum\Version2Bundle\Entity\Conference
  410.      */
  411.     public function getConference()
  412.     {
  413.         return $this->conference;
  414.     }
  415.  
  416.     /**
  417.      * Set section
  418.      *
  419.      * @param SciForum\Version2Bundle\Entity\Section $section
  420.      */
  421.     public function setSection(\SciForum\Version2Bundle\Entity\Section $section)
  422.     {
  423.         $this->section = $section;
  424.     }
  425.  
  426.     /**
  427.      * Get section
  428.      *
  429.      * @return SciForum\Version2Bundle\Entity\Section
  430.      */
  431.     public function getSection()
  432.     {
  433.         return $this->section;
  434.     }
  435.    
  436.     public static function loadValidatorMetadata(ClassMetadata $metadata)
  437.     {
  438.         $title_blank    = new NotBlank();
  439.         $title_min      = new MinLength(4);
  440.        
  441.         $abstract_blank = new NotBlank();
  442.         $abstract_min   = new MinLength(10);
  443.        
  444.         $title_blank->message       = "The title should not be blank";
  445.         $title_min->message         = "The title is too short. It should have {{ limit }} characters or more";
  446.        
  447.         $abstract_blank->message    = "The abstract should not be blank";
  448.         $abstract_min->message      = "The abstract is too short. It should have {{ limit }} characters or more";
  449.        
  450.         $metadata->addPropertyConstraint('title', $title_blank);
  451.         $metadata->addPropertyConstraint('title', $title_min);
  452.         $metadata->addPropertyConstraint('abstract', $abstract_blank);
  453.         $metadata->addPropertyConstraint('abstract', $abstract_min );
  454.     }
  455.  
  456.     /**
  457.      * Add authors
  458.      *
  459.      * @param SciForum\Version2Bundle\Entity\SubmissionAuthor $authors
  460.      */
  461.     public function addSubmissionAuthor(\SciForum\Version2Bundle\Entity\SubmissionAuthor $authors)
  462.     {
  463.         $this->authors[] = $authors;
  464.     }
  465.  
  466.  
  467.     /**
  468.      * Set state
  469.      *
  470.      * @param SciForum\Version2Bundle\Entity\PaperState $state
  471.      */
  472.     public function setState(\SciForum\Version2Bundle\Entity\PaperState $state)
  473.     {
  474.         $this->state = $state;
  475.     }
  476.  
  477.     /**
  478.      * Get state
  479.      *
  480.      * @return SciForum\Version2Bundle\Entity\PaperState
  481.      */
  482.     public function getState()
  483.     {
  484.         return $this->state;
  485.     }
  486.  
  487.     /**
  488.      * Set user
  489.      *
  490.      * @param SciForum\Version2Bundle\Entity\User $user
  491.      */
  492.     public function setUser(\SciForum\Version2Bundle\Entity\User $user)
  493.     {
  494.         $this->user = $user;
  495.     }
  496.  
  497.     /**
  498.      * Get user
  499.      *
  500.      * @return SciForum\Version2Bundle\Entity\User
  501.      */
  502.     public function getUser()
  503.     {
  504.         return $this->user;
  505.     }
  506.  
  507.     /**
  508.      * Add histories
  509.      *
  510.      * @param SciForum\Version2Bundle\Entity\SubmissionHistory $histories
  511.      */
  512.     public function addSubmissionHistory(\SciForum\Version2Bundle\Entity\SubmissionHistory $histories)
  513.     {
  514.         $this->histories[] = $histories;
  515.     }
  516.  
  517.     /**
  518.      * Get histories
  519.      *
  520.      * @return Doctrine\Common\Collections\Collection
  521.      */
  522.     public function getHistories()
  523.     {
  524.         return $this->histories;
  525.     }
  526.  
  527.     /**
  528.      * Set paper
  529.      *
  530.      * @param SciForum\Version2Bundle\Entity\Paper $paper
  531.      */
  532.     public function setPaper(\SciForum\Version2Bundle\Entity\Paper $paper)
  533.     {
  534.         $this->paper = $paper;
  535.     }
  536.  
  537.     /**
  538.      * Get paper
  539.      *
  540.      * @return SciForum\Version2Bundle\Entity\Paper
  541.      */
  542.     public function getPaper()
  543.     {
  544.         return $this->paper;
  545.     }
  546.  
  547.     /**
  548.      * Get authors
  549.      *
  550.      * @return Doctrine\Common\Collections\Collection
  551.      */
  552.     public function getAuthors()
  553.     {
  554.         return $this->authors;
  555.     }
  556. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement