Search in sources :

Example 66 with GroupHelper

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

the class ImportRdf4jHelper method addSingleConcept.

/**
 * ajoute un seul concept en choisissant un concept père
 *
 * @param selectedTerme
 * @throws java.sql.SQLException
 * @throws java.text.ParseException
 */
public void addSingleConcept(SelectedTerme selectedTerme) throws SQLException, ParseException {
    String idGroup = selectedTerme.getIdDomaine();
    String idConceptPere = selectedTerme.getIdC();
    idTheso = selectedTerme.getIdTheso();
    AddConceptsStruct acs = new AddConceptsStruct();
    acs.conceptHelper = new ConceptHelper();
    // addConcepts
    if (skosXmlDocument.getConceptList().size() == 1) {
        initAddConceptsStruct(acs, skosXmlDocument.getConceptList().get(0));
        addRelationNoBTHiera(acs);
        acs.concept.setTopConcept(false);
        acs.concept.setIdGroup(idGroup);
        acs.conceptHelper.insertConceptInTable(ds, acs.concept, idUser);
        // on lie le nouveau concept au concept père
        HierarchicalRelationship hierarchicalRelationship1 = new HierarchicalRelationship(acs.concept.getIdConcept(), idConceptPere, idTheso, "BT");
        HierarchicalRelationship hierarchicalRelationship2 = new HierarchicalRelationship(idConceptPere, acs.concept.getIdConcept(), idTheso, "NT");
        acs.hierarchicalRelationships.add(hierarchicalRelationship1);
        acs.hierarchicalRelationships.add(hierarchicalRelationship2);
        new GroupHelper().addConceptGroupConcept(ds, idGroup, acs.concept.getIdConcept(), acs.concept.getIdThesaurus());
        finalizeAddConceptStruct(acs);
    } else {
    // erreur il y a plus d'un concept
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HierarchicalRelationship(mom.trd.opentheso.bdd.datas.HierarchicalRelationship) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 67 with GroupHelper

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

the class ExportThesaurus method exportAltLabel.

public StringBuilder exportAltLabel(HikariDataSource ds, String idTheso, String idLang) {
    GroupHelper groupHelper = new GroupHelper();
    WriteAltLabel writeAltLabel = new WriteAltLabel();
    String GroupLabel;
    // getAllBottomGroup(ds, idTheso);
    ArrayList<String> GroupLists = groupHelper.getListIdOfGroup(ds, idTheso);
    if (GroupLists == null)
        return null;
    if (GroupLists.isEmpty())
        return new StringBuilder("");
    for (String GroupList : GroupLists) {
        GroupLabel = groupHelper.getLexicalValueOfGroup(ds, GroupList, idTheso, idLang);
        writeAltLabel.setGroup(GroupList, GroupLabel);
        writeAltLabel.setHeader();
        writeAltLabel.AddAltLabelByGroup(ds, idTheso, GroupList, idLang);
    }
    return writeAltLabel.getAllAltLabels();
}
Also used : WriteAltLabel(mom.trd.opentheso.core.exports.altlabel.WriteAltLabel) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 68 with GroupHelper

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

the class ExportTxtHelper method countIndentation.

/**
 * permet de compter le nombre de décalalge pour chaque type de données
 * concept : pour l'hiérarchie NT : pour le nombre maxi de NT existant dans
 * le thésaurus ou le domaine choisi RT ... UF ....
 *
 * @param idConcept
 * @param indentation
 */
private void countIndentation(String idConcept, String indentation) {
    ArrayList<NodeNT> childList = new RelationsHelper().getListNT(ds, idConcept, idTheso, selectedLang);
    if (childList == null) {
        return;
    }
    // indentation des concepts par hiérarchie
    indentation += "\t";
    int tot = StringUtils.countMatches(indentation, "\t");
    if (tot > indentationConcept) {
        indentationConcept = tot;
    }
    // indentation des NT nombre maxi
    if (selectedOptions.contains("nt")) {
        int totNT = new RelationsHelper().getCountOfNT(ds, idConcept, idTheso);
        if (totNT > indentationNT) {
            indentationNT = totNT;
        }
    }
    // indentation des BT nombre maxi
    if (selectedOptions.contains("bt")) {
        int totBT = new RelationsHelper().getCountOfBT(ds, idConcept, idTheso);
        if (totBT > indentationBT) {
            indentationBT = totBT;
        }
    }
    // indentation des RT nombre maxi
    if (selectedOptions.contains("rt")) {
        int totRT = new RelationsHelper().getCountOfRT(ds, idConcept, idTheso);
        if (totRT > indentationRT) {
            indentationRT = totRT;
        }
    }
    // indentation des UF nombre maxi
    if (selectedOptions.contains("uf")) {
        int totUF = new RelationsHelper().getCountOfUF(ds, idConcept, idTheso, selectedLang);
        if (totUF > indentationUF) {
            indentationUF = totUF;
        }
    }
    // indentation des Groups nombre maxi
    if (selectedOptions.contains("groups")) {
        int totGroup = new GroupHelper().getCountOfGroups(ds, idConcept, idTheso);
        if (totGroup > indentationGroups) {
            indentationGroups = totGroup;
        }
    }
    // indentation traductions
    if (selectedOptions.contains("traductions")) {
        int totTraductions = new TermHelper().getCountOfTraductions(ds, idConcept, idTheso, selectedLang);
        if (totTraductions > indentationTraductions) {
            indentationTraductions = totTraductions;
        }
    }
    // indentation notes
    if (selectedOptions.contains("notes")) {
        int totNotes = new NoteHelper().getCountOfNotes(ds, idConcept, idTheso, selectedLang);
        if (totNotes > indentationNotes) {
            indentationNotes = totNotes;
        }
    }
    for (NodeNT nodeNT : childList) {
        countIndentation(nodeNT.getIdConcept(), indentation);
    }
}
Also used : NoteHelper(mom.trd.opentheso.bdd.helper.NoteHelper) NodeNT(mom.trd.opentheso.bdd.helper.nodes.NodeNT) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 69 with GroupHelper

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

the class ExportFromBDD method exportThesaurusAdvanced.

/**
 * Fonction récursive permettant d'exporter le thésaurus de la tête jusqu'au
 * dernier descripteur en filtrant par langues et domaines choisis
 *
 * @param ds
 * @param idThesaurus
 * @param selectedLanguages
 * @param selectedGroups
 * @param downloadBean
 * @return
 */
public StringBuffer exportThesaurusAdvanced(HikariDataSource ds, String idThesaurus, List<NodeLang> selectedLanguages, List<NodeGroup> selectedGroups, DownloadBean downloadBean) {
    /*
         * Ecriture du thésaurus
         */
    this.downloadBean = downloadBean;
    ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
    NodeThesaurus nodeThesaurus = thesaurusHelper.getNodeThesaurus(ds, idThesaurus);
    WriteFileSKOS writeFileSKOS = new WriteFileSKOS();
    // inititialisation des URI
    writeFileSKOS.setServerArk(serverArk);
    writeFileSKOS.setServerAdress(serverAdress);
    writeFileSKOS.writeHeader();
    String idArk = thesaurusHelper.getIdArkOfThesaurus(ds, idThesaurus);
    if (idArk == null || idArk.trim().isEmpty()) {
        writeFileSKOS.setURI(serverAdress);
    } else {
        writeFileSKOS.setURI(serverArk);
    }
    // writeFileSKOS.setURI("http://opentheso.frantiq.fr/" + nodeThesaurus.getListThesaurusTraduction().get(0).getTitle());
    // thesaurus.description);
    writeFileSKOS.writeThesaurus(nodeThesaurus);
    // ecriture des TopConcept
    GroupHelper conceptGroupHelper = new GroupHelper();
    ArrayList<String> tabIdGroup = conceptGroupHelper.getListIdOfGroup(ds, idThesaurus);
    for (String tabIdGroup1 : tabIdGroup) {
        writeFileSKOS.writeTopConcepts(tabIdGroup1, idThesaurus);
    }
    writeFileSKOS.writeEndOfMicroThesaurusList();
    // fin du bloc thésaurus et id of TopConcept
    // écriture des Domaines et Descripteurs avec traductions
    ArrayList<NodeUri> idOfTopConcept;
    for (String tabIdGroup1 : tabIdGroup) {
        for (NodeGroup nodeGroup : selectedGroups) {
            if (nodeGroup.getConceptGroup().getIdgroup().equalsIgnoreCase(tabIdGroup1)) {
                NodeGroupLabel nodeGroupLabel = conceptGroupHelper.getNodeGroupLabel(ds, tabIdGroup1, idThesaurus);
                idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
                writeFileSKOS.writeGroup(nodeGroupLabel, idOfTopConcept, selectedLanguages);
            }
        }
    }
    for (String tabIdGroup1 : tabIdGroup) {
        for (NodeGroup nodeGroup : selectedGroups) {
            if (nodeGroup.getConceptGroup().getIdgroup().equalsIgnoreCase(tabIdGroup1)) {
                idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
                for (NodeUri idOfTopConcept1 : idOfTopConcept) {
                    exportAllConceptsAdvanced(ds, idOfTopConcept1.getIdConcept(), idThesaurus, writeFileSKOS, selectedLanguages);
                }
            }
        }
    }
    writeFileSKOS.endSkos();
    return writeFileSKOS.getSkosBuff();
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) NodeGroupLabel(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 70 with GroupHelper

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

the class ExportFromBDD method exportGroupsOfThesaurus.

/**
 * Fonction récursive permettant d'exporter le thésaurus de la tête jusqu'au
 * dernier descripteur
 *
 * @param ds
 * @param idThesaurus
 * @return
 */
public StringBuffer exportGroupsOfThesaurus(HikariDataSource ds, String idThesaurus) {
    /*
         * Ecriture du thésaurus
         */
    ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
    NodeThesaurus nodeThesaurus = thesaurusHelper.getNodeThesaurus(ds, idThesaurus);
    WriteFileSKOS writeFileSKOS = new WriteFileSKOS();
    // inititialisation des URI
    writeFileSKOS.setServerArk(serverArk);
    writeFileSKOS.setServerAdress(serverAdress);
    writeFileSKOS.writeHeader();
    String idArk = thesaurusHelper.getIdArkOfThesaurus(ds, idThesaurus);
    if (idArk == null || idArk.trim().isEmpty()) {
        writeFileSKOS.setURI(serverAdress);
    } else {
        writeFileSKOS.setURI(serverArk);
    }
    // writeFileSKOS.setURI("http://opentheso.frantiq.fr/" + nodeThesaurus.getListThesaurusTraduction().get(0).getTitle());
    // thesaurus.description);
    writeFileSKOS.writeThesaurus(nodeThesaurus);
    // ecriture des TopConcept
    GroupHelper conceptGroupHelper = new GroupHelper();
    ArrayList<String> tabIdGroup = conceptGroupHelper.getListIdOfGroup(ds, idThesaurus);
    for (String tabIdGroup1 : tabIdGroup) {
        writeFileSKOS.writeTopConcepts(tabIdGroup1, idThesaurus);
    }
    writeFileSKOS.writeEndOfMicroThesaurusList();
    // fin du bloc thésaurus et id of TopConcept
    /*        // écriture des Domaines et Descripteurs avec traductions
        ArrayList <NodeUri> idOfTopConcept;
        for (String tabIdGroup1 : tabIdGroup) {
            NodeGroupLabel nodeGroupLabel = conceptGroupHelper.getNodeGroupLabel(ds, tabIdGroup1, idThesaurus);
            idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
            writeFileSKOS.writeGroup(nodeGroupLabel, idOfTopConcept);
        }
        
        for (String tabIdGroup1 : tabIdGroup) {
            idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
            for (NodeUri idOfTopConcept1 : idOfTopConcept) {
                exportAllConcepts(ds, idOfTopConcept1.getIdConcept(), idThesaurus, writeFileSKOS);
            }
        }
        */
    writeFileSKOS.endSkos();
    return writeFileSKOS.getSkosBuff();
}
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)

Aggregations

GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)79 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)38 ArrayList (java.util.ArrayList)22 NodeGroup (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)18 SQLException (java.sql.SQLException)16 Connection (java.sql.Connection)14 FacesMessage (javax.faces.application.FacesMessage)13 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)9 MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)9 ConceptGroupLabel (mom.trd.opentheso.bdd.datas.ConceptGroupLabel)8 RelationsHelper (mom.trd.opentheso.bdd.helper.RelationsHelper)8 NodeUri (mom.trd.opentheso.bdd.helper.nodes.NodeUri)8 NodeGroupLabel (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel)8 PrefixString (com.k_int.IR.QueryModels.PrefixString)7 NodeAutoCompletion (mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)6 DefaultTreeNode (org.primefaces.model.DefaultTreeNode)6 HashMap (java.util.HashMap)5 Concept (mom.trd.opentheso.bdd.datas.Concept)5 OrphanHelper (mom.trd.opentheso.bdd.helper.OrphanHelper)5 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)5