Search in sources :

Example 11 with NodeConceptTree

use of mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree in project opentheso by miledrousset.

the class SelectedTerme method majTSpeGroup.

private void majTSpeGroup() {
    termesSpecifique = new ArrayList<>();
    ConceptHelper ch = new ConceptHelper();
    GroupHelper gh = new GroupHelper();
    ArrayList<NodeConceptTree> tempNT = ch.getListTopConcepts(connect.getPoolConnexion(), idC, idTheso, idlangue, false);
    for (NodeConceptTree nct : tempNT) {
        HashMap<String, String> tempMap1 = new HashMap<>();
        tempMap1.put(nct.getIdConcept(), nct.getTitle());
        termesSpecifique.addAll(tempMap1.entrySet());
    }
/*for(String tGroup : ch.getListGroupChildIdOfGroup(connect.getPoolConnexion(), idC, idTheso)){
            
            String value  = gh.getLexicalValueOfGroup(connect.getPoolConnexion(), tGroup, idTheso, idlangue);
            HashMap<String, String> tempMap1 = new HashMap<>();
            tempMap1.put(tGroup, value);
            termesSpecifique.addAll(tempMap1.entrySet());
        }*/
}
Also used : NodeConceptTree(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HashMap(java.util.HashMap) PrefixString(com.k_int.IR.QueryModels.PrefixString) JsonString(javax.json.JsonString) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 12 with NodeConceptTree

use of mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree in project opentheso by miledrousset.

the class GroupHelper method getRelationGroupOf.

// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// ////// fin des nouvelles fonctions ////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
/**
 * à supprimer (doublon) #MR
 * Permet de retourner la liste des sous_groupes d'un Group (type G/C/MT/T)
 * si le group n'est pas traduit, on récupère l'ID à la place
 *
 * @param ds
 * @param idConceptGroup
 * @param idThesaurus
 * @param idLang
 * @return
 */
public ArrayList<NodeConceptTree> getRelationGroupOf(HikariDataSource ds, String idConceptGroup, String idThesaurus, String idLang) {
    ArrayList<NodeConceptTree> nodeConceptTrees;
    ArrayList<String> lisIdGroups = getListGroupChildIdOfGroup(ds, idConceptGroup, idThesaurus);
    if (lisIdGroups == null)
        return null;
    if (lisIdGroups.isEmpty())
        return null;
    nodeConceptTrees = new ArrayList<>();
    for (String idGroup : lisIdGroups) {
        NodeConceptTree nodeConceptTree = new NodeConceptTree();
        nodeConceptTree.setIdConcept(idGroup);
        nodeConceptTree.setIdLang(idLang);
        nodeConceptTree.setIdThesaurus(idThesaurus);
        nodeConceptTree.setTitle(getLexicalValueOfGroup(ds, idGroup, idThesaurus, idLang));
        nodeConceptTree.setStatusConcept("");
        nodeConceptTree.setHaveChildren(true);
        nodeConceptTree.setIsGroup(false);
        nodeConceptTree.setIsSubGroup(true);
        nodeConceptTrees.add(nodeConceptTree);
    }
    return nodeConceptTrees;
}
Also used : NodeConceptTree(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree)

Example 13 with NodeConceptTree

use of mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree in project opentheso by miledrousset.

the class FacetHelper method getConceptOnFacet.

/**
 * Cette fonction permet de retourner le concept paretn d'une facette
 *
 * @param ds
 * @param idFacet
 * @param idThesaurus
 * @param lang
 * @return ArrayList of Id Facet (int)
 */
public NodeConceptTree getConceptOnFacet(HikariDataSource ds, int idFacet, String idThesaurus, String lang) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    NodeConceptTree nct = new NodeConceptTree();
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "select thesaurus_array.id_concept_parent, term.lexical_value " + "from thesaurus_array, term, preferred_term" + " where thesaurus_array.id_concept_parent=preferred_term.id_concept" + " and preferred_term.id_term=term.id_term" + " and thesaurus_array.id_thesaurus=term.id_thesaurus" + " and term.lang='" + lang.trim() + "'" + " and thesaurus_array.id_thesaurus = '" + idThesaurus + "'" + " and facet_id = '" + idFacet + "'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                if (resultSet.next()) {
                    nct.setHaveChildren(true);
                    nct.setIdLang(lang);
                    nct.setIdThesaurus(idThesaurus);
                    nct.setIdConcept(resultSet.getString("id_concept_parent"));
                    nct.setTitle(resultSet.getString("lexical_value"));
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting Concept of Facet : " + idFacet, sqle);
    }
    return nct;
}
Also used : NodeConceptTree(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree) SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet)

Example 14 with NodeConceptTree

use of mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree in project opentheso by miledrousset.

the class ConceptHelper method getListConcepts.

/**
 * Cette fonction permet de récupérer la liste des concepts suivant l'id du
 * Concept-Père et le thésaurus sous forme de classe NodeConceptTree (sans
 * les relations)
 * elle fait le tri alphabétique ou par notation
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @param idLang
 * @param isSortByNotation
 * @return Objet class NodeConceptTree
 */
public ArrayList<NodeConceptTree> getListConcepts(HikariDataSource ds, String idConcept, String idThesaurus, String idLang, boolean isSortByNotation) {
    // check pour choix de tri entre alphabétique sur terme ou sur notation
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeConceptTree> nodeConceptTree = null;
    String query;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                if (isSortByNotation) {
                    // / Notation Sort
                    query = "SELECT concept.notation, hierarchical_relationship.id_concept2" + " FROM concept, hierarchical_relationship" + " WHERE " + " concept.id_concept = hierarchical_relationship.id_concept2 AND" + " concept.id_thesaurus = hierarchical_relationship.id_thesaurus AND" + " hierarchical_relationship.id_thesaurus = '" + idThesaurus + "' AND" + " hierarchical_relationship.id_concept1 = '" + idConcept + "' AND" + " hierarchical_relationship.role ILIKE 'NT%'" + " ORDER BY" + " concept.notation ASC;";
                } else {
                    // alphabétique Sort
                    query = "select id_concept2 from hierarchical_relationship" + " where id_thesaurus = '" + idThesaurus + "'" + " and id_concept1 = '" + idConcept + "'" + " and role LIKE 'NT%'";
                }
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                if (resultSet != null) {
                    nodeConceptTree = new ArrayList<>();
                    while (resultSet.next()) {
                        NodeConceptTree nodeConceptTree1 = new NodeConceptTree();
                        nodeConceptTree1.setIdConcept(resultSet.getString("id_concept2"));
                        if (isSortByNotation)
                            nodeConceptTree1.setNotation(resultSet.getString("notation"));
                        nodeConceptTree1.setIdThesaurus(idThesaurus);
                        nodeConceptTree1.setIdLang(idLang);
                        nodeConceptTree1.setIsTerm(true);
                        nodeConceptTree.add(nodeConceptTree1);
                    }
                }
                for (NodeConceptTree nodeConceptTree1 : nodeConceptTree) {
                    query = "SELECT term.lexical_value, concept.status" + " FROM concept, preferred_term, term" + " WHERE concept.id_concept = preferred_term.id_concept AND" + " concept.id_thesaurus = preferred_term.id_thesaurus AND" + " preferred_term.id_term = term.id_term AND" + " preferred_term.id_thesaurus = term.id_thesaurus AND" + " concept.id_concept = '" + nodeConceptTree1.getIdConcept() + "' AND" + " term.lang = '" + idLang + "' AND" + " term.id_thesaurus = '" + idThesaurus + "';";
                    stmt.executeQuery(query);
                    resultSet = stmt.getResultSet();
                    if (resultSet != null) {
                        resultSet.next();
                        if (resultSet.getRow() == 0) {
                            nodeConceptTree1.setTitle("");
                            nodeConceptTree1.setStatusConcept("");
                        } else {
                            nodeConceptTree1.setTitle(resultSet.getString("lexical_value"));
                            if (resultSet.getString("status") == null) {
                                nodeConceptTree1.setStatusConcept("");
                            } else {
                                nodeConceptTree1.setStatusConcept(resultSet.getString("status"));
                            }
                        }
                        nodeConceptTree1.setHaveChildren(haveChildren(ds, idThesaurus, nodeConceptTree1.getIdConcept()));
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting ListConcept of Concept : " + idConcept, sqle);
    }
    if (!isSortByNotation) {
        Collections.sort(nodeConceptTree);
    }
    return nodeConceptTree;
}
Also used : NodeConceptTree(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet)

Example 15 with NodeConceptTree

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
 * @param isSortByNotation
 * @return Objet class NodeConceptTree
 */
public ArrayList<NodeConceptTree> getListTopConcepts(HikariDataSource ds, String idGroup, String idThesaurus, String idLang, boolean isSortByNotation) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeConceptTree> nodeConceptTree = null;
    String query;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                if (isSortByNotation) {
                    query = "SELECT concept.notation, 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" + " ORDER BY concept.notation ASC";
                } else {
                    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"));
                    if (isSortByNotation)
                        nodeConceptTree1.setNotation(resultSet.getString("notation"));
                    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();
                    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);
    }
    if (!isSortByNotation) {
        Collections.sort(nodeConceptTree);
    }
    return nodeConceptTree;
}
Also used : NodeConceptTree(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet)

Aggregations

NodeConceptTree (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree)15 Connection (java.sql.Connection)6 ResultSet (java.sql.ResultSet)6 SQLException (java.sql.SQLException)6 Statement (java.sql.Statement)6 ArrayList (java.util.ArrayList)6 MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)6 PreparedStatement (java.sql.PreparedStatement)4 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)4 FacetHelper (mom.trd.opentheso.bdd.helper.FacetHelper)4 DefaultTreeNode (org.primefaces.model.DefaultTreeNode)4 PrefixString (com.k_int.IR.QueryModels.PrefixString)3 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)3 TreeNode (org.primefaces.model.TreeNode)3 HashMap (java.util.HashMap)2 JsonString (javax.json.JsonString)2 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)2 NodeFacet (mom.trd.opentheso.bdd.helper.nodes.NodeFacet)2 FacesMessage (javax.faces.application.FacesMessage)1 Concept (mom.trd.opentheso.bdd.datas.Concept)1