// Save an individual notebook
public void addNotebook(SharedNotebook tempNotebook, boolean isDirty) {
boolean check;
SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
NSqlQuery query = new NSqlQuery(db.getConnection());
check = query.prepare("Insert Into SharedNotebook (id, userid, notebookGuid, email, "
+"notebookModifiable, requireLogin, serviceCreated, shareKey, username, isDirty) "
+ " Values("
+":id, :userid, :notebookGuid, :email, "
+":notebookModifiable, :requireLogin, :serviceCreated, "
+":shareKey, :username, :isDirty)");
query.bindValue(":id", tempNotebook.getId());
query.bindValue(":userid", tempNotebook.getUserId());
query.bindValue(":notebookGuid", tempNotebook.getNotebookGuid());
query.bindValue(":email", tempNotebook.getEmail());
query.bindValue(":notebookModifiable", tempNotebook.isNotebookModifiable());
query.bindValue(":requireLogin", tempNotebook.isRequireLogin());
StringBuilder serviceCreated = new StringBuilder(simple.format(tempNotebook.getServiceCreated()));
query.bindValue(":serviceCreated", serviceCreated.toString());
query.bindValue(":shareKey", tempNotebook.getShareKey());
query.bindValue(":username", tempNotebook.getUsername());
if (isDirty)
query.bindValue(":isDirty", true);
else
query.bindValue(":isDirty", false);
check = query.exec();
if (!check) {
logger.log(logger.MEDIUM, "SharedNotebook Table insert failed.");
logger.log(logger.MEDIUM, query.lastError().toString());
}
}