use of mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree in project opentheso by miledrousset.
the class NewTreeBean method onNodeExpand.
public void onNodeExpand(TreeNode treeNode) {
if (!treeNode.getType().equals("orphan")) {
ArrayList<NodeConceptTree> listeSubGroup = new ArrayList<>();
ArrayList<NodeConceptTree> listeConcept;
ArrayList<String> idGroupList;
ConceptHelper conceptHelper = new ConceptHelper();
GroupHelper groupHelper = new GroupHelper();
int type = 3;
boolean isTopTerm;
// <Retirer noeuds fictifs>
if (treeNode.getChildCount() == 1) {
treeNode.getChildren().remove(0);
}
MyTreeNode myTreeNode = (MyTreeNode) treeNode;
// id du concept ou group sélectionné qu'il faut déployer
String idSelectedNode = myTreeNode.getIdConcept();
// cas d'un Groupe ou sous-Groupe
if (myTreeNode.isIsGroup() || myTreeNode.isIsSubGroup()) {
// if (groupHelper.isIdOfGroup(connect.getPoolConnexion(), idSelectedNode, myTreeNode.getIdTheso())) {
// if (myTreeNode.isIsGroup() || myTreeNode.isIsSubGroup()) { //pour détecter les noeuds type Group/collecton/MT/Thèmes ...
// TypeConcept(1);//pour group ?
myTreeNode.setIsGroup(true);
// myTreeNode.setIsGroup(true);
// on récupère la liste des sous_groupes (s'il y en a)
listeSubGroup = groupHelper.getRelationGroupOf(connect.getPoolConnexion(), idSelectedNode, myTreeNode.getIdTheso(), myTreeNode.getLangue());
if (listeSubGroup == null) {
listeSubGroup = new ArrayList<>();
}
// pour récupérer les concepts mélangés avec les Sous_Groupes
listeConcept = conceptHelper.getListTopConcepts(connect.getPoolConnexion(), idSelectedNode, myTreeNode.getIdTheso(), myTreeNode.getLangue(), isSortByNotation);
} else {
listeConcept = conceptHelper.getListConcepts(connect.getPoolConnexion(), idSelectedNode, myTreeNode.getIdTheso(), myTreeNode.getLangue(), isSortByNotation);
// myTreeNode.setIsTopConcept(true);
}
MyTreeNode treeNode2 = null;
// 1 = domaine/Group, 2 = TT (top Term), 3 = Concept/term
// myTreeNode.isIsGroup() myTreeNode.isIsSubGroup()
//
String value = "";
String idTC = "";
String icon;
/**
* Ajout des sous_Groupes (MT, C, G, T ..)
*/
// attribut pour le trie
ArrayList<MyTreeNode> listeTreeNode = new ArrayList<>();
/*la partie de code suivant peut comporter des éléments inutiles**/
for (NodeConceptTree nodeConceptTreeGroup : listeSubGroup) {
treeNode2 = null;
value = nodeConceptTreeGroup.getTitle();
if (groupHelper.isHaveSubGroup(connect.getPoolConnexion(), nodeConceptTreeGroup.getIdThesaurus(), nodeConceptTreeGroup.getIdConcept()) || nodeConceptTreeGroup.isHaveChildren()) {
icon = getTypeOfSubGroup(myTreeNode.getTypeDomaine());
treeNode2 = new MyTreeNode(1, nodeConceptTreeGroup.getIdConcept(), ((MyTreeNode) treeNode).getIdTheso(), ((MyTreeNode) treeNode).getLangue(), nodeConceptTreeGroup.getIdConcept(), ((MyTreeNode) treeNode).getTypeDomaine(), idTC, icon, value, null);
((MyTreeNode) treeNode2).setIsSubGroup(true);
listeTreeNode.add(treeNode2);
((MyTreeNode) treeNode2).setIdParent(myTreeNode.getIdConcept());
/**
* *code poour la numérotation des sous groupes ***
*/
String prefix = groupHelper.getNotationOfGroup(connect.getPoolConnexion(), nodeConceptTreeGroup.getIdConcept(), nodeConceptTreeGroup.getIdThesaurus());
// ((MyTreeNode) treeNode2).setPrefix(myTreeNode.getNumerotation());
((MyTreeNode) treeNode2).setPrefix(prefix);
/*String suffix = groupHelper.getSuffixFromNode(connect.getPoolConnexion(), nodeConceptTreeGroup.getIdThesaurus(), nodeConceptTreeGroup.getIdConcept());
count += 5;
//a priori par défaut un getInt renvoit 0 si champ vide (cf groupHelper.getSuffixFromNode)
if (suffix.equalsIgnoreCase("0") || suffix.equalsIgnoreCase("00")) {
if (10 <= count) {
suffix = "" + count;
} else {
suffix = "0" + count;
}
groupHelper.saveSuffixFromNode(connect.getPoolConnexion(), nodeConceptTreeGroup.getIdThesaurus(), nodeConceptTreeGroup.getIdConcept(), suffix);
}
if (suffix.length() < 2) {
suffix = "0" + suffix;
}*/
// ((MyTreeNode) treeNode2).setSuffix(suffix);
// ((MyTreeNode) treeNode2).setData(((MyTreeNode) treeNode2).getNumerotation() + " " + treeNode2.getData());
((MyTreeNode) treeNode2).setData(prefix + " " + treeNode2.getData());
/**
* fin code numérotation des sous groupes****
*/
new DefaultTreeNode(null, treeNode2);
}
/**
* fin de la partie de code pouvant comporter des éléments inutiles
*/
}
for (MyTreeNode mtn : listeTreeNode) {
MyTreeNode tmp = new MyTreeNode(1, mtn.getIdConcept(), mtn.getIdTheso(), mtn.getLangue(), mtn.getIdConcept(), mtn.getTypeDomaine(), mtn.getIdTopConcept(), mtn.getType(), mtn.getData(), treeNode);
tmp.setPrefix(mtn.getPrefix());
tmp.setSuffix(mtn.getSuffix());
tmp.setIdParent(myTreeNode.getIdConcept());
tmp.setIsSubGroup(true);
new DefaultTreeNode(null, tmp);
}
// Ajout dans l'arbre des concepts
for (NodeConceptTree nodeConceptTree : listeConcept) {
isTopTerm = false;
treeNode2 = null;
if (// conceptHelper.haveChildren(connect.getPoolConnexion(), nodeConceptTree.getIdThesaurus(), nodeConceptTree.getIdConcept()) ||
nodeConceptTree.isHaveChildren()) {
icon = "dossier";
if (nodeConceptTree.isIsTopTerm()) {
// Création de topConcepts
if (nodeConceptTree.getTitle().trim().isEmpty()) {
value = nodeConceptTree.getIdConcept();
} else {
if (isSortByNotation) {
if (nodeConceptTree.getNotation().isEmpty()) {
value = nodeConceptTree.getTitle();
} else {
value = nodeConceptTree.getTitle() + " (" + nodeConceptTree.getNotation() + ")";
}
} else {
value = nodeConceptTree.getTitle();
}
}
idTC = value;
isTopTerm = true;
} else {
// Création de concepts
idTC = ((MyTreeNode) treeNode).getIdTopConcept();
if (nodeConceptTree.getTitle().trim().isEmpty()) {
value = nodeConceptTree.getIdConcept();
} else {
if (isSortByNotation) {
if (nodeConceptTree.getNotation().isEmpty()) {
value = nodeConceptTree.getTitle();
} else {
value = nodeConceptTree.getTitle() + " (" + nodeConceptTree.getNotation() + ")";
}
} else {
value = nodeConceptTree.getTitle();
}
}
}
if (nodeConceptTree.getStatusConcept() != null) {
if (nodeConceptTree.getStatusConcept().equals("hidden")) {
icon = "hidden";
}
}
treeNode2 = new MyTreeNode(type, nodeConceptTree.getIdConcept(), ((MyTreeNode) treeNode).getIdTheso(), ((MyTreeNode) treeNode).getLangue(), ((MyTreeNode) treeNode).getIdCurrentGroup(), ((MyTreeNode) treeNode).getTypeDomaine(), idTC, icon, value, treeNode);
if (isTopTerm) {
((MyTreeNode) treeNode2).setIsTopConcept(true);
}
idGroupList = groupHelper.getListIdGroupOfConcept(connect.getPoolConnexion(), nodeConceptTree.getIdThesaurus(), nodeConceptTree.getIdConcept());
((MyTreeNode) treeNode2).setOtherGroup(idGroupList);
((MyTreeNode) treeNode2).setIdParent(myTreeNode.getIdConcept());
new DefaultTreeNode(null, treeNode2);
} else {
icon = "fichier";
// if (type == 2) { //Création des topConcepts
if (nodeConceptTree.isIsTopTerm()) {
// cas de TT
// type=2;
idTC = nodeConceptTree.getIdConcept();
if (nodeConceptTree.getTitle().trim().isEmpty()) {
value = nodeConceptTree.getIdConcept();
} else {
if (isSortByNotation) {
if (nodeConceptTree.getNotation().isEmpty()) {
value = nodeConceptTree.getTitle();
} else {
value = nodeConceptTree.getTitle() + " (" + nodeConceptTree.getNotation() + ")";
}
} else {
value = nodeConceptTree.getTitle();
}
}
isTopTerm = true;
} else {
// Création de concepts
// type=3;
idTC = ((MyTreeNode) treeNode).getIdTopConcept();
if (nodeConceptTree.getTitle().trim().isEmpty()) {
value = nodeConceptTree.getIdConcept();
} else {
if (isSortByNotation) {
if (nodeConceptTree.getNotation().isEmpty()) {
value = nodeConceptTree.getTitle();
} else {
value = nodeConceptTree.getTitle() + " (" + nodeConceptTree.getNotation() + ")";
}
} else {
value = nodeConceptTree.getTitle();
}
}
}
if (nodeConceptTree.getStatusConcept().equals("hidden")) {
icon = "hidden";
}
treeNode2 = new MyTreeNode(type, nodeConceptTree.getIdConcept(), ((MyTreeNode) treeNode).getIdTheso(), ((MyTreeNode) treeNode).getLangue(), ((MyTreeNode) treeNode).getIdCurrentGroup(), ((MyTreeNode) treeNode).getTypeDomaine(), idTC, icon, value, treeNode);
if (isTopTerm) {
((MyTreeNode) treeNode2).setIsTopConcept(true);
}
idGroupList = groupHelper.getListIdGroupOfConcept(connect.getPoolConnexion(), nodeConceptTree.getIdThesaurus(), nodeConceptTree.getIdConcept());
((MyTreeNode) treeNode2).setOtherGroup(idGroupList);
}
((MyTreeNode) treeNode2).setIdParent(myTreeNode.getIdConcept());
}
}
}
use of mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree in project opentheso by miledrousset.
the class UnderTree method onNodeExpand.
/**
************************** ACTIONS TREE ***************************
*/
/**
* Expension de l'abre sur un seul noeud (ouvert manuellement)
* @param event Le noeud ouvert
*/
public void onNodeExpand(NodeExpandEvent event) {
String theso = ((MyTreeNode) event.getTreeNode()).getIdTheso();
String lang = ((MyTreeNode) event.getTreeNode()).getLangue();
// Récupération des facettes
ArrayList<Integer> listIdFacet = new FacetHelper().getIdFacetUnderConcept(connect.getPoolConnexion(), ((MyTreeNode) event.getTreeNode()).getIdConcept(), theso);
ArrayList<NodeFacet> listFacet = new ArrayList<>();
for (Integer id : listIdFacet) {
NodeFacet nf = new FacetHelper().getThisFacet(connect.getPoolConnexion(), id, theso, lang);
listFacet.add(nf);
}
// <Retirer noeuds fictifs>
if (event.getTreeNode().getChildCount() == 1) {
event.getTreeNode().getChildren().remove(0);
}
// Récupération et insertion des facettes avec leurs concepts
for (NodeFacet nf : listFacet) {
new MyTreeNode(1, String.valueOf(nf.getIdFacet()), theso, lang, "", "", "", "facette", nf.getLexicalValue() + "(" + String.valueOf(nf.getIdFacet()) + ")", event.getTreeNode());
ArrayList<String> listIdC = new FacetHelper().getIdConceptsOfFacet(connect.getPoolConnexion(), nf.getIdFacet(), theso);
ArrayList<NodeConceptTree> liste = new ArrayList<>();
for (String id : listIdC) {
String value = new TermHelper().getThisTerm(connect.getPoolConnexion(), id, theso, lang).getLexical_value();
NodeConceptTree nct = new NodeConceptTree();
nct.setHaveChildren(false);
nct.setIdConcept(id);
nct.setIdLang(lang);
nct.setIdThesaurus(theso);
nct.setTitle(value);
liste.add(nct);
}
// Ajout dans l'arbre
for (NodeConceptTree nct : liste) {
new MyTreeNode(3, nct.getIdConcept(), theso, lang, "", "", "", "fichier", nct.getTitle() + "(" + nct.getIdConcept() + ")", event.getTreeNode());
}
}
}
use of mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree in project opentheso by miledrousset.
the class UnderTree method initTree.
/**
* Récupère les facettes pour remplir la racine de l'arbre selon la langue et le thésaurus sélectionnés
* @param idTheso
* @param langue
*/
public void initTree(String idTheso, String langue) {
List<NodeConceptTree> racineNode = new FacetHelper().getIdParentOfFacet(connect.getPoolConnexion(), idTheso, langue);
for (NodeConceptTree nct : racineNode) {
TreeNode dynamicTreeNode = (TreeNode) new MyTreeNode(1, nct.getIdConcept(), idTheso, langue, "", "", "", "dossier", nct.getTitle() + "(" + nct.getIdConcept() + ")", root);
new DefaultTreeNode("fake", dynamicTreeNode);
}
}
use of mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree in project opentheso by miledrousset.
the class FacetHelper method getIdParentOfFacet.
/**
* Cette fonction permet de récupérer les Id des Concepts Parents qui continennent des Facettes
*
* @param ds
* @param idThesaurus
* @param lang
* @return ArrayList of IdConcepts
*/
public ArrayList<NodeConceptTree> getIdParentOfFacet(HikariDataSource ds, String idThesaurus, String lang) {
Connection conn;
Statement stmt;
ResultSet resultSet;
ArrayList<String> listIdC = new ArrayList<>();
ArrayList<NodeConceptTree> tabIdConcept = null;
try {
// Get connection from pool
conn = ds.getConnection();
try {
stmt = conn.createStatement();
try {
String query = "SELECT DISTINCT id_concept_parent" + " FROM thesaurus_array WHERE" + " id_thesaurus = '" + idThesaurus + "'";
stmt.executeQuery(query);
resultSet = stmt.getResultSet();
tabIdConcept = new ArrayList<>();
while (resultSet.next()) {
listIdC.add(resultSet.getString("id_concept_parent"));
}
for (String idC : listIdC) {
query = "SELECT term.lexical_value FROM term, preferred_term" + " WHERE preferred_term.id_term = term.id_term" + " and preferred_term.id_concept ='" + idC + "'" + " and term.lang = '" + lang + "'" + " and term.id_thesaurus = '" + idThesaurus + "'" + " order by lexical_value DESC";
stmt.executeQuery(query);
resultSet = stmt.getResultSet();
resultSet.next();
NodeConceptTree nct = new NodeConceptTree();
nct.setIdConcept(idC);
nct.setIdLang(lang);
nct.setIdThesaurus(idThesaurus);
if (resultSet.getRow() == 0) {
nct.setTitle("");
} else {
nct.setTitle(resultSet.getString("lexical_value"));
}
tabIdConcept.add(nct);
}
} finally {
stmt.close();
}
} finally {
conn.close();
}
} catch (SQLException sqle) {
// Log exception
log.error("Error while getting Facet of Thesaurus : " + idThesaurus, sqle);
}
return tabIdConcept;
}
use of mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree in project opentheso by miledrousset.
the class ConceptHelper method getListTopConcepts.
/**
* Cette fonction permet de récupérer la liste des Topconcepts suivant l'id
* du groupe et le thésaurus sous forme de classe NodeConceptTree (sans les
* relations)
*
* @param ds
* @param idGroup
* @param idThesaurus
* @param idLang
* @return Objet class NodeConceptTree
*/
public ArrayList<NodeConceptTree> getListTopConcepts(HikariDataSource ds, String idGroup, String idThesaurus, String idLang) {
Connection conn;
Statement stmt;
ResultSet resultSet;
ArrayList<NodeConceptTree> nodeConceptTree = null;
try {
// Get connection from pool
conn = ds.getConnection();
try {
stmt = conn.createStatement();
try {
String query = "SELECT concept.status, concept.id_concept" + " FROM concept, concept_group_concept WHERE" + " concept_group_concept.idconcept = concept.id_concept AND" + " concept_group_concept.idthesaurus = concept.id_thesaurus AND" + " concept_group_concept.idgroup = '" + idGroup + "' AND" + " concept.id_thesaurus = '" + idThesaurus + "' AND" + " concept.top_concept = true";
stmt.executeQuery(query);
resultSet = stmt.getResultSet();
nodeConceptTree = new ArrayList<>();
while (resultSet.next()) {
NodeConceptTree nodeConceptTree1 = new NodeConceptTree();
nodeConceptTree1.setIdConcept(resultSet.getString("id_concept"));
nodeConceptTree1.setStatusConcept(resultSet.getString("status"));
nodeConceptTree1.setIdThesaurus(idThesaurus);
nodeConceptTree1.setIdLang(idLang);
nodeConceptTree1.setIsTopTerm(true);
nodeConceptTree.add(nodeConceptTree1);
}
for (NodeConceptTree nodeConceptTree1 : nodeConceptTree) {
query = "SELECT term.lexical_value FROM" + " preferred_term, term WHERE" + " preferred_term.id_term = term.id_term AND" + " preferred_term.id_thesaurus = term.id_thesaurus AND" + " term.lang = '" + idLang + "' AND" + " preferred_term.id_concept = '" + nodeConceptTree1.getIdConcept() + "' AND" + " term.id_thesaurus = '" + idThesaurus + "'";
stmt.executeQuery(query);
resultSet = stmt.getResultSet();
if (resultSet.next()) {
if (resultSet.getString("lexical_value").isEmpty()) {
nodeConceptTree1.setTitle("");
} else {
nodeConceptTree1.setTitle(resultSet.getString("lexical_value"));
}
nodeConceptTree1.setHaveChildren(haveChildren(ds, idThesaurus, nodeConceptTree1.getIdConcept()));
}
}
// / ancienne version supprimée par Miled
/* String query = "select id_concept, status from concept where id_thesaurus = '"
+ idThesaurus + "'"
+ " and concept.id_concept IN (SELECT idconcept FROM concept_group_concept WHERE idgroup = '" + idGroup + "' AND idthesaurus = '" + idThesaurus + "' )"
+ " and top_concept = true";
stmt.executeQuery(query);
resultSet = stmt.getResultSet();
if (resultSet != null) {
nodeConceptTree = new ArrayList<>();
while (resultSet.next()) {
NodeConceptTree nodeConceptTree1 = new NodeConceptTree();
nodeConceptTree1.setIdConcept(resultSet.getString("id_concept"));
nodeConceptTree1.setStatusConcept(resultSet.getString("status"));
nodeConceptTree1.setIdThesaurus(idThesaurus);
nodeConceptTree1.setIdLang(idLang);
nodeConceptTree1.setIsTopTerm(true);
nodeConceptTree.add(nodeConceptTree1);
}
}
for (NodeConceptTree nodeConceptTree1 : nodeConceptTree) {
query = "SELECT term.lexical_value FROM preferred_term, term" +
" WHERE preferred_term.id_thesaurus = term.id_thesaurus AND" +
" term.id_term = preferred_term.id_term AND" +
" term.lang = '" + idLang + "' AND" +
" preferred_term.id_concept = '" + nodeConceptTree1.getIdConcept() + "' AND" +
" term.id_thesaurus = '" + idThesaurus + "'";
stmt.executeQuery(query);
resultSet = stmt.getResultSet();
if (resultSet != null) {
resultSet.next();
if (resultSet.getRow() == 0) {
nodeConceptTree1.setTitle("");
} else {
nodeConceptTree1.setTitle(resultSet.getString("lexical_value"));
}
nodeConceptTree1.setHaveChildren(
haveChildren(ds, idThesaurus, nodeConceptTree1.getIdConcept())
);
}
}
*/
} finally {
stmt.close();
}
} finally {
conn.close();
}
} catch (SQLException sqle) {
// Log exception
log.error("Error while getting TopConcept of Group : " + idGroup, sqle);
}
Collections.sort(nodeConceptTree);
return nodeConceptTree;
}
Aggregations