コード例 #1
0
 public function parseTheLightdataStringFromRequest($datastring)
 {
     //Instantiate an empty array for each possible type of missing nodes within the lightdata string.
     $array_of_missing_nodes = array();
     $missing_setup_nodes = array();
     $missing_groupings_node = array();
     $touchpoints_missing_nodes = array();
     $budgetallocation_missing_nodes = array();
     $timeallocation_missing_nodes = array();
     $the_start_date = null;
     //Instantiate a variable to check if there were errors on parsing the data to the db (if the string was malformed)
     $error_on_parsing = false;
     $contentOfJsonFile = $datastring;
     $em = $this->getDoctrine()->getManager();
     //Create a new Lightdata UUID
     $lightdata_uuid = Uuid::uuid4()->toString();
     $lightdata = new Lightdata();
     $lightdata->setInputstring($contentOfJsonFile);
     //Decode the Json File to an Array.
     $arrayOfJsonObjects = json_decode($contentOfJsonFile, true);
     $project_data = $arrayOfJsonObjects;
     if (isset($arrayOfJsonObjects['Project'])) {
         $project_data = $arrayOfJsonObjects['Project'];
     }
     //INSTANTIATE THE LIGHTDATA OBJECT
     ////////////////////////////////////////////////////////////////
     //Assign Project SETUP Data
     ////////////////////////////////////////////////////////////////
     //Grab setup array from the whole array.
     if (isset($project_data['Setup'])) {
         $setup_data = $project_data['Setup'];
         $client = new ClientLD();
         $target = new TargetLD();
         $survey = new SurveyLD();
         $setup = new SetupLD();
         //Assign The Client Data or add Node to Missing Setup Nodes.
         if (isset($setup_data['Client'])) {
             $client->setName($setup_data['Client']['Name']);
             $client->setDbid($setup_data['Client']['DbID']);
             $setup->setClient($client);
         } else {
             $missing_setup_nodes[] = 'Client';
         }
         //Assign The Target Data or add Node to Missing Setup Nodes.
         if (isset($setup_data['Target'])) {
             $target->setName($setup_data['Target']['Name']);
             $target->setDbid($setup_data['Target']['DbID']);
             $setup->setTarget($target);
         } else {
             $missing_setup_nodes[] = 'Target';
         }
         //Assign The Survey Data or add Node to Missing Setup Nodes.
         if (isset($setup_data['Survey'])) {
             $survey->setName($setup_data['Survey']['Name']);
             $survey->setDbid($setup_data['Survey']['DbID']);
             $setup->setSurvey($survey);
         } else {
             $missing_setup_nodes[] = 'Survey';
         }
         //Assign The ProjectName Data or add Node to Missing Setup Nodes.
         if (isset($setup_data['ProjectName'])) {
             $setup->setProjectName($setup_data['ProjectName']);
         } else {
             $missing_setup_nodes[] = 'ProjectName';
         }
         //Assign The Start Date or add Node to Missing Setup Nodes.
         if (isset($setup_data['StartDate'])) {
             $setup->setStartDate(new \DateTime($setup_data['StartDate']));
             $the_start_date = new \DateTime($setup_data['StartDate']);
         } else {
             $missing_setup_nodes[] = 'StartDate';
             $the_start_date = null;
         }
         //Assign The PeriodType Data or add Node to Missing Setup Nodes.
         if (isset($setup_data['PeriodType'])) {
             $setup->setPeriodType($setup_data['PeriodType']);
         } else {
             $missing_setup_nodes[] = 'PeriodType';
         }
         //Assign The NbPeriods Data or add Node to Missing Setup Nodes.
         if (isset($setup_data['NbPeriods'])) {
             $setup->setNbPeriods($setup_data['NbPeriods']);
         } else {
             $missing_setup_nodes[] = 'NbPeriods';
         }
         //Assign The Budget Data or add Node to Missing Setup  Nodes.
         if (isset($setup_data['Budget'])) {
             $setup->setBudget($setup_data['Budget']);
         } else {
             $missing_setup_nodes[] = 'Budget';
         }
         //Assign The BudgetCurrency Data or add Node to Missing Setup Nodes.
         if (isset($setup_data['BudgetCurrency'])) {
             $setup->setBudgetCurrency($setup_data['BudgetCurrency']);
         } else {
             $missing_setup_nodes[] = 'BudgetCurrency';
         }
         $setup->setLightdata($lightdata);
         $lightdata->setSetup($setup);
     } else {
         $error_on_parsing = true;
         $array_of_missing_nodes[] = "Setup";
     }
     //Assign The CurrentGroupingIndex Data or add Node to Missing Nodes.
     if (isset($project_data['CurrentGroupingIndex'])) {
         $lightdata->setCurrentgroupingindex($project_data['CurrentGroupingIndex']);
     } else {
         $array_of_missing_nodes[] = 'CurrentGroupingIndex';
     }
     ////////////////////////////////////////////////////////////////
     ////////////////////////////////////////////////////////////////
     ////////////////////////////////////////////////////////////////
     //Assign OBJECTIVES Data
     ////////////////////////////////////////////////////////////////
     //ONLY ADD IF EXISTS
     if (isset($project_data['Objectives'])) {
         $objectives_data = $project_data['Objectives'];
         foreach ($objectives_data as $objective_data) {
             $objective = new ObjectiveLD();
             $objective->setName($objective_data['Name']);
             $objective->setHtmlcolor($objective_data['HtmlColor']);
             $objective->setSelected($objective_data['Selected']);
             $objective->setScore($objective_data['Score']);
             $objective->setLightdata($lightdata);
             $lightdata->addObjective($objective);
         }
     } else {
         $array_of_missing_nodes[] = 'Objectives';
     }
     ////////////////////////////////////////////////////////////////
     ////////////////////////////////////////////////////////////////
     ////////////////////////////////////////////////////////////////
     //Assign GROUPINGS Data
     ////////////////////////////////////////////////////////////////
     if (isset($project_data['Groupings'])) {
         $groupings_data = $project_data['Groupings'];
         foreach ($groupings_data as $grouping_data) {
             if (isset($grouping_data['Name'])) {
                 $grouping = new GroupingLD();
                 $grouping->setName($grouping_data['Name']);
                 $grouping->setLightdata($lightdata);
                 if (isset($grouping_data['Categories'])) {
                     foreach ($grouping_data['Categories'] as $groupings_cateogry) {
                         $groupingcategory = new GroupingCategoryLD();
                         $groupingcategory->setGrouping($grouping);
                         $groupingcategory->setName($groupings_cateogry['Name']);
                         $groupingcategory->setHtmlcolor($groupings_cateogry['HtmlColor']);
                         $grouping->addGroupingcategory($groupingcategory);
                     }
                 } else {
                     $missing_groupings_node[] = "Categories";
                 }
                 if (isset($grouping_data['TouchpointCategoryMap'])) {
                     foreach ($grouping_data['TouchpointCategoryMap'] as $key => $value) {
                         $groupingstouchpointcategorymap = new GroupingTouchpointCategoryMapLD();
                         $groupingstouchpointcategorymap->setGrouping($grouping);
                         $groupingstouchpointcategorymap->setName($key);
                         $groupingstouchpointcategorymap->setValue($value);
                         $grouping->addGroupingtouchpointcategorymap($groupingstouchpointcategorymap);
                     }
                 } else {
                     $missing_groupings_node[] = "TouchpointCategoryMap";
                 }
                 $lightdata->addGrouping($grouping);
             } else {
                 $missing_groupings_node[] = "Groupings Node Availlable, Data Inside Missing.";
             }
         }
     } else {
         $array_of_missing_nodes[] = "Groupings";
     }
     //END FOREACH GROUPING
     ////////////////////////////////////////////////////////////////
     ////////////////////////////////////////////////////////////////
     //ASSIGN THE CURRENT GROUPING INDEX , TO THE LIGHTDATA ENTITI DIRECTLY
     //ASSIGN THE CURRENT GROUPING INDEX , TO THE LIGHTDATA ENTITI DIRECTLY
     ////////////////////////////////////////////////////////////////
     ////////////////////////////////////////////////////////////////
     //ASSIGN TOUCHPOINTS , OBJECTIVESCORES AND ATTRIBUTESCORES FOR EACH TOUCHPOINT
     //ASSIGN TOUCHPOINTS , OBJECTIVESCORES AND ATTRIBUTESCORES FOR EACH TOUCHPOINT
     if (isset($project_data['Touchpoints'])) {
         $touchpoints_data = $project_data['Touchpoints'];
         foreach ($touchpoints_data as $touchpoint_data) {
             $touchpoint = new TouchpointLD();
             $touchpoint->setName($touchpoint_data['Name']);
             $touchpoint->setLocalname($touchpoint_data['LocalName']);
             $touchpoint->setHtmlcolor($touchpoint_data['HtmlColor']);
             $touchpoint->setSelected($touchpoint_data['Selected']);
             $touchpoint->setAggobjectivescore($touchpoint_data['AggObjectiveScore']);
             $touchpoint->setLightdata($lightdata);
             //EVEN IF TOUCHPOINTS NODE IS AVAILLABLE , WE SHOULD CHECK IF THERE ARE ANY TOUCHPOINTS SET.
             //EVEN IF TOUCHPOINTS NODE IS AVAILLABLE , WE SHOULD CHECK IF THERE ARE ANY TOUCHPOINTS SET.
             if (isset($touchpoint_data['ObjectiveScores'])) {
                 foreach ($touchpoint_data['ObjectiveScores'] as $touchpoint_objectivescore) {
                     $touchpointObjectiveScore = new TouchpointObjectiveScoreLD();
                     $touchpointObjectiveScore->setValue($touchpoint_objectivescore);
                     $touchpointObjectiveScore->setTouchpoint($touchpoint);
                     $touchpoint->addTouchpointobjectivescore($touchpointObjectiveScore);
                 }
             } else {
                 $touchpoints_missing_nodes[] = "ObjectiveScores";
             }
             if (isset($touchpoint_data['AttributeScores'])) {
                 foreach ($touchpoint_data['AttributeScores'] as $touchpoint_attributescore) {
                     $touchpointAttributeScore = new TouchpointAttributeScoreLD();
                     $touchpointAttributeScore->setValue($touchpoint_attributescore);
                     $touchpointAttributeScore->setTouchpoint($touchpoint);
                     $touchpoint->addTouchpointattributescore($touchpointAttributeScore);
                 }
             } else {
                 $touchpoints_missing_nodes[] = "AttributeScores";
             }
             $lightdata->addTouchpoint($touchpoint);
         }
     } else {
         $array_of_missing_nodes[] = "Touchpoints";
     }
     ////////////////////////////////////////////////////////////////
     ////////////////////////////////////////////////////////////////
     ////////////////////////////////////////////////////
     //ASSIGN CPRATTRIBUTES
     ////////////////////////////////////////////////////
     if (isset($project_data['CPRAttributes'])) {
         $cprattributes_data = $project_data['CPRAttributes'];
         foreach ($cprattributes_data as $cprattribute_data) {
             $cprattribute = new CPRAttributeLD();
             $cprattribute->setName($cprattribute_data['Name']);
             $cprattribute->setDescription($cprattribute_data['Description']);
             $cprattribute->setSelected($cprattribute_data['Selected']);
             $cprattribute->setLightdata($lightdata);
             $lightdata->addCprattribute($cprattribute);
         }
     } else {
         $array_of_missing_nodes[] = "CPRAttributes";
     }
     ///////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////
     ////ASSIGN BUDGETALLOCATION
     ///////////////////////////////////////////////////////////////
     if (isset($project_data['BudgetAllocation'])) {
         $budgetallocation_data = $project_data['BudgetAllocation'];
         $budgetallocation = new BudgetAllocationLD();
         $lightdata->setBudgetallocation($budgetallocation);
         $budgetallocation->setLightdata($lightdata);
         ///ADD THE BUDGETALLOCATION ALLOCATEDTOUCHPOINTS
         if (isset($budgetallocation_data['AllocatedTouchpoints'])) {
             $ba_allocatedtouchpoints = $budgetallocation_data['AllocatedTouchpoints'];
             foreach ($ba_allocatedtouchpoints as $budgetallocation_allocatedtouchpoint) {
                 $AllocatedTouchpoint = new BAAllocatedTouchpointLD();
                 $AllocatedTouchpoint->setTouchpointname($budgetallocation_allocatedtouchpoint['TouchpointName']);
                 $AllocatedTouchpoint->setBudgetallocation($budgetallocation);
                 $budgetallocation->addAllocatedtouchpoint($AllocatedTouchpoint);
                 $allocation_data = $budgetallocation_allocatedtouchpoint['Allocation'];
                 $allocation = new BAATAllocationLD();
                 $allocation->setAllocatedtouchpoint($AllocatedTouchpoint);
                 $allocation->setBudget($allocation_data['Budget']);
                 $allocation->setCostpergrp($allocation_data['CostPerGRP']);
                 $allocation->setGrp($allocation_data['GRP']);
                 $AllocatedTouchpoint->setAllocation($allocation);
                 $result_data = $allocation_data['Result'];
                 $Result = new BAATAResultLD();
                 $Result->setAllocation($allocation);
                 $Result->setGlobalperformance($result_data['GlobalPerformance']);
                 $Result->setReach($result_data['Reach']);
                 $allocation->setResult($Result);
                 if (isset($result_data['IndividualPerformance'])) {
                     $individual_performances_data = $result_data['IndividualPerformance'];
                     foreach ($individual_performances_data as $individual_performance_data) {
                         $IndividualPerformance = new BAATARIndividualPerformanceLD();
                         $IndividualPerformance->setResult($Result);
                         $IndividualPerformance->setValue($individual_performance_data);
                         $Result->addIndividualperformance($IndividualPerformance);
                     }
                 } else {
                     //RETURN THAT NODE RESULT INDIVIDUALPERFORMANCE IS MISSING
                 }
             }
         } else {
             //RETURN THAT NODE RESULT ALLOCATEDTOUCHPOINTS IS MISSING
         }
         ///ADD THE BUDGETALLOCATION TOTAL
         if (isset($budgetallocation_data['Total'])) {
             $ba_total = $budgetallocation_data['Total'];
             $budgetallocation_total = new BATotalLD();
             $budgetallocation_total->setTouchpointname($ba_total['TouchpointName']);
             $budgetallocation_total->setBudgetallocation($budgetallocation);
             $budgetallocation->addTotal($budgetallocation_total);
             $total_data = $ba_total['Allocation'];
             $allocation = new BATOAllocationLD();
             $allocation->setAllocatedtouchpoint($budgetallocation_total);
             $allocation->setBudget($total_data['Budget']);
             $allocation->setCostpergrp($total_data['CostPerGRP']);
             $allocation->setGrp($total_data['GRP']);
             $budgetallocation_total->setAllocation($allocation);
             $result_data = $total_data['Result'];
             $Result = new BATOAResultLD();
             $Result->setAllocation($allocation);
             $Result->setGlobalperformance($result_data['GlobalPerformance']);
             $Result->setReach($result_data['Reach']);
             $allocation->setResult($Result);
             if (isset($result_data['IndividualPerformance'])) {
                 $individual_performances_data = $result_data['IndividualPerformance'];
                 foreach ($individual_performances_data as $individual_performance_data) {
                     $IndividualPerformance = new BATOARIndividualPerformanceLD();
                     $IndividualPerformance->setResult($Result);
                     $IndividualPerformance->setValue($individual_performance_data);
                     $Result->addIndividualperformance($IndividualPerformance);
                 }
             } else {
                 //RETURN THAT NODE RESULTDATA INDIVIDUALPERFORMANCE IS MISSING
             }
         } else {
             //RETURN THAT NODE BUDGETALLOCATION_TOTAL IS MISSING
         }
     } else {
         //RETURN THAT WHOLE BUDGETALLOCATION NODE IS MISSING
         $array_of_missing_nodes[] = "BudgetAllocation";
     }
     /////////////////////////////////////////
     // END OF ASSIGNS FOR BUDGETALLOCATION
     /////////////////////////////////////////
     ///////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////
     ////ASSIGN TIME ALLOCATION
     ///////////////////////////////////////////////////////////////
     if (isset($project_data['TimeAllocation'])) {
         $timeallocation_data = $project_data['TimeAllocation'];
         $timeallocation = new TimeAllocationLD();
         $lightdata->setTimeallocation($timeallocation);
         $timeallocation->setLightdata($lightdata);
         ///ADD THE TIMEALLOCATION ALLOCATEDTOUCHPOINTS
         //$timeallocation_missing_nodes
         if (isset($timeallocation_data['AllocatedTouchpoints'])) {
             $timeallocation_allocatedtouchpoints_data = $timeallocation_data['AllocatedTouchpoints'];
             foreach ($timeallocation_allocatedtouchpoints_data as $ta_allocatedtouchpoint) {
                 $TAAllocatedTouchpoint = new TAAllocatedTouchpointLD();
                 $TAAllocatedTouchpoint->setTouchpointname($ta_allocatedtouchpoint['TouchpointName']);
                 $TAAllocatedTouchpoint->setReachfrequency($ta_allocatedtouchpoint['ReachFrequency']);
                 $TAAllocatedTouchpoint->setTimeallocation($timeallocation);
                 $timeallocation->addAllocatedtouchpoint($TAAllocatedTouchpoint);
                 $allocations_by_period_data = $ta_allocatedtouchpoint['AllocationByPeriod'];
                 foreach ($allocations_by_period_data as $allocation_by_period) {
                     $AllocationByPeriod = new TAATAllocationByPeriod();
                     $AllocationByPeriod->setAllocatedtouchpoint($TAAllocatedTouchpoint);
                     $AllocationByPeriod->setBudget($allocation_by_period['Budget']);
                     $AllocationByPeriod->setCostpergrp($allocation_by_period['CostPerGRP']);
                     $AllocationByPeriod->setGrp($allocation_by_period['GRP']);
                     $TAAllocatedTouchpoint->addAllocationbyperiod($AllocationByPeriod);
                     $ABPresult_data = $allocation_by_period['Result'];
                     $ABPResult = new TAATABPResult();
                     $ABPResult->setAllocationbyperiod($AllocationByPeriod);
                     $ABPResult->setGlobalperformance($ABPresult_data['GlobalPerformance']);
                     $ABPResult->setReach($ABPresult_data['Reach']);
                     $AllocationByPeriod->setResult($ABPResult);
                     $ABPindividual_performances_data = $ABPresult_data['IndividualPerformance'];
                     foreach ($ABPindividual_performances_data as $individual_performance_data) {
                         $ABPIndividualPerformance = new TAATABPRIndividualPerformance();
                         $ABPIndividualPerformance->setResult($ABPResult);
                         $ABPIndividualPerformance->setValue($individual_performance_data);
                         $ABPResult->addIndividualperformance($ABPIndividualPerformance);
                     }
                 }
             }
         } else {
             $timeallocation_missing_nodes[] = "AllocatedTouchpoints";
         }
         ///ADD THE TIMEALLOCATION TOTAL
         //ONLYADD TOTAL IF IS SET
         if (isset($timeallocation_data['Total'])) {
             $timeallocation_total_data = $timeallocation_data['Total'];
             $TATotal = new TATotalLD();
             $TATotal->setTimeallocation($timeallocation);
             $TATotal->setTouchpointname($timeallocation_total_data['TouchpointName']);
             $TATotal->setReachfrequency($timeallocation_total_data['ReachFrequency']);
             $timeallocation->addTotal($TATotal);
             if (isset($timeallocation_total_data['AllocationByPeriod'])) {
                 $allocations_by_period_data_total = $timeallocation_total_data['AllocationByPeriod'];
                 foreach ($allocations_by_period_data_total as $allocation_by_period) {
                     $TotalAllocationByPeriod = new TATOAllocationByPeriod();
                     $TotalAllocationByPeriod->setAllocatedtouchpoint($TATotal);
                     $TotalAllocationByPeriod->setBudget($allocation_by_period['Budget']);
                     $TotalAllocationByPeriod->setCostpergrp($allocation_by_period['CostPerGRP']);
                     $TotalAllocationByPeriod->setGrp($allocation_by_period['GRP']);
                     $TATotal->addAllocationbyperiod($TotalAllocationByPeriod);
                     $TotalABPresult_data = $allocation_by_period['Result'];
                     $TotalABPResult = new TATOABPResult();
                     $TotalABPResult->setAllocationbyperiod($TotalAllocationByPeriod);
                     $TotalABPResult->setGlobalperformance($TotalABPresult_data['GlobalPerformance']);
                     $TotalABPResult->setReach($TotalABPresult_data['Reach']);
                     $TotalAllocationByPeriod->setResult($TotalABPResult);
                     $TotalABPindividual_performances_data = $TotalABPresult_data['IndividualPerformance'];
                     foreach ($TotalABPindividual_performances_data as $individual_performance_data) {
                         $TOABPIndividualPerformance = new TATOABPRIndividualPerformance();
                         $TOABPIndividualPerformance->setResult($TotalABPResult);
                         $TOABPIndividualPerformance->setValue($individual_performance_data);
                         $TotalABPResult->addIndividualperformance($TOABPIndividualPerformance);
                     }
                 }
             }
         } else {
             $timeallocation_missing_nodes[] = "Total";
         }
     } else {
         $array_of_missing_nodes[] = "TimeAllocation";
     }
     ////END ASSIGN TIME ALLOCATION
     ////ASSIGN THE WHATIFRESULT DATA////ASSIGN THE WHATIFRESULT DATA
     ////ASSIGN THE WHATIFRESULT DATA////ASSIGN THE WHATIFRESULT DATA
     ////ASSIGN THE WHATIFRESULT DATA////ASSIGN THE WHATIFRESULT DATA
     ////ASSIGN THE WHATIFRESULT DATA////ASSIGN THE WHATIFRESULT DATA
     //ONLY IF THE WHATIFRESULT IS AVAILLABLE INTO THE JSON UPDATED
     if (isset($project_data['WhatIfResult'])) {
         $whatifresult_data = $project_data['WhatIfResult'];
         $WhatIfResult = new WhatIfResult();
         ////////////////////////////////////////////
         $WhatIfResult->setLightdata($lightdata);
         $lightdata->setWhatifresult($WhatIfResult);
         ////////////////////////////////////////////
         $wirconfig_data = $whatifresult_data['Config'];
         $WIRConfig = new WIRConfig();
         ////////////////////////////////////////////
         $WIRConfig->setWhatifresult($WhatIfResult);
         $WhatIfResult->setConfig($WIRConfig);
         ////////////////////////////////////////////
         $WIRConfig->setFirstperiod($wirconfig_data['FirstPeriod']);
         $WIRConfig->setLastperiod($wirconfig_data['LastPeriod']);
         $WIRConfig->setSourcebudget($wirconfig_data['SourceBudget']);
         $WIRConfig->setBudgetminpercent($wirconfig_data['BudgetMinPercent']);
         $WIRConfig->setBudgetmaxpercent($wirconfig_data['BudgetMaxPercent']);
         $WIRConfig->setBudgetsteppercent($wirconfig_data['BudgetStepPercent']);
         $WIRConfig->setHascurrentmix($wirconfig_data['HasCurrentMix']);
         $WIRConfig->setHassingletouchpointmix($wirconfig_data['HasSingleTouchpointMix']);
         $WIRConfig->setHasoptimizedmix($wirconfig_data['HasOptimizedMix']);
         $wircoptimizedfunction_data = $wirconfig_data['OptimizedFunction'];
         $WIRCOptimizedFunction = new WIRCOptimizedFunction();
         ////////////////////////////////////////////
         $WIRCOptimizedFunction->setConfig($WIRConfig);
         $WIRConfig->setOptimizedfunction($WIRCOptimizedFunction);
         ////////////////////////////////////////////
         $WIRCOptimizedFunction->setCalculationtype($wircoptimizedfunction_data['CalculationType']);
         $WIRCOptimizedFunction->setAttributeindex($wircoptimizedfunction_data['AttributeIndex']);
         $wirpoints_data = $whatifresult_data['Points'];
         foreach ($wirpoints_data as $wirpoint_data) {
             $WIRPoint = new WIRPoint();
             $WIRPoint->setWhatifresult($WhatIfResult);
             $WIRPoint->setStepposition($wirpoint_data['StepPosition']);
             $WIRPoint->setActualpercent($wirpoint_data['ActualPercent']);
             $WhatIfResult->addPoint($WIRPoint);
             //ASSIGN THE CURRENT MIX DATA
             //ASSIGN THE CURRENT MIX DATA
             $currentmix_data = $wirpoint_data['CurrentMix'];
             $WIRPCurrentMix = new WIRPCurrentMix();
             $WIRPCurrentMix->setPoint($WIRPoint);
             $WIRPoint->setCurrentmix($WIRPCurrentMix);
             if (isset($currentmix_data['Details'])) {
                 $wirp_currentmix_details_data = $currentmix_data['Details'];
                 foreach ($wirp_currentmix_details_data as $detail_data) {
                     $WIRPCMDetail = new WIRPCMDetail();
                     $WIRPCMDetail->setCurrentmix($WIRPCurrentMix);
                     $WIRPCMDetail->setTouchpointname($detail_data['TouchpointName']);
                     $WIRPCMDetail->setBudget($detail_data['Budget']);
                     $WIRPCMDetail->setFunctionvalue($detail_data['FunctionValue']);
                     $WIRPCurrentMix->addDetail($WIRPCMDetail);
                 }
                 $wirp_currentmix_total_data = $currentmix_data['Total'];
                 $WIRPCMTotal = new WIRPCMTotal();
                 $WIRPCMTotal->setCurrentmix($WIRPCurrentMix);
                 $WIRPCMTotal->setTouchpointname($wirp_currentmix_total_data['TouchpointName']);
                 $WIRPCMTotal->setBudget($wirp_currentmix_total_data['Budget']);
                 $WIRPCMTotal->setFunctionvalue($wirp_currentmix_total_data['FunctionValue']);
                 $WIRPCurrentMix->setTotal($WIRPCMTotal);
             }
             //END ASSIGN THE CURRENT MIX DATA
             //ASSIGN THE OPTIMIZED MIX DATA
             //ASSIGN THE OPTIMIZED MIX DATA
             $optimizedmix_data = $wirpoint_data['OptimizedMix'];
             $WIRPOptimizedMix = new WIRPOptimizedMix();
             $WIRPOptimizedMix->setPoint($WIRPoint);
             $WIRPoint->setOptimizedmix($WIRPOptimizedMix);
             if (isset($optimizedmix_data['Details'])) {
                 $wirp_optimizedmix_details_data = $optimizedmix_data['Details'];
                 foreach ($wirp_optimizedmix_details_data as $detail_data) {
                     $WIRPOMDetail = new WIRPOMDetail();
                     $WIRPOMDetail->setOptimizedmix($WIRPOptimizedMix);
                     $WIRPOMDetail->setTouchpointname($detail_data['TouchpointName']);
                     $WIRPOMDetail->setBudget($detail_data['Budget']);
                     $WIRPOMDetail->setFunctionvalue($detail_data['FunctionValue']);
                     $WIRPOptimizedMix->addDetail($WIRPOMDetail);
                 }
                 $wirp_optimizedmix_total_data = $optimizedmix_data['Total'];
                 $WIRPOMTotal = new WIRPOMTotal();
                 $WIRPOMTotal->setOptimizedmix($WIRPOptimizedMix);
                 $WIRPOMTotal->setTouchpointname($wirp_optimizedmix_total_data['TouchpointName']);
                 $WIRPOMTotal->setBudget($wirp_optimizedmix_total_data['Budget']);
                 $WIRPOMTotal->setFunctionvalue($wirp_optimizedmix_total_data['FunctionValue']);
                 $WIRPOptimizedMix->setTotal($WIRPOMTotal);
             }
             //END ASSIGN THE OPTIMIZED MIX DATA
             //ASSIGN THE SINGLETOUCHPOINT MIX DATA
             //ASSIGN THE SINGLETOUCHPOINT MIX DATA
             $singletouchpointmix_data = $wirpoint_data['SingleTouchpointMix'];
             $WIRPSingleTouchpointMix = new WIRPSingleTouchpointMix();
             $WIRPSingleTouchpointMix->setPoint($WIRPoint);
             $WIRPoint->setSingletouchpointmix($WIRPSingleTouchpointMix);
             if (isset($singletouchpointmix_data['Details'])) {
                 $wirp_singletouchpointmix_details_data = $singletouchpointmix_data['Details'];
                 foreach ($wirp_singletouchpointmix_details_data as $detail_data) {
                     $WIRPSTMDetail = new WIRPSTMDetail();
                     $WIRPSTMDetail->setSingletouchpointmix($WIRPSingleTouchpointMix);
                     $WIRPSTMDetail->setTouchpointname($detail_data['TouchpointName']);
                     $WIRPSTMDetail->setBudget($detail_data['Budget']);
                     $WIRPSTMDetail->setFunctionvalue($detail_data['FunctionValue']);
                     $WIRPSingleTouchpointMix->addDetail($WIRPSTMDetail);
                 }
                 $wirp_singletouchpointmix_total_data = $singletouchpointmix_data['Total'];
                 $WIRPSTMTotal = new WIRPSTMTotal();
                 $WIRPSTMTotal->setSingletouchpointmix($WIRPSingleTouchpointMix);
                 $WIRPSTMTotal->setTouchpointname($wirp_singletouchpointmix_total_data['TouchpointName']);
                 $WIRPSTMTotal->setBudget($wirp_singletouchpointmix_total_data['Budget']);
                 $WIRPSTMTotal->setFunctionvalue($wirp_singletouchpointmix_total_data['FunctionValue']);
                 $WIRPSingleTouchpointMix->setTotal($WIRPSTMTotal);
             }
             //END ASSIGN THE SINGLETOUCHPOINT MIX DATA
         }
         $em->persist($WhatIfResult);
     } else {
         $array_of_missing_nodes[] = "WhatIfResult";
     }
     $em->persist($lightdata);
     $em->flush();
     $response = new Response();
     $response->setStatusCode(200);
     $response->setContent(json_encode(array('success' => true, 'lightdata_id' => $lightdata->getId(), 'start_date' => $the_start_date, 'error_on_parsing' => $error_on_parsing, 'main_missing_nodes' => $array_of_missing_nodes, 'setup_missing_nodes' => $missing_setup_nodes, 'groupings_missing_nodes' => $missing_groupings_node, 'touchpoints_missing_nodes' => $touchpoints_missing_nodes, 'budgetallocation_missing_nodes' => $budgetallocation_missing_nodes, 'timeallocation_missing_nodes' => $timeallocation_missing_nodes)));
     return $response;
 }
コード例 #2
0
 /**
  * Remove allocationbyperiod
  *
  * @param \MissionControl\Bundle\LightdataBundle\Entity\TAATAllocationByPeriod $allocationbyperiod
  */
 public function removeAllocationbyperiod(\MissionControl\Bundle\LightdataBundle\Entity\TAATAllocationByPeriod $allocationbyperiod)
 {
     $this->allocationbyperiod->removeElement($allocationbyperiod);
 }