// Path: src/main/java/org/aksw/TripleCheckMate/shared/sparql/Endpoint.java
// public class Endpoint implements Serializable {
//     private long endpointID = 0;
//     private String endpoint;
//     private List<String> graphs = new ArrayList<String>();
//     private String name;
// 
//     public Endpoint() {
//         endpoint = "";
//         name="";
//         graphs = Arrays.asList();
//     }
// 
//     public Endpoint(long id, String endpoint, String graphs, String name) {
//         this.endpointID = id;
//         this.endpoint = endpoint;
//         String[] g = graphs.split(";");
//         for (int i = 0; i < g.length; i++)
//             this.graphs.add(g[i]);
//         this.name = name;
//     }
// 
//     public long getID(){
//         return endpointID;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public String getEndpoint() {
//         return endpoint;
//     }
// 
//     public List<String> getGraphs() {
//         return graphs;
//     }
// 
//     public String getDefaultGraph() {
//         return graphs.get(0);
//     }
// 
//     public String generateQueryURL(String sparqlQuery) {
//         String retVal = "";
//         retVal += endpoint;
//         //retVal += "?default-graph-uri=" + URL.encode(graphs.get(0));
//         retVal += "?format=json&query=";
//         retVal += URL.encode(sparqlQuery).replace("#", "%23");
//         return retVal;
//     }
// 
//     public String getQueryforResourceTriples(String resource) {
//         String from = "";
//         for (String g : graphs)
//             from += " FROM <" + g + "> ";
//         return "select ?p ?o " +
//                 from +
//                 "where {<" +
//                 resource +
//                 "> ?p ?o} ORDER BY ?p";
//     }
// 
//     public String getQueryforRandomResource() {
// 
//         int offset = Random.nextInt(760129);
//         String from = "";
//         for (String g : graphs)
//             from += " FROM <" + g + "> ";
//         return " SELECT ?s " + from +
//                 " WHERE { ?s foaf:isPrimaryTopicOf ?o } LIMIT 1 OFFSET " + offset;
//     }
// 
//     public String getQueryforRandomClassResource(String classURI, long maxRand) {
// 
//         int offset = Random.nextInt((int) maxRand);
//         String from = "";
//         for (String g : graphs)
//             from += " FROM <" + g + "> ";
//         return " SELECT ?s " + from +
//                 " WHERE { ?s rdf:type <" + classURI + "> } LIMIT 1 OFFSET " + offset;
//     }
// 
//     public String getQueryforClassCount(String classURI) {
// 
//         String from = "";
//         for (String g : graphs)
//             from += " FROM <" + g + "> ";
//         return " SELECT count(?s) " + from +
//                 " WHERE { ?s rdf:type <" + classURI + "> }";
//     }
// 
//     public String getQueryforAutocomplete(String namepart) {
//         String from = "";
//         for (String g : graphs)
//             from += " FROM <" + g + "> ";
//         return " SELECT ?s " + from +
//                 " WHERE { ?s foaf:isPrimaryTopicOf ?o . " +
//                 " FILTER regex(str(?s), '" + namepart + "', 'i'). } LIMIT 10";
//     }
// }
// 
// Path: src/main/java/org/aksw/TripleCheckMate/shared/exceptions/StorageServiceException.java
// public class StorageServiceException extends Exception implements
//         Serializable {
// 
//     /**
//      * Autogenerated for serialization
//      */
//     private static final long serialVersionUID = -1709522630145405589L;
// 
//     private String errorMessage;
// 
//     public StorageServiceException() {
//     }
// 
//     public StorageServiceException(String message) {
//         this.errorMessage = message;
//     }
// 
//     public String getErrorMessage() {
//         return this.errorMessage;
//     }
// 
// }


import org.aksw.TripleCheckMate.shared.evaluate.*;
import org.aksw.TripleCheckMate.shared.sparql.Endpoint;
import org.aksw.TripleCheckMate.shared.exceptions.StorageServiceException;
import java.sql.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
/*******************************************************************************
 * Copyright 2013 Agile Knowledge Engineering and Semantic Web (AKSW) Group
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package org.aksw.TripleCheckMate.server.storage;



public class JDBCStorageService extends StorageService {

    private String JDBC_DRIVER = "org.h2.Driver";
    private String DB_URL = "jdbc:h2:evaluation_db";
    private String USER = "sa";
    private String PASS = "";

    public JDBCStorageService(String driver, String dburl, String username,
                              String password) {
        JDBC_DRIVER = driver;
        DB_URL = dburl;
        USER = username;
        PASS = password;

    }

    private void executeUpdateQuery(String query)
// Path: src/main/java/org/aksw/TripleCheckMate/shared/sparql/Endpoint.java
// public class Endpoint implements Serializable {
//     private long endpointID = 0;
//     private String endpoint;
//     private List<String> graphs = new ArrayList<String>();
//     private String name;
// 
//     public Endpoint() {
//         endpoint = "";
//         name="";
//         graphs = Arrays.asList();
//     }
// 
//     public Endpoint(long id, String endpoint, String graphs, String name) {
//         this.endpointID = id;
//         this.endpoint = endpoint;
//         String[] g = graphs.split(";");
//         for (int i = 0; i < g.length; i++)
//             this.graphs.add(g[i]);
//         this.name = name;
//     }
// 
//     public long getID(){
//         return endpointID;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public String getEndpoint() {
//         return endpoint;
//     }
// 
//     public List<String> getGraphs() {
//         return graphs;
//     }
// 
//     public String getDefaultGraph() {
//         return graphs.get(0);
//     }
// 
//     public String generateQueryURL(String sparqlQuery) {
//         String retVal = "";
//         retVal += endpoint;
//         //retVal += "?default-graph-uri=" + URL.encode(graphs.get(0));
//         retVal += "?format=json&query=";
//         retVal += URL.encode(sparqlQuery).replace("#", "%23");
//         return retVal;
//     }
// 
//     public String getQueryforResourceTriples(String resource) {
//         String from = "";
//         for (String g : graphs)
//             from += " FROM <" + g + "> ";
//         return "select ?p ?o " +
//                 from +
//                 "where {<" +
//                 resource +
//                 "> ?p ?o} ORDER BY ?p";
//     }
// 
//     public String getQueryforRandomResource() {
// 
//         int offset = Random.nextInt(760129);
//         String from = "";
//         for (String g : graphs)
//             from += " FROM <" + g + "> ";
//         return " SELECT ?s " + from +
//                 " WHERE { ?s foaf:isPrimaryTopicOf ?o } LIMIT 1 OFFSET " + offset;
//     }
// 
//     public String getQueryforRandomClassResource(String classURI, long maxRand) {
// 
//         int offset = Random.nextInt((int) maxRand);
//         String from = "";
//         for (String g : graphs)
//             from += " FROM <" + g + "> ";
//         return " SELECT ?s " + from +
//                 " WHERE { ?s rdf:type <" + classURI + "> } LIMIT 1 OFFSET " + offset;
//     }
// 
//     public String getQueryforClassCount(String classURI) {
// 
//         String from = "";
//         for (String g : graphs)
//             from += " FROM <" + g + "> ";
//         return " SELECT count(?s) " + from +
//                 " WHERE { ?s rdf:type <" + classURI + "> }";
//     }
// 
//     public String getQueryforAutocomplete(String namepart) {
//         String from = "";
//         for (String g : graphs)
//             from += " FROM <" + g + "> ";
//         return " SELECT ?s " + from +
//                 " WHERE { ?s foaf:isPrimaryTopicOf ?o . " +
//                 " FILTER regex(str(?s), '" + namepart + "', 'i'). } LIMIT 10";
//     }
// }
// 
// Path: src/main/java/org/aksw/TripleCheckMate/shared/exceptions/StorageServiceException.java
// public class StorageServiceException extends Exception implements
//         Serializable {
// 
//     /**
//      * Autogenerated for serialization
//      */
//     private static final long serialVersionUID = -1709522630145405589L;
// 
//     private String errorMessage;
// 
//     public StorageServiceException() {
//     }
// 
//     public StorageServiceException(String message) {
//         this.errorMessage = message;
//     }
// 
//     public String getErrorMessage() {
//         return this.errorMessage;
//     }
// 
// }


// Path: src/main/java/org/aksw/TripleCheckMate/server/storage/JDBCStorageService.java
import org.aksw.TripleCheckMate.shared.evaluate.*;
import org.aksw.TripleCheckMate.shared.sparql.Endpoint;
import org.aksw.TripleCheckMate.shared.exceptions.StorageServiceException;
import java.sql.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;

/*******************************************************************************
 * Copyright 2013 Agile Knowledge Engineering and Semantic Web (AKSW) Group
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package org.aksw.TripleCheckMate.server.storage;



public class JDBCStorageService extends StorageService {

    private String JDBC_DRIVER = "org.h2.Driver";
    private String DB_URL = "jdbc:h2:evaluation_db";
    private String USER = "sa";
    private String PASS = "";

    public JDBCStorageService(String driver, String dburl, String username,
                              String password) {
        JDBC_DRIVER = driver;
        DB_URL = dburl;
        USER = username;
        PASS = password;

    }

    private void executeUpdateQuery(String query)
            throws StorageServiceException {