Search in sources :

Example 1 with WriteXml

use of mom.trd.opentheso.core.exports.privatesdatas.WriteXml in project opentheso by miledrousset.

the class BaseDeDonnesBean method backUpBaseDonnees.

/**
 * Cette fonction permet de télécharger les tables et les données ce qui
 * permet de sauvegarder toutes les données privées pour les mise à jour
 *
 * @param toutTables
 * @return
 */
public StreamedContent backUpBaseDonnees(ArrayList<String> toutTables) {
    ArrayList<Table> sortirXml;
    ExportPrivatesDatas backUp = new ExportPrivatesDatas();
    Iterator<String> it1 = toutTables.iterator();
    WriteXml write = new WriteXml();
    write.writeHead();
    write.start();
    String table = "";
    // date du jour
    java.util.Date datetoday = new java.util.Date();
    while (it1.hasNext()) {
        table = it1.next();
        sortirXml = backUp.getDatasOfTable(connect.getPoolConnexion(), table);
        write.WriteIntoXML(sortirXml, table);
    }
    write.end();
    InputStream stream;
    try {
        stream = new ByteArrayInputStream(write.getXml().toString().getBytes("UTF-8"));
        file = new DefaultStreamedContent(stream, "application/xml", "backupOpentheso_" + datetoday + ".xml");
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    return file;
}
Also used : DefaultStreamedContent(org.primefaces.model.DefaultStreamedContent) Table(mom.trd.opentheso.core.exports.privatesdatas.tables.Table) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) WriteXml(mom.trd.opentheso.core.exports.privatesdatas.WriteXml) ByteArrayInputStream(java.io.ByteArrayInputStream) ExportPrivatesDatas(mom.trd.opentheso.core.exports.helper.ExportPrivatesDatas)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ExportPrivatesDatas (mom.trd.opentheso.core.exports.helper.ExportPrivatesDatas)1 WriteXml (mom.trd.opentheso.core.exports.privatesdatas.WriteXml)1 Table (mom.trd.opentheso.core.exports.privatesdatas.tables.Table)1 DefaultStreamedContent (org.primefaces.model.DefaultStreamedContent)1