Search in sources :

Example 1 with NodeMessageAdmin

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

the class CandidateHelper method getMessageAdmin.

/**
 * Cette fonction permet de retourner le nombre de candidats d'un concept
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @return Objet class NodeMessageAdmin
 */
public NodeMessageAdmin getMessageAdmin(HikariDataSource ds, String idThesaurus, String idConcept) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    NodeMessageAdmin nodeMessageAdmin = null;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT users.username, users.id_user," + " concept_candidat.admin_message" + " FROM concept_candidat, users WHERE" + " concept_candidat.admin_id = users.id_user" + " and concept_candidat.id_concept = '" + idConcept + "'" + " and concept_candidat.id_thesaurus = '" + idThesaurus + "'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                if (resultSet.next()) {
                    nodeMessageAdmin = new NodeMessageAdmin();
                    nodeMessageAdmin.setId_user(resultSet.getInt("id_user"));
                    nodeMessageAdmin.setUser(resultSet.getString("username"));
                    nodeMessageAdmin.setMessage(resultSet.getString("admin_message"));
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting Admin Message of candidat : " + idConcept, sqle);
    }
    return nodeMessageAdmin;
}
Also used : NodeMessageAdmin(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeMessageAdmin) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet)

Example 2 with NodeMessageAdmin

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

the class SelectedCandidat method maj.

/**
 * $$$$$$$$$ fonction à revoir, trop de connection, à optimiser $$$$$$$$$
 */
/**
 * Récupération des informations d'un candidat lors de sa sélection dans la
 * table des candidats
 *
 * @param theso
 * @param langue
 */
public void maj(String theso, String langue) {
    // if(theso == null) return;
    idTheso = theso;
    langueTheso = langue;
    infoCdt.setNodesUser(new CandidateHelper().getListUsersOfCandidat(connect.getPoolConnexion(), selected.getIdConcept(), theso));
    infoCdt.setNodeTraductions(new CandidateHelper().getNodeTraductionCandidat(connect.getPoolConnexion(), selected.getIdConcept(), idTheso, langue));
    nomsProp = new ArrayList<>();
    if (infoCdt.getNodesUser().isEmpty())
        reInit();
    for (NodeUser nuse : infoCdt.getNodesUser()) {
        nomsProp.add(nuse.getName());
    }
    if (selected.getIdConcept() != null && !selected.getIdConcept().isEmpty() && !infoCdt.getNodesUser().isEmpty()) {
        NodeProposition np = new CandidateHelper().getNodePropositionOfUser(connect.getPoolConnexion(), selected.getIdConcept(), theso, infoCdt.getNodesUser().get(0).getId());
        if (np == null) {
            // erreur
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error-BDD")));
            return;
        }
        note = np.getNote();
        niveau = new ConceptHelper().getLexicalValueOfConcept(connect.getPoolConnexion(), np.getIdConceptParent(), idTheso, langue) + " (" + np.getIdConceptParent() + ")";
        if (!np.getIdConceptParent().isEmpty()) {
            niveau = new ConceptHelper().getLexicalValueOfConcept(connect.getPoolConnexion(), np.getIdConceptParent(), idTheso, langueTheso) + " (" + np.getIdConceptParent() + ")";
            showGroup(np);
        // domaine = new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), np.getIdGroup(), idTheso, langueTheso) + " (" + np.getIdGroup() + ")";
        }
        modifiedProposition = np.getModified();
        createdProposition = np.getCreated();
        if (selected.getEtat().equals("r") || selected.getEtat().equals("v") || selected.getEtat().equals("i")) {
            msgAdm = new CandidateHelper().getMessageAdmin(connect.getPoolConnexion(), idTheso, selected.getIdConcept());
        } else {
            msgAdm = new NodeMessageAdmin();
        }
    }
}
Also used : NodeProposition(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeProposition) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeMessageAdmin(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeMessageAdmin) NodeUser(mom.trd.opentheso.bdd.helper.nodes.NodeUser) FacesMessage(javax.faces.application.FacesMessage) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Aggregations

NodeMessageAdmin (mom.trd.opentheso.bdd.helper.nodes.candidat.NodeMessageAdmin)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 FacesMessage (javax.faces.application.FacesMessage)1 CandidateHelper (mom.trd.opentheso.bdd.helper.CandidateHelper)1 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)1 NodeUser (mom.trd.opentheso.bdd.helper.nodes.NodeUser)1 NodeProposition (mom.trd.opentheso.bdd.helper.nodes.candidat.NodeProposition)1