Search in sources :

Example 1 with Triple

use of de.uni_koblenz.aggrimm.icp.crypto.sign.graph.Triple in project webofneeds by researchstudio-sat.

the class ModelConverter method modelToGraphCollection.

private static GraphCollection modelToGraphCollection(String name, Model model, Map<String, String> pm) {
    // Convert each subj pred obj in Jena Statement into String and add to
    // SigningFramework's NamedGraph.
    // The simpler approach with just using Jena's writer and Signingframework's
    // reader to transform data between data structures won't work since
    // Signingframework has problems with recognizing the [] structure
    GraphCollection graphc = new GraphCollection();
    NamedGraph namedGraph = new NamedGraph(enclose(name, "<", ">"), 0, null);
    StmtIterator iterator = model.listStatements();
    while (iterator.hasNext()) {
        Statement stmt = iterator.nextStatement();
        String subjString = rdfNodeAsString(stmt.getSubject());
        String objString = rdfNodeAsString(stmt.getObject());
        String predString = enclose(stmt.getPredicate().asResource().getURI(), "<", ">");
        Triple gcTriple = new Triple(subjString, predString, objString);
        namedGraph.addTriple(gcTriple);
    }
    graphc.addGraph(namedGraph);
    for (String prefix : pm.keySet()) {
        graphc.addPrefix(new Prefix(prefix + ":", "<" + pm.get(prefix) + ">"));
    }
    return graphc;
}
Also used : GraphCollection(de.uni_koblenz.aggrimm.icp.crypto.sign.graph.GraphCollection) Triple(de.uni_koblenz.aggrimm.icp.crypto.sign.graph.Triple) StmtIterator(org.apache.jena.rdf.model.StmtIterator) NamedGraph(de.uni_koblenz.aggrimm.icp.crypto.sign.graph.NamedGraph) Statement(org.apache.jena.rdf.model.Statement) Prefix(de.uni_koblenz.aggrimm.icp.crypto.sign.graph.Prefix)

Aggregations

GraphCollection (de.uni_koblenz.aggrimm.icp.crypto.sign.graph.GraphCollection)1 NamedGraph (de.uni_koblenz.aggrimm.icp.crypto.sign.graph.NamedGraph)1 Prefix (de.uni_koblenz.aggrimm.icp.crypto.sign.graph.Prefix)1 Triple (de.uni_koblenz.aggrimm.icp.crypto.sign.graph.Triple)1 Statement (org.apache.jena.rdf.model.Statement)1 StmtIterator (org.apache.jena.rdf.model.StmtIterator)1