当前位置: 首页>>代码示例>>PHP>>正文


PHP Import类代码示例

本文整理汇总了PHP中Import的典型用法代码示例。如果您正苦于以下问题:PHP Import类的具体用法?PHP Import怎么用?PHP Import使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Import类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testImportDataAnalysisResults

 public function testImportDataAnalysisResults()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $import = new Import();
     $serializedData['importRulesType'] = 'Users';
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), Yii::getPathOfAlias('application.modules.users.tests.unit.files'));
     $mappingData = array('column_0' => array('attributeIndexOrDerivedType' => 'username', 'type' => 'importColumn', 'mappingRulesData' => array()), 'column_1' => array('attributeIndexOrDerivedType' => 'Password', 'type' => 'importColumn', 'mappingRulesData' => array('PasswordDefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_2' => array('attributeIndexOrDerivedType' => 'UserStatus', 'type' => 'importColumn', 'mappingRulesData' => array('UserStatusDefaultValueMappingRuleForm' => array('defaultValue' => UserStatusUtil::ACTIVE))));
     $serializedData = unserialize($import->serializedData);
     $serializedData['mappingData'] = $mappingData;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     $importRules = ImportRulesUtil::makeImportRulesByType('Users');
     $config = array('pagination' => array('pageSize' => 2));
     //This test csv has a header row.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     //Run data analyzer
     $importDataAnalyzer = new ImportDataAnalyzer($importRules, $dataProvider);
     foreach ($mappingData as $columnName => $columnMappingData) {
         $importDataAnalyzer->analyzeByColumnNameAndColumnMappingData($columnName, $columnMappingData);
     }
     $messagesData = $importDataAnalyzer->getMessagesData();
     $compareData = array('column_0' => array(array('message' => '1 value(s) are too large for this field. These values will be truncated to a length of 64 upon import.', 'sanitizerUtilType' => 'Truncate', 'moreAvailable' => false)), 'column_1' => array(array('message' => '1 value(s) are too large for this field. These values will be truncated to a length of 32 upon import.', 'sanitizerUtilType' => 'Truncate', 'moreAvailable' => false)), 'column_2' => array(array('message' => '2 user status value(s) are not valid. Users that have these values will be set to active upon import.', 'sanitizerUtilType' => 'UserStatus', 'moreAvailable' => false)));
     $this->assertEquals($compareData, $messagesData);
     $importInstructionsData = $importDataAnalyzer->getImportInstructionsData();
     $compareInstructionsData = array();
     $this->assertEquals($compareInstructionsData, $importInstructionsData);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:30,代码来源:UsersImportDataAnalyzerTest.php

示例2: import

 public function import()
 {
     $page = new AdminPage();
     $panel = new Import();
     $page->addToContainer(1, $panel->getHtml());
     $page->pagePrint();
 }
开发者ID:remarco-mif,项目名称:ppos,代码行数:7,代码来源:ManageAdmin.php

示例3: testProcessStatusAndMessagesForEachRow

 public function testProcessStatusAndMessagesForEachRow()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $import = new Import();
     $serializedData['importRulesType'] = 'ImportModelTestItem';
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     $testTableName = $import->getTempTableName();
     $this->assertTrue(ImportTestHelper::createTempTableByFileNameAndTableName('importTest.csv', $testTableName));
     $count = ImportDatabaseUtil::getCount($testTableName);
     $this->assertEquals(5, $count);
     //Now add import results.
     $resultsUtil = new ImportResultsUtil($import);
     $rowDataResultsUtil = new ImportRowDataResultsUtil(2);
     $rowDataResultsUtil->setStatusToUpdated();
     $rowDataResultsUtil->addMessage('the first message');
     $resultsUtil->addRowDataResults($rowDataResultsUtil);
     $rowDataResultsUtil = new ImportRowDataResultsUtil(3);
     $rowDataResultsUtil->setStatusToCreated();
     $rowDataResultsUtil->addMessage('the second message');
     $resultsUtil->addRowDataResults($rowDataResultsUtil);
     $rowDataResultsUtil = new ImportRowDataResultsUtil(4);
     $rowDataResultsUtil->setStatusToError();
     $rowDataResultsUtil->addMessage('the third message');
     $resultsUtil->addRowDataResults($rowDataResultsUtil);
     $resultsUtil->processStatusAndMessagesForEachRow();
     $sql = 'select * from ' . $testTableName . ' where id != 1';
     $tempTableData = R::getAll($sql);
     $compareData = array(array('id' => 2, 'column_0' => 'abc', 'column_1' => '123', 'column_2' => 'a', 'status' => 1, 'serializedmessages' => serialize(array('the first message'))), array('id' => 3, 'column_0' => 'def', 'column_1' => '563', 'column_2' => 'b', 'status' => 2, 'serializedmessages' => serialize(array('the second message'))), array('id' => 4, 'column_0' => 'efg', 'column_1' => '456', 'column_2' => 'a', 'status' => 3, 'serializedmessages' => serialize(array('the third message'))), array('id' => 5, 'column_0' => 'we1s', 'column_1' => null, 'column_2' => 'b', 'status' => null, 'serializedmessages' => null));
     $this->assertEquals($compareData, $tempTableData);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:31,代码来源:ImportResultsUtilTest.php

示例4: testSequentialProcessViewFactory

 public function testSequentialProcessViewFactory()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $import = new Import();
     $mappingData = array('column_0' => array('attributeIndexOrDerivedType' => 'string', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_1' => array('attributeIndexOrDerivedType' => 'phone', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))));
     $serializedData['importRulesType'] = 'ImportModelTestItem';
     $serializedData['mappingData'] = $mappingData;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName());
     $config = array('pagination' => array('pageSize' => 2));
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     $sequentialProcess = new ImportDataAnalysisSequentialProcess($import, $dataProvider);
     $sequentialProcess->run(null, null);
     $route = 'default/someAction';
     $view = SequentialProcessViewFactory::makeBySequentialProcess($sequentialProcess, $route);
     $content = $view->render();
     $this->assertNotNull($content);
     $this->assertEquals('SequentialProcessView', get_class($view));
     //Now process the first run. Will process page 0.
     $sequentialProcess = new ImportDataAnalysisSequentialProcess($import, $dataProvider);
     $sequentialProcess->run('processColumns', null);
     $route = 'default/someAction';
     $view = SequentialProcessViewFactory::makeBySequentialProcess($sequentialProcess, $route);
     $content = $view->render();
     $this->assertNotNull($content);
     $this->assertEquals('SequentialProcessView', get_class($view));
     $this->assertEquals(array('columnNameToProcess' => 'column_1'), $sequentialProcess->getNextParams());
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:29,代码来源:ImportDataAnalysisSequentialProcessTest.php

示例5: testRun

 public function testRun()
 {
     $quote = DatabaseCompatibilityUtil::getQuote();
     //Create 2 imports, and set one with a date over a week ago (8 days ago) for the modifiedDateTime
     $import = new Import();
     $serializedData['importRulesType'] = 'ImportModelTestItem';
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), true);
     $modifiedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 8);
     $sql = "Update item set modifieddatetime = '" . $modifiedDateTime . "' where id = " . $import->getClassId('Item');
     ZurmoRedBean::exec($sql);
     $staleImportId = $import->id;
     $import2 = new Import();
     $serializedData['importRulesType'] = 'ImportModelTestItem';
     $import2->serializedData = serialize($serializedData);
     $this->assertTrue($import2->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import2->getTempTableName(), true);
     $this->assertEquals(2, Import::getCount());
     $tableExists = ZurmoRedBean::$writer->doesTableExist($import->getTempTableName());
     $this->assertTrue($tableExists);
     $job = new ImportCleanupJob();
     $this->assertTrue($job->run());
     $tableExists = ZurmoRedBean::$writer->doesTableExist($import->getTempTableName());
     $this->assertFalse($tableExists);
     $imports = Import::getAll();
     $this->assertEquals(1, count($imports));
     $this->assertEquals($import2->id, $imports[0]->id);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:29,代码来源:ImportCleanupJobTest.php

示例6: testImportDataAnalysisResults

 public function testImportDataAnalysisResults()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $import = new Import();
     $serializedData['importRulesType'] = 'Contacts';
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.contacts.tests.unit.files'));
     $mappingData = array('column_0' => array('attributeIndexOrDerivedType' => 'ContactState', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultContactStateIdMappingRuleForm' => array('defaultStateId' => null))));
     $serializedData = unserialize($import->serializedData);
     $serializedData['mappingData'] = $mappingData;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     $importRules = ImportRulesUtil::makeImportRulesByType('Contacts');
     $config = array('pagination' => array('pageSize' => 15));
     //This test csv has a header row.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     //Run data analyzer
     $importDataAnalyzer = new ImportDataAnalyzer($importRules, $dataProvider, $mappingData, array('column_0'));
     $importDataAnalyzer->analyzePage();
     $data = $dataProvider->getData();
     $this->assertEquals(13, count($data));
     $compareData = array();
     $compareData['column_0'] = array();
     $compareData['column_0'][] = 'Is invalid.';
     $this->assertEquals($compareData, unserialize($data[0]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[0]->analysisStatus);
     $compareData = array();
     $compareData['column_0'] = array();
     $compareData['column_0'][] = 'Is invalid.';
     $this->assertEquals($compareData, unserialize($data[1]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[1]->analysisStatus);
     $compareData = array();
     $compareData['column_0'] = array();
     $compareData['column_0'][] = 'Is invalid.';
     $this->assertEquals($compareData, unserialize($data[2]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[2]->analysisStatus);
     $this->assertNull($data[3]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[3]->analysisStatus);
     $this->assertNull($data[4]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[4]->analysisStatus);
     $this->assertNull($data[5]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[5]->analysisStatus);
     $this->assertNull($data[6]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[6]->analysisStatus);
     $this->assertNull($data[7]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[7]->analysisStatus);
     $this->assertNull($data[8]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[8]->analysisStatus);
     $this->assertNull($data[9]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[9]->analysisStatus);
     $this->assertNull($data[10]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[10]->analysisStatus);
     $this->assertNull($data[11]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[11]->analysisStatus);
     $this->assertNull($data[12]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[12]->analysisStatus);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:59,代码来源:ContactsImportDataAnalyzerTest.php

示例7: action

function action($arg)
{
    $f_articles = new Import($arg);
    $variableMetodo = array($f_articles, $arg);
    if (is_callable($variableMetodo)) {
        $f_articles->execute();
    }
}
开发者ID:dice9030,项目名称:GestionLogistico,代码行数:8,代码来源:f_articles.php

示例8: testSimpleUserImportWhereAllRowsSucceed

 public function testSimpleUserImportWhereAllRowsSucceed()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $tasks = Task::getAll();
     $this->assertEquals(0, count($tasks));
     $import = new Import();
     $serializedData['importRulesType'] = 'Tasks';
     $serializedData['firstRowIsHeaderRow'] = true;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('simpleImportTest.csv', $import->getTempTableName(), Yii::getPathOfAlias('application.modules.tasks.tests.unit.files'));
     $this->assertEquals(4, ImportDatabaseUtil::getCount($import->getTempTableName()));
     // includes header rows.
     $mappingData = array('column_0' => ImportMappingUtil::makeStringColumnMappingData('name'), 'column_1' => ImportMappingUtil::makeDateTimeColumnMappingData('dueDateTime'), 'column_2' => ImportMappingUtil::makeDateTimeColumnMappingData('completedDateTime'), 'column_3' => ImportMappingUtil::makeBooleanColumnMappingData('completed'), 'column_4' => ImportMappingUtil::makeModelDerivedColumnMappingData('AccountDerived'), 'column_5' => ImportMappingUtil::makeModelDerivedColumnMappingData('ContactDerived'), 'column_6' => ImportMappingUtil::makeModelDerivedColumnMappingData('OpportunityDerived'), 'column_7' => ImportMappingUtil::makeTextAreaColumnMappingData('description'));
     $importRules = ImportRulesUtil::makeImportRulesByType('Tasks');
     $page = 0;
     $config = array('pagination' => array('pageSize' => 50));
     //This way all rows are processed.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     $dataProvider->getPagination()->setCurrentPage($page);
     $importResultsUtil = new ImportResultsUtil($import);
     $actionDateTime = substr(DateTimeUtil::convertTimestampToDbFormatDateTime(time()), 0, -3);
     $messageLogger = new ImportMessageLogger();
     ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
     $importResultsUtil->processStatusAndMessagesForEachRow();
     //Confirm that 3 models where created.
     $tasks = Task::getAll();
     $this->assertEquals(3, count($tasks));
     $tasks = Task::getByName('task1');
     $this->assertEquals(1, count($tasks[0]));
     $this->assertEquals(1, count($tasks[0]->activityItems));
     $this->assertEquals('testAccount', $tasks[0]->activityItems[0]->name);
     $this->assertEquals('Account', get_class($tasks[0]->activityItems[0]));
     $this->assertNull($tasks[0]->completed);
     $this->assertEquals($actionDateTime, substr($tasks[0]->latestDateTime, 0, -3));
     $tasks = Task::getByName('task2');
     $this->assertEquals(1, count($tasks[0]));
     $this->assertEquals(1, count($tasks[0]->activityItems));
     $this->assertEquals('testContact', $tasks[0]->activityItems[0]->firstName);
     $this->assertEquals('Contact', get_class($tasks[0]->activityItems[0]));
     $this->assertEquals(1, $tasks[0]->completed);
     $this->assertEquals('2011-12-22 06:03', substr($tasks[0]->latestDateTime, 0, -3));
     $tasks = Task::getByName('task3');
     $this->assertEquals(1, count($tasks[0]));
     $this->assertEquals(1, count($tasks[0]->activityItems));
     $this->assertEquals('testOpportunity', $tasks[0]->activityItems[0]->name);
     $this->assertEquals('Opportunity', get_class($tasks[0]->activityItems[0]));
     $this->assertNull($tasks[0]->completed);
     $this->assertEquals($actionDateTime, substr($tasks[0]->latestDateTime, 0, -3));
     //Confirm 10 rows were processed as 'created'.
     $this->assertEquals(3, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::CREATED));
     //Confirm that 0 rows were processed as 'updated'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::UPDATED));
     //Confirm 2 rows were processed as 'errors'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR));
     $beansWithErrors = ImportDatabaseUtil::getSubset($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR);
     $this->assertEquals(0, count($beansWithErrors));
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:58,代码来源:TaskImportTest.php

示例9: testSimpleUserImportWhereAllRowsSucceed

 public function testSimpleUserImportWhereAllRowsSucceed()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $import = new Import();
     $serializedData['importRulesType'] = 'ProductTemplates';
     $serializedData['firstRowIsHeaderRow'] = true;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('productTemplates.csv', $import->getTempTableName(), Yii::getPathOfAlias('application.modules.productTemplates.tests.unit.files'));
     $this->assertEquals(3, ImportDatabaseUtil::getCount($import->getTempTableName()));
     // includes header rows.
     $currencies = Currency::getAll();
     $mappingData = array('column_0' => ImportMappingUtil::makeStringColumnMappingData('name'), 'column_1' => ImportMappingUtil::makeTextAreaColumnMappingData('description'), 'column_2' => ImportMappingUtil::makeIntegerColumnMappingData('sellPriceFormula__type'), 'column_3' => ImportMappingUtil::makeFloatColumnMappingData('sellPriceFormula__discountOrMarkupPercentage'), 'column_4' => ImportMappingUtil::makeCurrencyColumnMappingData('cost', $currencies[0]), 'column_5' => ImportMappingUtil::makeCurrencyColumnMappingData('listPrice', $currencies[0]), 'column_6' => ImportMappingUtil::makeCurrencyColumnMappingData('sellPrice', $currencies[0]), 'column_7' => ImportMappingUtil::makeIntegerColumnMappingData('priceFrequency'), 'column_8' => ImportMappingUtil::makeIntegerColumnMappingData('type'), 'column_9' => ImportMappingUtil::makeIntegerColumnMappingData('status'));
     $importRules = ImportRulesUtil::makeImportRulesByType('ProductTemplates');
     $page = 0;
     $config = array('pagination' => array('pageSize' => 50));
     //This way all rows are processed.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     $dataProvider->getPagination()->setCurrentPage($page);
     $importResultsUtil = new ImportResultsUtil($import);
     $messageLogger = new ImportMessageLogger();
     ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
     $importResultsUtil->processStatusAndMessagesForEachRow();
     //Confirm that 3 models where created.
     $productTemplates = ProductTemplate::getAll();
     $this->assertEquals(2, count($productTemplates));
     $productTemplates = ProductTemplate::getByName('A Gift of Monotheists import');
     $this->assertEquals(1, count($productTemplates[0]));
     $this->assertEquals('A Gift of Monotheists import', $productTemplates[0]->name);
     $this->assertEquals(2, $productTemplates[0]->sellPriceFormula->type);
     $this->assertEquals(10, $productTemplates[0]->sellPriceFormula->discountOrMarkupPercentage);
     $this->assertEquals(180, $productTemplates[0]->sellPrice->value);
     $this->assertEquals(200, $productTemplates[0]->listPrice->value);
     $this->assertEquals(200, $productTemplates[0]->cost->value);
     $this->assertEquals(2, $productTemplates[0]->priceFrequency);
     $this->assertEquals(2, $productTemplates[0]->type);
     $this->assertEquals(2, $productTemplates[0]->status);
     $productTemplates[0]->delete();
     $productTemplates = ProductTemplate::getByName('A Gift of Monotheists import Copy');
     $this->assertEquals(1, count($productTemplates[0]));
     $this->assertEquals('A Gift of Monotheists import Copy', $productTemplates[0]->name);
     $this->assertEquals(2, $productTemplates[0]->sellPriceFormula->type);
     $this->assertEquals(5, $productTemplates[0]->sellPriceFormula->discountOrMarkupPercentage);
     $this->assertEquals(180, $productTemplates[0]->sellPrice->value);
     $this->assertEquals(200, $productTemplates[0]->listPrice->value);
     $this->assertEquals(200, $productTemplates[0]->cost->value);
     $this->assertEquals(2, $productTemplates[0]->priceFrequency);
     $this->assertEquals(2, $productTemplates[0]->type);
     $this->assertEquals(2, $productTemplates[0]->status);
     $productTemplates[0]->delete();
     //Confirm that 2 rows were processed as 'updated'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::UPDATED));
     //Confirm 2 rows were processed as 'errors'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR));
     $beansWithErrors = ImportDatabaseUtil::getSubset($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR);
     $this->assertEquals(0, count($beansWithErrors));
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:57,代码来源:ProductTemplateImportTest.php

示例10: resolveCustomFieldsInstructionDataIntoImportAndSaveImport

 protected static function resolveCustomFieldsInstructionDataIntoImportAndSaveImport(ImportDataAnalyzer $importDataAnalyzer, Import $import)
 {
     $adapter = new ImportToCustomFieldsInstructionDataAdapter($import);
     $adapter->appendCustomFieldsInstructionData($importDataAnalyzer->getCustomFieldsInstructionData());
     $saved = $import->save();
     if (!$saved) {
         throw new FailedToSaveModelException();
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:9,代码来源:ImportDataAnalysisSequentialProcess.php

示例11: testImportDataAnalysisResults

 public function testImportDataAnalysisResults()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $import = new Import();
     $serializedData['importRulesType'] = 'Users';
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), Yii::getPathOfAlias('application.modules.users.tests.unit.files'));
     $mappingData = array('column_0' => array('attributeIndexOrDerivedType' => 'username', 'type' => 'importColumn', 'mappingRulesData' => array()), 'column_1' => array('attributeIndexOrDerivedType' => 'Password', 'type' => 'importColumn', 'mappingRulesData' => array('PasswordDefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_2' => array('attributeIndexOrDerivedType' => 'UserStatus', 'type' => 'importColumn', 'mappingRulesData' => array('UserStatusDefaultValueMappingRuleForm' => array('defaultValue' => UserStatusUtil::ACTIVE))));
     $serializedData = unserialize($import->serializedData);
     $serializedData['mappingData'] = $mappingData;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     $importRules = ImportRulesUtil::makeImportRulesByType('Users');
     $config = array('pagination' => array('pageSize' => 15));
     //This test csv has a header row.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     //Run data analyzer
     $importDataAnalyzer = new ImportDataAnalyzer($importRules, $dataProvider, $mappingData, array('column_0', 'column_1', 'column_2'));
     $importDataAnalyzer->analyzePage();
     $data = $dataProvider->getData();
     $this->assertEquals(10, count($data));
     $this->assertNull($data[0]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[0]->analysisStatus);
     $this->assertNull($data[1]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[1]->analysisStatus);
     $this->assertNull($data[2]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[2]->analysisStatus);
     $this->assertNull($data[3]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[3]->analysisStatus);
     $compareData = array();
     $compareData['column_0'] = array();
     $compareData['column_0'][] = 'Is too long. Maximum length is 64. This value will truncated upon import.';
     $this->assertEquals($compareData, unserialize($data[4]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_WARN, $data[4]->analysisStatus);
     $this->assertNull($data[5]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[5]->analysisStatus);
     $this->assertNull($data[6]->serializedAnalysisMessages);
     $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[6]->analysisStatus);
     $compareData = array();
     $compareData['column_2'] = array();
     $compareData['column_2'][] = 'Status value is invalid. This status will be set to active upon import.';
     $this->assertEquals($compareData, unserialize($data[7]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_WARN, $data[7]->analysisStatus);
     $compareData = array();
     $compareData['column_1'] = array();
     $compareData['column_1'][] = 'Is too long. Maximum length is 32. This value will truncated upon import.';
     $this->assertEquals($compareData, unserialize($data[8]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_WARN, $data[8]->analysisStatus);
     $compareData = array();
     $compareData['column_2'] = array();
     $compareData['column_2'][] = 'Status value is invalid. This status will be set to active upon import.';
     $this->assertEquals($compareData, unserialize($data[9]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_WARN, $data[9]->analysisStatus);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:56,代码来源:UsersImportDataAnalyzerTest.php

示例12: testSuperUserMappingRulesEditActionAllAttributeIndexAndDerivedTypes

 public function testSuperUserMappingRulesEditActionAllAttributeIndexAndDerivedTypes()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $import = new Import();
     $import->serializedData = serialize(array('importRulesType' => 'Contacts'));
     $this->assertTrue($import->save());
     //Test contact specific attribute indexes and derived attribute types
     $this->runMappingRulesEditAction($import->id, 'FullName');
     $this->runMappingRulesEditAction($import->id, 'ContactState');
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:10,代码来源:ContactsImportSuperUserWalkthroughTest.php

示例13: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('artist', function (Blueprint $table) {
         $table->increments('id_artist');
         $table->string('name');
         $table->string('description');
         $table->string('image');
         $table->string('tags');
     });
     $data = new Import();
     $data->import("public/assets/artistes.csv", "artist");
 }
开发者ID:marinesl,项目名称:Codepi_Concert,代码行数:17,代码来源:2016_01_12_162952_create_artist_table.php

示例14: testSimpleUserImportWhereAllRowsSucceed

 public function testSimpleUserImportWhereAllRowsSucceed()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $import = new Import();
     $serializedData['importRulesType'] = 'Projects';
     $serializedData['firstRowIsHeaderRow'] = true;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('projectsSample.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.projects.tests.unit.files'));
     $this->assertEquals(3, ImportDatabaseUtil::getCount($import->getTempTableName()));
     // includes header rows.
     $ownerColumnMappingData = array('attributeIndexOrDerivedType' => 'owner', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => null), 'UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::ZURMO_USERNAME)));
     $mappingData = array('column_0' => $ownerColumnMappingData, 'column_1' => ImportMappingUtil::makeStringColumnMappingData('name'), 'column_2' => ImportMappingUtil::makeTextAreaColumnMappingData('description'), 'column_3' => ImportMappingUtil::makeDropDownColumnMappingData('status'));
     $importRules = ImportRulesUtil::makeImportRulesByType('Projects');
     $page = 0;
     $config = array('pagination' => array('pageSize' => 50));
     //This way all rows are processed.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     $dataProvider->getPagination()->setCurrentPage($page);
     $importResultsUtil = new ImportResultsUtil($import);
     $messageLogger = new ImportMessageLogger();
     ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
     $importResultsUtil->processStatusAndMessagesForEachRow();
     //Confirm that 2 models where created.
     $projects = Project::getAll();
     $this->assertEquals(2, count($projects));
     $projects = Project::getByName('My first project');
     $this->assertEquals(1, count($projects[0]));
     $this->assertEquals('super', $projects[0]->owner->username);
     $this->assertEquals('My first project', $projects[0]->name);
     $this->assertEquals(2, $projects[0]->status);
     //todo ask Jason for it
     //$this->assertEquals('My first project Desc',   $projects[0]->description);
     $projects[0]->delete();
     $projects = Project::getByName('My second project');
     $this->assertEquals(1, count($projects[0]));
     $this->assertEquals('super', $projects[0]->owner->username);
     $this->assertEquals('My second project', $projects[0]->name);
     $this->assertEquals(1, $projects[0]->status);
     //$this->assertEquals('My second project Desc',  $projects[0]->description);
     $projects[0]->delete();
     //Confirm that 2 rows were processed as 'updated'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::UPDATED));
     //Confirm 2 rows were processed as 'errors'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR));
     $beansWithErrors = ImportDatabaseUtil::getSubset($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR);
     $this->assertEquals(0, count($beansWithErrors));
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:48,代码来源:ProjectImportTest.php

示例15: init

 function init($zone, $lang = null, $lr = null)
 {
     $this->regional = $zone;
     $this->lr = $lr;
     $this->hl = $lang;
     $this->htmlDOM =& Import::htmlDOM();
 }
开发者ID:zhaoshengloveqingqing,项目名称:fenxiao,代码行数:7,代码来源:crawler-google.php


注:本文中的Import类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。