use of connexion.ConnexionTest in project opentheso by miledrousset.
the class VerifyArkIdTest method regerateArkId.
@Test
public void regerateArkId() {
String idConcept = "13241";
String idTheso = "TH_1";
String idLang = "fr";
String urlSite = "http://test.frantiq.fr/";
ConnexionTest connexionTest = new ConnexionTest();
HikariDataSource ds = connexionTest.getConnexionPool();
if (ds == null) {
return;
}
ConceptHelper conceptHelper = new ConceptHelper();
conceptHelper.regenerateArkId(ds, idConcept, idLang, idTheso);
ds.close();
}
use of connexion.ConnexionTest in project opentheso by miledrousset.
the class CompareConceptTest method testExportAllDatas.
/**
* Test of Get datas for SiteMap.
*/
@org.junit.Test
public void testExportAllDatas() {
ConnexionTest connexionTest = new ConnexionTest();
HikariDataSource conn = connexionTest.getConnexionPool();
String idTheso = "TH_1";
String idLang = "fr";
String idGroup = "6";
ConceptHelper conceptHelper = new ConceptHelper();
StringPlus stringPlus = new StringPlus();
NodeConcept nodeConcept;
SearchHelper searchHelper = new SearchHelper();
ArrayList<NodeSearch> nodeSearchs;
StringBuilder stringBuilder = new StringBuilder();
// lecture du fichier tabulé /Users/Miled/
String path = "/Users/Miled/Desktop/inist.csv";
FileInputStream file = readFile(path);
if (file == null)
return;
String line;
String lineTmp;
String[] lineOrigine;
boolean first = true;
stringBuilder.append("Numéro BDD\tnom d'origine\tnom PACTOLS\tId PACTOLS\tURL Ark\tDéfinition\tTerme générique\tSynonyme\n");
BufferedReader bf = new BufferedReader(new InputStreamReader(file));
try {
while ((line = bf.readLine()) != null) {
lineOrigine = line.split("\t");
if (lineOrigine.length < 2)
continue;
lineTmp = removeStopWords(lineOrigine[1]);
nodeSearchs = searchHelper.searchTerm(conn, lineTmp, idLang, idTheso, idGroup, 2, false);
stringBuilder.append(lineOrigine[0]);
stringBuilder.append("\t");
stringBuilder.append(lineOrigine[1]);
// stringBuilder.append(" #### ");
stringBuilder.append("\t");
first = true;
for (NodeSearch nodeSearch : nodeSearchs) {
if (!first) {
// stringBuilder.append(" $$$$ ");
stringBuilder.append("\n");
stringBuilder.append("\t");
stringBuilder.append("\t");
}
stringBuilder.append(nodeSearch.getLexical_value());
stringBuilder.append("\t");
stringBuilder.append(nodeSearch.getIdConcept());
// récupération des données d'un Concept
nodeConcept = conceptHelper.getConcept(conn, nodeSearch.getIdConcept(), idTheso, idLang);
// URL
stringBuilder.append("\t");
if (nodeConcept.getConcept().getIdArk() != null || !nodeConcept.getConcept().getIdArk().isEmpty()) {
stringBuilder.append("http://ark.frantiq.fr/ark:/");
stringBuilder.append(nodeConcept.getConcept().getIdArk());
}
// définition
stringBuilder.append("\t");
for (NodeNote nodeNote : nodeConcept.getNodeNotesTerm()) {
if (nodeNote.getNotetypecode().equalsIgnoreCase("definition"))
stringBuilder.append(stringPlus.clearNewLine(nodeNote.getLexicalvalue()));
}
// BT
stringBuilder.append("\t");
for (NodeBT nodeBT : nodeConcept.getNodeBT()) {
stringBuilder.append(nodeBT.getTitle());
}
// UF
stringBuilder.append("\t");
for (NodeEM nodeEM : nodeConcept.getNodeEM()) {
stringBuilder.append(nodeEM.getLexical_value());
}
first = false;
}
System.out.println(stringBuilder.toString());
stringBuilder.delete(0, stringBuilder.capacity());
}
} catch (IOException ex) {
Logger.getLogger(CompareConceptTest.class.getName()).log(Level.SEVERE, null, ex);
}
// ArrayList<NodeConceptArkId> allIds = conceptHelper.getAllConceptArkIdOfThesaurus(conn, idTheso);
// StringBuilder file = new StringBuilder();
/* ArrayList<String> allIds = conceptHelper.getAllIdConceptOfThesaurusByGroup(conn, idTheso, idGroup);
for (String idConcept : allIds) {
nodeConcept = conceptHelper.getConcept(conn, idConcept, idTheso, idLang);
System.out.println("idConcept = " + idConcept + " " + nodeConcept.getTerm().getLexical_value());
}*/
conn.close();
}
use of connexion.ConnexionTest in project opentheso by miledrousset.
the class ExportCandidats method exportCandidatsToCSV.
@Test
public void exportCandidatsToCSV() {
ConnexionTest connexionTest = new ConnexionTest();
HikariDataSource conn = connexionTest.getConnexionPool();
String idTheso = "TH_1";
String idLang = "fr";
ArrayList<String> tabIdCandidats;
boolean passed = false;
StringBuilder file = new StringBuilder();
CandidateHelper candidateHelper = new CandidateHelper();
tabIdCandidats = candidateHelper.getAllCandidatId(conn, idTheso);
if (tabIdCandidats != null) {
if (!tabIdCandidats.isEmpty()) {
file.append("id_candidat");
file.append("\t");
file.append("titre");
file.append("\t");
file.append("langue");
file.append("\t");
file.append("notes contributeurs");
file.append("\t");
file.append("status");
file.append("\t");
file.append("message de l'administrateur");
file.append("\t");
file.append("id_concept");
file.append("\t");
file.append("date création");
file.append("\t");
file.append("date modification");
file.append("\n");
for (String tabIdCandidat : tabIdCandidats) {
file.append(tabIdCandidat);
file.append("\t");
file.append(" ");
file.append("\t");
file.append(" ");
file.append("\t");
file.append(" ");
file.append("\t");
file.append(" ");
file.append("\t");
file.append(" ");
file.append("\t");
file.append(" ");
file.append("\t");
file.append(" ");
file.append("\t");
file.append(" ");
file.append("\n");
}
}
}
System.out.println(file.toString());
conn.close();
}
use of connexion.ConnexionTest in project opentheso by miledrousset.
the class CompareCandidatConceptTest method compareCandidatPactols.
/**
* Test of Get datas for SiteMap.
*/
@org.junit.Test
public void compareCandidatPactols() {
ConnexionTest connexionTest = new ConnexionTest();
HikariDataSource conn = connexionTest.getConnexionPool();
String idTheso = "TH_1";
String idLang = "fr";
String idGroup = "6";
SearchHelper searchHelper = new SearchHelper();
ArrayList<String> nodeSearchTerm;
HashMap<String, String> hashMapSyn;
StringBuilder stringBuilder = new StringBuilder();
// lecture du fichier tabulé /Users/Miled/
// String path = "/Users/Miled/Desktop/candidatsPactols.csv";
String path = "C:/Users/jm.prudham/Desktop/candidatsPactols.csv";
String line;
boolean first;
// stringBuilder.append("Numéro BDD\tnom d'origine\tnom PACTOLS\tId PACTOLS\tURL Ark\tDéfinition\tTerme générique\tSynonyme\n");
// new InputStreamReader(file));
BufferedWriter bw = openFile("C:/Users/jm.prudham/Desktop/candidatsPactols_out.csv");
if (bw == null)
return;
// int i=0;
try {
File file = new File(path);
BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF8"));
while ((line = bf.readLine()) != null) {
/* lineOrigine = line.split("\t");
if(lineOrigine.length < 2) continue;
lineTmp = removeStopWords(lineOrigine[1]);
*/
nodeSearchTerm = searchHelper.simpleSearchPreferredTerm(conn, line.trim(), idLang, idTheso, idGroup);
hashMapSyn = searchHelper.simpleSearchNonPreferredTerm(conn, line.trim(), idLang, idTheso, idGroup);
stringBuilder.append(line.trim());
// stringBuilder.append(" #### ");
stringBuilder.append("\t");
first = true;
for (String term : nodeSearchTerm) {
if (!first) {
stringBuilder.append("##");
}
stringBuilder.append(term);
first = false;
}
stringBuilder.append("\t");
first = true;
for (Map.Entry<String, String> entry : hashMapSyn.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (!first) {
stringBuilder.append("##");
}
stringBuilder.append("Alt: ");
stringBuilder.append(value);
stringBuilder.append("-> Pref: ");
stringBuilder.append(key);
first = false;
}
// System.out.println(stringBuilder.toString());
bw.write(stringBuilder.toString());
bw.newLine();
stringBuilder.delete(0, stringBuilder.capacity());
/* i++;
if(i==1000) {
closeFile(bw);
conn.close();
return;
}*/
}
} catch (IOException ex) {
Logger.getLogger(CompareConceptTest.class.getName()).log(Level.SEVERE, null, ex);
}
closeFile(bw);
conn.close();
}
use of connexion.ConnexionTest 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