From 6728ccd128a5320256ac51c0a617f0c76b331ea7 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 22 Mar 2010 18:32:44 +0000 Subject: =?UTF-8?q?=E2=80=A2=20CSV=20Import=20Field=20Mapper=20-=20added?= =?UTF-8?q?=20the=20chance=20to=20mark=20a=20global=20value=20as=20SQL=20s?= =?UTF-8?q?tatement=20in=20the=20sheet=20to=20allow=20to=20use=20a=20calcu?= =?UTF-8?q?lated=20value=20like=20LENGTH(`foo`)=20or=20NOW()=20while=20ins?= =?UTF-8?q?erting/replacing/updating=20=E2=80=A2=20added=20^=E2=8C=A5?= =?UTF-8?q?=E2=8C=98N=20short-cut=20Navigator=20(still=20hidden)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/DataMigrationDialog.xib | 134 +++++++++++++++++++---- Interfaces/English.lproj/MainMenu.xib | 5 +- Source/SPFieldMapperController.h | 1 + Source/SPFieldMapperController.m | 33 ++++-- Source/TableDump.m | 81 +++++++------- 5 files changed, 184 insertions(+), 70 deletions(-) diff --git a/Interfaces/English.lproj/DataMigrationDialog.xib b/Interfaces/English.lproj/DataMigrationDialog.xib index a3cc1947..d57f084b 100644 --- a/Interfaces/English.lproj/DataMigrationDialog.xib +++ b/Interfaces/English.lproj/DataMigrationDialog.xib @@ -12,7 +12,7 @@ YES - + YES @@ -65,11 +65,13 @@ 256 {{1, 2.5}, {544, 0}} + {{-12, 53}, {546, 2}} {{0, 1.5}, {546, 0}} + {0, 0} 67239424 @@ -119,6 +121,7 @@ 269 {{175, 12}, {168, 17}} + YES 68288064 @@ -153,10 +156,12 @@ {{1, 1}, {522, 39}} + {{-1, 308}, {524, 41}} + {0, 0} 67239424 @@ -194,12 +199,14 @@ 288 {522, 126} + YES 256 {522, 17} + @@ -207,6 +214,7 @@ -2147483392 {{-22, 0}, {12, 17}} + YES @@ -458,6 +466,7 @@ {{1, 17}, {522, 126}} + @@ -473,6 +482,7 @@ -2147483392 {{413, 18}, {11, 140}} + 256 _doScroller: @@ -483,6 +493,7 @@ -2147483392 {{-100, -100}, {227, 11}} + 257 _doScroller: @@ -498,6 +509,7 @@ {{1, 0}, {522, 17}} + @@ -507,6 +519,7 @@ {{-1, 129}, {524, 144}} + 530 @@ -521,6 +534,7 @@ 289 {{343, 12}, {82, 32}} + YES 67239424 @@ -546,6 +560,7 @@ 289 {{425, 12}, {83, 32}} + 1 YES @@ -569,6 +584,7 @@ 292 {{20, 19}, {32, 24}} + YES 604110336 @@ -593,6 +609,7 @@ 292 {{51, 19}, {32, 24}} + 1 YES @@ -619,6 +636,7 @@ 294 {{88, 23}, {155, 14}} + YES 67239488 @@ -635,6 +653,7 @@ 267 {{290, 278}, {215, 22}} + YES -2076049856 @@ -667,6 +686,7 @@ 289 {{372, 97}, {133, 22}} + YES -2076049856 @@ -731,6 +751,7 @@ 289 {{276, 102}, {94, 14}} + YES 68288064 @@ -755,6 +776,7 @@ {{5, 280}, {260, 20}} + YES 69336641 @@ -804,6 +826,7 @@ 292 {{17, 100}, {188, 18}} + YES -2080244224 @@ -831,6 +854,7 @@ 289 {{372, 73}, {133, 22}} + YES -2076049856 @@ -913,6 +937,7 @@ 289 {{253, 79}, {117, 14}} + YES 68288064 @@ -929,6 +954,7 @@ 289 {{239, 12}, {82, 32}} + YES 67239424 @@ -949,6 +975,7 @@ 292 {{11, 56}, {29, 26}} + YES 67239424 @@ -975,6 +1002,7 @@ 268 {{17, 8}, {100, 18}} + YES 67239424 @@ -997,6 +1025,7 @@ 268 {{132, 8}, {80, 18}} + 1 YES @@ -1018,6 +1047,7 @@ {{145, 20}, {230, 44}} + NSView @@ -1030,6 +1060,7 @@ 268 {{227, 62}, {134, 18}} + YES -2080244224 @@ -1085,6 +1116,7 @@ {400, 14} + @@ -1164,6 +1196,7 @@ {{1, 1}, {400, 37}} + @@ -1178,6 +1211,7 @@ -2147483392 {{386, 1}, {15, 37}} + 512 _doScroller: @@ -1189,6 +1223,7 @@ -2147483392 {{-100, -100}, {87, 15}} + 513 _doScroller: @@ -1198,6 +1233,7 @@ {{20, 20}, {402, 39}} + 530 @@ -1209,6 +1245,7 @@ 268 {{227, 85}, {104, 18}} + YES 67239424 @@ -1231,6 +1268,7 @@ 268 {{17, 85}, {100, 18}} + YES 67239424 @@ -1253,6 +1291,7 @@ 268 {{17, 62}, {181, 18}} + 2 YES @@ -1276,6 +1315,7 @@ 268 {{137, 85}, {80, 18}} + 1 YES @@ -1299,6 +1339,7 @@ 268 {{354, 85}, {70, 18}} + YES 67239424 @@ -1319,6 +1360,7 @@ {{39, -57}, {442, 121}} + NSView @@ -1331,6 +1373,7 @@ 289 {{213, 8}, {139, 18}} + YES 67239424 @@ -1353,6 +1396,7 @@ 268 {{17, 8}, {100, 18}} + YES 67239424 @@ -1375,6 +1419,7 @@ 268 {{132, 8}, {70, 18}} + YES 67239424 @@ -1395,6 +1440,7 @@ {{66, 20}, {377, 44}} + NSView @@ -1402,6 +1448,7 @@ 292 {{34, 58}, {58, 23}} + YES -2080244224 @@ -1420,6 +1467,7 @@ {522, 348} + {{0, 0}, {1280, 778}} {522, 370} @@ -1456,14 +1504,12 @@ 256 {311, 111} - YES 256 {311, 17} - @@ -1471,7 +1517,6 @@ -2147483392 {{224, 0}, {16, 17}} - YES @@ -1506,13 +1551,13 @@ global_value - 275 + 240 10 3.4028234663852886e+38 75628096 2048 - Global Source Values + Global Source Values or SQL Expressions @@ -1531,6 +1576,39 @@ YES + + sql + 32 + 32 + 32 + + 75628096 + 2048 + SQL + + + + + + 67239424 + 201457664 + + + + 1215582719 + 2 + + + + + 200 + 25 + + 1 + YES + YES + + 3 2 @@ -1548,7 +1626,7 @@ 1522532352 - 4 + 2 15 0 YES @@ -1558,7 +1636,6 @@ {{1, 17}, {311, 111}} - @@ -1569,7 +1646,6 @@ -2147483392 {{-100, -100}, {15, 102}} - _doScroller: 0.99065423011779785 @@ -1579,7 +1655,6 @@ -2147483392 {{-100, -100}, {238, 15}} - 1 _doScroller: @@ -1595,7 +1670,6 @@ {{1, 0}, {311, 17}} - @@ -1605,7 +1679,6 @@ {{-1, 47}, {313, 129}} - 530 @@ -1620,7 +1693,6 @@ 292 {{20, 17}, {20, 23}} - YES -2080244224 @@ -1645,7 +1717,6 @@ -2147483356 {{112, -10}, {20, 23}} - YES -2080244224 @@ -1670,7 +1741,6 @@ 289 {{226, 13}, {70, 28}} - 1 YES @@ -1692,7 +1762,6 @@ 292 {{48, 17}, {40, 23}} - 1 YES @@ -1715,7 +1784,6 @@ 289 {{102, 19}, {120, 18}} - YES -2080244224 @@ -1736,7 +1804,6 @@ {311, 186} - {{0, 0}, {1280, 1002}} {311, 208} @@ -2860,6 +2927,7 @@ YES + @@ -3224,6 +3292,20 @@ + + 400 + + + YES + + + + + + 402 + + + @@ -3366,6 +3448,8 @@ 396.IBPluginDependency 397.IBPluginDependency 40.IBPluginDependency + 400.IBPluginDependency + 402.IBPluginDependency 41.IBPluginDependency 42.IBPluginDependency 42.ImportedFromIB2 @@ -3397,9 +3481,9 @@ YES com.apple.InterfaceBuilder.CocoaPlugin - {{361, 389}, {522, 348}} + {{222, 389}, {522, 348}} com.apple.InterfaceBuilder.CocoaPlugin - {{361, 389}, {522, 348}} + {{222, 389}, {522, 348}} {{387, 725}, {432, 282}} @@ -3414,7 +3498,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{722, 413}, {161, 71}} + {{583, 413}, {161, 71}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3464,9 +3548,9 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{68, 380}, {311, 186}} + {{160, 404}, {311, 186}} com.apple.InterfaceBuilder.CocoaPlugin - {{68, 380}, {311, 186}} + {{160, 404}, {311, 186}} {311, 186} @@ -3621,6 +3705,8 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3664,7 +3750,7 @@ - 399 + 402 diff --git a/Interfaces/English.lproj/MainMenu.xib b/Interfaces/English.lproj/MainMenu.xib index a08f7f23..705eaafb 100644 --- a/Interfaces/English.lproj/MainMenu.xib +++ b/Interfaces/English.lproj/MainMenu.xib @@ -1193,7 +1193,8 @@ YES Show Navigator - + n + 1835008 2147483647 @@ -4888,7 +4889,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{639, 365}, {237, 293}} + {{639, 365}, {251, 293}} com.apple.InterfaceBuilder.CocoaPlugin {{698, 703}, {184, 133}} diff --git a/Source/SPFieldMapperController.h b/Source/SPFieldMapperController.h index d291399f..ed66979c 100644 --- a/Source/SPFieldMapperController.h +++ b/Source/SPFieldMapperController.h @@ -83,6 +83,7 @@ NSMutableArray *fieldMappingOperatorOptions; NSMutableArray *fieldMappingOperatorArray; NSMutableArray *fieldMappingGlobalValues; + NSMutableArray *fieldMappingGlobalValuesSQLMarked; NSMutableArray *fieldMappingTableDefaultValues; NSNumber *doImport; diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index a269f75e..71220dd8 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -60,6 +60,7 @@ fieldMappingOperatorOptions = [[NSMutableArray alloc] init]; fieldMappingOperatorArray = [[NSMutableArray alloc] init]; fieldMappingGlobalValues = [[NSMutableArray alloc] init]; + fieldMappingGlobalValuesSQLMarked = [[NSMutableArray alloc] init]; fieldMappingArray = nil; lastDisabledCSVFieldcolumn = [NSNumber numberWithInteger:0]; @@ -152,6 +153,7 @@ if (fieldMappingOperatorOptions) [fieldMappingOperatorOptions release]; if (fieldMappingOperatorArray) [fieldMappingOperatorArray release]; if (fieldMappingGlobalValues) [fieldMappingGlobalValues release]; + if (fieldMappingGlobalValuesSQLMarked) [fieldMappingGlobalValuesSQLMarked release]; if (fieldMappingTableDefaultValues) [fieldMappingTableDefaultValues release]; [super dealloc]; } @@ -180,8 +182,10 @@ numberOfImportColumns = [NSArrayObjectAtIndex(fieldMappingImportArray, 0) count]; NSInteger i; - for(i=0; i= numberOfImportDataColumns) - cellData = NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn); - else + if(fieldMappingArrayHasGlobalVariables && mapColumn >= numberOfImportDataColumns) { + // Global variables are coming wrapped in ' ' if there're not marked as SQL + [whereString appendString:@"="]; + [whereString appendString:NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn)]; + } else { cellData = NSArrayObjectAtIndex(csvRowArray, mapColumn); - // If import column isn't specified import the table column default value - if ([cellData isSPNotLoaded]) - cellData = NSArrayObjectAtIndex(fieldMappingTableDefaultValues, i); + // If import column isn't specified import the table column default value + if ([cellData isSPNotLoaded]) + cellData = NSArrayObjectAtIndex(fieldMappingTableDefaultValues, i); - if (cellData == [NSNull null]) { - [whereString appendString:@" IS NULL"]; - } else { - [whereString appendString:@"="]; - [whereString appendString:@"'"]; - [whereString appendString:[mySQLConnection prepareString:cellData]]; - [whereString appendString:@"'"]; + if (cellData == [NSNull null]) { + [whereString appendString:@" IS NULL"]; + } else { + [whereString appendString:@"="]; + [whereString appendString:@"'"]; + [whereString appendString:[mySQLConnection prepareString:cellData]]; + [whereString appendString:@"'"]; + } } } } @@ -1407,21 +1412,23 @@ // Append the data // - check for global values - if(fieldMappingArrayHasGlobalVariables && mapColumn >= numberOfImportDataColumns) - cellData = NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn); - else + if(fieldMappingArrayHasGlobalVariables && mapColumn >= numberOfImportDataColumns) { + // Global variables are coming wrapped in ' ' if there're not marked as SQL + [valueString appendString:NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn)]; + } else { cellData = NSArrayObjectAtIndex(csvRowArray, mapColumn); - // If import column isn't specified import the table column default value - if ([cellData isSPNotLoaded]) - cellData = NSArrayObjectAtIndex(fieldMappingTableDefaultValues, i); + // If import column isn't specified import the table column default value + if ([cellData isSPNotLoaded]) + cellData = NSArrayObjectAtIndex(fieldMappingTableDefaultValues, i); - if (cellData == [NSNull null]) { - [valueString appendString:@"NULL"]; - } else { - [valueString appendString:@"'"]; - [valueString appendString:[mySQLConnection prepareString:cellData]]; - [valueString appendString:@"'"]; + if (cellData == [NSNull null]) { + [valueString appendString:@"NULL"]; + } else { + [valueString appendString:@"'"]; + [valueString appendString:[mySQLConnection prepareString:cellData]]; + [valueString appendString:@"'"]; + } } } -- cgit v1.2.3