use of mom.trd.opentheso.core.jsonld.helper.JsonHelper 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 mom.trd.opentheso.core.jsonld.helper.JsonHelper 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 mom.trd.opentheso.core.jsonld.helper.JsonHelper 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 mom.trd.opentheso.core.jsonld.helper.JsonHelper 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;
}
use of mom.trd.opentheso.core.jsonld.helper.JsonHelper in project opentheso by miledrousset.
the class Rest method getConceptJsonArk.
/**
* retourne un concept à partir de son identifiant Ark
*
* @param naan
* @param ark
* @return
*/
@Path("/jsonld/ark:/{naan}/{ark}")
@GET
// @Produces("application/json")
@Produces("application/json;charset=UTF-8")
public Response getConceptJsonArk(@PathParam("naan") String naan, @PathParam("ark") String ark) {
String idTheso = new ConceptHelper().getIdThesaurusFromArkId(ds, naan + "/" + ark);
if (idTheso == null) {
ds.close();
return Response.noContent().build();
}
if (!getStatusOfWebservices(idTheso)) {
ds.close();
return Response.status(Status.SERVICE_UNAVAILABLE).entity(messageJson()).type(MediaType.APPLICATION_JSON).build();
}
StringBuffer skos = conceptToSkosFromArk(naan + "/" + ark, idTheso);
if (skos == null) {
ds.close();
return Response.ok(messageErreur()).header("Access-Control-Allow-Origin", "*").build();
}
if (skos.length() == 0) {
ds.close();
return Response.ok(messageEmptyJson()).header("Access-Control-Allow-Origin", "*").build();
}
JsonHelper jsonHelper = new JsonHelper();
SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos);
StringBuffer jsonLd = jsonHelper.getJsonLd(sKOSXmlDocument);
ds.close();
return Response.ok(jsonLd.toString()).header("Access-Control-Allow-Origin", "*").build();
// return jsonLd.toString();
}
Aggregations