OSDN Git Service

Cleanup of initial sync with ink notes and added the ability to highlight words in...
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / sql / DatabaseConnection.java
index 2c32abd..807282b 100644 (file)
@@ -40,7 +40,11 @@ public class DatabaseConnection {
        private SavedSearchTable                        searchTable;
        private WatchFolderTable                        watchFolderTable;
        private InvalidXMLTable                         invalidXMLTable;
+       private LinkedNotebookTable                     linkedNotebookTable;
+       private SharedNotebookTable                     sharedNotebookTable;
+       private InkImagesTable                          inkImagesTable;
        private SyncTable                                       syncTable;
+       private SystemIconTable                         systemIconTable;
        private final ApplicationLogger         logger;
        private Connection                                      conn;
        int id;
@@ -61,6 +65,10 @@ public class DatabaseConnection {
                invalidXMLTable = new InvalidXMLTable(logger, this);
                wordsTable = new WordsTable(logger, this);
                syncTable = new SyncTable(logger, this);
+               linkedNotebookTable = new LinkedNotebookTable(logger, this);
+               sharedNotebookTable = new SharedNotebookTable(logger, this);
+               systemIconTable = new SystemIconTable(logger, this);
+               inkImagesTable = new InkImagesTable(logger, this);
        }
        
        
@@ -135,6 +143,41 @@ public class DatabaseConnection {
                        version = "0.86";
                        Global.setDatabaseVersion(version);
                } 
+               if (version.equals("0.86")) {
+       
+                       executeSql("alter table notebook add column publishingUri VarChar");
+                       executeSql("alter table notebook add column publishingOrder Integer");
+                       executeSql("alter table notebook add column publishingAscending Boolean");
+                       executeSql("alter table notebook add column publishingPublicDescription varchar");
+                       executeSql("alter table notebook add column stack varchar");
+                       executeSql("alter table notebook add column icon blob");
+                       executeSql("alter table notebook add column readOnly boolean");
+                       executeSql("alter table tag add column icon blob");
+                       executeSql("alter table SavedSearch add column icon blob");
+
+                       executeSql("create index NOTE_THUMBNAIL_INDEX on note (thumbnailneeded, guid);");
+                       executeSql("create index NOTE_EXPUNGED_INDEX on note (isExpunged, guid);");
+                       executeSql("create index NOTE_DUEDATE_INDEX on note (attributeSubjectDate, guid);");
+                       executeSql("create index RESOURCES_GUID_INDEX on noteresources (noteGuid, guid);");
+                       executeSql("update note set thumbnailneeded=true, thumbnail=null;");
+                       executeSql("update notebook set publishingUri='', " +
+                                       "publishingAscending=false, stack='', readonly=false, publishingOrder=1, " +
+                                       "publishingPublicDescription=''");
+                       
+                       sharedNotebookTable.createTable();
+                       linkedNotebookTable.createTable();
+                       systemIconTable.createTable();
+                       inkImagesTable.createTable();
+                       
+                       version = "0.95";
+                       executeSql("Insert into Sync (key, value) values ('FullNotebookSync', 'true')");
+                       executeSql("Insert into Sync (key, value) values ('FullLinkedNotebookSync', 'true')");
+                       executeSql("Insert into Sync (key, value) values ('FullSharedNotebookSync', 'true')");
+                       executeSql("Insert into Sync (key, value) values ('FullInkNoteImageSync', 'true')");
+                       executeSql("Update note set indexneeded='true'");
+                       executeSql("Update noteresources set indexneeded='true'");
+                       Global.setDatabaseVersion(version);
+               } 
        }
        
        public void executeSql(String sql) {
@@ -146,6 +189,9 @@ public class DatabaseConnection {
                if (!Global.getDatabaseVersion().equals("0.86")) {
                        upgradeDb(Global.getDatabaseVersion());
                }
+               if (!Global.getDatabaseVersion().equals("0.95")) {
+                       upgradeDb(Global.getDatabaseVersion());
+               }
        }
        
 
@@ -161,7 +207,7 @@ public class DatabaseConnection {
                Global.saveUploadAmount(0);
                
                getTagTable().createTable();
-               notebookTable.createTable();
+               notebookTable.createTable(true);
                noteTable.createTable();
                deletedTable.createTable();             
                searchTable.createTable();
@@ -169,7 +215,6 @@ public class DatabaseConnection {
                invalidXMLTable.createTable();
                wordsTable.createTable();
                syncTable.createTable();
-               
        }
        
        public Connection getConnection() {
@@ -206,4 +251,16 @@ public class DatabaseConnection {
        public SyncTable getSyncTable() {
                return syncTable;
        }
+       public LinkedNotebookTable getLinkedNotebookTable() {
+               return linkedNotebookTable;
+       }
+       public SharedNotebookTable getSharedNotebookTable() {
+               return sharedNotebookTable;
+       }
+       public SystemIconTable getSystemIconTable() {
+               return systemIconTable;
+       }
+       public InkImagesTable getInkImagesTable() {
+               return inkImagesTable;
+       }
 }