use of org.primefaces.model.ByteArrayContent in project opentheso by miledrousset.
the class DownloadBean method brancheToFile.
/**
* Cette fonction permet de retourner une branche en SKOS
*
* @param idConcept
* @param idTheso
* @return
*/
public StreamedContent brancheToFile(String idConcept, String idTheso, int type) {
RDFFormat format = null;
String extention = "";
switch(type) {
case 0:
format = RDFFormat.RDFXML;
extention = "_skos.xml";
break;
case 1:
format = RDFFormat.JSONLD;
extention = "_json-ld.json";
break;
case 2:
format = RDFFormat.TURTLE;
extention = "_turtle.ttl";
break;
}
NodePreference nodePreference = new PreferencesHelper().getThesaurusPreference(connect.getPoolConnexion(), idTheso);
if (nodePreference == null)
return null;
ExportRdf4jHelper exportRdf4jHelper = new ExportRdf4jHelper();
exportRdf4jHelper.setInfos(connect.getPoolConnexion(), "dd-mm-yyyy", false, idTheso, nodePreference.getCheminSite());
exportRdf4jHelper.setNodePreference(nodePreference);
exportRdf4jHelper.addBranch(idTheso, idConcept);
WriteRdf4j writeRdf4j = new WriteRdf4j(exportRdf4jHelper.getSkosXmlDocument());
ByteArrayOutputStream out;
out = new ByteArrayOutputStream();
Rio.write(writeRdf4j.getModel(), out, format);
file = new ByteArrayContent(out.toByteArray(), "application/xml", idTheso + " " + extention);
return file;
}
use of org.primefaces.model.ByteArrayContent in project opentheso by miledrousset.
the class DownloadBean method thesoToFile.
public StreamedContent thesoToFile(String idTheso, List<NodeLang> selectedLanguages, List<NodeGroup> selectedGroups, int type) {
RDFFormat format = null;
String extention = "";
switch(type) {
case 0:
format = RDFFormat.RDFXML;
extention = "_skos.xml";
break;
case 1:
format = RDFFormat.JSONLD;
extention = "_json-ld.json";
break;
case 2:
format = RDFFormat.TURTLE;
extention = "_turtle.ttl";
break;
}
WriteRdf4j writeRdf4j = loadExportHelper(idTheso, selectedLanguages, selectedGroups);
ByteArrayOutputStream out;
out = new ByteArrayOutputStream();
Rio.write(writeRdf4j.getModel(), out, format);
file = new ByteArrayContent(out.toByteArray(), "application/xml", idTheso + " " + extention);
progress_per_100 = 0;
progress_abs = 0;
return file;
}
use of org.primefaces.model.ByteArrayContent in project opentheso by miledrousset.
the class DownloadBean method conceptToFile.
/**
* Cette fonction permet d'exporter un concept en SKOS en temps réel dans la
* page principale
*
* @param idConcept
* @param idTheso
* @param type
* @return
*/
public StreamedContent conceptToFile(String idConcept, String idTheso, int type) {
RDFFormat format = null;
String extention = "";
switch(type) {
case 0:
format = RDFFormat.RDFXML;
extention = "_skos.xml";
break;
case 1:
format = RDFFormat.JSONLD;
extention = "_json-ld.json";
break;
case 2:
format = RDFFormat.TURTLE;
extention = "_turtle.ttl";
break;
case 3:
format = RDFFormat.RDFJSON;
extention = "_turtle.ttl";
break;
}
NodePreference nodePreference = new PreferencesHelper().getThesaurusPreference(connect.getPoolConnexion(), idTheso);
if (nodePreference == null)
return null;
ExportRdf4jHelper exportRdf4jHelper = new ExportRdf4jHelper();
exportRdf4jHelper.setNodePreference(nodePreference);
exportRdf4jHelper.setInfos(connect.getPoolConnexion(), "dd-mm-yyyy", false, idTheso, nodePreference.getCheminSite());
exportRdf4jHelper.setNodePreference(nodePreference);
exportRdf4jHelper.addSignleConcept(idTheso, idConcept);
WriteRdf4j writeRdf4j = new WriteRdf4j(exportRdf4jHelper.getSkosXmlDocument());
ByteArrayOutputStream out;
out = new ByteArrayOutputStream();
Rio.write(writeRdf4j.getModel(), out, format);
file = new ByteArrayContent(out.toByteArray(), "application/xml", idTheso + " " + extention);
return file;
// new ExportFromBDD().exportConcept(connect.getPoolConnexion(), idTheso, idC).toString();
}
Aggregations