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
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
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
}\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
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
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
- 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
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