/**
  * @param Request\ValueOv $request
  *
  * @return Response\ValueOv
  */
 public function valueOv(Request\ValueOv $request)
 {
     $result = new Response\ValueOv();
     $this->_logger->info("'OV Value' calculation is started.");
     $reqGetPeriod = new PeriodGetForDependentCalcRequest();
     $reqGetPeriod->setBaseCalcTypeCode(Cfg::CODE_TYPE_CALC_COMPRESS_FOR_PTC);
     $reqGetPeriod->setDependentCalcTypeCode(Cfg::CODE_TYPE_CALC_VALUE_OV);
     $respGetPeriod = $this->_callPeriod->getForDependentCalc($reqGetPeriod);
     if ($respGetPeriod->isSucceed()) {
         $def = $this->_manTrans->begin();
         try {
             /* working vars */
             $thisPeriodData = $respGetPeriod->getDependentPeriodData();
             $thisPeriodId = $thisPeriodData[Period::ATTR_ID];
             $thisCalcData = $respGetPeriod->getDependentCalcData();
             $thisCalcId = $thisCalcData[Calculation::ATTR_ID];
             $basePeriodData = $respGetPeriod->getBasePeriodData();
             $baseDsBegin = $basePeriodData->getDstampBegin();
             $baseDsEnd = $basePeriodData->getDstampEnd();
             $baseCalcData = $respGetPeriod->getBaseCalcData();
             $baseCalcId = $baseCalcData->getId();
             /* calculation itself */
             $this->_logger->info("Processing period #{$thisPeriodId} ({$baseDsBegin}-{$baseDsEnd})");
             /* get compressed data by calculation ID */
             $compressPtc = $this->_subDb->getCompressedPtcData($baseCalcId);
             $updates = $this->_subCalc->valueOv($compressPtc);
             $this->_subDb->saveValueOv($updates, $baseCalcId);
             $this->_subDb->markCalcComplete($thisCalcId);
             $this->_manTrans->commit($def);
             $result->markSucceed();
             $result->setPeriodId($thisPeriodId);
             $result->setCalcId($thisCalcId);
         } finally {
             $this->_manTrans->end($def);
         }
     }
     $this->_logMemoryUsage();
     $this->_logger->info("'OV Value' calculation is completed.");
     return $result;
 }
 public function test_valueOv()
 {
     /** === Test Data === */
     $COMPRESSION = [1 => [PtcCompress::ATTR_CUSTOMER_ID => 1, PtcCompress::ATTR_PARENT_ID => 1, PtcCompress::ATTR_PV => 325, PtcCompress::ATTR_DEPTH => 0], 2 => [PtcCompress::ATTR_CUSTOMER_ID => 2, PtcCompress::ATTR_PARENT_ID => 1, PtcCompress::ATTR_PV => 300, PtcCompress::ATTR_DEPTH => 1], 3 => [PtcCompress::ATTR_CUSTOMER_ID => 3, PtcCompress::ATTR_PARENT_ID => 1, PtcCompress::ATTR_PV => 700, PtcCompress::ATTR_DEPTH => 1]];
     /** === Mocks === */
     $mLogger = $this->_mockLogger();
     $mToolbox = $this->_mockToolbox();
     $mCallDownlineSnap = $this->_mockFor('\\Praxigento\\Downline\\Service\\ISnap');
     /**
      * Prepare request and perform call.
      */
     /** @var  $sub Calc */
     $sub = new Calc($mLogger, $mToolbox, $mCallDownlineSnap);
     $data = $sub->valueOv($COMPRESSION);
     $this->assertTrue(is_array($data));
 }