Examples of SQLiteStatement


Examples of com.almworks.sqlite4java.SQLiteStatement

    return dbQueue.execute(new SQLiteJob<DataDescriptor>() {
        protected DataDescriptor job(SQLiteConnection db) throws SQLiteException {
          String identifier = null;
          String path = null;
          String fname = null;
          SQLiteStatement stmt = db.prepare("SELECT Types.typelabel, Files.path, Files.fname FROM Types, TypeGuesses, Files WHERE TypeGuesses.fid = ? AND Files.fid = TypeGuesses.fid AND Types.typeid = TypeGuesses.typeid");
          try {
            stmt.bind(1, fid);
            if (stmt.step()) {
              identifier = stmt.columnString(0);
              path = stmt.columnString(1);
              fname = stmt.columnString(2);
            }
          } finally {
            stmt.dispose();
          }
          stmt = db.prepare("SELECT Schemas.schemaid, Schemas.schemarepr, Schemas.schemasrcdescription, Schemas.schemapayload FROM Schemas, SchemaGuesses WHERE SchemaGuesses.fid = ? AND SchemaGuesses.schemaid = Schemas.schemaid");
          try {
            List<String> schemaReprs = new ArrayList<String>();
            List<String> schemaDescs = new ArrayList<String>();
            List<byte[]> schemaBlobs = new ArrayList<byte[]>();
             
            stmt.bind(1, fid);
            while (stmt.step()) {
              schemaReprs.add(stmt.columnString(1));
              schemaDescs.add(stmt.columnString(2));
              schemaBlobs.add(stmt.columnBlob(3));
            }

            try {
              return formatAnalyzer.loadDataDescriptor(fs, new Path(path + fname), identifier, schemaReprs, schemaDescs, schemaBlobs);
            } catch (IOException ioex) {
              return null;
            }
          } finally {
            stmt.dispose();
          }
        }}).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

          long size = 0L;
          String modified = null;
          String path = null;
          String identifier = null;         

          SQLiteStatement stmt = db.prepare("SELECT isDir, crawlid, fname, owner, groupowner, permissions, size, modified, path FROM Files WHERE Files.fid = ?");
          try {
            stmt.bind(1, fid);
            if (stmt.step()) {
              isDir = "True".equals(stmt.columnString(0));
              crawlid = stmt.columnLong(1);
              fname = stmt.columnString(2);
              owner = stmt.columnString(3);
              groupowner = stmt.columnString(4);
              permissions = stmt.columnString(5);
              size = stmt.columnLong(6);
              modified = stmt.columnString(7);
              path = stmt.columnString(8);
            }
          } finally {
            stmt.dispose();
          }

          if (! isDir) {
            stmt = db.prepare("SELECT typelabel FROM Types, TypeGuesses WHERE TypeGuesses.fid = ? AND Types.typeid = TypeGuesses.typeid");
            try {
              stmt.bind(1, fid);
              if (stmt.step()) {
                identifier = stmt.columnString(0);
              }
            } finally {
              stmt.dispose();
            }
           
            stmt = db.prepare("SELECT Schemas.schemaid, Schemas.schemarepr, Schemas.schemasrcdescription, Schemas.schemapayload FROM Schemas, SchemaGuesses WHERE SchemaGuesses.fid = ? AND SchemaGuesses.schemaid = Schemas.schemaid");
            try {
              List<String> schemaReprs = new ArrayList<String>();
              List<String> schemaDescs = new ArrayList<String>();
              List<byte[]> schemaBlobs = new ArrayList<byte[]>();
             
              stmt.bind(1, fid);
              while (stmt.step()) {
                schemaReprs.add(stmt.columnString(1));
                schemaDescs.add(stmt.columnString(2));
                schemaBlobs.add(stmt.columnBlob(3));
              }

              try {
                DataDescriptor dd = formatAnalyzer.loadDataDescriptor(fs, new Path(path + fname), identifier, schemaReprs, schemaDescs, schemaBlobs);
                fsd = new FileSummaryData(FSAnalyzer.this, true, fid, crawlid, fname, owner, groupowner, permissions, size, modified, path);
                fsd.addCachedData(dd);
              } catch (IOException iex) {
                iex.printStackTrace();
                return null;
              }
            } finally {
              stmt.dispose();
            }
          } else {
            fsd = new FileSummaryData(FSAnalyzer.this, false, fid, crawlid, fname, owner, groupowner, permissions, size, modified, path);           
          }
          return fsd;
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

   * Get the top-level directory from a given crawl
   */
  public Path getTopDir(final long crawlid)  {
    return dbQueue.execute(new SQLiteJob<Path>() {
        protected Path job(SQLiteConnection db) throws SQLiteException {
          SQLiteStatement stmt = db.prepare("SELECT path, fname FROM Files WHERE crawlid = ? AND isDir = 'True' ORDER BY length(path||fname) ASC LIMIT 1");
          try {
            stmt.bind(1, crawlid);
            if (stmt.step()) {
              return new Path(stmt.columnString(0) + stmt.columnString(1));
            } else {
              return null;
            }
          } finally {
            stmt.dispose();
          }
        }
      }).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

   */
  public List<FileSummary> getDirParents(final long crawlid, final String targetDirStr) {
    return dbQueue.execute(new SQLiteJob<List<FileSummary>>() {
        protected List<FileSummary> job(SQLiteConnection db) throws SQLiteException {
          List<FileSummary> output = new ArrayList<FileSummary>();
          SQLiteStatement stmt = db.prepare("select fid, path, fname from Files WHERE crawlid = ? AND length(?) > length(path||fname) AND isDir = 'True' AND replace(?, path||fname, '') LIKE '/%'");
          try {
            Path targetDir = new Path(targetDirStr);
            if (targetDir.getParent() != null) {
              stmt.bind(1, crawlid).bind(2, targetDir.toString()).bind(3, targetDir.toString());
              while (stmt.step()) {
                //Path p = new Path(stmt.columnString(0) + stmt.columnString(1));
                output.add(new FileSummary(FSAnalyzer.this, stmt.columnLong(0)));
              }
            }
          } finally {
            stmt.dispose();
          }
          return output;
        }
      }).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

   */
  public List<FileSummary> getDirChildren(final long crawlid, final String targetDir) {
    return dbQueue.execute(new SQLiteJob<List<FileSummary>>() {
        protected List<FileSummary> job(SQLiteConnection db) throws SQLiteException {
          List<FileSummary> output = new ArrayList<FileSummary>();
          SQLiteStatement stmt = db.prepare("SELECT DISTINCT fid AS fullpath FROM Files WHERE isDir = 'True' AND crawlid = ? AND path = ? ORDER BY fname ASC");
          try {
            String targetDirNormalizedStr = targetDir;
            if (! targetDirNormalizedStr.endsWith("/")) {
              targetDirNormalizedStr += "/";
            }
            stmt.bind(1, crawlid).bind(2, targetDirNormalizedStr);
            while (stmt.step()) {
              output.add(new FileSummary(FSAnalyzer.this, stmt.columnLong(0)));
            }
          } finally {
            stmt.dispose();
          }
          return output;
        }
      }).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

  static String crawlInfoQuery = "SELECT crawlid, crawlstarted, crawlfinished, inprogress, fsid FROM Crawls";   
  public List<CrawlSummary> getCrawlSummaries() {
    return dbQueue.execute(new SQLiteJob<List<CrawlSummary>>() {
        protected List<CrawlSummary> job(SQLiteConnection db) throws SQLiteException {
          List<CrawlSummary> output = new ArrayList<CrawlSummary>();
          SQLiteStatement stmt = db.prepare(crawlInfoQuery);
          try {
            while (stmt.step()) {
              long cid = stmt.columnLong(0);
              String started = stmt.columnString(1);
              String finished = stmt.columnString(2);
              String inprogress = stmt.columnString(3);
              long fsid = stmt.columnLong(4);                           
              output.add(new CrawlSummary(FSAnalyzer.this, cid, started, finished, "True".equals(inprogress), fsid));
            }
          } catch (SQLiteException se) {
            se.printStackTrace();
          } finally {
            stmt.dispose();
          }
          return output;
        }}).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

   * Grab details on a crawl.
   */
  public CrawlSummary getCrawlSummaryData(final long crawlid) {
    return dbQueue.execute(new SQLiteJob<CrawlSummary>() {
        protected CrawlSummary job(SQLiteConnection db) throws SQLiteException {
          SQLiteStatement stmt = db.prepare("SELECT crawlstarted, crawlfinished, inprogress, fsid FROM Crawls WHERE crawlid = ?");
          try {
            stmt.bind(1, crawlid);
            if (stmt.step()) {
              return new CrawlSummary(FSAnalyzer.this, crawlid, stmt.columnString(0), stmt.columnString(1), "True".equals(stmt.columnString(2)), stmt.columnLong(3));
            } else {
              return null;
            }
          } finally {
            stmt.dispose();
          }
        }
      }).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

  static String typeInfoQuery = "SELECT typeid FROM Types";   
  public List<TypeSummary> getTypeSummaries() {
    return dbQueue.execute(new SQLiteJob<List<TypeSummary>>() {
        protected List<TypeSummary> job(SQLiteConnection db) throws SQLiteException {
          List<TypeSummary> output = new ArrayList<TypeSummary>();         
          SQLiteStatement stmt = db.prepare(typeInfoQuery);
         
          try {
            while (stmt.step()) {
              long typeid = stmt.columnLong(0);
              output.add(new TypeSummary(FSAnalyzer.this, typeid));
            }
          } catch (SQLiteException se) {
            se.printStackTrace();
          } finally {
            stmt.dispose();
          }
          return output;
        }}).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

   * Grab details on a type.
   */
  public TypeSummaryData getTypeSummaryData(final long typeid) {
    return dbQueue.execute(new SQLiteJob<TypeSummaryData>() {
        protected TypeSummaryData job(SQLiteConnection db) throws SQLiteException {
          SQLiteStatement stmt = db.prepare("SELECT typelabel FROM Types WHERE typeid = ?");
          try {
            stmt.bind(1, typeid);
            if (stmt.step()) {
              return new TypeSummaryData(typeid, stmt.columnString(0));
            } else {
              return null;
            }
          } finally {
            stmt.dispose();
          }
        }
      }).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

   * Read a property's value
   */
  public String getConfigProperty(final String propertyName) {
    return dbQueue.execute(new SQLiteJob<String>() {
        protected String job(SQLiteConnection db) throws SQLiteException {
          SQLiteStatement stmt = db.prepare("SELECT property FROM Configs WHERE propertyname=?");
          try {
            stmt.bind(1, propertyName);
            if (stmt.step()) {
              return stmt.columnString(0);
            } else {
              return null;
            }
          } finally {
            stmt.dispose();
          }
        }
      }).complete();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.