r55 - in trunk: . assets res/values res/values-fr res/xml src/fr/ifremer/wlo src/fr/ifremer/wlo/measurement src/fr/ifremer/wlo/models src/fr/ifremer/wlo/models/calcifiedPartTaking src/fr/ifremer/wlo/models/referentials/imports src/fr/ifremer/wlo/preferences src/fr/ifremer/wlo/storage src/fr/ifremer/wlo/utils/filechooser
Author: kmorin Date: 2014-02-28 14:13:35 +0100 (Fri, 28 Feb 2014) New Revision: 55 Url: http://codelutin.com/projects/wlo/repository/revisions/55 Log: refs #4122 Gestion des pr?\195?\169l?\195?\168vements de pi?\195?\168ces calcifi?\195?\169es refs #4176 Import du param?\195?\169trage de l'algorithme de pr?\195?\169l?\195?\168vement des pi?\195?\168ces calcifi?\195?\169es fix pom to make the release Added: trunk/assets/ref_import_calcified_part_takings.csv trunk/src/fr/ifremer/wlo/models/calcifiedPartTaking/ trunk/src/fr/ifremer/wlo/models/calcifiedPartTaking/CalcifiedPartTaking.java trunk/src/fr/ifremer/wlo/models/calcifiedPartTaking/CalcifiedPartTakingRowModel.java Modified: trunk/pom.xml trunk/res/values-fr/strings.xml trunk/res/values/strings.xml trunk/res/xml/preferences.xml trunk/src/fr/ifremer/wlo/MainActivity.java trunk/src/fr/ifremer/wlo/WeightsActivity.java trunk/src/fr/ifremer/wlo/measurement/MeasurementActivity.java trunk/src/fr/ifremer/wlo/models/BaseModel.java trunk/src/fr/ifremer/wlo/models/CategoryWeightModel.java trunk/src/fr/ifremer/wlo/models/MeasurementsModel.java trunk/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java trunk/src/fr/ifremer/wlo/storage/Exporter.java trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java trunk/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java Copied: trunk/assets/ref_import_calcified_part_takings.csv (from rev 29, trunk/assets/ref_import_scientific_species.csv) =================================================================== --- trunk/assets/ref_import_calcified_part_takings.csv (rev 0) +++ trunk/assets/ref_import_calcified_part_takings.csv 2014-02-28 13:13:35 UTC (rev 55) @@ -0,0 +1,6 @@ +Espece_scientifique;Classe_debut;Classe_fin;Pas_de_classe;Pas;Arret +AAPT;10;200;1;5;Inf +AAPT;201;400;1;2;Inf +AAPT;401;Inf;1;1;Inf +AAPTAAP;5;Inf;5;2;5 +ABAL;10;Inf;10;5;2 \ No newline at end of file Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2014-02-23 17:32:50 UTC (rev 54) +++ trunk/pom.xml 2014-02-28 13:13:35 UTC (rev 55) @@ -177,6 +177,31 @@ <version>3.0-alpha-1</version> </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>3.1</version> + </dependency> + + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + <version>20090211</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + <version>3.2.1</version> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.4</version> + </dependency> + </dependencies> <repositories> @@ -216,6 +241,14 @@ <checksumPolicy>fail</checksumPolicy> </releases> </pluginRepository> + <pluginRepository> + <id>oss.sonatype.org-jayway-snapshots</id> + <name>Jayway OpenSource SNAPSHOTs on Sonatype.org</name> + <url>http://oss.sonatype.org/content/repositories/jayway-snapshots/</url> + <snapshots> + <enabled>true</enabled> + </snapshots> + </pluginRepository> </pluginRepositories> <build> @@ -232,7 +265,7 @@ <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> - <version>3.8.2</version> + <version>3.8.3-SNAPSHOT</version> <executions> <execution> <id>alignApk</id> @@ -248,6 +281,9 @@ <platform>15</platform> </sdk> <extractDuplicates>true</extractDuplicates> + <excludeJarResources> + <excludeJarResource>.*nuiton.*</excludeJarResource> + </excludeJarResources> <!--<sign>--> <!--<debug>false</debug>--> <!--</sign>--> @@ -533,6 +569,37 @@ </build> </profile> + <profile> + <id>analyze-dependencies</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + <build> + <defaultGoal>verify</defaultGoal> + <plugins> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <inherited>true</inherited> + <executions> + <execution> + <id>analyze</id> + <goals> + <goal>analyze-only</goal> + </goals> + <configuration> + <usedDependencies> + <usedDependency>android.support:compatibility-v7-appcompat</usedDependency> + </usedDependencies> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> </profiles> </project> Modified: trunk/res/values/strings.xml =================================================================== --- trunk/res/values/strings.xml 2014-02-23 17:32:50 UTC (rev 54) +++ trunk/res/values/strings.xml 2014-02-28 13:13:35 UTC (rev 55) @@ -68,6 +68,9 @@ <string name="observed_number">Number of individuals observed:</string> + <string name="measurement_taking_message">STOP, please take calcified parts on this individual</string> + <string name="measurement_taking_audio_message">STOP, taking</string> + <!-- Home screen --> <string name="main_open_contexts">Watch/Input data</string> <string name="main_export_data">Export data</string> @@ -100,6 +103,7 @@ <string name="preferences_import_scientific_species">Import scientific species</string> <string name="preferences_import_states">Import states</string> <string name="preferences_import_vessels">Import vessels</string> + <string name="preferences_import_calcified_parts_takings">Import calcified parts taking algorithm settings</string> <string name="preferences_import_no_external_storage_title">External storage unavailable</string> <string name="preferences_import_no_external_storage_message">No externat storage is available.\nWould you like to import the data without saving the source file?</string> <string name="preferences_importing_referential">Importing referential data</string> Modified: trunk/res/values-fr/strings.xml =================================================================== --- trunk/res/values-fr/strings.xml 2014-02-23 17:32:50 UTC (rev 54) +++ trunk/res/values-fr/strings.xml 2014-02-28 13:13:35 UTC (rev 55) @@ -54,14 +54,17 @@ <string name="measurement_graph_title">Observations</string> <string name="deletion">Suppression</string> - <string name="input_deletion_confirmation_title">Supprimer une mesure</string> - <string name="input_deletion_confirmation_message">Êtes vous sûr de vouloir\nsupprimer la saisie\n%s ?</string> + <string name="input_deletion_confirmation_title">Supprimer une observation</string> + <string name="input_deletion_confirmation_message">Êtes vous sûr de vouloir\nsupprimer l\'observation\n%s ?</string> <string name="item_deletion_confirmation_message">Êtes vous sûr de vouloir\nsupprimer l\'élément\n%s ?</string> <string name="undefined">Non défini</string> <string name="observed_number">Nombre d\'individus observés :</string> + <string name="measurement_taking_message">STOP, merci de réaliser le prélèvement des pièces calcifiées de cet individu</string> + <string name="measurement_taking_audio_message">STOP, prélèvement</string> + <!-- Home screen --> <string name="main_open_contexts">Voir / saisir des données</string> <string name="main_export_data">Export des données</string> @@ -93,6 +96,8 @@ <string name="preferences_import_scientific_species">Importer des espèces scientifiques</string> <string name="preferences_import_states">Importer des états</string> <string name="preferences_import_vessels">Importer des navires</string> + <string name="preferences_import_calcified_parts_takings">Import des paramètres des prélèvements</string> + <string name="preferences_import_calcified_parts_takings_summary">des pièces calcifiées</string> <string name="preferences_import_no_external_storage_title">Stockage externe non trouvé</string> <string name="preferences_import_no_external_storage_message">Aucun stockage externe n\'est disponible.\nVoulez vous continuer sans sauvegarder le fichier d\'origine ?</string> <string name="preferences_importing_referential">Import des données du référentiel en cours</string> Modified: trunk/res/xml/preferences.xml =================================================================== --- trunk/res/xml/preferences.xml 2014-02-23 17:32:50 UTC (rev 54) +++ trunk/res/xml/preferences.xml 2014-02-28 13:13:35 UTC (rev 55) @@ -63,6 +63,9 @@ android:key="import_maturities"/> <Preference android:title="@string/preferences_import_genders" android:key="import_genders"/> + <Preference android:title="@string/preferences_import_calcified_parts_takings" + android:summary="@string/preferences_import_calcified_parts_takings_summary" + android:key="import_calcified_parts_takings"/> </PreferenceScreen> Modified: trunk/src/fr/ifremer/wlo/MainActivity.java =================================================================== --- trunk/src/fr/ifremer/wlo/MainActivity.java 2014-02-23 17:32:50 UTC (rev 54) +++ trunk/src/fr/ifremer/wlo/MainActivity.java 2014-02-28 13:13:35 UTC (rev 55) @@ -29,31 +29,24 @@ import android.bluetooth.BluetoothAdapter; import android.content.Intent; import android.content.res.Configuration; -import android.database.Cursor; import android.os.Bundle; -import android.os.Environment; import android.os.Handler; import android.os.Message; import android.os.Messenger; import android.os.RemoteException; import android.util.Log; import android.view.View; -import android.view.ViewGroup; import android.widget.Button; import android.widget.LinearLayout; import android.widget.Toast; -import fr.ifremer.wlo.models.ContextModel; import fr.ifremer.wlo.models.referentials.imports.ImportUtil; 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.BigFinFeedReaderRecord; import fr.ifremer.wlo.utils.filechooser.FileDialog; import fr.ifremer.wlo.utils.filechooser.SelectionMode; import org.apache.commons.io.FileUtils; import org.json.JSONException; -import org.json.JSONObject; import java.io.File; import java.io.IOException; @@ -305,8 +298,11 @@ File file = new File(selectedFile, "export" + date + ".json"); FileUtils.write(file, jsonData); + 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); + Toast.makeText(this, "Erreur lors de l'export", Toast.LENGTH_SHORT).show(); } } break; Modified: trunk/src/fr/ifremer/wlo/WeightsActivity.java =================================================================== --- trunk/src/fr/ifremer/wlo/WeightsActivity.java 2014-02-23 17:32:50 UTC (rev 54) +++ trunk/src/fr/ifremer/wlo/WeightsActivity.java 2014-02-28 13:13:35 UTC (rev 55) @@ -1,5 +1,29 @@ package fr.ifremer.wlo; +/* + * #%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.Intent; import android.content.SharedPreferences; import android.database.Cursor; Modified: trunk/src/fr/ifremer/wlo/measurement/MeasurementActivity.java =================================================================== --- trunk/src/fr/ifremer/wlo/measurement/MeasurementActivity.java 2014-02-23 17:32:50 UTC (rev 54) +++ trunk/src/fr/ifremer/wlo/measurement/MeasurementActivity.java 2014-02-28 13:13:35 UTC (rev 55) @@ -25,6 +25,8 @@ */ import android.app.ActionBar; +import android.app.AlertDialog; +import android.content.DialogInterface; import android.content.Intent; import android.content.res.Configuration; import android.database.Cursor; @@ -63,10 +65,9 @@ import fr.ifremer.wlo.ScientificSpeciesFormActivity; import fr.ifremer.wlo.VesselFormActivity; 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.HierarchicalModel; +import fr.ifremer.wlo.models.calcifiedPartTaking.CalcifiedPartTaking; import fr.ifremer.wlo.models.referentials.Mensuration; import fr.ifremer.wlo.storage.DataCache; import fr.ifremer.wlo.models.BaseModel; @@ -164,6 +165,8 @@ measurements.addMeasurement(measurement); } } + fetchCalcifiedPartTakings(); + measurements.addMeasurementsListener(new MeasurementsModel.MeasurementsListener() { @Override public void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement) { @@ -353,6 +356,7 @@ break; case 4: scientificSpecies = (ScientificSpeciesModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL); + fetchCalcifiedPartTakings(); break; } setDrawerListAdapter(); @@ -462,8 +466,28 @@ } soh.saveData(measurement); - measurements.addMeasurement(measurement); + boolean take = measurements.addMeasurement(measurement); + if (take) { + if (useTextToSpeech) { + textToSpeech.speak(getString(R.string.measurement_taking_audio_message), TextToSpeech.QUEUE_FLUSH, null); + } else { + ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, ToneGenerator.MAX_VOLUME); + tg.startTone(ToneGenerator.TONE_PROP_PROMPT); + } + + // Get instance of Vibrator from current Context + Vibrator v = (Vibrator) getSystemService(VIBRATOR_SERVICE); + // Vibrate for 300 milliseconds + v.vibrate(300); + + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage(R.string.measurement_taking_message) + .setPositiveButton(android.R.string.ok, UIUtils.getCancelClickListener()) + .create() + .show(); + } + MeasurementModel result = measurement; initFishMeasurement(size, cat1, cat2, cat3); @@ -552,6 +576,21 @@ })); } + protected void fetchCalcifiedPartTakings() { + if (scientificSpecies.isTakingActivation()) { + WloSqlOpenHelper soh = new WloSqlOpenHelper(this); + Cursor cursor = soh.getAllCalcifiedPartTakings(scientificSpecies.getName().getId()); + List<CalcifiedPartTaking> calcifiedPartTakings = WloSqlOpenHelper.transformCursorIntoCollection(cursor, new Function<Cursor, CalcifiedPartTaking>() { + @Override + public CalcifiedPartTaking apply(Cursor input) { + return new CalcifiedPartTaking(input); + } + }); + soh.close(); + measurements.setCalcifiedPartTakings(calcifiedPartTakings); + } + } + private class DrawerItemClickListener implements ListView.OnItemClickListener { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { Modified: trunk/src/fr/ifremer/wlo/models/BaseModel.java =================================================================== --- trunk/src/fr/ifremer/wlo/models/BaseModel.java 2014-02-23 17:32:50 UTC (rev 54) +++ trunk/src/fr/ifremer/wlo/models/BaseModel.java 2014-02-28 13:13:35 UTC (rev 55) @@ -199,4 +199,13 @@ } } + 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/CategoryWeightModel.java =================================================================== --- trunk/src/fr/ifremer/wlo/models/CategoryWeightModel.java 2014-02-23 17:32:50 UTC (rev 54) +++ trunk/src/fr/ifremer/wlo/models/CategoryWeightModel.java 2014-02-28 13:13:35 UTC (rev 55) @@ -1,5 +1,29 @@ package fr.ifremer.wlo.models; +/* + * #%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.ContentValues; import android.content.Context; import android.database.Cursor; Modified: trunk/src/fr/ifremer/wlo/models/MeasurementsModel.java =================================================================== --- trunk/src/fr/ifremer/wlo/models/MeasurementsModel.java 2014-02-23 17:32:50 UTC (rev 54) +++ trunk/src/fr/ifremer/wlo/models/MeasurementsModel.java 2014-02-28 13:13:35 UTC (rev 55) @@ -3,8 +3,8 @@ /* * #%L * WLO - * $Id:$ - * $HeadURL:$ + * $Id$ + * $HeadURL$ * %% * Copyright (C) 2013 - 2014 Ifremer * %% @@ -24,9 +24,11 @@ * #L% */ +import android.util.Log; import com.google.common.collect.HashMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; +import fr.ifremer.wlo.models.calcifiedPartTaking.CalcifiedPartTaking; import fr.ifremer.wlo.models.referentials.Mensuration; import java.io.Serializable; @@ -47,6 +49,8 @@ protected Multimap<Integer, MeasurementModel> measurements = HashMultimap.create(); + protected List<CalcifiedPartTaking> calcifiedPartTakings; + transient protected List<MeasurementsListener> listeners = new ArrayList<MeasurementsListener>(); public ScientificSpeciesModel getScientificSpecies() { @@ -77,10 +81,41 @@ return measurements.get(size).size(); } - public void addMeasurement(MeasurementModel fishMeasurement) { + public boolean addMeasurement(MeasurementModel fishMeasurement) { int size = fishMeasurement.getSize(); measurements.put(size, fishMeasurement); fireMeasurementAdded(fishMeasurement); + + boolean result = false; + Log.d(TAG, "calcifiedPartTakings : " + calcifiedPartTakings); + if (calcifiedPartTakings != null) { + CalcifiedPartTaking calcifiedPartTaking = null; + for (CalcifiedPartTaking cpt : calcifiedPartTakings) { + Log.d(TAG, "size : " + size); + Integer startSize = cpt.getStartSize(); + Log.d(TAG, "startSize : " + startSize); + Integer endSize = cpt.getEndSize(); + Log.d(TAG, "endSize : " + endSize); + if ((startSize == null || startSize <= size) + && (endSize == null || endSize >= size)) { + calcifiedPartTaking = cpt; + break; + } + } + Log.d(TAG, "calcifiedPartTaking : " + calcifiedPartTaking); + if (calcifiedPartTaking != null) { + int nb = measurements.get(size).size(); + Log.d(TAG, "nb : " + nb); + int step = calcifiedPartTaking.getStep(); + Log.d(TAG, "step : " + step); + Integer stop = calcifiedPartTaking.getStop(); + Log.d(TAG, "stop : " + stop); + Log.d(TAG, "nb % step : " + (nb % step)); + result = nb == 1 || (nb % step == 0 && (stop == null || nb <= stop)); + } + + } + return result; } public void removeMeasurement(MeasurementModel fishMeasurement) { @@ -89,6 +124,14 @@ fireMeasurementRemoved(fishMeasurement); } + public List<CalcifiedPartTaking> getCalcifiedPartTakings() { + return calcifiedPartTakings; + } + + public void setCalcifiedPartTakings(List<CalcifiedPartTaking> calcifiedPartTakings) { + this.calcifiedPartTakings = calcifiedPartTakings; + } + public void addMeasurementsListener(MeasurementsListener listener) { ensureListeners(); listeners.add(listener); Added: trunk/src/fr/ifremer/wlo/models/calcifiedPartTaking/CalcifiedPartTaking.java =================================================================== --- trunk/src/fr/ifremer/wlo/models/calcifiedPartTaking/CalcifiedPartTaking.java (rev 0) +++ trunk/src/fr/ifremer/wlo/models/calcifiedPartTaking/CalcifiedPartTaking.java 2014-02-28 13:13:35 UTC (rev 55) @@ -0,0 +1,142 @@ +package fr.ifremer.wlo.models.calcifiedPartTaking; + +/* + * #%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.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) + * @since x.x + */ +public class CalcifiedPartTaking extends HierarchicalModel<ScientificSpecies> { + + private static final String TAG = "CalcifiedPartTaking"; + + public static final String TABLE_NAME = "calcifiedPartTaking"; + public static final String COLUMN_START_SIZE = "startSize"; + public static final String COLUMN_END_SIZE = "endSize"; + public static final String COLUMN_SIZE_STEP = "sizeStep"; + public static final String COLUMN_STEP = "step"; + public static final String COLUMN_STOP = "stop"; + public static final String COLUMN_SCIENTIFIC_SPECIES_ID = "scientificSpeciesId"; + public static final String[] ALL_COLUMNS = new String[] { + _ID, + COLUMN_START_SIZE, + COLUMN_END_SIZE, + COLUMN_SIZE_STEP, + COLUMN_STEP, + COLUMN_STOP, + COLUMN_SCIENTIFIC_SPECIES_ID + }; + + @Override + public String getTableName() { + return TABLE_NAME; + } + + protected Integer startSize; + protected Integer endSize; + protected int sizeStep; + protected int step; + protected Integer stop; + + public CalcifiedPartTaking() { + } + + public CalcifiedPartTaking(Cursor cursor) { + super(cursor); + if (!cursor.isNull(1)) { + startSize = cursor.getInt(1); + } + if (!cursor.isNull(2)) { + endSize = cursor.getInt(2); + } + if (!cursor.isNull(3)) { + sizeStep = cursor.getInt(3); + } + step = cursor.getInt(4); + if (!cursor.isNull(5)) { + stop = cursor.getInt(5); + } + Log.d(TAG, startSize + " " + endSize + " " + sizeStep + " " + step + " " + stop); + } + + public Integer getStartSize() { + return startSize; + } + + public void setStartSize(Integer startSize) { + this.startSize = startSize; + } + + public Integer getEndSize() { + return endSize; + } + + public void setEndSize(Integer endSize) { + this.endSize = endSize; + } + + public int getSizeStep() { + return sizeStep; + } + + public void setSizeStep(int sizeStep) { + this.sizeStep = sizeStep; + } + + public int getStep() { + return step; + } + + public void setStep(int step) { + this.step = step; + } + + public Integer getStop() { + return stop; + } + + public void setStop(Integer stop) { + this.stop = stop; + } + + @Override + public ContentValues convertIntoContentValues() { + ContentValues value = super.convertIntoContentValues(); + putValue(value, COLUMN_START_SIZE, startSize); + putValue(value, COLUMN_END_SIZE, endSize); + putValue(value, COLUMN_SIZE_STEP, sizeStep); + putValue(value, COLUMN_STEP, step); + putValue(value, COLUMN_STOP, stop); + putValue(value, COLUMN_SCIENTIFIC_SPECIES_ID, getParentId()); + return value; + } +} \ No newline at end of file Copied: trunk/src/fr/ifremer/wlo/models/calcifiedPartTaking/CalcifiedPartTakingRowModel.java (from rev 29, trunk/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java) =================================================================== --- trunk/src/fr/ifremer/wlo/models/calcifiedPartTaking/CalcifiedPartTakingRowModel.java (rev 0) +++ trunk/src/fr/ifremer/wlo/models/calcifiedPartTaking/CalcifiedPartTakingRowModel.java 2014-02-28 13:13:35 UTC (rev 55) @@ -0,0 +1,132 @@ +package fr.ifremer.wlo.models.calcifiedPartTaking; + +/* + * #%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.util.Log; +import com.google.common.base.Function; +import com.google.common.collect.Maps; +import fr.ifremer.wlo.models.referentials.ScientificSpecies; +import org.nuiton.csv.ValueSetter; +import org.nuiton.csv.ext.AbstractImportExportModel; + +import java.util.Collection; +import java.util.Map; + +/** + * @author kmorin <kmorin@codelutin.com> + * @since 0.1 + */ +public class CalcifiedPartTakingRowModel extends AbstractImportExportModel<CalcifiedPartTaking> { + + private static final String TAG = "CalcifiedPartTakingRowModel"; + + public CalcifiedPartTakingRowModel(char separator, Collection<ScientificSpecies> scientificSpecies) { + + super(separator); + + final Map<String, ScientificSpecies> scientificSpeciesByCode = Maps.uniqueIndex(scientificSpecies, new Function<ScientificSpecies, String>() { + @Override + public String apply(ScientificSpecies input) { + return input.getCode(); + } + }); + + newMandatoryColumn("Espece_scientifique", new ValueSetter<CalcifiedPartTaking, String>() { + @Override + public void set(CalcifiedPartTaking object, String value) throws Exception { + if (value == null) { + throw new NullPointerException("L'espece scientifique ne peut etre nulle"); + } + ScientificSpecies species = scientificSpeciesByCode.get(value); + object.setParent(species); + } + }); + + newMandatoryColumn("Classe_debut", new ValueSetter<CalcifiedPartTaking, String>() { + @Override + public void set(CalcifiedPartTaking object, String value) throws Exception { + Integer size; + try { + size = Integer.parseInt(value); + } catch (NumberFormatException e) { + size = null; + } + Log.d(TAG, object + "setStartSize " + size); + object.setStartSize(size); + } + }); + + newMandatoryColumn("Classe_fin", new ValueSetter<CalcifiedPartTaking, String>() { + @Override + public void set(CalcifiedPartTaking object, String value) throws Exception { + Integer size; + try { + size = Integer.parseInt(value); + } catch (NumberFormatException e) { + size = null; + } + Log.d(TAG, object + "setEndSize " + size); + object.setEndSize(size); + } + }); + + newMandatoryColumn("Pas_de_classe", new ValueSetter<CalcifiedPartTaking, String>() { + @Override + public void set(CalcifiedPartTaking object, String value) throws Exception { + Integer size = Integer.parseInt(value); + Log.d(TAG, object + "setSizeStep " + size); + object.setSizeStep(size); + } + }); + + newMandatoryColumn("Pas", new ValueSetter<CalcifiedPartTaking, String>() { + @Override + public void set(CalcifiedPartTaking object, String value) throws Exception { + Integer size = Integer.parseInt(value); + Log.d(TAG, object + "setStep " + size); + object.setStep(size); + } + }); + + newMandatoryColumn("Arret", new ValueSetter<CalcifiedPartTaking, String>() { + @Override + public void set(CalcifiedPartTaking object, String value) throws Exception { + Integer size; + try { + size = Integer.parseInt(value); + } catch (NumberFormatException e) { + size = null; + } + Log.d(TAG, object + "setStop " + size); + object.setStop(size); + } + }); + } + + @Override + public CalcifiedPartTaking newEmptyInstance() { + return new CalcifiedPartTaking(); + } +} Modified: trunk/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java =================================================================== --- trunk/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java 2014-02-23 17:32:50 UTC (rev 54) +++ trunk/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java 2014-02-28 13:13:35 UTC (rev 55) @@ -35,6 +35,8 @@ import com.google.common.collect.Lists; import fr.ifremer.wlo.R; import fr.ifremer.wlo.models.BaseModel; +import fr.ifremer.wlo.models.calcifiedPartTaking.CalcifiedPartTaking; +import fr.ifremer.wlo.models.calcifiedPartTaking.CalcifiedPartTakingRowModel; import fr.ifremer.wlo.models.referentials.HasCode; import fr.ifremer.wlo.storage.DataCache; import fr.ifremer.wlo.storage.WloSqlOpenHelper; @@ -49,6 +51,7 @@ import java.io.InputStream; import java.io.StringWriter; import java.nio.charset.Charset; +import java.util.ArrayList; import java.util.Collection; /** @@ -237,8 +240,23 @@ return result; } + public static int importCalcifiedPartTakings(Context context, String path) { + try { + return importCalcifiedPartTakings(context, new FileInputStream(path)); + } catch (FileNotFoundException e) { + Log.e(TAG, "File " + path + " not found", e); + } + return 0; + } + + public static int importCalcifiedPartTakings(Context context, InputStream inputStream) { + CalcifiedPartTakingRowModel calcifiedPartTakingRowModel = new CalcifiedPartTakingRowModel(CSV_SEPARATOR, DataCache.getAllScientificSpecies(context)); + int result = importData(context, calcifiedPartTakingRowModel, inputStream, new ArrayList<CalcifiedPartTaking>()); + return result; + } + protected static <M extends BaseModel> int importData(Context context, ImportModel<M> importModel, - InputStream inputStream, final Collection<M> actualReferential) { + InputStream inputStream, final Collection<M> actualReferential) { Preconditions.checkNotNull(actualReferential); Import<M> importer = null; Collection<M> models = null; Modified: trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java =================================================================== --- trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java 2014-02-23 17:32:50 UTC (rev 54) +++ trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java 2014-02-28 13:13:35 UTC (rev 55) @@ -88,6 +88,8 @@ protected static final int REQUEST_IMPORT_SCIENTIFIC_SPECIES = 8; protected static final int REQUEST_IMPORT_STATES = 9; protected static final int REQUEST_IMPORT_VESSELS = 10; + protected static final int REQUEST_IMPORT_CALCIFIED_PARTS_TAKINGS = 11; + @Override protected Integer getContentView() { return null; @@ -133,6 +135,7 @@ requestCodeByPrefKey.put("import_scientific_species", REQUEST_IMPORT_SCIENTIFIC_SPECIES); requestCodeByPrefKey.put("import_states", REQUEST_IMPORT_STATES); requestCodeByPrefKey.put("import_vessels", REQUEST_IMPORT_VESSELS); + requestCodeByPrefKey.put("import_calcified_parts_takings", REQUEST_IMPORT_CALCIFIED_PARTS_TAKINGS); Map<String, Integer> nbElementsByPrefKey = Maps.newHashMap(); Context context = getActivity(); @@ -151,7 +154,10 @@ for (String key : requestCodeByPrefKey.keySet()) { final Integer requestCode = requestCodeByPrefKey.get(key); Preference filePicker = findPreference(key); - filePicker.setSummary(getString(R.string.preferences_import_summary, nbElementsByPrefKey.get(key))); + Integer nb = nbElementsByPrefKey.get(key); + if (nb != null) { + filePicker.setSummary(getString(R.string.preferences_import_summary, nb)); + } filePicker.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { @@ -234,7 +240,7 @@ @Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { if (resultCode == RESULT_OK - && requestCode >= REQUEST_IMPORT_AGES && requestCode <= REQUEST_IMPORT_VESSELS) { + && requestCode >= REQUEST_IMPORT_AGES && requestCode <= REQUEST_IMPORT_CALCIFIED_PARTS_TAKINGS) { Context context = getActivity(); if (!StorageUtils.isExternalStorageWritable()) { @@ -273,8 +279,8 @@ public void run() { String path = data.getStringExtra(FileDialog.RESULT_PATH); Log.d(TAG, path); - final int updatedNb; - final int newNb; + final Integer updatedNb; + final Integer newNb; try { switch (requestCode) { @@ -322,9 +328,16 @@ newNb = ImportUtil.importVessels(context, path); updatedNb = DataCache.getAllVessels(context).size(); break; + case REQUEST_IMPORT_CALCIFIED_PARTS_TAKINGS: + WloSqlOpenHelper soh = new WloSqlOpenHelper(context); + soh.clearCalcifiedPartTakings(); + soh.close(); + newNb = ImportUtil.importCalcifiedPartTakings(context, path); + updatedNb = null; + break; default: - newNb = 0; - updatedNb = 0; + newNb = null; + updatedNb = null; } if (backupFile) { @@ -343,10 +356,13 @@ @Override public void run() { dialog.dismiss(); - String key = requestCodeByPrefKey.inverse().get(requestCode); - Preference filePicker = findPreference(key); - filePicker.setSummary(getString(R.string.preferences_import_summary, updatedNb)); + if (updatedNb != null) { + String key = requestCodeByPrefKey.inverse().get(requestCode); + Preference filePicker = findPreference(key); + filePicker.setSummary(getString(R.string.preferences_import_summary, updatedNb)); + } + Toast.makeText(context, context.getString(R.string.import_new_element_number, newNb), Toast.LENGTH_SHORT).show(); } }); Modified: trunk/src/fr/ifremer/wlo/storage/Exporter.java =================================================================== --- trunk/src/fr/ifremer/wlo/storage/Exporter.java 2014-02-23 17:32:50 UTC (rev 54) +++ trunk/src/fr/ifremer/wlo/storage/Exporter.java 2014-02-28 13:13:35 UTC (rev 55) @@ -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 com.google.common.base.Function; Modified: trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java =================================================================== --- trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-02-23 17:32:50 UTC (rev 54) +++ trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-02-28 13:13:35 UTC (rev 55) @@ -28,10 +28,10 @@ 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; -import com.google.common.collect.Sets; import fr.ifremer.wlo.models.BaseModel; import fr.ifremer.wlo.models.CategoryWeightModel; import fr.ifremer.wlo.models.CommercialSpeciesModel; @@ -41,6 +41,7 @@ import fr.ifremer.wlo.models.MetierModel; import fr.ifremer.wlo.models.ScientificSpeciesModel; import fr.ifremer.wlo.models.VesselModel; +import fr.ifremer.wlo.models.calcifiedPartTaking.CalcifiedPartTaking; import fr.ifremer.wlo.models.referentials.Age; import fr.ifremer.wlo.models.referentials.CommercialSpecies; import fr.ifremer.wlo.models.referentials.Gender; @@ -55,7 +56,6 @@ import java.util.Collection; import java.util.List; -import java.util.Set; import java.util.UUID; /** @@ -67,11 +67,12 @@ private static final String TAG = "WloOpenHelper"; public static final String DATABASE_NAME = "wlo.db"; - public static final int DATABASE_VERSION = 17; + public static final int DATABASE_VERSION = 18; public static final String TEXT_TYPE = " TEXT"; - public static final String BIGINT_TYPE = " BIGINT"; - public static final String BYTE_TYPE = " BYTE"; + public static final String INTEGER_TYPE = " INTEGER"; + public static final String NUMERIC_TYPE = " NUMERIC"; + public static final String REAL_TYPE = " REAL"; public static final String COMMA_SEP = ","; public static final String NOT_NULL = " NOT NULL"; @@ -92,8 +93,8 @@ "CREATE TABLE " + LocationModel.TABLE_NAME + " (" + LocationModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP + LocationModel.COLUMN_OPERATOR + TEXT_TYPE + COMMA_SEP + - LocationModel.COLUMN_START_DATE + BIGINT_TYPE + COMMA_SEP + - LocationModel.COLUMN_END_DATE + BIGINT_TYPE + COMMA_SEP + + LocationModel.COLUMN_START_DATE + INTEGER_TYPE + COMMA_SEP + + LocationModel.COLUMN_END_DATE + INTEGER_TYPE + COMMA_SEP + LocationModel.COLUMN_LOCATION + TEXT_TYPE + NOT_NULL + COMMA_SEP + LocationModel.COLUMN_COMMENT + TEXT_TYPE + COMMA_SEP + LocationModel.COLUMN_CONTEXT_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP + @@ -112,7 +113,7 @@ VesselModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP + VesselModel.COLUMN_REGISTRATION_NUMBER + TEXT_TYPE + COMMA_SEP + VesselModel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP + - VesselModel.COLUMN_LANDING_DATE + BIGINT_TYPE + COMMA_SEP + + VesselModel.COLUMN_LANDING_DATE + INTEGER_TYPE + COMMA_SEP + VesselModel.COLUMN_LANDING_LOCATION + TEXT_TYPE + COMMA_SEP + VesselModel.COLUMN_COMMENT + TEXT_TYPE + COMMA_SEP + VesselModel.COLUMN_LOCATION_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP + @@ -150,12 +151,12 @@ CommercialSpeciesModel.COLUMN_FAO_CODE + TEXT_TYPE + COMMA_SEP + CommercialSpeciesModel.COLUMN_MEASUREMENT_METHOD + TEXT_TYPE + COMMA_SEP + CommercialSpeciesModel.COLUMN_PRECISION + TEXT_TYPE + COMMA_SEP + - CommercialSpeciesModel.COLUMN_SPECIES_MIX + BYTE_TYPE + COMMA_SEP + + CommercialSpeciesModel.COLUMN_SPECIES_MIX + NUMERIC_TYPE + COMMA_SEP + CommercialSpeciesModel.COLUMN_SORT_CATEGORY + TEXT_TYPE + COMMA_SEP + CommercialSpeciesModel.COLUMN_STATE + TEXT_TYPE + COMMA_SEP + CommercialSpeciesModel.COLUMN_PRESENTATION + TEXT_TYPE + COMMA_SEP + CommercialSpeciesModel.COLUMN_COMMENT + TEXT_TYPE + COMMA_SEP + - CommercialSpeciesModel.COLUMN_TOTAL_UNLOADED_WEIGHT + BIGINT_TYPE + COMMA_SEP + + CommercialSpeciesModel.COLUMN_TOTAL_UNLOADED_WEIGHT + INTEGER_TYPE + COMMA_SEP + CommercialSpeciesModel.COLUMN_METIER_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP + "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_METIER_ID + ") REFERENCES " + MetierModel.TABLE_NAME + "(" + MetierModel._ID + ") ON DELETE CASCADE" + COMMA_SEP + @@ -177,10 +178,10 @@ "CREATE TABLE " + ScientificSpeciesModel.TABLE_NAME + " (" + ScientificSpeciesModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP + ScientificSpeciesModel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP + - ScientificSpeciesModel.COLUMN_TAKING_ACTIVATION + BYTE_TYPE + COMMA_SEP + + ScientificSpeciesModel.COLUMN_TAKING_ACTIVATION + NUMERIC_TYPE + COMMA_SEP + ScientificSpeciesModel.COLUMN_COMMENT + TEXT_TYPE + COMMA_SEP + - ScientificSpeciesModel.COLUMN_SORTED_WEIGHT + BIGINT_TYPE + COMMA_SEP + - ScientificSpeciesModel.COLUMN_SAMPLE_WEIGHT + BIGINT_TYPE + COMMA_SEP + + ScientificSpeciesModel.COLUMN_SORTED_WEIGHT + INTEGER_TYPE + COMMA_SEP + + ScientificSpeciesModel.COLUMN_SAMPLE_WEIGHT + INTEGER_TYPE + COMMA_SEP + ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP + "FOREIGN KEY(" + ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + ") REFERENCES " + CommercialSpeciesModel.TABLE_NAME + "(" + CommercialSpeciesModel._ID + ") ON DELETE CASCADE" + COMMA_SEP + @@ -195,8 +196,8 @@ protected static final String SQL_CREATE_MEASUREMENTS = "CREATE TABLE " + MeasurementModel.TABLE_NAME + " (" + MeasurementModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP + - MeasurementModel.COLUMN_SIZE + BIGINT_TYPE + COMMA_SEP + - MeasurementModel.COLUMN_DATE + BIGINT_TYPE + COMMA_SEP + + MeasurementModel.COLUMN_SIZE + INTEGER_TYPE + COMMA_SEP + + MeasurementModel.COLUMN_DATE + INTEGER_TYPE + COMMA_SEP + MeasurementModel.COLUMN_CATEGORY_1 + TEXT_TYPE + COMMA_SEP + MeasurementModel.COLUMN_CATEGORY_2 + TEXT_TYPE + COMMA_SEP + MeasurementModel.COLUMN_CATEGORY_3 + TEXT_TYPE + COMMA_SEP + @@ -215,7 +216,7 @@ CategoryWeightModel.COLUMN_CATEGORY_1 + TEXT_TYPE + COMMA_SEP + CategoryWeightModel.COLUMN_CATEGORY_2 + TEXT_TYPE + COMMA_SEP + CategoryWeightModel.COLUMN_CATEGORY_3 + TEXT_TYPE + COMMA_SEP + - CategoryWeightModel.COLUMN_WEIGHT + BIGINT_TYPE + COMMA_SEP + + CategoryWeightModel.COLUMN_WEIGHT + INTEGER_TYPE + COMMA_SEP + CategoryWeightModel.COLUMN_SCIENTIFIC_SPECIES_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP + "FOREIGN KEY(" + CategoryWeightModel.COLUMN_SCIENTIFIC_SPECIES_ID + ") REFERENCES " + ScientificSpeciesModel.TABLE_NAME + "(" + ScientificSpeciesModel._ID + ") ON DELETE CASCADE" + @@ -224,6 +225,23 @@ protected static final String SQL_DELETE_CATEGORY_WEIGHTS = "DROP TABLE IF EXISTS " + CategoryWeightModel.TABLE_NAME; + // CALCIFIED PART TAKING + protected static final String SQL_CREATE_CALCIFIED_PART_TAKINGS = + "CREATE TABLE " + CalcifiedPartTaking.TABLE_NAME + " (" + + CalcifiedPartTaking._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP + + CalcifiedPartTaking.COLUMN_START_SIZE + INTEGER_TYPE + COMMA_SEP + + CalcifiedPartTaking.COLUMN_END_SIZE + INTEGER_TYPE + COMMA_SEP + + CalcifiedPartTaking.COLUMN_SIZE_STEP + INTEGER_TYPE + COMMA_SEP + + CalcifiedPartTaking.COLUMN_STEP + INTEGER_TYPE + COMMA_SEP + + CalcifiedPartTaking.COLUMN_STOP + INTEGER_TYPE + COMMA_SEP + + CalcifiedPartTaking.COLUMN_SCIENTIFIC_SPECIES_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP + + "FOREIGN KEY(" + CalcifiedPartTaking.COLUMN_SCIENTIFIC_SPECIES_ID + ") REFERENCES " + + ScientificSpecies.TABLE_NAME + "(" + ScientificSpecies._ID + ") ON DELETE CASCADE" + + " )"; + + protected static final String SQL_DELETE_CALCIFIED_PART_TAKINGS = + "DROP TABLE IF EXISTS " + CalcifiedPartTaking.TABLE_NAME; + // Referentials // Ages @@ -247,7 +265,7 @@ CommercialSpecies.COLUMN_FRENCH_LABEL + TEXT_TYPE + COMMA_SEP + CommercialSpecies.COLUMN_FAMILY + TEXT_TYPE + COMMA_SEP + CommercialSpecies.COLUMN_SPECIES_ORDER + TEXT_TYPE + COMMA_SEP + - CommercialSpecies.COLUMN_ACTIVE + BYTE_TYPE + + CommercialSpecies.COLUMN_ACTIVE + NUMERIC_TYPE + " )"; protected static final String SQL_DELETE_REF_COMMERCIAL_SPECIES = @@ -308,8 +326,8 @@ Metier.COLUMN_GEAR_LABEL + TEXT_TYPE + COMMA_SEP + Metier.COLUMN_SPECIES_CODE + TEXT_TYPE + COMMA_SEP + Metier.COLUMN_SPECIES_LABEL + TEXT_TYPE + COMMA_SEP + - Metier.COLUMN_FISHING + BYTE_TYPE + COMMA_SEP + - Metier.COLUMN_ACTIVE + BYTE_TYPE + + Metier.COLUMN_FISHING + NUMERIC_TYPE + COMMA_SEP + + Metier.COLUMN_ACTIVE + NUMERIC_TYPE + " )"; protected static final String SQL_DELETE_REF_METIERS = @@ -390,12 +408,14 @@ db.execSQL(SQL_CREATE_SCIENTIFIC_SPECIES); db.execSQL(SQL_CREATE_MEASUREMENTS); db.execSQL(SQL_CREATE_CATEGORY_WEIGHTS); + db.execSQL(SQL_CREATE_CALCIFIED_PART_TAKINGS); } @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); db.execSQL(SQL_DELETE_MEASUREMENTS); db.execSQL(SQL_DELETE_SCIENTIFIC_SPECIES); @@ -549,6 +569,21 @@ return cursor; } + // CALCIFIED PART TAKING + + public Cursor getAllCalcifiedPartTakings(String scientificSpeciesId) { + SQLiteDatabase db = getReadableDatabase(); + Cursor cursor = db.query(CalcifiedPartTaking.TABLE_NAME, CalcifiedPartTaking.ALL_COLUMNS, + CalcifiedPartTaking.COLUMN_SCIENTIFIC_SPECIES_ID + " = ?", new String[]{ scientificSpeciesId }, + null, null, CalcifiedPartTaking.COLUMN_START_SIZE + " ASC"); + return cursor; + } + + public void clearCalcifiedPartTakings() { + SQLiteDatabase db = getWritableDatabase(); + db.delete(CalcifiedPartTaking.TABLE_NAME, null, null); + } + // Referentials public Cursor getAllRefAges() { Modified: trunk/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java =================================================================== --- trunk/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java 2014-02-23 17:32:50 UTC (rev 54) +++ trunk/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java 2014-02-28 13:13:35 UTC (rev 55) @@ -88,7 +88,7 @@ /** * Parametro de entrada da Activity: tipo de selecao: pode criar novos paths * ou nao. Padrao: nao permite. - * + * * @see {@link SelectionMode} */ public static final String SELECTION_MODE = "SELECTION_MODE"; @@ -224,7 +224,7 @@ /** * Monta a estrutura de arquivos e diretorios filhos do diretorio fornecido. - * + * * @param dirPath * Diretorio pai. */ @@ -385,7 +385,7 @@ /** * Define se o botao de CREATE e visivel. - * + * * @param v */ private void setCreateVisible(View v) { @@ -398,7 +398,7 @@ /** * Define se o botao de SELECT e visivel. - * + * * @param v */ private void setSelectVisible(View v) {
participants (1)
-
kmorin@users.forge.codelutin.com