Search in sources :

Example 1 with NodeGroup

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

the class ThesaurusDatas method exportAllDatas.

/**
 * permet de récupérer toutes les données d'un thésaurus
 * puis les chargées dans les variables de la classe
 * en filrant par langue et Groupe
 *
 * @param ds
 * @param idThesaurus
 * @param selectedLanguages
 * @param selectedGroups
 * @return
 */
public boolean exportAllDatas(HikariDataSource ds, String idThesaurus, List<NodeLang> selectedLanguages, List<NodeGroup> selectedGroups) {
    // récupération du thésaurus
    this.nodeThesaurus = new ThesaurusHelper().getNodeThesaurus(ds, idThesaurus);
    // ArrayList<String> idGroups = new GroupHelper().getListIdOfGroup(ds, idThesaurus);
    for (NodeGroup nodeGroup : selectedGroups) {
        this.nodeGroupLabels.add(new GroupHelper().getNodeGroupLabel(ds, nodeGroup.getConceptGroup().getIdgroup(), idThesaurus));
    // System.out.println("idGroup = : " + idGroup);
    }
    // récupération des ids des Tops Concepts
    // nodeTTs = new ConceptHelper().getAllListIdsOfTopConcepts(ds, idThesaurus);
    ArrayList<String> listTopConcept;
    for (NodeGroup nodeGroup : selectedGroups) {
        listTopConcept = new ConceptHelper().getListIdsOfTopConcepts(ds, nodeGroup.getConceptGroup().getIdgroup(), idThesaurus);
        // récupération de tous les concepts
        for (String idTop : listTopConcept) {
            new ConceptHelper().exportAllConcepts(ds, idTop, idThesaurus, nodeConceptExports);
        }
    }
    return true;
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 2 with NodeGroup

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

the class ExportTxtHelper method exportToTxtCsv.

/**
 * permet de préparer le thésaurus au format tabulé. Les données sont
 * écrites dans des variables type StringBuffer suivant les options
 * sélectionnées dans le tableau String[] selectedOptions
 *
 * @return
 */
public boolean exportToTxtCsv() {
    txtBuff = new StringBuffer();
    ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
    NodeThesaurus nodeThesaurus = thesaurusHelper.getNodeThesaurus(ds, idTheso);
    if (nodeThesaurus == null) {
        return false;
    }
    // on écrit le label du thésaurus
    // writeHeader(nodeThesaurus);
    // écriture des groupes
    GroupHelper groupHelper = new GroupHelper();
    NodeGroup nodeGroup;
    for (NodeGroup selectedGroup : selectedGroups) {
        nodeGroup = groupHelper.getThisConceptGroup(ds, selectedGroup.getConceptGroup().getIdgroup(), idTheso, selectedLang);
        // writeGroup(nodeGroup);
        // écriture récursive des concepts
        writeConcepts(nodeGroup.getConceptGroup().getIdgroup());
    }
    return true;
}
Also used : ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 3 with NodeGroup

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

the class ExportTxtHelper method writeConceptsInfo.

/**
 * Permet d'écrire les concepts en bouclant par récursivité pour définir les
 * niveaux
 *
 * @return
 */
private void writeConceptsInfo(String idConcept, String indentation) {
    ConceptHelper conceptHelper = new ConceptHelper();
    NodeConcept nodeConcept = conceptHelper.getConcept(ds, idConcept, idTheso, selectedLang);
    StringPlus stringPlus = new StringPlus();
    boolean first = true;
    if (nodeConcept == null) {
        return;
    }
    // id numérique séquentiel
    txtBuff.append(++number);
    txtBuff.append("\t");
    // Id_concept
    txtBuff.append(idConcept);
    txtBuff.append("\t");
    // on écrit le Term_concept
    txtBuff.append(indentation);
    if (nodeConcept.getTerm().getLexical_value().isEmpty()) {
        txtBuff.append("(");
        txtBuff.append(idConcept);
        txtBuff.append(")");
    } else {
        txtBuff.append(nodeConcept.getTerm().getLexical_value());
    }
    int tot = StringUtils.countMatches(indentation, "\t");
    if (tot < indentationConcept) {
        addTabulate(indentationConcept - (tot + 1));
    }
    if (selectedOptions.contains("occ")) {
        // on écrit les occurences
        txtBuff.append("\t");
        txtBuff.append(totalOfNotices(idConcept));
    }
    first = true;
    if (selectedOptions.contains("nt")) {
        // on écrit la relation NT
        if (!nodeConcept.getNodeNT().isEmpty()) {
            txtBuff.append("\t");
            for (NodeNT nodeNT : nodeConcept.getNodeNT()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("NT: ");
                txtBuff.append(nodeNT.getTitle());
                first = false;
            }
        }
        if (nodeConcept.getNodeNT().size() < indentationNT) {
            addTabulate(indentationNT - nodeConcept.getNodeNT().size());
        }
    }
    first = true;
    // on écrit la relation UF
    if (selectedOptions.contains("uf")) {
        if (!nodeConcept.getNodeEM().isEmpty()) {
            txtBuff.append("\t");
            for (NodeEM nodeEm : nodeConcept.getNodeEM()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("UF: ");
                txtBuff.append(nodeEm.getLexical_value());
                first = false;
            }
        }
        if (nodeConcept.getNodeEM().size() < indentationUF) {
            addTabulate(indentationUF - nodeConcept.getNodeEM().size());
        }
    }
    first = true;
    if (selectedOptions.contains("bt")) {
        // on écrit la relation TG
        if (!nodeConcept.getNodeBT().isEmpty()) {
            txtBuff.append("\t");
            for (NodeBT nodeBT : nodeConcept.getNodeBT()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("BT: ");
                txtBuff.append(nodeBT.getTitle());
                first = false;
            }
        }
        if (nodeConcept.getNodeBT().size() < indentationBT) {
            addTabulate(indentationBT - nodeConcept.getNodeBT().size());
        }
    }
    first = true;
    // on écrit la relation RT
    if (selectedOptions.contains("rt")) {
        if (!nodeConcept.getNodeRT().isEmpty()) {
            txtBuff.append("\t");
            for (NodeRT nodeRT : nodeConcept.getNodeRT()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("RT: ");
                txtBuff.append(nodeRT.getTitle());
                first = false;
            }
        }
        if (nodeConcept.getNodeRT().size() < indentationRT) {
            addTabulate(indentationRT - nodeConcept.getNodeRT().size());
        }
    }
    first = true;
    // on écrit les Groupes
    if (selectedOptions.contains("groups")) {
        if (!nodeConcept.getNodeConceptGroup().isEmpty()) {
            txtBuff.append("\t");
            for (NodeGroup nodeGroup : nodeConcept.getNodeConceptGroup()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("MT: ");
                txtBuff.append(nodeGroup.getLexicalValue());
                first = false;
            }
        }
        if (nodeConcept.getNodeConceptGroup().size() < indentationGroups) {
            addTabulate(indentationGroups - nodeConcept.getNodeConceptGroup().size());
        }
    }
    first = true;
    // on écrit les traductions
    if (selectedOptions.contains("traductions")) {
        if (!nodeConcept.getNodeTermTraductions().isEmpty()) {
            txtBuff.append("\t");
            for (NodeTermTraduction nodeTermTraduction : nodeConcept.getNodeTermTraductions()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("Tr: ");
                txtBuff.append(nodeTermTraduction.getLexicalValue());
                txtBuff.append("(");
                txtBuff.append(nodeTermTraduction.getLang());
                txtBuff.append(")");
                first = false;
            }
        }
        if (nodeConcept.getNodeTermTraductions().size() < indentationTraductions) {
            addTabulate(indentationTraductions - nodeConcept.getNodeTermTraductions().size());
        }
    }
    first = true;
    // on écrit les notes de type Term
    if (selectedOptions.contains("notes")) {
        if ((!nodeConcept.getNodeNotesTerm().isEmpty()) || (!nodeConcept.getNodeNotesConcept().isEmpty())) {
            txtBuff.append("\t");
            for (NodeNote nodeNote : nodeConcept.getNodeNotesTerm()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("noteT: ");
                txtBuff.append(stringPlus.clearNewLine(nodeNote.getLexicalvalue()));
                first = false;
            }
            for (NodeNote nodeNote : nodeConcept.getNodeNotesConcept()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("noteC: ");
                txtBuff.append(stringPlus.clearNewLine(nodeNote.getLexicalvalue()));
                first = false;
            }
        }
        if (nodeConcept.getNodeNotesTerm().size() < indentationNotes) {
            addTabulate(indentationNotes - (nodeConcept.getNodeNotesConcept().size() + nodeConcept.getNodeNotesTerm().size()));
        }
    }
    txtBuff.append("\n");
}
Also used : NodeBT(mom.trd.opentheso.bdd.helper.nodes.NodeBT) NodeRT(mom.trd.opentheso.bdd.helper.nodes.NodeRT) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeConcept(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote) NodeNT(mom.trd.opentheso.bdd.helper.nodes.NodeNT) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 4 with NodeGroup

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

the class TreeChange method getPathFromSelectedConcept.

public ArrayList<String> getPathFromSelectedConcept(Connexion conn, MyTreeNode selectedNode) {
    String id = selectedNode.getIdConcept();
    String theso = selectedNode.getIdTheso();
    GroupHelper gh = new GroupHelper();
    ArrayList<NodeGroup> groups = gh.getListGroupOfConcept(conn.getPoolConnexion(), theso, id, selectedNode.getLangue());
    ConceptHelper ch = new ConceptHelper();
    ArrayList<String> result = new ArrayList<>();
    ArrayList<String> bt = new ArrayList<>();
    ArrayList<String> groupIds = new ArrayList<>();
    for (NodeGroup ng : groups) {
        groupIds.add(ng.getConceptGroup().getIdgroup());
        bt.addAll(ch.getAllBTOfConceptOfThisGroup(conn.getPoolConnexion(), id, ng.getConceptGroup().getIdgroup(), theso));
    }
    result.addAll(bt);
    while (!bt.isEmpty()) {
        ArrayList<String> tmp = new ArrayList<>();
        for (String idBt : bt) {
            for (String idGroup : groupIds) {
                tmp.addAll(ch.getAllBTOfConceptOfThisGroup(conn.getPoolConnexion(), idBt, idGroup, theso));
            }
        }
        bt = new ArrayList<>(tmp);
        result.addAll(bt);
    }
    for (String idGroup : groupIds) {
        String fat = gh.getIdFather(conn.getPoolConnexion(), idGroup, theso);
        result.add(fat);
        while (fat != null && !fat.isEmpty()) {
            fat = gh.getIdFather(conn.getPoolConnexion(), fat, theso);
            result.add(fat);
        }
    }
    result.addAll(groupIds);
    return result;
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ArrayList(java.util.ArrayList) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 5 with NodeGroup

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

the class GroupHelper method getThisConceptGroup2.

public ArrayList<NodeGroup> getThisConceptGroup2(HikariDataSource ds, String idConceptGroup, String idThesaurus, String idLang, ArrayList<NodeGroup> nodeConceptGroupList) throws SQLException {
    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 permuted where " + " id_group = '" + idConceptGroup + "'" + "  and id_thesaurus = '" + idThesaurus + "'";
                resultSet = stmt.executeQuery(query);
                while (resultSet.next()) {
                    nodeConceptGroup = new NodeGroup();
                    int orden = resultSet.getInt(1);
                    nodeConceptGroup.setOrde(orden);
                    nodeConceptGroup.setId_concept(resultSet.getString("id_concept"));
                    nodeConceptGroup.setId_group(idConceptGroup);
                    nodeConceptGroup.setId_theso(idThesaurus);
                    nodeConceptGroup.setIdLang(resultSet.getString("id_lang"));
                    nodeConceptGroup.setLexicalValue(resultSet.getString("lexical_value"));
                    nodeConceptGroup.setIspreferredterm(resultSet.getBoolean("ispreferredterm"));
                    nodeConceptGroup.setOriginal_value(resultSet.getString("original_value"));
                    nodeConceptGroupList.add(nodeConceptGroup);
                }
                nodeConceptGroup.setConceptGroup(conceptGroup);
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while adding element : " + idThesaurus, sqle);
    }
    return nodeConceptGroupList;
}
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