Search in sources :

Example 11 with FacesMessage

use of javax.faces.application.FacesMessage in project opentheso by miledrousset.

the class NewRestJson method openConnexionPool.

private HikariDataSource openConnexionPool(Properties properties) {
    HikariConfig config = new HikariConfig();
    config.setMinimumIdle(Integer.parseInt(properties.getProperty("minimumIdle")));
    config.setMaximumPoolSize(Integer.parseInt(properties.getProperty("setMaximumPoolSize")));
    config.setAutoCommit(true);
    config.setIdleTimeout(Integer.parseInt(properties.getProperty("idleTimeout")));
    config.setConnectionTimeout(Integer.parseInt(properties.getProperty("connectionTimeout")));
    config.setConnectionTestQuery(properties.getProperty("connectionTestQuery"));
    config.setDataSourceClassName(properties.getProperty("dataSourceClassName"));
    config.addDataSourceProperty("user", properties.getProperty("dataSource.user"));
    config.addDataSourceProperty("password", properties.getProperty("dataSource.password"));
    config.addDataSourceProperty("databaseName", properties.getProperty("dataSource.databaseName"));
    config.addDataSourceProperty("serverName", properties.getProperty("dataSource.serverName"));
    config.addDataSourceProperty("portNumber", properties.getProperty("dataSource.serverPort"));
    HikariDataSource poolConnexion1 = new HikariDataSource(config);
    try {
        Connection conn = poolConnexion1.getConnection();
        if (conn == null) {
            return null;
        }
        conn.close();
    } catch (SQLException ex) {
        Logger.getLogger(Connexion.class.getName()).log(Level.SEVERE, null, ex);
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_FATAL, ex.getClass().getName(), ex.getMessage());
        FacesContext.getCurrentInstance().addMessage(null, message);
        poolConnexion1.close();
        return null;
    }
    return poolConnexion1;
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) SQLException(java.sql.SQLException) Connection(java.sql.Connection) HikariConfig(com.zaxxer.hikari.HikariConfig) Connexion(mom.trd.opentheso.bdd.helper.Connexion) FacesMessage(javax.faces.application.FacesMessage)

Example 12 with FacesMessage

use of javax.faces.application.FacesMessage in project opentheso by miledrousset.

the class SelectedTerme method creerTermeSpe.

/**
 * *************************************** CREATION
 * ****************************************
 */
/**
 * Crée un nouveau terme spécifique au terme sélectionné
 *
 * @param selecedTerm
 * @return true or false
 */
public boolean creerTermeSpe(MyTreeNode selecedTerm) {
    ConceptHelper instance = new ConceptHelper();
    if (user.nodePreference == null)
        return false;
    instance.setNodePreference(user.getNodePreference());
    // 1 = domaine/Group, 2 = TT (top Term), 3 = Concept/term
    if (selecedTerm.isIsSubGroup() || selecedTerm.isIsGroup()) {
        // ici c'est le cas d'un Group ou Sous Group, on crée un TT Top Terme
        Concept concept = new Concept();
        concept.setIdGroup(selecedTerm.getIdConcept());
        concept.setIdThesaurus(idTheso);
        concept.setStatus("D");
        concept.setNotation("");
        Term terme = new Term();
        terme.setId_thesaurus(idTheso);
        terme.setLang(idlangue);
        terme.setLexical_value(valueEdit);
        terme.setSource("");
        terme.setStatus("");
        if (instance.addTopConcept(connect.getPoolConnexion(), idTheso, concept, terme, user.getUser().getId()) == null) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", instance.getMessage()));
            return false;
        }
        // instance.insertID_grouptoPermuted(connect.getPoolConnexion(), concept.getIdThesaurus(), concept.getIdConcept());
        ConceptHelper ch = new ConceptHelper();
        ArrayList<NodeConceptTree> tempNT = ch.getListTopConcepts(connect.getPoolConnexion(), idC, idTheso, idlangue);
        termesSpecifique = new ArrayList<>();
        HashMap<String, String> tempMap = new HashMap<>();
        for (NodeConceptTree nct : tempNT) {
            tempMap.put(nct.getIdConcept(), nct.getTitle());
        }
        termesSpecifique.addAll(tempMap.entrySet());
    } else {
        Concept concept = new Concept();
        concept.setIdGroup(selecedTerm.getIdCurrentGroup());
        concept.setIdThesaurus(idTheso);
        concept.setStatus("D");
        concept.setNotation("");
        Term terme = new Term();
        terme.setId_thesaurus(idTheso);
        terme.setLang(idlangue);
        terme.setLexical_value(valueEdit);
        terme.setSource("");
        terme.setStatus("");
        // String idTC = idTopConcept;
        String idP = idC;
        if (instance.addConcept(connect.getPoolConnexion(), idP, concept, terme, user.getUser().getId()) == null) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", instance.getMessage()));
            return false;
        }
        // instance.insertID_grouptoPermuted(connect.getPoolConnexion(), concept.getIdThesaurus(), concept.getIdConcept());
        concept.getUserName();
        ArrayList<NodeNT> tempNT = new RelationsHelper().getListNT(connect.getPoolConnexion(), idC, idTheso, idlangue);
        termesSpecifique = new ArrayList<>();
        HashMap<String, String> tempMap = new HashMap<>();
        for (NodeNT nnt : tempNT) {
            tempMap.put(nnt.getIdConcept(), nnt.getTitle() + " (" + nnt.getRole() + ")");
        }
        termesSpecifique.addAll(tempMap.entrySet());
    }
    vue.setAddTSpe(false);
    valueEdit = "";
    return true;
}
Also used : Concept(mom.trd.opentheso.bdd.datas.Concept) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HashMap(java.util.HashMap) Term(mom.trd.opentheso.bdd.datas.Term) PrefixString(com.k_int.IR.QueryModels.PrefixString) NodeNT(mom.trd.opentheso.bdd.helper.nodes.NodeNT) NodeConceptTree(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree) FacesMessage(javax.faces.application.FacesMessage) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper)

Example 13 with FacesMessage

use of javax.faces.application.FacesMessage in project opentheso by miledrousset.

the class SelectedTerme method editNoteHisto.

/**
 * Crée ou modifie la note historique du terme courant
 */
public void editNoteHisto() {
    int idUser = user.getUser().getId();
    if (noteHistorique.isEmpty()) {
        deleteThisNoteOfConcept("note");
        return;
    }
    if (new NoteHelper().isNoteExistOfTerm(connect.getPoolConnexion(), idT, idTheso, idlangue, "historyNote")) {
        new NoteHelper().updateTermNote(connect.getPoolConnexion(), idT, idlangue, idTheso, noteHistorique, "historyNote", idUser);
    } else {
        new NoteHelper().addTermNote(connect.getPoolConnexion(), idT, idlangue, idTheso, noteHistorique, "historyNote", idUser);
    }
    majNotes();
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sTerme.info12")));
}
Also used : NoteHelper(mom.trd.opentheso.bdd.helper.NoteHelper) FacesMessage(javax.faces.application.FacesMessage)

Example 14 with FacesMessage

use of javax.faces.application.FacesMessage in project opentheso by miledrousset.

the class SelectedTerme method addTermeGeneOtherGroup.

/**
 * Ajoute une relation terme générique au concept courant
 *
 * @param idConcept
 * @param idGroup
 * @param idNewConceptBT
 * @return true or false
 */
public boolean addTermeGeneOtherGroup(String idConcept, String idGroup, String idNewConceptBT) {
    ConceptHelper conceptHelper = new ConceptHelper();
    RelationsHelper relationsHelper = new RelationsHelper();
    GroupHelper groupHelper = new GroupHelper();
    String idNewGroup = conceptHelper.getGroupIdOfConcept(connect.getPoolConnexion(), idNewConceptBT, idTheso);
    if (idNewGroup == null) {
        return false;
    }
    try {
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        if (termeGenerique.isEmpty()) {
            // c'était un orphelin
            if (!new OrphanHelper().deleteOrphan(conn, idConcept, idTheso)) {
                conn.rollback();
                conn.close();
                return false;
            }
        }
        // On ajoute la realtion BT au concept
        if (!relationsHelper.addRelationBT(conn, idConcept, idTheso, idNewConceptBT, user.getUser().getId())) {
            conn.rollback();
            conn.close();
            return false;
        }
        // on récupère les Ids des concepts à modifier
        ArrayList<String> lisIds = new ArrayList<>();
        lisIds = conceptHelper.getIdsOfBranch(connect.getPoolConnexion(), idConcept, idTheso, lisIds);
        // on ajoute le nouveau domaine à la branche
        if (!groupHelper.addDomainToBranch(conn, lisIds, idNewGroup, idTheso, user.getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
            conn.rollback();
            conn.close();
            return false;
        }
        conn.commit();
        conn.close();
    } catch (SQLException ex) {
        Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
        return false;
    }
    termeGenerique = new ArrayList<>();
    majTGen();
    return true;
}
Also used : OrphanHelper(mom.trd.opentheso.bdd.helper.OrphanHelper) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) PrefixString(com.k_int.IR.QueryModels.PrefixString) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) FacesMessage(javax.faces.application.FacesMessage)

Example 15 with FacesMessage

use of javax.faces.application.FacesMessage in project opentheso by miledrousset.

the class SelectedTerme method deleteThisNoteOfConcept.

/**
 * Cette fonction permet de supprimer une note suivant son type
 *
 * @param noteTypeCode
 */
public void deleteThisNoteOfConcept(String noteTypeCode) {
    int idUser = user.getUser().getId();
    new NoteHelper().deletethisNoteOfConcept(connect.getPoolConnexion(), idC, idTheso, idlangue, noteTypeCode);
    majNotes();
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sTerme.info13")));
}
Also used : NoteHelper(mom.trd.opentheso.bdd.helper.NoteHelper) FacesMessage(javax.faces.application.FacesMessage)

Aggregations

FacesMessage (javax.faces.application.FacesMessage)370 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)43 SQLException (java.sql.SQLException)40 Connection (java.sql.Connection)34 FacesContext (javax.faces.context.FacesContext)25 ArrayList (java.util.ArrayList)24 UIInput (javax.faces.component.UIInput)24 ValidatorException (javax.faces.validator.ValidatorException)24 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)22 NodeAutoCompletion (mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)22 CandidateHelper (mom.trd.opentheso.bdd.helper.CandidateHelper)19 UserHelper2 (mom.trd.opentheso.bdd.helper.UserHelper2)19 IOException (java.io.IOException)16 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)15 Test (org.junit.Test)13 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)12 Term (mom.trd.opentheso.bdd.datas.Term)11 UploadedFile (org.primefaces.model.UploadedFile)11 HikariDataSource (com.zaxxer.hikari.HikariDataSource)10 Date (java.util.Date)10