use of skos.SKOSXmlDocument in project opentheso by miledrousset.
the class Rest method getConceptJsonByValue.
/**
* Permet de retourner les Concepts par value (en précisant un thésaurus et
* une langue)
*
* @param value
* @param idLang
* @param idTheso
* @return
*/
@Path("/jsonld/concept/value={value}&lang={lang}&th={th}")
@GET
// @Produces("application/json")
@Produces("application/json;charset=UTF-8")
public Response getConceptJsonByValue(@PathParam("value") String value, @PathParam("lang") String idLang, @PathParam("th") String idTheso) {
if (!getStatusOfWebservices(idTheso)) {
ds.close();
return Response.status(Status.SERVICE_UNAVAILABLE).entity(messageJson()).type(MediaType.APPLICATION_JSON).build();
}
// transforme le codage de la valeur de l'UTF-8
try {
value = URLDecoder.decode(value, "UTF-8");
// System.out.println(URLDecoder.decode("%C3%A9", "UTF-8"));
// System.out.println(URLDecoder.decode("%E9glise", "UTF-8"));
// System.out.println(URLDecoder.decode("%E9glise", "ISO-8859-1"));
// System.out.println(URLDecoder.decode("%E9glise", "US-ASCII"));
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(Rest.class.getName()).log(Level.SEVERE, null, ex);
}
StringBuffer skos = ConceptByValueToSkos(value, idTheso, idLang);
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();
}
use of skos.SKOSXmlDocument in project opentheso by miledrousset.
the class Rest method getAllGroupsJson.
/**
* pour récuperer la liste des domaines d'un thésaurus
*
* @param idTheso
* @return
*/
@Path("/jsonld/concept/th={th}")
@GET
@Produces("application/json;charset=UTF-8")
public Response getAllGroupsJson(@PathParam("th") String idTheso) {
if (!getStatusOfWebservices(idTheso)) {
ds.close();
return Response.status(Status.SERVICE_UNAVAILABLE).entity(messageJson()).type(MediaType.APPLICATION_JSON).build();
}
StringBuffer skos = groupsOfThesaurusToSkos(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.getJsonLdForConceptScheme(sKOSXmlDocument);
ds.close();
return Response.ok(jsonLd.toString()).header("Access-Control-Allow-Origin", "*").build();
// return jsonLd.toString();
}
use of skos.SKOSXmlDocument in project opentheso by miledrousset.
the class Rest method getConceptsJsonOfGroup.
/**
* Pour retourner un domaine (Groupe) en JsonLd avec ses concepts
*
* @param idGroup
* @param idTheso
* @return
*/
@Path("/jsonld/concept/all/idg={idg}&th={th}")
@GET
@Produces("application/json;charset=UTF-8")
public Response getConceptsJsonOfGroup(@PathParam("idg") String idGroup, @PathParam("th") String idTheso) {
if (!getStatusOfWebservices(idTheso)) {
ds.close();
return Response.status(Status.SERVICE_UNAVAILABLE).entity(messageJson()).type(MediaType.APPLICATION_JSON).build();
}
StringBuffer skos = conceptsOfGroupToSkos(idGroup, 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();
}
use of skos.SKOSXmlDocument in project opentheso by miledrousset.
the class TestImportBranch method TestImportMultiBranchUnderGroup.
/**
* Test of Tabulate reading.
*/
/* @org.junit.Test
public void testImportBranchAfterGroup() {
HikariDataSource conn = openConnexionPool();
String idTheso = "";
String idGroup = "";
String path = "/Users/Miled/ownCloud_cnrs/Projets/OpenTheso/artefacts/25.xml";
String dateFromat = "yyyy-MM-dd";
boolean useArk = false;
String adresseSite = "http://localhost";
int idUser = 1;
FileInputStream file = readFile(path);
SKOSXmlDocument sKOSXmlDocument = readSkosFile(conn,
file,
dateFromat,
useArk,
adresseSite);
// permet d'importer une branche entière sous un domaine avec l'alignement automatique à la source
WriteBranchSkosBDD writeBranchSkosBDD = new WriteBranchSkosBDD(conn);
//idGroup, idThesaurus, sKOSXmlDocument, dateFormat, ark, adressSite, user);
writeBranchSkosBDD.importBranchAfterGroup(
idGroup,
idTheso,
sKOSXmlDocument, dateFromat, useArk,
adresseSite, idUser);
}*/
/**
* Test of Tabulate reading.
*/
@org.junit.Test
public void TestImportMultiBranchUnderGroup() {
HikariDataSource conn = openConnexionPool();
String idTheso = "1";
String idGroup = "";
String path = "/Users/Miled/ownCloud_cnrs/GDS_FRANTIQ/Pactols/2016-11-15/Sujets.xml";
String dateFromat = "yyyy-MM-dd";
boolean useArk = false;
String adresseSite = "http://localhost";
int idUser = 1;
FileInputStream file = readFile(path);
SKOSXmlDocument sKOSXmlDocument = readSkosFile(conn, file, dateFromat, useArk, adresseSite);
// permet d'importer une branche entière avec son domaine en intégrant l'alignement à la source
WriteBranchSkosBDD writeBranchSkosBDD = new WriteBranchSkosBDD(conn);
// idGroup, idThesaurus, sKOSXmlDocument, dateFormat, ark, adressSite, user);
writeBranchSkosBDD.importMultiBranchUnderGroup(idTheso, idGroup, sKOSXmlDocument, dateFromat, useArk, adresseSite, idUser);
}
use of skos.SKOSXmlDocument in project opentheso by miledrousset.
the class TestImportBranch method readSkosFile.
private SKOSXmlDocument readSkosFile(HikariDataSource conn, FileInputStream file, String dateFromat, boolean useArk, String adresseSite) {
try {
ReadFileSKOS readFileSKOS = new ReadFileSKOS();
readFileSKOS.readBranchFile(conn, file, dateFromat, useArk, adresseSite);
SKOSXmlDocument sKOSXmlDocument = readFileSKOS.getThesaurus();
return sKOSXmlDocument;
} catch (Exception ex) {
Logger.getLogger(TestImportBranch.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
Aggregations