예제 #1
0
 /**
  * @param WordCount_Struct $wordCount_Struct
  *
  * @return WordCount_Struct
  * @throws Exception
  */
 public function updateDB(WordCount_Struct $wordCount_Struct)
 {
     $res = updateWordCount($wordCount_Struct);
     if ($res < 0) {
         throw new Exception("Failed to update counter", $res);
     }
     $newWCount = new WordCount_Struct();
     $newWCount->setNewWords($this->oldWCount->getNewWords() + $wordCount_Struct->getNewWords());
     $newWCount->setTranslatedWords($this->oldWCount->getTranslatedWords() + $wordCount_Struct->getTranslatedWords());
     $newWCount->setApprovedWords($this->oldWCount->getApprovedWords() + $wordCount_Struct->getApprovedWords());
     $newWCount->setRejectedWords($this->oldWCount->getRejectedWords() + $wordCount_Struct->getRejectedWords());
     $newWCount->setDraftWords($this->oldWCount->getDraftWords() + $wordCount_Struct->getDraftWords());
     $newWCount->setIdSegment($this->oldWCount->getIdSegment());
     $newWCount->setOldStatus($this->oldStatus);
     $newWCount->setNewStatus($this->newStatus);
     $newWCount->setIdJob($this->oldWCount->getIdJob());
     $newWCount->setJobPassword($this->oldWCount->getJobPassword());
     return $newWCount;
 }
예제 #2
0
파일: Counter.php 프로젝트: reysub/MateCat
 /**
  * @param WordCount_Struct[] $wordCount_Struct
  *
  * @return WordCount_Struct
  */
 public function sumDifferentials($wordCount_Struct)
 {
     $newWCount = new WordCount_Struct();
     $newWCount->setIdSegment($this->oldWCount->getIdSegment());
     $newWCount->setOldStatus($this->oldStatus);
     $newWCount->setNewStatus($this->newStatus);
     $newWCount->setIdJob($this->oldWCount->getIdJob());
     $newWCount->setJobPassword($this->oldWCount->getJobPassword());
     /**
      * @var WordCount_Struct $count
      */
     foreach ($wordCount_Struct as $count) {
         $newWCount->setNewWords($newWCount->getNewWords() + $count->getNewWords());
         $newWCount->setTranslatedWords($newWCount->getTranslatedWords() + $count->getTranslatedWords());
         $newWCount->setApprovedWords($newWCount->getApprovedWords() + $count->getApprovedWords());
         $newWCount->setRejectedWords($newWCount->getRejectedWords() + $count->getRejectedWords());
         $newWCount->setDraftWords($newWCount->getDraftWords() + $count->getDraftWords());
     }
     return $newWCount;
 }