あれとこれのコンバータ
Revision | 8ece8bbf421226ddce3c4f26df1acff3c279292f (tree) |
---|---|
Time | 2011-12-03 17:21:11 |
Author | masakih <masakih@user...> |
Commiter | masakih |
Treat source code
ソースコードの整理。
@@ -71,11 +71,21 @@ | ||
71 | 71 | return bathyscapheSupportFolderPath; |
72 | 72 | } |
73 | 73 | |
74 | + | |
75 | +- (void)loggingIfNeeded | |
76 | +{ | |
77 | + SQLiteDB *db = [[DatabaseManager defaultManager]databaseForCurrentThread]; | |
78 | + if([db lastErrorID] != SQLITE_OK) { | |
79 | + NSLog(@"%@", [db lastError]); | |
80 | + } | |
81 | +} | |
82 | + | |
74 | 83 | - (void)updateTime |
75 | 84 | { |
76 | 85 | NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0.0]; |
77 | 86 | panel.progressTime = [NSDate dateWithTimeIntervalSince1970:[now timeIntervalSinceDate:startTime] - [[NSTimeZone systemTimeZone] secondsFromGMT]]; |
78 | 87 | } |
88 | + | |
79 | 89 | - (SQLiteReservedQuery *)sqlForInsertion |
80 | 90 | { |
81 | 91 | static SQLiteReservedQuery *query = nil; |
@@ -141,11 +151,6 @@ | ||
141 | 151 | return; |
142 | 152 | } |
143 | 153 | |
144 | -// NSString *sql = [NSString stringWithFormat:@"INSERT INTO %@ ( %@, %@, %@, %@, %@, %@, %@, %@ ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?)", | |
145 | -// ThreadInfoTableName, | |
146 | -// BoardIDColumn, ThreadIDColumn, ThreadNameColumn, NumberOfAllColumn, NumberOfReadColumn, ModifiedDateColumn, ThreadStatusColumn, | |
147 | -// IsDatOchiColumn]; | |
148 | - | |
149 | 154 | SQLiteReservedQuery *sqlForInsertion = [self sqlForInsertion]; |
150 | 155 | [sqlForInsertion cursorWithFormat: |
151 | 156 | F_Int F_NSString F_NSString F_NSNumberOfInt F_NSNumberOfInt F_NSNumberOfDouble F_NSNumberOfInt F_NSNumberOfInt, |
@@ -191,12 +196,26 @@ | ||
191 | 196 | } |
192 | 197 | } |
193 | 198 | |
194 | -- (void)loggingIfNeeded | |
199 | +- (void)convertBoardHistories:(NSArray *)boards | |
195 | 200 | { |
196 | - SQLiteDB *db = [[DatabaseManager defaultManager]databaseForCurrentThread]; | |
197 | - if([db lastErrorID] != SQLITE_OK) { | |
198 | - NSLog(@"%@", [db lastError]); | |
201 | + panel.message = @"Converting board histories ..."; | |
202 | + DatabaseManager *dm = [DatabaseManager defaultManager]; | |
203 | + NSString *sql = [NSString stringWithFormat:@"INSERT INTO %@ (%@, %@, %@) VALUES (?, ?, ?);", | |
204 | + BoardInfoHistoryTableName, | |
205 | + BoardIDColumn, BoardNameColumn, BoardURLColumn]; | |
206 | + SQLiteReservedQuery *query = [[SQLiteReservedQuery alloc] initWithQuery:sql | |
207 | + usingSQLiteDB:[[DatabaseManager defaultManager] databaseForCurrentThread]]; | |
208 | + for(BSBoardInformationObject *board in boards) { | |
209 | + [self updateTime]; | |
210 | + NSUInteger boardID = [dm boardIDForURLString:board.boardURL]; | |
211 | + for(BSBoardHistoryObject *hist in board.histories) { | |
212 | + [self updateTime]; | |
213 | + [query cursorWithFormat:F_Int F_NSString F_NSString, | |
214 | + boardID, hist.boardName, hist.boardURL]; | |
215 | + [self loggingIfNeeded]; | |
216 | + } | |
199 | 217 | } |
218 | + [query release]; | |
200 | 219 | } |
201 | 220 | |
202 | 221 | - (void)doConvertToSQLite |
@@ -224,25 +243,7 @@ | ||
224 | 243 | [self updateTime]; |
225 | 244 | |
226 | 245 | pool = [[NSAutoreleasePool alloc] init]; |
227 | - panel.message = @"Converting board histories ..."; | |
228 | - DatabaseManager *dm = [DatabaseManager defaultManager]; | |
229 | - NSString *sql = [NSString stringWithFormat:@"INSERT INTO %@ (%@, %@, %@) VALUES (?, ?, ?);", | |
230 | - BoardInfoHistoryTableName, | |
231 | - BoardIDColumn, BoardNameColumn, BoardURLColumn]; | |
232 | - SQLiteReservedQuery *query = [[SQLiteReservedQuery alloc] initWithQuery:sql | |
233 | - usingSQLiteDB:[[DatabaseManager defaultManager] databaseForCurrentThread]]; | |
234 | - for(BSBoardInformationObject *board in boards) { | |
235 | - [self updateTime]; | |
236 | - NSUInteger boardID = [dm boardIDForURLString:board.boardURL]; | |
237 | - for(BSBoardHistoryObject *hist in board.histories) { | |
238 | - [self updateTime]; | |
239 | - [query cursorWithFormat:F_Int F_NSString F_NSString, | |
240 | - boardID, hist.boardName, hist.boardURL]; | |
241 | - [self loggingIfNeeded]; | |
242 | - } | |
243 | - } | |
244 | - [query release]; | |
245 | - | |
246 | + [self convertBoardHistories:boards]; | |
246 | 247 | panel.amount = 0; |
247 | 248 | panel.count = 0; |
248 | 249 | [pool release]; |