Search in sources :

Example 56 with GroupHelper

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

the class SelectedTerme method creerTradterme.

/**
 * Ajoute une traduction au terme courant et met l'affichage à jour
 */
public void creerTradterme() {
    if (valueEdit == null || valueEdit.trim().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error3")));
        return;
    }
    boolean tradExist = false;
    // c'est le cas ou le concept n'a pas de traduction dans la langue en cours, il faut le mettre a jour dans l'arbre
    boolean newTraduction = false;
    for (Entry<String, String> e : langues) {
        if (e.getKey().equals(langueEdit)) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
            tradExist = true;
            break;
        }
    }
    ConceptHelper ch = new ConceptHelper();
    TermHelper termHelper = new TermHelper();
    if (idT.isEmpty()) {
        newTraduction = true;
        String tmp = termHelper.getIdTermOfConcept(connect.getPoolConnexion(), idC, idTheso);
        if (tmp != null) {
            idT = tmp;
        }
    }
    // traduction du domaine
    if (type == 1 && !tradExist) {
        ConceptGroupLabel cgl = new ConceptGroupLabel();
        cgl.setLexicalvalue(valueEdit);
        cgl.setIdgroup(idDomaine);
        cgl.setIdthesaurus(idTheso);
        cgl.setLang(langueEdit);
        GroupHelper cgh = new GroupHelper();
        if (cgh.isDomainExist(connect.getPoolConnexion(), cgl.getLexicalvalue(), cgl.getIdthesaurus(), cgl.getLang())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
            return;
        }
        if (!cgh.addGroupTraduction(connect.getPoolConnexion(), cgl, user.getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
            return;
        }
        ArrayList<NodeGroupTraductions> tempNGT = new GroupHelper().getGroupTraduction(connect.getPoolConnexion(), idDomaine, idTheso, idlangue);
        langues = new ArrayList<>();
        HashMap<String, String> tempMapL = new HashMap<>();
        for (NodeGroupTraductions ngt : tempNGT) {
            tempMapL.put(ngt.getIdLang(), ngt.getTitle());
        }
        if (newTraduction) {
            nom = cgh.getLexicalValueOfGroup(connect.getPoolConnexion(), idDomaine, idTheso, idlangue);
        }
        langues.addAll(tempMapL.entrySet());
    // traduction du TT
    } else if (type == 2 && !tradExist) {
        Term terme = new Term();
        terme.setId_thesaurus(idTheso);
        terme.setLang(langueEdit);
        terme.setLexical_value(valueEdit);
        terme.setId_term(idT);
        terme.setContributor(user.getUser().getId());
        terme.setCreator(user.getUser().getId());
        terme.setSource("");
        terme.setStatus("");
        if (termHelper.isTermExist(connect.getPoolConnexion(), terme.getLexical_value(), terme.getId_thesaurus(), terme.getLang())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
            return;
        }
        if (!ch.addTopConceptTraduction(connect.getPoolConnexion(), terme, user.getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
            return;
        }
        ArrayList<NodeTermTraduction> tempNTT = termHelper.getTraductionsOfConcept(connect.getPoolConnexion(), idC, idTheso, idlangue);
        langues = new ArrayList<>();
        HashMap<String, String> tempMapL = new HashMap<>();
        for (NodeTermTraduction ntt : tempNTT) {
            tempMapL.put(ntt.getLang(), ntt.getLexicalValue());
        }
        if (newTraduction) {
            nom = termHelper.getThisTerm(connect.getPoolConnexion(), idC, idTheso, idlangue).getLexical_value();
        }
        langues.addAll(tempMapL.entrySet());
    // traduction des concepts
    } else if (type == 3 && !tradExist) {
        Term terme = new Term();
        terme.setId_thesaurus(idTheso);
        terme.setLang(langueEdit);
        terme.setLexical_value(valueEdit);
        terme.setId_term(idT);
        terme.setContributor(user.getUser().getId());
        terme.setCreator(user.getUser().getId());
        terme.setSource("");
        terme.setStatus("");
        if (termHelper.isTermExist(connect.getPoolConnexion(), terme.getLexical_value(), terme.getId_thesaurus(), terme.getLang())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
            return;
        }
        if (!ch.addConceptTraduction(connect.getPoolConnexion(), terme, user.getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
            return;
        }
        ArrayList<NodeTermTraduction> tempNTT = termHelper.getTraductionsOfConcept(connect.getPoolConnexion(), idC, idTheso, idlangue);
        langues = new ArrayList<>();
        HashMap<String, String> tempMapL = new HashMap<>();
        for (NodeTermTraduction ntt : tempNTT) {
            tempMapL.put(ntt.getLang(), ntt.getLexicalValue());
        }
        langues.addAll(tempMapL.entrySet());
        if (newTraduction) {
            nom = termHelper.getThisTerm(connect.getPoolConnexion(), idC, idTheso, idlangue).getLexical_value();
        }
    }
    langueEdit = "";
    valueEdit = "";
    if (!tradExist) {
        vue.setAddTrad(0);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sTerme.info2")));
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HashMap(java.util.HashMap) ConceptGroupLabel(mom.trd.opentheso.bdd.datas.ConceptGroupLabel) ArrayList(java.util.ArrayList) PrefixString(com.k_int.IR.QueryModels.PrefixString) Term(mom.trd.opentheso.bdd.datas.Term) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeGroupTraductions(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions) FacesMessage(javax.faces.application.FacesMessage) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 57 with GroupHelper

use of mom.trd.opentheso.bdd.helper.GroupHelper 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)

Example 58 with GroupHelper

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

the class SelectedThesaurus method addSubGroup.

/**
 * permet d'ajouter un sous groupe avec un type défini, le groupe père doit
 * exister. Le sous-groupe prend le même type que le père
 *
 * @param codeTypeGroupFather
 * @param titleGroupSubGroup
 */
public void addSubGroup(String codeTypeGroupFather, String titleGroupSubGroup) {
    // typeDom = "";
    // si on a bien selectioner un group
    String idGroup = tree.getSelectedTerme().getIdC();
    if (new GroupHelper().isIdOfGroup(connect.getPoolConnexion(), idGroup, thesaurus.getId_thesaurus())) {
        String idSubGroup = addGroup(codeTypeGroupFather, titleGroupSubGroup);
        new GroupHelper().addSubGroup(connect.getPoolConnexion(), idGroup, idSubGroup, thesaurus.getId_thesaurus());
        tree.reInit();
        tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
    }
}
Also used : GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 59 with GroupHelper

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

the class ExportRdf4jHelper method addGroup.

/*
    private void addSelectedGroupRecursif(){
        
    }*/
public void addGroup(String idThesaurus, List<NodeLang> selectedLanguages, List<NodeGroup> selectedGroups) {
    rootGroupList = new GroupHelper().getListIdOfRootGroup(ds, idTheso);
    for (String idGroup : rootGroupList) {
        boolean isInselectedGroups = false;
        for (NodeGroup nodeGroup : selectedGroups) {
            if (nodeGroup.getConceptGroup().getIdgroup().equals(idGroup)) {
                isInselectedGroups = true;
                break;
            }
        }
        if (!isInselectedGroups) {
            continue;
        }
        SKOSResource group = new SKOSResource(getUriFromId(idGroup), SKOSProperty.ConceptGroup);
        group.addRelation(getUriFromId(idThesaurus), SKOSProperty.microThesaurusOf);
        addFilsGroupRcursif(idThesaurus, idGroup, group, selectedLanguages);
    }
}
Also used : SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 60 with GroupHelper

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

the class ExportRdf4jHelper method writeGroupInfo.

private void writeGroupInfo(SKOSResource sKOSResource, String idThesaurus, String idOfGroupChildren, List<NodeLang> selectedLanguages) {
    NodeGroupLabel nodeGroupLabel;
    nodeGroupLabel = new GroupHelper().getNodeGroupLabel(ds, idOfGroupChildren, idThesaurus);
    sKOSResource.setUri(getUriFromId(idOfGroupChildren));
    sKOSResource.setProperty(SKOSProperty.ConceptGroup);
    for (NodeGroupTraductions traduction : nodeGroupLabel.getNodeGroupTraductionses()) {
        boolean isInSelectedLanguages = false;
        for (NodeLang nodeLang : selectedLanguages) {
            if (nodeLang.getCode().equals(traduction.getIdLang())) {
                isInSelectedLanguages = true;
                break;
            }
        }
        if (!isInSelectedLanguages) {
            continue;
        }
        sKOSResource.addLabel(traduction.getTitle(), traduction.getIdLang(), SKOSProperty.prefLabel);
        // dates
        String created;
        String modified;
        created = traduction.getCreated().toString();
        modified = traduction.getModified().toString();
        if (created != null) {
            sKOSResource.addDate(created, SKOSProperty.created);
        }
        if (modified != null) {
            sKOSResource.addDate(modified, SKOSProperty.modified);
        }
    }
    ArrayList<String> childURI = new GroupHelper().getListGroupChildIdOfGroup(ds, idOfGroupChildren, idThesaurus);
    ArrayList<NodeUri> nodeUris = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, idOfGroupChildren, idThesaurus);
    for (NodeUri nodeUri : nodeUris) {
        sKOSResource.addRelation(getUriFromNodeUri(nodeUri, idThesaurus), SKOSProperty.member);
        addMember(nodeUri.getIdConcept(), idThesaurus, sKOSResource);
    }
    for (String id : childURI) {
        sKOSResource.addRelation(getUriFromId(id), SKOSProperty.subGroup);
        superGroupHashMap.put(id, idOfGroupChildren);
    }
    // addNotes(idOfGroupChildren, group, selectedLanguages);
    // addGPS(idOfGroupChildren, group);
    // addAlignement(idOfGroupChildren, group);
    // addRelation(idOfGroupChildren, group);
    String idSuperGroup = superGroupHashMap.get(idOfGroupChildren);
    if (idSuperGroup != null) {
        sKOSResource.addRelation(getUriFromId(idSuperGroup), SKOSProperty.superGroup);
        superGroupHashMap.remove(idOfGroupChildren);
    }
    skosXmlDocument.addGroup(sKOSResource);
    // liste top concept
    nodeTTs.addAll(nodeUris);
    for (NodeUri topConcept : nodeTTs) {
        skosXmlDocument.getConceptScheme().addRelation(getUriFromNodeUri(topConcept, idThesaurus), SKOSProperty.hasTopConcept);
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeGroupLabel(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroupTraductions(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions)

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