r47 - in trunk: . res/drawable res/layout res/menu res/values res/values-fr src/fr/ifremer/wlo src/fr/ifremer/wlo/models src/fr/ifremer/wlo/preferences src/fr/ifremer/wlo/storage src/fr/ifremer/wlo/utils
Author: kmorin Date: 2014-02-13 22:28:40 +0100 (Thu, 13 Feb 2014) New Revision: 47 Url: http://forge.codelutin.com/projects/wlo/repository/revisions/47 Log: refs #4192 [SAISIE] ?\195?\137cran des poids [niveau 5 ?\195?\160 7] Added: trunk/proguard.cfg trunk/res/drawable/weight.png trunk/res/layout/weights.xml trunk/res/menu/weight_menu.xml trunk/src/fr/ifremer/wlo/WeightsActivity.java trunk/src/fr/ifremer/wlo/models/CategoryWeightModel.java Modified: trunk/AndroidManifest.xml trunk/pom.xml trunk/res/values-fr/strings.xml trunk/res/values/strings.xml trunk/src/fr/ifremer/wlo/ScientificSpeciesActivity.java trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java trunk/src/fr/ifremer/wlo/preferences/WloMultiSelectListPreference.java trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextViewWithFavorites.java Modified: trunk/AndroidManifest.xml =================================================================== --- trunk/AndroidManifest.xml 2014-02-04 18:31:27 UTC (rev 46) +++ trunk/AndroidManifest.xml 2014-02-13 21:28:40 UTC (rev 47) @@ -108,6 +108,10 @@ android:noHistory="true" android:configChanges="orientation|screenSize|keyboardHidden"/> + <activity android:name=".WeightsActivity" + android:label="@string/weights_title" + android:configChanges="orientation|screenSize|keyboardHidden"/> + <activity android:name=".preferences.SettingsActivity" android:label="@string/main_settings" android:configChanges="orientation|screenSize|keyboardHidden"/> Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2014-02-04 18:31:27 UTC (rev 46) +++ trunk/pom.xml 2014-02-13 21:28:40 UTC (rev 47) @@ -254,6 +254,10 @@ <!--<path>${env.ANDROID_HOME}</path>--> <platform>15</platform> </sdk> + <extractDuplicates>true</extractDuplicates> + <!--<sign>--> + <!--<debug>false</debug>--> + <!--</sign>--> <!--<device>emulator</device>--> <device>usb</device> <zipalign> @@ -266,7 +270,9 @@ ${project.build.directory}/${project.artifactId}-${project.version}-aligned.apk </outputApk> </zipalign> - <extractDuplicates>true</extractDuplicates> + <proguard> + <skip>true</skip> <!-- android.proguard.skip --> + </proguard> </configuration> <extensions>true</extensions> </plugin> Added: trunk/proguard.cfg =================================================================== --- trunk/proguard.cfg (rev 0) +++ trunk/proguard.cfg 2014-02-13 21:28:40 UTC (rev 47) @@ -0,0 +1,10 @@ +-dontoptimize +-dontobfuscate +-dontwarn javax.annotation.** +-dontwarn javax.inject.** +-dontwarn sun.misc.Unsafe +-dontwarn com.google.common.collect.MinMaxPriorityQueue + +-keepclasseswithmembers public class * { + public static void main(java.lang.String[]); +} \ No newline at end of file Added: trunk/res/drawable/weight.png =================================================================== (Binary files differ) Property changes on: trunk/res/drawable/weight.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/res/layout/weights.xml =================================================================== --- trunk/res/layout/weights.xml (rev 0) +++ trunk/res/layout/weights.xml 2014-02-13 21:28:40 UTC (rev 47) @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <ScrollView android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:fillViewport="true"> + + <LinearLayout android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <TextView android:text="@string/commercial_species_total_unloaded_weight" + android:layout_width="match_parent" + android:layout_height="wrap_content"/> + + <EditText android:id="@+id/total_unloaded_weight" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:inputType="numberDecimal"/> + + </LinearLayout> + + </ScrollView> + + <LinearLayout android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="bottom"> + + <Button android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="@android:string/cancel" + android:onClick="cancel" /> + + <Button android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="@android:string/ok" + android:onClick="validate" /> + + </LinearLayout> + +</LinearLayout> \ No newline at end of file Added: trunk/res/menu/weight_menu.xml =================================================================== --- trunk/res/menu/weight_menu.xml (rev 0) +++ trunk/res/menu/weight_menu.xml 2014-02-13 21:28:40 UTC (rev 47) @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> + +<menu xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:wlo="http://schemas.android.com/apk/res-auto"> + + <item android:id="@+id/weights" + android:icon="@drawable/weight" + wlo:showAsAction="always" /> + +</menu> \ No newline at end of file Modified: trunk/res/values/strings.xml =================================================================== --- trunk/res/values/strings.xml 2014-02-04 18:31:27 UTC (rev 46) +++ trunk/res/values/strings.xml 2014-02-13 21:28:40 UTC (rev 47) @@ -168,6 +168,10 @@ <string name="exit_form_confirmation">Do you want to save the form before leaving?</string> + <!-- Weights --> + <string name="weights_title">Weights</string> + <string name="commercial_species_total_unloaded_weight">Total unloaded weight</string> + <!--File chooser--> <string name="file_chooser_location">Location</string> <string name="file_chooser_cant_read_folder">folder can\'t be read!</string> Modified: trunk/res/values-fr/strings.xml =================================================================== --- trunk/res/values-fr/strings.xml 2014-02-04 18:31:27 UTC (rev 46) +++ trunk/res/values-fr/strings.xml 2014-02-13 21:28:40 UTC (rev 47) @@ -161,6 +161,10 @@ <string name="exit_form_confirmation">Voulez-vous sauvegarder les données avant de quitter le formulaire ?</string> + <!-- Weights --> + <string name="weights_title">Poids</string> + <string name="commercial_species_total_unloaded_weight">Poids total débarqué</string> + <!--File chooser--> <string name="file_chooser_location">Emplacement</string> <string name="file_chooser_cant_read_folder">Le dossier est illisible !</string> Modified: trunk/src/fr/ifremer/wlo/ScientificSpeciesActivity.java =================================================================== --- trunk/src/fr/ifremer/wlo/ScientificSpeciesActivity.java 2014-02-04 18:31:27 UTC (rev 46) +++ trunk/src/fr/ifremer/wlo/ScientificSpeciesActivity.java 2014-02-13 21:28:40 UTC (rev 47) @@ -30,6 +30,7 @@ import android.util.Log; import android.view.Menu; import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.widget.ListView; import com.google.common.collect.Maps; @@ -58,10 +59,11 @@ @Override public boolean onCreateOptionsMenu(Menu menu) { CommercialSpeciesModel parent = (CommercialSpeciesModel) parentModel; + MenuInflater inflater = getMenuInflater(); if (parent.isSpeciesMix() || adapter.getCount() == 0) { - MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.model_list_menu, menu); } + inflater.inflate(R.menu.weight_menu, menu); return true; } @@ -77,6 +79,18 @@ } @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.weights: + Intent intent = new Intent(this, WeightsActivity.class); + intent.putExtra(WeightsActivity.INTENT_COMMERCIAL_SPECIES, parentModel); + startActivity(intent); + return true; + } + return super.onOptionsItemSelected(item); + } + + @Override protected Class<? extends WloModelEditionActivity> getEditionActivity() { return ScientificSpeciesFormActivity.class; } Added: trunk/src/fr/ifremer/wlo/WeightsActivity.java =================================================================== --- trunk/src/fr/ifremer/wlo/WeightsActivity.java (rev 0) +++ trunk/src/fr/ifremer/wlo/WeightsActivity.java 2014-02-13 21:28:40 UTC (rev 47) @@ -0,0 +1,80 @@ +package fr.ifremer.wlo; + +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.EditText; +import com.google.common.collect.Multimap; +import fr.ifremer.wlo.models.BaseModel; +import fr.ifremer.wlo.models.CommercialSpeciesModel; +import fr.ifremer.wlo.storage.WloSqlOpenHelper; +import fr.ifremer.wlo.utils.BaseTextWatcher; +import org.apache.commons.lang3.StringUtils; + +import java.lang.reflect.InvocationTargetException; +import java.util.Collection; + +/** + * @author Kevin Morin (Code Lutin) + * @since x.x + */ +public class WeightsActivity extends WloBaseActivity { + + private static final String TAG = "WeightsActivity"; + + public static final String INTENT_COMMERCIAL_SPECIES = "commercialSpecies"; + + protected CommercialSpeciesModel commercialSpeciesModel; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + commercialSpeciesModel = (CommercialSpeciesModel) getIntent().getSerializableExtra(INTENT_COMMERCIAL_SPECIES); + getSupportActionBar().setSubtitle(commercialSpeciesModel.toString(this)); + + final EditText totalUnloadedWeightText = (EditText) findViewById(R.id.total_unloaded_weight); + Log.d(TAG, "TotalUnloadedWeight " + commercialSpeciesModel.getTotalUnloadedWeight()); + totalUnloadedWeightText.setText(String.valueOf(commercialSpeciesModel.getTotalUnloadedWeight())); + totalUnloadedWeightText.addTextChangedListener(new BaseTextWatcher() { + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + Integer newValue = null; + Log.d(TAG, "onTextChanged " + s); + if (StringUtils.isNotEmpty(s)) { + newValue = Integer.parseInt(s.toString()); + } + Log.d(TAG, "TotalUnloadedWeight " + newValue); + commercialSpeciesModel.setTotalUnloadedWeight(newValue); + totalUnloadedWeightText.setSelection(start + count); + } + + }); + } + + @Override + protected Integer getContentView() { + return R.layout.weights; + } + + @Override + protected Class<? extends WloBaseActivity> getUpActivity() { + return ScientificSpeciesActivity.class; + } + + public void validate(View view) { + saveModel(); + finish(); + } + + /* Protected methods */ + + protected void saveModel() { + WloSqlOpenHelper woh = new WloSqlOpenHelper(this); + Log.d(TAG, "TotalUnloadedWeight " + commercialSpeciesModel.getTotalUnloadedWeight()); + woh.saveData(commercialSpeciesModel); + woh.close(); + } + +} Added: trunk/src/fr/ifremer/wlo/models/CategoryWeightModel.java =================================================================== --- trunk/src/fr/ifremer/wlo/models/CategoryWeightModel.java (rev 0) +++ trunk/src/fr/ifremer/wlo/models/CategoryWeightModel.java 2014-02-13 21:28:40 UTC (rev 47) @@ -0,0 +1,102 @@ +package fr.ifremer.wlo.models; + +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import fr.ifremer.wlo.utils.UIUtils; + +/** + * @author Kevin Morin (Code Lutin) + * @since 0.2 + */ +public class CategoryWeightModel extends HierarchicalModel<ScientificSpeciesModel> { + + private static final String TAG = "CategoryWeightModel"; + + public static final String TABLE_NAME = "category_weights"; + public static final String COLUMN_CATEGORY_1 = "category1"; + public static final String COLUMN_CATEGORY_2 = "category2"; + public static final String COLUMN_CATEGORY_3 = "category3"; + public static final String COLUMN_WEIGHT = "weight"; + public static final String COLUMN_SCIENTIFIC_SPECIES_ID = "scientificSpeciesId"; + public static final String[] ALL_COLUMNS = new String[] { + _ID, + COLUMN_CATEGORY_1, + COLUMN_CATEGORY_2, + COLUMN_CATEGORY_3, + COLUMN_WEIGHT, + COLUMN_SCIENTIFIC_SPECIES_ID + }; + + @Override + public String getTableName() { + return TABLE_NAME; + } + + protected String category1; + protected String category2; + protected String category3; + protected int weight; + + public CategoryWeightModel() { + } + + public CategoryWeightModel(Cursor cursor) { + super(cursor); + category1 = cursor.getString(1); + category2 = cursor.getString(2); + category3 = cursor.getString(3); + weight = cursor.getInt(4); + } + public String getCategory1() { + return category1; + } + + public void setCategory1(String category1) { + Object oldValue = this.category1; + this.category1 = category1; + firePropertyChange(COLUMN_CATEGORY_1, oldValue, category1); + } + + public String getCategory2() { + return category2; + } + + public void setCategory2(String category2) { + Object oldValue = this.category2; + this.category2 = category2; + firePropertyChange(COLUMN_CATEGORY_2, oldValue, category2); + } + + public String getCategory3() { + return category3; + } + + public void setCategory3(String category3) { + Object oldValue = this.category3; + this.category3 = category3; + firePropertyChange(COLUMN_CATEGORY_3, oldValue, category3); + } + + public int getWeight() { + return weight; + } + + public void setWeight(int weight) { + Object oldValue = this.weight; + this.weight = weight; + firePropertyChange(COLUMN_WEIGHT, oldValue, weight); + } + + @Override + public ContentValues convertIntoContentValues() { + ContentValues value = super.convertIntoContentValues(); + putValue(value, COLUMN_CATEGORY_1, category1); + putValue(value, COLUMN_CATEGORY_2, category2); + putValue(value, COLUMN_CATEGORY_3, category3); + putValue(value, COLUMN_WEIGHT, weight); + putValue(value, COLUMN_SCIENTIFIC_SPECIES_ID, getParentId()); + return value; + } + +} Modified: trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java =================================================================== --- trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java 2014-02-04 18:31:27 UTC (rev 46) +++ trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java 2014-02-13 21:28:40 UTC (rev 47) @@ -54,6 +54,7 @@ public static final String COLUMN_STATE = "state"; public static final String COLUMN_PRESENTATION = "presentation"; public static final String COLUMN_COMMENT = "comment"; + public static final String COLUMN_TOTAL_UNLOADED_WEIGHT = "totalUnloadedWeight"; public static final String COLUMN_METIER_ID = "metierId"; public static final String[] ALL_COLUMNS = new String[] { _ID, @@ -65,6 +66,7 @@ COLUMN_STATE, COLUMN_PRESENTATION, COLUMN_COMMENT, + COLUMN_TOTAL_UNLOADED_WEIGHT, COLUMN_METIER_ID }; @@ -76,6 +78,7 @@ protected State state; protected Presentation presentation; protected String comment; + protected Integer totalUnloadedWeight; public CommercialSpeciesModel() { } @@ -96,6 +99,7 @@ String presentationId = cursor.getString(7); presentation = DataCache.getPresentationById(context, presentationId); comment = cursor.getString(8); + totalUnloadedWeight = cursor.getInt(9); } public CommercialSpecies getFaoCode() { @@ -179,6 +183,16 @@ firePropertyChange(COLUMN_COMMENT, oldValue, comment); } + public Integer getTotalUnloadedWeight() { + return totalUnloadedWeight; + } + + public void setTotalUnloadedWeight(Integer totalUnloadedWeight) { + Object oldValue = this.totalUnloadedWeight; + this.totalUnloadedWeight = totalUnloadedWeight; + firePropertyChange(COLUMN_TOTAL_UNLOADED_WEIGHT, oldValue, totalUnloadedWeight); + } + @Override public String getTableName() { return TABLE_NAME; @@ -200,6 +214,7 @@ putValue(value, COLUMN_STATE, state != null ? state.getId() : null); putValue(value, COLUMN_PRESENTATION, presentation != null ? presentation.getId() : null); putValue(value, COLUMN_COMMENT, comment); + putValue(value, COLUMN_TOTAL_UNLOADED_WEIGHT, totalUnloadedWeight); putValue(value, COLUMN_METIER_ID, getParentId()); return value; } Modified: trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java =================================================================== --- trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java 2014-02-04 18:31:27 UTC (rev 46) +++ trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java 2014-02-13 21:28:40 UTC (rev 47) @@ -44,18 +44,21 @@ public static final String COLUMN_NAME = "name"; public static final String COLUMN_TAKING_ACTIVATION = "takingActivation"; public static final String COLUMN_COMMENT = "comment"; + public static final String COLUMN_SAMPLE_WEIGHT = "sampleWeight"; public static final String COLUMN_COMMERCIAL_SPECIES_ID = "commercialSpeciesId"; public static final String[] ALL_COLUMNS = new String[] { _ID, COLUMN_NAME, COLUMN_TAKING_ACTIVATION, COLUMN_COMMENT, + COLUMN_SAMPLE_WEIGHT, COLUMN_COMMERCIAL_SPECIES_ID }; protected ScientificSpecies name; protected boolean takingActivation; protected String comment; + protected int sampleWeight; public ScientificSpeciesModel() { } @@ -66,6 +69,7 @@ name = DataCache.getScientificSpeciesById(context, nameId); takingActivation = cursor.getShort(2) > 0; comment = cursor.getString(3); + sampleWeight = cursor.getInt(4); } public ScientificSpecies getName() { @@ -98,6 +102,16 @@ firePropertyChange(COLUMN_COMMENT, oldValue, comment); } + public int getSampleWeight() { + return sampleWeight; + } + + public void setSampleWeight(int sampleWeight) { + Object oldValue = this.sampleWeight; + this.sampleWeight = sampleWeight; + firePropertyChange(COLUMN_SAMPLE_WEIGHT, oldValue, sampleWeight); + } + @Override public String getTableName() { return TABLE_NAME; @@ -114,6 +128,7 @@ putValue(value, COLUMN_NAME, name != null ? name.getId() : null); putValue(value, COLUMN_TAKING_ACTIVATION, takingActivation ? 1 : 0); putValue(value, COLUMN_COMMENT, comment); + putValue(value, COLUMN_SAMPLE_WEIGHT, sampleWeight); putValue(value, COLUMN_COMMERCIAL_SPECIES_ID, getParentId()); return value; } Modified: trunk/src/fr/ifremer/wlo/preferences/WloMultiSelectListPreference.java =================================================================== --- trunk/src/fr/ifremer/wlo/preferences/WloMultiSelectListPreference.java 2014-02-04 18:31:27 UTC (rev 46) +++ trunk/src/fr/ifremer/wlo/preferences/WloMultiSelectListPreference.java 2014-02-13 21:28:40 UTC (rev 47) @@ -1,5 +1,29 @@ package fr.ifremer.wlo.preferences; +/* + * #%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.content.SharedPreferences; import android.preference.MultiSelectListPreference; Modified: trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java =================================================================== --- trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-02-04 18:31:27 UTC (rev 46) +++ trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-02-13 21:28:40 UTC (rev 47) @@ -33,6 +33,7 @@ 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; import fr.ifremer.wlo.models.ContextModel; import fr.ifremer.wlo.models.LocationModel; @@ -66,7 +67,7 @@ private static final String TAG = "WloOpenHelper"; public static final String DATABASE_NAME = "wlo.db"; - public static final int DATABASE_VERSION = 14; + public static final int DATABASE_VERSION = 15; public static final String TEXT_TYPE = " TEXT"; public static final String BIGINT_TYPE = " BIGINT"; @@ -154,6 +155,7 @@ 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_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,6 +179,7 @@ ScientificSpeciesModel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP + ScientificSpeciesModel.COLUMN_TAKING_ACTIVATION + BYTE_TYPE + COMMA_SEP + ScientificSpeciesModel.COLUMN_COMMENT + TEXT_TYPE + COMMA_SEP + + ScientificSpeciesModel.COLUMN_SAMPLE_WEIGHT + BIGINT_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 + @@ -204,7 +207,22 @@ protected static final String SQL_DELETE_MEASUREMENTS = "DROP TABLE IF EXISTS " + MeasurementModel.TABLE_NAME; + // CATEGORY WEIGHTS + protected static final String SQL_CREATE_CATEGORY_WEIGHTS = + "CREATE TABLE " + CategoryWeightModel.TABLE_NAME + " (" + + CategoryWeightModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP + + 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_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" + + " )"; + protected static final String SQL_DELETE_CATEGORY_WEIGHTS = + "DROP TABLE IF EXISTS " + CategoryWeightModel.TABLE_NAME; + // Referentials // Ages @@ -370,12 +388,14 @@ db.execSQL(SQL_CREATE_COMMERCIAL_SPECIES); db.execSQL(SQL_CREATE_SCIENTIFIC_SPECIES); db.execSQL(SQL_CREATE_MEASUREMENTS); + db.execSQL(SQL_CREATE_CATEGORY_WEIGHTS); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { //TODO kmorin 20131129 migrate data before droping the table // models + db.execSQL(SQL_DELETE_CATEGORY_WEIGHTS); db.execSQL(SQL_DELETE_MEASUREMENTS); db.execSQL(SQL_DELETE_SCIENTIFIC_SPECIES); db.execSQL(SQL_DELETE_COMMERCIAL_SPECIES); @@ -502,6 +522,16 @@ } } + // CATEGORY WEIGHTS + + public Cursor getAllCategoryWeigths(String scientificSpeciesId) { + SQLiteDatabase db = getReadableDatabase(); + Cursor cursor = db.query(CategoryWeightModel.TABLE_NAME, CategoryWeightModel.ALL_COLUMNS, + CategoryWeightModel.COLUMN_SCIENTIFIC_SPECIES_ID + " = ?", new String[]{ scientificSpeciesId }, + null, null, null); + return cursor; + } + // Referentials public Cursor getAllRefAges() { @@ -581,25 +611,6 @@ return cursor; } - //TODO remove when tests are over - public void clearReferentials() { - SQLiteDatabase db = getWritableDatabase(); - db.beginTransaction(); - db.delete(Age.TABLE_NAME, null, null); - db.delete(CommercialSpecies.TABLE_NAME, null, null); - db.delete(Gender.TABLE_NAME, null, null); - db.delete(Location.TABLE_NAME, null, null); - db.delete(Maturity.TABLE_NAME, null, null); - db.delete(Mensuration.TABLE_NAME, null, null); - db.delete(Metier.TABLE_NAME, null, null); - db.delete(Presentation.TABLE_NAME, null, null); - db.delete(ScientificSpecies.TABLE_NAME, null, null); - db.delete(State.TABLE_NAME, null, null); - db.delete(Vessel.TABLE_NAME, null, null); - db.setTransactionSuccessful(); - db.endTransaction(); - } - public <M extends BaseModel> void saveData(M model) { saveData(Lists.newArrayList(model)); } Modified: trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextViewWithFavorites.java =================================================================== --- trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextViewWithFavorites.java 2014-02-04 18:31:27 UTC (rev 46) +++ trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextViewWithFavorites.java 2014-02-13 21:28:40 UTC (rev 47) @@ -1,5 +1,29 @@ package fr.ifremer.wlo.utils; +/* + * #%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.util.AttributeSet; import android.util.Log;
participants (1)
-
kmorin@users.forge.codelutin.com