use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.
the class SearchHelper method generatePermutedTable.
/**
* Cette fonction permet de générer la table Permuted d'après les tables
* PreferredTerm et NonPreferredTerm
*
* @param ds
* @param idThesaurus
* @return ArrayList de NodePermute
*/
public boolean generatePermutedTable(HikariDataSource ds, String idThesaurus) {
ConceptHelper conceptHelper = new ConceptHelper();
TermHelper termHelper = new TermHelper();
ArrayList<NodeTermTraduction> nodeTermTraductionList;
ArrayList<NodeEM> nodeEMList;
// suppression des données de la table Permuted pour un thésaurus
termHelper.deletePermutedTable(ds, idThesaurus);
// Génération des Termes Préférés (PreferredTerm)
ArrayList<String> tabIdConcept = conceptHelper.getAllIdConceptOfThesaurus(ds, idThesaurus);
for (String idConcept : tabIdConcept) {
nodeTermTraductionList = termHelper.getAllTraductionsOfConcept(ds, idConcept, idThesaurus);
for (NodeTermTraduction nodeTermTraduction : nodeTermTraductionList) {
// cette fonction permet de remplir la table Permutée
termHelper.splitConceptForPermute(ds, idConcept, new ConceptHelper().getGroupIdOfConcept(ds, idConcept, idThesaurus), idThesaurus, nodeTermTraduction.getLang(), nodeTermTraduction.getLexicalValue());
}
}
// Génération des Termes Synonymes (NonPreferredTerm)
ArrayList<NodeTab2Levels> tabIdNonPreferredTerm = termHelper.getAllIdOfNonPreferredTerms(ds, idThesaurus);
for (NodeTab2Levels nodeTab2Levels : tabIdNonPreferredTerm) {
nodeEMList = termHelper.getAllNonPreferredTerms(ds, nodeTab2Levels.getIdTerm(), idThesaurus);
for (NodeEM nodeEM : nodeEMList) {
// cette fonction permet de remplir la table Permutée
termHelper.splitConceptForNonPermuted(ds, nodeTab2Levels.getIdConcept(), new ConceptHelper().getGroupIdOfConcept(ds, nodeTab2Levels.getIdConcept(), idThesaurus), idThesaurus, nodeEM.getLang(), nodeEM.getLexical_value());
}
}
return true;
}
use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.
the class SelectedTerme method majLangueConcept.
public void majLangueConcept() {
langues = new ArrayList<>();
ArrayList<NodeTermTraduction> tempNTT = new TermHelper().getTraductionsOfConcept(connect.getPoolConnexion(), idC, idTheso, idlangue);
HashMap<String, String> tempMapL = new HashMap<>();
for (NodeTermTraduction ntt : tempNTT) {
tempMapL.put(ntt.getLang(), ntt.getLexicalValue());
}
langues.addAll(tempMapL.entrySet());
}
use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.
the class SelectedTerme method creerTradterme.
/**
* Ajoute une traduction au terme courant et met l'affichage à jour
*/
public void creerTradterme() {
if (valueEdit == null || valueEdit.trim().equals("")) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error3")));
return;
}
boolean tradExist = false;
// c'est le cas ou le concept n'a pas de traduction dans la langue en cours, il faut le mettre a jour dans l'arbre
boolean newTraduction = false;
for (Entry<String, String> e : langues) {
if (e.getKey().equals(langueEdit)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
tradExist = true;
break;
}
}
ConceptHelper ch = new ConceptHelper();
TermHelper termHelper = new TermHelper();
if (idT.isEmpty()) {
newTraduction = true;
String tmp = termHelper.getIdTermOfConcept(connect.getPoolConnexion(), idC, idTheso);
if (tmp != null) {
idT = tmp;
}
}
// traduction du domaine
if (type == 1 && !tradExist) {
ConceptGroupLabel cgl = new ConceptGroupLabel();
cgl.setLexicalvalue(valueEdit);
cgl.setIdgroup(idDomaine);
cgl.setIdthesaurus(idTheso);
cgl.setLang(langueEdit);
GroupHelper cgh = new GroupHelper();
if (cgh.isDomainExist(connect.getPoolConnexion(), cgl.getLexicalvalue(), cgl.getIdthesaurus(), cgl.getLang())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
return;
}
if (!cgh.addGroupTraduction(connect.getPoolConnexion(), cgl, user.getUser().getId())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
return;
}
ArrayList<NodeGroupTraductions> tempNGT = new GroupHelper().getGroupTraduction(connect.getPoolConnexion(), idDomaine, idTheso, idlangue);
langues = new ArrayList<>();
HashMap<String, String> tempMapL = new HashMap<>();
for (NodeGroupTraductions ngt : tempNGT) {
tempMapL.put(ngt.getIdLang(), ngt.getTitle());
}
if (newTraduction) {
nom = cgh.getLexicalValueOfGroup(connect.getPoolConnexion(), idDomaine, idTheso, idlangue);
}
langues.addAll(tempMapL.entrySet());
// traduction du TT
} else if (type == 2 && !tradExist) {
Term terme = new Term();
terme.setId_thesaurus(idTheso);
terme.setLang(langueEdit);
terme.setLexical_value(valueEdit);
terme.setId_term(idT);
terme.setContributor(user.getUser().getId());
terme.setCreator(user.getUser().getId());
terme.setSource("");
terme.setStatus("");
if (termHelper.isTermExist(connect.getPoolConnexion(), terme.getLexical_value(), terme.getId_thesaurus(), terme.getLang())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
return;
}
if (!ch.addTopConceptTraduction(connect.getPoolConnexion(), terme, user.getUser().getId())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
return;
}
ArrayList<NodeTermTraduction> tempNTT = termHelper.getTraductionsOfConcept(connect.getPoolConnexion(), idC, idTheso, idlangue);
langues = new ArrayList<>();
HashMap<String, String> tempMapL = new HashMap<>();
for (NodeTermTraduction ntt : tempNTT) {
tempMapL.put(ntt.getLang(), ntt.getLexicalValue());
}
if (newTraduction) {
nom = termHelper.getThisTerm(connect.getPoolConnexion(), idC, idTheso, idlangue).getLexical_value();
}
langues.addAll(tempMapL.entrySet());
// traduction des concepts
} else if (type == 3 && !tradExist) {
Term terme = new Term();
terme.setId_thesaurus(idTheso);
terme.setLang(langueEdit);
terme.setLexical_value(valueEdit);
terme.setId_term(idT);
terme.setContributor(user.getUser().getId());
terme.setCreator(user.getUser().getId());
terme.setSource("");
terme.setStatus("");
if (termHelper.isTermExist(connect.getPoolConnexion(), terme.getLexical_value(), terme.getId_thesaurus(), terme.getLang())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
return;
}
if (!ch.addConceptTraduction(connect.getPoolConnexion(), terme, user.getUser().getId())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
return;
}
ArrayList<NodeTermTraduction> tempNTT = termHelper.getTraductionsOfConcept(connect.getPoolConnexion(), idC, idTheso, idlangue);
langues = new ArrayList<>();
HashMap<String, String> tempMapL = new HashMap<>();
for (NodeTermTraduction ntt : tempNTT) {
tempMapL.put(ntt.getLang(), ntt.getLexicalValue());
}
langues.addAll(tempMapL.entrySet());
if (newTraduction) {
nom = termHelper.getThisTerm(connect.getPoolConnexion(), idC, idTheso, idlangue).getLexical_value();
}
}
langueEdit = "";
valueEdit = "";
if (!tradExist) {
vue.setAddTrad(0);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sTerme.info2")));
}
}
use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.
the class GetAllArkTest method testExportAllDatas.
/**
* Test of Get datas for SiteMap.
*/
@org.junit.Test
public void testExportAllDatas() {
HikariDataSource conn = openConnexionPool();
String idTheso = "TH_1";
ConceptHelper conceptHelper = new ConceptHelper();
ArrayList<NodeConceptArkId> allIds = conceptHelper.getAllConceptArkIdOfThesaurus(conn, idTheso);
StringBuilder file = new StringBuilder();
TermHelper termHelper = new TermHelper();
NoteHelper noteHelper = new NoteHelper();
ArrayList<NodeTermTraduction> nodeTermTraductions;
String idTerme;
ArrayList<NodeNote> nodeNote;
boolean passed = false;
boolean notePassed = false;
String note = "";
for (NodeConceptArkId ids : allIds) {
file.append(ids.getIdConcept());
file.append("\t");
if (ids.getIdArk() == null || ids.getIdArk().isEmpty()) {
file.append("");
} else {
file.append(ids.getIdArk().substring(ids.getIdArk().indexOf("/") + 1));
}
nodeTermTraductions = termHelper.getAllTraductionsOfConcept(conn, ids.getIdConcept(), idTheso);
if (!nodeTermTraductions.isEmpty()) {
for (NodeTermTraduction nodeTermTraduction : nodeTermTraductions) {
if (nodeTermTraduction.getLang().equalsIgnoreCase("fr")) {
file.append("\t");
file.append(nodeTermTraduction.getLexicalValue());
// file.append("(");
// file.append(nodeTermTraduction.getLang());
// file.append(")");
}
}
}
idTerme = termHelper.getIdTermOfConcept(conn, ids.getIdConcept(), idTheso);
nodeNote = noteHelper.getListNotesTerm(conn, idTerme, idTheso, "fr");
for (NodeNote nodeNote1 : nodeNote) {
if (nodeNote1.getLang().equalsIgnoreCase("fr")) {
if (nodeNote1.getNotetypecode().equalsIgnoreCase("definition")) {
note = nodeNote1.getLexicalvalue().replace('\r', ' ');
note = note.replace('\n', ' ');
if (!notePassed) {
file.append("\t");
} else {
file.append(" ## ");
}
file.append(note);
passed = true;
notePassed = true;
}
}
}
if (!passed) {
file.append("\t");
file.append(" ");
}
passed = false;
notePassed = false;
file.append("\n");
}
System.out.println(file.toString());
conn.close();
}
use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.
the class ExportRdf4jHelper method writeConceptInfo.
private void writeConceptInfo(ConceptHelper conceptHelper, SKOSResource sKOSResource, String idThesaurus, String idOfConceptChildren, DownloadBean downloadBean, List<NodeLang> selectedLanguages) {
NodeConceptExport nodeConcept = conceptHelper.getConceptForExport(ds, idOfConceptChildren, idThesaurus, false);
if (nodeConcept == null) {
return;
}
sKOSResource.setUri(getUri(nodeConcept));
sKOSResource.setProperty(SKOSProperty.Concept);
// prefLabel
for (NodeTermTraduction traduction : nodeConcept.getNodeTermTraductions()) {
boolean isInselectedLanguages = false;
for (NodeLang nodeLang : selectedLanguages) {
if (nodeLang.getCode().equals(traduction.getLang())) {
isInselectedLanguages = true;
break;
}
}
if (isInselectedLanguages) {
sKOSResource.addLabel(traduction.getLexicalValue(), traduction.getLang(), SKOSProperty.prefLabel);
}
}
// altLabel
for (NodeEM nodeEM : nodeConcept.getNodeEM()) {
boolean isInselectedLanguages = false;
for (NodeLang nodeLang : selectedLanguages) {
if (nodeLang.getCode().equals(nodeEM.getLang())) {
isInselectedLanguages = true;
break;
}
}
if (isInselectedLanguages) {
sKOSResource.addLabel(nodeEM.getLexical_value(), nodeEM.getLang(), SKOSProperty.altLabel);
}
}
ArrayList<NodeNote> nodeNotes = nodeConcept.getNodeNoteConcept();
nodeNotes.addAll(nodeConcept.getNodeNoteTerm());
addNoteGiven(nodeNotes, sKOSResource, selectedLanguages);
addGPSGiven(nodeConcept.getNodeGps(), sKOSResource);
addAlignementGiven(nodeConcept.getNodeAlignmentsList(), sKOSResource);
addRelationGiven(nodeConcept.getNodeListOfBT(), nodeConcept.getNodeListOfNT(), nodeConcept.getNodeListIdsOfRT(), sKOSResource, nodeConcept.getConcept().getIdThesaurus());
String notation = nodeConcept.getConcept().getNotation();
String created = nodeConcept.getConcept().getCreated().toString();
String modified = nodeConcept.getConcept().getModified().toString();
if (notation != null && !notation.equals("null")) {
sKOSResource.addNotation(notation);
}
if (created != null) {
sKOSResource.addDate(created, SKOSProperty.created);
}
if (modified != null) {
sKOSResource.addDate(modified, SKOSProperty.modified);
}
sKOSResource.addRelation(getUriFromId(idTheso), SKOSProperty.inScheme);
sKOSResource.addIdentifier(nodeConcept.getConcept().getIdConcept(), SKOSProperty.identifier);
downloadBean.setProgress_abs(downloadBean.getProgress_abs() + 1);
double progress = (downloadBean.getProgress_abs() / downloadBean.getSizeOfTheso()) * 100;
if (progress > 100) {
progress = 100;
}
downloadBean.setProgress_per_100((int) progress);
skosXmlDocument.addconcept(sKOSResource);
}
Aggregations