Search in sources :

Example 16 with Concept

use of mom.trd.opentheso.bdd.datas.Concept in project opentheso by miledrousset.

the class SelectedTerme method addBranchGroup.

/**
 * Cette fonction permet d'ajouter un groupe à une branche
 *
 * @param newGroup
 * @param idConcept
 * @return
 */
public boolean addBranchGroup(ArrayList<String> newGroup, String idConcept) {
    try {
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        if (new ConceptHelper().haveChildren(connect.getPoolConnexion(), idTheso, idConcept)) {
            List<NodeNT> children = new RelationsHelper().getListNT(connect.getPoolConnexion(), idConcept, idTheso, "");
            for (NodeNT nnt : children) {
                if (!addBranchGroup(newGroup, nnt.getIdConcept())) {
                    conn.rollback();
                    conn.close();
                    return false;
                }
            }
        }
        for (String s : newGroup) {
            if (!new ConceptHelper().haveThisGroup(connect.getPoolConnexion(), idConcept, s, idTheso)) {
                Concept c = new Concept();
                c.setIdConcept(idConcept);
                c.setIdGroup(s);
                c.setIdThesaurus(idTheso);
                c.setTopConcept(false);
                c.setStatus("D");
                if (!new GroupHelper().addConceptGroupConcept(conn, s, idConcept, idTheso)) {
                    // !new ConceptHelper().addNewGroupOfConcept(conn, c, user.getUser().getId())) {
                    conn.rollback();
                    conn.close();
                    return false;
                }
            }
        }
        conn.commit();
        conn.close();
        return true;
    } catch (SQLException ex) {
        Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
    }
    return false;
}
Also used : Concept(mom.trd.opentheso.bdd.datas.Concept) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SQLException(java.sql.SQLException) Connection(java.sql.Connection) PrefixString(com.k_int.IR.QueryModels.PrefixString) NodeNT(mom.trd.opentheso.bdd.helper.nodes.NodeNT) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 17 with Concept

use of mom.trd.opentheso.bdd.datas.Concept in project opentheso by miledrousset.

the class ConceptHelper method getMultiConceptForExport.

/**
 * Cette fonction permet de récupérer toutes les informations concernant un
 * ou plusieurs Concept par une chaîne de caractère, suivant le thésaurus,
 * la langue et le group
 *
 * @param ds
 * @param value
 * @param idThesaurus
 * @param idGroup
 * @param idLang
 * @param isArkActif
 * @return Objet class NodeConcept
 */
public ArrayList<NodeConceptExport> getMultiConceptForExport(HikariDataSource ds, String value, String idLang, String idGroup, String idThesaurus, boolean isArkActif) {
    ArrayList<NodeConceptExport> listNce = new ArrayList<>();
    // Récupération des concept
    ArrayList<NodeSearch> listRes = new SearchHelper().searchTerm(ds, value, idLang, idThesaurus, idGroup, 1, false);
    for (NodeSearch ns : listRes) {
        Concept concept = getThisConcept(ds, ns.getIdConcept(), idThesaurus);
        NodeConceptExport nce = new NodeConceptExport();
        nce.setConcept(concept);
        listNce.add(nce);
    }
    for (NodeConceptExport nce : listNce) {
        String idConcept = nce.getConcept().getIdConcept();
        RelationsHelper relationsHelper = new RelationsHelper();
        // récupération des BT
        ArrayList<NodeHieraRelation> nodeListIdOfBT_Ark = relationsHelper.getListBT(ds, idConcept, idThesaurus);
        nce.setNodeListOfBT(nodeListIdOfBT_Ark);
        // récupération des termes spécifiques
        ArrayList<NodeHieraRelation> nodeListIdOfNT_Ark = relationsHelper.getListNT(ds, idConcept, idThesaurus);
        nce.setNodeListOfNT(nodeListIdOfNT_Ark);
        // récupération des termes associés
        ArrayList<NodeHieraRelation> nodeListIdOfRT_Ark = relationsHelper.getListRT(ds, idConcept, idThesaurus);
        nce.setNodeListIdsOfRT(nodeListIdOfRT_Ark);
        // récupération des Non Prefered Term
        nce.setNodeEM(new TermHelper().getAllNonPreferredTerms(ds, new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus), idThesaurus));
        // récupération des traductions
        nce.setNodeTermTraductions(new TermHelper().getAllTraductionsOfConcept(ds, idConcept, idThesaurus));
        // récupération des Groupes
        ArrayList<NodeUri> nodeListIdsOfConceptGroup_Ark = getListIdArkOfGroup(ds, new GroupHelper().getListIdGroupOfConcept(ds, idThesaurus, idConcept), idThesaurus);
        nce.setNodeListIdsOfConceptGroup(nodeListIdsOfConceptGroup_Ark);
        // récupération des notes du Terme
        String idTerm = new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus);
        nce.setNodeNoteTerm(new NoteHelper().getListNotesTermAllLang(ds, idTerm, idThesaurus));
        // récupération des Notes du Concept
        nce.setNodeNoteConcept(new NoteHelper().getListNotesConceptAllLang(ds, idConcept, idThesaurus));
        // récupération des Alignements
        nce.setNodeAlignmentsList(new AlignmentHelper().getAllAlignmentOfConcept(ds, idConcept, idThesaurus));
    }
    return listNce;
}
Also used : NodeConcept(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept) Concept(mom.trd.opentheso.bdd.datas.Concept) NodeConceptExport(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport) ArrayList(java.util.ArrayList) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) NodeHieraRelation(mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation) NodeSearch(mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch)

Example 18 with Concept

use of mom.trd.opentheso.bdd.datas.Concept in project opentheso by miledrousset.

the class ConceptHelper method getConceptHisoriqueAll.

/**
 * Cette fonction permet de récupérer l'historique d'un concept
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @return String idGroup
 */
public ArrayList<Concept> getConceptHisoriqueAll(HikariDataSource ds, String idConcept, String idThesaurus) {
    ArrayList<Concept> listeConcept = new ArrayList<>();
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT modified, status, notation, top_concept, id_group, username from concept_historique, users where id_thesaurus = '" + idThesaurus + "'" + " and id_concept = '" + idConcept + "'" + " and concept_historique.id_user=users.id_user" + " order by modified DESC";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                if (resultSet != null) {
                    while (resultSet.next()) {
                        Concept c = new Concept();
                        c.setIdConcept(idConcept);
                        c.setIdThesaurus(idThesaurus);
                        c.setModified(resultSet.getDate("modified"));
                        c.setStatus(resultSet.getString("status"));
                        c.setNotation(resultSet.getString("notation"));
                        c.setTopConcept(resultSet.getBoolean("top_concept"));
                        c.setIdGroup(resultSet.getString("id_group"));
                        c.setUserName(resultSet.getString("username"));
                        listeConcept.add(c);
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting historique of Concept : " + idConcept, sqle);
    }
    return listeConcept;
}
Also used : NodeConcept(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept) Concept(mom.trd.opentheso.bdd.datas.Concept) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet)

Example 19 with Concept

use of mom.trd.opentheso.bdd.datas.Concept in project opentheso by miledrousset.

the class SelectedTerme method creerTermeSpe.

/**
 * Corrigé par M.R. Ajoute une relation terme spécifique au concept courant
 *
 * @param idCNT
 * @return true or false
 */
public boolean creerTermeSpe(String idCNT) {
    ConceptHelper conceptHelper = new ConceptHelper();
    if (new OrphanHelper().isOrphan(connect.getPoolConnexion(), idCNT, idTheso)) {
        try {
            Connection conn = connect.getPoolConnexion().getConnection();
            conn.setAutoCommit(false);
            ArrayList<String> newGroup = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), idC, idTheso);
            for (String s : newGroup) {
                Concept c = new Concept();
                c.setIdConcept(idCNT);
                c.setIdGroup(s);
                c.setIdThesaurus(idTheso);
                c.setStatus("D");
                String idConcept = conceptHelper.addConceptInTable(conn, c, user.getUser().getId());
                // si ça se passe mal, on ajoute rien;
                if (idConcept == null) {
                    conn.rollback();
                    conn.close();
                    return false;
                }
            }
            if (!new OrphanHelper().deleteOrphan(conn, idCNT, idTheso)) {
                conn.rollback();
                conn.close();
                return false;
            }
            // On crée les relations
            if (!new RelationsHelper().addRelationBT(conn, idCNT, idTheso, idC, user.getUser().getId())) {
                conn.rollback();
                conn.close();
                return false;
            }
            conn.commit();
            conn.close();
        } catch (SQLException ex) {
            Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    } else if (type == 1) {
        try {
            Connection conn = connect.getPoolConnexion().getConnection();
            conn.setAutoCommit(false);
            if (new ConceptHelper().haveThisGroup(connect.getPoolConnexion(), idCNT, idC, idTheso)) {
                if (!new RelationsHelper().setRelationTopConcept(conn, idCNT, idTheso, idC, true, user.getUser().getId())) {
                    conn.rollback();
                    conn.close();
                    return false;
                }
            } else {
                ArrayList<String> newGroup = new ArrayList<>();
                newGroup.add(idC);
                if (!addBranchGroup(newGroup, idCNT)) {
                    conn.rollback();
                    conn.close();
                    return false;
                }
                if (!new RelationsHelper().setRelationTopConcept(conn, idCNT, idTheso, idC, true, user.getUser().getId())) {
                    conn.rollback();
                    conn.close();
                    return false;
                }
            }
            conn.commit();
            conn.close();
        } catch (SQLException ex) {
            Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        try {
            Connection conn = connect.getPoolConnexion().getConnection();
            conn.setAutoCommit(false);
            // On ajoute les nouveaux domaines s'il y en a
            ArrayList<String> groupNT = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), idCNT, idTheso);
            ArrayList<String> groupCurrent = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), idC, idTheso);
            ArrayList<String> newGroup = new ArrayList<>();
            for (String s : groupCurrent) {
                if (!groupNT.contains(s)) {
                    newGroup.add(s);
                }
            }
            if (!addBranchGroup(newGroup, idCNT)) {
                conn.rollback();
                conn.close();
                return false;
            }
            // On crée les relations
            if (!new RelationsHelper().addRelationBT(conn, idCNT, idTheso, idC, user.getUser().getId())) {
                conn.rollback();
                conn.close();
                return false;
            }
            conn.commit();
            conn.close();
        } catch (SQLException ex) {
            Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }
    ArrayList<NodeNT> tempNT = new RelationsHelper().getListNT(connect.getPoolConnexion(), idC, idTheso, idlangue);
    termesSpecifique = new ArrayList<>();
    HashMap<String, String> tempMap = new HashMap<>();
    for (NodeNT nnt : tempNT) {
        tempMap.put(nnt.getIdConcept(), nnt.getTitle() + " (" + nnt.getRole() + ")");
    }
    termesSpecifique.addAll(tempMap.entrySet());
    vue.setAddTSpe(false);
    return true;
}
Also used : OrphanHelper(mom.trd.opentheso.bdd.helper.OrphanHelper) Concept(mom.trd.opentheso.bdd.datas.Concept) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SQLException(java.sql.SQLException) HashMap(java.util.HashMap) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) PrefixString(com.k_int.IR.QueryModels.PrefixString) NodeNT(mom.trd.opentheso.bdd.helper.nodes.NodeNT) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper)

Example 20 with Concept

use of mom.trd.opentheso.bdd.datas.Concept in project opentheso by miledrousset.

the class SelectedThesaurus method preRenderView.

/**
 * récupère la variable URL et affiche le terme qu'elle désigne
 */
public void preRenderView() {
    // if the URL is for Concept
    if (idCurl != null && idTurl != null) {
        idLurl = Locale.getDefault().toString().substring(0, 2);
        ArrayList<Languages_iso639> temp = new LanguageHelper().getLanguagesOfThesaurus(connect.getPoolConnexion(), idTurl);
        if (temp.isEmpty()) {
            idCurl = null;
            idGurl = null;
            idTurl = null;
            return;
        } else {
            boolean lExist = false;
            for (Languages_iso639 l : temp) {
                if (l.getId_iso639_1().trim().equals(idLurl)) {
                    lExist = true;
                }
            }
            if (!lExist) {
                idLurl = temp.get(0).getId_iso639_1().trim();
            }
        }
        if (new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl) == null) {
            idCurl = null;
            idGurl = null;
            idTurl = null;
            return;
        }
        tree.getSelectedTerme().reInitTerme();
        // Initialisation du thésaurus et de l'arbre
        thesaurus.setId_thesaurus(idTurl);
        thesaurus.setLanguage(idLurl);
        tree.getSelectedTerme().reInitTerme();
        tree.reInit();
        tree.initTree(null, null);
        ThesaurusHelper th = new ThesaurusHelper();
        thesaurus = th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        user.initUserNodePref(idTurl);
        // Initialisation du terme séléctionné et de l'arbre
        int type;
        Concept c = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl);
        if (c.isTopConcept()) {
            type = 2;
        } else {
            type = 3;
        }
        tree.getSelectedTerme().setIdTheso(idTurl);
        tree.getSelectedTerme().setIdlangue(idLurl);
        MyTreeNode mTN = new MyTreeNode(type, idCurl, idTurl, idLurl, c.getIdGroup(), "", null, null, null, null);
        tree.getSelectedTerme().majTerme(mTN);
        tree.reExpand();
        idCurl = null;
        idGurl = null;
        idTurl = null;
        idLurl = null;
        return;
    }
    // if the URL is for Groups
    if (idGurl != null && idTurl != null) {
        idLurl = Locale.getDefault().toString().substring(0, 2);
        ArrayList<Languages_iso639> temp = new LanguageHelper().getLanguagesOfThesaurus(connect.getPoolConnexion(), idTurl);
        if (temp.isEmpty()) {
            idCurl = null;
            idGurl = null;
            idTurl = null;
            return;
        } else {
            boolean lExist = false;
            for (Languages_iso639 l : temp) {
                if (l.getId_iso639_1().trim().equals(idLurl)) {
                    lExist = true;
                }
            }
            if (!lExist) {
                idLurl = temp.get(0).getId_iso639_1().trim();
            }
        }
        if (new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(), idGurl, idTurl, idLurl) == null) {
            idCurl = null;
            idGurl = null;
            idTurl = null;
            return;
        }
        tree.getSelectedTerme().reInitTerme();
        // Initialisation du thésaurus et de l'arbre
        thesaurus.setId_thesaurus(idTurl);
        thesaurus.setLanguage(idLurl);
        tree.getSelectedTerme().reInitTerme();
        tree.reInit();
        tree.initTree(null, null);
        ThesaurusHelper th = new ThesaurusHelper();
        thesaurus = th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        user.initUserNodePref(idTurl);
        // Initialisation du terme séléctionné et de l'arbre
        int type = 1;
        // NodeGroup nodeGroup = new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(),idGurl, idTurl, idLurl);
        /*
            Concept c = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl);
            if (c.isTopConcept()) {
                type = 2;
            } else {
                type = 3;
            }*/
        tree.getSelectedTerme().setIdTheso(idTurl);
        tree.getSelectedTerme().setIdlangue(idLurl);
        MyTreeNode mTN = new MyTreeNode(type, idGurl, idTurl, idLurl, idGurl, "", null, null, null, null);
        tree.getSelectedTerme().majTerme(mTN);
        tree.reExpand();
        idCurl = null;
        idGurl = null;
        idTurl = null;
        idLurl = null;
        return;
    }
    // if the URL is only for thésaurus
    if (idTurl != null) {
        idLurl = Locale.getDefault().toString().substring(0, 2);
        ArrayList<Languages_iso639> temp = new LanguageHelper().getLanguagesOfThesaurus(connect.getPoolConnexion(), idTurl);
        if (temp.isEmpty()) {
            idCurl = null;
            idGurl = null;
            idTurl = null;
            return;
        } else {
            boolean lExist = false;
            for (Languages_iso639 l : temp) {
                if (l.getId_iso639_1().trim().equals(idLurl)) {
                    lExist = true;
                }
            }
            if (!lExist) {
                idLurl = temp.get(0).getId_iso639_1().trim();
            }
        }
        /*   if (new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(), idGurl, idTurl, idLurl) == null) {
                idCurl = null;
                idGurl = null;
                idTurl = null;
                return;
            }*/
        tree.getSelectedTerme().reInitTerme();
        // Initialisation du thésaurus et de l'arbre
        thesaurus.setId_thesaurus(idTurl);
        thesaurus.setLanguage(idLurl);
        tree.getSelectedTerme().reInitTerme();
        tree.reInit();
        tree.initTree(null, null);
        ThesaurusHelper th = new ThesaurusHelper();
        thesaurus = th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        user.initUserNodePref(idTurl);
        // Initialisation du terme séléctionné et de l'arbre
        // NodeGroup nodeGroup = new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(),idGurl, idTurl, idLurl);
        /*
            Concept c = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl);
            if (c.isTopConcept()) {
                type = 2;
            } else {
                type = 3;
            }*/
        tree.getSelectedTerme().setIdTheso(idTurl);
        tree.getSelectedTerme().setIdlangue(idLurl);
        // MyTreeNode mTN = new MyTreeNode(type, idGurl, idTurl, idLurl, idGurl, "", null, null, null);
        // tree.getSelectedTerme().majTerme(mTN);
        // tree.reExpand();
        idCurl = null;
        idGurl = null;
        idTurl = null;
        idLurl = null;
    }
}
Also used : Concept(mom.trd.opentheso.bdd.datas.Concept) LanguageHelper(mom.trd.opentheso.bdd.helper.LanguageHelper) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639)

Aggregations

Concept (mom.trd.opentheso.bdd.datas.Concept)30 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)18 Term (mom.trd.opentheso.bdd.datas.Term)15 SQLException (java.sql.SQLException)12 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)12 Connection (java.sql.Connection)11 AlignmentHelper (mom.trd.opentheso.bdd.helper.AlignmentHelper)10 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)10 NodeConcept (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept)10 NodeTerm (mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm)10 ArrayList (java.util.ArrayList)9 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)9 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)9 RelationsHelper (mom.trd.opentheso.bdd.helper.RelationsHelper)7 PreparedStatement (java.sql.PreparedStatement)6 Statement (java.sql.Statement)6 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)5 NodeAlignment (mom.trd.opentheso.bdd.helper.nodes.NodeAlignment)5 SKOSMapping (skos.SKOSMapping)5 SKOSTopConcept (skos.SKOSTopConcept)5