use of skos.SKOSXmlDocument in project opentheso by miledrousset.
the class JsonHelper method readSkosDocument.
public SKOSXmlDocument readSkosDocument(StringBuffer skosStringBuffer) {
SKOSXmlDocument sKOSXmlDocument;
try {
ReadFileSKOS readFileSKOS = new ReadFileSKOS();
sKOSXmlDocument = readFileSKOS.readStringBuffer(skosStringBuffer);
return sKOSXmlDocument;
} catch (Exception ex) {
Logger.getLogger(JsonHelper.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
use of skos.SKOSXmlDocument in project opentheso by miledrousset.
the class SelectedThesaurus method getMetaData.
/**
* ************************************ GETTERS SETTERS
* *************************************
*/
/**
* @return
*/
public String getMetaData() {
if (this.tree.getSelectedTerme() != null) {
if (this.tree.getSelectedTerme().getIdC() != null) {
if (this.tree.getSelectedTerme().getIdTheso() != null) {
// cas d'un domaine ou Groupe
if (tree.getSelectedTerme().getType() == 1) {
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setNodePreference(nodePreference);
exportFromBDD.setServerArk(serverArk);
exportFromBDD.setServerAdress(cheminSite);
StringBuffer skos = exportFromBDD.exportThisGroup(connect.getPoolConnexion(), this.tree.getSelectedTerme().getIdTheso(), this.tree.getSelectedTerme().getIdC());
JsonHelper jsonHelper = new JsonHelper();
SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos);
StringBuffer jsonLd = jsonHelper.getJsonLdForSchemaOrg(sKOSXmlDocument);
if (jsonLd != null) {
return jsonLd.toString();
} else {
return "";
}
}
// cas d'un concept
if (tree.getSelectedTerme().getType() == 2 || tree.getSelectedTerme().getType() == 3) {
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setNodePreference(nodePreference);
exportFromBDD.setServerArk(serverArk);
exportFromBDD.setServerAdress(cheminSite);
StringBuffer skos = exportFromBDD.exportConcept(connect.getPoolConnexion(), this.tree.getSelectedTerme().getIdTheso(), this.tree.getSelectedTerme().getIdC());
if (skos == null) {
return "";
}
JsonHelper jsonHelper = new JsonHelper();
SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos);
if (sKOSXmlDocument == null) {
return "";
}
StringBuffer jsonLd = jsonHelper.getJsonLdForSchemaOrg(sKOSXmlDocument);
if (jsonLd != null) {
return jsonLd.toString();
} else {
return "";
}
}
}
}
}
// Envoye les domaines (MT)
if (thesaurus != null && thesaurus.getId_thesaurus() != null) {
if (!thesaurus.getId_thesaurus().trim().isEmpty()) {
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setNodePreference(nodePreference);
exportFromBDD.setServerArk(serverArk);
exportFromBDD.setServerAdress(cheminSite);
StringBuffer skos = exportFromBDD.exportGroupsOfThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus());
JsonHelper jsonHelper = new JsonHelper();
SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos);
StringBuffer jsonLd = jsonHelper.getJsonLdForSchemaOrgForConceptScheme(sKOSXmlDocument);
if (jsonLd == null) {
return "";
}
return jsonLd.toString();
}
}
return "";
// ancienne version
/* if(this.tree.getSelectedTerme() != null ) {
if(this.tree.getSelectedTerme().getIdC() != null ) {
if(this.tree.getSelectedTerme().getIdTheso() != null ) {
// cas d'un domaine ou Groupe
if(tree.getSelectedTerme().getType() == 1) {
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setServerArk(serverArk);
exportFromBDD.setServerAdress(cheminSite);
StringBuffer skos = exportFromBDD.exportThisGroup(
connect.getPoolConnexion(),
this.tree.getSelectedTerme().getIdTheso(),
this.tree.getSelectedTerme().getIdC());
JsonHelper jsonHelper = new JsonHelper();
SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos);
StringBuffer jsonLd = jsonHelper.getJsonLd(sKOSXmlDocument);
return jsonLd.toString();
}
// cas d'un concept
if(tree.getSelectedTerme().getType() == 2 || tree.getSelectedTerme().getType() == 3) {
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setServerArk(serverArk);
exportFromBDD.setServerAdress(cheminSite);
StringBuffer skos = exportFromBDD.exportConcept(
connect.getPoolConnexion(),
this.tree.getSelectedTerme().getIdTheso(),
this.tree.getSelectedTerme().getIdC());
JsonHelper jsonHelper = new JsonHelper();
SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos);
StringBuffer jsonLd = jsonHelper.getJsonLd(sKOSXmlDocument);
return jsonLd.toString();
}
}
}
}
// Envoye les domaines (MT)
if(thesaurus.getId_thesaurus() != null) {
if(!thesaurus.getId_thesaurus().trim().isEmpty()) {
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setServerArk(serverArk);
exportFromBDD.setServerAdress(cheminSite);
StringBuffer skos = exportFromBDD.exportGroupsOfThesaurus(
connect.getPoolConnexion(),
thesaurus.getId_thesaurus());
JsonHelper jsonHelper = new JsonHelper();
SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos);
StringBuffer jsonLd = jsonHelper.getJsonLdForConceptScheme(sKOSXmlDocument);
if(jsonLd == null) return "";
return jsonLd.toString();
}
}
return ""; */
}
use of skos.SKOSXmlDocument in project opentheso by miledrousset.
the class DownloadBean method thisGroupToJsonLd.
/**
* Cette fonction permet de retourner pour téléchargement un groupe en
* JsonLd
*
* @param idGroup
* @param idTheso
* @return
*/
public StreamedContent thisGroupToJsonLd(String idGroup, String idTheso) {
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setServerAdress(serverAdress);
exportFromBDD.setServerArk(serverArk);
exportFromBDD.setArkActive(arkActive);
StringBuffer skos_local = exportFromBDD.exportThisGroup(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;
}
use of skos.SKOSXmlDocument in project opentheso by miledrousset.
the class DownloadBean method groupJsonLd.
public String groupJsonLd(String idGroup, String idTheso) {
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setServerAdress(serverAdress);
exportFromBDD.setServerArk(serverArk);
exportFromBDD.setArkActive(arkActive);
StringBuffer skos_local = exportFromBDD.exportThisGroup(connect.getPoolConnexion(), idTheso, idGroup);
JsonHelper jsonHelper = new JsonHelper();
SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos_local);
StringBuffer jsonLd = jsonHelper.getJsonLd(sKOSXmlDocument);
return jsonLd.toString();
}
use of skos.SKOSXmlDocument 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();
}
Aggregations