masakih

あれとこれコンバータ (プロジェクト終了)

  • R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoapythonrubywindowsphpgameguibathyscaphec翻訳omegatframework計画中(planning stage)twitterdombtronvb.nettestarduinodirectxpreviewerゲームエンジン

あれとこれのコンバータ


Commit MetaInfo

Révisiona1229f1946ef2ea825bbc30bd25577293e637f4e (tree)
l'heure2011-12-03 16:40:23
Auteurmasakih <masakih@user...>
Commitermasakih

Message de Log

板移転履歴のコンバート

Change Summary

Modification

--- a/BathyScapheDataConverter/BSDCAppDelegate.m
+++ b/BathyScapheDataConverter/BSDCAppDelegate.m
@@ -17,6 +17,7 @@
1717 #import "BSBoardInformationObject.h"
1818 #import "BSThreadInformationObject.h"
1919 #import "BSFavoriteObject.h"
20+#import "BSBoardHistoryObject.h"
2021
2122
2223 @implementation BSDCAppDelegate
@@ -174,6 +175,30 @@
174175 }
175176 }
176177
178+- (void)convertFavorites:(BSCoreDataManager *)cdm
179+{
180+ panel.message = @"Converting Favorites ...";
181+ DatabaseManager *dm = [DatabaseManager defaultManager];
182+ NSArray *favs = [cdm fetchDataForEntityName:@"Favorite"
183+ predicate:nil];
184+ for(BSFavoriteObject *fav in favs) {
185+ [self updateTime];
186+// NSLog(@"%@", fav.thread.board.boardName);
187+ NSUInteger boardID = [dm boardIDForURLString:fav.thread.board.boardURL];
188+ SQLiteReservedQuery *query = [self sqlForInsertFav];
189+ [query cursorWithFormat:F_Int F_NSNumberOfInt,
190+ boardID, fav.thread.threadID];
191+ }
192+}
193+
194+- (void)loggingIfNeeded
195+{
196+ SQLiteDB *db = [[DatabaseManager defaultManager]databaseForCurrentThread];
197+ if([db lastErrorID] != SQLITE_OK) {
198+ NSLog(@"%@", [db lastError]);
199+ }
200+}
201+
177202 - (void)doConvertToSQLite
178203 {
179204 self.startTime = [NSDate dateWithTimeIntervalSinceNow:0.0];
@@ -198,10 +223,31 @@
198223 [pool release];
199224 [self updateTime];
200225
226+ pool = [[NSAutoreleasePool alloc] init];
201227 panel.message = @"Converting board histories ...";
202- //
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];
203245
246+ panel.amount = 0;
247+ panel.count = 0;
248+ [pool release];
204249 [self updateTime];
250+
205251 pool = [[NSAutoreleasePool alloc] init];
206252 [self convertThreadsInBoards:boards];
207253 panel.amount = 0;
@@ -210,21 +256,12 @@
210256 [self updateTime];
211257
212258 pool = [[NSAutoreleasePool alloc] init];
213- panel.message = @"Converting Favorites ...";
214- // Fav
215- DatabaseManager *dm = [DatabaseManager defaultManager];
216- NSArray *favs = [cdm fetchDataForEntityName:@"Favorite"
217- predicate:nil];
218- for(BSFavoriteObject *fav in favs) {
219-// NSLog(@"%@", fav.thread.board.boardName);
220- NSUInteger boardID = [dm boardIDForURLString:fav.thread.board.boardURL];
221- SQLiteReservedQuery *query = [self sqlForInsertFav];
222- [query cursorWithFormat:F_Int F_NSNumberOfInt,
223- boardID, fav.thread.threadID];
224- }
259+ [self convertFavorites:cdm];
260+ panel.amount = 0;
261+ panel.count = 0;
262+ [pool release];
225263
226264 finish:
227- [pool release];
228265 [NSApp endModalSession:session];
229266 [panel.window close];
230267 [panel release];