Wlo-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
March 2014
- 4 participants
- 35 discussions
Author: maven-release
Date: 2014-03-31 09:46:34 +0200 (Mon, 31 Mar 2014)
New Revision: 87
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/87
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-03-31 07:46:29 UTC (rev 86)
+++ trunk/pom.xml 2014-03-31 07:46:34 UTC (rev 87)
@@ -33,7 +33,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>wlo</artifactId>
- <version>0.4</version>
+ <version>0.5-SNAPSHOT</version>
<name>WLO</name>
<description>
@@ -76,12 +76,12 @@
</developers>
<scm>
- <url>https://svn.codelutin.com/wlo/tags/wlo-0.4</url>
+ <url>https://svn.codelutin.com/wlo/trunk</url>
<connection>
- scm:svn:https://svn.codelutin.com/wlo/tags/wlo-0.4
+ scm:svn:https://svn.codelutin.com/wlo/trunk
</connection>
<developerConnection>
- scm:svn:https://svn.codelutin.com/wlo/tags/wlo-0.4
+ scm:svn:https://svn.codelutin.com/wlo/trunk
</developerConnection>
</scm>
<distributionManagement>
1
0
Author: maven-release
Date: 2014-03-31 09:46:29 +0200 (Mon, 31 Mar 2014)
New Revision: 86
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/86
Log:
[maven-release-plugin] copy for tag wlo-0.4
Added:
tags/wlo-0.4/
1
0
Author: maven-release
Date: 2014-03-31 09:46:22 +0200 (Mon, 31 Mar 2014)
New Revision: 85
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/85
Log:
[maven-release-plugin] prepare release wlo-0.4
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-03-28 12:49:26 UTC (rev 84)
+++ trunk/pom.xml 2014-03-31 07:46:22 UTC (rev 85)
@@ -33,7 +33,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>wlo</artifactId>
- <version>0.4-SNAPSHOT</version>
+ <version>0.4</version>
<name>WLO</name>
<description>
@@ -76,12 +76,12 @@
</developers>
<scm>
- <url>https://svn.codelutin.com/wlo/trunk</url>
+ <url>https://svn.codelutin.com/wlo/tags/wlo-0.4</url>
<connection>
- scm:svn:https://svn.codelutin.com/wlo/trunk
+ scm:svn:https://svn.codelutin.com/wlo/tags/wlo-0.4
</connection>
<developerConnection>
- scm:svn:https://svn.codelutin.com/wlo/trunk
+ scm:svn:https://svn.codelutin.com/wlo/tags/wlo-0.4
</developerConnection>
</scm>
<distributionManagement>
1
0
r84 - in trunk: res/values-fr src/fr/ifremer/wlo src/fr/ifremer/wlo/models src/fr/ifremer/wlo/storage src/fr/ifremer/wlo/utils
by kmorin@users.forge.codelutin.com 28 Mar '14
by kmorin@users.forge.codelutin.com 28 Mar '14
28 Mar '14
Author: kmorin
Date: 2014-03-28 13:49:26 +0100 (Fri, 28 Mar 2014)
New Revision: 84
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/84
Log:
refs-100 #4710 [EXPORT] Exporter les donn?\195?\169es dans un seul tableau
fixes #4846 [POIDS] Lorsqu'il y a plusieurs esp?\195?\168ces scientifiques, seuls les poids de la denri?\195?\168re sont sauvegard?\195?\169s
Added:
trunk/src/fr/ifremer/wlo/storage/CsvExporter.java
trunk/src/fr/ifremer/wlo/storage/JsonExporter.java
Removed:
trunk/src/fr/ifremer/wlo/storage/Exporter.java
Modified:
trunk/res/values-fr/strings.xml
trunk/src/fr/ifremer/wlo/MainActivity.java
trunk/src/fr/ifremer/wlo/WeightsActivity.java
trunk/src/fr/ifremer/wlo/models/HierarchicalModel.java
trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java
trunk/src/fr/ifremer/wlo/utils/ImportExportUtil.java
trunk/src/fr/ifremer/wlo/utils/UIUtils.java
trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java
Modified: trunk/res/values-fr/strings.xml
===================================================================
--- trunk/res/values-fr/strings.xml 2014-03-27 10:20:09 UTC (rev 83)
+++ trunk/res/values-fr/strings.xml 2014-03-28 12:49:26 UTC (rev 84)
@@ -70,7 +70,7 @@
<!-- Home screen -->
<string name="main_open_contexts">Voir / saisir des données</string>
- <string name="main_export_data">Export des données</string>
+ <string name="main_export_data">Exporter les données</string>
<string name="main_connect_ichtyometer">Connecter un ichtyomètre</string>
<string name="main_disconnect_ichtyometer">Déconnecter l\'ichtyomètre</string>
<string name="main_settings">Configuration</string>
Modified: trunk/src/fr/ifremer/wlo/MainActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/MainActivity.java 2014-03-27 10:20:09 UTC (rev 83)
+++ trunk/src/fr/ifremer/wlo/MainActivity.java 2014-03-28 12:49:26 UTC (rev 84)
@@ -30,6 +30,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
+import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
@@ -41,21 +42,38 @@
import android.widget.Button;
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;
+import fr.ifremer.wlo.models.MeasurementModel;
+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;
import fr.ifremer.wlo.models.categorization.CategoryModel;
import fr.ifremer.wlo.preferences.SettingsActivity;
import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.storage.Exporter;
import fr.ifremer.wlo.storage.WloSqlOpenHelper;
import fr.ifremer.wlo.utils.UpdateCheckTask;
import fr.ifremer.wlo.utils.filechooser.FileDialog;
import fr.ifremer.wlo.utils.filechooser.SelectionMode;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.tuple.Triple;
import org.json.JSONException;
+import org.nuiton.csv.Export;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* @author kmorin <kmorin(a)codelutin.com>
@@ -195,7 +213,7 @@
intent.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
//alternatively you can set file filter
- intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "json" });
+ intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "csv" });
startActivityForResult(intent, REQUEST_SELECT_EXPORT_FOLDER);
}
@@ -229,20 +247,24 @@
case REQUEST_SELECT_EXPORT_FOLDER:
if (resultCode == Activity.RESULT_OK) {
try {
- String jsonData = Exporter.exportData(this);
+// 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 + ".json");
- FileUtils.write(file, jsonData);
+ File file = new File(selectedFile, "export" + date + ".csv");
+// FileUtils.write(file, jsonData);
+ CsvExporter exporter = new CsvExporter(';', this);
+ List<MeasurementModel> measurementModelList = getMeasurementModels();
+ Export.exportToFile(exporter, measurementModelList, file);
+
Toast.makeText(this, "Export effectué dans le fichier " + file.getAbsolutePath(), Toast.LENGTH_LONG).show();
- } catch (JSONException | IOException e) {
- Log.e(TAG, "error while exporting to JSON", e);
+ } catch (Exception e) {
+ Log.e(TAG, "error while exporting to CSV", e);
Toast.makeText(this, "Erreur lors de l'export", Toast.LENGTH_SHORT).show();
}
}
@@ -251,6 +273,120 @@
}
+ protected List<MeasurementModel> getMeasurementModels() {
+ List<MeasurementModel> measurementModelList = new ArrayList<>();
+
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(this);
+ Cursor cursor = soh.getAllContexts();
+ List<ContextModel> contexts =
+ WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, ContextModel>() {
+ @Override
+ public ContextModel apply(Cursor input) {
+ return new ContextModel(input);
+ }
+ });
+ for (final ContextModel contextModel : contexts) {
+ cursor = soh.getAllLocations(contextModel.getId());
+ List<LocationModel> locationModels =
+ WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, LocationModel>() {
+ @Override
+ public LocationModel apply(Cursor input) {
+ LocationModel locationModel = new LocationModel(MainActivity.this, input);
+ locationModel.setParent(contextModel);
+ return locationModel;
+ }
+ });
+ for (final LocationModel locationModel : locationModels) {
+ cursor = soh.getAllVessels(locationModel.getId());
+ List<VesselModel> vesselModels =
+ WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, VesselModel>() {
+ @Override
+ public VesselModel apply(Cursor input) {
+ VesselModel vesselModel = new VesselModel(MainActivity.this, input);
+ vesselModel.setParent(locationModel);
+ return vesselModel;
+ }
+ });
+ for (final VesselModel vesselModel : vesselModels) {
+ cursor = soh.getAllMetiers(vesselModel.getId());
+ List<MetierModel> metierModels =
+ WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, MetierModel>() {
+ @Override
+ public MetierModel apply(Cursor input) {
+ MetierModel metierModel = new MetierModel(MainActivity.this, input);
+ metierModel.setParent(vesselModel);
+ return metierModel;
+ }
+ });
+ for (final MetierModel metierModel : metierModels) {
+ cursor = soh.getAllCommercialSpecies(metierModel.getId());
+ List<CommercialSpeciesModel> commercialSpeciesModels =
+ WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, CommercialSpeciesModel>() {
+ @Override
+ public CommercialSpeciesModel apply(Cursor input) {
+ CommercialSpeciesModel commercialSpeciesModel = new CommercialSpeciesModel(MainActivity.this, input);
+ commercialSpeciesModel.setParent(metierModel);
+ return commercialSpeciesModel;
+ }
+ });
+ for (final CommercialSpeciesModel commercialSpeciesModel : commercialSpeciesModels) {
+ cursor = soh.getAllScientificSpecies(commercialSpeciesModel.getId());
+ List<ScientificSpeciesModel> scientificSpeciesModels =
+ WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, ScientificSpeciesModel>() {
+ @Override
+ public ScientificSpeciesModel apply(Cursor input) {
+ ScientificSpeciesModel scientificSpeciesModel = new ScientificSpeciesModel(MainActivity.this, input);
+ scientificSpeciesModel.setParent(commercialSpeciesModel);
+ return scientificSpeciesModel;
+ }
+ });
+
+ for (final ScientificSpeciesModel scientificSpeciesModel : scientificSpeciesModels) {
+ Map<Triple<String, String, String>, Integer> categoryWeights = new HashMap<>();
+ cursor = soh.getAllCategoryWeigths(scientificSpeciesModel.getId());
+ boolean cont = cursor.moveToFirst();
+ while (cont) {
+ String category1 = cursor.getString(1);
+ String category2 = cursor.getString(2);
+ String category3 = cursor.getString(3);
+ Integer weight = null;
+ if (!cursor.isNull(4)) {
+ weight = cursor.getInt(4);
+ }
+ Triple<String, String, String> key = Triple.of(category1, category2, category3);
+ categoryWeights.put(key, weight);
+
+ cont = cursor.moveToNext();
+ }
+ scientificSpeciesModel.setCategoryWeights(categoryWeights);
+
+ cursor = soh.getAllMeasurements(scientificSpeciesModel.getId());
+ List<MeasurementModel> measurementModels =
+ WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, MeasurementModel>() {
+ @Override
+ public MeasurementModel apply(Cursor input) {
+ MeasurementModel measurementModel = new MeasurementModel(input);
+ measurementModel.setParent(scientificSpeciesModel);
+ return measurementModel;
+ }
+ });
+ measurementModelList.addAll(measurementModels);
+ }
+ }
+ }
+ }
+ }
+ }
+ return measurementModelList;
+ }
+
protected void setOrientation(int orientation) {
LinearLayout.LayoutParams logoParams, buttonParams;
Modified: trunk/src/fr/ifremer/wlo/WeightsActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/WeightsActivity.java 2014-03-27 10:20:09 UTC (rev 83)
+++ trunk/src/fr/ifremer/wlo/WeightsActivity.java 2014-03-28 12:49:26 UTC (rev 84)
@@ -195,7 +195,7 @@
// get all the category weights
Cursor categoryWeighs = woh.getAllCategoryWeigths(scientificSpecies.getId());
- categoryWeightModels = WloSqlOpenHelper.transformCursorIntoCollection(categoryWeighs,
+ List<CategoryWeightModel> categoryWeightModels = WloSqlOpenHelper.transformCursorIntoCollection(categoryWeighs,
new Function<Cursor, CategoryWeightModel>() {
@Override
public CategoryWeightModel apply(Cursor input) {
@@ -204,6 +204,7 @@
return result;
}
});
+ this.categoryWeightModels.addAll(categoryWeightModels);
for (final CategoryWeightModel categoryWeightModel : categoryWeightModels) {
Modified: trunk/src/fr/ifremer/wlo/models/HierarchicalModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/HierarchicalModel.java 2014-03-27 10:20:09 UTC (rev 83)
+++ trunk/src/fr/ifremer/wlo/models/HierarchicalModel.java 2014-03-28 12:49:26 UTC (rev 84)
@@ -44,13 +44,12 @@
return parent;
}
- public BaseModel getParent(int level) {
+ public <T extends BaseModel> T getParent(Class<T> parentClass) {
BaseModel result = this;
- //TODO kmorin 20131219 handle NPE
- for (int i = 0 ; i < level ; i++) {
+ while(result != null && !result.getClass().isAssignableFrom(parentClass)) {
result = ((HierarchicalModel) result).getParent();
}
- return result;
+ return (T) result;
}
public void setParent(P parent) {
Modified: trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java 2014-03-27 10:20:09 UTC (rev 83)
+++ trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java 2014-03-28 12:49:26 UTC (rev 84)
@@ -31,7 +31,10 @@
import fr.ifremer.wlo.models.referentials.ScientificSpecies;
import fr.ifremer.wlo.storage.DataCache;
import fr.ifremer.wlo.utils.UIUtils;
+import org.apache.commons.lang3.tuple.Triple;
+import java.util.Map;
+
/**
* @author kmorin <kmorin(a)codelutin.com>
* @since 0.1
@@ -63,6 +66,9 @@
protected Integer sortedWeight;
protected Integer sampleWeight;
+ // used for the export
+ protected Map<Triple<String, String, String>, Integer> categoryWeights;
+
public ScientificSpeciesModel() {
}
@@ -130,6 +136,14 @@
firePropertyChange(COLUMN_SAMPLE_WEIGHT, oldValue, sampleWeight);
}
+ public Map<Triple<String, String, String>, Integer> getCategoryWeights() {
+ return categoryWeights;
+ }
+
+ public void setCategoryWeights(Map<Triple<String, String, String>, Integer> categoryWeights) {
+ this.categoryWeights = categoryWeights;
+ }
+
@Override
public String getTableName() {
return TABLE_NAME;
Added: trunk/src/fr/ifremer/wlo/storage/CsvExporter.java
===================================================================
--- trunk/src/fr/ifremer/wlo/storage/CsvExporter.java (rev 0)
+++ trunk/src/fr/ifremer/wlo/storage/CsvExporter.java 2014-03-28 12:49:26 UTC (rev 84)
@@ -0,0 +1,531 @@
+package fr.ifremer.wlo.storage;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.util.Log;
+import com.google.common.base.Function;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.CommercialSpeciesModel;
+import fr.ifremer.wlo.models.ContextModel;
+import fr.ifremer.wlo.models.LocationModel;
+import fr.ifremer.wlo.models.MeasurementModel;
+import fr.ifremer.wlo.models.MetierModel;
+import fr.ifremer.wlo.models.ScientificSpeciesModel;
+import fr.ifremer.wlo.models.VesselModel;
+import fr.ifremer.wlo.models.categorization.CategoryModel;
+import fr.ifremer.wlo.models.categorization.QualitativeValueModel;
+import fr.ifremer.wlo.models.referentials.CommercialSpecies;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.models.referentials.Metier;
+import fr.ifremer.wlo.models.referentials.Presentation;
+import fr.ifremer.wlo.models.referentials.ScientificSpecies;
+import fr.ifremer.wlo.models.referentials.State;
+import fr.ifremer.wlo.utils.UIUtils;
+import org.apache.commons.lang3.tuple.Triple;
+import org.nuiton.csv.ValueGetter;
+import org.nuiton.csv.ext.AbstractExportModel;
+
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Kevin Morin (Code Lutin)
+ * @since x.x
+ */
+public class CsvExporter extends AbstractExportModel<MeasurementModel> {
+
+ private static final String TAG = "CsvExporter";
+
+ protected Map<String, QualitativeValueModel> qualitativeValuesById;
+
+ public CsvExporter(char separator, Context context) {
+ super(separator);
+
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor qualitativeValuesCursor = soh.getAllQualitativeValues();
+ List<QualitativeValueModel> qualitativeValues =
+ WloSqlOpenHelper.transformCursorIntoCollection(qualitativeValuesCursor,
+ new Function<Cursor, QualitativeValueModel>() {
+ @Override
+ public QualitativeValueModel apply(Cursor input) {
+ return new QualitativeValueModel(input);
+ }
+ });
+ qualitativeValuesById = Maps.uniqueIndex(qualitativeValues, BaseModel.GET_ID_FUNCTION);
+
+ // context
+ newColumnForExport("contexte_nom", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ ContextModel contextModel = object.getParent(ContextModel.class);
+ return contextModel.getName();
+ }
+ });
+
+ newColumnForExport("contexte_commentaire", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ ContextModel contextModel = object.getParent(ContextModel.class);
+ return contextModel.getComment();
+ }
+ });
+
+ // location
+ newColumnForExport("lieu_code", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ LocationModel locationModel = object.getParent(LocationModel.class);
+ return locationModel.getLocation().getCode();
+ }
+ });
+
+ newColumnForExport("lieu_libelle", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ LocationModel locationModel = object.getParent(LocationModel.class);
+ return locationModel.getLocation().getLabel();
+ }
+ });
+
+ newColumnForExport("lieu_type", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ LocationModel locationModel = object.getParent(LocationModel.class);
+ return locationModel.getLocation().getTypeLabel();
+ }
+ });
+
+ newColumnForExport("lieu_date_debut", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ LocationModel locationModel = object.getParent(LocationModel.class);
+ Calendar startDate = locationModel.getStartDate();
+ return formatDate(startDate);
+ }
+ });
+
+ newColumnForExport("lieu_date_fin", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ LocationModel locationModel = object.getParent(LocationModel.class);
+ Calendar endDate = locationModel.getEndDate();
+ return formatDate(endDate);
+ }
+ });
+
+ newColumnForExport("lieu_observateur", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ LocationModel locationModel = object.getParent(LocationModel.class);
+ return locationModel.getOperator();
+ }
+ });
+
+ newColumnForExport("lieu_commentaire", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ LocationModel locationModel = object.getParent(LocationModel.class);
+ return locationModel.getComment();
+ }
+ });
+
+ // vessel
+
+ newColumnForExport("navire_immatriculation", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ VesselModel vesselModel = object.getParent(VesselModel.class);
+ return vesselModel.getRegistrationNumber();
+ }
+ });
+
+ newColumnForExport("navire_nom", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ VesselModel vesselModel = object.getParent(VesselModel.class);
+ return vesselModel.getName();
+ }
+ });
+
+ newColumnForExport("navire_date_debarquement", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ VesselModel vesselModel = object.getParent(VesselModel.class);
+ Calendar landingDate = vesselModel.getLandingDate();
+ return formatDate(landingDate);
+ }
+ });
+
+ newColumnForExport("navire_lieu_debarquement_code", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ VesselModel vesselModel = object.getParent(VesselModel.class);
+ Location landingLocation = vesselModel.getLandingLocation();
+ return landingLocation != null ? landingLocation.getCode() : null;
+ }
+ });
+
+ newColumnForExport("navire_lieu_debarquement_libelle", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ VesselModel vesselModel = object.getParent(VesselModel.class);
+ Location landingLocation = vesselModel.getLandingLocation();
+ return landingLocation != null ? landingLocation.getLabel() : null;
+ }
+ });
+
+ newColumnForExport("navire_lieu_debarquement_type", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ VesselModel vesselModel = object.getParent(VesselModel.class);
+ Location landingLocation = vesselModel.getLandingLocation();
+ return landingLocation != null ? landingLocation.getTypeLabel() : null;
+ }
+ });
+
+ newColumnForExport("navire_commentaire", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ VesselModel vesselModel = object.getParent(VesselModel.class);
+ return vesselModel.getComment();
+ }
+ });
+
+ // metier
+
+ newColumnForExport("metier_engin_id", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ MetierModel metierModel = object.getParent(MetierModel.class);
+ Metier gearSpecies = metierModel.getGearSpecies();
+ return gearSpecies != null ? gearSpecies.getMetierId() : null;
+ }
+ });
+
+ newColumnForExport("metier_engin_code", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ MetierModel metierModel = object.getParent(MetierModel.class);
+ Metier gearSpecies = metierModel.getGearSpecies();
+ return gearSpecies != null ? gearSpecies.getCode() : null;
+ }
+ });
+
+ newColumnForExport("metier_engin_libelle", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ MetierModel metierModel = object.getParent(MetierModel.class);
+ Metier gearSpecies = metierModel.getGearSpecies();
+ return gearSpecies != null ? gearSpecies.getLabel() : null;
+ }
+ });
+
+ newColumnForExport("metier_secteur_peche", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ MetierModel metierModel = object.getParent(MetierModel.class);
+ return metierModel.getZone();
+ }
+ });
+
+ newColumnForExport("metier_plan", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ MetierModel metierModel = object.getParent(MetierModel.class);
+ return metierModel.getSampleRowCode();
+ }
+ });
+
+ newColumnForExport("metier_commentaire", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ MetierModel metierModel = object.getParent(MetierModel.class);
+ return metierModel.getComment();
+ }
+ });
+
+ // commercial species
+
+ newColumnForExport("espece_commerciale_code", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ CommercialSpecies species = commercialSpeciesModel.getFaoCode();
+ return species != null ? species.getCode() : null;
+ }
+ });
+
+ newColumnForExport("espece_commerciale_label", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ CommercialSpecies species = commercialSpeciesModel.getFaoCode();
+ return species != null ? species.getFrenchLabel() : null;
+ }
+ });
+
+ newColumnForExport("espece_commerciale_methode_mensuration_code", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ Mensuration measurementMethod = commercialSpeciesModel.getMeasurementMethod();
+ return measurementMethod != null ? measurementMethod.getCode() : null;
+ }
+ });
+
+ newColumnForExport("espece_commerciale_methode_mensuration_libelle", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ Mensuration measurementMethod = commercialSpeciesModel.getMeasurementMethod();
+ return measurementMethod != null ? measurementMethod.getLabel() : null;
+ }
+ });
+
+ newColumnForExport("espece_commerciale_precision", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ return commercialSpeciesModel.getPrecision().getLabel();
+ }
+ });
+
+ newColumnForExport("espece_commerciale_melange_especes", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ return String.valueOf(commercialSpeciesModel.isSpeciesMix());
+ }
+ });
+
+ newColumnForExport("espece_commerciale_categorie_tri", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ return commercialSpeciesModel.getSortCategory();
+ }
+ });
+
+ newColumnForExport("espece_commerciale_etat_code", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ State state = commercialSpeciesModel.getState();
+ return state != null ? state.getCode() : null;
+ }
+ });
+
+ newColumnForExport("espece_commerciale_etat_libelle", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ State state = commercialSpeciesModel.getState();
+ return state != null ? state.getLabel() : null;
+ }
+ });
+
+ newColumnForExport("espece_commerciale_presentation_code", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ Presentation presentation = commercialSpeciesModel.getPresentation();
+ return presentation != null ? presentation.getCode() : null;
+ }
+ });
+
+ newColumnForExport("espece_commerciale_presentation_libelle", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ Presentation presentation = commercialSpeciesModel.getPresentation();
+ return presentation != null ? presentation.getLabel() : null;
+ }
+ });
+
+ newColumnForExport("espece_commerciale_categorie1", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ CategoryModel category = commercialSpeciesModel.getCategory1();
+ return category != null ? category.getLabel() : null;
+ }
+ });
+
+ newColumnForExport("espece_commerciale_categorie2", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ CategoryModel category = commercialSpeciesModel.getCategory2();
+ return category != null ? category.getLabel() : null;
+ }
+ });
+
+ newColumnForExport("espece_commerciale_categorie3", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ CategoryModel category = commercialSpeciesModel.getCategory3();
+ return category != null ? category.getLabel() : null;
+ }
+ });
+
+ newColumnForExport("espece_commerciale_poids_total", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ Integer totalUnloadedWeight = commercialSpeciesModel.getTotalUnloadedWeight();
+ return totalUnloadedWeight != null ? totalUnloadedWeight.toString() : null;
+ }
+ });
+
+ newColumnForExport("espece_commerciale_commentaire", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ CommercialSpeciesModel commercialSpeciesModel = object.getParent(CommercialSpeciesModel.class);
+ return commercialSpeciesModel.getComment();
+ }
+ });
+
+ // scientific species
+
+ newColumnForExport("espece_scientifique_code", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ ScientificSpeciesModel speciesModel = object.getParent();
+ ScientificSpecies species = speciesModel.getName();
+ return species != null ? species.getCode() : null;
+ }
+ });
+
+ newColumnForExport("espece_scientifique_name", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ ScientificSpeciesModel speciesModel = object.getParent();
+ ScientificSpecies species = speciesModel.getName();
+ return species != null ? species.getLabel() : null;
+ }
+ });
+
+ newColumnForExport("espece_scientifique_comment", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ ScientificSpeciesModel speciesModel = object.getParent();
+ return speciesModel.getComment();
+ }
+ });
+
+ newColumnForExport("espece_scientifique_sorted_weight", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ ScientificSpeciesModel speciesModel = object.getParent();
+ Integer sortedWeight = speciesModel.getSortedWeight();
+ return sortedWeight != null ? sortedWeight.toString() : null;
+ }
+ });
+
+ newColumnForExport("espece_scientifique_sample_weight", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ ScientificSpeciesModel speciesModel = object.getParent();
+ Integer sampleWeight = speciesModel.getSampleWeight();
+ return sampleWeight != null ? sampleWeight.toString() : null;
+ }
+ });
+
+ // observations
+
+ newColumnForExport("observation_categorie1_code", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ return getCategoryValue(object.getCategory1());
+ }
+ });
+
+ newColumnForExport("observation_categorie1_label", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ return getCategoryLabel(object.getCategory1());
+ }
+ });
+
+ newColumnForExport("observation_categorie2_code", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ return getCategoryValue(object.getCategory2());
+ }
+ });
+
+ newColumnForExport("observation_categorie2_label", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ return getCategoryLabel(object.getCategory2());
+ }
+ });
+
+ newColumnForExport("observation_categorie3_code", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ return getCategoryValue(object.getCategory3());
+ }
+ });
+
+ newColumnForExport("observation_categorie3_label", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ return getCategoryLabel(object.getCategory3());
+ }
+ });
+
+ newColumnForExport("observation_categories_poids", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ ScientificSpeciesModel speciesModel = object.getParent();
+ Map<Triple<String, String, String>, Integer> categoryWeights = speciesModel.getCategoryWeights();
+ Triple<String, String, String> key = Triple.of(object.getCategory1(), object.getCategory2(), object.getCategory3());
+ Integer weight = categoryWeights.get(key);
+ return weight != null ? weight.toString() : null;
+ }
+ });
+
+ newColumnForExport("observation_date", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ return formatDate(object.getDate());
+ }
+ });
+
+ newColumnForExport("observation_taille", new ValueGetter<MeasurementModel, String>() {
+ @Override
+ public String get(MeasurementModel object) throws Exception {
+ return object.getSize().toString();
+ }
+ });
+ }
+
+ protected String getCategoryValue(String measurementCategory) {
+ QualitativeValueModel value = qualitativeValuesById.get(measurementCategory);
+ if (value == null) {
+ return measurementCategory;
+
+ }
+ return value.getValue();
+ }
+
+ protected String getCategoryLabel(String measurementCategory) {
+ QualitativeValueModel value = qualitativeValuesById.get(measurementCategory);
+ if (value == null) {
+ return measurementCategory;
+
+ }
+ return value.getLabel();
+ }
+
+ protected String formatDate(Calendar calendar) {
+ return calendar != null ? UIUtils.UTC_DATE_FORMAT.format(calendar.getTime()) : null;
+ }
+}
Deleted: trunk/src/fr/ifremer/wlo/storage/Exporter.java
===================================================================
--- trunk/src/fr/ifremer/wlo/storage/Exporter.java 2014-03-27 10:20:09 UTC (rev 83)
+++ trunk/src/fr/ifremer/wlo/storage/Exporter.java 2014-03-28 12:49:26 UTC (rev 84)
@@ -1,473 +0,0 @@
-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.Pair;
-import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
-import fr.ifremer.wlo.models.*;
-import fr.ifremer.wlo.models.categorization.CategoryModel;
-import fr.ifremer.wlo.models.categorization.QualitativeValueModel;
-import fr.ifremer.wlo.models.referentials.*;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Kevin Morin (Code Lutin)
- * @since x.x
- */
-public class Exporter {
-
- public static final SimpleDateFormat UTC_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
-
- protected static Map<String, QualitativeValueModel> qualitativeValuesById;
-
- public static String exportData(Context context) throws JSONException {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- JSONArray root = new JSONArray();
- try {
-
- Cursor qualitativeValuesCursor = soh.getAllQualitativeValues();
- List<QualitativeValueModel> qualitativeValues = WloSqlOpenHelper.transformCursorIntoCollection(qualitativeValuesCursor,
- new Function<Cursor, QualitativeValueModel>() {
- @Override
- public QualitativeValueModel apply(Cursor input) {
- return new QualitativeValueModel(input);
- }
- });
- qualitativeValuesById = Maps.uniqueIndex(qualitativeValues, BaseModel.GET_ID_FUNCTION);
-
- Cursor cursor = soh.getAllContexts();
- List<ContextModel> contexts = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, ContextModel>() {
- @Override
- public ContextModel apply(Cursor input) {
- return new ContextModel(input);
- }
- });
- for (ContextModel contextModel : contexts) {
- JSONObject jsonContext = createJSONContextModel(contextModel, context, soh);
- root.put(jsonContext);
- }
-
- } finally {
- soh.close();
- }
- return root.toString(2);
- }
-
- public static JSONObject createJSONContextModel(ContextModel model,
- final Context context,
- WloSqlOpenHelper soh) throws JSONException {
- Preconditions.checkNotNull(model);
- Preconditions.checkNotNull(soh);
-
- JSONObject jsonContext = new JSONObject();
- jsonContext.put("contexte", model.getName());
- jsonContext.put("commentaire", model.getComment());
-
- Cursor cursor = soh.getAllLocations(model.getId());
- List<LocationModel> locations = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, LocationModel>() {
- @Override
- public LocationModel apply(Cursor input) {
- return new LocationModel(context, input);
- }
- });
- JSONArray jsonLocations = new JSONArray();
- for (LocationModel location : locations) {
- JSONObject jsonLocation = createJSONLocationModel(location, context, soh);
- jsonLocations.put(jsonLocation);
- }
- jsonContext.put("lieux", jsonLocations);
- cursor.close();
-
- return jsonContext;
- }
-
- public static JSONObject createJSONLocationModel(LocationModel model,
- final Context context,
- WloSqlOpenHelper soh) throws JSONException {
- Preconditions.checkNotNull(model);
- Preconditions.checkNotNull(soh);
-
- JSONObject jsonLocation = new JSONObject();
-
- jsonLocation.put("lieu", createJSONLocation(model.getLocation()));
- if (model.getStartDate() != null) {
- jsonLocation.put("date-début", UTC_DATE_FORMAT.format(model.getStartDate().getTime()));
- }
- if (model.getEndDate() != null) {
- jsonLocation.put("date-fin", UTC_DATE_FORMAT.format(model.getEndDate().getTime()));
- }
- jsonLocation.put("observateur", model.getOperator());
- jsonLocation.put("commentaire", model.getComment());
-
- Cursor cursor = soh.getAllVessels(model.getId());
- List<VesselModel> vessels = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, VesselModel>() {
- @Override
- public VesselModel apply(Cursor input) {
- return new VesselModel(context, input);
- }
- });
- JSONArray jsonVessels = new JSONArray();
- for (VesselModel vessel : vessels) {
- JSONObject jsonVessel = createJSONVesselModel(vessel, context, soh);
- jsonVessels.put(jsonVessel);
- }
- jsonLocation.put("navires", jsonVessels);
- cursor.close();
-
- return jsonLocation;
- }
-
- public static JSONObject createJSONVesselModel(VesselModel model,
- final Context context,
- WloSqlOpenHelper soh) throws JSONException {
- Preconditions.checkNotNull(model);
- Preconditions.checkNotNull(soh);
-
- JSONObject jsonVessel = new JSONObject();
-
- jsonVessel.put("immatriculation", model.getRegistrationNumber());
- jsonVessel.put("nom", model.getRegistrationNumber());
- if (model.getLandingDate() != null) {
- jsonVessel.put("date-débarquement", UTC_DATE_FORMAT.format(model.getLandingDate().getTime()));
- }
- jsonVessel.put("lieu-débarquement", createJSONLocation(model.getLandingLocation()));
- jsonVessel.put("commentaire", model.getComment());
-
- Cursor cursor = soh.getAllMetiers(model.getId());
- List<MetierModel> metiers = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, MetierModel>() {
- @Override
- public MetierModel apply(Cursor input) {
- return new MetierModel(context, input);
- }
- });
- JSONArray jsonMetiers = new JSONArray();
- for (MetierModel metier : metiers) {
- JSONObject jsonMetier = createJSONMetierModel(metier, context, soh);
- jsonMetiers.put(jsonMetier);
- }
- jsonVessel.put("métiers", jsonMetiers);
- cursor.close();
-
- return jsonVessel;
- }
-
- public static JSONObject createJSONMetierModel(MetierModel model,
- final Context context,
- WloSqlOpenHelper soh) throws JSONException {
- Preconditions.checkNotNull(model);
- Preconditions.checkNotNull(soh);
-
- JSONObject jsonMetier = new JSONObject();
-
- jsonMetier.put("engin-espèce", createJSONMetier(model.getGearSpecies()));
- jsonMetier.put("secteur", model.getZone());
- jsonMetier.put("référence-plan", model.getSampleRowCode());
- jsonMetier.put("commentaire", model.getComment());
-
- Cursor cursor = soh.getAllCommercialSpecies(model.getId());
- List<CommercialSpeciesModel> commercialSpecies = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, CommercialSpeciesModel>() {
- @Override
- public CommercialSpeciesModel apply(Cursor input) {
- return new CommercialSpeciesModel(context, input);
- }
- });
- JSONArray jsonCommercialSpeciesArray = new JSONArray();
- for (CommercialSpeciesModel commercialSpeciesModel : commercialSpecies) {
- JSONObject jsonCommercialSpecies = createJSONComercialSpeciesModel(commercialSpeciesModel, context, soh);
- jsonCommercialSpeciesArray.put(jsonCommercialSpecies);
- }
- jsonMetier.put("espèces-fao", jsonCommercialSpeciesArray);
- cursor.close();
-
- return jsonMetier;
- }
-
- public static JSONObject createJSONComercialSpeciesModel(CommercialSpeciesModel model,
- final Context context,
- WloSqlOpenHelper soh) throws JSONException {
- Preconditions.checkNotNull(model);
- Preconditions.checkNotNull(soh);
-
- JSONObject jsonCommercialSpecies = new JSONObject();
-
- jsonCommercialSpecies.put("espèce-fao", createJSONCommercialSpecies(model.getFaoCode()));
- jsonCommercialSpecies.put("méthode-mensuration", createJSONMensuration(model.getMeasurementMethod()));
- jsonCommercialSpecies.put("état", createJSONState(model.getState()));
- jsonCommercialSpecies.put("présentation", createJSONPresentation(model.getPresentation()));
- jsonCommercialSpecies.put("précision", model.getPrecision().getValue());
- jsonCommercialSpecies.put("mélange-espèces", model.isSpeciesMix());
- jsonCommercialSpecies.put("catégorie-tri", model.getSortCategory());
- jsonCommercialSpecies.put("poids-total-déchargé", model.getTotalUnloadedWeight());
- jsonCommercialSpecies.put("commentaire", model.getComment());
-
- Cursor cursor = soh.getAllScientificSpecies(model.getId());
- List<ScientificSpeciesModel> scientificSpecies = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, ScientificSpeciesModel>() {
- @Override
- public ScientificSpeciesModel apply(Cursor input) {
- return new ScientificSpeciesModel(context, input);
- }
- });
- JSONArray jsonScientificSpeciesArray = new JSONArray();
- for (ScientificSpeciesModel scientificSpeciesModel : scientificSpecies) {
- scientificSpeciesModel.setParent(model);
- JSONObject jsonScientificSpecies = createJSONScientificSpeciesModel(scientificSpeciesModel, context, soh);
- jsonScientificSpeciesArray.put(jsonScientificSpecies);
- }
- jsonCommercialSpecies.put("espèces-scientifiques", jsonScientificSpeciesArray);
- cursor.close();
-
- return jsonCommercialSpecies;
- }
-
- public static JSONObject createJSONScientificSpeciesModel(ScientificSpeciesModel model,
- final Context context,
- WloSqlOpenHelper soh) throws JSONException {
- Preconditions.checkNotNull(model);
- Preconditions.checkNotNull(soh);
-
- JSONObject jsonScientificSpeciesModel = new JSONObject();
- jsonScientificSpeciesModel.put("espèce-scientifique", createJSONScientificSpecies(model.getName()));
- jsonScientificSpeciesModel.put("prélèvement-pièces-calcifiées", model.isTakingActivation());
- jsonScientificSpeciesModel.put("commentaire", model.getComment());
- jsonScientificSpeciesModel.put("poids-trié", model.getSortedWeight());
- jsonScientificSpeciesModel.put("poids-échantillon", model.getSampleWeight());
-
- Cursor cursor = soh.getAllMeasurements(model.getId());
- List<MeasurementModel> measurements = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, MeasurementModel>() {
- @Override
- public MeasurementModel apply(Cursor input) {
- return new MeasurementModel(input);
- }
- });
-
- List<String> categories = new ArrayList<>();
- CommercialSpeciesModel parent = model.getParent();
- CategoryModel cat1 = parent.getCategory1();
- categories.add(cat1 != null ? cat1.getLabel() : null);
- CategoryModel cat2 = parent.getCategory2();
- categories.add(cat2 != null ? cat2.getLabel() : null);
- CategoryModel cat3 = parent.getCategory3();
- categories.add(cat3 != null ? cat3.getLabel() : null);
-
- JSONArray jsonMeasurements = new JSONArray();
- for (MeasurementModel measurement : measurements) {
- JSONObject jsonMeasurement = createJSONMeasurementModel(measurement, categories);
- jsonMeasurements.put(jsonMeasurement);
- }
- jsonScientificSpeciesModel.put("observations", jsonMeasurements);
- cursor.close();
-
- cursor = soh.getAllCategoryWeigths(model.getId());
- List<CategoryWeightModel> categoryWeights = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, CategoryWeightModel>() {
- @Override
- public CategoryWeightModel apply(Cursor input) {
- return new CategoryWeightModel(input);
- }
- });
- JSONArray jsonCategoryWeightModels = new JSONArray();
- for (CategoryWeightModel categoryWeight : categoryWeights) {
- JSONObject jsonCategoryWeightModel = createJSONCategoryWeightModel(categoryWeight, categories);
- jsonCategoryWeightModels.put(jsonCategoryWeightModel);
- }
- jsonScientificSpeciesModel.put("poids-par-categorie", jsonCategoryWeightModels);
- cursor.close();
-
- return jsonScientificSpeciesModel;
- }
-
- public static JSONObject createJSONMeasurementModel(MeasurementModel model,
- List<String> categories) throws JSONException {
- Preconditions.checkNotNull(model);
- JSONObject jsonMeasurementModel = new JSONObject();
- for (int i = 0 ; i < categories.size() ; i++) {
- String categoryLabel = categories.get(i);
- if (categoryLabel != null) {
- String measurementCategory = null;
- switch (i) {
- case 0:
- measurementCategory = model.getCategory1();
- break;
- case 1:
- measurementCategory = model.getCategory2();
- break;
- case 2:
- measurementCategory = model.getCategory3();
- break;
- }
- if (measurementCategory != null) {
- QualitativeValueModel value = qualitativeValuesById.get(measurementCategory);
- if (value == null) {
- jsonMeasurementModel.put(categoryLabel, measurementCategory);
-
- } else {
- JSONObject jsonCategory = new JSONObject();
- jsonCategory.put("code", value.getValue());
- jsonCategory.put("libellé", value.getLabel());
- jsonMeasurementModel.put(categoryLabel, jsonCategory);
- }
- }
- }
- }
- jsonMeasurementModel.put("taille", model.getSize());
- jsonMeasurementModel.put("date", UTC_DATE_FORMAT.format(model.getDate().getTime()));
-
- return jsonMeasurementModel;
- }
-
- public static JSONObject createJSONCategoryWeightModel(CategoryWeightModel model,
- List<String> categories) throws JSONException {
- Preconditions.checkNotNull(model);
- JSONObject jsonCategoryWeightModel = new JSONObject();
- for (int i = 0 ; i < categories.size() ; i++) {
- String categoryLabel = categories.get(i);
- if (categoryLabel != null) {
- String measurementCategory = null;
- switch (i) {
- case 0:
- measurementCategory = model.getCategory1();
- break;
- case 1:
- measurementCategory = model.getCategory2();
- break;
- case 2:
- measurementCategory = model.getCategory3();
- break;
- }
- if (measurementCategory != null) {
- QualitativeValueModel value = qualitativeValuesById.get(measurementCategory);
- if (value == null) {
- jsonCategoryWeightModel.put(categoryLabel, measurementCategory);
-
- } else {
- JSONObject jsonCategory = new JSONObject();
- jsonCategory.put("code", value.getValue());
- jsonCategory.put("libellé", value.getLabel());
- jsonCategoryWeightModel.put(categoryLabel, jsonCategory);
- }
- }
- }
- }
- jsonCategoryWeightModel.put("poids", model.getWeight());
-
- return jsonCategoryWeightModel;
- }
-
- public static JSONObject createJSONLocation(Location location) throws JSONException {
- if (location == null) {
- return null;
- }
- JSONObject jsonLocation = new JSONObject();
- jsonLocation.put("type", location.getTypeLabel());
- jsonLocation.put("code", location.getCode());
- jsonLocation.put("libellé", location.getLabel());
- return jsonLocation;
- }
-
- public static JSONObject createJSONMetier(Metier metier) throws JSONException {
- if (metier == null) {
- return null;
- }
- JSONObject jsonMetier = new JSONObject();
- jsonMetier.put("id", metier.getId());
- jsonMetier.put("code", metier.getCode());
- jsonMetier.put("libellé", metier.getLabel());
- jsonMetier.put("engin-code", metier.getGearCode());
- jsonMetier.put("engin-libellé", metier.getGearLabel());
- jsonMetier.put("espece-code", metier.getSpeciesCode());
- jsonMetier.put("espece-libellé", metier.getSpeciesLabel());
- jsonMetier.put("pêche", metier.getFishing());
- jsonMetier.put("actif", metier.getActive());
- return jsonMetier;
- }
-
- public static JSONObject createJSONCommercialSpecies(CommercialSpecies commercialSpecies) throws JSONException {
- if (commercialSpecies == null) {
- return null;
- }
- JSONObject jsonCommercialSpecies = new JSONObject();
- jsonCommercialSpecies.put("code", commercialSpecies.getCode());
- jsonCommercialSpecies.put("isscap", commercialSpecies.getIsscap());
- jsonCommercialSpecies.put("code-taxon", commercialSpecies.getTaxonCode());
- jsonCommercialSpecies.put("libellé-scientifique", commercialSpecies.getScientificLabel());
- jsonCommercialSpecies.put("libellé-français", commercialSpecies.getFrenchLabel());
- jsonCommercialSpecies.put("famille", commercialSpecies.getFamily());
- jsonCommercialSpecies.put("ordre", commercialSpecies.getSpeciesOrder());
- jsonCommercialSpecies.put("actif", commercialSpecies.getActive());
- return jsonCommercialSpecies;
- }
-
- public static JSONObject createJSONMensuration(Mensuration mensuration) throws JSONException {
- if (mensuration == null) {
- return null;
- }
- JSONObject jsonMensuration = new JSONObject();
- jsonMensuration.put("code", mensuration.getCode());
- jsonMensuration.put("libellé", mensuration.getLabel());
- return jsonMensuration;
- }
-
- public static JSONObject createJSONState(State state) throws JSONException {
- if (state == null) {
- return null;
- }
- JSONObject jsonState = new JSONObject();
- jsonState.put("code", state.getCode());
- jsonState.put("libellé", state.getLabel());
- return jsonState;
- }
-
- public static JSONObject createJSONPresentation(Presentation presentation) throws JSONException {
- if (presentation == null) {
- return null;
- }
- JSONObject jsonPresentation = new JSONObject();
- jsonPresentation.put("code", presentation.getCode());
- jsonPresentation.put("libellé", presentation.getLabel());
- return jsonPresentation;
- }
-
- public static JSONObject createJSONScientificSpecies(ScientificSpecies scientificSpecies) throws JSONException {
- if (scientificSpecies == null) {
- return null;
- }
- JSONObject jsonScientificSpecies = new JSONObject();
- jsonScientificSpecies.put("code", scientificSpecies.getCode());
- jsonScientificSpecies.put("libellé", scientificSpecies.getLabel());
- jsonScientificSpecies.put("perm-code", scientificSpecies.getPermCode());
- return jsonScientificSpecies;
- }
-
-}
\ No newline at end of file
Copied: trunk/src/fr/ifremer/wlo/storage/JsonExporter.java (from rev 81, trunk/src/fr/ifremer/wlo/storage/Exporter.java)
===================================================================
--- trunk/src/fr/ifremer/wlo/storage/JsonExporter.java (rev 0)
+++ trunk/src/fr/ifremer/wlo/storage/JsonExporter.java 2014-03-28 12:49:26 UTC (rev 84)
@@ -0,0 +1,472 @@
+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.Pair;
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.models.*;
+import fr.ifremer.wlo.models.categorization.CategoryModel;
+import fr.ifremer.wlo.models.categorization.QualitativeValueModel;
+import fr.ifremer.wlo.models.referentials.*;
+import fr.ifremer.wlo.utils.UIUtils;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Kevin Morin (Code Lutin)
+ * @since x.x
+ */
+public class JsonExporter {
+
+ protected static Map<String, QualitativeValueModel> qualitativeValuesById;
+
+ public static String exportData(Context context) throws JSONException {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ JSONArray root = new JSONArray();
+ try {
+
+ Cursor qualitativeValuesCursor = soh.getAllQualitativeValues();
+ List<QualitativeValueModel> qualitativeValues = WloSqlOpenHelper.transformCursorIntoCollection(qualitativeValuesCursor,
+ new Function<Cursor, QualitativeValueModel>() {
+ @Override
+ public QualitativeValueModel apply(Cursor input) {
+ return new QualitativeValueModel(input);
+ }
+ });
+ qualitativeValuesById = Maps.uniqueIndex(qualitativeValues, BaseModel.GET_ID_FUNCTION);
+
+ Cursor cursor = soh.getAllContexts();
+ List<ContextModel> contexts = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, ContextModel>() {
+ @Override
+ public ContextModel apply(Cursor input) {
+ return new ContextModel(input);
+ }
+ });
+ for (ContextModel contextModel : contexts) {
+ JSONObject jsonContext = createJSONContextModel(contextModel, context, soh);
+ root.put(jsonContext);
+ }
+
+ } finally {
+ soh.close();
+ }
+ return root.toString(2);
+ }
+
+ public static JSONObject createJSONContextModel(ContextModel model,
+ final Context context,
+ WloSqlOpenHelper soh) throws JSONException {
+ Preconditions.checkNotNull(model);
+ Preconditions.checkNotNull(soh);
+
+ JSONObject jsonContext = new JSONObject();
+ jsonContext.put("contexte", model.getName());
+ jsonContext.put("commentaire", model.getComment());
+
+ Cursor cursor = soh.getAllLocations(model.getId());
+ List<LocationModel> locations = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, LocationModel>() {
+ @Override
+ public LocationModel apply(Cursor input) {
+ return new LocationModel(context, input);
+ }
+ });
+ JSONArray jsonLocations = new JSONArray();
+ for (LocationModel location : locations) {
+ JSONObject jsonLocation = createJSONLocationModel(location, context, soh);
+ jsonLocations.put(jsonLocation);
+ }
+ jsonContext.put("lieux", jsonLocations);
+ cursor.close();
+
+ return jsonContext;
+ }
+
+ public static JSONObject createJSONLocationModel(LocationModel model,
+ final Context context,
+ WloSqlOpenHelper soh) throws JSONException {
+ Preconditions.checkNotNull(model);
+ Preconditions.checkNotNull(soh);
+
+ JSONObject jsonLocation = new JSONObject();
+
+ jsonLocation.put("lieu", createJSONLocation(model.getLocation()));
+ if (model.getStartDate() != null) {
+ jsonLocation.put("date-début", UIUtils.UTC_DATE_FORMAT.format(model.getStartDate().getTime()));
+ }
+ if (model.getEndDate() != null) {
+ jsonLocation.put("date-fin", UIUtils.UTC_DATE_FORMAT.format(model.getEndDate().getTime()));
+ }
+ jsonLocation.put("observateur", model.getOperator());
+ jsonLocation.put("commentaire", model.getComment());
+
+ Cursor cursor = soh.getAllVessels(model.getId());
+ List<VesselModel> vessels = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, VesselModel>() {
+ @Override
+ public VesselModel apply(Cursor input) {
+ return new VesselModel(context, input);
+ }
+ });
+ JSONArray jsonVessels = new JSONArray();
+ for (VesselModel vessel : vessels) {
+ JSONObject jsonVessel = createJSONVesselModel(vessel, context, soh);
+ jsonVessels.put(jsonVessel);
+ }
+ jsonLocation.put("navires", jsonVessels);
+ cursor.close();
+
+ return jsonLocation;
+ }
+
+ public static JSONObject createJSONVesselModel(VesselModel model,
+ final Context context,
+ WloSqlOpenHelper soh) throws JSONException {
+ Preconditions.checkNotNull(model);
+ Preconditions.checkNotNull(soh);
+
+ JSONObject jsonVessel = new JSONObject();
+
+ jsonVessel.put("immatriculation", model.getRegistrationNumber());
+ jsonVessel.put("nom", model.getRegistrationNumber());
+ if (model.getLandingDate() != null) {
+ jsonVessel.put("date-débarquement", UIUtils.UTC_DATE_FORMAT.format(model.getLandingDate().getTime()));
+ }
+ jsonVessel.put("lieu-débarquement", createJSONLocation(model.getLandingLocation()));
+ jsonVessel.put("commentaire", model.getComment());
+
+ Cursor cursor = soh.getAllMetiers(model.getId());
+ List<MetierModel> metiers = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, MetierModel>() {
+ @Override
+ public MetierModel apply(Cursor input) {
+ return new MetierModel(context, input);
+ }
+ });
+ JSONArray jsonMetiers = new JSONArray();
+ for (MetierModel metier : metiers) {
+ JSONObject jsonMetier = createJSONMetierModel(metier, context, soh);
+ jsonMetiers.put(jsonMetier);
+ }
+ jsonVessel.put("métiers", jsonMetiers);
+ cursor.close();
+
+ return jsonVessel;
+ }
+
+ public static JSONObject createJSONMetierModel(MetierModel model,
+ final Context context,
+ WloSqlOpenHelper soh) throws JSONException {
+ Preconditions.checkNotNull(model);
+ Preconditions.checkNotNull(soh);
+
+ JSONObject jsonMetier = new JSONObject();
+
+ jsonMetier.put("engin-espèce", createJSONMetier(model.getGearSpecies()));
+ jsonMetier.put("secteur", model.getZone());
+ jsonMetier.put("référence-plan", model.getSampleRowCode());
+ jsonMetier.put("commentaire", model.getComment());
+
+ Cursor cursor = soh.getAllCommercialSpecies(model.getId());
+ List<CommercialSpeciesModel> commercialSpecies = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, CommercialSpeciesModel>() {
+ @Override
+ public CommercialSpeciesModel apply(Cursor input) {
+ return new CommercialSpeciesModel(context, input);
+ }
+ });
+ JSONArray jsonCommercialSpeciesArray = new JSONArray();
+ for (CommercialSpeciesModel commercialSpeciesModel : commercialSpecies) {
+ JSONObject jsonCommercialSpecies = createJSONComercialSpeciesModel(commercialSpeciesModel, context, soh);
+ jsonCommercialSpeciesArray.put(jsonCommercialSpecies);
+ }
+ jsonMetier.put("espèces-fao", jsonCommercialSpeciesArray);
+ cursor.close();
+
+ return jsonMetier;
+ }
+
+ public static JSONObject createJSONComercialSpeciesModel(CommercialSpeciesModel model,
+ final Context context,
+ WloSqlOpenHelper soh) throws JSONException {
+ Preconditions.checkNotNull(model);
+ Preconditions.checkNotNull(soh);
+
+ JSONObject jsonCommercialSpecies = new JSONObject();
+
+ jsonCommercialSpecies.put("espèce-fao", createJSONCommercialSpecies(model.getFaoCode()));
+ jsonCommercialSpecies.put("méthode-mensuration", createJSONMensuration(model.getMeasurementMethod()));
+ jsonCommercialSpecies.put("état", createJSONState(model.getState()));
+ jsonCommercialSpecies.put("présentation", createJSONPresentation(model.getPresentation()));
+ jsonCommercialSpecies.put("précision", model.getPrecision().getValue());
+ jsonCommercialSpecies.put("mélange-espèces", model.isSpeciesMix());
+ jsonCommercialSpecies.put("catégorie-tri", model.getSortCategory());
+ jsonCommercialSpecies.put("poids-total-déchargé", model.getTotalUnloadedWeight());
+ jsonCommercialSpecies.put("commentaire", model.getComment());
+
+ Cursor cursor = soh.getAllScientificSpecies(model.getId());
+ List<ScientificSpeciesModel> scientificSpecies = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, ScientificSpeciesModel>() {
+ @Override
+ public ScientificSpeciesModel apply(Cursor input) {
+ return new ScientificSpeciesModel(context, input);
+ }
+ });
+ JSONArray jsonScientificSpeciesArray = new JSONArray();
+ for (ScientificSpeciesModel scientificSpeciesModel : scientificSpecies) {
+ scientificSpeciesModel.setParent(model);
+ JSONObject jsonScientificSpecies = createJSONScientificSpeciesModel(scientificSpeciesModel, context, soh);
+ jsonScientificSpeciesArray.put(jsonScientificSpecies);
+ }
+ jsonCommercialSpecies.put("espèces-scientifiques", jsonScientificSpeciesArray);
+ cursor.close();
+
+ return jsonCommercialSpecies;
+ }
+
+ public static JSONObject createJSONScientificSpeciesModel(ScientificSpeciesModel model,
+ final Context context,
+ WloSqlOpenHelper soh) throws JSONException {
+ Preconditions.checkNotNull(model);
+ Preconditions.checkNotNull(soh);
+
+ JSONObject jsonScientificSpeciesModel = new JSONObject();
+ jsonScientificSpeciesModel.put("espèce-scientifique", createJSONScientificSpecies(model.getName()));
+ jsonScientificSpeciesModel.put("prélèvement-pièces-calcifiées", model.isTakingActivation());
+ jsonScientificSpeciesModel.put("commentaire", model.getComment());
+ jsonScientificSpeciesModel.put("poids-trié", model.getSortedWeight());
+ jsonScientificSpeciesModel.put("poids-échantillon", model.getSampleWeight());
+
+ Cursor cursor = soh.getAllMeasurements(model.getId());
+ List<MeasurementModel> measurements = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, MeasurementModel>() {
+ @Override
+ public MeasurementModel apply(Cursor input) {
+ return new MeasurementModel(input);
+ }
+ });
+
+ List<String> categories = new ArrayList<>();
+ CommercialSpeciesModel parent = model.getParent();
+ CategoryModel cat1 = parent.getCategory1();
+ categories.add(cat1 != null ? cat1.getLabel() : null);
+ CategoryModel cat2 = parent.getCategory2();
+ categories.add(cat2 != null ? cat2.getLabel() : null);
+ CategoryModel cat3 = parent.getCategory3();
+ categories.add(cat3 != null ? cat3.getLabel() : null);
+
+ JSONArray jsonMeasurements = new JSONArray();
+ for (MeasurementModel measurement : measurements) {
+ JSONObject jsonMeasurement = createJSONMeasurementModel(measurement, categories);
+ jsonMeasurements.put(jsonMeasurement);
+ }
+ jsonScientificSpeciesModel.put("observations", jsonMeasurements);
+ cursor.close();
+
+ cursor = soh.getAllCategoryWeigths(model.getId());
+ List<CategoryWeightModel> categoryWeights = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, CategoryWeightModel>() {
+ @Override
+ public CategoryWeightModel apply(Cursor input) {
+ return new CategoryWeightModel(input);
+ }
+ });
+ JSONArray jsonCategoryWeightModels = new JSONArray();
+ for (CategoryWeightModel categoryWeight : categoryWeights) {
+ JSONObject jsonCategoryWeightModel = createJSONCategoryWeightModel(categoryWeight, categories);
+ jsonCategoryWeightModels.put(jsonCategoryWeightModel);
+ }
+ jsonScientificSpeciesModel.put("poids-par-categorie", jsonCategoryWeightModels);
+ cursor.close();
+
+ return jsonScientificSpeciesModel;
+ }
+
+ public static JSONObject createJSONMeasurementModel(MeasurementModel model,
+ List<String> categories) throws JSONException {
+ Preconditions.checkNotNull(model);
+ JSONObject jsonMeasurementModel = new JSONObject();
+ for (int i = 0 ; i < categories.size() ; i++) {
+ String categoryLabel = categories.get(i);
+ if (categoryLabel != null) {
+ String measurementCategory = null;
+ switch (i) {
+ case 0:
+ measurementCategory = model.getCategory1();
+ break;
+ case 1:
+ measurementCategory = model.getCategory2();
+ break;
+ case 2:
+ measurementCategory = model.getCategory3();
+ break;
+ }
+ if (measurementCategory != null) {
+ QualitativeValueModel value = qualitativeValuesById.get(measurementCategory);
+ if (value == null) {
+ jsonMeasurementModel.put(categoryLabel, measurementCategory);
+
+ } else {
+ JSONObject jsonCategory = new JSONObject();
+ jsonCategory.put("code", value.getValue());
+ jsonCategory.put("libellé", value.getLabel());
+ jsonMeasurementModel.put(categoryLabel, jsonCategory);
+ }
+ }
+ }
+ }
+ jsonMeasurementModel.put("taille", model.getSize());
+ jsonMeasurementModel.put("date", UIUtils.UTC_DATE_FORMAT.format(model.getDate().getTime()));
+
+ return jsonMeasurementModel;
+ }
+
+ public static JSONObject createJSONCategoryWeightModel(CategoryWeightModel model,
+ List<String> categories) throws JSONException {
+ Preconditions.checkNotNull(model);
+ JSONObject jsonCategoryWeightModel = new JSONObject();
+ for (int i = 0 ; i < categories.size() ; i++) {
+ String categoryLabel = categories.get(i);
+ if (categoryLabel != null) {
+ String measurementCategory = null;
+ switch (i) {
+ case 0:
+ measurementCategory = model.getCategory1();
+ break;
+ case 1:
+ measurementCategory = model.getCategory2();
+ break;
+ case 2:
+ measurementCategory = model.getCategory3();
+ break;
+ }
+ if (measurementCategory != null) {
+ QualitativeValueModel value = qualitativeValuesById.get(measurementCategory);
+ if (value == null) {
+ jsonCategoryWeightModel.put(categoryLabel, measurementCategory);
+
+ } else {
+ JSONObject jsonCategory = new JSONObject();
+ jsonCategory.put("code", value.getValue());
+ jsonCategory.put("libellé", value.getLabel());
+ jsonCategoryWeightModel.put(categoryLabel, jsonCategory);
+ }
+ }
+ }
+ }
+ jsonCategoryWeightModel.put("poids", model.getWeight());
+
+ return jsonCategoryWeightModel;
+ }
+
+ public static JSONObject createJSONLocation(Location location) throws JSONException {
+ if (location == null) {
+ return null;
+ }
+ JSONObject jsonLocation = new JSONObject();
+ jsonLocation.put("type", location.getTypeLabel());
+ jsonLocation.put("code", location.getCode());
+ jsonLocation.put("libellé", location.getLabel());
+ return jsonLocation;
+ }
+
+ public static JSONObject createJSONMetier(Metier metier) throws JSONException {
+ if (metier == null) {
+ return null;
+ }
+ JSONObject jsonMetier = new JSONObject();
+ jsonMetier.put("id", metier.getId());
+ jsonMetier.put("code", metier.getCode());
+ jsonMetier.put("libellé", metier.getLabel());
+ jsonMetier.put("engin-code", metier.getGearCode());
+ jsonMetier.put("engin-libellé", metier.getGearLabel());
+ jsonMetier.put("espece-code", metier.getSpeciesCode());
+ jsonMetier.put("espece-libellé", metier.getSpeciesLabel());
+ jsonMetier.put("pêche", metier.getFishing());
+ jsonMetier.put("actif", metier.getActive());
+ return jsonMetier;
+ }
+
+ public static JSONObject createJSONCommercialSpecies(CommercialSpecies commercialSpecies) throws JSONException {
+ if (commercialSpecies == null) {
+ return null;
+ }
+ JSONObject jsonCommercialSpecies = new JSONObject();
+ jsonCommercialSpecies.put("code", commercialSpecies.getCode());
+ jsonCommercialSpecies.put("isscap", commercialSpecies.getIsscap());
+ jsonCommercialSpecies.put("code-taxon", commercialSpecies.getTaxonCode());
+ jsonCommercialSpecies.put("libellé-scientifique", commercialSpecies.getScientificLabel());
+ jsonCommercialSpecies.put("libellé-français", commercialSpecies.getFrenchLabel());
+ jsonCommercialSpecies.put("famille", commercialSpecies.getFamily());
+ jsonCommercialSpecies.put("ordre", commercialSpecies.getSpeciesOrder());
+ jsonCommercialSpecies.put("actif", commercialSpecies.getActive());
+ return jsonCommercialSpecies;
+ }
+
+ public static JSONObject createJSONMensuration(Mensuration mensuration) throws JSONException {
+ if (mensuration == null) {
+ return null;
+ }
+ JSONObject jsonMensuration = new JSONObject();
+ jsonMensuration.put("code", mensuration.getCode());
+ jsonMensuration.put("libellé", mensuration.getLabel());
+ return jsonMensuration;
+ }
+
+ public static JSONObject createJSONState(State state) throws JSONException {
+ if (state == null) {
+ return null;
+ }
+ JSONObject jsonState = new JSONObject();
+ jsonState.put("code", state.getCode());
+ jsonState.put("libellé", state.getLabel());
+ return jsonState;
+ }
+
+ public static JSONObject createJSONPresentation(Presentation presentation) throws JSONException {
+ if (presentation == null) {
+ return null;
+ }
+ JSONObject jsonPresentation = new JSONObject();
+ jsonPresentation.put("code", presentation.getCode());
+ jsonPresentation.put("libellé", presentation.getLabel());
+ return jsonPresentation;
+ }
+
+ public static JSONObject createJSONScientificSpecies(ScientificSpecies scientificSpecies) throws JSONException {
+ if (scientificSpecies == null) {
+ return null;
+ }
+ JSONObject jsonScientificSpecies = new JSONObject();
+ jsonScientificSpecies.put("code", scientificSpecies.getCode());
+ jsonScientificSpecies.put("libellé", scientificSpecies.getLabel());
+ jsonScientificSpecies.put("perm-code", scientificSpecies.getPermCode());
+ return jsonScientificSpecies;
+ }
+
+}
\ No newline at end of file
Modified: trunk/src/fr/ifremer/wlo/utils/ImportExportUtil.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/ImportExportUtil.java 2014-03-27 10:20:09 UTC (rev 83)
+++ trunk/src/fr/ifremer/wlo/utils/ImportExportUtil.java 2014-03-28 12:49:26 UTC (rev 84)
@@ -482,8 +482,7 @@
}
try {
- Export<M> exporter = Export.newExport(exportModel, data);
- exporter.write(targetFile);
+ Export.exportToFile(exportModel, data, targetFile);
result = data.size();
} catch (Exception e) {
Modified: trunk/src/fr/ifremer/wlo/utils/UIUtils.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/UIUtils.java 2014-03-27 10:20:09 UTC (rev 83)
+++ trunk/src/fr/ifremer/wlo/utils/UIUtils.java 2014-03-28 12:49:26 UTC (rev 84)
@@ -36,6 +36,7 @@
import fr.ifremer.wlo.models.referentials.Mensuration;
import fr.ifremer.wlo.preferences.ListItemPreference;
+import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
@@ -47,6 +48,8 @@
private static final String TAG = "UIUtils";
+ public static final SimpleDateFormat UTC_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
+
/**
* @return A dialog click listener which cancel the dialog
*/
Modified: trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-03-27 10:20:09 UTC (rev 83)
+++ trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-03-28 12:49:26 UTC (rev 84)
@@ -120,7 +120,8 @@
textView.setText(ref != null ? ref.toString(context): "");
return true;
}
- if (DataType.SCIENTIFIC_SPECIES.equals(dataType)) {
+ if (DataType.SCIENTIFIC_SPECIES.equals(dataType)
+ || DataType.METIER.equals(dataType)) {
textView.setText(
context.getString(R.string.undefined));
return true;
1
0
27 Mar '14
Author: kmorin
Date: 2014-03-27 11:20:09 +0100 (Thu, 27 Mar 2014)
New Revision: 83
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/83
Log:
fixes #4805 les mesures au cm inf?\195?\169rieur : 25.8 s'enregistre 26 au lieu de 25
Modified:
trunk/assets/ref_import_calcified_part_takings.csv
trunk/src/fr/ifremer/wlo/utils/UIUtils.java
trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java
Modified: trunk/assets/ref_import_calcified_part_takings.csv
===================================================================
--- trunk/assets/ref_import_calcified_part_takings.csv 2014-03-18 16:15:11 UTC (rev 82)
+++ trunk/assets/ref_import_calcified_part_takings.csv 2014-03-27 10:20:09 UTC (rev 83)
@@ -1,6 +1,6 @@
Espece_scientifique;Classe_debut;Classe_fin;Pas_de_classe;Pas;Arret
-AAPT;10;200;1;5;Inf
-AAPT;201;400;1;2;Inf
-AAPT;401;Inf;1;1;Inf
+AAPT;10;200;10;5;Inf
+AAPT;201;400;10;2;Inf
+AAPT;401;Inf;10;1;Inf
AAPTAAP;5;Inf;5;2;5
ABAL;10;Inf;10;5;2
\ No newline at end of file
Modified: trunk/src/fr/ifremer/wlo/utils/UIUtils.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/UIUtils.java 2014-03-18 16:15:11 UTC (rev 82)
+++ trunk/src/fr/ifremer/wlo/utils/UIUtils.java 2014-03-27 10:20:09 UTC (rev 83)
@@ -29,6 +29,7 @@
import android.content.SharedPreferences;
import android.database.Cursor;
import android.preference.PreferenceManager;
+import android.util.Log;
import com.google.common.base.Preconditions;
import fr.ifremer.wlo.R;
import fr.ifremer.wlo.models.BaseModel;
@@ -137,9 +138,17 @@
public static String getFormattedSize(int size, Mensuration.Precision precision) {
Preconditions.checkNotNull(precision);
+
+ // round the size down, otherwise, the string.format method will round it up (eg 25.8 -> 26)
+ // cf http://forge.codelutin.com/issues/4805
+ int precisionValue = precision.getValue();
+ int roundedSize = (size / precisionValue) * precisionValue;
+
String format = getSizeFormat(precision);
int divider = precision.getUnitDivider();
- double dSize = (double) size / divider;
- return String.format(Locale.US, format, dSize);
+ double dSize = (double) roundedSize / divider;
+
+ String result = String.format(Locale.US, format, dSize);
+ return result;
}
}
Modified: trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-03-18 16:15:11 UTC (rev 82)
+++ trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-03-27 10:20:09 UTC (rev 83)
@@ -79,20 +79,18 @@
DataType dataType = dataTypes.get(columnIndex);
Log.d(TAG, "dataType for " + columnIndex + " : " + dataType);
- if (DataType.DATE.equals(dataType) || DataType.DATETIME.equals(dataType)) {
- if (cursor.getType(columnIndex) != Cursor.FIELD_TYPE_NULL) {
- long time = cursor.getLong(columnIndex);
- Date date = new Date(time);
- String format = DataType.DATE.equals(dataType) ? dateFormat : dateTimeFormat;
- String formattedDate = String.format(format, date);
- TextView textView = (TextView) view;
- textView.setText(formattedDate);
- return true;
- }
- }
-
+ TextView textView = (TextView) view;
if (dataType != null) {
if (cursor.getType(columnIndex) != Cursor.FIELD_TYPE_NULL) {
+ if (DataType.DATE.equals(dataType) || DataType.DATETIME.equals(dataType)) {
+ long time = cursor.getLong(columnIndex);
+ Date date = new Date(time);
+ String format = DataType.DATE.equals(dataType) ? dateFormat : dateTimeFormat;
+ String formattedDate = String.format(format, date);
+ textView.setText(formattedDate);
+ return true;
+ }
+
Context context = view.getContext();
String id = cursor.getString(columnIndex);
BaseModel ref = null;
@@ -119,19 +117,16 @@
ref = DataCache.getScientificSpeciesById(context, id);
break;
}
- TextView textView = (TextView) view;
textView.setText(ref != null ? ref.toString(context): "");
return true;
}
+ if (DataType.SCIENTIFIC_SPECIES.equals(dataType)) {
+ textView.setText(
+ context.getString(R.string.undefined));
+ return true;
+ }
}
- String value = cursor.getString(columnIndex);
- if (value == null) {
- TextView textView = (TextView) view;
- textView.setText("");
- return true;
- }
-
return false;
}
}
1
0
r82 - in trunk: res/values res/values-fr src/fr/ifremer/wlo src/fr/ifremer/wlo/utils
by kmorin@users.forge.codelutin.com 18 Mar '14
by kmorin@users.forge.codelutin.com 18 Mar '14
18 Mar '14
Author: kmorin
Date: 2014-03-18 17:15:11 +0100 (Tue, 18 Mar 2014)
New Revision: 82
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/82
Log:
fixes #4742 [ERGO] ne pas afficher les "Non d?\195?\169fini - Non d?\195?\169fini - Non d?\195?\169fini" ou 'NA, NA"
Modified:
trunk/res/values-fr/strings.xml
trunk/res/values/strings.xml
trunk/src/fr/ifremer/wlo/WeightsActivity.java
trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java
Modified: trunk/res/values/strings.xml
===================================================================
--- trunk/res/values/strings.xml 2014-03-17 18:25:25 UTC (rev 81)
+++ trunk/res/values/strings.xml 2014-03-18 16:15:11 UTC (rev 82)
@@ -232,7 +232,7 @@
<string name="commercial_species_total_unloaded_weight">Total unloaded weight</string>
<string name="scientific_species_sorted_weight">Sorted weight</string>
<string name="scientific_species_sample_weight">Sample weight</string>
- <string name="scientific_species_categories">Weights per category (gender / maturity / age)</string>
+ <string name="scientific_species_categories">Weights per category</string>
<!--File chooser-->
<string name="file_chooser_location">Location</string>
Modified: trunk/res/values-fr/strings.xml
===================================================================
--- trunk/res/values-fr/strings.xml 2014-03-17 18:25:25 UTC (rev 81)
+++ trunk/res/values-fr/strings.xml 2014-03-18 16:15:11 UTC (rev 82)
@@ -224,7 +224,7 @@
<string name="commercial_species_total_unloaded_weight">Poids total débarqué</string>
<string name="scientific_species_sorted_weight">Poids trié</string>
<string name="scientific_species_sample_weight">Poids d\'échantillon</string>
- <string name="scientific_species_categories">Poids par catégorie (Sexe / maturité / age)</string>
+ <string name="scientific_species_categories">Poids par catégorie</string>
<!--File chooser-->
<string name="file_chooser_location">Emplacement</string>
Modified: trunk/src/fr/ifremer/wlo/WeightsActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/WeightsActivity.java 2014-03-17 18:25:25 UTC (rev 81)
+++ trunk/src/fr/ifremer/wlo/WeightsActivity.java 2014-03-18 16:15:11 UTC (rev 82)
@@ -102,17 +102,21 @@
commercialSpeciesModel = (CommercialSpeciesModel) getIntent().getSerializableExtra(INTENT_COMMERCIAL_SPECIES);
+ List<String> categoryLabels = new ArrayList<>();
CategoryModel category1 = commercialSpeciesModel.getCategory1();
if (category1 != null) {
valuesById.putAll(Maps.uniqueIndex(category1.getQualitativeValues(), BaseModel.GET_ID_FUNCTION));
+ categoryLabels.add(category1.getLabel());
}
CategoryModel category2 = commercialSpeciesModel.getCategory2();
if (category2 != null) {
valuesById.putAll(Maps.uniqueIndex(category2.getQualitativeValues(), BaseModel.GET_ID_FUNCTION));
+ categoryLabels.add(category2.getLabel());
}
CategoryModel category3 = commercialSpeciesModel.getCategory3();
if (category3 != null) {
valuesById.putAll(Maps.uniqueIndex(category3.getQualitativeValues(), BaseModel.GET_ID_FUNCTION));
+ categoryLabels.add(category3.getLabel());
}
getSupportActionBar().setSubtitle(commercialSpeciesModel.toString(this));
@@ -179,50 +183,68 @@
}
});
- // weight per category
- TextView weightByCategoryView = new TextView(this);
- weightByCategoryView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
- weightByCategoryView.setTextAppearance(this, android.R.style.TextAppearance_Medium);
- weightByCategoryView.setText(R.string.scientific_species_categories);
- container.addView(weightByCategoryView);
+ if (!categoryLabels.isEmpty()) {
+ // weight per category
+ TextView weightByCategoryView = new TextView(this);
+ weightByCategoryView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
+ weightByCategoryView.setTextAppearance(this, android.R.style.TextAppearance_Medium);
+ String weightByCategoryViewText = getString(R.string.scientific_species_categories)
+ + " (" + StringUtils.join(categoryLabels, " / ") + ")";
+ weightByCategoryView.setText(weightByCategoryViewText);
+ container.addView(weightByCategoryView);
- // get all the category weights
- Cursor categoryWeighs = woh.getAllCategoryWeigths(scientificSpecies.getId());
- categoryWeightModels = WloSqlOpenHelper.transformCursorIntoCollection(categoryWeighs,
- new Function<Cursor, CategoryWeightModel>() {
- @Override
- public CategoryWeightModel apply(Cursor input) {
- CategoryWeightModel result = new CategoryWeightModel(input);
- result.setParent(scientificSpecies);
- return result;
- }
- });
+ // get all the category weights
+ Cursor categoryWeighs = woh.getAllCategoryWeigths(scientificSpecies.getId());
+ categoryWeightModels = WloSqlOpenHelper.transformCursorIntoCollection(categoryWeighs,
+ new Function<Cursor, CategoryWeightModel>() {
+ @Override
+ public CategoryWeightModel apply(Cursor input) {
+ CategoryWeightModel result = new CategoryWeightModel(input);
+ result.setParent(scientificSpecies);
+ return result;
+ }
+ });
- for (final CategoryWeightModel categoryWeightModel : categoryWeightModels) {
- // create the weight field
- QualitativeValueModel category1Value = valuesById.get(categoryWeightModel.getCategory1());
- QualitativeValueModel category2Value = valuesById.get(categoryWeightModel.getCategory2());
- QualitativeValueModel category3Value = valuesById.get(categoryWeightModel.getCategory3());
+ for (final CategoryWeightModel categoryWeightModel : categoryWeightModels) {
+ // create the weight field
- String category1ValueLabel = category1Value != null ? category1Value.toString() : categoryWeightModel.getCategory1();
- String category2ValueLabel = category2Value != null ? category2Value.toString() : categoryWeightModel.getCategory2();
- String category3ValueLabel = category3Value != null ? category3Value.toString() : categoryWeightModel.getCategory3();
+ List<String> labels = new ArrayList<>();
- String label = (category1ValueLabel != null ? category1ValueLabel : "NA") + ", " +
- (category2ValueLabel != null ? category2ValueLabel : "NA") + ", " +
- (category3ValueLabel != null ? category3ValueLabel : "NA");
+ String categoryWeightModelCategory1 = categoryWeightModel.getCategory1();
+ if (categoryWeightModelCategory1 != null) {
+ QualitativeValueModel category1Value = valuesById.get(categoryWeightModelCategory1);
+ String category1ValueLabel = category1Value != null ? category1Value.toString() : categoryWeightModelCategory1;
+ labels.add(category1ValueLabel);
+ }
- // add label
- createWeightLabel(label);
+ String categoryWeightModelCategory2 = categoryWeightModel.getCategory2();
+ if (categoryWeightModelCategory2 != null) {
+ QualitativeValueModel category2Value = valuesById.get(categoryWeightModelCategory2);
+ String category2ValueLabel = category2Value != null ? category2Value.toString() : categoryWeightModelCategory2;
+ labels.add(category2ValueLabel);
+ }
- createEditText(categoryWeightModel.getWeight(), new Function<Integer, Void>() {
- @Override
- public Void apply(Integer input) {
- categoryWeightModel.setWeight(input);
- return null;
+ String categoryWeightModelCategory3 = categoryWeightModel.getCategory3();
+ if (categoryWeightModelCategory3 != null) {
+ QualitativeValueModel category3Value = valuesById.get(categoryWeightModelCategory3);
+ String category3ValueLabel = category3Value != null ? category3Value.toString() : categoryWeightModelCategory3;
+ labels.add(category3ValueLabel);
}
- });
+
+ String label = StringUtils.join(labels, " / ");
+
+ // add label
+ createWeightLabel(label);
+
+ createEditText(categoryWeightModel.getWeight(), new Function<Integer, Void>() {
+ @Override
+ public Void apply(Integer input) {
+ categoryWeightModel.setWeight(input);
+ return null;
+ }
+ });
+ }
}
}
woh.close();
Modified: trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-03-17 18:25:25 UTC (rev 81)
+++ trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-03-18 16:15:11 UTC (rev 82)
@@ -120,7 +120,7 @@
break;
}
TextView textView = (TextView) view;
- textView.setText(UIUtils.getStringOrUndefined(ref, context));
+ textView.setText(ref != null ? ref.toString(context): "");
return true;
}
}
@@ -128,7 +128,7 @@
String value = cursor.getString(columnIndex);
if (value == null) {
TextView textView = (TextView) view;
- textView.setText(R.string.undefined);
+ textView.setText("");
return true;
}
1
0
Author: kmorin
Date: 2014-03-17 19:25:25 +0100 (Mon, 17 Mar 2014)
New Revision: 81
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/81
Log:
add missing signing parameters
Modified:
trunk/AndroidManifest.xml
trunk/pom.xml
Modified: trunk/AndroidManifest.xml
===================================================================
--- trunk/AndroidManifest.xml 2014-03-17 17:21:13 UTC (rev 80)
+++ trunk/AndroidManifest.xml 2014-03-17 18:25:25 UTC (rev 81)
@@ -15,8 +15,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.ifremer.wlo"
- android:versionCode="2"
- android:versionName="0.3">
+ android:versionCode="3"
+ android:versionName="0.4">
<uses-sdk android:minSdkVersion="15"
android:targetSdkVersion="15"/>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-03-17 17:21:13 UTC (rev 80)
+++ trunk/pom.xml 2014-03-17 18:25:25 UTC (rev 81)
@@ -283,7 +283,7 @@
${project.build.directory}/${project.artifactId}-${project.version}.apk
</inputApk>
<outputApk>
- ${project.build.directory}/${project.artifactId}-${project.version}-aligned.apk
+ ${project.build.directory}/${project.artifactId}-${project.version}.apk
</outputApk>
</zipalign>
</configuration>
@@ -368,6 +368,10 @@
<includes>
<include>target/*.apk</include>
</includes>
+ <arguments>
+ <argument>-sigalg</argument><argument>MD5withRSA</argument>
+ <argument>-digestalg</argument><argument>SHA1</argument>
+ </arguments>
</configuration>
</execution>
</executions>
1
0
Author: maven-release
Date: 2014-03-17 18:21:13 +0100 (Mon, 17 Mar 2014)
New Revision: 80
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/80
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-03-17 17:21:06 UTC (rev 79)
+++ trunk/pom.xml 2014-03-17 17:21:13 UTC (rev 80)
@@ -33,7 +33,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>wlo</artifactId>
- <version>0.3</version>
+ <version>0.4-SNAPSHOT</version>
<name>WLO</name>
<description>
@@ -76,12 +76,12 @@
</developers>
<scm>
- <url>https://svn.codelutin.com/wlo/tags/wlo-0.3</url>
+ <url>https://svn.codelutin.com/wlo/trunk</url>
<connection>
- scm:svn:https://svn.codelutin.com/wlo/tags/wlo-0.3
+ scm:svn:https://svn.codelutin.com/wlo/trunk
</connection>
<developerConnection>
- scm:svn:https://svn.codelutin.com/wlo/tags/wlo-0.3
+ scm:svn:https://svn.codelutin.com/wlo/trunk
</developerConnection>
</scm>
<distributionManagement>
1
0
Author: maven-release
Date: 2014-03-17 18:21:06 +0100 (Mon, 17 Mar 2014)
New Revision: 79
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/79
Log:
[maven-release-plugin] copy for tag wlo-0.3
Added:
tags/wlo-0.3/
1
0
Author: maven-release
Date: 2014-03-17 18:20:48 +0100 (Mon, 17 Mar 2014)
New Revision: 78
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/78
Log:
[maven-release-plugin] prepare release wlo-0.3
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-03-17 17:08:51 UTC (rev 77)
+++ trunk/pom.xml 2014-03-17 17:20:48 UTC (rev 78)
@@ -33,7 +33,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>wlo</artifactId>
- <version>0.3-SNAPSHOT</version>
+ <version>0.3</version>
<name>WLO</name>
<description>
@@ -76,12 +76,12 @@
</developers>
<scm>
- <url>https://svn.codelutin.com/wlo/trunk</url>
+ <url>https://svn.codelutin.com/wlo/tags/wlo-0.3</url>
<connection>
- scm:svn:https://svn.codelutin.com/wlo/trunk
+ scm:svn:https://svn.codelutin.com/wlo/tags/wlo-0.3
</connection>
<developerConnection>
- scm:svn:https://svn.codelutin.com/wlo/trunk
+ scm:svn:https://svn.codelutin.com/wlo/tags/wlo-0.3
</developerConnection>
</scm>
<distributionManagement>
1
0