Search in sources :

Example 36 with NodeAutoCompletion

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

the class TermeConverter method getAsObject.

@Override
public Object getAsObject(FacesContext fc, UIComponent uic, String value) {
    if (value != null && value.trim().length() > 0) {
        NodeAutoCompletion nac = new NodeAutoCompletion();
        nac.setIdConcept(value);
        nac.setIdGroup(value);
        return nac;
    } else {
        return null;
    }
}
Also used : NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)

Example 37 with NodeAutoCompletion

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

the class GroupHelper method getAutoCompletionOtherGroup.

/**
 * Cette fonction permet de récupérer la liste des domaines sauf celui en
 * cours pour l'autocomplétion
 *
 * @param ds
 * @param idThesaurus
 * @param idGroup
 * @param text
 * @param idLang
 * @return Objet class Concept
 */
public List<NodeAutoCompletion> getAutoCompletionOtherGroup(HikariDataSource ds, String idThesaurus, // le Group à ignorer
String idGroup, String idLang, String text) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    List<NodeAutoCompletion> nodeAutoCompletionList = null;
    text = new StringPlus().convertString(text);
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT concept_group_label.idgroup," + " concept_group_label.lexicalvalue FROM concept_group_label" + " WHERE " + " concept_group_label.idthesaurus = '" + idThesaurus + "'" + " AND concept_group_label.lang = '" + idLang + "'" + " AND concept_group_label.idgroup != '" + idGroup + "'" + " AND unaccent_string(concept_group_label.lexicalvalue) ILIKE unaccent_string('" + text + "%')" + " ORDER BY concept_group_label.lexicalvalue ASC LIMIT 20";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                nodeAutoCompletionList = new ArrayList<>();
                while (resultSet.next()) {
                    if (resultSet.getRow() != 0) {
                        NodeAutoCompletion nodeAutoCompletion = new NodeAutoCompletion();
                        nodeAutoCompletion.setIdConcept("");
                        nodeAutoCompletion.setTermLexicalValue("");
                        nodeAutoCompletion.setGroupLexicalValue(resultSet.getString("lexicalvalue"));
                        nodeAutoCompletion.setIdGroup(resultSet.getString("idgroup"));
                        nodeAutoCompletionList.add(nodeAutoCompletion);
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting List of autocompletion of Text : " + text, sqle);
    }
    return nodeAutoCompletionList;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)

Example 38 with NodeAutoCompletion

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

the class GroupHelper method getAutoCompletionGroup.

/**
 * Cette fonction permet de récupérer la liste des domaines pour
 * l'autocomplétion
 *
 * @param ds
 * @param idThesaurus
 * @param text
 * @param idLang
 * @return Objet class Concept
 */
public List<NodeAutoCompletion> getAutoCompletionGroup(HikariDataSource ds, String idThesaurus, String idLang, String text) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    List<NodeAutoCompletion> nodeAutoCompletionList = null;
    text = new StringPlus().convertString(text);
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT concept_group_label.idgroup," + " concept_group_label.lexicalvalue FROM concept_group_label" + " WHERE " + " concept_group_label.idthesaurus = '" + idThesaurus + "'" + " AND concept_group_label.lang = '" + idLang + "'" + " AND unaccent_string(concept_group_label.lexicalvalue) ILIKE unaccent_string('" + text + "%')" + " ORDER BY concept_group_label.lexicalvalue ASC LIMIT 20";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                nodeAutoCompletionList = new ArrayList<>();
                while (resultSet.next()) {
                    if (resultSet.getRow() != 0) {
                        NodeAutoCompletion nodeAutoCompletion = new NodeAutoCompletion();
                        nodeAutoCompletion.setIdConcept("");
                        nodeAutoCompletion.setTermLexicalValue("");
                        nodeAutoCompletion.setGroupLexicalValue(resultSet.getString("lexicalvalue"));
                        nodeAutoCompletion.setIdGroup(resultSet.getString("idgroup"));
                        nodeAutoCompletionList.add(nodeAutoCompletion);
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting List of autocompletion of Text : " + text, sqle);
    }
    return nodeAutoCompletionList;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)

Example 39 with NodeAutoCompletion

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

the class SelectedCandidat method editMyProp.

/**
 * Permet d'éditer sa propre proposition
 *
 * @param langue
 */
public void editMyProp(String langue) {
    if (selectedNvx != null) {
        niveauEdit = selectedNvx.getIdConcept();
    } else {
        niveauEdit = "";
    }
    if (domaineEdit == null) {
        domaineEdit = "";
    }
    new CandidateHelper().updatePropositionCandidat(connect.getPoolConnexion(), selected.getIdConcept(), theUser.getUser().getId(), idTheso, noteEdit, niveauEdit, domaineEdit);
    NodeProposition np = new CandidateHelper().getNodePropositionOfUser(connect.getPoolConnexion(), selected.getIdConcept(), idTheso, infoCdt.getNodesUser().get(0).getId());
    infoCdt.setNodesUser(new CandidateHelper().getListUsersOfCandidat(connect.getPoolConnexion(), selected.getIdConcept(), idTheso));
    note = np.getNote();
    niveau = new ConceptHelper().getLexicalValueOfConcept(connect.getPoolConnexion(), np.getIdConceptParent(), idTheso, langue) + " (" + np.getIdConceptParent() + ")";
    domaine = new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), np.getIdGroup(), idTheso, langue) + " (" + np.getIdGroup() + ")";
    vue.setEditPropCandidat(false);
    selectedNvx = new NodeAutoCompletion();
    domaineEdit = "";
    niveauEdit = "";
    noteEdit = "";
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sCdt.info8")));
}
Also used : NodeProposition(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeProposition) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion) FacesMessage(javax.faces.application.FacesMessage) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Example 40 with NodeAutoCompletion

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

the class TermHelper method getAutoCompletionTerm.

/**
 * Cette fonction permet de récupérer une liste des terms pour
 * l'autocomplétion en se limitant à un Group et en ignorant le terme lui
 * même et ses BT
 *
 * @param ds
 * @param idSelectedConcept
 * @param idBTs
 * @param idThesaurus
 * @param text
 * @param idGroup
 * @param idLang
 * @return Objet class Concept
 */
public List<NodeAutoCompletion> getAutoCompletionTerm(HikariDataSource ds, // le concept à ignorer
String idSelectedConcept, // le concept à ignorer
ArrayList<String> idBTs, String idThesaurus, String idLang, String idGroup, String text) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    List<NodeAutoCompletion> nodeAutoCompletionList = new ArrayList<>();
    text = new StringPlus().convertString(text);
    String BT = "";
    for (String idBt : idBTs) {
        if (!BT.isEmpty()) {
            BT = BT + ",'" + idBt + "'";
        } else {
            BT = "'" + idBt + "'";
        }
    }
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT DISTINCT term.lexical_value, concept.id_concept, idgroup " + "FROM preferred_term, term, concept,concept_group_concept WHERE " + "preferred_term.id_term = term.id_term AND " + "concept_group_concept.idconcept = concept.id_concept AND " + "concept_group_concept.idthesaurus = term.id_thesaurus" + "preferred_term.id_thesaurus = term.id_thesaurus AND " + "concept.id_concept = preferred_term.id_concept AND " + "concept.id_thesaurus = preferred_term.id_thesaurus AND " + "term.id_thesaurus = '" + idThesaurus + "' AND " + "term.lang = '" + idLang + "' AND " + "concept_group_concept.idgroup = '" + idGroup + "' AND " + "concept.id_concept != '" + idSelectedConcept + "' AND " + "concept.id_concept not in (" + BT + ") AND " + "concept.status != 'hidden' AND " + "unaccent_string(term.lexical_value) ILIKE unaccent_string('" + text + "%')" + " ORDER BY term.lexical_value ASC LIMIT 20";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                if (resultSet != null) {
                    while (resultSet.next()) {
                        if (resultSet.getRow() != 0) {
                            NodeAutoCompletion nodeAutoCompletion = new NodeAutoCompletion();
                            nodeAutoCompletion.setIdConcept(resultSet.getString("id_concept"));
                            nodeAutoCompletion.setTermLexicalValue(resultSet.getString("lexical_value"));
                            nodeAutoCompletion.setGroupLexicalValue(new GroupHelper().getLexicalValueOfGroup(ds, resultSet.getString("idgroup"), idThesaurus, idLang));
                            nodeAutoCompletion.setIdGroup(resultSet.getString("idgroup"));
                            // if(!nodeAutoCompletionList.contains(nodeAutoCompletion))
                            nodeAutoCompletionList.add(nodeAutoCompletion);
                        }
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting List of autocompletion of Text : " + text, sqle);
    }
    return nodeAutoCompletionList;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)

Aggregations

NodeAutoCompletion (mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)41 FacesMessage (javax.faces.application.FacesMessage)17 ArrayList (java.util.ArrayList)16 Connection (java.sql.Connection)11 SQLException (java.sql.SQLException)11 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)8 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)7 ResultSet (java.sql.ResultSet)6 Statement (java.sql.Statement)6 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)6 StringPlus (mom.trd.opentheso.bdd.tools.StringPlus)6 PreparedStatement (java.sql.PreparedStatement)2 Term (mom.trd.opentheso.bdd.datas.Term)2 MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)2 NodeCandidat (mom.trd.opentheso.bdd.helper.nodes.candidat.NodeCandidat)2 NodeCandidatValue (mom.trd.opentheso.bdd.helper.nodes.candidat.NodeCandidatValue)2 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1