Search in sources :

Example 1 with NodeFacet

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

the class SelectedTerme method onNodeExpand.

/**
 * 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) {
        String valeur = nf.getLexicalValue() + "(" + String.valueOf(nf.getIdFacet()) + ")";
        new MyTreeNode(1, String.valueOf(nf.getIdFacet()), theso, lang, "", "", "", "facette", valeur, 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());
        }
    }
}
Also used : NodeConceptTree(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree) ArrayList(java.util.ArrayList) FacetHelper(mom.trd.opentheso.bdd.helper.FacetHelper) NodeFacet(mom.trd.opentheso.bdd.helper.nodes.NodeFacet) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) PrefixString(com.k_int.IR.QueryModels.PrefixString) JsonString(javax.json.JsonString) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 2 with NodeFacet

use of mom.trd.opentheso.bdd.helper.nodes.NodeFacet 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());
        }
    }
}
Also used : NodeConceptTree(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree) ArrayList(java.util.ArrayList) FacetHelper(mom.trd.opentheso.bdd.helper.FacetHelper) NodeFacet(mom.trd.opentheso.bdd.helper.nodes.NodeFacet) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 3 with NodeFacet

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

the class FacetHelper method getAllFacetsOfThesaurus.

/**
 * Cette fonction permet de retourner toutes les Facettes d'un thésaurus
 * sous forme de NodeFacet
 *
 * @param ds
 * @param idThesaurus
 * @param idLang
 * @return ArrayList de NodeFacet
 */
public ArrayList<NodeFacet> getAllFacetsOfThesaurus(HikariDataSource ds, String idThesaurus, String idLang) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeFacet> nodeFacetlist = new ArrayList();
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT node_label.lexical_value," + " node_label.facet_id, thesaurus_array.id_concept_parent FROM " + " thesaurus_array, node_label WHERE" + " thesaurus_array.facet_id = node_label.facet_id AND" + " thesaurus_array.id_thesaurus = node_label.id_thesaurus" + " and node_label.lang = '" + idLang + "'" + " and node_label.id_thesaurus = '" + idThesaurus + "'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                while (resultSet.next()) {
                    NodeFacet nodeFacet = new NodeFacet();
                    nodeFacet.setIdFacet(resultSet.getInt("facet_id"));
                    nodeFacet.setLexicalValue(resultSet.getString("lexical_value"));
                    nodeFacet.setIdConceptParent(resultSet.getString("id_concept_parent"));
                    nodeFacetlist.add(nodeFacet);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting All Facet of Thesaurus : " + idThesaurus, sqle);
    }
    return nodeFacetlist;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) NodeFacet(mom.trd.opentheso.bdd.helper.nodes.NodeFacet)

Example 4 with NodeFacet

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

the class SelectedTerme method getArrayFacetteInclure.

public ArrayList<Entry<String, String>> getArrayFacetteInclure() {
    if (connect.getPoolConnexion() == null) {
        return null;
    }
    ArrayList<NodeFacet> temp = new FacetHelper().getAllFacetsOfThesaurus(connect.getPoolConnexion(), idTheso, idlangue);
    ArrayList<Integer> temp2 = new FacetHelper().getIdFacetOfConcept(connect.getPoolConnexion(), idC, idTheso);
    Map<String, String> mapTemp = new HashMap<>();
    /*    for (NodeFacet nf : temp) {
            if (!temp2.contains(nf.getIdFacet())) {
                String value = new TermHelper().getThisTerm(connect.getPoolConnexion(), nf.getIdConceptParent(), idTheso, idlangue).getLexical_value();
                mapTemp.put(String.valueOf(nf.getIdFacet()), nf.getLexicalValue() + " (" + value + ")");
            }
        }*/
    arrayFacette = new ArrayList<>(mapTemp.entrySet());
    return arrayFacette;
}
Also used : HashMap(java.util.HashMap) NodeFacet(mom.trd.opentheso.bdd.helper.nodes.NodeFacet) FacetHelper(mom.trd.opentheso.bdd.helper.FacetHelper) PrefixString(com.k_int.IR.QueryModels.PrefixString) JsonString(javax.json.JsonString)

Example 5 with NodeFacet

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

the class SelectedThesaurus method getArrayFacette.

public ArrayList<Entry<String, String>> getArrayFacette() {
    if (connect.getPoolConnexion() != null) {
        if (thesaurus == null) {
            return arrayFacette;
        }
        ArrayList<NodeFacet> temp = new FacetHelper().getAllFacetsOfThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        Map<String, String> mapTemp = new HashMap<>();
        Term value;
        for (NodeFacet nf : temp) {
            value = new TermHelper().getThisTerm(connect.getPoolConnexion(), nf.getIdConceptParent(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
            if (value == null) {
                mapTemp.put(String.valueOf(nf.getIdFacet()), nf.getLexicalValue() + " (" + nf.getIdConceptParent() + ")");
            } else {
                mapTemp.put(String.valueOf(nf.getIdFacet()), nf.getLexicalValue() + " (" + value.getLexical_value() + ")");
            }
        }
        arrayFacette = new ArrayList<>(mapTemp.entrySet());
    }
    return arrayFacette;
}
Also used : HashMap(java.util.HashMap) NodeFacet(mom.trd.opentheso.bdd.helper.nodes.NodeFacet) FacetHelper(mom.trd.opentheso.bdd.helper.FacetHelper) Term(mom.trd.opentheso.bdd.datas.Term) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Aggregations

NodeFacet (mom.trd.opentheso.bdd.helper.nodes.NodeFacet)6 FacetHelper (mom.trd.opentheso.bdd.helper.FacetHelper)4 ArrayList (java.util.ArrayList)3 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)3 PrefixString (com.k_int.IR.QueryModels.PrefixString)2 Connection (java.sql.Connection)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2 HashMap (java.util.HashMap)2 JsonString (javax.json.JsonString)2 MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)2 NodeConceptTree (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree)2 Term (mom.trd.opentheso.bdd.datas.Term)1