Search in sources :

Example 31 with RDFFormat

use of org.eclipse.rdf4j.rio.RDFFormat in project opentheso by miledrousset.

the class RestRDFHelper method brancheOfConceptsTop.

/**
 * Fonction qui permet de récupérer une branche complète en partant d'un
 * concept et en allant jusqu'à la racine (vers le haut)
 *
 * @param ds
 * @param idConcept
 * @param idTheso
 * @param format
 * @return skos
 */
public String brancheOfConceptsTop(HikariDataSource ds, String idConcept, String idTheso, String format) {
    RDFFormat rDFFormat = getRDFFormat(format);
    WriteRdf4j writeRdf4j = brancheOfConceptsTop__(ds, idConcept, idTheso);
    if (writeRdf4j == null)
        return null;
    ByteArrayOutputStream out;
    out = new ByteArrayOutputStream();
    Rio.write(writeRdf4j.getModel(), out, rDFFormat);
    return out.toString();
}
Also used : WriteRdf4j(mom.trd.opentheso.core.exports.rdf4j.WriteRdf4j) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RDFFormat(org.eclipse.rdf4j.rio.RDFFormat)

Example 32 with RDFFormat

use of org.eclipse.rdf4j.rio.RDFFormat in project opentheso by miledrousset.

the class RestRDFHelper method exportGroup.

/**
 * Permet de retourner un group au format défini en passant par un identifiant Ark
 * utilisé pour la négociation de contenu
 *
 * @param ds
 * @param idArk
 * @param format
 * @return
 */
public String exportGroup(HikariDataSource ds, String idArk, String format) {
    RDFFormat rDFFormat = getRDFFormat(format);
    WriteRdf4j writeRdf4j = getGroupFromArk(ds, idArk);
    if (writeRdf4j == null)
        return null;
    ByteArrayOutputStream out;
    out = new ByteArrayOutputStream();
    Rio.write(writeRdf4j.getModel(), out, rDFFormat);
    return out.toString();
}
Also used : WriteRdf4j(mom.trd.opentheso.core.exports.rdf4j.WriteRdf4j) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RDFFormat(org.eclipse.rdf4j.rio.RDFFormat)

Example 33 with RDFFormat

use of org.eclipse.rdf4j.rio.RDFFormat in project opentheso by miledrousset.

the class RestRDFHelper method exportConcept.

/**
 * Permet de retourner un concept au format défini en passant par un identifiant Ark
 * utilisé pour la négociation de contenu
 *
 * @param ds
 * @param idArk
 * @param format
 * @return
 */
public String exportConcept(HikariDataSource ds, String idArk, String format) {
    RDFFormat rDFFormat = getRDFFormat(format);
    WriteRdf4j writeRdf4j = getConceptFromArk(ds, idArk);
    if (writeRdf4j == null)
        return null;
    ByteArrayOutputStream out;
    out = new ByteArrayOutputStream();
    Rio.write(writeRdf4j.getModel(), out, rDFFormat);
    return out.toString();
}
Also used : WriteRdf4j(mom.trd.opentheso.core.exports.rdf4j.WriteRdf4j) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RDFFormat(org.eclipse.rdf4j.rio.RDFFormat)

Example 34 with RDFFormat

use of org.eclipse.rdf4j.rio.RDFFormat in project opentheso by miledrousset.

the class RestRDFHelper method findConcepts.

/**
 * Permet de retourner un concept au format défini en passant par un identifiant Ark
 * utilisé pour la négociation de contenu
 *
 * @param ds
 * @param idTheso
 * @param lang
 * @param group
 * @param format
 * @param value
 * @return
 */
public String findConcepts(HikariDataSource ds, String idTheso, String lang, String group, String value, String format) {
    RDFFormat rDFFormat = getRDFFormat(format);
    WriteRdf4j writeRdf4j = findConcepts__(ds, value, idTheso, lang, group);
    if (writeRdf4j == null)
        return null;
    ByteArrayOutputStream out;
    out = new ByteArrayOutputStream();
    Rio.write(writeRdf4j.getModel(), out, rDFFormat);
    return out.toString();
}
Also used : WriteRdf4j(mom.trd.opentheso.core.exports.rdf4j.WriteRdf4j) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RDFFormat(org.eclipse.rdf4j.rio.RDFFormat)

Example 35 with RDFFormat

use of org.eclipse.rdf4j.rio.RDFFormat in project opentheso by miledrousset.

the class CopyAndPasteHelper method getBranch.

private SKOSXmlDocument getBranch(HikariDataSource ds, String fromIdTheso, String fromIdConcept) {
    RDFFormat format = RDFFormat.RDFXML;
    NodePreference nodePreference = new PreferencesHelper().getThesaurusPreferences(ds, fromIdTheso);
    if (nodePreference == null)
        return null;
    ExportRdf4jHelper exportRdf4jHelper = new ExportRdf4jHelper();
    exportRdf4jHelper.setInfos(ds, "dd-mm-yyyy", false, fromIdTheso, nodePreference.getCheminSite());
    exportRdf4jHelper.setNodePreference(nodePreference);
    exportRdf4jHelper.addBranch(fromIdTheso, fromIdConcept);
    return exportRdf4jHelper.getSkosXmlDocument();
/*        WriteRdf4j writeRdf4j = new WriteRdf4j(exportRdf4jHelper.getSkosXmlDocument());
        
        ByteArrayOutputStream out;
        out = new ByteArrayOutputStream();
        Rio.write(writeRdf4j.getModel(), out, format);
        return out.toString();*/
}
Also used : ExportRdf4jHelper(mom.trd.opentheso.core.exports.rdf4j.ExportRdf4jHelper) NodePreference(mom.trd.opentheso.bdd.helper.nodes.NodePreference) RDFFormat(org.eclipse.rdf4j.rio.RDFFormat)

Aggregations

RDFFormat (org.eclipse.rdf4j.rio.RDFFormat)62 ByteArrayOutputStream (java.io.ByteArrayOutputStream)17 IOException (java.io.IOException)17 WriteRdf4j (mom.trd.opentheso.core.exports.rdf4j.WriteRdf4j)14 InputStream (java.io.InputStream)12 RDFParseException (org.eclipse.rdf4j.rio.RDFParseException)11 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)8 FileInputStream (java.io.FileInputStream)7 Model (org.eclipse.rdf4j.model.Model)6 RDFHandlerException (org.eclipse.rdf4j.rio.RDFHandlerException)6 RDFParser (org.eclipse.rdf4j.rio.RDFParser)5 UnsupportedRDFormatException (org.eclipse.rdf4j.rio.UnsupportedRDFormatException)5 Rdf2GoCore (de.knowwe.rdf2go.Rdf2GoCore)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 File (java.io.File)4 NodePreference (mom.trd.opentheso.bdd.helper.nodes.NodePreference)4 ExportRdf4jHelper (mom.trd.opentheso.core.exports.rdf4j.ExportRdf4jHelper)4 IRI (org.eclipse.rdf4j.model.IRI)4 Statement (org.eclipse.rdf4j.model.Statement)4 Test (org.junit.Test)4