// Path: DBPediaAnalyzer/src/dbpediaanalyzer/io/SparqlRecord.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SparqlRecord {
//     private HashMap<String, SparqlValue> fields = new HashMap<>();
// 
//     public HashMap<String, SparqlValue> getFields() {
//         return this.fields;
//     }
// 
//     @JsonAnySetter
//     public void set(String name, SparqlValue value) {
//         this.fields.put(name, value);
//     }
// }
// 
// Path: DBPediaAnalyzer/src/dbpediaanalyzer/io/SparqlResponse.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SparqlResponse {
//     private SparqlHead head;
//     private SparqlResults results;
// 
//     public SparqlHead getHead() {
//         return this.head;
//     }
// 
//     public void setHead(SparqlHead head) {
//         this.head = head;
//     }
// 
//     public SparqlResults getResults() {
//         return this.results;
//     }
// 
//     public void setResults(SparqlResults results) {
//         this.results = results;
//     }
// 
//     public ArrayList<SparqlRecord> getRecords() {
//         if(this.results != null && this.results.getBindings() != null) {
//             return this.results.getBindings();
//         }
// 
//         return new ArrayList<>();
//     }
// }


import dbpediaanalyzer.dbpediaobject.*;
import dbpediaanalyzer.io.ServerQuerier;
import dbpediaanalyzer.io.SparqlRecord;
import dbpediaanalyzer.io.SparqlResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
package dbpediaanalyzer.factory;



/**
 * Built the data set from DBpedia pages selected with min and max death date
 *
 * @author Pierre Monnin
 *
 */
public class DataSetFactory {

    public static Map<String, Page> createDataSet(String minDeathDate, String maxDeathDate, HierarchiesManager hierarchiesManager) {
        HashMap<String, Page> dataSet = new HashMap<>();
        HashMap<String, Boolean> missingCategories = new HashMap<>();
        HashMap<String, Boolean> missingOntologyClasses = new HashMap<>();
        HashMap<String, Boolean> missingYagoClasses = new HashMap<>();

        try {
            SparqlResponse response = (new ServerQuerier()).runQuery(
                    "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
                    "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> " +
                    "PREFIX dbo:<http://dbpedia.org/ontology/> " +
                    "select distinct ?page where { " +
                    "?page dbo:wikiPageID ?pageId . " +
                    "?page rdf:type/rdfs:subClassOf* dbo:Person . " +
                    "?page dbo:deathDate ?deathDate . " +
                    "FILTER(?deathDate >= \"" + minDeathDate + "\"^^xsd:date) . " +
                    "FILTER(?deathDate < \"" + maxDeathDate + "\"^^xsd:date) }"
                    );

// Path: DBPediaAnalyzer/src/dbpediaanalyzer/io/SparqlRecord.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SparqlRecord {
//     private HashMap<String, SparqlValue> fields = new HashMap<>();
// 
//     public HashMap<String, SparqlValue> getFields() {
//         return this.fields;
//     }
// 
//     @JsonAnySetter
//     public void set(String name, SparqlValue value) {
//         this.fields.put(name, value);
//     }
// }
// 
// Path: DBPediaAnalyzer/src/dbpediaanalyzer/io/SparqlResponse.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SparqlResponse {
//     private SparqlHead head;
//     private SparqlResults results;
// 
//     public SparqlHead getHead() {
//         return this.head;
//     }
// 
//     public void setHead(SparqlHead head) {
//         this.head = head;
//     }
// 
//     public SparqlResults getResults() {
//         return this.results;
//     }
// 
//     public void setResults(SparqlResults results) {
//         this.results = results;
//     }
// 
//     public ArrayList<SparqlRecord> getRecords() {
//         if(this.results != null && this.results.getBindings() != null) {
//             return this.results.getBindings();
//         }
// 
//         return new ArrayList<>();
//     }
// }


// Path: DBPediaAnalyzer/src/dbpediaanalyzer/factory/DataSetFactory.java
import dbpediaanalyzer.dbpediaobject.*;
import dbpediaanalyzer.io.ServerQuerier;
import dbpediaanalyzer.io.SparqlRecord;
import dbpediaanalyzer.io.SparqlResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

package dbpediaanalyzer.factory;



/**
 * Built the data set from DBpedia pages selected with min and max death date
 *
 * @author Pierre Monnin
 *
 */
public class DataSetFactory {

    public static Map<String, Page> createDataSet(String minDeathDate, String maxDeathDate, HierarchiesManager hierarchiesManager) {
        HashMap<String, Page> dataSet = new HashMap<>();
        HashMap<String, Boolean> missingCategories = new HashMap<>();
        HashMap<String, Boolean> missingOntologyClasses = new HashMap<>();
        HashMap<String, Boolean> missingYagoClasses = new HashMap<>();

        try {
            SparqlResponse response = (new ServerQuerier()).runQuery(
                    "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
                    "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> " +
                    "PREFIX dbo:<http://dbpedia.org/ontology/> " +
                    "select distinct ?page where { " +
                    "?page dbo:wikiPageID ?pageId . " +
                    "?page rdf:type/rdfs:subClassOf* dbo:Person . " +
                    "?page dbo:deathDate ?deathDate . " +
                    "FILTER(?deathDate >= \"" + minDeathDate + "\"^^xsd:date) . " +
                    "FILTER(?deathDate < \"" + maxDeathDate + "\"^^xsd:date) }"
                    );

            for(SparqlRecord r : response.getRecords()) {