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
- 141 discussions
Author: maven-release
Date: 2014-04-01 18:09:17 +0200 (Tue, 01 Apr 2014)
New Revision: 93
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/93
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-04-01 16:09:11 UTC (rev 92)
+++ trunk/pom.xml 2014-04-01 16:09:17 UTC (rev 93)
@@ -33,7 +33,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>wlo</artifactId>
- <version>0.5</version>
+ <version>0.6-SNAPSHOT</version>
<name>WLO</name>
<description>
@@ -76,12 +76,12 @@
</developers>
<scm>
- <url>https://svn.codelutin.com/wlo/tags/wlo-0.5</url>
+ <url>https://svn.codelutin.com/wlo/trunk</url>
<connection>
- scm:svn:https://svn.codelutin.com/wlo/tags/wlo-0.5
+ scm:svn:https://svn.codelutin.com/wlo/trunk
</connection>
<developerConnection>
- scm:svn:https://svn.codelutin.com/wlo/tags/wlo-0.5
+ scm:svn:https://svn.codelutin.com/wlo/trunk
</developerConnection>
</scm>
<distributionManagement>
1
0
Author: maven-release
Date: 2014-04-01 18:09:11 +0200 (Tue, 01 Apr 2014)
New Revision: 92
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/92
Log:
[maven-release-plugin] copy for tag wlo-0.5
Added:
tags/wlo-0.5/
1
0
Author: maven-release
Date: 2014-04-01 18:09:03 +0200 (Tue, 01 Apr 2014)
New Revision: 91
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/91
Log:
[maven-release-plugin] prepare release wlo-0.5
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-04-01 16:05:42 UTC (rev 90)
+++ trunk/pom.xml 2014-04-01 16:09:03 UTC (rev 91)
@@ -33,7 +33,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>wlo</artifactId>
- <version>0.5-SNAPSHOT</version>
+ <version>0.5</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.5</url>
<connection>
- scm:svn:https://svn.codelutin.com/wlo/trunk
+ scm:svn:https://svn.codelutin.com/wlo/tags/wlo-0.5
</connection>
<developerConnection>
- scm:svn:https://svn.codelutin.com/wlo/trunk
+ scm:svn:https://svn.codelutin.com/wlo/tags/wlo-0.5
</developerConnection>
</scm>
<distributionManagement>
1
0
r90 - in trunk: res/drawable src/fr/ifremer/wlo src/fr/ifremer/wlo/imports src/fr/ifremer/wlo/measurement src/fr/ifremer/wlo/models src/fr/ifremer/wlo/models/categorization src/fr/ifremer/wlo/models/referentials src/fr/ifremer/wlo/preferences src/fr/ifremer/wlo/storage src/fr/ifremer/wlo/utils
by kmorin@users.forge.codelutin.com 01 Apr '14
by kmorin@users.forge.codelutin.com 01 Apr '14
01 Apr '14
Author: kmorin
Date: 2014-04-01 18:05:42 +0200 (Tue, 01 Apr 2014)
New Revision: 90
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/90
Log:
fixes #4878 [TECHNIQUE] La connexion ?\195?\160 l'ichtom?\195?\168tre se coupe quand on sort de l'appli
fixes #4880 [ERGO] Mettre une icone diff?\195?\169rente dans la notification si un ichtyom?\195?\168tre est connect?\195?\169
remove logs
Added:
trunk/res/drawable/wlo_ico_small_connected.png
Modified:
trunk/src/fr/ifremer/wlo/BigFinCommunicationService.java
trunk/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java
trunk/src/fr/ifremer/wlo/ContextFormActivity.java
trunk/src/fr/ifremer/wlo/ContextsActivity.java
trunk/src/fr/ifremer/wlo/DeviceListActivity.java
trunk/src/fr/ifremer/wlo/LocationFormActivity.java
trunk/src/fr/ifremer/wlo/MainActivity.java
trunk/src/fr/ifremer/wlo/MetierFormActivity.java
trunk/src/fr/ifremer/wlo/ScientificSpeciesActivity.java
trunk/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java
trunk/src/fr/ifremer/wlo/WloBaseActivity.java
trunk/src/fr/ifremer/wlo/WloBaseListActivity.java
trunk/src/fr/ifremer/wlo/WloModelEditionActivity.java
trunk/src/fr/ifremer/wlo/imports/CalcifiedPartTakingRowModel.java
trunk/src/fr/ifremer/wlo/measurement/MeasurementActivity.java
trunk/src/fr/ifremer/wlo/models/BaseModel.java
trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java
trunk/src/fr/ifremer/wlo/models/VesselModel.java
trunk/src/fr/ifremer/wlo/models/categorization/QualitativeValueModel.java
trunk/src/fr/ifremer/wlo/models/referentials/CalcifiedPartTaking.java
trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java
trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java
trunk/src/fr/ifremer/wlo/utils/BigFinFeedReaderRecord.java
trunk/src/fr/ifremer/wlo/utils/UpdateCheckTask.java
trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java
trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextViewWithFavorites.java
trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java
Added: trunk/res/drawable/wlo_ico_small_connected.png
===================================================================
(Binary files differ)
Property changes on: trunk/res/drawable/wlo_ico_small_connected.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/src/fr/ifremer/wlo/BigFinCommunicationService.java
===================================================================
--- trunk/src/fr/ifremer/wlo/BigFinCommunicationService.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/BigFinCommunicationService.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -55,7 +55,6 @@
import android.os.Messenger;
import android.os.RemoteException;
import android.support.v4.app.NotificationCompat;
-import android.support.v4.app.TaskStackBuilder;
import android.util.Log;
import com.google.common.collect.Lists;
import fr.ifremer.wlo.utils.BigFinFeedReaderRecord;
@@ -102,10 +101,14 @@
public static final int MESSAGE_SEND_DATA = 4;
public static final int MESSAGE_DISCONNECT_DEVICE = 5;
+ //BOTH
+ public static final int MESSAGE_CONNECTION_STATE = 7;
+
public static final String DEVICE_NAME = "device_name";
public static final String TOAST = "toast";
public static final String DEVICE_ADDRESS = "device_address";
public static final String DATA_TO_SEND = "dataToSend";
+ public static final String EXTRA_DISCONNECT = "disconnect";
// Member fields
protected BluetoothAdapter mAdapter;
@@ -127,19 +130,27 @@
mAdapter = BluetoothAdapter.getDefaultAdapter();
+ notificationBuilder = new NotificationCompat.Builder(this);
+
setState(STATE_NONE);
- notificationBuilder = new NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.wlo_ico_small)
- .setContentIntent(PendingIntent.getActivity(this, -1, new Intent(this, MainActivity.class), PendingIntent.FLAG_CANCEL_CURRENT));
-
- updateNotification(false);
-
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.notify(NOIFICATION_ID, notificationBuilder.build());
}
@Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ if (intent.getBooleanExtra(EXTRA_DISCONNECT, false)) {
+ if (mClients.isEmpty()) {
+ stopSelf();
+ } else {
+ stop();
+ }
+ }
+ return START_STICKY;
+ }
+
+ @Override
public void onDestroy() {
super.onDestroy();
stop();
@@ -149,34 +160,54 @@
@Override
public IBinder onBind(Intent intent) {
+ // start the service for it to keep living after all activities unbound it
+ startService(intent);
return mMessenger.getBinder();
}
+ @Override
+ public boolean onUnbind(Intent intent) {
+ // stop the service only if it is not connected
+ if (mState != STATE_CONNECTED) {
+ stopSelf();
+ }
+ return true;
+ }
+
protected void updateNotification(boolean connected) {
int title;
int text;
+ int icon;
+ PendingIntent pendingIntent;
-// TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
-// // Adds the Intent to the top of the stack
-// stackBuilder.addNextIntent(new Intent(this, MainActivity.class));
-
if (connected) {
title = R.string.bigfin_ichtyometer_connected_title;
text = R.string.bigfin_ichtyometer_connected_text;
+ icon = R.drawable.wlo_ico_small_connected;
+ Intent intent = new Intent(this, BigFinCommunicationService.class);
+ intent.putExtra(EXTRA_DISCONNECT, true);
+ pendingIntent = PendingIntent.getService(this,
+ -1,
+ intent,
+ PendingIntent.FLAG_CANCEL_CURRENT);
} else {
title = R.string.bigfin_no_ichtyometer_connected_title;
text = R.string.bigfin_no_ichtyometer_connected_text;
+ icon = R.drawable.wlo_ico_small;
+ Intent intent = new Intent(this, DeviceListActivity.class);
+ pendingIntent = PendingIntent.getActivity(this,
+ -1,
+ intent,
+ PendingIntent.FLAG_CANCEL_CURRENT);
}
notificationBuilder.setContentTitle(getText(title))
- .setContentText(getText(text));
+ .setSmallIcon(icon)
+ .setContentText(getText(text))
+ .setContentIntent(pendingIntent);
- if (connected) {
- startForeground(NOIFICATION_ID, notificationBuilder.build());
- } else {
- stopForeground(false);
- }
+ startForeground(NOIFICATION_ID, notificationBuilder.build());
}
protected void sendMessage(int what, int arg1) {
@@ -187,6 +218,10 @@
sendMessage(what, arg1, arg2, null);
}
+ protected void sendMessage(int what, Object obj) {
+ sendMessage(what, -1, -1, obj);
+ }
+
protected void sendMessage(int what, int arg1, int arg2, Object obj) {
for (Messenger messenger : mClients) {
try {
@@ -219,7 +254,8 @@
* @param state An integer defining the current connection state
*/
protected synchronized void setState(int state) {
- Log.d(TAG, "setState() " + mState + " -> " + state);
+ updateNotification(state== STATE_CONNECTED);
+
mState = state;
sendMessage(MESSAGE_STATE_CHANGE, state);
}
@@ -228,8 +264,6 @@
* Stop all threads
*/
protected synchronized void stop() {
- Log.d(TAG, "stop");
-
if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
@@ -247,16 +281,9 @@
setState(STATE_NONE);
- notificationBuilder.setContentTitle(getText(R.string.bigfin_no_ichtyometer_connected_title))
- .setContentText(getText(R.string.bigfin_no_ichtyometer_connected_text));
- NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- manager.notify(NOIFICATION_ID, notificationBuilder.build());
-
}
protected synchronized void reset() {
- Log.d(TAG, "reset");
-
stop();
setState(STATE_LISTEN);
@@ -271,8 +298,6 @@
* @param device The BluetoothDevice to connect
*/
protected synchronized void connect(BluetoothDevice device) {
- Log.d(TAG, "connect to: " + device);
-
// Cancel any thread attempting to make a connection
if (mState == STATE_CONNECTING) {
if (mConnectThread != null) {
@@ -288,9 +313,11 @@
}
// Start the thread to connect with the given device
- mConnectThread = new ConnectThread(device);
- mConnectThread.start();
- setState(STATE_CONNECTING);
+ //TODO
+// mConnectThread = new ConnectThread(device);
+// mConnectThread.start();
+// setState(STATE_CONNECTING);
+ setState(STATE_CONNECTED);
}
/**
@@ -299,8 +326,6 @@
* @param device The BluetoothDevice that has been connected
*/
protected synchronized void connected(BluetoothSocket socket, BluetoothDevice device) {
- Log.d(TAG, "connected");
-
// Cancel the thread that completed the connection
if (mConnectThread != null) {
mConnectThread.cancel();
@@ -327,9 +352,6 @@
sendMessage(MESSAGE_DEVICE_NAME, DEVICE_NAME, device.getName());
setState(STATE_CONNECTED);
-
- updateNotification(true);
-
}
/**
@@ -346,7 +368,8 @@
r = mConnectedThread;
}
// Perform the write unsynchronized
- r.write(out);
+ //TODO
+// r.write(out);
}
/**
@@ -394,7 +417,6 @@
}
public void run() {
- Log.d(TAG, "BEGIN mAcceptThread" + this);
setName("AcceptThread");
BluetoothSocket socket = null;
@@ -432,12 +454,9 @@
}
}
}
- Log.i(TAG, "END mAcceptThread");
-
}
public void cancel() {
- Log.d(TAG, "Socket cancel " + this);
try {
mmServerSocket.close();
mmServerSocket = null;
@@ -472,7 +491,6 @@
}
public void run() {
- Log.i(TAG, "BEGIN mConnectThread");
setName("ConnectThread");
// Make a connection to the BluetoothSocket
@@ -522,7 +540,6 @@
protected boolean stop;
public ConnectedThread(BluetoothSocket socket) {
- Log.d(TAG, "create ConnectedThread");
mmSocket = socket;
InputStream tmpIn = null;
OutputStream tmpOut = null;
@@ -542,7 +559,6 @@
}
public void run() {
- Log.i(TAG, "BEGIN mConnectedThread");
byte[] buffer = new byte[1024];
int bytes;
@@ -580,11 +596,10 @@
String crc = result.substring(lastComma);
- Log.d(TAG, String.format("Record: %s / %s", record, crc));
BigFinFeedReaderRecord readerRecord = new BigFinFeedReaderRecord(record, crc);
// Send the obtained bytes to the UI Activity
- sendMessage(MESSAGE_READ, -1, -1, readerRecord);
+ sendMessage(MESSAGE_READ, readerRecord);
} catch (IOException e) {
Log.e(TAG, "disconnected");
@@ -602,7 +617,7 @@
mmOutStream.write(buffer);
// Share the sent message back to the UI Activity
- sendMessage(MESSAGE_WRITE, -1, -1, buffer);
+ sendMessage(MESSAGE_WRITE, buffer);
} catch (IOException e) {
Log.e(TAG, "Exception during write", e);
@@ -636,7 +651,6 @@
reset();
String deviceAddress = msg.getData().getString(DEVICE_ADDRESS);
- Log.d(TAG, "connect device " + deviceAddress);
// Get the BluetoothDevice object
BluetoothDevice device = mAdapter.getRemoteDevice(deviceAddress);
connect(device);
@@ -651,6 +665,9 @@
stop();
break;
+ case MESSAGE_CONNECTION_STATE:
+ BigFinCommunicationService.this.sendMessage(MESSAGE_CONNECTION_STATE, mState);
+
default:
super.handleMessage(msg);
}
Modified: trunk/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -28,11 +28,9 @@
import android.database.Cursor;
import android.os.Bundle;
import android.preference.PreferenceManager;
-import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.Spinner;
@@ -41,7 +39,6 @@
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-import fr.ifremer.wlo.models.BaseModel;
import fr.ifremer.wlo.models.CommercialSpeciesModel;
import fr.ifremer.wlo.models.categorization.CategoryModel;
import fr.ifremer.wlo.models.referentials.CommercialSpecies;
@@ -93,7 +90,6 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
super.onCreate(savedInstanceState);
// editors
@@ -211,7 +207,6 @@
final Function<CategoryModel, Void> setCategoryFunction) {
List<Object> categories = new ArrayList<Object>(DataCache.getAllCategories(this));
categories.add(0, "");
- Log.d(TAG, categories.toString());
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, categories);
spinner.setAdapter(adapter);
spinner.setSelection(adapter.getPosition(category));
Modified: trunk/src/fr/ifremer/wlo/ContextFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/ContextFormActivity.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/ContextFormActivity.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -25,7 +25,6 @@
*/
import android.os.Bundle;
-import android.util.Log;
import fr.ifremer.wlo.models.ContextModel;
/**
@@ -63,7 +62,6 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
super.onCreate(savedInstanceState);
initEditText(R.id.context_form_name, ContextModel.COLUMN_NAME);
Modified: trunk/src/fr/ifremer/wlo/ContextsActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/ContextsActivity.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/ContextsActivity.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -3,8 +3,8 @@
/*
* #%L
* WLO
- * $Id:$
- * $HeadURL:$
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2013 - 2014 Ifremer
* %%
@@ -26,7 +26,6 @@
import android.database.Cursor;
import android.support.v4.widget.SimpleCursorAdapter;
-import android.util.Log;
import fr.ifremer.wlo.models.ContextModel;
/**
@@ -83,7 +82,6 @@
super.onResume();
Cursor cursor = getAllData();
- Log.d(TAG, "cursor size : " + cursor.getCount());
adapter.swapCursor(cursor);
}
}
Modified: trunk/src/fr/ifremer/wlo/DeviceListActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/DeviceListActivity.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/DeviceListActivity.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -56,7 +56,6 @@
import android.os.RemoteException;
import android.util.Log;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
@@ -80,7 +79,6 @@
// Member fields
protected BluetoothAdapter mBtAdapter;
protected ArrayAdapter<String> mPairedDevicesArrayAdapter;
-// private ArrayAdapter<String> mNewDevicesArrayAdapter;
protected Messenger mServiceMessenger = null;
protected Messenger mMessenger = new Messenger(new IncomingHandler());
@@ -126,7 +124,6 @@
doUnbindService();
}
-
/**
* Un-bind this Activity to MyService
*/
@@ -215,8 +212,8 @@
case BigFinCommunicationService.STATE_CONNECTED:
sendDataToDevice("a");
sendDataToDevice("b");
-
- dialog.dismiss();
+//TODO
+// dialog.dismiss();
setResult(RESULT_OK);
finish();
@@ -234,13 +231,11 @@
byte[] writeBuf = (byte[]) msg.obj;
// construct a string from the buffer
String writeMessage = new String(writeBuf);
- Log.d(TAG, "write " + writeMessage);
break;
case BigFinCommunicationService.MESSAGE_READ:
BigFinFeedReaderRecord record = (BigFinFeedReaderRecord) msg.obj;
// construct a string from the valid bytes in the buffer
- Log.d(TAG, "read " + record.getLength());
break;
case BigFinCommunicationService.MESSAGE_DEVICE_NAME:
Modified: trunk/src/fr/ifremer/wlo/LocationFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/LocationFormActivity.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/LocationFormActivity.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -28,7 +28,6 @@
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.DialogFragment;
-import android.util.Log;
import android.view.View;
import android.widget.TextView;
import com.google.common.collect.Lists;
@@ -78,7 +77,6 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
super.onCreate(savedInstanceState);
// init editors
Modified: trunk/src/fr/ifremer/wlo/MainActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/MainActivity.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/MainActivity.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -27,6 +27,7 @@
import android.app.Activity;
import android.app.ProgressDialog;
import android.bluetooth.BluetoothAdapter;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
@@ -34,6 +35,7 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
+import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
@@ -50,19 +52,18 @@
import fr.ifremer.wlo.models.MetierModel;
import fr.ifremer.wlo.models.ScientificSpeciesModel;
import fr.ifremer.wlo.models.VesselModel;
-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.CsvExporter;
import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.storage.JsonExporter;
import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+import fr.ifremer.wlo.utils.ImportExportUtil;
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;
@@ -82,8 +83,7 @@
private static final String TAG = "MainActivity";
protected static final int REQUEST_ENABLE_BT = 1;
- protected static final int REQUEST_CONNECT_ICHTYOMETER = 2;
- protected static final int REQUEST_SELECT_EXPORT_FOLDER = 3;
+ protected static final int REQUEST_SELECT_EXPORT_FOLDER = 2;
// Local Bluetooth adapter
protected BluetoothAdapter mBluetoothAdapter = null;
@@ -97,8 +97,6 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "create");
-
super.onCreate(savedInstanceState);
new InitializationTask().execute();
@@ -143,12 +141,44 @@
case BigFinCommunicationService.MESSAGE_CONNECTION_LOST:
bigfinDisconnected();
break;
+ case BigFinCommunicationService.MESSAGE_CONNECTION_STATE:
+ if (msg.arg1 == BigFinCommunicationService.STATE_CONNECTED) {
+ bigfinConnected();
+ } else {
+ bigfinDisconnected();
+ }
}
}
});
bigfinDisconnected();
}
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ getBigFinConnectionState();
+ }
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ super.onServiceConnected(name, service);
+ getBigFinConnectionState();
+ }
+
+ protected void getBigFinConnectionState() {
+ if (mServiceMessenger != null) {
+ try {
+ Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_CONNECTION_STATE);
+ msg.replyTo = mMessenger;
+ mServiceMessenger.send(msg);
+
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error while sending data to the service");
+ }
+ }
+ }
+
protected void bigfinConnected() {
disconnectButton.setVisibility(View.VISIBLE);
connectButton.setVisibility(View.GONE);
@@ -220,14 +250,14 @@
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
- case REQUEST_CONNECT_ICHTYOMETER:
- // When DeviceListActivity returns with a device to connect
- if (resultCode == Activity.RESULT_OK) {
- bigfinConnected();
- } else {
- bigfinDisconnected();
- }
- break;
+// case REQUEST_CONNECT_ICHTYOMETER:
+// // When DeviceListActivity returns with a device to connect
+// if (resultCode == Activity.RESULT_OK) {
+// bigfinConnected();
+// } else {
+// bigfinDisconnected();
+// }
+// break;
case REQUEST_ENABLE_BT:
// When the request to enable Bluetooth returns
@@ -237,7 +267,6 @@
} else {
// User did not enable Bluetooth or an error occurred
- Log.d(TAG, "BT not enabled");
Toast.makeText(this, R.string.bt_not_enabled, Toast.LENGTH_SHORT).show();
}
break;
@@ -417,7 +446,7 @@
protected void selectDevice() {
// Launch the DeviceListActivity to see devices and do scan
Intent serverIntent = new Intent(this, DeviceListActivity.class);
- startActivityForResult(serverIntent, REQUEST_CONNECT_ICHTYOMETER);
+ startActivity(serverIntent);
}
protected class InitializationTask extends AsyncTask<Void, Integer, Void> {
Modified: trunk/src/fr/ifremer/wlo/MetierFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/MetierFormActivity.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/MetierFormActivity.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -25,11 +25,8 @@
*/
import android.os.Bundle;
-import android.util.Log;
import com.google.common.collect.Lists;
-import fr.ifremer.wlo.models.LocationModel;
import fr.ifremer.wlo.models.MetierModel;
-import fr.ifremer.wlo.models.referentials.Location;
import fr.ifremer.wlo.models.referentials.Metier;
import fr.ifremer.wlo.storage.DataCache;
@@ -70,7 +67,6 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
super.onCreate(savedInstanceState);
// init editors
Modified: trunk/src/fr/ifremer/wlo/ScientificSpeciesActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/ScientificSpeciesActivity.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/ScientificSpeciesActivity.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -27,7 +27,6 @@
import android.content.Intent;
import android.database.Cursor;
import android.support.v4.widget.SimpleCursorAdapter;
-import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -35,7 +34,6 @@
import android.widget.ListView;
import com.google.common.collect.Maps;
import fr.ifremer.wlo.measurement.MeasurementActivity;
-import fr.ifremer.wlo.models.BaseModel;
import fr.ifremer.wlo.models.CommercialSpeciesModel;
import fr.ifremer.wlo.models.ScientificSpeciesModel;
import fr.ifremer.wlo.utils.WloItemListViewBinder;
@@ -86,7 +84,6 @@
switch (item.getItemId()) {
case R.id.weights:
Intent intent = new Intent(this, WeightsActivity.class);
- Log.d(TAG, "getTotalUnloadedWeight " + ((CommercialSpeciesModel) parentModel).getTotalUnloadedWeight());
intent.putExtra(WeightsActivity.INTENT_COMMERCIAL_SPECIES, parentModel);
startActivityForResult(intent, REQUEST_EDIT_WEIGHTS);
return true;
@@ -117,7 +114,6 @@
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
ScientificSpeciesModel model = createNewModel(l, position);
- Log.d(TAG, model.toString(this) + " clicked");
updateDrawerItems(model);
Modified: trunk/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -28,8 +28,6 @@
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
-import android.util.Log;
-import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import com.google.common.base.Predicate;
@@ -41,7 +39,6 @@
import fr.ifremer.wlo.models.referentials.ScientificSpecies;
import fr.ifremer.wlo.preferences.MultiSelectItemPreference;
import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
import fr.ifremer.wlo.utils.WloAutoCompleteTextViewWithFavorites;
import java.util.Collection;
@@ -83,7 +80,6 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
super.onCreate(savedInstanceState);
// editors
Modified: trunk/src/fr/ifremer/wlo/WloBaseActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/WloBaseActivity.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/WloBaseActivity.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -37,7 +37,6 @@
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
-import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
@@ -45,9 +44,6 @@
import android.view.View;
import android.widget.Toast;
-import java.io.File;
-import java.io.FileNotFoundException;
-
/**
* @author kmorin <kmorin(a)codelutin.com>
* @since 0.1
@@ -61,6 +57,7 @@
protected DownloadManager downloadManager;
protected static Long downloadingApkId = null;
+
protected final BroadcastReceiver downloadReceiver = new BroadcastReceiver() {
@Override
@@ -124,20 +121,17 @@
@Override
protected void onPause() {
- Log.d(TAG, "pause");
super.onPause();
unregisterReceiver(downloadReceiver);
}
@Override
protected void onStop() {
- Log.d(TAG, "stop");
super.onStop();
doUnbindService();
}
protected void doUnbindService() {
- Log.d(TAG, "doUnbindService " + this);
// If we have received the service, and hence registered with it, then now is the time to unregister.
if (mServiceMessenger != null && mMessenger != null) {
try {
@@ -155,9 +149,7 @@
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
- Log.d(TAG, "onServiceConnected " + this);
mServiceMessenger = new Messenger(service);
- Log.d(TAG, "mMessenger " + mMessenger);
if (mMessenger != null) {
try {
Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_REGISTER_CLIENT);
@@ -172,7 +164,6 @@
@Override
public void onServiceDisconnected(ComponentName name) {
- Log.d(TAG, "onServiceDisconnected " + this);
mServiceMessenger = null;
}
Modified: trunk/src/fr/ifremer/wlo/WloBaseListActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/WloBaseListActivity.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/WloBaseListActivity.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -50,7 +50,6 @@
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.SimpleCursorAdapter;
-import android.util.Log;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
@@ -75,7 +74,6 @@
import fr.ifremer.wlo.utils.WloItemListViewBinder;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -353,10 +351,8 @@
super.onResume();
parentModel = (BaseModel) getIntent().getSerializableExtra(INTENT_EXTRA_PARENT_MODEL);
- Log.d(TAG, "resume " + parentModel);
if (parentModel != null) {
Cursor cursor = getAllData();
- Log.d(TAG, "cursor size : " + cursor.getCount());
adapter.swapCursor(cursor);
Integer subtitleId = getSubtitle();
@@ -460,8 +456,6 @@
protected void onListItemClick(ListView l, View v, int position, long id) {
M model = createNewModel(l, position);
- Log.d(TAG, model.toString(this) + " clicked");
-
updateDrawerItems(model);
Intent intent = new Intent(this, getNextActivity());
Modified: trunk/src/fr/ifremer/wlo/WloModelEditionActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/WloModelEditionActivity.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/WloModelEditionActivity.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -28,7 +28,6 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
-import android.text.Editable;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
@@ -39,7 +38,6 @@
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
-import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import fr.ifremer.wlo.models.BaseModel;
import fr.ifremer.wlo.models.HierarchicalModel;
@@ -47,14 +45,11 @@
import fr.ifremer.wlo.utils.BaseTextWatcher;
import fr.ifremer.wlo.utils.UIUtils;
import fr.ifremer.wlo.utils.WloAutoCompleteTextViewWithFavorites;
-import org.apache.commons.lang3.ObjectUtils;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
-import java.util.List;
-import java.util.Map;
/**
* @author kmorin <kmorin(a)codelutin.com>
@@ -78,7 +73,6 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
super.onCreate(savedInstanceState);
// model
@@ -101,7 +95,6 @@
model.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
- Log.d(TAG, "modified !");
model.setModified(true);
}
});
@@ -307,7 +300,6 @@
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
R selectedData = (R) parent.getItemAtPosition(position);
- Log.d(TAG, "selectedData.getClass() " + selectedData.getClass());
try {
clazz.getMethod("set" + firtsLetterUpperCaseAttribute, selectedData.getClass()).invoke(model, selectedData);
Modified: trunk/src/fr/ifremer/wlo/imports/CalcifiedPartTakingRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/imports/CalcifiedPartTakingRowModel.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/imports/CalcifiedPartTakingRowModel.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -24,14 +24,11 @@
* #L%
*/
-import android.util.Log;
import com.google.common.base.Function;
import com.google.common.collect.Maps;
import fr.ifremer.wlo.models.referentials.CalcifiedPartTaking;
import fr.ifremer.wlo.models.referentials.ScientificSpecies;
import org.nuiton.csv.ValueGetterSetter;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
import java.util.Collection;
import java.util.Map;
@@ -58,9 +55,7 @@
newColumnForImportExport("Espece_scientifique", new ValueGetterSetter<CalcifiedPartTaking, String>() {
@Override
public void set(CalcifiedPartTaking object, String value) throws Exception {
- Log.d(TAG, "code expece scientific " + value);
ScientificSpecies species = scientificSpeciesByCode.get(value);
- Log.d(TAG, "expece scientific " + species);
object.setParent(species);
}
@@ -79,7 +74,6 @@
} catch (NumberFormatException e) {
size = null;
}
- Log.d(TAG, object + "setStartSize " + size);
object.setStartSize(size);
}
@@ -98,7 +92,6 @@
} catch (NumberFormatException e) {
size = null;
}
- Log.d(TAG, object + "setEndSize " + size);
object.setEndSize(size);
}
@@ -117,7 +110,6 @@
} catch (NumberFormatException e) {
size = null;
}
- Log.d(TAG, object + "setSizeStep " + size);
object.setSizeStep(size);
}
@@ -131,7 +123,6 @@
@Override
public void set(CalcifiedPartTaking object, String value) throws Exception {
Integer size = Integer.parseInt(value);
- Log.d(TAG, object + "setStep " + size);
object.setStep(size);
}
@@ -150,7 +141,6 @@
} catch (NumberFormatException e) {
size = null;
}
- Log.d(TAG, object + "setStop " + size);
object.setStop(size);
}
Modified: trunk/src/fr/ifremer/wlo/measurement/MeasurementActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/measurement/MeasurementActivity.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/measurement/MeasurementActivity.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -70,19 +70,19 @@
import fr.ifremer.wlo.WloBaseActivity;
import fr.ifremer.wlo.WloBaseListActivity;
import fr.ifremer.wlo.WloModelEditionActivity;
-import fr.ifremer.wlo.models.CategoryWeightModel;
-import fr.ifremer.wlo.models.LocationModel;
-import fr.ifremer.wlo.models.categorization.CategoryModel;
-import fr.ifremer.wlo.models.categorization.QualitativeValueModel;
-import fr.ifremer.wlo.models.referentials.CalcifiedPartTaking;
-import fr.ifremer.wlo.models.referentials.Mensuration;
import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.CategoryWeightModel;
import fr.ifremer.wlo.models.CommercialSpeciesModel;
+import fr.ifremer.wlo.models.LocationModel;
import fr.ifremer.wlo.models.MeasurementModel;
import fr.ifremer.wlo.models.MeasurementsModel;
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.CalcifiedPartTaking;
+import fr.ifremer.wlo.models.referentials.Mensuration;
import fr.ifremer.wlo.storage.WloSqlOpenHelper;
import fr.ifremer.wlo.utils.BaseTextWatcher;
import fr.ifremer.wlo.utils.BigFinFeedReaderRecord;
@@ -152,7 +152,6 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- Log.d(TAG, "on create");
measurements = (MeasurementsModel) getIntent().getSerializableExtra(INTENT_EXTRA_MEASUREMENTS);
if (measurements != null) {
@@ -426,7 +425,6 @@
}
} else if (resultCode == RESULT_OK) {
- Log.d(TAG, "requestCode " + requestCode);
switch (requestCode) {
case 1:
vessel = (VesselModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
@@ -662,7 +660,6 @@
}
protected void setDrawerListAdapter() {
- Log.d(TAG, scientificSpecies.toString(this));
mDrawerList.setAdapter(new ArrayAdapter<>(this,
android.R.layout.simple_list_item_1,
new String[]{
@@ -720,7 +717,6 @@
if (clazz != null) {
Intent intent = new Intent(this, clazz);
intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL, modelToEdit);
- Log.d(TAG, "startActivityForResult " + position);
startActivityForResult(intent, position);
}
}
Modified: trunk/src/fr/ifremer/wlo/models/BaseModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/BaseModel.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/models/BaseModel.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -25,7 +25,6 @@
*/
import android.content.ContentValues;
-import android.content.Context;
import android.database.Cursor;
import android.provider.BaseColumns;
import android.util.Log;
@@ -36,11 +35,9 @@
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
-import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
-import java.util.Objects;
import java.util.Set;
/**
@@ -176,7 +173,6 @@
protected void putValue(ContentValues values, String column, String value) {
if (value == null) {
values.putNull(column);
- Log.d(TAG, "put value null for column " + column);
} else {
values.put(column, value);
}
@@ -185,7 +181,6 @@
protected void putValue(ContentValues values, String column, Long value) {
if (value == null) {
values.putNull(column);
- Log.d(TAG, "put value null for column " + column);
} else {
values.put(column, value);
}
@@ -194,7 +189,6 @@
protected void putValue(ContentValues values, String column, Integer value) {
if (value == null) {
values.putNull(column);
- Log.d(TAG, "put value null for column " + column);
} else {
values.put(column, value);
}
@@ -203,7 +197,6 @@
protected void putValue(ContentValues values, String column, Float value) {
if (value == null) {
values.putNull(column);
- Log.d(TAG, "put value null for column " + column);
} else {
values.put(column, value);
}
Modified: trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -27,7 +27,6 @@
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
-import android.util.Log;
import fr.ifremer.wlo.models.categorization.CategoryModel;
import fr.ifremer.wlo.models.referentials.CommercialSpecies;
import fr.ifremer.wlo.models.referentials.Mensuration;
@@ -99,9 +98,7 @@
faoCode = DataCache.getCommercialSpeciesById(context, faoCodeId);
String measurementMethodId = cursor.getString(2);
measurementMethod = DataCache.getMensurationById(context, measurementMethodId);
- Log.d(TAG, cursor.getString(3));
precision = Mensuration.Precision.valueOf(cursor.getString(3));
- Log.d(TAG, precision.toString());
speciesMix = cursor.getShort(4) > 0;
sortCategory = cursor.getString(5);
String stateId = cursor.getString(6);
@@ -157,7 +154,6 @@
public void setSpeciesMix(boolean speciesMix) {
boolean oldValue = this.speciesMix;
this.speciesMix = speciesMix;
- Log.d(TAG, "species mix change");
firePropertyChange(COLUMN_SPECIES_MIX, oldValue, speciesMix);
}
Modified: trunk/src/fr/ifremer/wlo/models/VesselModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/VesselModel.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/models/VesselModel.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -27,7 +27,6 @@
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
-import android.util.Log;
import com.google.common.collect.Sets;
import fr.ifremer.wlo.models.referentials.Location;
import fr.ifremer.wlo.models.referentials.Vessel;
@@ -87,14 +86,12 @@
}
public void setRegistrationNumber(String registrationNumber) {
- Log.d(TAG, "setRegistrationNumber string " + registrationNumber);
Object oldValue = this.registrationNumber;
this.registrationNumber = registrationNumber;
firePropertyChange(COLUMN_REGISTRATION_NUMBER, oldValue, registrationNumber);
}
public void setRegistrationNumber(Vessel vessel) {
- Log.d(TAG, "setRegistrationNumber vessel " + vessel.getCode());
if (vessel != null) {
setRegistrationNumber(vessel.getCode());
if (StringUtils.isEmpty(name)) {
@@ -108,7 +105,6 @@
}
public void setName(String name) {
- Log.d(TAG, "setName " + name);
Object oldValue = this.name;
this.name = name;
firePropertyChange(COLUMN_NAME, oldValue, name);
Modified: trunk/src/fr/ifremer/wlo/models/categorization/QualitativeValueModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/categorization/QualitativeValueModel.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/models/categorization/QualitativeValueModel.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -26,7 +26,6 @@
import android.content.ContentValues;
import android.database.Cursor;
-import android.util.Log;
import fr.ifremer.wlo.models.BaseModel;
import org.apache.commons.lang3.StringUtils;
@@ -65,7 +64,6 @@
super(cursor);
value = cursor.getString(1);
label = cursor.getString(2);
- Log.d(TAG, cursor.getString(3) + " " + value + " " + label);
}
public String getValue() {
Modified: trunk/src/fr/ifremer/wlo/models/referentials/CalcifiedPartTaking.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/CalcifiedPartTaking.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/models/referentials/CalcifiedPartTaking.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -26,10 +26,7 @@
import android.content.ContentValues;
import android.database.Cursor;
-import android.util.Log;
-import fr.ifremer.wlo.models.BaseModel;
import fr.ifremer.wlo.models.HierarchicalModel;
-import fr.ifremer.wlo.models.referentials.ScientificSpecies;
/**
* @author Kevin Morin (Code Lutin)
@@ -85,7 +82,6 @@
if (!cursor.isNull(5)) {
stop = cursor.getInt(5);
}
- Log.d(TAG, startSize + " " + endSize + " " + sizeStep + " " + step + " " + stop);
}
public Integer getStartSize() {
Modified: trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -230,7 +230,6 @@
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- Log.d(TAG, "onSharedPreferenceChanged " + key);
Preference preference = findPreference(key);
String summary = null;
@@ -279,14 +278,12 @@
ScientificSpecies.class,
REQUEST_FAVORITES_SCIENTIFIC_SPECIES);
- Log.d(TAG, "registerOnSharedPreferenceChangeListener");
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onPause() {
super.onPause();
- Log.d(TAG, "unregisterOnSharedPreferenceChangeListener");
getPreferenceScreen().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(this);
}
@@ -351,7 +348,6 @@
protected <M extends BaseModel> void initMultiSelectListPreference(String prefKey,
final Class clazz,
final int requestCode) {
- Log.d(TAG, "initMultiSelectListPreference " + prefKey);
Preference preference = findPreference(prefKey);
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
@@ -414,7 +410,6 @@
String path = (String) params[0];
Integer requestCode = (Integer) params[1];
Boolean backupFile = (Boolean) params[2];
- Log.d(TAG, path);
Integer[] result = new Integer[3];
result[2] = requestCode;
@@ -548,7 +543,6 @@
Context context = getActivity();
String path = (String) params[0];
Integer requestCode = (Integer) params[1];
- Log.d(TAG, path);
Integer result;
Modified: trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java
===================================================================
--- trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -28,7 +28,6 @@
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
-import android.util.Log;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
@@ -706,11 +705,9 @@
ContentValues values = model.convertIntoContentValues();
if (newSession) {
- Log.d(TAG, "create " + values);
db.insert(tableName, null, values);
} else {
- Log.d(TAG, "update " + values);
db.update(tableName, values, BaseModel._ID + " = ?", new String[]{ model.getId() });
}
model.setModified(false);
Modified: trunk/src/fr/ifremer/wlo/utils/BigFinFeedReaderRecord.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/BigFinFeedReaderRecord.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/utils/BigFinFeedReaderRecord.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -122,24 +122,19 @@
// get msb bite value
long msb = checksum >> 31;
- Log.d(TAG, String.format("i=%4d char=%s(int:%3d) incoming checksum=%10d msb=%d bits=%33s", i, record.charAt(i), (int) record.charAt(i), checksum, msb, Long.toBinaryString(checksum)));
// logical shift left
checksum <<= 1;
- Log.d(TAG, String.format("After lef shift : %33s", Long.toBinaryString(checksum)));
// rotates msb to lsb
checksum += msb;
- Log.d(TAG, String.format("After add smb : %33s", Long.toBinaryString(checksum)));
// add new caracter
checksum += record.charAt(i);
- Log.d(TAG, String.format("After add car : %33s", Long.toBinaryString(checksum)));
}
// get a hexadecimal on 32bites -> 8 hexadecimal caracters
String hex = Long.toHexString(checksum).toUpperCase();
- Log.d(TAG, "checksum= " + checksum);
return hex;
}
Modified: trunk/src/fr/ifremer/wlo/utils/UpdateCheckTask.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/UpdateCheckTask.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/utils/UpdateCheckTask.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -27,13 +27,9 @@
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.app.ProgressDialog;
-import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.IntentFilter;
import android.content.pm.PackageManager;
-import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
@@ -44,13 +40,8 @@
import org.nuiton.util.Version;
import org.nuiton.util.VersionUtil;
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Date;
import java.util.Properties;
/**
@@ -111,7 +102,6 @@
result = props.getProperty(URL_PROP);
} else {
- Log.d(TAG, "The application is up to date");
result = null;
}
Modified: trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -26,7 +26,6 @@
import android.content.Context;
import android.util.AttributeSet;
-import android.util.Log;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
@@ -71,7 +70,6 @@
setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- Log.d(TAG, "onClick " + isPopupShowing());
if (getAdapter() != null && !getAdapter().isEmpty() && !popupShown) {
showDropDown();
popupShown = true;
Modified: trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextViewWithFavorites.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextViewWithFavorites.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextViewWithFavorites.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -26,7 +26,6 @@
import android.content.Context;
import android.util.AttributeSet;
-import android.util.Log;
import android.widget.Adapter;
import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
@@ -37,7 +36,6 @@
import org.apache.commons.collections.CollectionUtils;
import java.util.Collection;
-import java.util.Collections;
/**
* @author kmorin <kmorin(a)codelutin.com>
@@ -73,7 +71,6 @@
toggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- Log.d(TAG, "onCheckedChanged " + isChecked);
String s = autoCompleteTextView.getText().toString();
autoCompleteTextView.setText(null);
Adapter adapter = autoCompleteTextView.getAdapter();
@@ -109,7 +106,6 @@
protected void useFavorites(boolean favorites) {
if (CollectionUtils.isNotEmpty(favoriteData)) {
- Log.d(TAG, "useFavorites " + favorites);
clear();
if (favorites) {
addAll(favoriteData);
Modified: trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-04-01 09:35:09 UTC (rev 89)
+++ trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-04-01 16:05:42 UTC (rev 90)
@@ -27,19 +27,14 @@
import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.SimpleCursorAdapter;
-import android.util.Log;
import android.view.View;
import android.widget.TextView;
-import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import fr.ifremer.wlo.R;
import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.models.referentials.Metier;
import fr.ifremer.wlo.storage.DataCache;
import java.util.Date;
-import java.util.List;
import java.util.Map;
/**
@@ -77,7 +72,6 @@
@Override
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
DataType dataType = dataTypes.get(columnIndex);
- Log.d(TAG, "dataType for " + columnIndex + " : " + dataType);
TextView textView = (TextView) view;
if (dataType != null) {
1
0
01 Apr '14
Author: kmorin
Date: 2014-04-01 11:35:09 +0200 (Tue, 01 Apr 2014)
New Revision: 89
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/89
Log:
fixes #4881 [ESPECE COMMERCIALE] Empecher de d?\195?\169grader une pr?\195?\169cision si des donn?\195?\169es sont d?\195?\169j?\195?\160 saisies
Modified:
trunk/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java
trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java
Modified: trunk/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java 2014-04-01 09:08:18 UTC (rev 88)
+++ trunk/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java 2014-04-01 09:35:09 UTC (rev 89)
@@ -137,6 +137,14 @@
}
});
precisionSpinner.setSelection(model.getPrecision().ordinal());
+ boolean precisionEnabled = model.isNew();
+ if (!precisionEnabled) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(this);
+ Cursor cursor = soh.getAllMeasurementsForCommercialSpecies(model.getId());
+ int measurementNb = cursor.getCount();
+ precisionEnabled = measurementNb == 0;
+ }
+ precisionSpinner.setEnabled(precisionEnabled);
Set<String> sortCategories = DataCache.getAllSortCategories(this);
sortCategories.remove("");
Modified: trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java
===================================================================
--- trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-04-01 09:08:18 UTC (rev 88)
+++ trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-04-01 09:35:09 UTC (rev 89)
@@ -66,6 +66,7 @@
private static final String TAG = "WloOpenHelper";
public static final String DATABASE_NAME = "wlo.db";
+ // if you change the version, do not forget to migrate the data in the onUpgrade method
public static final int DATABASE_VERSION = 19;
public static final String TEXT_TYPE = " TEXT";
@@ -413,7 +414,6 @@
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- //TODO kmorin 20131129 migrate data before droping the table
// models
db.execSQL(SQL_DELETE_CALCIFIED_PART_TAKINGS);
db.execSQL(SQL_DELETE_CATEGORY_WEIGHTS);
@@ -516,6 +516,17 @@
return cursor;
}
+ public Cursor getAllMeasurementsForCommercialSpecies(String commercialSpeciesId) {
+ SQLiteDatabase db = getReadableDatabase();
+ String query = "SELECT * FROM " + MeasurementModel.TABLE_NAME + " m INNER JOIN " +
+ ScientificSpeciesModel.TABLE_NAME + " s " +
+ "ON m." + MeasurementModel.COLUMN_SCIENTIFIC_SPECIES_ID + " = " +
+ "s." + ScientificSpeciesModel._ID +
+ " WHERE s." + ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + "=?";
+ Cursor cursor = db.rawQuery(query, new String[]{ commercialSpeciesId });
+ return cursor;
+ }
+
//SCIENTIFIC SPECIES
public Cursor getAllScientificSpecies(String commercialSpeciesId) {
1
0
01 Apr '14
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;
1
0
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