Search in sources :

Example 51 with GroupHelper

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

the class SelectedCandidat method toInsert.

/**
 * Passe un candidat de son état courant à l'état inséré. Les modifications
 * nécessaires en bases de données sont traitées ici.
 *
 * @return
 */
public boolean toInsert() {
    setPreferences();
    if (selectedNvx == null) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sCdt.error4")));
        return false;
    }
    niveauEdit = selectedNvx.getIdConcept();
    /*else {
            niveauEdit = null;
        }*/
    /*   if (domaineEdit == null || domaineEdit.trim().equals("")) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sCdt.error1")));
            return false;
        }*/
    GroupHelper groupHelper = new GroupHelper();
    ArrayList<String> idGroups = groupHelper.getListIdGroupOfConcept(connect.getPoolConnexion(), idTheso, niveauEdit);
    if (tradInsert.isEmpty()) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sCdt.error2")));
        return false;
    }
    if (new TermHelper().isTermExist(connect.getPoolConnexion(), selected.getValue().trim(), idTheso, langueTheso)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("tree.error2")));
        return false;
    }
    if (idGroups.isEmpty()) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", "No Group Error !!"));
        return false;
    }
    HashMap<String, String> trad = new HashMap<>();
    if (tradInsert.contains(langueTheso)) {
        trad.put(langueTheso, selected.getValue());
        tradInsert.remove(langueTheso);
    }
    for (String l : tradInsert) {
        for (NodeTraductionCandidat ntc : infoCdt.getNodeTraductions()) {
            if (l.equals(ntc.getIdLang())) {
                trad.put(l, ntc.getTitle());
            }
        }
    }
    ArrayList<Entry<String, String>> temp = new ArrayList<>(trad.entrySet());
    ConceptHelper instance = new ConceptHelper();
    instance.setNodePreference(user.getNodePreference());
    Concept concept = new Concept();
    concept.setIdGroup(idGroups.get(0));
    concept.setIdThesaurus(idTheso);
    concept.setStatus("D");
    concept.setNotation("");
    String langueTemp = temp.get(0).getKey();
    Term terme = new Term();
    terme.setId_thesaurus(idTheso);
    terme.setLang(temp.get(0).getKey());
    terme.setLexical_value(temp.get(0).getValue());
    temp.remove(0);
    String idc;
    // if (niveauEdit == null || niveauEdit.trim().equals("")) { // Top concept
    // idc = instance.addTopConcept(connect.getPoolConnexion(), idTheso, concept, terme, serverAdress, arkActive, theUser.getUser().getId());
    // } else { // concept
    idc = instance.addConcept(connect.getPoolConnexion(), niveauEdit, concept, terme, theUser.getUser().getId());
    // permet d'ajouter les domaines au nouveau concept
    for (String idGroup : idGroups) {
        groupHelper.addConceptGroupConcept(connect.getPoolConnexion(), idGroup, niveauEdit, idTheso);
    }
    if (!temp.isEmpty()) {
        String idt = new TermHelper().getThisTerm(connect.getPoolConnexion(), idc, idTheso, langueTemp).getId_term();
        for (Entry<String, String> e : temp) {
            terme = new Term();
            terme.setId_concept(idc);
            terme.setId_term(idt);
            terme.setId_thesaurus(idTheso);
            terme.setLang(e.getKey());
            terme.setLexical_value(e.getValue());
            new TermHelper().addTraduction(connect.getPoolConnexion(), terme, theUser.getUser().getId());
        }
    }
    CandidateHelper ch = new CandidateHelper();
    ch.updateCandidatStatus(connect.getPoolConnexion(), "i", idTheso, selected.getIdConcept());
    ch.addAdminMessage(connect.getPoolConnexion(), selected.getIdConcept(), idTheso, theUser.getUser().getId(), msgValid);
    // message d'alerte
    /*    ArrayList<NodeUser> contribs = ch.getListUsersOfCandidat(connect.getPoolConnexion(),
            selected.getIdConcept(), idTheso);*/
    /*    for (NodeUser nodeUser : contribs) {
            if (!lesMails.contains(contrib)) {
                lesMails.add(contrib);
            }
        }*/
    /*
        for (NodeUser nodeUser : contribs) {
            if (nodeUser.getMail() != null &&  !nodeUser.getMail().trim().equals("")) {
                String message =  "Votre candidat " + selected.getValue() + " a été intégré au thésaurus par le(a) terminologue : " + theUser.getUser().getName() + ".";
                envoyerMailAlert(nodeUser.getMail(), message);
            }
        } */
    msgValid = "";
    selected.setEtat("i");
    vue.setAddInsertCdt(false);
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sCdt.info6")));
    return true;
}
Also used : Concept(mom.trd.opentheso.bdd.datas.Concept) NodeTraductionCandidat(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeTraductionCandidat) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Term(mom.trd.opentheso.bdd.datas.Term) Entry(java.util.Map.Entry) FacesMessage(javax.faces.application.FacesMessage) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 52 with GroupHelper

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

the class SelectedCandidat method editMyProp.

/**
 * Permet d'éditer sa propre proposition
 *
 * @param langue
 */
public void editMyProp(String langue) {
    if (selectedNvx != null) {
        niveauEdit = selectedNvx.getIdConcept();
    } else {
        niveauEdit = "";
    }
    if (domaineEdit == null) {
        domaineEdit = "";
    }
    new CandidateHelper().updatePropositionCandidat(connect.getPoolConnexion(), selected.getIdConcept(), theUser.getUser().getId(), idTheso, noteEdit, niveauEdit, domaineEdit);
    NodeProposition np = new CandidateHelper().getNodePropositionOfUser(connect.getPoolConnexion(), selected.getIdConcept(), idTheso, infoCdt.getNodesUser().get(0).getId());
    infoCdt.setNodesUser(new CandidateHelper().getListUsersOfCandidat(connect.getPoolConnexion(), selected.getIdConcept(), idTheso));
    note = np.getNote();
    niveau = new ConceptHelper().getLexicalValueOfConcept(connect.getPoolConnexion(), np.getIdConceptParent(), idTheso, langue) + " (" + np.getIdConceptParent() + ")";
    domaine = new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), np.getIdGroup(), idTheso, langue) + " (" + np.getIdGroup() + ")";
    vue.setEditPropCandidat(false);
    selectedNvx = new NodeAutoCompletion();
    domaineEdit = "";
    niveauEdit = "";
    noteEdit = "";
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sCdt.info8")));
}
Also used : NodeProposition(mom.trd.opentheso.bdd.helper.nodes.candidat.NodeProposition) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion) FacesMessage(javax.faces.application.FacesMessage) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Example 53 with GroupHelper

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

the class SelectedTerme method majTerme.

/**
 * *************************************** MISE A JOUR
 * ****************************************
 */
/**
 * Met à jour le terme à la sélection d'un node de l'arbre (traitement
 * différent si Domaine/TopConcept/Concept)
 *
 * @param sN
 */
public void majTerme(MyTreeNode sN) {
    // contrôler si la connexion est toujour valide
    // connect.
    selectedNode = sN;
    reInitTerme();
    majPref();
    idC = sN.getIdConcept();
    idTheso = sN.getIdTheso();
    idlangue = sN.getLangue();
    idDomaine = sN.getIdCurrentGroup();
    idTopConcept = sN.getIdTopConcept();
    type = sN.getTypeConcept();
    status = "";
    notation = "";
    latitudLongitud = null;
    totalConceptOfBranch = "";
    totalNoticesOfBranch = "";
    majTAsso();
    GroupHelper groupHelper = new GroupHelper();
    ConceptHelper conceptHelper = new ConceptHelper();
    if (groupHelper.isIdOfGroup(connect.getPoolConnexion(), idC, idTheso)) {
        microTheso = new GroupHelper().getLexicalValueOfGroup(connect.getPoolConnexion(), idDomaine, idTheso, idlangue);
        NodeGroup ncg = new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(), idC, idTheso, idlangue);
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        nom = ncg.getLexicalValue();
        idArk = ncg.getConceptGroup().getIdARk();
        nomEdit = nom;
        idT = "";
        if (ncg.getCreated() != null && ncg.getModified() != null) {
            dateC = dateFormat.format(ncg.getCreated());
            dateM = dateFormat.format(ncg.getModified());
        }
        majGroupTGen();
        majLangueGroup();
        majTSpeGroup();
        majNotes();
    } else {
        Concept concept = conceptHelper.getThisConcept(connect.getPoolConnexion(), idC, idTheso);
        if (concept == null) {
            return;
        }
        status = concept.getStatus();
        notation = concept.getNotation();
        if (!idDomaine.equals("Orphan")) {
            majGroup();
            majTGen();
        } else {
            microTheso = idDomaine;
        }
        Term t = new TermHelper().getThisTerm(connect.getPoolConnexion(), idC, idTheso, idlangue);
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        nom = t.getLexical_value();
        nomEdit = nom;
        idT = t.getId_term();
        dateC = dateFormat.format(t.getCreated());
        dateM = dateFormat.format(t.getModified());
        creator = t.getCreator();
        contributor = t.getContributor();
        images = new ImagesHelper().getImage(connect.getPoolConnexion(), idC, idTheso, user.getUser().getId());
        majNotes();
        majLangueConcept();
        majSyno();
        updateGps();
        majTSpeConcept();
        align = new AlignmentHelper().getAllAlignmentOfConcept(connect.getPoolConnexion(), idC, idTheso);
        // ResourceBundle bundlePref = getBundlePref();
        if (user.getNodePreference().isZ3950actif()) {
            majNoticeZ3950();
        }
        if (user.getNodePreference().isBddActive()) {
            majNoticeBdd();
        }
        idArk = conceptHelper.getIdArkOfConcept(connect.getPoolConnexion(), idC, idTheso);
        idHandle = conceptHelper.getIdHandleOfConcept(connect.getPoolConnexion(), idC, idTheso);
        reInitFacette();
        initTree();
    }
}
Also used : Concept(mom.trd.opentheso.bdd.datas.Concept) ImagesHelper(mom.trd.opentheso.bdd.helper.ImagesHelper) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) AlignmentHelper(mom.trd.opentheso.bdd.helper.AlignmentHelper) Term(mom.trd.opentheso.bdd.datas.Term) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) SimpleDateFormat(java.text.SimpleDateFormat) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 54 with GroupHelper

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

the class SelectedTerme method majTSpeGroup.

private void majTSpeGroup() {
    termesSpecifique = new ArrayList<>();
    ConceptHelper ch = new ConceptHelper();
    GroupHelper gh = new GroupHelper();
    ArrayList<NodeConceptTree> tempNT = ch.getListTopConcepts(connect.getPoolConnexion(), idC, idTheso, idlangue);
    for (NodeConceptTree nct : tempNT) {
        HashMap<String, String> tempMap1 = new HashMap<>();
        tempMap1.put(nct.getIdConcept(), nct.getTitle());
        termesSpecifique.addAll(tempMap1.entrySet());
    }
/*for(String tGroup : ch.getListGroupChildIdOfGroup(connect.getPoolConnexion(), idC, idTheso)){
            
            String value  = gh.getLexicalValueOfGroup(connect.getPoolConnexion(), tGroup, idTheso, idlangue);
            HashMap<String, String> tempMap1 = new HashMap<>();
            tempMap1.put(tGroup, value);
            termesSpecifique.addAll(tempMap1.entrySet());
        }*/
}
Also used : NodeConceptTree(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HashMap(java.util.HashMap) PrefixString(com.k_int.IR.QueryModels.PrefixString) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 55 with GroupHelper

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

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