OSDN Git Service

Add selective sync, cleanup debug messages, & correct network sync not disconnecting...
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / sql / NoteTable.java
index 446d1a6..97c0b15 100644 (file)
@@ -975,6 +975,60 @@ public class NoteTable {
                return note.replace("<div/>", "<div>&nbsp;</div>");\r
        }\r
        \r
+       // Expunge notes that we don't want to synchronize\r
+       public List<String> expungeIgnoreSynchronizedNotes(List<String> notebooks, List<String>tags) {\r
+               \r
+               List<String> noteGuids = new ArrayList<String>();\r
+               for (int i=0; i<notebooks.size(); i++) {\r
+                       List<String> notes = findNotesByNotebook(notebooks.get(i));\r
+                       for (int j=0; j<notes.size(); j++) {\r
+                               if (!isNoteDirty(notes.get(j))) {\r
+                                       expungeNote(notes.get(j), true, false);\r
+                                       noteGuids.add(notes.get(j));\r
+                               }\r
+                       }\r
+               }\r
+               \r
+               for (int i=0; i<tags.size(); i++) {\r
+                       List<String> notes = findNotesByTag(tags.get(i));\r
+                       for (int j=0; j<notes.size(); j++) {\r
+                               if (!isNoteDirty(notes.get(j))) {\r
+                                       expungeNote(notes.get(j), true, false);\r
+                                       noteGuids.add(notes.get(j));\r
+                               }\r
+                       }\r
+               }\r
+               return noteGuids;\r
+       }\r
+       \r
+       // Find a note by its notebook\r
+       // Expunge notes that we don't want to synchronize\r
+       public List<String> findNotesByNotebook(String notebook) {\r
+               List<String> values = new ArrayList<String>();\r
+               NSqlQuery query = new NSqlQuery(db.getConnection());\r
+               query.prepare("Select guid from note where notebookguid=:notebook");\r
+\r
+               query.bindValue(":notebook", notebook);\r
+               query.exec();\r
+               while (query.next()) {\r
+                       values.add(query.valueString(0));\r
+               }\r
+               return values;\r
+       }\r
+       \r
+       public List<String> findNotesByTag(String tag) {\r
+               List<String> values = new ArrayList<String>();\r
+               NSqlQuery query = new NSqlQuery(db.getConnection());\r
+               query.prepare("Select distinct noteguid from notetags where tagguid=:tag");\r
+\r
+               query.bindValue(":tag", tag);\r
+               query.exec();\r
+               while (query.next()) {\r
+                       values.add(query.valueString(0));\r
+               }\r
+               return values;\r
+       }\r
+       \r
        \r
        \r
        //********************************************************************************\r