Exemple #1
0
 /**
  * basic info convert
  *
  * @todo convert $action for bug import
  *
  * @param array $basicInfo
  * @param string $infoType
  * @return string
  */
 private function basicInfoConv($basicInfo, $infoType)
 {
     // hard code for productmodule_id
     if (isset($basicInfo['productmodule_id'])) {
         $moduleSplitterPos = strpos($basicInfo['productmodule_id'], ProductModule::MODULE_SPLITTER);
         if (false !== $moduleSplitterPos) {
             $moduleName = substr($basicInfo['productmodule_id'], $moduleSplitterPos + 1);
             $moduleInfo = ProductModule::model()->findByAttributes(array('product_id' => $basicInfo['product_id'], 'full_path_name' => $moduleName));
             if (!empty($moduleInfo)) {
                 $basicInfo['productmodule_id'] = $moduleInfo->id;
             }
         } else {
             //$basicInfo['productmodule_id'] = 0;
         }
     }
     // hard code for id
     if (isset($basicInfo['id']) && '' == $basicInfo['id']) {
         unset($basicInfo['id']);
     }
     // hard code for delete_flag
     if (isset($basicInfo['delete_flag'])) {
         $basicInfo['delete_flag'] = CommonService::getTrueFalseValue($basicInfo['delete_flag']);
     }
     if (isset($basicInfo['priority'])) {
         if (Info::TYPE_CASE == $infoType) {
             $basicInfo['priority'] = ProductService::getCasePriorityValueByName($basicInfo['product_id'], $basicInfo['priority']);
         } else {
             if (Info::TYPE_BUG == $infoType) {
                 $basicInfo['priority'] = ProductService::getBugPriorityValueByName($basicInfo['product_id'], $basicInfo['priority']);
             }
         }
     }
     if (isset($basicInfo['severity']) && Info::TYPE_BUG == $infoType) {
         $basicInfo['severity'] = ProductService::getBugSeverityValueByName($basicInfo['product_id'], $basicInfo['severity']);
     }
     // @TODO convert for bug import
     $bugUserKeyArr = array('resolved_by', 'closed_by');
     foreach ($bugUserKeyArr as $bugUserKey) {
         if (isset($basicInfo[$bugUserKey])) {
             $resolvedByInfo = TestUserService::getUserInfoByRealname($basicInfo[$bugUserKey]);
             if (!empty($resolvedByInfo)) {
                 $basicInfo[$bugUserKey] = $resolvedByInfo['id'];
             } else {
                 unset($basicInfo[$bugUserKey]);
             }
         }
     }
     $bugDateKeyArr = array('resolved_at', 'closed_at');
     foreach ($bugDateKeyArr as $bugDateKey) {
         if (empty($basicInfo[$bugDateKey])) {
             unset($basicInfo[$bugDateKey]);
         }
     }
     return $basicInfo;
 }