Search in sources :

Example 1 with PreferencesHelper

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

the class CurrentUser method initUserNodePref.

public void initUserNodePref(String idThesaurus) {
    PreferencesHelper preferencesHelper = new PreferencesHelper();
    nodePreference = preferencesHelper.getThesaurusPreference(connect.getPoolConnexion(), idThesaurus);
}
Also used : PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

Example 2 with PreferencesHelper

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

the class CurrentUser method editAllPref.

public void editAllPref() {
    // nodePreference.setAlertCdt(alertCdtEdit);
    nodePreference.setSourceLang(langSourceEdit);
    if (!new PreferencesHelper().updateAllPreferenceUser(connect.getPoolConnexion(), nodePreference, idTheso)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
        return;
    }
    initUserNodePref(idTheso);
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info6")));
}
Also used : FacesMessage(javax.faces.application.FacesMessage) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

Example 3 with PreferencesHelper

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

the class CurrentUser method getThesaurusPreferences.

/**
 * cette fonction permet de retourner les préférences d'un thésaurus, s'il y
 * en a pas, on les initialises par les valeurs par defaut
 *
 * @param idThesaurus
 * @param workLanguage
 * @return
 */
public NodePreference getThesaurusPreferences(String idThesaurus, String workLanguage) {
    if (user.getId() == 1) {
        // superAdmin
        authorizedTheso = new ThesaurusHelper().getAllIdOfThesaurus(connect.getPoolConnexion());
    } else {
        authorizedTheso = new UserHelper().getAuthorizedThesaurus(connect.getPoolConnexion(), user.getId());
    }
    PreferencesHelper preferencesHelper = new PreferencesHelper();
    if (connect.getPoolConnexion() != null) {
        nodePreference = preferencesHelper.getThesaurusPreference(connect.getPoolConnexion(), idThesaurus);
        if (nodePreference == null) {
            // cas où il n'y a pas de préférence pour ce thésaurus, il faut les créer
            preferencesHelper.initPreferences(connect.getPoolConnexion(), idThesaurus, workLanguage);
            nodePreference = preferencesHelper.getThesaurusPreference(connect.getPoolConnexion(), idThesaurus);
        } else {
            langSourceEdit = nodePreference.getSourceLang();
            // alertNbCdtEdit = nodePreference.getNbAlertCdt();
            // alertCdtEdit = nodePreference.isAlertCdt();
            selectedThesaurus = new ArrayList<>();
            selectedThesaurus.add(idTheso);
        }
        idTheso = idThesaurus;
        versionOfOpentheso = new BaseDeDoneesHelper().getVersionOfOpentheso(connect.getPoolConnexion());
        return nodePreference;
    }
    return null;
}
Also used : UserHelper(mom.trd.opentheso.bdd.helper.UserHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) BaseDeDoneesHelper(mom.trd.opentheso.bdd.helper.BaseDeDoneesHelper) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

Example 4 with PreferencesHelper

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

the class DownloadBean method thesoTxtCsv.

/**
 * Permet d'exporter le thésauurus au format txt (tabulé et hiérarchisé)
 * avec des options de colonnes supplémentaires NT, BT, RT, Notes, traductions
 * ceci figure dans le tableau (String[] selectedOptions)
 * @param idTheso
 * @param selectedGroups
 * @param codeLang
 * @param selectedOptions
 * @return
 * MR
 */
public StreamedContent thesoTxtCsv(String idTheso, List<NodeGroup> selectedGroups, String codeLang, ArrayList<String> selectedOptions) {
    progress_per_100 = 0;
    progress_abs = 0;
    NodePreference nodePreference = new PreferencesHelper().getThesaurusPreference(connect.getPoolConnexion(), idTheso);
    if (nodePreference == null)
        return null;
    ExportTxtHelper exportTxtHelper = new ExportTxtHelper();
    exportTxtHelper.setThesaurusDatas(connect.getPoolConnexion(), idTheso, codeLang, selectedGroups, nodePreference, selectedOptions);
    exportTxtHelper.exportToTxtCsv();
    InputStream stream;
    try {
        stream = new ByteArrayInputStream(exportTxtHelper.getTxtBuff().toString().getBytes("UTF-8"));
        file = new DefaultStreamedContent(stream, "text/csv", "Txt_" + idTheso + ".csv");
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    return file;
}
Also used : DefaultStreamedContent(org.primefaces.model.DefaultStreamedContent) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NodePreference(mom.trd.opentheso.bdd.helper.nodes.NodePreference) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper) ExportTxtHelper(mom.trd.opentheso.core.exports.helper.ExportTxtHelper)

Example 5 with PreferencesHelper

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

the class DownloadBean method thesoPDF.

public StreamedContent thesoPDF(String idTheso, List<NodeLang> selectedLanguages, List<NodeGroup> selectedGroups, String codeLang, String codeLang2, int type) {
    progress_per_100 = 0;
    progress_abs = 0;
    NodePreference nodePreference = new PreferencesHelper().getThesaurusPreference(connect.getPoolConnexion(), idTheso);
    if (nodePreference == null)
        return null;
    sizeOfTheso = new ConceptHelper().getAllIdConceptOfThesaurus(connect.getPoolConnexion(), idTheso).size();
    ExportRdf4jHelper exportRdf4jHelper = new ExportRdf4jHelper();
    exportRdf4jHelper.setInfos(connect.getPoolConnexion(), "dd-mm-yyyy", false, idTheso, nodePreference.getCheminSite());
    exportRdf4jHelper.setNodePreference(nodePreference);
    exportRdf4jHelper.addThesaurus(idTheso, selectedLanguages);
    exportRdf4jHelper.addGroup(idTheso, selectedLanguages, selectedGroups);
    exportRdf4jHelper.addConcept(idTheso, this, selectedLanguages);
    WritePdf writePdf = new WritePdf(exportRdf4jHelper.getSkosXmlDocument(), codeLang, codeLang2, type);
    InputStream stream;
    stream = new ByteArrayInputStream(writePdf.getOutput().toByteArray());
    file = new DefaultStreamedContent(stream, "application/pdf", "test.pdf");
    return file;
}
Also used : DefaultStreamedContent(org.primefaces.model.DefaultStreamedContent) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) WritePdf(mom.trd.opentheso.core.exports.pdf.WritePdf) ExportRdf4jHelper(mom.trd.opentheso.core.exports.rdf4j.helper.ExportRdf4jHelper) NodePreference(mom.trd.opentheso.bdd.helper.nodes.NodePreference) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

Aggregations

PreferencesHelper (mom.trd.opentheso.bdd.helper.PreferencesHelper)20 ExportFromBDD (mom.trd.opentheso.core.exports.old.ExportFromBDD)9 NodePreference (mom.trd.opentheso.bdd.helper.nodes.NodePreference)8 ExportRdf4jHelper (mom.trd.opentheso.core.exports.rdf4j.helper.ExportRdf4jHelper)7 WriteRdf4j (mom.trd.opentheso.core.exports.rdf4j.WriteRdf4j)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)4 RDFFormat (org.eclipse.rdf4j.rio.RDFFormat)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 ByteArrayContent (org.primefaces.model.ByteArrayContent)2 DefaultStreamedContent (org.primefaces.model.DefaultStreamedContent)2 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 ConnexionTest (connexion.ConnexionTest)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 FacesMessage (javax.faces.application.FacesMessage)1 BaseDeDoneesHelper (mom.trd.opentheso.bdd.helper.BaseDeDoneesHelper)1 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)1 UserHelper (mom.trd.opentheso.bdd.helper.UserHelper)1