diff --git a/TERWEB2016/src/com/terweb/packageInterrogationDonnees/InterrogationDataRDF.java b/TERWEB2016/src/com/terweb/packageInterrogationDonnees/InterrogationDataRDF.java index 47b975c..72f2b38 100644 --- a/TERWEB2016/src/com/terweb/packageInterrogationDonnees/InterrogationDataRDF.java +++ b/TERWEB2016/src/com/terweb/packageInterrogationDonnees/InterrogationDataRDF.java @@ -519,4 +519,84 @@ static Object_RapportCalculVecteur getVecteurCalcul(String path, Object_TIEG obj return rapport; } + + + /** + * + * Fonction qui retourne le numéro de la table "Process Description d'un document donnée. + * + * @param path : Chemin des données en cas d'une interrogation en local. + * @param idDocument : Identifiant du document. + * @return Obj:String + * @throws Exception_SparqlConnexion + * + */ + + static String getTableID(String path, String idDocument) throws Exception_SparqlConnexion + { + String resultat = null; + + String comNameQuery= + "prefix rdfs: \n" + + " prefix owl: \n" + + " PREFIX onto: \n" + + " PREFIX domain: \n" + + " PREFIX rdf: \n" + + " PREFIX dc: \n" + + "\n" + + " SELECT ?tableID\n" + + " WHERE {\n" + + " ?document rdf:type onto:Document.\n" + + " ?document onto:hasForID ?idDocument.\n" + + " FILTER(str(?idDocument)=\""+idDocument+"\")\n" + + " ?document onto:hasTable ?table.\n" + + " ?table dc:title ?tableTitle.\n" + + " FILTER regex(?tableTitle, \"Process\", \"i\" )\n" + + " ?table onto:hasForID ?tableID.\n" + + " }"; + + /************************LOCAL MODE *********************************** + + Path input = Paths.get(path+"DonneesLocales/RDF/", "annotations_atweb.ttl"); + + Model model = ModelFactory.createDefaultModel() ; + + model.read(input.toUri().toString()); + + Query query = QueryFactory.create(comNameQuery); + + QueryExecution qe = QueryExecutionFactory.create(query, model); + + ************************************************************************/ + + /**********************SPARQL ENDPOINT MODE*****************/ + + Query query = QueryFactory.create(comNameQuery); + + QueryExecution qe = QueryExecutionFactory.sparqlService(sparqlEndpoint,query); + + /************************************************************************/ + + try { + ResultSet rs = qe.execSelect(); + + while ( rs.hasNext() ) { + + QuerySolution solution=rs.next(); + + resultat=solution.getLiteral("tableID").getLexicalForm(); + } + } + catch(Exception e){ + + throw new Exception_SparqlConnexion(e); + + } + finally { + qe.close(); + } + + return resultat; + + } } diff --git a/TERWEB2016/src/com/terweb/packageInterrogationDonnees/LienDocument.java b/TERWEB2016/src/com/terweb/packageInterrogationDonnees/LienDocument.java index 4c434ef..9836911 100644 --- a/TERWEB2016/src/com/terweb/packageInterrogationDonnees/LienDocument.java +++ b/TERWEB2016/src/com/terweb/packageInterrogationDonnees/LienDocument.java @@ -1,10 +1,55 @@ package com.terweb.packageInterrogationDonnees; +import com.terweb.packageExceptions.Exception_SparqlConnexion; + + + /** + * + * Classe qui regroupe des méthodes utilisées pour récupérer l'URI d'une table : Process Description sur @WEB + * à partir de l'identifiant du document scientifique correspendant. + * + * + */ + public class LienDocument { - public static String genereLien(int numDocument){ + + /** + * + * Fonction qui retourne l'URI de la table annotée (Process Description) d'un document donné. + * + * @param path : Chemin des données en cas d'une interrogation en local. + * @param idDocument : Identifiant du document. + * @return Obj:String + * @throws Exception_SparqlConnexion + * + */ + + public static String genereLien(String path, String idDocument) throws Exception_SparqlConnexion{ - System.out.println("hadmmmmmmmmmmmmmmmmmmmmmmmmmm"); - return "http://localhost:5355/TERWEB2016/index/mm"; + int idTable = Integer.parseInt(InterrogationDataRDF.getTableID(path,idDocument)); + + String lien=getLien(idDocument, idTable); + + return lien; } + + /** + * + * Fonction qui génère l'URI de la table annotée (Process Description) d'un document donné. + * + * @param path : Chemin des données en cas d'une interrogation en local. + * @param idDocument : Identifiant de la table. + * @return Obj:String + * + */ + + private static String getLien(String idDocument, int idItem) + { + String serial=Integer.toString(idItem * idItem - idItem, 8); + + String lien="http://pfl.grignon.inra.fr/atWeb/TableServlet?viewTable="+idItem+"&idDoc="+idDocument+"&id="+serial; + + return lien; + } }