Search in sources :

Example 61 with GroupHelper

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

the class ExportRdf4jHelper method addFilsGroupRcursif.

private void addFilsGroupRcursif(String idThesaurus, String idPere, SKOSResource sKOSResource, List<NodeLang> selectedLanguages) {
    GroupHelper groupHelper = new GroupHelper();
    ArrayList<String> listIdsOfGroupChildren = groupHelper.getListGroupChildIdOfGroup(ds, idPere, idThesaurus);
    writeGroupInfo(sKOSResource, idThesaurus, idPere, selectedLanguages);
    for (String idOfGroupChildren : listIdsOfGroupChildren) {
        sKOSResource = new SKOSResource();
        // writeGroupInfo(groupHelper, group, idThesaurus, idOfGroupChildren, selectedLanguages);
        // if (!groupHelper.getListGroupChildIdOfGroup(ds, idOfGroupChildren, idThesaurus).isEmpty()) {
        addFilsGroupRcursif(idThesaurus, idOfGroupChildren, sKOSResource, selectedLanguages);
    // }
    }
}
Also used : SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 62 with GroupHelper

use of mom.trd.opentheso.bdd.helper.GroupHelper 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
 *
 * @param ds
 * @param idThesaurus
 * @return
 */
public boolean exportAllDatas(HikariDataSource ds, String idThesaurus) {
    // récupération du thésaurus
    this.nodeThesaurus = new ThesaurusHelper().getNodeThesaurus(ds, idThesaurus);
    // récupération des groupes
    ArrayList<String> idGroups = new GroupHelper().getListIdOfGroup(ds, idThesaurus);
    for (String idGroup : idGroups) {
        this.nodeGroupLabels.add(new GroupHelper().getNodeGroupLabel(ds, idGroup, idThesaurus));
    // System.out.println("idGroup = : " + idGroup);
    }
    // récupération des ids des Tops Concepts
    nodeTTs = new ConceptHelper().getAllListIdsOfTopConcepts(ds, idThesaurus);
    // récupération de tous les concepts
    for (NodeTT nodeTT1 : nodeTTs) {
        new ConceptHelper().exportAllConcepts(ds, nodeTT1.getIdConcept(), idThesaurus, nodeConceptExports);
    }
    return true;
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) NodeTT(mom.trd.opentheso.bdd.helper.nodes.NodeTT) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 63 with GroupHelper

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

the class ImportRdf4jHelper method addBranch.

/**
 * ajoute une brache en choisissant un concept père
 *
 * @param selectedTerme
 * @throws java.text.ParseException
 * @throws java.sql.SQLException
 */
public void addBranch(SelectedTerme selectedTerme) throws ParseException, SQLException {
    String idGroup = selectedTerme.getIdDomaine();
    String idConceptPere = selectedTerme.getIdC();
    idTheso = selectedTerme.getIdTheso();
    SKOSResource root = detectRootOfBranch();
    // on ajoute la racine de la branche
    AddConceptsStruct acs;
    acs = new AddConceptsStruct();
    acs.conceptHelper = new ConceptHelper();
    initAddConceptsStruct(acs, root);
    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);
    // on ajoute le reste
    skosXmlDocument.getConceptList().remove(root);
    for (SKOSResource resource : skosXmlDocument.getConceptList()) {
        acs = new AddConceptsStruct();
        acs.conceptHelper = new ConceptHelper();
        initAddConceptsStruct(acs, resource);
        addRelation(acs);
        acs.concept.setTopConcept(false);
        acs.concept.setIdGroup(idGroup);
        acs.conceptHelper.insertConceptInTable(ds, acs.concept, idUser);
        new GroupHelper().addConceptGroupConcept(ds, idGroup, acs.concept.getIdConcept(), acs.concept.getIdThesaurus());
        finalizeAddConceptStruct(acs);
    }
}
Also used : SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HierarchicalRelationship(mom.trd.opentheso.bdd.datas.HierarchicalRelationship) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 64 with GroupHelper

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

the class ImportRdf4jHelper method addGroups.

public void addGroups(rdf4jFileBean fileBean) {
    // récupération des groups ou domaine
    GroupHelper groupHelper = new GroupHelper();
    String idGroup;
    for (SKOSResource group : skosXmlDocument.getGroupList()) {
        fileBean.setAbs_progress(fileBean.getAbs_progress() + 1);
        fileBean.setProgress(fileBean.getAbs_progress() / fileBean.getTotal() * 100);
        idGroup = getIdFromUri(group.getUri());
        ArrayList<SKOSNotation> notationList = group.getNotationList();
        SKOSNotation notation = null;
        if (notationList != null && !notationList.isEmpty()) {
            notation = notationList.get(0);
        }
        String notationValue;
        if (notation == null) {
            notationValue = "";
        } else {
            notationValue = notation.getNotation();
        }
        String type;
        switch(group.getProperty()) {
            case SKOSProperty.Collection:
                type = "C";
                break;
            case SKOSProperty.ConceptGroup:
                type = "G";
                break;
            case SKOSProperty.MicroThesaurus:
            default:
                type = "MT";
                break;
            case SKOSProperty.Theme:
                type = "T";
                break;
        }
        groupHelper.insertGroup(ds, idGroup, thesaurus.getId_thesaurus(), type, notationValue, adressSite, useArk, idUser);
        // sub group
        String idSubGroup;
        // concept group concept
        String idSubConcept;
        for (SKOSRelation relation : group.getRelationsList()) {
            int prop = relation.getProperty();
            switch(prop) {
                case SKOSProperty.subGroup:
                    idSubGroup = getIdFromUri(relation.getTargetUri());
                    groupHelper.addSubGroup(ds, idGroup, idSubGroup, thesaurus.getId_thesaurus());
                    break;
                case SKOSProperty.member:
                    // option cochée
                    /*   if(identifierType.equalsIgnoreCase("sans")){
                            idSubConcept = getIdFromUri(relation.getTargetUri());
                        } else {*/
                    // Récupération de l'Id d'origine sauvegardé à l'import (idArk -> identifier)
                    idSubConcept = getOriginalId(relation.getTargetUri());
                    // }
                    groupHelper.addConceptGroupConcept(ds, idGroup, idSubConcept, thesaurus.getId_thesaurus());
                    memberHashMap.put(relation.getTargetUri(), idGroup);
                    break;
                case SKOSProperty.hasTopConcept:
                    hasTopConcceptList.add(relation.getTargetUri());
                    break;
                default:
                    break;
            }
        }
        for (SKOSLabel label : group.getLabelsList()) {
            // ajouter les traductions des Groupes
            ConceptGroupLabel conceptGroupLabel = new ConceptGroupLabel();
            conceptGroupLabel.setIdgroup(idGroup);
            conceptGroupLabel.setIdthesaurus(thesaurus.getId_thesaurus());
            conceptGroupLabel.setLang(label.getLanguage());
            conceptGroupLabel.setLexicalvalue(label.getLabel());
            groupHelper.addGroupTraduction(ds, conceptGroupLabel, idUser);
        }
    }
/*
        groupHelper.insertGroup(ds,
                idGroupDefault,
                thesaurus.getId_thesaurus(),
                "MT",
                "", //notation
                adressSite,
                useArk,
                idUser);
*/
// Création du domaine par défaut
// ajouter les traductions des Groupes
/*ConceptGroupLabel conceptGroupLabel = new ConceptGroupLabel();
        conceptGroupLabel.setIdgroup(idGroupDefault);
        conceptGroupLabel.setIdthesaurus(thesaurus.getId_thesaurus());
        
        conceptGroupLabel.setLang(langueSource);
        conceptGroupLabel.setLexicalvalue("groupDefault");
        groupHelper.addGroupTraduction(ds, conceptGroupLabel, idUser);*/
}
Also used : SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) ConceptGroupLabel(mom.trd.opentheso.bdd.datas.ConceptGroupLabel) SKOSRelation(mom.trd.opentheso.skosapi.SKOSRelation) SKOSLabel(mom.trd.opentheso.skosapi.SKOSLabel) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) SKOSNotation(mom.trd.opentheso.skosapi.SKOSNotation)

Example 65 with GroupHelper

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

the class ImportRdf4jHelper method addGroupDefault.

/**
 * Permet d'ajouter le Groupe par défaut pour les concepts qui sont orphelins
 * @return
 */
private void addGroupDefault() {
    if (defaultGroupToAdd) {
        GroupHelper groupHelper = new GroupHelper();
        groupHelper.insertGroup(ds, idGroupDefault, thesaurus.getId_thesaurus(), "MT", // notation
        "", adressSite, useArk, idUser);
        // Création du domaine par défaut
        // ajouter les traductions des Groupes
        ConceptGroupLabel conceptGroupLabel = new ConceptGroupLabel();
        conceptGroupLabel.setIdgroup(idGroupDefault);
        conceptGroupLabel.setIdthesaurus(thesaurus.getId_thesaurus());
        conceptGroupLabel.setLang(langueSource);
        conceptGroupLabel.setLexicalvalue("groupDefault");
        groupHelper.addGroupTraduction(ds, conceptGroupLabel, idUser);
    }
}
Also used : ConceptGroupLabel(mom.trd.opentheso.bdd.datas.ConceptGroupLabel) 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