diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-02-18 12:54:38 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-02-18 12:54:38 +0000 |
commit | 1bde8b65c0213bcf0514c69f1b8b70a00971b573 (patch) | |
tree | b4a56556179011242f9309f8df1b21355bf4c11b /Source/TableDump.m | |
parent | 299e8821edf9a1705a556c482a2a0ea4d6f9a0a8 (diff) | |
download | sequelpro-1bde8b65c0213bcf0514c69f1b8b70a00971b573.tar.gz sequelpro-1bde8b65c0213bcf0514c69f1b8b70a00971b573.tar.bz2 sequelpro-1bde8b65c0213bcf0514c69f1b8b70a00971b573.zip |
• CSV Import Field Mapper
- allow to define a list of global variables (incl. a true NULL value)
- such a global variable will be inserted into the mapped table target field for all rows imported
Diffstat (limited to 'Source/TableDump.m')
-rw-r--r-- | Source/TableDump.m | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Source/TableDump.m b/Source/TableDump.m index 2a39aca5..b1cbbda8 100644 --- a/Source/TableDump.m +++ b/Source/TableDump.m @@ -782,6 +782,7 @@ BOOL insertBaseStringHasEntries; NSStringEncoding csvEncoding = [MCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] UTF8String]]; fieldMappingArray = nil; + fieldMappingGlobalValueArray = nil; // Start the notification timer to allow notifications to be shown even if frontmost for long queries [[SPGrowlController sharedGrowlController] setVisibilityForNotificationName:@"Import Finished"]; @@ -1039,6 +1040,7 @@ [parsedRows release]; [parsePositions release]; if(fieldMappingArray) [fieldMappingArray release]; fieldMappingArray = nil; + if(fieldMappingGlobalValueArray) [fieldMappingGlobalValueArray release]; fieldMappingGlobalValueArray = nil; if(fieldMapperOperator) [fieldMapperOperator release]; fieldMapperOperator = nil; [importPool drain]; [tableDocumentInstance setQueryMode:SPInterfaceQueryMode]; @@ -1154,6 +1156,7 @@ fieldMappingImportArray = [[NSArray alloc] initWithArray:importData]; fieldMapperSheetStatus = 1; + fieldMappingArrayHasGlobalVariables = NO; // Init the field mapper controller fieldMapperController = [[SPFieldMapperController alloc] initWithDelegate:self]; @@ -1180,6 +1183,11 @@ selectedTableTarget = [NSString stringWithString:[fieldMapperController selectedTableTarget]]; selectedImportMethod = [NSString stringWithString:[fieldMapperController selectedImportMethod]]; fieldMappingTableColumnNames = [NSArray arrayWithArray:[fieldMapperController fieldMappingTableColumnNames]]; + fieldMappingGlobalValueArray = [[NSArray arrayWithArray:[fieldMapperController fieldMappingGlobalValueArray]] retain]; + + if([fieldMappingGlobalValueArray count] > [fieldMappingArray count]) + fieldMappingArrayHasGlobalVariables = YES; + [importFieldNamesSwitch setState:[fieldMapperController importFieldNamesHeader]]; [prefs setBool:[importFieldNamesSwitch state] forKey:SPCSVImportFirstLineIsHeader]; @@ -1219,7 +1227,11 @@ if ([valueString length] > 1) [valueString appendString:@","]; // Append the data - cellData = NSArrayObjectAtIndex(csvRowArray, mapColumn); + // - check for global values + if(fieldMappingArrayHasGlobalVariables && mapColumn >= [csvRowArray count]) + cellData = NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn); + else + cellData = NSArrayObjectAtIndex(csvRowArray, mapColumn); if (cellData == [NSNull null]) { [valueString appendString:@"NULL"]; @@ -2783,8 +2795,10 @@ tables = [[NSMutableArray alloc] init]; fieldMappingArray = nil; + fieldMappingGlobalValueArray = nil; fieldMappingImportArray = nil; fieldMappingImportArrayIsPreview = NO; + fieldMappingArrayHasGlobalVariables = NO; prefs = nil; lastFilename = nil; |