OSDN Git Service

Beginning logic framework to import notebooks & tags when importing notes.
authorRandy Baumgarte <randy@fbn.cx>
Sun, 10 Oct 2010 13:57:37 +0000 (09:57 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 10 Oct 2010 14:04:41 +0000 (10:04 -0400)
src/cx/fbn/nevernote/xml/ImportData.java

index e85e492..15f3e90 100644 (file)
@@ -63,6 +63,8 @@ public class ImportData {
        private final ApplicationLogger         logger;\r
        private final boolean                           backup;\r
        private String                                          notebookGuid;\r
        private final ApplicationLogger         logger;\r
        private final boolean                           backup;\r
        private String                                          notebookGuid;\r
+       public final boolean                            importTags = false;\r
+       public final boolean                            importNotebooks = false;\r
        \r
        public ImportData(DatabaseConnection c, boolean full) {\r
                logger = new ApplicationLogger("import.log");\r
        \r
        public ImportData(DatabaseConnection c, boolean full) {\r
                logger = new ApplicationLogger("import.log");\r
@@ -142,7 +144,7 @@ public class ImportData {
                                if (titleColors.containsKey(note.getGuid())) \r
                                        conn.getNoteTable().setNoteTitleColor(note.getGuid(), titleColors.get(note.getGuid()));\r
                        }\r
                                if (titleColors.containsKey(note.getGuid())) \r
                                        conn.getNoteTable().setNoteTitleColor(note.getGuid(), titleColors.get(note.getGuid()));\r
                        }\r
-                       if (reader.name().equalsIgnoreCase("notebook") && reader.isStartElement() && backup) {\r
+                       if (reader.name().equalsIgnoreCase("notebook") && reader.isStartElement() && (backup || importNotebooks)) {\r
                                processNotebookNode();\r
                        String existingGuid = conn.getNotebookTable().findNotebookByName(notebook.getName());\r
                        if (existingGuid == null)\r
                                processNotebookNode();\r
                        String existingGuid = conn.getNotebookTable().findNotebookByName(notebook.getName());\r
                        if (existingGuid == null)\r
@@ -154,7 +156,7 @@ public class ImportData {
                        }\r
 \r
                        }\r
                        }\r
 \r
                        }\r
-                       if (reader.name().equalsIgnoreCase("tag") && reader.isStartElement() && backup) {\r
+                       if (reader.name().equalsIgnoreCase("tag") && reader.isStartElement() && (backup || importTags)) {\r
                                processTagNode();\r
                                String testGuid = conn.getTagTable().findTagByName(tag.getName());\r
                        if (testGuid == null)\r
                                processTagNode();\r
                                String testGuid = conn.getTagTable().findTagByName(tag.getName());\r
                        if (testGuid == null)\r
@@ -202,11 +204,11 @@ public class ImportData {
                                        note.setDeleted(longValue());\r
                                if (reader.name().equalsIgnoreCase("Active")) \r
                                        note.setActive(booleanValue());\r
                                        note.setDeleted(longValue());\r
                                if (reader.name().equalsIgnoreCase("Active")) \r
                                        note.setActive(booleanValue());\r
-                               if (reader.name().equalsIgnoreCase("NotebookGuid") && backup\r
+                               if (reader.name().equalsIgnoreCase("NotebookGuid") && (backup || importNotebooks)\r
                                        note.setNotebookGuid(textValue());\r
                                if (reader.name().equalsIgnoreCase("Content")) \r
                                        note.setContent(textValue());\r
                                        note.setNotebookGuid(textValue());\r
                                if (reader.name().equalsIgnoreCase("Content")) \r
                                        note.setContent(textValue());\r
-                               if (reader.name().equalsIgnoreCase("NoteTags") && backup\r
+                               if (reader.name().equalsIgnoreCase("NoteTags") && (backup || importTags)\r
                                        note.setTagGuids(processNoteTagList());\r
                                if (reader.name().equalsIgnoreCase("NoteAttributes")) \r
                                        note.setAttributes(processNoteAttributes());\r
                                        note.setTagGuids(processNoteTagList());\r
                                if (reader.name().equalsIgnoreCase("NoteAttributes")) \r
                                        note.setAttributes(processNoteAttributes());\r