// Path: src/main/java/uk/ac/ic/wlgitbridge/bridge/db/DBInitException.java
// public class DBInitException extends RuntimeException {
// 
//     public DBInitException(String message) {
//         super(message);
//     }
// 
//     public DBInitException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public DBInitException(Throwable cause) {
//         super(cause);
//     }
// 
// }
// 
// Path: src/main/java/uk/ac/ic/wlgitbridge/bridge/db/DBStore.java
// public interface DBStore {
// 
//     int getNumProjects();
// 
//     List<String> getProjectNames();
// 
//     void setLatestVersionForProject(String project, int versionID);
// 
//     int getLatestVersionForProject(String project);
// 
//     void addURLIndexForProject(String projectName, String url, String path);
// 
//     void deleteFilesForProject(String project, String... files);
// 
//     String getPathForURLInProject(String projectName, String url);
// 
//     String getOldestUnswappedProject();
// 
//     int getNumUnswappedProjects();
// 
//     ProjectState getProjectState(String projectName);
// 
//     /**
//      * Sets the last accessed time for the given project name.
//      * @param projectName the project's name
//      * @param time the time, or null if the project is to be swapped
//      */
//     void setLastAccessedTime(String projectName, Timestamp time);
// 
// }
// 
// Path: src/main/java/uk/ac/ic/wlgitbridge/bridge/db/ProjectState.java
// public enum ProjectState {
// 
//     NOT_PRESENT,
//     PRESENT,
//     SWAPPED
// 
// }


import com.google.common.base.Preconditions;
import uk.ac.ic.wlgitbridge.bridge.db.DBInitException;
import uk.ac.ic.wlgitbridge.bridge.db.DBStore;
import uk.ac.ic.wlgitbridge.bridge.db.ProjectState;
import uk.ac.ic.wlgitbridge.bridge.db.sqlite.query.*;
import uk.ac.ic.wlgitbridge.bridge.db.sqlite.update.alter.*;
import uk.ac.ic.wlgitbridge.bridge.db.sqlite.update.create.*;
import uk.ac.ic.wlgitbridge.bridge.db.sqlite.update.delete.*;
import uk.ac.ic.wlgitbridge.bridge.db.sqlite.update.insert.*;
import java.io.File;
import java.sql.*;
import java.util.List;
import java.util.stream.Stream;
package uk.ac.ic.wlgitbridge.bridge.db.sqlite;



/**
 * Created by Winston on 17/11/14.
 */
public class SqliteDBStore implements DBStore {

    private final Connection connection;

    public SqliteDBStore(File dbFile) {
        try {
            connection = openConnectionTo(dbFile);
            createTables();
        } catch (Throwable t) {
// Path: src/main/java/uk/ac/ic/wlgitbridge/bridge/db/DBInitException.java
// public class DBInitException extends RuntimeException {
// 
//     public DBInitException(String message) {
//         super(message);
//     }
// 
//     public DBInitException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public DBInitException(Throwable cause) {
//         super(cause);
//     }
// 
// }
// 
// Path: src/main/java/uk/ac/ic/wlgitbridge/bridge/db/DBStore.java
// public interface DBStore {
// 
//     int getNumProjects();
// 
//     List<String> getProjectNames();
// 
//     void setLatestVersionForProject(String project, int versionID);
// 
//     int getLatestVersionForProject(String project);
// 
//     void addURLIndexForProject(String projectName, String url, String path);
// 
//     void deleteFilesForProject(String project, String... files);
// 
//     String getPathForURLInProject(String projectName, String url);
// 
//     String getOldestUnswappedProject();
// 
//     int getNumUnswappedProjects();
// 
//     ProjectState getProjectState(String projectName);
// 
//     /**
//      * Sets the last accessed time for the given project name.
//      * @param projectName the project's name
//      * @param time the time, or null if the project is to be swapped
//      */
//     void setLastAccessedTime(String projectName, Timestamp time);
// 
// }
// 
// Path: src/main/java/uk/ac/ic/wlgitbridge/bridge/db/ProjectState.java
// public enum ProjectState {
// 
//     NOT_PRESENT,
//     PRESENT,
//     SWAPPED
// 
// }


// Path: src/main/java/uk/ac/ic/wlgitbridge/bridge/db/sqlite/SqliteDBStore.java
import com.google.common.base.Preconditions;
import uk.ac.ic.wlgitbridge.bridge.db.DBInitException;
import uk.ac.ic.wlgitbridge.bridge.db.DBStore;
import uk.ac.ic.wlgitbridge.bridge.db.ProjectState;
import uk.ac.ic.wlgitbridge.bridge.db.sqlite.query.*;
import uk.ac.ic.wlgitbridge.bridge.db.sqlite.update.alter.*;
import uk.ac.ic.wlgitbridge.bridge.db.sqlite.update.create.*;
import uk.ac.ic.wlgitbridge.bridge.db.sqlite.update.delete.*;
import uk.ac.ic.wlgitbridge.bridge.db.sqlite.update.insert.*;
import java.io.File;
import java.sql.*;
import java.util.List;
import java.util.stream.Stream;

package uk.ac.ic.wlgitbridge.bridge.db.sqlite;



/**
 * Created by Winston on 17/11/14.
 */
public class SqliteDBStore implements DBStore {

    private final Connection connection;

    public SqliteDBStore(File dbFile) {
        try {
            connection = openConnectionTo(dbFile);
            createTables();
        } catch (Throwable t) {
            throw new DBInitException(t);