use of mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch in project opentheso by miledrousset.
the class SearchHelper method searchNote.
/**
* Cette fonction permet de faire une recherche par value sur les notes
*
* @param ds
* @param value
* @param idLang
* @param idThesaurus
* @param idGroup
* @param startByOrContain //1=contient 2=commence par
* @return
*/
public ArrayList<NodeSearch> searchNote(HikariDataSource ds, String value, String idLang, String idThesaurus, String idGroup, int startByOrContain) {
Connection conn;
Statement stmt;
ResultSet resultSet;
ArrayList<NodeSearch> nodeSearchList = new ArrayList<>();
value = new StringPlus().convertString(value);
String[] values = value.trim().split(" ");
String query;
String langNote;
String group;
String multivaluesNote = "";
// préparation de la valeur à rechercher
if (startByOrContain == 1) {
// contient
for (String value1 : values) {
multivaluesNote += " and unaccent_string(note.lexicalvalue) ilike" + " unaccent_string('%" + value1 + "%')";
}
}
if (startByOrContain == 2) {
// commence par
multivaluesNote += " and (unaccent_string(note.lexicalvalue) ilike" + " unaccent_string('" + value + "%')" + " OR unaccent_string(note.lexicalvalue) ilike" + " unaccent_string('% " + value + "%'))";
}
// préparation de la requête en focntion du choix (toutes les langues ou langue donnée)
if (idLang.isEmpty()) {
langNote = "";
} else {
langNote = " and note.lang ='" + idLang + "'";
}
// cas du choix d'un group
if (idGroup.isEmpty()) {
group = "";
} else {
group = " and idgroup = '" + idGroup + "'";
}
try {
conn = ds.getConnection();
try {
stmt = conn.createStatement();
try {
// notes des terms
query = "SELECT concept.id_concept, concept.id_thesaurus," + " concept.top_concept, idgroup," + " note.lang, note.lexicalvalue," + " note.id_term " + " FROM preferred_term, note, concept,concept_group_concept" + " WHERE " + "concept_group_concept.idthesaurus = concept.id_thesaurus AND " + "concept.id_concept = concept_group_concept.idconcept AND " + " preferred_term.id_term = note.id_term" + " AND" + " preferred_term.id_thesaurus = note.id_thesaurus" + " AND" + " concept.id_concept = preferred_term.id_concept" + " AND" + " concept.id_thesaurus = preferred_term.id_thesaurus" + " AND" + " note.id_thesaurus = '" + idThesaurus + "'" + multivaluesNote + langNote + group + " order by lexicalvalue ASC LIMIT 200";
resultSet = stmt.executeQuery(query);
while (resultSet.next()) {
NodeSearch nodeSearch = new NodeSearch();
nodeSearch.setLexical_value(resultSet.getString("lexicalvalue"));
nodeSearch.setIdConcept(resultSet.getString("id_concept"));
nodeSearch.setIdTerm(resultSet.getString("id_term"));
nodeSearch.setIdGroup(resultSet.getString("idgroup"));
nodeSearch.setIdLang(resultSet.getString("lang"));
nodeSearch.setIdThesaurus(idThesaurus);
nodeSearch.setTopConcept(resultSet.getBoolean("top_concept"));
nodeSearch.setPreferredLabel(true);
nodeSearchList.add(nodeSearch);
}
// notes des concepts
query = "SELECT concept.id_concept, concept.id_thesaurus," + " concept.top_concept, idgroup," + " note.lang, note.lexicalvalue," + " preferred_term.id_term " + " FROM preferred_term, note, concept, concept_group_concept" + " WHERE " + "concept_group_concept.idconcept = concept.id_concept AND " + "concept_group_concept.idthesaurus = concept.id_thesaurus AND " + " preferred_term.id_concept = note.id_concept" + " AND" + " preferred_term.id_thesaurus = note.id_thesaurus" + " AND" + " concept.id_concept = preferred_term.id_concept" + " AND" + " concept.id_thesaurus = preferred_term.id_thesaurus" + " AND" + " note.id_thesaurus = '" + idThesaurus + "'" + multivaluesNote + langNote + group + " order by lexicalvalue ASC LIMIT 200";
resultSet = stmt.executeQuery(query);
while (resultSet.next()) {
NodeSearch nodeSearch = new NodeSearch();
nodeSearch.setLexical_value(resultSet.getString("lexicalvalue"));
nodeSearch.setIdConcept(resultSet.getString("id_concept"));
nodeSearch.setIdTerm(resultSet.getString("id_term"));
nodeSearch.setIdGroup(resultSet.getString("idgroup"));
nodeSearch.setIdLang(resultSet.getString("lang"));
nodeSearch.setIdThesaurus(idThesaurus);
nodeSearch.setTopConcept(resultSet.getBoolean("top_concept"));
nodeSearch.setPreferredLabel(true);
nodeSearchList.add(nodeSearch);
}
} finally {
stmt.close();
}
} finally {
conn.close();
}
} catch (SQLException ex) {
Logger.getLogger(SearchHelper.class.getName()).log(Level.SEVERE, null, ex);
}
return nodeSearchList;
}
use of mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch in project opentheso by miledrousset.
the class SelectedTerme method reInitTerme.
/**
* Vide toutes les informations du terme
*/
public void reInitTerme() {
root = (TreeNode) new DefaultTreeNode("Root", null);
nom = "";
nomEdit = "";
termeGenerique = new ArrayList<>();
termesSpecifique = new ArrayList<>();
termesAssocies = new ArrayList<>();
termesSynonymesE = new ArrayList<>();
termesSynonymesP = new ArrayList<>();
langues = new ArrayList<>();
images = new ArrayList<>();
align = new ArrayList<>();
note = "";
definition = "";
noteApplication = "";
noteHistorique = "";
noteEditoriale = "";
idT = "";
idC = null;
status = "";
notation = "";
idTheso = "";
idlangue = "";
idDomaine = "";
idTopConcept = "";
nbNotices = 0;
urlNotice = "";
microTheso = "";
dateC = "";
dateM = "";
idArk = "";
idHandle = "";
type = 1;
valueEdit = "";
langueEdit = "";
statutEdit = "";
nodeSe = new NodeSearch();
nodeGroupIdLabel = new ArrayList<>();
}
use of mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch in project opentheso by miledrousset.
the class SearchBean method research.
public void research() {
result1 = new ArrayList<>();
result2 = new ArrayList<>();
if (typeSearch == 1) {
// ALPHABETIQUE/HIERARCHIQUE
if (typeValueSearch == 0) {
if (onlyNote) {
result1 = new SearchHelper().searchNote(connect.getPoolConnexion(), entry, langue.trim(), theso.getThesaurus().getId_thesaurus(), idGroup, startByOrContain);
} else {
if (onlyNotation) {
result1 = new SearchHelper().searchNotation(connect.getPoolConnexion(), entry, langue.trim(), theso.getThesaurus().getId_thesaurus(), idGroup);
} else {
result1 = new SearchHelper().searchTerm(connect.getPoolConnexion(), entry, langue.trim(), theso.getThesaurus().getId_thesaurus(), idGroup, startByOrContain, withNote);
}
}
} else if (typeValueSearch == 1) {
// idC
result1 = new SearchHelper().searchIdConcept(connect.getPoolConnexion(), entry, theso.getThesaurus().getId_thesaurus(), theso.getWorkLanguage());
}
nbRes = result1.size();
} else if (typeSearch == 2) {
// PERMUTEE
if (typeValueSearch == 0) {
// Terme
if (idGroup == null || idGroup.equals("")) {
result2 = new SearchHelper().getListPermute(connect.getPoolConnexion(), theso.getThesaurus().getId_thesaurus(), langue.trim(), entry);
// result2.addAll(new SearchHelper().getListPermuteNonPreferredTerm(connect.getPoolConnexion(), theso.getThesaurus().getId_thesaurus(), langue.trim(), entry));
} else {
result2 = new SearchHelper().getListPermute(connect.getPoolConnexion(), theso.getThesaurus().getId_thesaurus(), langue.trim(), entry, idGroup);
// result2.addAll(new SearchHelper().getListPermuteNonPreferredTerm(connect.getPoolConnexion(), theso.getThesaurus().getId_thesaurus(), langue.trim(), entry, idGroup));
}
nbRes = result2.size();
} else if (typeValueSearch == 1) {
// idC
typeSearch = 1;
result1 = new SearchHelper().searchIdConcept(connect.getPoolConnexion(), entry, theso.getThesaurus().getId_thesaurus());
nbRes = result1.size();
}
}
if (!langue.isEmpty()) {
if (!langue.trim().equals(theso.getThesaurus().getLanguage())) {
theso.getThesaurus().setLanguage(langue.trim());
theso.update();
}
}
for (NodeSearch ns : result1) {
String temp;
if (typeValueSearch == 1) {
temp = new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), ns.getIdGroup(), theso.getThesaurus().getId_thesaurus(), theso.getWorkLanguage());
} else
temp = new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), ns.getIdGroup(), theso.getThesaurus().getId_thesaurus(), theso.getThesaurus().getLanguage());
ns.setGroupLabel(temp);
}
theso.getVue().setOnglet(1);
}
use of mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch in project opentheso by miledrousset.
the class ConceptHelper method getMultiConceptForExport.
/**
* Cette fonction permet de récupérer toutes les informations concernant un
* ou plusieurs Concept par une chaîne de caractère, suivant le thésaurus,
* la langue et le group
*
* @param ds
* @param value
* @param idThesaurus
* @param idGroup
* @param idLang
* @param isArkActif
* @return Objet class NodeConcept
*/
public ArrayList<NodeConceptExport> getMultiConceptForExport(HikariDataSource ds, String value, String idLang, String idGroup, String idThesaurus, boolean isArkActif) {
ArrayList<NodeConceptExport> listNce = new ArrayList<>();
// Récupération des concept
ArrayList<NodeSearch> listRes = new SearchHelper().searchTerm(ds, value, idLang, idThesaurus, idGroup, 1, false);
for (NodeSearch ns : listRes) {
Concept concept = getThisConcept(ds, ns.getIdConcept(), idThesaurus);
NodeConceptExport nce = new NodeConceptExport();
nce.setConcept(concept);
listNce.add(nce);
}
for (NodeConceptExport nce : listNce) {
String idConcept = nce.getConcept().getIdConcept();
RelationsHelper relationsHelper = new RelationsHelper();
// récupération des BT
ArrayList<NodeHieraRelation> nodeListIdOfBT_Ark = relationsHelper.getListBT(ds, idConcept, idThesaurus);
nce.setNodeListOfBT(nodeListIdOfBT_Ark);
// récupération des termes spécifiques
ArrayList<NodeHieraRelation> nodeListIdOfNT_Ark = relationsHelper.getListNT(ds, idConcept, idThesaurus);
nce.setNodeListOfNT(nodeListIdOfNT_Ark);
// récupération des termes associés
ArrayList<NodeHieraRelation> nodeListIdOfRT_Ark = relationsHelper.getListRT(ds, idConcept, idThesaurus);
nce.setNodeListIdsOfRT(nodeListIdOfRT_Ark);
// récupération des Non Prefered Term
nce.setNodeEM(new TermHelper().getAllNonPreferredTerms(ds, new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus), idThesaurus));
// récupération des traductions
nce.setNodeTermTraductions(new TermHelper().getAllTraductionsOfConcept(ds, idConcept, idThesaurus));
// récupération des Groupes
ArrayList<NodeUri> nodeListIdsOfConceptGroup_Ark = getListIdArkOfGroup(ds, new GroupHelper().getListIdGroupOfConcept(ds, idThesaurus, idConcept), idThesaurus);
nce.setNodeListIdsOfConceptGroup(nodeListIdsOfConceptGroup_Ark);
// récupération des notes du Terme
String idTerm = new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus);
nce.setNodeNoteTerm(new NoteHelper().getListNotesTermAllLang(ds, idTerm, idThesaurus));
// récupération des Notes du Concept
nce.setNodeNoteConcept(new NoteHelper().getListNotesConceptAllLang(ds, idConcept, idThesaurus));
// récupération des Alignements
nce.setNodeAlignmentsList(new AlignmentHelper().getAllAlignmentOfConcept(ds, idConcept, idThesaurus));
}
return listNce;
}
use of mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch in project opentheso by miledrousset.
the class SelectedTerme method majPref.
private void majPref() {
nodeSe = new NodeSearch();
images = new ArrayList<>();
root = (TreeNode) new DefaultTreeNode("Root", null);
}
Aggregations