use of org.primefaces.model.DefaultStreamedContent in project opentheso by miledrousset.
the class DownloadBean method thesoCsv2.
/**
* Cette fonction permet d'exporter un thésaurus au format CSV à partir de
* son identifiant.
* Il est filtré par Langue et par Groupe
* 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
* @param selectedLanguages
* @param selectedGroups
* @return
*/
public StreamedContent thesoCsv2(String idTheso, List<NodeLang> selectedLanguages, List<NodeGroup> selectedGroups) {
progress_per_100 = 0;
progress_abs = 0;
ConceptHelper conceptHelper = new ConceptHelper();
sizeOfTheso = conceptHelper.getAllIdConceptOfThesaurus(connect.getPoolConnexion(), idTheso).size();
ExportTabulateHelper exportTabulateHelper = new ExportTabulateHelper();
exportTabulateHelper.setThesaurusDatas(connect.getPoolConnexion(), idTheso, selectedLanguages, selectedGroups);
exportTabulateHelper.exportToTabulate();
StringBuffer temp = exportTabulateHelper.getTabulateBuff();
InputStream stream;
try {
stream = new ByteArrayInputStream(temp.toString().getBytes("UTF-8"));
file = new DefaultStreamedContent(stream, "text/csv", "downloadedCsv.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 thesoCsv.
/**
* Cette fonction permet d'exporter un thésaurus au format CSV à 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 thesoCsv(String idTheso) {
progress_per_100 = 0;
progress_abs = 0;
ConceptHelper conceptHelper = new ConceptHelper();
sizeOfTheso = conceptHelper.getAllIdConceptOfThesaurus(connect.getPoolConnexion(), idTheso).size();
ExportTabulateHelper exportTabulateHelper = new ExportTabulateHelper();
exportTabulateHelper.setThesaurusDatas(connect.getPoolConnexion(), idTheso);
exportTabulateHelper.exportToTabulate();
StringBuffer temp = exportTabulateHelper.getTabulateBuff();
InputStream stream;
try {
stream = new ByteArrayInputStream(temp.toString().getBytes("UTF-8"));
file = new DefaultStreamedContent(stream, "text/csv", "downloadedCsv.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 groupToSkos.
/**
* Cette fonction permet de retourner la branche antière d'un groupe en SKOS
*
* @param idGroup
* @param idTheso
* @return
*/
public StreamedContent groupToSkos(String idGroup, String idTheso) {
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setServerAdress(serverAdress);
exportFromBDD.setServerArk(serverArk);
exportFromBDD.setArkActive(arkActive);
StringBuffer skos_local = exportFromBDD.exportGroup(connect.getPoolConnexion(), idTheso, idGroup);
InputStream stream;
try {
stream = new ByteArrayInputStream(skos_local.toString().getBytes("UTF-8"));
file = new DefaultStreamedContent(stream, "application/xml", idGroup + "_Group_skos.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 conceptToJsonLd.
/**
* Cette fonction permet d'exporter un concept en JsonLd
*
* @param idC
* @param idTheso
* @return
*/
public StreamedContent conceptToJsonLd(String idC, String idTheso) {
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setServerAdress(serverAdress);
exportFromBDD.setServerArk(serverArk);
exportFromBDD.setArkActive(arkActive);
InputStream stream;
StringBuffer skos_local = exportFromBDD.exportConcept(connect.getPoolConnexion(), idTheso, idC);
JsonHelper jsonHelper = new JsonHelper();
SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos_local);
StringBuffer jsonLd = jsonHelper.getJsonLd(sKOSXmlDocument);
if (jsonLd == null) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, languageBean.getMsg("error") + " :", languageBean.getMsg("index.exportJsonError")));
return file;
}
try {
stream = new ByteArrayInputStream(jsonLd.toString().getBytes("UTF-8"));
file = new DefaultStreamedContent(stream, "application/xml", idC + "_jsonLd.xml");
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
}
return file;
// new ExportFromBDD().exportConcept(connect.getPoolConnexion(), idTheso, idC).toString();
}
use of org.primefaces.model.DefaultStreamedContent in project opentheso by miledrousset.
the class DownloadBean method groupToJsonLd.
/**
* Cette fonction permet de retourner la branche entière d'un groupe en
* JsonLd
*
* @param idGroup
* @param idTheso
* @return
*/
public StreamedContent groupToJsonLd(String idGroup, String idTheso) {
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setServerAdress(serverAdress);
exportFromBDD.setServerArk(serverArk);
exportFromBDD.setArkActive(arkActive);
StringBuffer skos_local = exportFromBDD.exportGroup(connect.getPoolConnexion(), idTheso, idGroup);
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", idGroup + "_Group_jsonld.xml");
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
}
return file;
}
Aggregations