use of mom.trd.opentheso.bdd.helper.PreferencesHelper in project opentheso by miledrousset.
the class DownloadBean method conceptToFile.
/**
* Cette fonction permet d'exporter un concept en SKOS en temps réel dans la
* page principale
*
* @param idConcept
* @param idTheso
* @param type
* @return
*/
public StreamedContent conceptToFile(String idConcept, String idTheso, int type) {
RDFFormat format = null;
String extention = "";
switch(type) {
case 0:
format = RDFFormat.RDFXML;
extention = "_skos.xml";
break;
case 1:
format = RDFFormat.JSONLD;
extention = "_json-ld.json";
break;
case 2:
format = RDFFormat.TURTLE;
extention = "_turtle.ttl";
break;
case 3:
format = RDFFormat.RDFJSON;
extention = "_turtle.ttl";
break;
}
NodePreference nodePreference = new PreferencesHelper().getThesaurusPreference(connect.getPoolConnexion(), idTheso);
if (nodePreference == null)
return null;
ExportRdf4jHelper exportRdf4jHelper = new ExportRdf4jHelper();
exportRdf4jHelper.setNodePreference(nodePreference);
exportRdf4jHelper.setInfos(connect.getPoolConnexion(), "dd-mm-yyyy", false, idTheso, nodePreference.getCheminSite());
exportRdf4jHelper.setNodePreference(nodePreference);
exportRdf4jHelper.addSignleConcept(idTheso, idConcept);
WriteRdf4j writeRdf4j = new WriteRdf4j(exportRdf4jHelper.getSkosXmlDocument());
ByteArrayOutputStream out;
out = new ByteArrayOutputStream();
Rio.write(writeRdf4j.getModel(), out, format);
file = new ByteArrayContent(out.toByteArray(), "application/xml", idTheso + " " + extention);
return file;
// new ExportFromBDD().exportConcept(connect.getPoolConnexion(), idTheso, idC).toString();
}
use of mom.trd.opentheso.bdd.helper.PreferencesHelper in project opentheso by miledrousset.
the class Rest method brancheOfConceptsToSkosTop.
/**
* Fonction qui permet de récupérer une branche complète en partant d'un
* concept vers le haut
*
* @param idGroup
* @param idThesaurus
* @return skos
*/
private StringBuffer brancheOfConceptsToSkosTop(String idConcept, String idTheso) {
if (ds == null) {
return null;
}
nodePreference = new PreferencesHelper().getThesaurusPreference(ds, idTheso);
if (nodePreference == null) {
return null;
}
ArrayList<String> path = new ArrayList<>();
ArrayList<ArrayList<String>> tabId = new ArrayList<>();
ConceptHelper conceptHelper = new ConceptHelper();
path.add(idConcept);
tabId = conceptHelper.getPathOfConceptWithoutGroup(ds, idConcept, idTheso, path, tabId);
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setServerArk(nodePreference.getServeurArk());
exportFromBDD.setServerAdress(nodePreference.getCheminSite());
exportFromBDD.setNodePreference(nodePreference);
StringBuffer skos = exportFromBDD.exportConceptByLot(ds, idTheso, tabId);
return skos;
}
use of mom.trd.opentheso.bdd.helper.PreferencesHelper in project opentheso by miledrousset.
the class Rest method conceptToSkos.
/**
* Fonction qui permet de récupérer un concept skos par identifiant
*
* @param idConcept
* @param idThesaurus
* @return skos
*/
private StringBuffer conceptToSkos(String idConcept, String idTheso) {
if (ds == null) {
return null;
}
nodePreference = new PreferencesHelper().getThesaurusPreference(ds, idTheso);
if (nodePreference == null) {
return null;
}
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setNodePreference(nodePreference);
exportFromBDD.setServerArk(nodePreference.getServeurArk());
exportFromBDD.setServerAdress(nodePreference.getCheminSite());
StringBuffer skos = exportFromBDD.exportConcept(ds, idTheso, idConcept);
if (skos == null) {
return new StringBuffer("");
}
return skos;
}
use of mom.trd.opentheso.bdd.helper.PreferencesHelper in project opentheso by miledrousset.
the class Rest method getJsonLdDatas.
private String getJsonLdDatas(String value, String idLang, String idTheso) {
ArrayList<String> listId = getListId(value, idLang, idTheso);
NodePreference nodePreference1 = new PreferencesHelper().getThesaurusPreference(ds, idTheso);
if (nodePreference != null) {
ExportRdf4jHelper exportRdf4jHelper = new ExportRdf4jHelper();
exportRdf4jHelper.setNodePreference(nodePreference1);
exportRdf4jHelper.setInfos(ds, "dd-mm-yyyy", false, idTheso, nodePreference1.getCheminSite());
exportRdf4jHelper.setNodePreference(nodePreference1);
for (String idConcept : listId) {
exportRdf4jHelper.addSignleConcept(idTheso, idConcept);
}
WriteRdf4j writeRdf4j = new WriteRdf4j(exportRdf4jHelper.getSkosXmlDocument());
ByteArrayOutputStream out;
out = new ByteArrayOutputStream();
Rio.write(writeRdf4j.getModel(), out, RDFFormat.JSONLD);
// System.out.println(out.toString());
return out.toString();
}
return messageEmptyJson();
}
use of mom.trd.opentheso.bdd.helper.PreferencesHelper in project opentheso by miledrousset.
the class ExportJsonTest method getJson.
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
@Test
public void getJson() {
String idConcept1 = "14767";
String idConcept2 = "36825";
String idTheso = "TH_1";
int type = 3;
RDFFormat format = null;
String extention;
switch(type) {
case 0:
format = RDFFormat.RDFXML;
extention = "_skos.xml";
break;
case 1:
format = RDFFormat.JSONLD;
extention = "_json-ld.json";
break;
case 2:
format = RDFFormat.TURTLE;
extention = "_turtle.ttl";
break;
case 3:
format = RDFFormat.RDFJSON;
extention = "_json.json";
break;
}
HikariDataSource ds;
ConnexionTest connexionTest = new ConnexionTest();
ds = connexionTest.getConnexionPool();
NodePreference nodePreference = new PreferencesHelper().getThesaurusPreference(ds, idTheso);
if (nodePreference != null) {
ExportRdf4jHelper exportRdf4jHelper = new ExportRdf4jHelper();
exportRdf4jHelper.setNodePreference(nodePreference);
exportRdf4jHelper.setInfos(ds, "dd-mm-yyyy", false, idTheso, nodePreference.getCheminSite());
exportRdf4jHelper.setNodePreference(nodePreference);
exportRdf4jHelper.addSignleConcept(idTheso, idConcept1);
exportRdf4jHelper.addSignleConcept(idTheso, idConcept2);
WriteRdf4j writeRdf4j = new WriteRdf4j(exportRdf4jHelper.getSkosXmlDocument());
ByteArrayOutputStream out;
out = new ByteArrayOutputStream();
Rio.write(writeRdf4j.getModel(), out, format);
System.out.println(out.toString());
// file = new ByteArrayContent(out.toByteArray(), "application/xml", idTheso + " " + extention);
}
ds.close();
}
Aggregations