Author: kmorin
Date: 2014-04-01 11:08:18 +0200 (Tue, 01 Apr 2014)
New Revision: 88
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/88
Log:
fixes #4871 [EXPORT] Exporter ?\195?\160 la fois en JSON et en CSV
Modified:
trunk/src/fr/ifremer/wlo/MainActivity.java
trunk/src/fr/ifremer/wlo/storage/CsvExporter.java
Modified: trunk/src/fr/ifremer/wlo/MainActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/MainActivity.java 2014-03-31 07:46:34 UTC (rev 87)
+++ trunk/src/fr/ifremer/wlo/MainActivity.java 2014-04-01 09:08:18 UTC (rev 88)
@@ -43,7 +43,6 @@
import android.widget.LinearLayout;
import android.widget.Toast;
import com.google.common.base.Function;
-import fr.ifremer.wlo.models.CategoryWeightModel;
import fr.ifremer.wlo.models.CommercialSpeciesModel;
import fr.ifremer.wlo.models.ContextModel;
import fr.ifremer.wlo.models.LocationModel;
@@ -51,7 +50,6 @@
import fr.ifremer.wlo.models.MetierModel;
import fr.ifremer.wlo.models.ScientificSpeciesModel;
import fr.ifremer.wlo.models.VesselModel;
-import fr.ifremer.wlo.models.referentials.CommercialSpecies;
import fr.ifremer.wlo.storage.CsvExporter;
import fr.ifremer.wlo.storage.JsonExporter;
import fr.ifremer.wlo.utils.ImportExportUtil;
@@ -247,22 +245,25 @@
case REQUEST_SELECT_EXPORT_FOLDER:
if (resultCode == Activity.RESULT_OK) {
try {
-// String jsonData = JsonExporter.exportData(this);
File selectedFile = new File(data.getStringExtra(FileDialog.RESULT_PATH));
if (selectedFile.isFile()) {
selectedFile = selectedFile.getParentFile();
}
String date = String.format("-%1$tY%1$tm%1$td-%1$tH%1$tM%1$tS", new Date());
- File file = new File(selectedFile, "export" + date + ".csv");
-// FileUtils.write(file, jsonData);
+ File csvFile = new File(selectedFile, "export" + date + ".csv");
CsvExporter exporter = new CsvExporter(';', this);
List<MeasurementModel> measurementModelList = getMeasurementModels();
- Export.exportToFile(exporter, measurementModelList, file);
+ Export.exportToFile(exporter, measurementModelList, csvFile);
- Toast.makeText(this, "Export effectué dans le fichier " + file.getAbsolutePath(), Toast.LENGTH_LONG).show();
+ String jsonData = JsonExporter.exportData(this);
+ File jsonFile = new File(selectedFile, "export" + date + ".json");
+ FileUtils.write(jsonFile, jsonData);
+ Toast.makeText(this, "Export effectué dans les fichiers " + csvFile.getAbsolutePath() +
+ " et " + jsonFile.getAbsolutePath(), Toast.LENGTH_LONG).show();
+
} catch (Exception e) {
Log.e(TAG, "error while exporting to CSV", e);
Toast.makeText(this, "Erreur lors de l'export", Toast.LENGTH_SHORT).show();
Modified: trunk/src/fr/ifremer/wlo/storage/CsvExporter.java
===================================================================
--- trunk/src/fr/ifremer/wlo/storage/CsvExporter.java 2014-03-31 07:46:34 UTC (rev 87)
+++ trunk/src/fr/ifremer/wlo/storage/CsvExporter.java 2014-04-01 09:08:18 UTC (rev 88)
@@ -1,5 +1,29 @@
package fr.ifremer.wlo.storage;
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import android.content.Context;
import android.database.Cursor;
import android.util.Log;