OSDN Git Service

Alter import logic to create a new, unique GUID for each note. Prior to this it assum...
authorRandy Baumgarte <randy@fbn.cx>
Tue, 17 Aug 2010 18:30:19 +0000 (14:30 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 22 Aug 2010 22:47:37 +0000 (18:47 -0400)
src/cx/fbn/nevernote/xml/ImportData.java

index 8a028d6..e85e492 100644 (file)
@@ -22,6 +22,7 @@ package cx.fbn.nevernote.xml;
 import java.util.ArrayList;\r
 import java.util.HashMap;\r
 import java.util.List;\r
+import java.util.Random;\r
 \r
 import com.evernote.edam.type.Data;\r
 import com.evernote.edam.type.Note;\r
@@ -181,6 +182,14 @@ public class ImportData {
                        if (reader.isStartElement()) {\r
                                if (reader.name().equalsIgnoreCase("Guid")) \r
                                        note.setGuid(textValue());\r
+                               if (!backup) {\r
+                                       Random random1 = new Random();\r
+                                       String newGuid = "IMP" +new Integer(random1.nextInt(1000)).toString();\r
+                                       newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();\r
+                                       newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();\r
+                                       newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();\r
+                                       note.setGuid(newGuid);\r
+                               }\r
                                if (reader.name().equalsIgnoreCase("UpdateSequenceNumber")) \r
                                        note.setUpdateSequenceNum(intValue());\r
                                if (reader.name().equalsIgnoreCase("Title")) \r
@@ -226,6 +235,14 @@ public class ImportData {
                        if (reader.isStartElement()) {\r
                                if (reader.name().equalsIgnoreCase("Guid")) \r
                                        resource.setGuid(textValue());\r
+                               if (!backup) {\r
+                                       Random random1 = new Random();\r
+                                       String newGuid = "IMP" +new Integer(random1.nextInt(1000)).toString();\r
+                                       newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();\r
+                                       newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();\r
+                                       newGuid = newGuid+"-"+new Integer(random1.nextInt(1000)).toString();\r
+                                       resource.setGuid(newGuid);\r
+                               }\r
                                if (reader.name().equalsIgnoreCase("NoteGuid")) \r
                                        resource.setNoteGuid(textValue());\r
                                if (reader.name().equalsIgnoreCase("UpdateSequenceNumber")) \r