Search in sources :

Example 1 with VirtGraph

use of virtuoso.jena.driver.VirtGraph in project opentheso by miledrousset.

the class SynchroSparql method run.

@Override
public void run() {
    System.out.println("dans le run saprtql");
    String url = sparqlStruct.getAdresseServeur().replaceAll("http", "jdbc:virtuoso").trim() + ":1111";
    VirtGraph graph = new VirtGraph(sparqlStruct.getGraph(), url, sparqlStruct.getNom_d_utilisateur(), sparqlStruct.getMot_de_passe());
    String str = "CLEAR GRAPH <" + sparqlStruct.getGraph() + ">";
    VirtuosoUpdateRequest vur = VirtuosoUpdateFactory.create(str, graph);
    vur.exec();
    Model m = ModelFactory.createDefaultModel();
    DownloadBean db = new DownloadBean();
    db.setConnect(conn);
    StreamedContent file = db.thesoToFile(sparqlStruct.getThesaurus(), liste_lang, liste_group, 0);
    try {
        m.read(file.getStream(), null);
    } catch (Exception e) {
    // graph.close();
    }
    StmtIterator iter = m.listStatements();
    while (iter.hasNext()) {
        Statement stmt = iter.nextStatement();
        Resource subject = stmt.getSubject();
        Property predicate = stmt.getPredicate();
        RDFNode object = stmt.getObject();
        Triple tri = new Triple(subject.asNode(), predicate.asNode(), object.asNode());
        graph.add(tri);
    }
    graph.close();
}
Also used : StmtIterator(org.apache.jena.rdf.model.StmtIterator) VirtuosoUpdateRequest(virtuoso.jena.driver.VirtuosoUpdateRequest) DownloadBean(mom.trd.opentheso.SelectedBeans.DownloadBean) Statement(org.apache.jena.rdf.model.Statement) Resource(org.apache.jena.rdf.model.Resource) Triple(org.apache.jena.graph.Triple) VirtGraph(virtuoso.jena.driver.VirtGraph) Model(org.apache.jena.rdf.model.Model) StreamedContent(org.primefaces.model.StreamedContent) Property(org.apache.jena.rdf.model.Property) RDFNode(org.apache.jena.rdf.model.RDFNode)

Aggregations

DownloadBean (mom.trd.opentheso.SelectedBeans.DownloadBean)1 Triple (org.apache.jena.graph.Triple)1 Model (org.apache.jena.rdf.model.Model)1 Property (org.apache.jena.rdf.model.Property)1 RDFNode (org.apache.jena.rdf.model.RDFNode)1 Resource (org.apache.jena.rdf.model.Resource)1 Statement (org.apache.jena.rdf.model.Statement)1 StmtIterator (org.apache.jena.rdf.model.StmtIterator)1 StreamedContent (org.primefaces.model.StreamedContent)1 VirtGraph (virtuoso.jena.driver.VirtGraph)1 VirtuosoUpdateRequest (virtuoso.jena.driver.VirtuosoUpdateRequest)1