use of org.primefaces.model.DefaultStreamedContent in project opentheso by miledrousset.
the class DownloadBean method thesoTxtCsv.
/**
* Permet d'exporter le thésauurus au format txt (tabulé et hiérarchisé)
* avec des options de colonnes supplémentaires NT, BT, RT, Notes, traductions
* ceci figure dans le tableau (String[] selectedOptions)
* @param idTheso
* @param selectedGroups
* @param codeLang
* @param selectedOptions
* @return
* MR
*/
public StreamedContent thesoTxtCsv(String idTheso, List<NodeGroup> selectedGroups, String codeLang, ArrayList<String> selectedOptions) {
progress_per_100 = 0;
progress_abs = 0;
NodePreference nodePreference = new PreferencesHelper().getThesaurusPreference(connect.getPoolConnexion(), idTheso);
if (nodePreference == null)
return null;
ExportTxtHelper exportTxtHelper = new ExportTxtHelper();
exportTxtHelper.setThesaurusDatas(connect.getPoolConnexion(), idTheso, codeLang, selectedGroups, nodePreference, selectedOptions);
exportTxtHelper.exportToTxtCsv();
InputStream stream;
try {
stream = new ByteArrayInputStream(exportTxtHelper.getTxtBuff().toString().getBytes("UTF-8"));
file = new DefaultStreamedContent(stream, "text/csv", "Txt_" + idTheso + ".csv");
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
}
return file;
}
use of org.primefaces.model.DefaultStreamedContent in project opentheso by miledrousset.
the class DownloadBean method thesoSkos.
/**
* Cette fonction permet d'exporter un thésaurus au format SKOS à partir de
* son identifiant. Le résultat est enregistré dans la variable 'skos' du
* downloadBean si la taille est petite, ou dans la variable 'file' du
* downloadBean sinon. Dans le premier cas on affiche la variable, dans le
* second cas l'utilisateur télécharge de fichier.
*
* @param idTheso
* @return
*/
public StreamedContent thesoSkos(String idTheso) {
/**
* Cette initialisation est pour exporter les PACTOLS au format accepté
* par Koha
*/
// ExportFromBDD_Frantiq exportFromBDD = new ExportFromBDD_Frantiq();
/**
* ici c'est la classe à utiliser pour un export standard au foramt SKOS
*/
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setServerAdress(serverAdress);
exportFromBDD.setServerArk(serverArk);
exportFromBDD.setArkActive(arkActive);
StringBuffer skos_local = exportFromBDD.exportThesaurus(connect.getPoolConnexion(), idTheso);
InputStream stream;
try {
stream = new ByteArrayInputStream(skos_local.toString().getBytes("UTF-8"));
file = new DefaultStreamedContent(stream, "application/xml", idTheso + "_skos.xml");
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
}
vue.setThesoToSkosCsvFile(true);
return file;
/* if (temp.length() <= 1500000) {
skos = temp.toString();
vue.setThesoToSkosCsv(true);
} else {
InputStream stream;
try {
stream = new ByteArrayInputStream(temp.toString().getBytes("UTF-8"));
file = new DefaultStreamedContent(stream, "application/xml ", "downloadedSkos.xml");
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
}
vue.setThesoToSkosCsvFile(true);
}*/
}
use of org.primefaces.model.DefaultStreamedContent in project opentheso by miledrousset.
the class DownloadBean method brancheToJsonLd.
/**
* Cette fonction permet de retourner une branche en JsonLd
*
* @param idConcept
* @param idTheso
* @return
*/
public StreamedContent brancheToJsonLd(String idConcept, String idTheso) {
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setServerAdress(serverAdress);
exportFromBDD.setServerArk(serverArk);
exportFromBDD.setArkActive(arkActive);
StringBuffer skos_local = exportFromBDD.exportBranchOfConcept(connect.getPoolConnexion(), idTheso, idConcept);
JsonHelper jsonHelper = new JsonHelper();
SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos_local);
StringBuffer jsonLd = jsonHelper.getJsonLd(sKOSXmlDocument);
InputStream stream;
try {
stream = new ByteArrayInputStream(jsonLd.toString().getBytes("UTF-8"));
file = new DefaultStreamedContent(stream, "application/xml", idConcept + "_Branch_jsonld.xml");
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
}
return file;
}
use of org.primefaces.model.DefaultStreamedContent in project opentheso by miledrousset.
the class DownloadBean method thesoSkosFrantiq.
/**
* Cette fonction permet d'exporter un thésaurus au format SKOS à partir de
* son identifiant. Le résultat est enregistré dans la variable 'skos' du
* downloadBean si la taille est petite, ou dans la variable 'file' du
* downloadBean sinon. Dans le premier cas on affiche la variable, dans le
* second cas l'utilisateur télécharge de fichier.
*
* @param idTheso
*/
public void thesoSkosFrantiq(String idTheso) {
/**
* Cette initialisation est pour exporter les PACTOLS au format accepté
* par Koha
*/
ExportFromBDD_Frantiq exportFromBDD = new ExportFromBDD_Frantiq();
/**
* ici c'est la classe à utiliser pour un export standard au foramt SKOS
*/
// ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setServerAdress(serverAdress);
exportFromBDD.setServerArk(serverArk);
exportFromBDD.setArkActive(arkActive);
StringBuffer temp = exportFromBDD.exportThesaurus(connect.getPoolConnexion(), idTheso);
if (temp.length() <= 1500000) {
skos = temp.toString();
vue.setThesoToSkosCsv(true);
} else {
InputStream stream;
try {
stream = new ByteArrayInputStream(temp.toString().getBytes("UTF-8"));
file = new DefaultStreamedContent(stream, "application/xml ", "downloadedSkos.xml");
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
}
vue.setThesoToSkosCsvFile(true);
}
}
use of org.primefaces.model.DefaultStreamedContent in project opentheso by miledrousset.
the class DownloadBean method thesoPDF.
public StreamedContent thesoPDF(String idTheso, List<NodeLang> selectedLanguages, List<NodeGroup> selectedGroups, String codeLang, String codeLang2, int type) {
progress_per_100 = 0;
progress_abs = 0;
NodePreference nodePreference = new PreferencesHelper().getThesaurusPreference(connect.getPoolConnexion(), idTheso);
if (nodePreference == null)
return null;
sizeOfTheso = new ConceptHelper().getAllIdConceptOfThesaurus(connect.getPoolConnexion(), idTheso).size();
ExportRdf4jHelper exportRdf4jHelper = new ExportRdf4jHelper();
exportRdf4jHelper.setInfos(connect.getPoolConnexion(), "dd-mm-yyyy", false, idTheso, nodePreference.getCheminSite());
exportRdf4jHelper.setNodePreference(nodePreference);
exportRdf4jHelper.addThesaurus(idTheso, selectedLanguages);
exportRdf4jHelper.addGroup(idTheso, selectedLanguages, selectedGroups);
exportRdf4jHelper.addConcept(idTheso, this, selectedLanguages);
WritePdf writePdf = new WritePdf(exportRdf4jHelper.getSkosXmlDocument(), codeLang, codeLang2, type);
InputStream stream;
stream = new ByteArrayInputStream(writePdf.getOutput().toByteArray());
file = new DefaultStreamedContent(stream, "application/pdf", "test.pdf");
return file;
}
Aggregations