public function testMakeColumnNamesAndAttributeIndexOrDerivedTypeLabels() { Yii::app()->user->userModel = User::getByUsername('super'); $mappingData = array('column_0' => array('type' => 'importColumn', 'attributeIndexOrDerivedType' => 'string', 'mappingRulesData' => null), 'column_1' => array('type' => 'importColumn', 'attributeIndexOrDerivedType' => null, 'mappingRulesData' => null), 'column_2' => array('type' => 'importColumn', 'attributeIndexOrDerivedType' => 'FullName', 'mappingRulesData' => null)); $data = ImportMappingUtil::makeColumnNamesAndAttributeIndexOrDerivedTypeLabels($mappingData, 'ImportModelTestItem'); $compareData = array('column_0' => 'String', 'column_1' => null, 'column_2' => 'Full Name'); $this->assertEquals($compareData, $data); }
/** * Step 5. Analyze data in a sequential process. * @param integer id - Import model id * @param string $step */ public function actionStep5($id, $step = null, $pageSize = null) { $getData = GetUtil::getData(); if (isset($getData['nextParams'])) { $nextParams = $getData['nextParams']; } else { $nextParams = null; } assert('$step == null || is_string($step)'); assert('$nextParams == null || is_array($nextParams)'); $import = Import::getById((int) $id); $importWizardForm = ImportWizardUtil::makeFormByImport($import); $unserializedData = unserialize($import->serializedData); if ($pageSize == null) { $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('importPageSize'); } $config = array('pagination' => array('pageSize' => $pageSize)); $filteredByStatus = $this->resolveFilteredByStatus(); $dataProvider = new ImportDataProvider($import->getTempTableName(), (bool) $importWizardForm->firstRowIsHeaderRow, $config, null, $filteredByStatus); $sequentialProcess = new ImportDataAnalysisSequentialProcess($import, $dataProvider); $sequentialProcess->run($step, $nextParams); $route = $this->getModule()->getId() . '/' . $this->getId() . '/step5'; if ($sequentialProcess->isComplete()) { $this->resolveResettingPageOnCompletion($dataProvider); $columnNamesAndAttributeIndexOrDerivedTypeLabels = ImportMappingUtil::makeColumnNamesAndAttributeIndexOrDerivedTypeLabels($unserializedData['mappingData'], $unserializedData['importRulesType']); if (isset($getData['ajax']) && $getData['ajax'] == 'import-temp-table-list-view') { $resolvedView = new AnalysisResultsImportTempTableListView($this->getId(), $this->getModule()->getId(), $dataProvider, $unserializedData['mappingData'], $importWizardForm->importRulesType, ImportWizardDataAnalysisCompleteView::resolveConfigurationForm(), new ZurmoActiveForm(), $import->id); } else { $dataAnalysisCompleteView = new ImportWizardDataAnalysisCompleteView($this->getId(), $this->getModule()->getId(), $importWizardForm, $columnNamesAndAttributeIndexOrDerivedTypeLabels, $dataProvider, $unserializedData['mappingData']); $resolvedView = new ContainedViewCompleteSequentialProcessView($dataAnalysisCompleteView); } } else { $resolvedView = SequentialProcessViewFactory::makeBySequentialProcess($sequentialProcess, $route); } if ($step == null) { $title = Zurmo::t('ImportModule', 'Import Wizard - Analyze Data'); $importRulesClassName = ImportRulesUtil::getImportRulesClassNameByType($importWizardForm->importRulesType); $stepToUse = ImportStepsAndProgressBarForWizardView::resolveAfterUploadStepByImportClassName(4, $importRulesClassName); $progressBarAndStepsView = new ImportStepsAndProgressBarForWizardView($importRulesClassName, $stepToUse); $wrapperView = new ImportSequentialProcessContainerView($resolvedView, $sequentialProcess->getAllStepsMessage(), $title); $wrapperView->setCssClasses(array('DetailsView')); $view = $this->getImportPageView($progressBarAndStepsView, $wrapperView); } else { $view = new AjaxPageView($resolvedView); } echo $view->render(); }
/** * Step 5. Analyze data in a sequential process. * @param integer id - Import model id * @param string $step */ function actionStep5($id, $step = null) { if (isset($_GET['nextParams'])) { $nextParams = $_GET['nextParams']; } else { $nextParams = null; } assert('$step == null || is_string($step)'); assert('$nextParams == null || is_array($nextParams)'); $import = Import::getById((int) $id); $importWizardForm = ImportWizardUtil::makeFormByImport($import); $unserializedData = unserialize($import->serializedData); $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('importPageSize'); $config = array('pagination' => array('pageSize' => $pageSize)); $dataProvider = new ImportDataProvider($import->getTempTableName(), (bool) $importWizardForm->firstRowIsHeaderRow, $config); $sequentialProcess = new ImportDataAnalysisSequentialProcess($import, $dataProvider); $sequentialProcess->run($step, $nextParams); $nextStep = $sequentialProcess->getNextStep(); $route = $this->getModule()->getId() . '/' . $this->getId() . '/step5'; if ($sequentialProcess->isComplete()) { $columnNamesAndAttributeIndexOrDerivedTypeLabels = ImportMappingUtil::makeColumnNamesAndAttributeIndexOrDerivedTypeLabels($unserializedData['mappingData'], $unserializedData['importRulesType']); $dataAnalysisCompleteView = new ImportWizardDataAnalysisCompleteView($this->getId(), $this->getModule()->getId(), $importWizardForm, $columnNamesAndAttributeIndexOrDerivedTypeLabels); $sequenceView = new ContainedViewCompleteSequentialProcessView($dataAnalysisCompleteView); } else { $sequenceView = SequentialProcessViewFactory::makeBySequentialProcess($sequentialProcess, $route); } if ($step == null) { $title = Zurmo::t('ImportModule', 'Import Wizard: Step 5 of 6'); $wrapperView = new ImportSequentialProcessContainerView($sequenceView, $sequentialProcess->getAllStepsMessage(), $title); $wrapperView->setCssClasses(array('DetailsView')); $view = new ImportPageView(ZurmoDefaultAdminViewUtil::makeStandardViewForCurrentUser($this, $wrapperView)); } else { $view = new AjaxPageView($sequenceView); } echo $view->render(); }