Package cx.fbn.nevernote.sql.driver

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


    }
    boolean returnValue = query.valueBoolean(0, false);
    return returnValue;
  }
  public boolean isReadOnly(String guid) {
        NSqlQuery query = new NSqlQuery(db.getConnection());
   
    query.prepare("Select readOnly from "+dbName+" where guid=:guid and readOnly=true");
    query.bindValue(":guid", guid);
    query.exec();
    if (!query.next()) {
      return false;
    }
    boolean returnValue = query.valueBoolean(0, false);
    return returnValue;
  }
View Full Code Here


    return returnValue;
  }
  // Update a notebook sequence number
  public void updateNotebookSequence(String guid, int sequence) {
    boolean check;
        NSqlQuery query = new NSqlQuery(db.getConnection());
    check = query.prepare("Update "+dbName+" set sequence=:sequence where guid=:guid");
    query.bindValue(":guid", guid);
    query.bindValue(":sequence", sequence);
    query.exec();
    if (!check) {
      logger.log(logger.MEDIUM, dbName+" sequence update failed.");
      logger.log(logger.MEDIUM, query.lastError());
    }
  }
View Full Code Here

      logger.log(logger.MEDIUM, query.lastError());
    }
  }
  // Update a notebook GUID number
  public void updateNotebookGuid(String oldGuid, String newGuid) {
        NSqlQuery query = new NSqlQuery(db.getConnection());
    query.prepare("Update "+dbName+" set guid=:newGuid where guid=:oldGuid");
    query.bindValue(":oldGuid", oldGuid);
    query.bindValue(":newGuid", newGuid);
    if (!query.exec()) {
      logger.log(logger.MEDIUM, dbName+" guid update failed.");
      logger.log(logger.MEDIUM, query.lastError());
    }
    
    // Update any notes containing the notebook guid
    query.prepare("Update Note set notebookGuid=:newGuid where notebookGuid=:oldGuid");
    query.bindValue(":oldGuid", oldGuid);
    query.bindValue(":newGuid", newGuid);
    if (!query.exec()) {
      logger.log(logger.MEDIUM, dbName+" guid update for note failed.");
      logger.log(logger.MEDIUM, query.lastError());
    }
   
    // Update any watch folders with the new guid
    query = new NSqlQuery(db.getConnection());
    query.prepare("Update WatchFolders set notebook=:newGuid where notebook=:oldGuid");
    query.bindValue(":oldGuid", oldGuid);
    query.bindValue(":newGuid", newGuid);
    if (!query.exec()) {
      logger.log(logger.MEDIUM, "Update WatchFolder notebook failed.");
      logger.log(logger.MEDIUM, query.lastError().toString());
    }
  }
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 SavedSearch...");
        if (!query.exec("Create table SavedSearch (guid varchar primary key, " +
            "name varchar, query varchar, format integer, sequence integer, isDirty boolean)"))
          logger.log(logger.HIGH, "Table SavedSearch creation FAILED!!!");
  }
View Full Code Here

            "name varchar, query varchar, format integer, sequence integer, isDirty boolean)"))
          logger.log(logger.HIGH, "Table SavedSearch creation FAILED!!!");
  }
  // Drop the table
  public void dropTable() {
    NSqlQuery query = new NSqlQuery(db.getConnection());
    query.exec("Drop table SavedSearch");
  }
View Full Code Here

  public List<SavedSearch> getAll() {
    SavedSearch tempSearch;
    List<SavedSearch> index = new ArrayList<SavedSearch>();
    boolean check;
           
        NSqlQuery query = new NSqlQuery(db.getConnection());
                       
    check = query.exec("Select guid, name, query, format, sequence"
        +" from SavedSearch");
    if (!check)
      logger.log(logger.EXTREME, "SavedSearch SQL retrieve has failed in getAll().");
    while (query.next()) {
      tempSearch = new SavedSearch();
      tempSearch.setGuid(query.valueString(0));
      tempSearch.setName(query.valueString(1));
      tempSearch.setQuery(query.valueString(2));
      int fmt = new Integer(query.valueString(3));
      if (fmt == 1)
        tempSearch.setFormat(QueryFormat.USER);
      else
        tempSearch.setFormat(QueryFormat.SEXP);
      int sequence = new Integer(query.valueString(4)).intValue();
      tempSearch.setUpdateSequenceNum(sequence);
      index.add(tempSearch);
   
    return index;
  }
View Full Code Here

  }
  public SavedSearch getSavedSearch(String guid) {
    SavedSearch tempSearch = null;
    boolean check;
     
        NSqlQuery query = new NSqlQuery(db.getConnection());
                       
    check = query.prepare("Select guid, name, query, format, sequence"
        +" from SavedSearch where guid=:guid");
    if (!check)
      logger.log(logger.EXTREME, "SavedSearch SQL prepare has failed in getSavedSearch.");
    query.bindValue(":guid", guid);
    query.exec();
    if (!check)
      logger.log(logger.EXTREME, "SavedSearch SQL retrieve has failed in getSavedSearch.");
    if (query.next()) {
      tempSearch = new SavedSearch();
      tempSearch.setGuid(query.valueString(0));
      tempSearch.setName(query.valueString(1));
      tempSearch.setQuery(query.valueString(2));
      int fmt = new Integer(query.valueString(3));
      if (fmt == 1)
        tempSearch.setFormat(QueryFormat.USER);
      else
        tempSearch.setFormat(QueryFormat.SEXP);
      int sequence = new Integer(query.valueInteger(4));
      tempSearch.setUpdateSequenceNum(sequence);
    }
    return tempSearch;
  }
View Full Code Here

    return tempSearch;
  }
  // Update a tag
  public void updateSavedSearch(SavedSearch search, boolean isDirty) {
    boolean check;
        NSqlQuery query = new NSqlQuery(db.getConnection());
    check = query.prepare("Update SavedSearch set sequence=:sequence, "+
      "name=:name, isDirty=:isDirty, query=:query, format=:format "
      +"where guid=:guid");
      
    if (!check) {
      logger.log(logger.EXTREME, "SavedSearch SQL update prepare has failed.");
      logger.log(logger.EXTREME, query.lastError().toString());
    }
    query.bindValue(":sequence", search.getUpdateSequenceNum());
    query.bindValue(":name", search.getName());
    query.bindValue(":isDirty", isDirty);
    query.bindValue(":query", search.getQuery());
    if (search.getFormat() == QueryFormat.USER)
      query.bindValue(":format", 1);
    else
      query.bindValue(":format", 2);
   
    query.bindValue(":guid", search.getGuid());
   
    check = query.exec();
    if (!check) {
      logger.log(logger.MEDIUM, "Tag Table update failed.");
      logger.log(logger.EXTREME, query.lastError().toString());
    }
  }
View Full Code Here

  }
  // Delete a tag
  public void expungeSavedSearch(String guid, boolean needsSync) {
    boolean check;
    SavedSearch s = getSavedSearch(guid);
        NSqlQuery query = new NSqlQuery(db.getConnection());

         check = query.prepare("delete from SavedSearch "
           +"where guid=:guid");
    if (!check) {
      logger.log(logger.EXTREME, "SavedSearch SQL delete prepare has failed.");
      logger.log(logger.EXTREME, query.lastError().toString());
    }
    query.bindValue(":guid", guid);
    check = query.exec();
    if (!check) {
      logger.log(logger.MEDIUM, "Saved Search delete failed.");
      logger.log(logger.EXTREME, query.lastError().toString());
    }

    // Add the work to the parent queue
    if (needsSync && s != null && s.getUpdateSequenceNum() > 0) {
      DeletedTable del = new DeletedTable(logger, db);
View Full Code Here

    }
  }
  // Save a tag
  public void addSavedSearch(SavedSearch search, boolean isDirty) {
    boolean check;
        NSqlQuery query = new NSqlQuery(db.getConnection());
    check = query.prepare("Insert Into SavedSearch (guid, query, sequence, format, name, isDirty)"
        +" Values(:guid, :query, :sequence, :format, :name, :isDirty)");
    if (!check) {
      logger.log(logger.EXTREME, "Search SQL insert prepare has failed.");
      logger.log(logger.EXTREME, query.lastError().toString());
    }
    query.bindValue(":guid", search.getGuid());
    query.bindValue(":query", search.getQuery());
    query.bindValue(":sequence", search.getUpdateSequenceNum());
    if (search.getFormat() == QueryFormat.USER)
      query.bindValue(":format", 1);
    else
      query.bindValue(":format", 2);
    query.bindValue(":name", search.getName());
    query.bindValue(":isDirty", isDirty);
 
    check = query.exec();
    if  (!check) {
      logger.log(logger.MEDIUM, "Search Table insert failed.");
      logger.log(logger.MEDIUM, query.lastError().toString());
    }
  }
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.