package control;
import JOINT.Kao;
import java.util.ArrayList;
import java.util.List;
import joint_codegen_foaf.Agent;
import joint_codegen_swrc.Person;
import joint_codegen_swrc.University;
/**
*
* @author Judson
*/
public class Controller {
private final String authorsOntologyURI = "http://dblp.l3s.de/d2r/all/Authors";
private final String journalsOntologyURI = "http://dblp.l3s.de/d2r/all/Journals";
private final String publicationsOntologyURI = "http://dblp.l3s.de/d2r/all/Publications";
private final String conferencesOntologyURI = "http://dblp.l3s.de/d2r/all/Conferences";
private final String collectionsOntologyURI = "http://dblp.l3s.de/d2r/all/Collections";
private final String swrcOntologyURI = "http://swrc.ontoware.org/ontology";
private final String ontoAppOntologyURI = "http://www.nees.com.br/ontologies/2014/ontoApp";
public List<String> searchResearchersByName(String personName) {
Kao kaoPerson = new Kao(Agent.class, swrcOntologyURI);
String query = "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"
+ "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>\n"
+ "PREFIX foaf:<http://xmlns.com/foaf/0.1/>\n"
+ "SELECT ?name\n"
+ "WHERE{?subject rdf:type foaf:Agent.\n"
+ " ?subject rdfs:label ?name.\n"
+ "FILTER regex(?name,'" + personName + "','i').\n"
+ "}";
List<? extends Object> researcher = null;
try {
researcher = (List<? extends Object>) kaoPerson.executeQueryAsSingleResult(query);
} catch (Exception e) {
researcher = null;
} finally {
kaoPerson.save();
return (List<String>) researcher;
}
}
public List<String> searchUniversityByName(String universityName) {
Kao kaoUniversity = new Kao(University.class, swrcOntologyURI);
String query = "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"
+ "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>\n"
+ "PREFIX swrc:<http://swrc.ontoware.org/ontology/>\n"
+ "SELECT ?name\n"
+ "WHERE{?subject rdf:type swrc:University.\n"
+ " ?subject rdfs:label ?name.\n"
+ "FILTER regex(?name,'" + universityName + "','i').\n"
+ "}";
List<? extends Object> university = null;
try {
university = (List<? extends Object>) kaoUniversity.executeQueryAsSingleResult(query);
} catch (Exception e) {
university = null;
} finally {
kaoUniversity.save();
return (List<String>) university;
}
}
}