aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/SPSQLParser.h4
-rw-r--r--Source/SPSQLParser.m42
-rw-r--r--Source/TableDump.h2
-rw-r--r--Source/TableDump.m711
4 files changed, 457 insertions, 302 deletions
diff --git a/Source/SPSQLParser.h b/Source/SPSQLParser.h
index 022e17bb..73dfe493 100644
--- a/Source/SPSQLParser.h
+++ b/Source/SPSQLParser.h
@@ -54,14 +54,14 @@
*
* It is anticipated that characterAtIndex: is currently the parsing weak point, and that in future
* this class could be further optimised by working with the underlying object/characters directly.
- * This class could also be improved by maintaining an internal parsedTo number to allow streaming
- * processing to occur without repetition.
*/
@interface SPSQLParser : NSMutableString
{
id string;
unichar *stringCharCache;
+ unichar parsedToChar;
+ long parsedToPosition;
long charCacheStart;
long charCacheEnd;
NSString *delimiter;
diff --git a/Source/SPSQLParser.m b/Source/SPSQLParser.m
index ac59c2fc..a2fb2026 100644
--- a/Source/SPSQLParser.m
+++ b/Source/SPSQLParser.m
@@ -476,7 +476,11 @@ TO_BUFFER_STATE to_scan_string (const char *);
*/
- (long) firstOccurrenceOfCharacter:(unichar)character ignoringQuotedStrings:(BOOL)ignoreQuotedStrings
{
- return [self firstOccurrenceOfCharacter:character afterIndex:-1 skippingBrackets:NO ignoringQuotedStrings:ignoreQuotedStrings];
+ if (character != parsedToChar) {
+ parsedToChar = character;
+ parsedToPosition = -1;
+ }
+ return [self firstOccurrenceOfCharacter:character afterIndex:parsedToPosition skippingBrackets:NO ignoringQuotedStrings:ignoreQuotedStrings];
}
@@ -485,6 +489,10 @@ TO_BUFFER_STATE to_scan_string (const char *);
*/
- (long) firstOccurrenceOfCharacter:(unichar)character afterIndex:(long)startIndex ignoringQuotedStrings:(BOOL)ignoreQuotedStrings
{
+ if (character != parsedToChar) {
+ parsedToChar = '\0';
+ parsedToPosition = -1;
+ }
return [self firstOccurrenceOfCharacter:character afterIndex:startIndex skippingBrackets:NO ignoringQuotedStrings:ignoreQuotedStrings];
}
@@ -496,6 +504,11 @@ TO_BUFFER_STATE to_scan_string (const char *);
long stringLength = [string length];
int bracketingLevel = 0;
+ if (character != parsedToChar) {
+ parsedToChar = character;
+ parsedToPosition = -1;
+ }
+
// Cache frequently used selectors, avoiding dynamic binding overhead
IMP charAtIndex = [self methodForSelector:@selector(charAtIndex:)];
IMP endIndex = [self methodForSelector:@selector(endIndexOfStringQuotedByCharacter:startingAtIndex:)];
@@ -510,6 +523,7 @@ TO_BUFFER_STATE to_scan_string (const char *);
// Check for the ending character, and if it has been found and quoting/brackets is valid, return.
if (currentCharacter == character) {
if (!skipBrackets || bracketingLevel <= 0) {
+ parsedToPosition = currentStringIndex;
return currentStringIndex;
}
}
@@ -524,6 +538,7 @@ TO_BUFFER_STATE to_scan_string (const char *);
if (!ignoreQuotedStrings) break;
quotedStringEndIndex = (long)(*endIndex)(self, @selector(endIndexOfStringQuotedByCharacter:startingAtIndex:), currentCharacter, currentStringIndex+1);
if (quotedStringEndIndex == NSNotFound) {
+ parsedToPosition = currentStringIndex;
return NSNotFound;
}
currentStringIndex = quotedStringEndIndex;
@@ -560,6 +575,7 @@ TO_BUFFER_STATE to_scan_string (const char *);
}
// If no matches have been made in this string, return NSNotFound.
+ parsedToPosition = stringLength - 1;
return NSNotFound;
}
@@ -824,6 +840,8 @@ TO_BUFFER_STATE to_scan_string (const char *);
}
charCacheEnd = -1;
charCacheStart = 0;
+ parsedToChar = '\0';
+ parsedToPosition = -1;
}
- (void) deleteCharactersInRange:(NSRange)aRange
{
@@ -842,6 +860,8 @@ TO_BUFFER_STATE to_scan_string (const char *);
if (self = [super init]) {
string = [[NSMutableString string] retain];
}
+ parsedToChar = '\0';
+ parsedToPosition = -1;
charCacheEnd = -1;
return self;
}
@@ -849,6 +869,8 @@ TO_BUFFER_STATE to_scan_string (const char *);
if (self = [super init]) {
string = [[NSMutableString alloc] initWithBytes:bytes length:length encoding:encoding];
}
+ parsedToChar = '\0';
+ parsedToPosition = -1;
charCacheEnd = -1;
return self;
}
@@ -856,6 +878,8 @@ TO_BUFFER_STATE to_scan_string (const char *);
if (self = [super init]) {
string = [[NSMutableString alloc] initWithBytesNoCopy:bytes length:length encoding:encoding freeWhenDone:flag];
}
+ parsedToChar = '\0';
+ parsedToPosition = -1;
charCacheEnd = -1;
return self;
}
@@ -863,6 +887,8 @@ TO_BUFFER_STATE to_scan_string (const char *);
if (self = [super init]) {
string = [[NSMutableString stringWithCapacity:capacity] retain];
}
+ parsedToChar = '\0';
+ parsedToPosition = -1;
charCacheEnd = -1;
return self;
}
@@ -870,17 +896,23 @@ TO_BUFFER_STATE to_scan_string (const char *);
if (self = [super init]) {
string = [[NSMutableString alloc] initWithCharactersNoCopy:characters length:length freeWhenDone:flag];
}
+ parsedToChar = '\0';
+ parsedToPosition = -1;
charCacheEnd = -1;
return self;
}
- (id) initWithContentsOfFile:(id)path {
- charCacheEnd = -1;
+ parsedToChar = '\0';
+ parsedToPosition = 0;
+ parsedToPosition = -1;
return [self initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL];
}
- (id) initWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding)encoding error:(NSError **)error {
if (self = [super init]) {
string = [[NSMutableString alloc] initWithContentsOfFile:path encoding:encoding error:error];
}
+ parsedToChar = '\0';
+ parsedToPosition = -1;
charCacheEnd = -1;
return self;
}
@@ -888,6 +920,8 @@ TO_BUFFER_STATE to_scan_string (const char *);
if (self = [super init]) {
string = [[NSMutableString alloc] initWithCString:nullTerminatedCString encoding:encoding];
}
+ parsedToChar = '\0';
+ parsedToPosition = -1;
charCacheEnd = -1;
return self;
}
@@ -896,6 +930,8 @@ TO_BUFFER_STATE to_scan_string (const char *);
va_start(argList, format);
id str = [self initWithFormat:format arguments:argList];
va_end(argList);
+ parsedToChar = '\0';
+ parsedToPosition = -1;
charCacheEnd = -1;
return str;
}
@@ -903,6 +939,8 @@ TO_BUFFER_STATE to_scan_string (const char *);
if (self = [super init]) {
string = [[NSMutableString alloc] initWithFormat:format arguments:argList];
}
+ parsedToChar = '\0';
+ parsedToPosition = -1;
charCacheEnd = -1;
return self;
}
diff --git a/Source/TableDump.h b/Source/TableDump.h
index dc99d4bb..1dba02e2 100644
--- a/Source/TableDump.h
+++ b/Source/TableDump.h
@@ -116,6 +116,8 @@
// Import methods
- (void)importFile;
+- (void) importSQLFile:(NSString *)filename;
+- (void) importCSVFile:(NSString *)filename;
- (IBAction)changeFormat:(id)sender;
- (IBAction)changeTable:(id)sender;
- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(NSString *)contextInfo;
diff --git a/Source/TableDump.m b/Source/TableDump.m
index dbd28bcd..a41b61df 100644
--- a/Source/TableDump.m
+++ b/Source/TableDump.m
@@ -402,364 +402,479 @@
- (void)importBackgroundProcess:(NSString*)filename
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- SPSQLParser *dumpFile = nil;
- NSError *errorStr = nil;
- NSMutableString *errors = [NSMutableString string];
NSString *fileType = [[importFormatPopup selectedItem] title];
- BOOL importSQLAsUTF8 = YES;
- // Load file into string. For SQL imports, try UTF8 file encoding before the current encoding.
- if ([fileType isEqualToString:@"SQL"]) {
- DLog(@"Attempting to read as utf8");
- dumpFile = [SPSQLParser stringWithContentsOfFile:filename
- encoding:NSUTF8StringEncoding
- error:&errorStr];
-
- // This will crash if dumpFile is big.
- DLog(dumpFile);
-
- if (errorStr) {
- importSQLAsUTF8 = NO;
- errorStr = nil;
- }
- }
+ // Use the appropriate processing function for the file type
+ if ([fileType isEqualToString:@"SQL"])
+ [self importSQLFile:filename];
+ else if ([fileType isEqualToString:@"CSV"])
+ [self importCSVFile:filename];
- // If the SQL-as-UTF8 read failed, and for CSVs, use the current connection encoding.
- if (!importSQLAsUTF8 || [fileType isEqualToString:@"CSV"]) {
- DLog(@"Reading using connection encoding");
- dumpFile = [SPSQLParser stringWithContentsOfFile:filename
- encoding:[MCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] UTF8String]]
- error:&errorStr];
- }
+ [pool release];
+}
- if (errorStr) {
- NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"),
- NSLocalizedString(@"OK", @"OK button"),
- nil, nil,
- tableWindow, self,
- nil, nil, nil,
- [errorStr localizedDescription]
- );
- [pool release];
+- (void) importSQLFile:(NSString *)filename
+{
+ NSAutoreleasePool *importPool;
+ NSFileHandle *sqlFileHandle;
+ NSMutableData *sqlDataBuffer;
+ const unsigned char *sqlDataBufferBytes;
+ NSData *fileChunk;
+ NSString *sqlString;
+ SPSQLParser *sqlParser;
+ NSString *query;
+ NSMutableString *errors = [NSMutableString string];
+ NSInteger fileChunkMaxLength = 1024 * 1024;
+ NSInteger fileTotalLength = 0;
+ NSInteger fileProcessedLength = 0;
+ NSInteger queriesPerformed = 0;
+ NSInteger dataBufferLength = 0;
+ NSInteger dataBufferPosition = 0;
+ NSInteger dataBufferLastQueryEndPosition = 0;
+ BOOL importSQLAsUTF8 = YES;
+ BOOL allDataRead = NO;
+ NSStringEncoding sqlEncoding = NSUTF8StringEncoding;
+ NSCharacterSet *whitespaceAndNewlineCharset = [NSCharacterSet whitespaceAndNewlineCharacterSet];
+
+ // Open a filehandle for the SQL file
+ sqlFileHandle = [NSFileHandle fileHandleForReadingAtPath:filename];
+ if (!sqlFileHandle) {
+ NSBeginAlertSheet(NSLocalizedString(@"Import Error title", @"Import Error"),
+ NSLocalizedString(@"OK button label", @"OK button"),
+ nil, nil, tableWindow, self, nil, nil, nil,
+ NSLocalizedString(@"SQL file open error", @"The SQL file you selected could not be found or read."));
return;
}
-
- // reset interface
+
+ // Grab the file length
+ fileTotalLength = [[[[NSFileManager defaultManager] fileAttributesAtPath:filename traverseLink:YES] objectForKey:NSFileSize] integerValue];
+ if (!fileTotalLength) fileTotalLength = 1;
+
+ // Reset progress interface
[errorsView setString:@""];
- [errorsView displayIfNeeded];
- [singleProgressTitle setStringValue:NSLocalizedString(@"Starting import...", @"text showing that the application has started importing")];
- [singleProgressTitle displayIfNeeded];
+ [singleProgressTitle setStringValue:NSLocalizedString(@"Importing SQL", @"text showing that the application is importing SQL")];
[singleProgressText setStringValue:NSLocalizedString(@"Reading...", @"text showing that app is reading dump")];
- [singleProgressText displayIfNeeded];
- [singleProgressBar setDoubleValue:0];
- [singleProgressBar displayIfNeeded];
-
- if ( [fileType isEqualToString:@"SQL"] ) {
-
- //import dump file
- NSArray *queries;
- int i=0;
-
- //open progress sheet
- [NSApp beginSheet:singleProgressSheet
- modalForWindow:tableWindow
- modalDelegate:self
- didEndSelector:nil
- contextInfo:nil];
-
- [singleProgressSheet makeKeyWindow];
- [singleProgressBar setIndeterminate:YES];
- [singleProgressBar setUsesThreadedAnimation:YES];
- [singleProgressBar startAnimation:self];
-
- //get array with an object for each mysql-query
- queries = [dumpFile splitSqlStringByCharacter:';'];
+ [singleProgressBar setIndeterminate:NO];
+ [singleProgressBar setMaxValue:fileTotalLength];
+ [singleProgressBar setUsesThreadedAnimation:YES];
+
+ // Open the progress sheet
+ [NSApp beginSheet:singleProgressSheet modalForWindow:tableWindow modalDelegate:self didEndSelector:nil contextInfo:nil];
+ [singleProgressSheet makeKeyWindow];
+
+ // Read in the file in a loop
+ sqlParser = [[SPSQLParser alloc] init];
+ sqlDataBuffer = [[NSMutableData alloc] init];
+ importPool = [[NSAutoreleasePool alloc] init];
+ while (1) {
+ @try {
+ fileChunk = [sqlFileHandle readDataOfLength:fileChunkMaxLength];
+ }
- unsigned long queryCount = [queries count];
+ // Report file read errors, and bail
+ @catch (NSException *exception) {
+ NSBeginAlertSheet(NSLocalizedString(@"SQL read error title", @"File read error"),
+ NSLocalizedString(@"OK", @"OK button"),
+ nil, nil, tableWindow, self, nil, nil, nil,
+ [NSString stringWithFormat:NSLocalizedString(@"SQL read error", @"An error occurred when reading the file.\n\nOnly %i queries were executed.\n\n(%@)"), queriesPerformed, [exception reason]]);
+ [sqlParser release];
+ [sqlDataBuffer release];
+ [importPool drain];
+ return;
+ }
- [singleProgressBar stopAnimation:self];
- [singleProgressBar setIndeterminate:NO];
- [singleProgressTitle setStringValue:NSLocalizedString(@"Importing SQL", @"text showing that the application is importing SQL")];
- [singleProgressText setStringValue:[NSString stringWithFormat:NSLocalizedString(@"Executing %d statements...", @"text showing that app is executing x statements"), queryCount]];
+ // If no data returned, end of file - set a marker to ensure full processing
+ if (!fileChunk || ![fileChunk length]) {
+ allDataRead = YES;
+
+ // Otherwise add the data to the read/parse buffer
+ } else {
+ [sqlDataBuffer appendData:fileChunk];
+ }
- NSCharacterSet *whitespaceAndNewline = [NSCharacterSet whitespaceAndNewlineCharacterSet];
+ // Step through the data buffer, identifying line endings to parse the data with
+ sqlDataBufferBytes = [sqlDataBuffer bytes];
+ dataBufferLength = [sqlDataBuffer length];
+ for ( ; dataBufferPosition < dataBufferLength || allDataRead; dataBufferPosition++) {
+ if (sqlDataBufferBytes[dataBufferPosition] == 0x0A || sqlDataBufferBytes[dataBufferPosition] == 0x0D || allDataRead) {
+
+ // Keep reading through any other line endings
+ while (dataBufferPosition + 1 < dataBufferLength
+ && (sqlDataBufferBytes[dataBufferPosition+1] == 0x0A
+ || sqlDataBufferBytes[dataBufferPosition+1] == 0x0D))
+ {
+ dataBufferPosition++;
+ }
- //perform all mysql-queries
- if (importSQLAsUTF8)
- for ( i = 0 ; i < queryCount ; i++ ) {
- [singleProgressBar setDoubleValue:(i*100/queryCount)];
-
- // Skip blank or whitespace-only queries to avoid errors
- NSString *q = [NSArrayObjectAtIndex(queries, i) stringByTrimmingCharactersInSet:whitespaceAndNewline];
- if (![q length]) continue;
-
- [mySQLConnection queryString:q usingEncoding:NSUTF8StringEncoding streamingResult:NO];
-
- if ([[mySQLConnection getLastErrorMessage] length] && ![[mySQLConnection getLastErrorMessage] isEqualToString:@"Query was empty"]) {
- [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"[ERROR in query %d] %@\n", @"error text when multiple custom query failed"), (i+1),[mySQLConnection getLastErrorMessage]]];
+ // Try to generate a NSString with the resulting data
+ if (importSQLAsUTF8) {
+ sqlString = [[NSString alloc] initWithData:[sqlDataBuffer subdataWithRange:NSMakeRange(dataBufferLastQueryEndPosition, dataBufferPosition - dataBufferLastQueryEndPosition)]
+ encoding:NSUTF8StringEncoding];
+ if (!sqlString) {
+ importSQLAsUTF8 = NO;
+ sqlEncoding = [MCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] UTF8String]];
+ }
+ }
+ if (!importSQLAsUTF8) {
+ sqlString = [[NSString alloc] initWithData:[sqlDataBuffer subdataWithRange:NSMakeRange(dataBufferLastQueryEndPosition, dataBufferPosition - dataBufferLastQueryEndPosition)]
+ encoding:[MCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] UTF8String]]];
+ if (!sqlString) {
+ NSBeginAlertSheet(NSLocalizedString(@"SQL read error title", @"File read error"),
+ NSLocalizedString(@"OK", @"OK button"),
+ nil, nil, tableWindow, self, nil, nil, nil,
+ [NSString stringWithFormat:NSLocalizedString(@"SQL encoding read error", @"An error occurred when reading the file, as it could not be read in either UTF-8 or %@.\n\nOnly %i queries were executed."), [[tableDocumentInstance connectionEncoding] UTF8String], queriesPerformed]);
+ [sqlParser release];
+ [sqlDataBuffer release];
+ [importPool drain];
+ return;
+ }
}
+
+ // Add the NSString segment to the SQL parser and release it
+ [sqlParser appendString:sqlString];
+ [sqlString release];
+
+ if (allDataRead) break;
+
+ // Increment the query end position marker
+ dataBufferLastQueryEndPosition = dataBufferPosition;
}
- else
- for ( i = 0 ; i < queryCount ; i++ ) {
- [singleProgressBar setDoubleValue:(i*100/queryCount)];
+ }
+
+ // Trim the data buffer if part of it was used
+ if (dataBufferLastQueryEndPosition) {
+ [sqlDataBuffer setData:[sqlDataBuffer subdataWithRange:NSMakeRange(dataBufferLastQueryEndPosition, dataBufferLength - dataBufferLastQueryEndPosition)]];
+ dataBufferPosition -= dataBufferLastQueryEndPosition;
+ dataBufferLastQueryEndPosition = 0;
+ }
+
+ // Extract and process any complete SQL queries that can be found in the strings parsed so far
+ while (query = [sqlParser trimAndReturnStringToCharacter:';' trimmingInclusively:YES returningInclusively:NO]) {
+ fileProcessedLength += [query lengthOfBytesUsingEncoding:sqlEncoding] + 1;
- // Skip blank or whitespace-only queries to avoid errors
- NSString *q = [NSArrayObjectAtIndex(queries, i) stringByTrimmingCharactersInSet:whitespaceAndNewline];
- if (![q length]) continue;
-
- [mySQLConnection queryString:q];
+ // Skip blank or whitespace-only queries to avoid errors
+ query = [query stringByTrimmingCharactersInSet:whitespaceAndNewlineCharset];
+ if (![query length]) continue;
+
+ // Run the query
+ [mySQLConnection queryString:query usingEncoding:sqlEncoding streamingResult:NO];
- if ([[mySQLConnection getLastErrorMessage] length] && ![[mySQLConnection getLastErrorMessage] isEqualToString:@"Query was empty"]) {
- [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"[ERROR in query %d] %@\n", @"error text when multiple custom query failed"), (i+1),[mySQLConnection getLastErrorMessage]]];
- }
+ // Check for any errors
+ if ([[mySQLConnection getLastErrorMessage] length] && ![[mySQLConnection getLastErrorMessage] isEqualToString:@"Query was empty"]) {
+ [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"[ERROR in query %d] %@\n", @"error text when multiple custom query failed"), (queriesPerformed+1), [mySQLConnection getLastErrorMessage]]];
}
- //close progress sheet
- [NSApp endSheet:singleProgressSheet];
- [singleProgressSheet orderOut:nil];
+ // Increment the processed queries count
+ queriesPerformed++;
+
+ // Update the progress bar
+ [singleProgressBar setDoubleValue:fileProcessedLength];
+ [singleProgressText setStringValue:[NSString stringWithFormat:NSLocalizedString(@"Imported %@ of %@", @"SQL import progress text"),
+ [NSString stringForByteSize:fileProcessedLength], [NSString stringForByteSize:fileTotalLength]]];
+ }
- //display errors
- if ( [errors length] ) {
- [errorsView setString:errors];
- [NSApp beginSheet:errorsSheet
- modalForWindow:tableWindow
- modalDelegate:self
- didEndSelector:nil
- contextInfo:nil];
+ // If all the data has been read, break out of the processing loop
+ if (allDataRead) break;
+
+ // Reset the autorelease pool
+ [importPool drain];
+ importPool = [[NSAutoreleasePool alloc] init];
+ }
+
+ // If any text remains in the SQL parser, it's an unterminated query - execute it.
+ query = [sqlParser stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ if ([query length]) {
- [NSApp runModalForWindow:errorsSheet];
- [NSApp endSheet:errorsSheet];
- [errorsSheet orderOut:nil];
+ // Run the query
+ [mySQLConnection queryString:query usingEncoding:sqlEncoding streamingResult:NO];
+
+ // Check for any errors
+ if ([[mySQLConnection getLastErrorMessage] length] && ![[mySQLConnection getLastErrorMessage] isEqualToString:@"Query was empty"]) {
+ [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"[ERROR in query %d] %@\n", @"error text when multiple custom query failed"), (queriesPerformed+1), [mySQLConnection getLastErrorMessage]]];
}
- //update available databases
- [tableDocumentInstance setDatabases:self];
- //update current selected database
- [tableDocumentInstance refreshCurrentDatabase];
- //udpate current database tables
- [tablesListInstance updateTables:self];
-
- ////////////////
- // IMPORT CSV //
- ////////////////
- } else if ( [fileType isEqualToString:@"CSV"] ) {
- int code;
- //open progress sheet
- [NSApp beginSheet:singleProgressSheet
- modalForWindow:tableWindow
- modalDelegate:self
- didEndSelector:nil
- contextInfo:nil];
-
- [singleProgressTitle setStringValue:NSLocalizedString(@"Importing CSV", @"text showing that the application is importing CSV")];
- [singleProgressSheet makeKeyWindow];
- [singleProgressBar setIndeterminate:YES];
- [singleProgressBar setUsesThreadedAnimation:YES];
- [singleProgressBar startAnimation:self];
-
- //put file in array
- if (importArray)
- [importArray release];
-
- importArray = [[self arrayForCSV:dumpFile
- terminatedBy:[importFieldsTerminatedField stringValue]
- enclosedBy:[importFieldsEnclosedField stringValue]
- escapedBy:[importFieldsEscapedField stringValue]
- lineEnds:[importLinesTerminatedField stringValue]] retain];
-
- long importArrayCount = [importArray count];
-
- //close progress sheet
+ // Increment the processed queries count
+ queriesPerformed++;
+ }
+
+ // Clean up
+ [sqlParser release];
+ [sqlDataBuffer release];
+ [importPool drain];
+
+ // Close progress sheet
+ [NSApp endSheet:singleProgressSheet];
+ [singleProgressSheet orderOut:nil];
+ [singleProgressBar setMaxValue:100];
+
+ // Display any errors
+ if ([errors length]) {
+ [errorsView setString:errors];
+ [NSApp beginSheet:errorsSheet modalForWindow:tableWindow modalDelegate:self didEndSelector:nil contextInfo:nil];
+ [NSApp runModalForWindow:errorsSheet];
+ [NSApp endSheet:errorsSheet];
+ [errorsSheet orderOut:nil];
+ }
+
+ // Update available databases
+ [tableDocumentInstance setDatabases:self];
+
+ // Update current selected database
+ [tableDocumentInstance refreshCurrentDatabase];
+
+ // Update current database tables
+ [tablesListInstance updateTables:self];
+
+ // Import finished Growl notification
+ [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Import Finished"
+ description:[NSString stringWithFormat:NSLocalizedString(@"Finished importing %@",@"description for finished importing growl notification"), [filename lastPathComponent]]
+ notificationName:@"Import Finished"];
+}
+
+- (void) importCSVFile:(NSString *)filename
+{
+ NSString *dumpFile = nil;
+ NSError *errorStr = nil;
+ NSMutableString *errors = [NSMutableString string];
+
+ // Reset progress interface
+ [errorsView setString:@""];
+ [errorsView displayIfNeeded];
+ [singleProgressTitle setStringValue:NSLocalizedString(@"Importing CSV", @"text showing that the application is importing CSV")];
+ [singleProgressTitle displayIfNeeded];
+ [singleProgressText setStringValue:NSLocalizedString(@"Reading...", @"text showing that app is reading dump")];
+ [singleProgressText displayIfNeeded];
+ [singleProgressBar setIndeterminate:YES];
+ [singleProgressBar setUsesThreadedAnimation:YES];
+ [singleProgressBar startAnimation:self];
+
+ int code;
+
+ //open progress sheet
+ [NSApp beginSheet:singleProgressSheet
+ modalForWindow:tableWindow
+ modalDelegate:self
+ didEndSelector:nil
+ contextInfo:nil];
+ [singleProgressSheet makeKeyWindow];
+
+ // Read the file with the current connection encoding.
+ dumpFile = [NSString stringWithContentsOfFile:filename
+ encoding:[MCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] UTF8String]]
+ error:&errorStr];
+
+ if (errorStr) {
[NSApp endSheet:singleProgressSheet];
[singleProgressSheet orderOut:nil];
- [singleProgressBar stopAnimation:self];
- [singleProgressBar setUsesThreadedAnimation:NO];
- [singleProgressBar setIndeterminate:NO];
+ NSBeginAlertSheet(NSLocalizedString(@"Error", @"Error"),
+ NSLocalizedString(@"OK", @"OK button"),
+ nil, nil,
+ tableWindow, self,
+ nil, nil, nil,
+ [errorStr localizedDescription]
+ );
+ return;
+ }
+
+
+ //put file in array
+ if (importArray)
+ [importArray release];
+
+ importArray = [[self arrayForCSV:dumpFile
+ terminatedBy:[importFieldsTerminatedField stringValue]
+ enclosedBy:[importFieldsEnclosedField stringValue]
+ escapedBy:[importFieldsEscapedField stringValue]
+ lineEnds:[importLinesTerminatedField stringValue]] retain];
+
+ long importArrayCount = [importArray count];
+
+ //close progress sheet
+ [NSApp endSheet:singleProgressSheet];
+ [singleProgressSheet orderOut:nil];
+ [singleProgressBar stopAnimation:self];
+ [singleProgressBar setUsesThreadedAnimation:NO];
+ [singleProgressBar setIndeterminate:NO];
+
+ if(importArrayCount == 0){
+ NSBeginAlertSheet(NSLocalizedString(@"Error", @"Error"),
+ NSLocalizedString(@"OK", @"OK button"),
+ nil, nil,
+ tableWindow, self,
+ nil, nil, nil,
+ NSLocalizedString(@"Could not parse file as CSV", @"Error when we can't parse/split file as CSV")
+ );
+ [importArray release], importArray = nil;
+ return;
+ }
+
+ if (progressCancelled) {
+ progressCancelled = NO;
+ [importArray release], importArray = nil;
+ return;
+ }
+ MCPResult *theResult;
+ int i;
+ theResult = (MCPResult *) [mySQLConnection listTables];
+ if ([theResult numOfRows]) [theResult dataSeek:0];
+ [fieldMappingPopup removeAllItems];
+ for ( i = 0 ; i < [theResult numOfRows] ; i++ ) {
+ [fieldMappingPopup addItemWithTitle:NSArrayObjectAtIndex([theResult fetchRowAsArray], 0)];
+ }
+
+ if ([tableDocumentInstance table] != nil && ![(NSString *)[tableDocumentInstance table] isEqualToString:@""]) {
+ [fieldMappingPopup selectItemWithTitle:[(TableDocument *)tableDocumentInstance table]];
+ } else {
+ [fieldMappingPopup selectItemAtIndex:0];
+ }
+
+ if( ![tablesListInstance selectTableOrViewWithName:[fieldMappingPopup titleOfSelectedItem]] ) {
+ [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"[ERROR] %@\n", @"error text when trying to import csv data, but we have no tables in the db"), @"Can't import CSV data into a database without any tables!"]];
+ } else {
- if(importArrayCount == 0){
+ //set up tableView
+ currentRow = 0;
+
+ // Sanity check the first row of the CSV to prevent hang loops caused by wrong line ending entry
+ if ([[importArray objectAtIndex:currentRow] count] > 512) {
NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"),
NSLocalizedString(@"OK", @"OK button"),
nil, nil,
tableWindow, self,
nil, nil, nil,
- NSLocalizedString(@"Could not parse file as CSV", @"Error when we can't parse/split file as CSV")
+ NSLocalizedString(@"The CSV was read as containing more than 512 columns, more than the maximum columns permitted for speed reasons by Sequel Pro.\n\nThis usually happens due to errors reading the CSV; please double-check the CSV to be imported and the line endings and escape characters at the bottom of the CSV selection dialog.", @"Error when CSV appears to have too many columns to import, probably due to line ending mismatch")
);
[importArray release], importArray = nil;
- [pool release];
- return;
- }
-
- if (progressCancelled) {
- progressCancelled = NO;
- [importArray release], importArray = nil;
- [pool release];
return;
}
- MCPResult *theResult;
- int i;
- theResult = (MCPResult *) [mySQLConnection listTables];
- if ([theResult numOfRows]) [theResult dataSeek:0];
- [fieldMappingPopup removeAllItems];
- for ( i = 0 ; i < [theResult numOfRows] ; i++ ) {
- [fieldMappingPopup addItemWithTitle:NSArrayObjectAtIndex([theResult fetchRowAsArray], 0)];
- }
- if ([tableDocumentInstance table] != nil && ![(NSString *)[tableDocumentInstance table] isEqualToString:@""]) {
- [fieldMappingPopup selectItemWithTitle:[(TableDocument *)tableDocumentInstance table]];
- } else {
- [fieldMappingPopup selectItemAtIndex:0];
- }
+ if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil;
+ [self setupFieldMappingArray];
+ [rowDownButton setEnabled:NO];
+ [rowUpButton setEnabled:(importArrayCount > 1)];
+ [recordCountLabel setStringValue:[NSString stringWithFormat:@"%i of %i records", currentRow+1, importArrayCount]];
+
+ //set up tableView buttons
+ NSPopUpButtonCell *buttonCell = [[NSPopUpButtonCell alloc] init];
+ [buttonCell setControlSize:NSSmallControlSize];
+ [buttonCell setFont:[NSFont labelFontOfSize:[NSFont smallSystemFontSize]]];
+ [buttonCell setBordered:NO];
+ [[fieldMappingTableView tableColumnWithIdentifier:@"value"] setDataCell:buttonCell];
+ [self updateFieldMappingButtonCell];
+ [fieldMappingTableView reloadData];
+ [buttonCell release];
+
+ // show fieldMapping sheet
+ [NSApp beginSheet:fieldMappingSheet
+ modalForWindow:tableWindow
+ modalDelegate:self
+ didEndSelector:nil
+ contextInfo:nil];
- if( ![tablesListInstance selectTableOrViewWithName:[fieldMappingPopup titleOfSelectedItem]] ) {
- [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"[ERROR] %@\n", @"error text when trying to import csv data, but we have no tables in the db"), @"Can't import CSV data into a database without any tables!"]];
- } else {
-
- //set up tableView
- currentRow = 0;
-
- // Sanity check the first row of the CSV to prevent hang loops caused by wrong line ending entry
- if ([[importArray objectAtIndex:currentRow] count] > 512) {
- NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"),
- NSLocalizedString(@"OK", @"OK button"),
- nil, nil,
- tableWindow, self,
- nil, nil, nil,
- NSLocalizedString(@"The CSV was read as containing more than 512 columns, more than the maximum columns permitted for speed reasons by Sequel Pro.\n\nThis usually happens due to errors reading the CSV; please double-check the CSV to be imported and the line endings and escape characters at the bottom of the CSV selection dialog.", @"Error when CSV appears to have too many columns to import, probably due to line ending mismatch")
- );
- [importArray release], importArray = nil;
- [pool release];
- return;
- }
-
- if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil;
- [self setupFieldMappingArray];
- [rowDownButton setEnabled:NO];
- [rowUpButton setEnabled:(importArrayCount > 1)];
- [recordCountLabel setStringValue:[NSString stringWithFormat:@"%i of %i records", currentRow+1, importArrayCount]];
-
- //set up tableView buttons
- NSPopUpButtonCell *buttonCell = [[NSPopUpButtonCell alloc] init];
- [buttonCell setControlSize:NSSmallControlSize];
- [buttonCell setFont:[NSFont labelFontOfSize:[NSFont smallSystemFontSize]]];
- [buttonCell setBordered:NO];
- [[fieldMappingTableView tableColumnWithIdentifier:@"value"] setDataCell:buttonCell];
- [self updateFieldMappingButtonCell];
- [fieldMappingTableView reloadData];
- [buttonCell release];
+ code = [NSApp runModalForWindow:fieldMappingSheet];
+ [NSApp endSheet:fieldMappingSheet];
+ [fieldMappingSheet orderOut:nil];
+
+ if ( code ) {
+ //import array into db
+ NSMutableString *fNames = [NSMutableString string];
+ //NSMutableArray *fValuesIndexes = [NSMutableArray array];
+ NSMutableString *fValues = [NSMutableString string];
+ NSString *insertFormatString = nil;
+ int i,j;
- // show fieldMapping sheet
- [NSApp beginSheet:fieldMappingSheet
+ //open progress sheet
+ [NSApp beginSheet:singleProgressSheet
modalForWindow:tableWindow
modalDelegate:self
didEndSelector:nil
contextInfo:nil];
- code = [NSApp runModalForWindow:fieldMappingSheet];
- [NSApp endSheet:fieldMappingSheet];
- [fieldMappingSheet orderOut:nil];
+ [singleProgressBar setUsesThreadedAnimation:NO];
+ [singleProgressSheet makeKeyWindow];
+ [singleProgressText setStringValue:NSLocalizedString(@"Creating rows...", @"text showing that app is importing rows from CSV")];
+ [singleProgressText displayIfNeeded];
- if ( code ) {
- //import array into db
- NSMutableString *fNames = [NSMutableString string];
- //NSMutableArray *fValuesIndexes = [NSMutableArray array];
- NSMutableString *fValues = [NSMutableString string];
- NSString *insertFormatString = nil;
- int i,j;
-
- //open progress sheet
- [NSApp beginSheet:singleProgressSheet
- modalForWindow:tableWindow
- modalDelegate:self
- didEndSelector:nil
- contextInfo:nil];
-
- [singleProgressBar setUsesThreadedAnimation:NO];
- [singleProgressSheet makeKeyWindow];
- [singleProgressText setStringValue:NSLocalizedString(@"Creating rows...", @"text showing that app is importing rows from CSV")];
- [singleProgressText displayIfNeeded];
-
- // get fields to be imported
- for (i = 0; i < [fieldMappingArray count] ; i++ ) {
- if ([NSArrayObjectAtIndex(fieldMappingArray, i) intValue] > 0) {
- if ( [fNames length] )
- [fNames appendString:@","];
-
- [fNames appendString:[NSArrayObjectAtIndex([tableSourceInstance fieldNames], i) backtickQuotedString]];
- }
+ // get fields to be imported
+ for (i = 0; i < [fieldMappingArray count] ; i++ ) {
+ if ([NSArrayObjectAtIndex(fieldMappingArray, i) intValue] > 0) {
+ if ( [fNames length] )
+ [fNames appendString:@","];
+
+ [fNames appendString:[NSArrayObjectAtIndex([tableSourceInstance fieldNames], i) backtickQuotedString]];
}
-
- // import array
- long fieldMappingArrayCount = [fieldMappingArray count];
- insertFormatString = [NSString stringWithFormat:@"INSERT INTO %@ (%@) VALUES (%%@)",
- [[fieldMappingPopup titleOfSelectedItem] backtickQuotedString], fNames];
- int fieldMappingIntValue;
- Class nullClass = [NSNull class];
-
- for ( i = 0 ; i < importArrayCount ; i++ ) {
- //show progress bar
- [singleProgressBar setDoubleValue:((i+1)*100/importArrayCount)];
-
- if ( !([importFieldNamesSwitch state] && (i == 0)) ) {
- //put values in string
- [fValues setString:@""];
-
- for ( j = 0 ; j < fieldMappingArrayCount ; j++ ) {
- fieldMappingIntValue = [NSArrayObjectAtIndex(fieldMappingArray,j) intValue];
- if ( fieldMappingIntValue > 0 ) {
-
- if ( [fValues length] )
- [fValues appendString:@","];
+ }
+
+ // import array
+ long fieldMappingArrayCount = [fieldMappingArray count];
+ insertFormatString = [NSString stringWithFormat:@"INSERT INTO %@ (%@) VALUES (%%@)",
+ [[fieldMappingPopup titleOfSelectedItem] backtickQuotedString], fNames];
+ int fieldMappingIntValue;
+ Class nullClass = [NSNull class];
+
+ for ( i = 0 ; i < importArrayCount ; i++ ) {
+ //show progress bar
+ [singleProgressBar setDoubleValue:((i+1)*100/importArrayCount)];
+
+ if ( !([importFieldNamesSwitch state] && (i == 0)) ) {
+ //put values in string
+ [fValues setString:@""];
+
+ for ( j = 0 ; j < fieldMappingArrayCount ; j++ ) {
+ fieldMappingIntValue = [NSArrayObjectAtIndex(fieldMappingArray,j) intValue];
+ if ( fieldMappingIntValue > 0 ) {
+
+ if ( [fValues length] )
+ [fValues appendString:@","];
- id c = NSArrayObjectAtIndex(NSArrayObjectAtIndex(importArray, i), (fieldMappingIntValue - 1));
+ id c = NSArrayObjectAtIndex(NSArrayObjectAtIndex(importArray, i), (fieldMappingIntValue - 1));
- [fValues appendString: ([c isMemberOfClass:nullClass]) ?
- @"NULL" : [NSString stringWithFormat:@"'%@'", [mySQLConnection prepareString:c]]];
- }
- }
-
- //perform query
- [mySQLConnection queryString:[NSString stringWithFormat:insertFormatString, fValues]];
-
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
- [errors appendString:[NSString stringWithFormat:
- NSLocalizedString(@"[ERROR in line %d] %@\n", @"error text when reading of csv file gave errors"),
- (i+1),[mySQLConnection getLastErrorMessage]]];
+ [fValues appendString: ([c isMemberOfClass:nullClass]) ?
+ @"NULL" : [NSString stringWithFormat:@"'%@'", [mySQLConnection prepareString:c]]];
}
}
+
+ //perform query
+ [mySQLConnection queryString:[NSString stringWithFormat:insertFormatString, fValues]];
+
+ if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ [errors appendString:[NSString stringWithFormat:
+ NSLocalizedString(@"[ERROR in line %d] %@\n", @"error text when reading of csv file gave errors"),
+ (i+1),[mySQLConnection getLastErrorMessage]]];
+ }
}
-
- //close progress sheet
- [NSApp endSheet:singleProgressSheet];
- [singleProgressSheet orderOut:nil];
}
- [tableContentInstance loadTableValues];
+ //close progress sheet
+ [NSApp endSheet:singleProgressSheet];
+ [singleProgressSheet orderOut:nil];
}
- //display errors
- if ( [errors length] ) {
- [errorsView setString:errors];
- [NSApp beginSheet:errorsSheet
- modalForWindow:tableWindow
- modalDelegate:self
- didEndSelector:nil
- contextInfo:nil];
-
- [NSApp runModalForWindow:errorsSheet];
- [NSApp endSheet:errorsSheet];
- [errorsSheet orderOut:nil];
- }
+ [tableContentInstance loadTableValues];
+ }
+
+ //display errors
+ if ( [errors length] ) {
+ [errorsView setString:errors];
+ [NSApp beginSheet:errorsSheet
+ modalForWindow:tableWindow
+ modalDelegate:self
+ didEndSelector:nil
+ contextInfo:nil];
- //free arrays
- if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil;
- [importArray release], importArray = nil;
+ [NSApp runModalForWindow:errorsSheet];
+ [NSApp endSheet:errorsSheet];
+ [errorsSheet orderOut:nil];
}
+ //free arrays
+ if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil;
+ [importArray release], importArray = nil;
+
// Import finished Growl notification
[[SPGrowlController sharedGrowlController] notifyWithTitle:@"Import Finished"
description:[NSString stringWithFormat:NSLocalizedString(@"Finished importing %@",@"description for finished importing growl notification"), [filename lastPathComponent]]
notificationName:@"Import Finished"];
- [pool release];
}
- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(NSString *)contextInfo
id='n1843' href='#n1843'>1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817