コード例 #1
0
ファイル: PersonMerger.php プロジェクト: JhnMhf/SimpleProject
 public function createMergedWeddingObj(\UR\DB\NewBundle\Entity\Wedding $dataMasterWedding, \UR\DB\NewBundle\Entity\Wedding $toBeDeletedWedding)
 {
     //husband/ wife?
     $dataMasterWedding->setWeddingDate($this->mergeDateReference($dataMasterWedding->getWeddingDate(), $toBeDeletedWedding->getWeddingDate()));
     $dataMasterWedding->setWeddingLocation($this->mergeLocationObject($dataMasterWedding->getWeddingLocation(), $toBeDeletedWedding->getWeddingLocation()));
     $dataMasterWedding->setWeddingTerritory($this->mergeTerritoryObject($dataMasterWedding->getWeddingTerritory(), $toBeDeletedWedding->getWeddingTerritory()));
     $dataMasterWedding->setBannsDate($this->mergeDateReference($dataMasterWedding->getBannsDate(), $toBeDeletedWedding->getBannsDate()));
     $dataMasterWedding->setBreakupReason($this->mergeStrings($dataMasterWedding->getBreakupReason(), $toBeDeletedWedding->getBreakupReason()));
     $dataMasterWedding->setBreakupDate($this->mergeDateReference($dataMasterWedding->getBreakupDate(), $toBeDeletedWedding->getBreakupDate()));
     $dataMasterWedding->setMarriageComment($this->mergeComment($dataMasterWedding->getMarriageComment(), $toBeDeletedWedding->getMarriageComment()));
     $dataMasterWedding->setBeforeAfter($this->mergeStrings($dataMasterWedding->getBeforeAfter(), $toBeDeletedWedding->getBeforeAfter()));
     $dataMasterWedding->setProvenDate($this->mergeDateReference($dataMasterWedding->getProvenDate(), $toBeDeletedWedding->getProvenDate()));
     $dataMasterWedding->setComment($this->mergeComment($dataMasterWedding->getComment(), $toBeDeletedWedding->getComment()));
     $toBeDeletedWedding->setWeddingDate(null);
     $toBeDeletedWedding->setBannsDate(null);
     $toBeDeletedWedding->setBreakupDate(null);
     $toBeDeletedWedding->setProvenDate(null);
     return $dataMasterWedding;
 }
コード例 #2
0
ファイル: MigrateData.php プロジェクト: JhnMhf/SimpleProject
 public function migrateWedding($weddingOrder, $personOne, $personTwo, $weddingDate = null, $weddingLocation = null, $weddingTerritory = null, $bannsDate = null, $breakupReason = null, $breakupDate = null, $marriageComment = null, $beforeAfter = null, $comment = null, $provenDate = null)
 {
     //create new wedding obj
     $newWedding = new Wedding();
     $husband = $personOne;
     $wife = $personTwo;
     if ($personTwo != null && $personTwo->getGender() == 1 || $personOne != null && $personOne->getGender() == 2) {
         //personTwo is husband, since he is male or personOne is female
         $husband = $personTwo;
         $wife = $personOne;
     }
     $this->LOGGER->info("Adding wedding between Husband: " . $husband . " and Wife: " . $wife . " at order: " . $weddingOrder);
     $newWedding->setHusbandId($husband != null ? $husband->getId() : null);
     $newWedding->setWifeId($wife != null ? $wife->getId() : null);
     $newWedding->setWeddingOrder($weddingOrder);
     $newWedding->setWeddingDate($this->getDate($weddingDate));
     $newWedding->setWeddingLocation($this->getLocation($weddingLocation));
     $newWedding->setWeddingTerritory($this->getTerritory($weddingTerritory, $weddingLocation));
     $newWedding->setBannsDate($this->getDate($bannsDate));
     $newWedding->setBreakupReason($this->normalize($breakupReason));
     $newWedding->setBreakupDate($this->getDate($breakupDate));
     $newWedding->setMarriageComment($this->normalize($marriageComment));
     $newWedding->setBeforeAfter($beforeAfter);
     $newWedding->setComment($this->normalize($comment));
     $newWedding->setProvenDate($this->getDate($provenDate));
     $existingWedding = $this->checkIfWeddingAlreadyExists($weddingOrder, $personOne, $personTwo);
     if (is_null($existingWedding)) {
         //persist new wedding obj
         $this->getDBManager()->persist($newWedding);
         $this->getDBManager()->flush();
     } else {
         //merge with existing wedding
         $this->LOGGER->info("Merging new wedding with existing wedding.");
         $existingWedding = $this->get("person_merging.service")->createMergedWeddingObj($existingWedding, $newWedding);
         $this->getDBManager()->persist($existingWedding);
         $this->getDBManager()->flush();
     }
 }