Search in sources :

Example 1 with NodeStatTheso

use of mom.trd.opentheso.bdd.helper.nodes.statistic.NodeStatTheso in project opentheso by miledrousset.

the class StatBean method creatCSVFile.

/**
 * #JM
 * Méthode pour créer un fichier télécharger
 * soit un fichier pour les statistiques du thesaurus soit pour les
 * statistiques concepts
 * @param idTheso
 * @return
 */
public StreamedContent creatCSVFile(String idTheso) {
    StringBuffer sbr = new StringBuffer();
    try {
        // ajou du titre au documen CSV
        ArrayList<String> line = new ArrayList<>();
        line.add("thesaurus : " + idTheso);
        line.add(lang.toUpperCase());
        line.add(new Date().toString());
        if (this.typeStat == 1)
            line.add(lb.getMsg("stat.forTheso"));
        if (this.typeStat == 2) {
            line.add(lb.getMsg("stat.forConcept"));
            if (searchFromDate) {
                line.add(lb.getMsg("stat.opt3") + " : " + begin);
                line.add(lb.getMsg("stat.opt4") + " : " + end);
                line.add((typeDate == 1) ? lb.getMsg("stat.opt2.1") : lb.getMsg("stat.opt2.2"));
            }
            if (searchFromGroup)
                line.add(lb.getMsg("stat.group") + " : " + this.selectedGroup);
        }
        writeLine(sbr, line);
        line = new ArrayList<>();
        // ajout entête du tableau
        if (this.typeStat == 1) {
            line.add(lb.getMsg("stat.statTheso1"));
            line.add(lb.getMsg("stat.statTheso2"));
            line.add(lb.getMsg("stat.statTheso3"));
            line.add(lb.getMsg("stat.statTheso4"));
            line.add(lb.getMsg("stat.statTheso5"));
        }
        if (this.typeStat == 2) {
            line.add(lb.getMsg("stat.statCpt1"));
            line.add(lb.getMsg("stat.idC"));
            line.add(lb.getMsg("stat.statCpt2"));
            line.add(lb.getMsg("stat.statCpt3"));
            line.add(lb.getMsg("stat.statCpt4"));
        }
        writeLine(sbr, line);
        if (this.typeStat == 1) {
            for (NodeStatTheso nst : this.statTheso) {
                line = new ArrayList<>();
                line.add(nst.getGroup());
                line.add("" + nst.getNbDescripteur());
                line.add("" + nst.getNbNonDescripteur());
                line.add("" + nst.getNbNoTrad());
                line.add("" + nst.getNbNotes());
                writeLine(sbr, line);
            }
        }
        if (this.typeStat == 2) {
            for (NodeStatConcept nsc : this.statConcept) {
                line = new ArrayList<>();
                line.add(nsc.getValue());
                line.add(nsc.getIdConcept());
                line.add("" + nsc.getDateCreat());
                line.add("" + nsc.getDateEdit());
                line.add(nsc.getGroup());
                writeLine(sbr, line);
            }
        }
    } catch (IOException e) {
        System.out.println("erreur pendant l'écriture du fichier" + e);
        return null;
    }
    InputStream stream;
    StreamedContent file = null;
    try {
        stream = new ByteArrayInputStream(sbr.toString().getBytes("UTF-8"));
        String name_file = (typeStat == 1) ? "downloadedCsv_Thesaurus_stat.csv" : "downloadedCsv_concept_stat.csv";
        file = new DefaultStreamedContent(stream, "text/csv", name_file);
    } catch (UnsupportedEncodingException e) {
        System.out.println("erreur création inputStream " + e);
        return null;
    }
    return file;
}
Also used : DefaultStreamedContent(org.primefaces.model.DefaultStreamedContent) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) NodeStatConcept(mom.trd.opentheso.bdd.helper.nodes.statistic.NodeStatConcept) ArrayList(java.util.ArrayList) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) Date(java.util.Date) NodeStatTheso(mom.trd.opentheso.bdd.helper.nodes.statistic.NodeStatTheso) ByteArrayInputStream(java.io.ByteArrayInputStream) StreamedContent(org.primefaces.model.StreamedContent) DefaultStreamedContent(org.primefaces.model.DefaultStreamedContent)

Example 2 with NodeStatTheso

use of mom.trd.opentheso.bdd.helper.nodes.statistic.NodeStatTheso in project opentheso by miledrousset.

the class StatBean method loadStatTheso.

public void loadStatTheso(String idTheso, String langue) {
    statTheso = new ArrayList<>();
    nbCpt = new StatisticHelper().getNbCpt(connect.getPoolConnexion(), idTheso);
    ArrayList<NodeGroup> lng = new GroupHelper().getListConceptGroup(connect.getPoolConnexion(), idTheso, langue);
    Collections.sort(lng);
    StatisticHelper sh = new StatisticHelper();
    for (NodeGroup ng : lng) {
        NodeStatTheso nst = new NodeStatTheso();
        nst.setGroup(ng.getLexicalValue() + "(" + ng.getConceptGroup().getIdgroup() + ")");
        nst.setNbDescripteur(sh.getNbDescOfGroup(connect.getPoolConnexion(), idTheso, ng.getConceptGroup().getIdgroup()));
        nst.setNbNonDescripteur(sh.getNbNonDescOfGroup(connect.getPoolConnexion(), idTheso, ng.getConceptGroup().getIdgroup(), langue));
        int termNonTraduit = nst.getNbDescripteur() - sh.getNbTradOfGroup(connect.getPoolConnexion(), idTheso, ng.getConceptGroup().getIdgroup(), langue);
        nst.setNbNoTrad(termNonTraduit);
        int nombreNote = sh.getNbDefinitionNoteOfGroup(connect.getPoolConnexion(), idTheso, langue, ng.getConceptGroup().getIdgroup());
        nst.setNbNotes(nombreNote);
        statTheso.add(nst);
    }
    vue.setStatTheso(true);
    vue.setStatCpt(false);
    vue.setStatPermuted(false);
}
Also used : StatisticHelper(mom.trd.opentheso.bdd.helper.StatisticHelper) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeStatTheso(mom.trd.opentheso.bdd.helper.nodes.statistic.NodeStatTheso) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Aggregations

NodeStatTheso (mom.trd.opentheso.bdd.helper.nodes.statistic.NodeStatTheso)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)1 StatisticHelper (mom.trd.opentheso.bdd.helper.StatisticHelper)1 NodeGroup (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)1 NodeStatConcept (mom.trd.opentheso.bdd.helper.nodes.statistic.NodeStatConcept)1 DefaultStreamedContent (org.primefaces.model.DefaultStreamedContent)1 StreamedContent (org.primefaces.model.StreamedContent)1