Search in sources :

Example 6 with NodeGroup

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

the class GroupHelper method getListRootConceptGroup.

/**
 * permet de retournner la liste des domaines de premier niveau (MT, G, C, T
 * )
 *
 * @param ds
 * @param idThesaurus
 * @param idLang
 * @return
 */
public ArrayList<NodeGroup> getListRootConceptGroup(HikariDataSource ds, String idThesaurus, String idLang) {
    ArrayList<NodeGroup> nodeConceptGroupList;
    ArrayList tabIdConceptGroup = getListIdOfRootGroup(ds, idThesaurus);
    nodeConceptGroupList = new ArrayList<>();
    for (Object tabIdGroup1 : tabIdConceptGroup) {
        NodeGroup nodeConceptGroup;
        nodeConceptGroup = getThisConceptGroup(ds, tabIdGroup1.toString(), idThesaurus, idLang);
        if (nodeConceptGroup == null) {
            return null;
        }
        nodeConceptGroupList.add(nodeConceptGroup);
    }
    return nodeConceptGroupList;
}
Also used : ArrayList(java.util.ArrayList) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 7 with NodeGroup

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

the class GroupHelper method getGroupHistoriqueFromDate.

/**
 * Cette fonction permet de récupérer l'historique d'un groupe à une date
 * précise
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @param date
 * @return
 */
public ArrayList<NodeGroup> getGroupHistoriqueFromDate(HikariDataSource ds, String idConcept, String idThesaurus, Date date) {
    Connection conn;
    Statement stmt;
    ArrayList<NodeGroup> nodeGroupList = null;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "select idgroup, id_ark, idtypecode, idparentgroup, notation, modified, username from concept_group_historique, users " + "where idconcept = '" + idConcept + "'" + " and idthesaurus = '" + idThesaurus + "'" + " and concept_group_historique.id_user=users.id_user" + " and modified <= '" + date.toString() + "' order by modified DESC";
                ResultSet resultSet = stmt.executeQuery(query);
                if (resultSet != null) {
                    nodeGroupList = new ArrayList<>();
                    while (resultSet.next()) {
                        NodeGroup nodeGroup = new NodeGroup();
                        nodeGroup.setIdUser(resultSet.getString("username"));
                        nodeGroup.setModified(resultSet.getDate("modified"));
                        nodeGroup.getConceptGroup().setId(resultSet.getInt("idgroup"));
                        nodeGroup.getConceptGroup().setIdARk(resultSet.getString("id_ark"));
                        nodeGroup.getConceptGroup().setIdthesaurus(idThesaurus);
                        nodeGroup.getConceptGroup().setIdtypecode(resultSet.getString("idtypecode"));
                        nodeGroup.getConceptGroup().setIdparentgroup(resultSet.getString("idparentgroup"));
                        nodeGroup.getConceptGroup().setNotation(resultSet.getString("notation"));
                        nodeGroup.getConceptGroup().setIdconcept(resultSet.getString("idconcept"));
                        nodeGroupList.add(nodeGroup);
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting date historique group of concept : " + idConcept, sqle);
    }
    return nodeGroupList;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 8 with NodeGroup

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

the class GroupHelper method getListGroupOfConcept.

/**
 * Permet de retourner la liste des Groupes pour un Concept et un thésaurus
 * donné
 *
 * @param ds le pool de connexion
 * @param idThesaurus
 * @param idConcept
 * @param idLang
 * @return Objet Class ArrayList NodeGroup
 */
public ArrayList<NodeGroup> getListGroupOfConcept(HikariDataSource ds, String idThesaurus, String idConcept, String idLang) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeGroup> nodeGroups = new ArrayList<>();
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                /*String query = "select id_group from concept where id_thesaurus = '" + idThesaurus + "'"
                            + " and id_concept = '" + idConcept + "'";*/
                String query = "select idgroup from concept_group_concept where idthesaurus = '" + idThesaurus + "'" + " and idconcept = '" + idConcept + "'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                while (resultSet.next()) {
                    NodeGroup nodeGroup = getThisConceptGroup(ds, resultSet.getString("idgroup"), idThesaurus, idLang);
                    if (nodeGroup != null)
                        nodeGroups.add(nodeGroup);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting List Id or Groups of Concept : " + idConcept, sqle);
    }
    return nodeGroups;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 9 with NodeGroup

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

the class GroupHelper method getGroupHistoriqueAll.

/**
 * Cette fonction permet de récupérer l'historique d'un groupe
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @return
 */
public ArrayList<NodeGroup> getGroupHistoriqueAll(HikariDataSource ds, String idConcept, String idThesaurus) {
    Connection conn;
    Statement stmt;
    ArrayList<NodeGroup> nodeGroupList = null;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "select idgroup, id_ark, idtypecode, idparentgroup, notation, modified, username from concept_group_historique, users " + "where idconcept = '" + idConcept + "'" + " and idthesaurus = '" + idThesaurus + "'" + " and concept_group_historique.id_user=users.id_user" + " order by modified DESC";
                ResultSet resultSet = stmt.executeQuery(query);
                if (resultSet != null) {
                    nodeGroupList = new ArrayList<>();
                    while (resultSet.next()) {
                        NodeGroup nodeGroup = new NodeGroup();
                        nodeGroup.setIdUser(resultSet.getString("username"));
                        nodeGroup.setModified(resultSet.getDate("modified"));
                        nodeGroup.getConceptGroup().setId(resultSet.getInt("idgroup"));
                        nodeGroup.getConceptGroup().setIdARk(resultSet.getString("id_ark"));
                        nodeGroup.getConceptGroup().setIdthesaurus(idThesaurus);
                        nodeGroup.getConceptGroup().setIdtypecode(resultSet.getString("idtypecode"));
                        nodeGroup.getConceptGroup().setIdparentgroup(resultSet.getString("idparentgroup"));
                        nodeGroup.getConceptGroup().setNotation(resultSet.getString("notation"));
                        nodeGroup.getConceptGroup().setIdconcept(resultSet.getString("idconcept"));
                        nodeGroupList.add(nodeGroup);
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting All historique group of concept : " + idConcept, sqle);
    }
    return nodeGroupList;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 10 with NodeGroup

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

the class GroupHelper method getThisConceptGroup.

/**
 * Permet de retourner un NodeConceptGroup par identifiant, par thésaurus et
 * par langue / ou null si rien cette fonction ne retourne pas les détails
 * et les traductions
 *
 * @param ds le pool de connexion
 * @param idConceptGroup
 * @param idThesaurus
 * @param idLang
 * @return Objet Class NodeConceptGroup
 */
public NodeGroup getThisConceptGroup(HikariDataSource ds, String idConceptGroup, String idThesaurus, String idLang) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    NodeGroup nodeConceptGroup = null;
    ConceptGroup conceptGroup = null;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT * from concept_group where " + " idgroup = '" + idConceptGroup + "'" + " and idthesaurus = '" + idThesaurus + "'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                if (resultSet != null) {
                    resultSet.next();
                    if (resultSet.getRow() != 0) {
                        conceptGroup = new ConceptGroup();
                        conceptGroup.setIdgroup(idConceptGroup);
                        conceptGroup.setIdthesaurus(idThesaurus);
                        conceptGroup.setIdARk(resultSet.getString("id_ark"));
                        conceptGroup.setIdtypecode(resultSet.getString("idtypecode"));
                        conceptGroup.setNotation(resultSet.getString("notation"));
                    }
                }
                if (conceptGroup != null) {
                    query = "SELECT * FROM concept_group_label WHERE" + " idgroup = '" + conceptGroup.getIdgroup() + "'" + " AND idthesaurus = '" + idThesaurus + "'" + " AND lang = '" + idLang + "'";
                    stmt.executeQuery(query);
                    resultSet = stmt.getResultSet();
                    if (resultSet != null) {
                        nodeConceptGroup = new NodeGroup();
                        resultSet.next();
                        if (resultSet.getRow() == 0) {
                            // cas du Group non traduit
                            nodeConceptGroup.setLexicalValue("");
                            nodeConceptGroup.setIdLang(idLang);
                        } else {
                            nodeConceptGroup.setLexicalValue(resultSet.getString("lexicalvalue"));
                            nodeConceptGroup.setIdLang(idLang);
                            nodeConceptGroup.setCreated(resultSet.getDate("created"));
                            nodeConceptGroup.setModified(resultSet.getDate("modified"));
                        }
                        nodeConceptGroup.setConceptGroup(conceptGroup);
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while adding element : " + idThesaurus, sqle);
    }
    return nodeConceptGroup;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ConceptGroup(mom.trd.opentheso.bdd.datas.ConceptGroup) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Aggregations

NodeGroup (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)29 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)18 ArrayList (java.util.ArrayList)8 Connection (java.sql.Connection)7 PreparedStatement (java.sql.PreparedStatement)7 ResultSet (java.sql.ResultSet)7 SQLException (java.sql.SQLException)7 Statement (java.sql.Statement)7 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)5 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)4 ConceptGroup (mom.trd.opentheso.bdd.datas.ConceptGroup)3 StatisticHelper (mom.trd.opentheso.bdd.helper.StatisticHelper)2 MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)2 NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)2 NodeThesaurus (mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus)2 DefaultTreeNode (org.primefaces.model.DefaultTreeNode)2 TreeNode (org.primefaces.model.TreeNode)2 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 FacesMessage (javax.faces.application.FacesMessage)1