Package cx.fbn.nevernote.sql.driver

Examples of cx.fbn.nevernote.sql.driver.NSqlQuery


   
  }
  // Given a notebook, what tags are valid for it?
  public void deleteLinkedTags(String guid) {
   
        NSqlQuery query = new NSqlQuery(db.getConnection());              
    query.prepare("select distinct tagguid from noteTags " +
        "where noteGuid in " +
        "(SELECT guid from note where notebookguid=:guid)");
    query.bindValue(":guid", guid);
    boolean check = query.exec();
    if (!check)
      logger.log(logger.EXTREME, "Notebook SQL getValidLinedTags failed.");
    while(query.next()) {
      db.getTagTable().expungeTag(query.valueString(0), false);
    }
   
   
    query.prepare("delete from note " +
        "where notebookguid=:guid");
    query.bindValue(":guid", guid);
    check = query.exec();
    if (!check)
      logger.log(logger.EXTREME, "Notebook SQL getValidLinedTags failed.");

   
    return;
View Full Code Here


  }
 
  // Given a notebook, what tags are valid for it?
  public void convertFromSharedNotebook(String guid, boolean local) {
   
        NSqlQuery query = new NSqlQuery(db.getConnection())
       
        query.prepare("Update Notebook set sequence=0, published=false, isdirty=true, local=:local, publishinguri=''"
        +" where guid=:guid");
    query.bindValue(":guid", guid);
    if (local)
      query.bindValue(":local", true);
    else
      query.bindValue(":local", false);
   
    if (!query.exec())
      logger.log(logger.EXTREME, "NotebookTable.convertToLocalNotebook error.");
   
        query.prepare("Update Note set updatesequencenumber=0, isdirty=true"
        +" where notebookguid=:guid");
    query.bindValue(":guid", guid);
    if (!query.exec())
      logger.log(logger.EXTREME, "NotebookTable.convertToLocalNotebook #2 error.");
     
    return;
   
   
View Full Code Here

    logger = l;
    db = d;
  }
  // Create the table
  public void createTable() {
    NSqlQuery query = new NSqlQuery(db.getConnection());
    logger.log(logger.HIGH, "Creating table DeletedItems...");
        if (!query.exec("Create table DeletedItems (guid varchar primary key, type varchar)"))
             logger.log(logger.HIGH, "Table DeletedItems creation FAILED!!!");
  }
View Full Code Here

        if (!query.exec("Create table DeletedItems (guid varchar primary key, type varchar)"))
             logger.log(logger.HIGH, "Table DeletedItems creation FAILED!!!");
  }
  // Drop the table
  public void dropTable() {
    NSqlQuery query = new NSqlQuery(db.getConnection());
    query.exec("Drop table DeletedItems");
  }
View Full Code Here

  }
  // Add an item to the deleted table
  public void addDeletedItem(String guid, String type) {
    if (exists(guid,type))
      return;
        NSqlQuery query = new NSqlQuery(db.getConnection());
    query.prepare("Insert Into DeletedItems (guid, type) Values(:guid, :type)");
    query.bindValue(":guid", guid);
    query.bindValue(":type", type);
    if (!query.exec()) {
      logger.log(logger.MEDIUM, "Insert into deleted items failed.");
      logger.log(logger.MEDIUM, query.lastError());
    }
  }
View Full Code Here

      logger.log(logger.MEDIUM, query.lastError());
    }
  }
  // Check if a record exists
  public boolean exists(String guid, String type) {
        NSqlQuery query = new NSqlQuery(db.getConnection());
    query.prepare("Select guid, type from DeletedItems where guid=:guid and type=:type");
    query.bindValue(":guid", guid);
    query.bindValue(":type", type);
    query.exec();
    if (!query.next()) {
      return false;
    }
    return true;
  }
View Full Code Here

    }
    return true;
  }
  // Add an item to the deleted table
  public void expungeDeletedItem(String guid, String type) {
        NSqlQuery query = new NSqlQuery(db.getConnection());
    query.prepare("delete from DeletedItems where guid=:guid and type=:type");
    query.bindValue(":guid", guid);
    query.bindValue(":type", type);
    if (!query.exec()) {
      logger.log(logger.LOW, "Expunge deleted items failed.");
      logger.log(logger.LOW, query.lastError());
    }
  }
View Full Code Here

  public List <Notebook> getDirty() {
    Notebook tempNotebook;
    List<Notebook> index = new ArrayList<Notebook>();
    boolean check;
           
        NSqlQuery query = new NSqlQuery(db.getConnection());
               
    check = query.exec("Select guid, sequence, name, defaultNotebook, " +
        "serviceCreated, serviceUpdated, published, stack, "+
        "publishinguri, publishingascending, publishingPublicDescription, "+
        "publishingOrder " +
        "from "+dbName+" where isDirty=true and local=false and linked=false");
    if (!check)
      logger.log(logger.EXTREME, dbName+" SQL retrieve has failed.");
    while (query.next()) {
      tempNotebook = new Notebook();
      tempNotebook.setGuid(query.valueString(0));
      int sequence = new Integer(query.valueString(1)).intValue();
      tempNotebook.setUpdateSequenceNum(sequence);
      tempNotebook.setName(query.valueString(2));
     
      DateFormat indfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
      try {
        tempNotebook.setServiceCreated(indfm.parse(query.valueString(4)).getTime());
        tempNotebook.setServiceUpdated(indfm.parse(query.valueString(5)).getTime());
      } catch (ParseException e) {
        e.printStackTrace();
      }
      tempNotebook.setPublished(new Boolean(query.valueString(6)));
      if (query.valueString(7) != null && !query.valueString(7).trim().equals(""))
        tempNotebook.setStack(query.valueString(7));
     
      if (tempNotebook.isPublished()) {
        Publishing p = new Publishing();
        p.setUri(query.valueString(8));
        p.setAscending(query.valueBoolean(9, false));
        p.setPublicDescription(query.valueString(10));
        p.setOrder(NoteSortOrder.findByValue(query.valueInteger(11)));
        if (p.getPublicDescription() != null && p.getPublicDescription().trim().equalsIgnoreCase(""))
          p.setPublicDescription(null);
        tempNotebook.setPublishing(p);
      }
     
View Full Code Here

  // Get a list of notes that need to be updated
  public Notebook getNotebook(String guid) {
    Notebook tempNotebook;
    boolean check;
           
        NSqlQuery query = new NSqlQuery(db.getConnection());
               
    query.prepare("Select guid, sequence, name, defaultNotebook, " +
        "serviceCreated, serviceUpdated, published, stack, "+
        "publishinguri, publishingascending, publishingPublicDescription, "+
        "publishingOrder " +
        "from "+dbName+" where guid=:guid");
    query.bindValue(":guid", guid);
    check  = query.exec();
    if (!check)
      logger.log(logger.EXTREME, dbName+" SQL retrieve has failed.");
    while (query.next()) {
      tempNotebook = new Notebook();
      tempNotebook.setGuid(query.valueString(0));
      int sequence = new Integer(query.valueString(1)).intValue();
      tempNotebook.setUpdateSequenceNum(sequence);
      tempNotebook.setName(query.valueString(2));
     
      DateFormat indfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
      try {
        tempNotebook.setServiceCreated(indfm.parse(query.valueString(4)).getTime());
        tempNotebook.setServiceUpdated(indfm.parse(query.valueString(5)).getTime());
      } catch (ParseException e) {
        e.printStackTrace();
      }
      tempNotebook.setPublished(new Boolean(query.valueString(6)));
      if (query.valueString(7) != null && !query.valueString(7).trim().equals(""))
        tempNotebook.setStack(query.valueString(7));
     
      if (tempNotebook.isPublished()) {
        Publishing p = new Publishing();
        p.setUri(query.valueString(8));
        p.setAscending(query.valueBoolean(9, false));
        p.setPublicDescription(query.valueString(10));
        p.setOrder(NoteSortOrder.findByValue(query.valueInteger(11)));
        if (p.getPublicDescription() != null && p.getPublicDescription().trim().equalsIgnoreCase(""))
          p.setPublicDescription(null);
        tempNotebook.setPublishing(p);
      }
     
View Full Code Here

    updateNotebook(notebook, isDirty);
  }
  // does a record exist?
  private boolean exists(String guid) {
    
    NSqlQuery query = new NSqlQuery(db.getConnection());
   
    query.prepare("Select guid from "+dbName+" where guid=:guid");
    query.bindValue(":guid", guid);
    if (!query.exec())
      logger.log(logger.EXTREME, dbName+" SQL retrieve has failed.");
    boolean retval = query.next();
    return retval;
  }
View Full Code Here

TOP

Related Classes of cx.fbn.nevernote.sql.driver.NSqlQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.