OSDN Git Service

Correct problem where resources were not kept when importing a note from a NixNote...
authorRandy Baumgarte <randy@fbn.cx>
Wed, 21 Dec 2011 12:56:57 +0000 (07:56 -0500)
committerRandy Baumgarte <randy@fbn.cx>
Wed, 21 Dec 2011 12:56:57 +0000 (07:56 -0500)
src/cx/fbn/nevernote/xml/ImportData.java

index 9e95bab..99d5393 100644 (file)
@@ -143,8 +143,6 @@ public class ImportData {
                                processSynchronizationNode();\r
                                conn.getSyncTable().setLastSequenceDate(lastSequenceDate);\r
                        conn.getSyncTable().setUpdateSequenceNumber(highUpdateSequenceNumber);\r
-//                             Global.setSequenceDate(lastSequenceDate);\r
-//                     Global.setUpdateSequenceNumber(highUpdateSequenceNumber);\r
                        }\r
                        if (reader.name().equalsIgnoreCase("note") && reader.isStartElement()) {\r
                                processNoteNode();\r
@@ -233,11 +231,11 @@ public class ImportData {
                                        note.setDeleted(longValue());\r
                                if (reader.name().equalsIgnoreCase("Active")) \r
                                        note.setActive(booleanValue());\r
-                               if (reader.name().equalsIgnoreCase("NotebookGuid") && (backup || importNotebooks)\r
+                               if (reader.name().equalsIgnoreCase("NotebookGuid")) \r
                                        note.setNotebookGuid(textValue());\r
                                if (reader.name().equalsIgnoreCase("Content")) \r
                                        note.setContent(textValue());\r
-                               if (reader.name().equalsIgnoreCase("NoteTags") && (backup || importTags)\r
+                               if (reader.name().equalsIgnoreCase("NoteTags")) \r
                                        note.setTagGuids(processNoteTagList());\r
                                if (reader.name().equalsIgnoreCase("NoteAttributes")) \r
                                        note.setAttributes(processNoteAttributes());\r
@@ -280,8 +278,11 @@ public class ImportData {
                                        newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();\r
                                        resource.setGuid(newGuid);\r
                                }\r
-                               if (reader.name().equalsIgnoreCase("NoteGuid")) \r
-                                       resource.setNoteGuid(noteMap.get(textValue()));\r
+                               if (reader.name().equalsIgnoreCase("NoteGuid")) {\r
+                                       String tx = textValue();\r
+                                       resource.setNoteGuid(noteMap.get(textValue()));  \r
+                                       resource.setNoteGuid(noteMap.get(tx));\r
+                               }\r
                                if (reader.name().equalsIgnoreCase("UpdateSequenceNumber")) \r
                                        resource.setUpdateSequenceNum(intValue());\r
                                if (reader.name().equalsIgnoreCase("Active")) \r
@@ -558,59 +559,61 @@ public class ImportData {
                notebookIcon = null;\r
                boolean atEnd = false;\r
                while(!atEnd) {\r
-                       if (reader.isStartElement()) {\r
-                               if (reader.name().equalsIgnoreCase("Guid")) \r
-                                       notebook.setGuid(textValue());\r
-                               if (reader.name().equalsIgnoreCase("Name")) \r
-                                       notebook.setName(textValue());\r
-                               if (reader.name().equalsIgnoreCase("UpdateSequenceNumber")) \r
-                                       notebook.setUpdateSequenceNum(intValue());\r
-                               if (reader.name().equalsIgnoreCase("ServiceCreated")) \r
-                                       notebook.setServiceCreated(longValue());\r
-                               if (reader.name().equalsIgnoreCase("ServiceUpdated")) \r
-                                       notebook.setServiceUpdated(longValue());\r
-                               if (reader.name().equalsIgnoreCase("DefaultNotebook")) {\r
-                                       notebook.setDefaultNotebook(booleanValue());\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("Dirty")) {\r
-                                       if (booleanValue())\r
-                                               notebookIsDirty = true;\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("LocalNotebook")) {\r
-                                       if (booleanValue())\r
-                                               notebookIsLocal = true;\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("ReadOnly")) {\r
-                                       if (booleanValue())\r
-                                               notebookIsReadOnly = true;\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("PublishingPublicDescription")) {\r
-                                       notebook.getPublishing().setPublicDescription(textValue());\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("PublishingUri")) {\r
-                                       notebook.getPublishing().setUri(textValue());\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("PublishingOrder")) {\r
-                                       notebook.getPublishing().setOrder(NoteSortOrder.findByValue(intValue()));\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("ReadOnly")) {\r
-                                       if (booleanValue())\r
-                                               notebookIsReadOnly = true;\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("PublishingAscending")) {\r
-                                       if (booleanValue())\r
-                                               notebook.getPublishing().setAscending(true);\r
-                                       else\r
-                                               notebook.getPublishing().setAscending(false);\r
-                               }               \r
-                               if (reader.name().equalsIgnoreCase("Icon")) {\r
-                                       byte[] b = textValue().getBytes();   // data binary\r
-                                       QByteArray hexData = new QByteArray(b);\r
-                                       QByteArray binData = new QByteArray(QByteArray.fromHex(hexData));\r
-                                       notebookIcon = new QIcon(QPixmap.fromImage(QImage.fromData(binData)));\r
+                       if (backup || importNotebooks) {\r
+                               if (reader.isStartElement()) {\r
+                                       if (reader.name().equalsIgnoreCase("Guid")) \r
+                                               notebook.setGuid(textValue());\r
+                                       if (reader.name().equalsIgnoreCase("Name")) \r
+                                               notebook.setName(textValue());\r
+                                       if (reader.name().equalsIgnoreCase("UpdateSequenceNumber")) \r
+                                               notebook.setUpdateSequenceNum(intValue());\r
+                                       if (reader.name().equalsIgnoreCase("ServiceCreated")) \r
+                                               notebook.setServiceCreated(longValue());\r
+                                       if (reader.name().equalsIgnoreCase("ServiceUpdated")) \r
+                                               notebook.setServiceUpdated(longValue());\r
+                                       if (reader.name().equalsIgnoreCase("DefaultNotebook")) {\r
+                                               notebook.setDefaultNotebook(booleanValue());\r
+                                       }\r
+                                       if (reader.name().equalsIgnoreCase("Dirty")) {\r
+                                               if (booleanValue())\r
+                                                       notebookIsDirty = true;\r
+                                       }\r
+                                       if (reader.name().equalsIgnoreCase("LocalNotebook")) {\r
+                                               if (booleanValue())\r
+                                                       notebookIsLocal = true;\r
+                                       }\r
+                                       if (reader.name().equalsIgnoreCase("ReadOnly")) {\r
+                                               if (booleanValue())\r
+                                                       notebookIsReadOnly = true;\r
+                                       }\r
+                                       if (reader.name().equalsIgnoreCase("PublishingPublicDescription")) {\r
+                                               notebook.getPublishing().setPublicDescription(textValue());\r
+                                       }\r
+                                       if (reader.name().equalsIgnoreCase("PublishingUri")) {\r
+                                               notebook.getPublishing().setUri(textValue());\r
+                                       }\r
+                                       if (reader.name().equalsIgnoreCase("PublishingOrder")) {\r
+                                               notebook.getPublishing().setOrder(NoteSortOrder.findByValue(intValue()));\r
+                                       }\r
+                                       if (reader.name().equalsIgnoreCase("ReadOnly")) {\r
+                                               if (booleanValue())\r
+                                                       notebookIsReadOnly = true;\r
+                                       }\r
+                                       if (reader.name().equalsIgnoreCase("PublishingAscending")) {\r
+                                               if (booleanValue())\r
+                                                       notebook.getPublishing().setAscending(true);\r
+                                               else\r
+                                                       notebook.getPublishing().setAscending(false);\r
+                                       }               \r
+                                       if (reader.name().equalsIgnoreCase("Icon")) {\r
+                                               byte[] b = textValue().getBytes();   // data binary\r
+                                               QByteArray hexData = new QByteArray(b);\r
+                                               QByteArray binData = new QByteArray(QByteArray.fromHex(hexData));\r
+                                               notebookIcon = new QIcon(QPixmap.fromImage(QImage.fromData(binData)));\r
+                                       }\r
+                                       if (reader.name().equalsIgnoreCase("Stack"))\r
+                                               notebook.setStack(textValue());\r
                                }\r
-                               if (reader.name().equalsIgnoreCase("Stack"))\r
-                                       notebook.setStack(textValue());\r
                        }\r
                        reader.readNext();\r
                        if (reader.name().equalsIgnoreCase("notebook") && reader.isEndElement())\r
@@ -626,18 +629,20 @@ public class ImportData {
                tagIsDirty = false;\r
                boolean atEnd = false;\r
                while(!atEnd) {\r
-                       if (reader.isStartElement()) {                  \r
-                               if (reader.name().equalsIgnoreCase("Guid")) \r
-                                       tag.setGuid(textValue());\r
-                               if (reader.name().equalsIgnoreCase("Name")) \r
-                                       tag.setName(textValue());\r
-                               if (reader.name().equalsIgnoreCase("UpdateSequenceNumber")) \r
-                                       tag.setUpdateSequenceNum(intValue());\r
-                               if (reader.name().equalsIgnoreCase("ParentGuid")) \r
-                                       tag.setParentGuid(textValue());\r
-                               if (reader.name().equalsIgnoreCase("Dirty")) {\r
-                                       if (booleanValue())\r
-                                               tagIsDirty = true;\r
+                       if (backup || importTags) {\r
+                               if (reader.isStartElement()) {                  \r
+                                       if (reader.name().equalsIgnoreCase("Guid")) \r
+                                               tag.setGuid(textValue());\r
+                                       if (reader.name().equalsIgnoreCase("Name")) \r
+                                               tag.setName(textValue());\r
+                                       if (reader.name().equalsIgnoreCase("UpdateSequenceNumber")) \r
+                                               tag.setUpdateSequenceNum(intValue());\r
+                                       if (reader.name().equalsIgnoreCase("ParentGuid")) \r
+                                               tag.setParentGuid(textValue());\r
+                                       if (reader.name().equalsIgnoreCase("Dirty")) {\r
+                                               if (booleanValue())\r
+                                                       tagIsDirty = true;\r
+                                       }\r
                                }\r
                        }\r
                        reader.readNext();\r