private function buildSubclassesForModel($formSubclasses, CeModelInterface $model)
 {
     $subclasses = array();
     foreach ($model->getChildren() as $childModel) {
         foreach ($childModel->getModelEntities() as $modelEntity) {
             /** @var $subclass Subclass */
             $subclass = $modelEntity->getSubclass();
             if (!isset($subclasses[$subclass->getSource()->getId()])) {
                 foreach ($formSubclasses as $formSubclass) {
                     if ($formSubclass->getSource()->getId() == $subclass->getSource()->getId()) {
                         $subclass->setExpectedPerformance($formSubclass->getExpectedPerformance());
                         $subclass->setAccountType($formSubclass->getAccountType());
                         break;
                     }
                 }
                 $subclasses[$subclass->getSource()->getId()] = $subclass;
             }
         }
     }
     foreach ($formSubclasses as $formSubclass) {
         $sourceId = $formSubclass->getSource()->getId();
         if (!isset($subclasses[$sourceId])) {
             $formAsset = $formSubclass->getAssetClass();
             $identicalSourceId = null;
             foreach ($formSubclasses as $tmpFormSubclass) {
                 $tmpFormAsset = $tmpFormSubclass->getAssetClass();
                 $tmpSourceId = $tmpFormSubclass->getSource()->getId();
                 if (isset($subclasses[$tmpSourceId]) && $formAsset === $tmpFormAsset) {
                     $identicalSourceId = $tmpSourceId;
                     break;
                 }
             }
             if ($identicalSourceId) {
                 $asset = $subclasses[$identicalSourceId]->getAssetClass();
                 $formSubclass->setAssetClass($asset);
                 $this->em->persist($formSubclass);
             } else {
                 $oldAsset = $formSubclass->getAssetClass();
                 $newAsset = $oldAsset->getCopy();
                 $oldAsset->removeSubclasse($formSubclass);
                 $newAsset->addSubclasse($formSubclass);
                 $formSubclass->setAssetClass($newAsset);
                 $subclasses[$sourceId] = $formSubclass;
             }
         }
     }
 }
 /**
  * Get forecast
  *
  * @return int|null
  */
 public function getForecast()
 {
     return $this->model->getForecast();
 }
Beispiel #3
0
 /**
  * Mark model as deleted
  *
  * @param CeModelInterface $model
  */
 public function deleteModel(CeModelInterface $model)
 {
     $model->setIsDeleted(true);
     $this->objectManager->persist($model);
     $childModels = $this->getChildModels($model);
     /** @var CeModelInterface $child */
     foreach ($childModels as $child) {
         $riskRating = $child->getRiskRating();
         if ($riskRating > $model->getRiskRating()) {
             $child->setRiskRating($riskRating - 1);
             $this->objectManager->persist($child);
         }
     }
     $this->objectManager->flush();
 }